diff 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
line wrap: on
line diff
--- a/src/core/sat_main.py	Tue Feb 04 18:24:27 2014 +0100
+++ b/src/core/sat_main.py	Tue Feb 04 18:26:03 2014 +0100
@@ -154,11 +154,11 @@
         self.bridge.register("getParamsCategories", self.memory.getParamsCategories)
         self.bridge.register("paramsRegisterApp", self.memory.paramsRegisterApp)
         self.bridge.register("getHistory", self.memory.getHistory)
-        self.bridge.register("setPresence", self.setPresence)
+        self.bridge.register("setPresence", self._setPresence)
         self.bridge.register("subscription", self.subscription)
-        self.bridge.register("addContact", self.addContact)
-        self.bridge.register("updateContact", self.updateContact)
-        self.bridge.register("delContact", self.delContact)
+        self.bridge.register("addContact", self._addContact)
+        self.bridge.register("updateContact", self._updateContact)
+        self.bridge.register("delContact", self._delContact)
         self.bridge.register("isConnected", self.isConnected)
         self.bridge.register("launchAction", self.launchCallback)
         self.bridge.register("confirmationAnswer", self.confirmationAnswer)
@@ -423,34 +423,6 @@
         else:
             self.actionResult(action_id, "SUPPRESS", {}, profile)
 
-    def submitForm(self, action, target, fields, profile_key):
-        """submit a form
-        @param target: target jid where we are submitting
-        @param fields: list of tuples (name, value)
-        @return: tuple: (id, deferred)
-        """
-        # FIXME: to be removed
-
-        profile = self.memory.getProfileName(profile_key)
-        assert(profile)
-        to_jid = jid.JID(target)
-
-        iq = compat.IQ(self.profiles[profile].xmlstream, 'set')
-        iq["to"] = target
-        iq["from"] = self.profiles[profile].jid.full()
-        query = iq.addElement(('jabber:iq:register', 'query'))
-        if action == 'SUBMIT':
-            form = tupleList2dataForm(fields)
-            query.addChild(form.toElement())
-        elif action == 'CANCEL':
-            query.addElement('remove')
-        else:
-            error(_("FIXME FIXME FIXME: Unmanaged action (%s) in submitForm") % action)
-            raise NotImplementedError
-
-        deferred = iq.send(target)
-        return (iq['id'], deferred)
-
     ## Client management ##
 
     def setParam(self, name, value, category, security_limit, profile_key):
@@ -591,13 +563,15 @@
                                        extra=mess_data['extra'],
                                        profile=profile)
 
-    def setPresence(self, to="", show="", priority=0, statuses=None, profile_key='@NONE@'):
+    def _setPresence(self, to="", show="", priority=0, statuses=None, profile_key='@NONE@'):
+        return self.setPresence(jid.JID(to) if to else None, show, priority, statuses, profile_key)
+
+    def setPresence(self, to_jid=None, show="", priority=0, statuses=None, profile_key='@NONE@'):
         """Send our presence information"""
         if statuses is None:
             statuses = {}
         profile = self.memory.getProfileName(profile_key)
         assert(profile)
-        to_jid = jid.JID(to) if to else None
         self.profiles[profile].presence.available(to_jid, show, statuses, priority)
         #XXX: FIXME: temporary fix to work around openfire 3.7.0 bug (presence is not broadcasted to generating resource)
         if '' in statuses:
@@ -624,30 +598,36 @@
         elif subs_type == "unsubscribed":
             self.profiles[profile].presence.unsubscribed(to_jid)
 
-    def addContact(self, to, profile_key):
+    def _addContact(self, to_jid_s, profile_key):
+        return self.addContact(jid.JID(to), profile_key)
+
+    def addContact(self, to_jid, profile_key):
         """Add a contact in roster list"""
         profile = self.memory.getProfileName(profile_key)
         assert(profile)
-        to_jid = jid.JID(to)
         #self.profiles[profile].roster.addItem(to_jid)  #XXX: disabled (cf http://wokkel.ik.nu/ticket/56))
         self.profiles[profile].presence.subscribe(to_jid)
 
-    def updateContact(self, to, name, groups, profile_key):
+    def _updateContact(self, to_jid_s, name, groups, profile_key):
+        return self.updateContact(jid.JID(to_jid_s), name, groups, profile_key)
+
+    def updateContact(self, to_jid, name, groups, profile_key):
         """update a contact in roster list"""
         profile = self.memory.getProfileName(profile_key)
         assert(profile)
-        to_jid = jid.JID(to)
         groups = set(groups)
         roster_item = RosterItem(to_jid)
         roster_item.name = name or None
         roster_item.groups = set(groups)
         self.profiles[profile].roster.updateItem(roster_item)
 
-    def delContact(self, to, profile_key):
+    def _delContact(self, to_jid_s, profile_key):
+        return self.delContact(jid.JID(to_jid_s), profile_key)
+
+    def delContact(self, to_jid, profile_key):
         """Remove contact from roster list"""
         profile = self.memory.getProfileName(profile_key)
         assert(profile)
-        to_jid = jid.JID(to)
         self.profiles[profile].roster.removeItem(to_jid)
         self.profiles[profile].presence.unsubscribe(to_jid)