Mercurial > libervia-backend
comparison sat.tac @ 65:d35c5edab53f
SàT: multi-profile: memory & dbus bridge's methods profile management
/!\ profiles not managed yet for dbus signals
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 31 Jan 2010 15:57:03 +1100 |
parents | d46f849664aa |
children | 8147b4f40809 |
comparison
equal
deleted
inserted
replaced
64:d46f849664aa | 65:d35c5edab53f |
---|---|
79 | 79 |
80 def _authd(self, xmlstream): | 80 def _authd(self, xmlstream): |
81 print "SatXMPPClient" | 81 print "SatXMPPClient" |
82 client.XMPPClient._authd(self, xmlstream) | 82 client.XMPPClient._authd(self, xmlstream) |
83 self.__connected=True | 83 self.__connected=True |
84 print "********** CONNECTED **********" | 84 print "********** [%s] CONNECTED **********" % self.profile |
85 self.streamInitialized() | 85 self.streamInitialized() |
86 self.host_app.bridge.connected() #we send the signal to the clients | 86 self.host_app.bridge.connected() #we send the signal to the clients |
87 | 87 |
88 def streamInitialized(self): | 88 def streamInitialized(self): |
89 """Called after _authd""" | 89 """Called after _authd""" |
105 def isConnected(self): | 105 def isConnected(self): |
106 return self.__connected | 106 return self.__connected |
107 | 107 |
108 def connectionLost(self, connector, unused_reason): | 108 def connectionLost(self, connector, unused_reason): |
109 self.__connected=False | 109 self.__connected=False |
110 print "********** DISCONNECTED **********" | 110 print "********** [%s] DISCONNECTED **********" % self.profile |
111 try: | 111 try: |
112 self.keep_alife.stop() | 112 self.keep_alife.stop() |
113 except AttributeError: | 113 except AttributeError: |
114 debug("No keep_alife") | 114 debug("No keep_alife") |
115 self.host_app.bridge.disconnected() #we send the signal to the clients | 115 self.host_app.bridge.disconnected() #we send the signal to the clients |
162 'ask': str(item.ask) | 162 'ask': str(item.ask) |
163 } | 163 } |
164 if item.name: | 164 if item.name: |
165 item_attr['name'] = item.name | 165 item_attr['name'] = item.name |
166 info ("new contact in roster list: %s", item.jid.full()) | 166 info ("new contact in roster list: %s", item.jid.full()) |
167 self.host.memory.addContact(item.jid, item_attr, item.groups) | 167 self.host.memory.addContact(item.jid, item_attr, item.groups, self.parent.profile) |
168 self.host.bridge.newContact(item.jid.full(), item_attr, item.groups) | 168 self.host.bridge.newContact(item.jid.full(), item_attr, item.groups) |
169 | 169 |
170 def onRosterRemove(self, entity): | 170 def onRosterRemove(self, entity): |
171 """Called when a roster removal event is received""" | 171 """Called when a roster removal event is received""" |
172 #TODO: send a signal to frontends | 172 #TODO: send a signal to frontends |
173 print "removing %s from roster list" % entity.full() | 173 print "removing %s from roster list" % entity.full() |
174 self.host.memory.delContact(entity) | 174 self.host.memory.delContact(entity, self.parent.profile) |
175 | 175 |
176 class SatPresenceProtocol(xmppim.PresenceClientProtocol): | 176 class SatPresenceProtocol(xmppim.PresenceClientProtocol): |
177 | 177 |
178 def __init__(self, host): | 178 def __init__(self, host): |
179 xmppim.PresenceClientProtocol.__init__(self) | 179 xmppim.PresenceClientProtocol.__init__(self) |
185 if statuses.has_key(None): #we only want string keys | 185 if statuses.has_key(None): #we only want string keys |
186 statuses["default"] = statuses[None] | 186 statuses["default"] = statuses[None] |
187 del statuses[None] | 187 del statuses[None] |
188 | 188 |
189 self.host.memory.addPresenceStatus(entity, show or "", | 189 self.host.memory.addPresenceStatus(entity, show or "", |
190 int(priority), statuses) | 190 int(priority), statuses, self.parent.profile) |
191 | 191 |
192 #now it's time to notify frontends | 192 #now it's time to notify frontends |
193 self.host.bridge.presenceUpdate(entity.full(), show or "", | 193 self.host.bridge.presenceUpdate(entity.full(), show or "", |
194 int(priority), statuses) | 194 int(priority), statuses) |
195 | 195 |
196 def unavailableReceived(self, entity, statuses=None): | 196 def unavailableReceived(self, entity, statuses=None): |
197 if statuses and statuses.has_key(None): #we only want string keys | 197 if statuses and statuses.has_key(None): #we only want string keys |
198 statuses["default"] = statuses[None] | 198 statuses["default"] = statuses[None] |
199 del statuses[None] | 199 del statuses[None] |
200 self.host.memory.addPresenceStatus(entity, "unavailable", 0, statuses) | 200 self.host.memory.addPresenceStatus(entity, "unavailable", 0, statuses, self.parent.profile) |
201 | 201 |
202 #now it's time to notify frontends | 202 #now it's time to notify frontends |
203 self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses) | 203 self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses) |
204 | 204 |
205 | 205 |
209 del statuses['default'] | 209 del statuses['default'] |
210 xmppim.PresenceClientProtocol.available(self, entity, show, statuses, priority) | 210 xmppim.PresenceClientProtocol.available(self, entity, show, statuses, priority) |
211 | 211 |
212 def subscribedReceived(self, entity): | 212 def subscribedReceived(self, entity): |
213 debug ("subscription approved for [%s]" % entity.userhost()) | 213 debug ("subscription approved for [%s]" % entity.userhost()) |
214 self.host.memory.delWaitingSub(entity.userhost()) | 214 self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile) |
215 self.host.bridge.subscribe('subscribed', entity.userhost()) | 215 self.host.bridge.subscribe('subscribed', entity.userhost()) |
216 | 216 |
217 def unsubscribedReceived(self, entity): | 217 def unsubscribedReceived(self, entity): |
218 debug ("unsubscription confirmed for [%s]" % entity.userhost()) | 218 debug ("unsubscription confirmed for [%s]" % entity.userhost()) |
219 self.host.memory.delWaitingSub(entity.userhost()) | 219 self.host.memory.delWaitingSub(entity.userhost(), self.parent.profile) |
220 self.host.bridge.subscribe('unsubscribed', entity.userhost()) | 220 self.host.bridge.subscribe('unsubscribed', entity.userhost()) |
221 | 221 |
222 def subscribeReceived(self, entity): | 222 def subscribeReceived(self, entity): |
223 debug ("subscription request for [%s]" % entity.userhost()) | 223 debug ("subscription request for [%s]" % entity.userhost()) |
224 self.host.memory.addWaitingSub('subscribe', entity.userhost()) | 224 self.host.memory.addWaitingSub('subscribe', entity.userhost(), self.parent.profile) |
225 self.host.bridge.subscribe('subscribe', entity.userhost()) | 225 self.host.bridge.subscribe('subscribe', entity.userhost()) |
226 | 226 |
227 def unsubscribeReceived(self, entity): | 227 def unsubscribeReceived(self, entity): |
228 debug ("unsubscription asked for [%s]" % entity.userhost()) | 228 debug ("unsubscription asked for [%s]" % entity.userhost()) |
229 self.host.memory.addWaitingSub('unsubscribe', entity.userhost()) | 229 self.host.memory.addWaitingSub('unsubscribe', entity.userhost(), self.parent.profile) |
230 self.host.bridge.subscribe('unsubscribe', entity.userhost()) | 230 self.host.bridge.subscribe('unsubscribe', entity.userhost()) |
231 | 231 |
232 class SatDiscoProtocol(disco.DiscoClientProtocol): | 232 class SatDiscoProtocol(disco.DiscoClientProtocol): |
233 def __init__(self, host): | 233 def __init__(self, host): |
234 disco.DiscoClientProtocol.__init__(self) | 234 disco.DiscoClientProtocol.__init__(self) |