changeset 66:8147b4f40809

SàT: multi-profile: DBus signals and frontend adaptation (first draft) - Quick App: new single_profile parameter in __init__ (default: yes), used to tell if the application use only one profile at the time or not - Quick App: new __check_profile method, tell if the profile is used by the current frontend - Quick App: new methods plug_profile, unplug_profile and clear_profile, must be called by the frontend to tell which profiles to use - DBus Bridge: new methods getProfileName, getProfilesList and createProfile
author Goffi <goffi@goffi.org>
date Wed, 03 Feb 2010 23:35:57 +1100
parents d35c5edab53f
children 0e50dd3a234a
files frontends/quick_frontend/quick_app.py frontends/quick_frontend/quick_contact_management.py frontends/sat_bridge_frontend/DBus.py frontends/wix/chat.py frontends/wix/main_window.py plugins/plugin_xep_0054.py sat.tac sat_bridge/DBus.py tools/memory.py
diffstat 9 files changed, 173 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/quick_frontend/quick_app.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/frontends/quick_frontend/quick_app.py	Wed Feb 03 23:35:57 2010 +1100
@@ -27,8 +27,10 @@
 class QuickApp():
     """This class contain the main methods needed for the frontend"""
 
-    def __init__(self):
+    def __init__(self, single_profile=True):
         self.rosterList = {}
+        self.profiles = {}
+        self.single_profile = single_profile
         
         ## bridge ##
         self.bridge=DBusBridgeFrontend()
@@ -45,70 +47,113 @@
         self.bridge.register("actionResult", self.actionResult, "request")
         self.bridge.register("actionResultExt", self.actionResult, "request")
         
+        self.current_action_ids = set()
+        self.current_action_ids_cb = {}
+    
+    def __check_profile(self, profile):
+        """Tell if the profile is currently followed by the application"""
+        return profile in self.profiles.keys()
+
+    def plug_profile(self, profile_key='@DEFAULT@'):
+        """Tell application which profile must be used"""
+        if self.single_profile and self.profiles:
+            error('There is already one profile plugged (we are in single profile mode) !')
+            return
+        profile = self.bridge.getProfileName(profile_key)
+        if not profile:
+            error("The profile asked doesn't exist")
+        if self.profiles.has_key(profile):
+            warning("The profile is already plugged")
+            return
+        self.profiles[profile]={}
+        if self.single_profile:
+            self.profile = profile
+        
         ###now we get the essential params###
-        self.whoami=JID(self.bridge.getParamA("JabberID","Connection"))
-        self.watched=self.bridge.getParamA("Watched", "Misc").split() #TODO: put this in a plugin
+        self.profiles[profile]['whoami']=JID(self.bridge.getParamA("JabberID","Connection", profile))
+        self.profiles[profile]['watched']=self.bridge.getParamA("Watched", "Misc", profile).split() #TODO: put this in a plugin
 
         ## misc ##
-        self.current_action_ids = set()
-        self.current_action_ids_cb = {}
-        self.onlineContact = set()  #FIXME: temporary
+        self.profiles[profile]['onlineContact'] = set()  #FIXME: temporary
 
-        if self.bridge.isConnected():
+        #TODO: managed multi-profiles here
+        if self.bridge.isConnected(profile):
             self.setStatusOnline(True)
         else:
             self.setStatusOnline(False)
             return
 
         ### now we fill the contact list ###
-        for contact in self.bridge.getContacts():
-            self.newContact(contact[0], contact[1], contact[2])
+        for contact in self.bridge.getContacts(profile):
+            self.newContact(contact[0], contact[1], contact[2], profile)
 
-        presences = self.bridge.getPresenceStatus()
+        presences = self.bridge.getPresenceStatus(profile)
         for contact in presences:
             for res in presences[contact]:
                 jabber_id = contact+('/'+res if res else '')
                 show = presences[contact][res][0]
                 priority = presences[contact][res][1]
                 statuses = presences[contact][res][2]
-                self.presenceUpdate(jabber_id, show, priority, statuses)
+                self.presenceUpdate(jabber_id, show, priority, statuses, profile)
 
-        waitingSub = self.bridge.getWaitingSub()
+        waitingSub = self.bridge.getWaitingSub(profile)
         for sub in waitingSub:
-            self.subscribe(waitingSub[sub], sub)
-
+            self.subscribe(waitingSub[sub], sub, profile)
 
-    def connected(self):
+    def unplug_profile(self, profile):
+        """Tell the application to not follow anymore the profile"""
+        if not profile in self.profiles:
+            warning ("This profile is not plugged")
+            return
+        self.profiles.remove(profile)
+
+    def clear_profile(self):
+        self.profiles.clear()
+
+    def connected(self, profile):
         """called when the connection is made"""
+        if not self.__check_profile(profile):
+            return
         debug("Connected")
         self.setStatusOnline(True)
 
-    def disconnected(self):
+    def disconnected(self, profile):
         """called when the connection is closed"""
+        if not self.__check_profile(profile):
+            return
         debug("Disconnected")
         self.CM.clear()
         self.contactList.clear_contacts()
         self.setStatusOnline(False)
     
-    def newContact(self, JabberId, attributes, groups):
+    def newContact(self, JabberId, attributes, groups, profile):
+        if not self.__check_profile(profile):
+            return
         entity=JID(JabberId)
         self.rosterList[entity.short]=(dict(attributes), list(groups))
     
-    def newMessage(self, from_jid, msg, type, to_jid):
+    def newMessage(self, from_jid, msg, type, to_jid, profile):
+        if not self.__check_profile(profile):
+            return
         sender=JID(from_jid)
         addr=JID(to_jid)
-        win = addr if sender.short == self.whoami.short else sender
-        self.chat_wins[win.short].printMessage(sender, msg)
+        win = addr if sender.short == self.profiles[profile]['whoami'].short else sender
+        self.current_action_ids = set()
+        self.current_action_ids_cb = {}
+        self.chat_wins[win.short].printMessage(sender, msg, profile)
 
     def setStatusOnline(self, online=True):
         pass
 
-    def presenceUpdate(self, jabber_id, show, priority, statuses):
+    def presenceUpdate(self, jabber_id, show, priority, statuses, profile):
+        if not self.__check_profile(profile):
+            return
+        print "check ok"
         debug ("presence update for %s (show=%s, statuses=%s)", jabber_id, show, statuses);
         from_jid=JID(jabber_id)
-        debug ("from_jid.short=%s whoami.short=%s", from_jid.short, self.whoami.short)
+        debug ("from_jid.short=%s whoami.short=%s", from_jid.short, self.profiles[profile]['whoami'].short)
 
-        if from_jid.short==self.whoami.short:
+        if from_jid.short==self.profiles[profile]['whoami'].short:
             if not type:
                 self.setStatusOnline(True)
             elif type=="unavailable":
@@ -124,10 +169,10 @@
                 groups=self.rosterList[from_jid.short][1]
 
             #FIXME: must be moved in a plugin
-            if from_jid.short in self.watched and not from_jid.short in self.onlineContact:
+            if from_jid.short in self.profiles[profile]['watched'] and not from_jid.short in self.profiles[profile]['onlineContact']:
                 self.showAlert("Watched jid [%s] is connected !" % from_jid.short)
 
-            self.onlineContact.add(from_jid)  #FIXME onlineContact is useless with CM, must be removed
+            self.profiles[profile]['onlineContact'].add(from_jid)  #FIXME onlineContact is useless with CM, must be removed
             self.CM.add(from_jid)
             self.CM.update(from_jid, 'name', name)
             self.CM.update(from_jid, 'show', show)
@@ -140,14 +185,16 @@
                 self.CM.update(from_jid, 'avatar', self.bridge.getAvatarFile(cache['avatar']))
             self.contactList.replace(from_jid)
 
-        if show=="unavailable" and from_jid in self.onlineContact:
-            self.onlineContact.remove(from_jid)
+        if show=="unavailable" and from_jid in self.profiles[profile]['onlineContact']:
+            self.profiles[profile]['onlineContact'].remove(from_jid)
             self.CM.remove(from_jid)
             if not self.CM.isConnected(from_jid):
                 self.contactList.disconnect(from_jid)
 
-    def subscribe(self, type, raw_jid):
+    def subscribe(self, type, raw_jid, profile):
         """Called when a subsciption maangement signal is received"""
+        if not self.__check_profile(profile):
+            return
         entity = JID(raw_jid)
         if type=="subscribed":
             # this is a subscription confirmation, we just have to inform user
@@ -169,29 +216,35 @@
     def showAlert(self, message):
         pass  #FIXME
     
-    def paramUpdate(self, name, value, namespace):
+    def paramUpdate(self, name, value, namespace, profile):
+        if not self.__check_profile(profile):
+            return
         debug("param update: [%s] %s = %s", namespace, name, value)
         if (namespace,name) == ("Connection", "JabberID"):
             debug ("Changing ID to %s", value)
-            self.whoami=JID(value)
+            self.profiles[profile]['whoami']=JID(value)
         elif (namespace,name) == ("Misc", "Watched"):
-            self.watched=value.split()
+            self.profiles[profile]['watched']=value.split()
 
-    def contactDeleted(self, jid):
+    def contactDeleted(self, jid, profile):
+        if not self.__check_profile(profile):
+            return
         target = JID(jid)
         self.CM.remove(target)
         self.contactList.remove(self.CM.get_full(target))
         try:
-            self.onlineContact.remove(target.short)
+            self.profiles[profile]['onlineContact'].remove(target.short)
         except KeyError:
             pass
 
-    def updatedValue(self, name, data):
-        if name == "profile_nick":
+    def updatedValue(self, name, data, profile):
+        if not self.__check_profile(profile):
+            return
+        if name == "card_nick":
             target = JID(data['jid'])
             self.CM.update(target, 'nick', data['nick'])
             self.contactList.replace(target)
-        elif name == "profile_avatar":
+        elif name == "card_avatar":
             target = JID(data['jid'])
             filename = self.bridge.getAvatarFile(data['avatar'])
             self.CM.update(target, 'avatar', filename)
--- a/frontends/quick_frontend/quick_contact_management.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/frontends/quick_frontend/quick_contact_management.py	Wed Feb 03 23:35:57 2010 +1100
@@ -91,7 +91,7 @@
         if self.__contactlist.has_key(entity.short):
             self.__contactlist[entity.short][key] = value
         else:
-            debug ('Trying to update an uknown contact: %s', entity.short)
+            debug ('Trying to update an unknown contact: %s', entity.short)
 
     def get_full(self, entity):
         return entity.short+'/'+self.__contactlist[entity.short]['resources'][-1]
--- a/frontends/sat_bridge_frontend/DBus.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/frontends/sat_bridge_frontend/DBus.py	Wed Feb 03 23:35:57 2010 +1100
@@ -40,6 +40,15 @@
         elif iface == "request":
             self.db_req_iface.connect_to_signal(functionName, handler)
 
+    def getProfileName(self, profile_key='@DEFAULT@'):
+        return self.db_req_iface.getProfileName(profile_key)
+
+    def getProfilesList(self):
+        return self.db_req_iface.getProfilesList()
+    
+    def createProfile(self, profile):
+        return self.db_req_iface.getProfileName(profile)
+
     def connect(self, profile_key='@DEFAULT@'):
         return self.db_comm_iface.connect(profile_key)
 
@@ -80,7 +89,7 @@
         return self.db_comm_iface.getParamsForCategory(category, profile_key)
 
     def getParamsCategories(self):
-        return self.db_comm_iface.getParamsCategories(profile_key)
+        return self.db_comm_iface.getParamsCategories()
 
     def getHistory(self, from_jid, to_jid, size):
         return self.db_comm_iface.getHistory(from_jid, to_jid, size)
--- a/frontends/wix/chat.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/frontends/wix/chat.py	Wed Feb 03 23:35:57 2010 +1100
@@ -92,10 +92,10 @@
 
         
 
-    def printMessage(self, from_jid, msg, timestamp=""):   #FIXME: factorize with printDistantMessage
+    def printMessage(self, from_jid, msg, profile, timestamp=""):
         """Print the message with differents colors depending on where it comes from."""
         jid=JID(from_jid)
-        mymess = (jid.short == self.host.whoami.short) #mymess = True if message comes from local user
+        mymess = (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user
         _font = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD)
         self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font))
         self.chatWindow.AppendText("[%s] " % jid)
--- a/frontends/wix/main_window.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/frontends/wix/main_window.py	Wed Feb 03 23:35:57 2010 +1100
@@ -223,6 +223,7 @@
         self.CM = QuickContactManagement() #FIXME: not the best place
 
 
+
         #Frame elements
         self.contactList = ContactList(self, self.CM)
         self.contactList.registerActivatedCB(self.onContactActivated)
@@ -253,6 +254,7 @@
         self.Bind(wx.EVT_CLOSE, self.onClose, self)
 
         QuickApp.__init__(self)
+        self.plug_profile()
         
         self.Show()
 
@@ -329,10 +331,6 @@
             self.tools.Disable()
         return
 
-
-    def presenceUpdate(self, jabber_id, show, priority, statuses):
-        QuickApp.presenceUpdate(self, jabber_id, show, priority, statuses)
-
     def askConfirmation(self, type, id, data):
         #TODO: refactor this in QuickApp
         debug ("Confirmation asked")
@@ -533,7 +531,7 @@
 
     def onFindGateways(self, e):
         debug("Find Gateways request")
-        id = self.bridge.findGateways(self.whoami.domain)
+        id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain)
         self.current_action_ids.add(id)
         self.current_action_ids_cb[id] = self.onGatewaysFound
 
--- a/plugins/plugin_xep_0054.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/plugins/plugin_xep_0054.py	Wed Feb 03 23:35:57 2010 +1100
@@ -91,7 +91,7 @@
         if not old_value or value != old_value:
             cache[name] = value
             self.host.memory.setPrivate("vcard_cache", self.vcard_cache)
-            self.host.bridge.updatedValue('profile_'+name, {'jid':jid.userhost(), name:value})
+            self.host.bridge.updatedValue('card_'+name, {'jid':jid.userhost(), name:value})
 
     def get_cache(self, jid, name):
         """return cached value for jid
--- a/sat.tac	Sun Jan 31 15:57:03 2010 +1100
+++ b/sat.tac	Wed Feb 03 23:35:57 2010 +1100
@@ -83,7 +83,7 @@
         self.__connected=True
         print "********** [%s] CONNECTED **********" % self.profile
         self.streamInitialized()
-        self.host_app.bridge.connected() #we send the signal to the clients
+        self.host_app.bridge.connected(self.profile) #we send the signal to the clients
 
     def streamInitialized(self):
         """Called after _authd"""
@@ -112,7 +112,7 @@
             self.keep_alife.stop()
         except AttributeError:
             debug("No keep_alife")
-        self.host_app.bridge.disconnected() #we send the signal to the clients
+        self.host_app.bridge.disconnected(self.profile) #we send the signal to the clients
 
 
 class SatMessageProtocol(xmppim.MessageProtocol):
@@ -125,7 +125,7 @@
       debug (u"got_message from: %s", message["from"])
       for e in message.elements():
         if e.name == "body":
-          self.host.bridge.newMessage(message["from"], e.children[0])
+          self.host.bridge.newMessage(message["from"], e.children[0], self.parent.profile)
           self.host.memory.addToHistory(self.parent.jid, jid.JID(message["from"]), self.parent.jid, "chat", e.children[0])
           break
     
@@ -165,7 +165,7 @@
             item_attr['name'] = item.name
         info ("new contact in roster list: %s", item.jid.full())
         self.host.memory.addContact(item.jid, item_attr, item.groups, self.parent.profile)
-        self.host.bridge.newContact(item.jid.full(), item_attr, item.groups)
+        self.host.bridge.newContact(item.jid.full(), item_attr, item.groups, self.parent.profile)
     
     def onRosterRemove(self, entity):
         """Called when a roster removal event is received"""
@@ -191,7 +191,7 @@
 
         #now it's time to notify frontends
         self.host.bridge.presenceUpdate(entity.full(),  show or "",
-                int(priority), statuses)
+                int(priority), statuses, self.parent.profile)
     
     def unavailableReceived(self, entity, statuses=None):
         if statuses and statuses.has_key(None):   #we only want string keys
@@ -200,7 +200,7 @@
         self.host.memory.addPresenceStatus(entity, "unavailable", 0, statuses, self.parent.profile)
 
         #now it's time to notify frontends
-        self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses)
+        self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile)
         
     
     def available(self, entity=None, show=None, statuses=None, priority=0):
@@ -212,22 +212,22 @@
     def subscribedReceived(self, entity):
         debug ("subscription approved for [%s]" % entity.userhost())
         self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile)
-        self.host.bridge.subscribe('subscribed', entity.userhost())
+        self.host.bridge.subscribe('subscribed', entity.userhost(), self.parent.profile)
 
     def unsubscribedReceived(self, entity):
         debug ("unsubscription confirmed for [%s]" % entity.userhost())
         self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile)
-        self.host.bridge.subscribe('unsubscribed', entity.userhost())
+        self.host.bridge.subscribe('unsubscribed', entity.userhost(), self.parent.profile)
 
     def subscribeReceived(self, entity):
         debug ("subscription request for [%s]" % entity.userhost())
         self.host.memory.addWaitingSub('subscribe', entity.userhost(), self.parent.profile)
-        self.host.bridge.subscribe('subscribe', entity.userhost())
+        self.host.bridge.subscribe('subscribe', entity.userhost(), self.parent.profile)
 
     def unsubscribeReceived(self, entity):
         debug ("unsubscription asked for [%s]" % entity.userhost())
         self.host.memory.addWaitingSub('unsubscribe', entity.userhost(), self.parent.profile)
-        self.host.bridge.subscribe('unsubscribe', entity.userhost())
+        self.host.bridge.subscribe('unsubscribe', entity.userhost(), self.parent.profile)
 
 class SatDiscoProtocol(disco.DiscoClientProtocol):
     def __init__(self, host):
@@ -326,6 +326,7 @@
         self.server_features=[]  #XXX: temp dic, need to be transfered into self.memory in the future
 
         self.bridge=DBusBridge()
+        self.bridge.register("getProfileName", self.memory.getProfileName)
         self.bridge.register("getProfilesList", self.memory.getProfilesList)
         self.bridge.register("createProfile", self.memory.createProfile)
         self.bridge.register("registerNewAccount", self.registerNewAccount)
@@ -407,7 +408,6 @@
 
         debug ("setting plugins parents")
         
-        #FIXME: gof
         for plugin in self.plugins.iteritems():
             if plugin[1].is_handler:
                 plugin[1].getHandler().setHandlerParent(current)
@@ -585,7 +585,7 @@
         message.addElement("body", "jabber:client", msg)
         self.profiles[profile].xmlstream.send(message)
         self.memory.addToHistory(current_jid, current_jid, jid.JID(to), message["type"], unicode(msg))
-        self.bridge.newMessage(message['from'], unicode(msg), to=message['to']) #We send back the message, so all clients are aware of it
+        self.bridge.newMessage(message['from'], unicode(msg), to=message['to'], profile=profile) #We send back the message, so all clients are aware of it
 
 
     def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'):
@@ -630,7 +630,7 @@
         to_jid=jid.JID(to)
         self.profiles[profile].roster.removeItem(to_jid)
         self.profiles[profile].presence.unsubscribe(to_jid)
-        self.profiles[profile].bridge.contactDeleted(to)
+        self.host.bridge.contactDeleted(to, profile)
 
 
     ## callbacks ##
--- a/sat_bridge/DBus.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/sat_bridge/DBus.py	Wed Feb 03 23:35:57 2010 +1100
@@ -44,44 +44,44 @@
     ### signals ###    
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
-                         signature='')
-    def connected(self):
+                         signature='s')
+    def connected(self, profile):
         debug("Connected signal")
     
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
-                         signature='')
-    def disconnected(self):
+                         signature='s')
+    def disconnected(self, profile):
         debug("Disconnected signal")
     
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
-                         signature='sa{ss}as')
-    def newContact(self, contact, attributes, groups):
-        debug("new contact signal (%s) sended", contact)
+                         signature='sa{ss}ass')
+    def newContact(self, contact, attributes, groups, profile):
+        debug("new contact signal (%s) sended (profile: %s)", contact, profile)
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
-                         signature='ssss')
-    def newMessage(self, from_jid, msg, type='chat', to=''):
+                         signature='sssss')
+    def newMessage(self, from_jid, msg, type='chat', to='', profile='@NONE@'):
         debug("new message signal (from:%s msg:%s type:%s to:%s) sended", from_jid, msg, type, to)
      
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
-                         signature='ssia{ss}')
-    def presenceUpdate(self, entity, show, priority, statuses):
-        debug("presence update signal (from:%s show:%s priority:%d statuses:%s) sended" , entity, show, priority, statuses)
+                         signature='ssia{ss}s')
+    def presenceUpdate(self, entity, show, priority, statuses, profile):
+        debug("presence update signal (from:%s show:%s priority:%d statuses:%s profile:%s) sended" , entity, show, priority, statuses, profile)
+
+    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+                         signature='sss')
+    def subscribe(self, type, entity, profile):
+        debug("subscribe (type: [%s] from:[%s] profile:[%s])" , type, entity, profile)
+    
+    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+                         signature='ssss')
+    def paramUpdate(self, name, value, category, profile):
+        debug("param update signal: %s=%s in category %s (profile: %s)", name, value, category, profile)
 
     @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
                          signature='ss')
-    def subscribe(self, type, entity):
-        debug("subscribe (type: [%s] from:[%s])" , type, entity)
-    
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
-                         signature='sss')
-    def paramUpdate(self, name, value, category):
-        debug("param update signal: %s=%s in category %s", name, value, category)
-
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
-                         signature='s')
-    def contactDeleted(self, entity):
-        debug("contact deleted signal: %s", entity)
+    def contactDeleted(self, entity, profile):
+        debug("contact deleted signal: %s (profile: %s)", entity, profile)
     
     @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
                          signature='ssa{ss}')
@@ -106,14 +106,19 @@
     ### methods ###    
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+                         in_signature='s', out_signature='s')
+    def getProfileName(self, profile_key):
+        return self.cb["getProfileName"](profile_key)
+    
+    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
                          in_signature='', out_signature='as')
     def getProfilesList(self):
         info ('Profile list asked')
         return self.cb["getProfilesList"]()
 
     @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
-                         in_signature='sb', out_signature='')
-    def createProfile(self, name, default=False):
+                         in_signature='s', out_signature='')
+    def createProfile(self, name):
         info ('Profile creation asked')
         return self.cb["createProfile"](name, default)
 
@@ -279,34 +284,34 @@
         self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus)
         self.dbus_bridge = DbusObject(self.session_bus, '/org/goffi/SAT/bridge')
 
-    def connected(self):
-        self.dbus_bridge.connected()
+    def connected(self, profile):
+        self.dbus_bridge.connected(profile)
     
-    def disconnected(self):
-        self.dbus_bridge.disconnected()
+    def disconnected(self, profile):
+        self.dbus_bridge.disconnected(profile)
     
-    def newContact(self, contact, attributes, groups):
-        self.dbus_bridge.newContact(contact, attributes, groups)
+    def newContact(self, contact, attributes, groups, profile):
+        self.dbus_bridge.newContact(contact, attributes, groups, profile)
 
-    def newMessage(self,from_jid,msg,type='chat', to=''):
+    def newMessage(self,from_jid, msg, type, to, profile):
         debug("sending message...")
-        self.dbus_bridge.newMessage(from_jid, msg, type, to)
+        self.dbus_bridge.newMessage(from_jid, msg, type, to, profile)
 
-    def presenceUpdate(self, entity, show, priority, statuses):
+    def presenceUpdate(self, entity, show, priority, statuses, profile):
         debug("updating presence for %s",entity)
-        self.dbus_bridge.presenceUpdate(entity, show, priority, statuses)
+        self.dbus_bridge.presenceUpdate(entity, show, priority, statuses, profile)
 
-    def subscribe(self, type, entity):
+    def subscribe(self, type, entity, profile):
         debug("subscribe request for %s",entity)
-        self.dbus_bridge.subscribe(type, entity)
+        self.dbus_bridge.subscribe(type, entity, profile)
 
-    def paramUpdate(self, name, value, category):
+    def paramUpdate(self, name, value, category, profile):
         debug("updating param [%s] %s ", category, name)
-        self.dbus_bridge.paramUpdate(name, value, category)
+        self.dbus_bridge.paramUpdate(name, value, category, profile)
 
-    def contactDeleted(self, entity):
+    def contactDeleted(self, entity, profile):
         debug("sending contact deleted signal %s ", entity)
-        self.dbus_bridge.contactDeleted(entity)
+        self.dbus_bridge.contactDeleted(entity, profile)
 
     def askConfirmation(self, type, id, data):
         self.dbus_bridge.askConfirmation(type, id, data)
@@ -321,7 +326,7 @@
         self.dbus_bridge.updatedValue(name, value)
 
     def register(self, name, callback):
-        debug("registering DBus bridge method [%s]",name)
+        debug("registering DBus bridge method [%s]", name)
         self.dbus_bridge.register(name, callback)
 
     def addMethod(self, name, int_suffix, in_sign, out_sign, method):
--- a/tools/memory.py	Sun Jan 31 15:57:03 2010 +1100
+++ b/tools/memory.py	Wed Feb 03 23:35:57 2010 +1100
@@ -117,7 +117,7 @@
     def getProfilesList(self):
         return self.params.keys()
 
-    def createProfile(self, name, default=False):
+    def createProfile(self, name):
         """Create a new profile
         @param name: Name of the profile
         @param default: True if default value"""
@@ -135,12 +135,12 @@
         @return: requested profile name or None if it doesn't exist"""
         if profile_key=='@DEFAULT@':
             if not self.params:
-                return None
+                return ""
             info('No default profile, returning first one') #TODO: manage real default profile
             return self.params.keys()[0]  #FIXME: gof: temporary, must use real default value, and fallback to first one if it doesn't exists
         if not self.params.has_key(profile_key):
             error ('Trying to access an unknown profile')
-            return None
+            return ""
         return profile_key
 
     def __get_unique_node(self, parent, tag, name):
@@ -354,7 +354,7 @@
             print "clique",node.toxml()
         else:
             self.params[profile][(category, name)] = value
-            self.host.bridge.paramUpdate(name, value, category) #TODO: add profile in signal
+            self.host.bridge.paramUpdate(name, value, category, profile) #TODO: add profile in signal
 
 class Memory:
     """This class manage all persistent informations"""
@@ -605,8 +605,8 @@
     def getParams(self):
         return self.params.getParams() 
     
-    def getParamsForCategory(self, category):
-        return self.params.getParamsForCategory(category) 
+    def getParamsForCategory(self, category, profile_key='@DEFAULT@'):
+        return self.params.getParamsForCategory(category, profile_key) 
     
     def getParamsCategories(self):
         return self.params.getParamsCategories()