comparison src/core/sat_main.py @ 807:be4c5e24dab9

plugin XEP-0077, plugin XEP-0100, frontends: gateways have been entirely implemented in backend using the new refactored XMLUI and AdvancedListContainer. The now useless code has been removed from frontends.
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:26:03 +0100
parents 5d6c45d6ee1b
children 743b757777d3
comparison
equal deleted inserted replaced
806:5d6c45d6ee1b 807:be4c5e24dab9
152 self.bridge.register("getParams", self.memory.getParams) 152 self.bridge.register("getParams", self.memory.getParams)
153 self.bridge.register("getParamsForCategory", self.memory.getParamsForCategory) 153 self.bridge.register("getParamsForCategory", self.memory.getParamsForCategory)
154 self.bridge.register("getParamsCategories", self.memory.getParamsCategories) 154 self.bridge.register("getParamsCategories", self.memory.getParamsCategories)
155 self.bridge.register("paramsRegisterApp", self.memory.paramsRegisterApp) 155 self.bridge.register("paramsRegisterApp", self.memory.paramsRegisterApp)
156 self.bridge.register("getHistory", self.memory.getHistory) 156 self.bridge.register("getHistory", self.memory.getHistory)
157 self.bridge.register("setPresence", self.setPresence) 157 self.bridge.register("setPresence", self._setPresence)
158 self.bridge.register("subscription", self.subscription) 158 self.bridge.register("subscription", self.subscription)
159 self.bridge.register("addContact", self.addContact) 159 self.bridge.register("addContact", self._addContact)
160 self.bridge.register("updateContact", self.updateContact) 160 self.bridge.register("updateContact", self._updateContact)
161 self.bridge.register("delContact", self.delContact) 161 self.bridge.register("delContact", self._delContact)
162 self.bridge.register("isConnected", self.isConnected) 162 self.bridge.register("isConnected", self.isConnected)
163 self.bridge.register("launchAction", self.launchCallback) 163 self.bridge.register("launchAction", self.launchCallback)
164 self.bridge.register("confirmationAnswer", self.confirmationAnswer) 164 self.bridge.register("confirmationAnswer", self.confirmationAnswer)
165 self.bridge.register("getProgress", self.getProgress) 165 self.bridge.register("getProgress", self.getProgress)
166 self.bridge.register("getMenus", self.getMenus) 166 self.bridge.register("getMenus", self.getMenus)
421 server = self.memory.getParamA("Server", "Connection", profile_key=profile) 421 server = self.memory.getParamA("Server", "Connection", profile_key=profile)
422 self.registerNewAccount(user, password, None, server, id=action_id) 422 self.registerNewAccount(user, password, None, server, id=action_id)
423 else: 423 else:
424 self.actionResult(action_id, "SUPPRESS", {}, profile) 424 self.actionResult(action_id, "SUPPRESS", {}, profile)
425 425
426 def submitForm(self, action, target, fields, profile_key):
427 """submit a form
428 @param target: target jid where we are submitting
429 @param fields: list of tuples (name, value)
430 @return: tuple: (id, deferred)
431 """
432 # FIXME: to be removed
433
434 profile = self.memory.getProfileName(profile_key)
435 assert(profile)
436 to_jid = jid.JID(target)
437
438 iq = compat.IQ(self.profiles[profile].xmlstream, 'set')
439 iq["to"] = target
440 iq["from"] = self.profiles[profile].jid.full()
441 query = iq.addElement(('jabber:iq:register', 'query'))
442 if action == 'SUBMIT':
443 form = tupleList2dataForm(fields)
444 query.addChild(form.toElement())
445 elif action == 'CANCEL':
446 query.addElement('remove')
447 else:
448 error(_("FIXME FIXME FIXME: Unmanaged action (%s) in submitForm") % action)
449 raise NotImplementedError
450
451 deferred = iq.send(target)
452 return (iq['id'], deferred)
453
454 ## Client management ## 426 ## Client management ##
455 427
456 def setParam(self, name, value, category, security_limit, profile_key): 428 def setParam(self, name, value, category, security_limit, profile_key):
457 """set wanted paramater and notice observers""" 429 """set wanted paramater and notice observers"""
458 info(_("setting param: %(name)s=%(value)s in category %(category)s") % {'name': name, 'value': value, 'category': category}) 430 info(_("setting param: %(name)s=%(value)s in category %(category)s") % {'name': name, 'value': value, 'category': category})
589 mess_type=mess_data["type"], 561 mess_type=mess_data["type"],
590 to_jid=mess_data['xml']['to'], 562 to_jid=mess_data['xml']['to'],
591 extra=mess_data['extra'], 563 extra=mess_data['extra'],
592 profile=profile) 564 profile=profile)
593 565
594 def setPresence(self, to="", show="", priority=0, statuses=None, profile_key='@NONE@'): 566 def _setPresence(self, to="", show="", priority=0, statuses=None, profile_key='@NONE@'):
567 return self.setPresence(jid.JID(to) if to else None, show, priority, statuses, profile_key)
568
569 def setPresence(self, to_jid=None, show="", priority=0, statuses=None, profile_key='@NONE@'):
595 """Send our presence information""" 570 """Send our presence information"""
596 if statuses is None: 571 if statuses is None:
597 statuses = {} 572 statuses = {}
598 profile = self.memory.getProfileName(profile_key) 573 profile = self.memory.getProfileName(profile_key)
599 assert(profile) 574 assert(profile)
600 to_jid = jid.JID(to) if to else None
601 self.profiles[profile].presence.available(to_jid, show, statuses, priority) 575 self.profiles[profile].presence.available(to_jid, show, statuses, priority)
602 #XXX: FIXME: temporary fix to work around openfire 3.7.0 bug (presence is not broadcasted to generating resource) 576 #XXX: FIXME: temporary fix to work around openfire 3.7.0 bug (presence is not broadcasted to generating resource)
603 if '' in statuses: 577 if '' in statuses:
604 statuses['default'] = statuses[''] 578 statuses['default'] = statuses['']
605 del statuses[''] 579 del statuses['']
622 elif subs_type == "unsubscribe": 596 elif subs_type == "unsubscribe":
623 self.profiles[profile].presence.unsubscribe(to_jid) 597 self.profiles[profile].presence.unsubscribe(to_jid)
624 elif subs_type == "unsubscribed": 598 elif subs_type == "unsubscribed":
625 self.profiles[profile].presence.unsubscribed(to_jid) 599 self.profiles[profile].presence.unsubscribed(to_jid)
626 600
627 def addContact(self, to, profile_key): 601 def _addContact(self, to_jid_s, profile_key):
602 return self.addContact(jid.JID(to), profile_key)
603
604 def addContact(self, to_jid, profile_key):
628 """Add a contact in roster list""" 605 """Add a contact in roster list"""
629 profile = self.memory.getProfileName(profile_key) 606 profile = self.memory.getProfileName(profile_key)
630 assert(profile) 607 assert(profile)
631 to_jid = jid.JID(to)
632 #self.profiles[profile].roster.addItem(to_jid) #XXX: disabled (cf http://wokkel.ik.nu/ticket/56)) 608 #self.profiles[profile].roster.addItem(to_jid) #XXX: disabled (cf http://wokkel.ik.nu/ticket/56))
633 self.profiles[profile].presence.subscribe(to_jid) 609 self.profiles[profile].presence.subscribe(to_jid)
634 610
635 def updateContact(self, to, name, groups, profile_key): 611 def _updateContact(self, to_jid_s, name, groups, profile_key):
612 return self.updateContact(jid.JID(to_jid_s), name, groups, profile_key)
613
614 def updateContact(self, to_jid, name, groups, profile_key):
636 """update a contact in roster list""" 615 """update a contact in roster list"""
637 profile = self.memory.getProfileName(profile_key) 616 profile = self.memory.getProfileName(profile_key)
638 assert(profile) 617 assert(profile)
639 to_jid = jid.JID(to)
640 groups = set(groups) 618 groups = set(groups)
641 roster_item = RosterItem(to_jid) 619 roster_item = RosterItem(to_jid)
642 roster_item.name = name or None 620 roster_item.name = name or None
643 roster_item.groups = set(groups) 621 roster_item.groups = set(groups)
644 self.profiles[profile].roster.updateItem(roster_item) 622 self.profiles[profile].roster.updateItem(roster_item)
645 623
646 def delContact(self, to, profile_key): 624 def _delContact(self, to_jid_s, profile_key):
625 return self.delContact(jid.JID(to_jid_s), profile_key)
626
627 def delContact(self, to_jid, profile_key):
647 """Remove contact from roster list""" 628 """Remove contact from roster list"""
648 profile = self.memory.getProfileName(profile_key) 629 profile = self.memory.getProfileName(profile_key)
649 assert(profile) 630 assert(profile)
650 to_jid = jid.JID(to)
651 self.profiles[profile].roster.removeItem(to_jid) 631 self.profiles[profile].roster.removeItem(to_jid)
652 self.profiles[profile].presence.unsubscribe(to_jid) 632 self.profiles[profile].presence.unsubscribe(to_jid)
653 633
654 def requestServerDisco(self, feature, jid_=None, cache_only=False, profile_key="@NONE"): 634 def requestServerDisco(self, feature, jid_=None, cache_only=False, profile_key="@NONE"):
655 """Discover if a server or its items offer a given feature 635 """Discover if a server or its items offer a given feature