Mercurial > libervia-backend
diff sat.tac @ 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 |
line wrap: on
line diff
--- 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 ##