comparison frontends/src/quick_frontend/quick_app.py @ 503:10119c2a9d33

Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
author Goffi <goffi@goffi.org>
date Wed, 26 Sep 2012 00:38:41 +0200
parents debcf5dd404a
children 65ecbb473cbb
comparison
equal deleted inserted replaced
502:debcf5dd404a 503:10119c2a9d33
21 21
22 from logging import debug, info, warning, error 22 from logging import debug, info, warning, error
23 from sat.tools.jid import JID 23 from sat.tools.jid import JID
24 from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService 24 from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService
25 from optparse import OptionParser 25 from optparse import OptionParser
26 import pdb
27 26
28 import gettext 27 import gettext
29 gettext.install('sat_frontend', "../i18n", unicode=True) 28 gettext.install('sat_frontend', "../i18n", unicode=True)
30 29
31 class QuickApp(): 30 class QuickApp():
146 self.profiles[profile]['watched'] = watched.split() #TODO: put this in a plugin 145 self.profiles[profile]['watched'] = watched.split() #TODO: put this in a plugin
147 146
148 ## misc ## 147 ## misc ##
149 self.profiles[profile]['onlineContact'] = set() #FIXME: temporary 148 self.profiles[profile]['onlineContact'] = set() #FIXME: temporary
150 149
151 #TODO: gof: manage multi-profiles here 150 #TODO: manage multi-profiles here
152 if not self.bridge.isConnected(profile): 151 if not self.bridge.isConnected(profile):
153 self.setStatusOnline(False) 152 self.setStatusOnline(False)
154 else: 153 else:
155 self.setStatusOnline(True) 154 self.setStatusOnline(True)
156 155
204 def disconnected(self, profile): 203 def disconnected(self, profile):
205 """called when the connection is closed""" 204 """called when the connection is closed"""
206 if not self.check_profile(profile): 205 if not self.check_profile(profile):
207 return 206 return
208 debug(_("Disconnected")) 207 debug(_("Disconnected"))
209 self.contactList.clearContacts() 208 self.contact_list.clearContacts()
210 self.setStatusOnline(False) 209 self.setStatusOnline(False)
211 210
212 def connectionError(self, error_type, profile): 211 def connectionError(self, error_type, profile):
213 """called when something goest wrong with the connection""" 212 """called when something goest wrong with the connection"""
214 if not self.check_profile(profile): 213 if not self.check_profile(profile):
469 468
470 def contactDeleted(self, jid, profile): 469 def contactDeleted(self, jid, profile):
471 if not self.check_profile(profile): 470 if not self.check_profile(profile):
472 return 471 return
473 target = JID(jid) 472 target = JID(jid)
474 self.contactList.remove(target) 473 self.contact_list.remove(target)
475 try: 474 try:
476 self.profiles[profile]['onlineContact'].remove(target.short) 475 self.profiles[profile]['onlineContact'].remove(target.short)
477 except KeyError: 476 except KeyError:
478 pass 477 pass
479 478
481 #FIXME: to be removed 480 #FIXME: to be removed
482 if not self.check_profile(profile): 481 if not self.check_profile(profile):
483 return 482 return
484 if name == "card_nick": 483 if name == "card_nick":
485 target = JID(data['jid']) 484 target = JID(data['jid'])
486 if target in self.contactList: 485 if target in self.contact_list:
487 #self.CM.update(target, 'nick', unicode(data['nick'])) 486 #self.CM.update(target, 'nick', unicode(data['nick']))
488 self.contact_list._replace(target) 487 self.contact_list._replace(target)
489 elif name == "card_avatar": 488 elif name == "card_avatar":
490 target = JID(data['jid']) 489 target = JID(data['jid'])
491 if target in self.contactList: 490 if target in self.contact_list:
492 filename = self.bridge.getAvatarFile(data['avatar']) 491 filename = self.bridge.getAvatarFile(data['avatar'])
493 #self.CM.update(target, 'avatar', filename) 492 #self.CM.update(target, 'avatar', filename)
494 self.contact_list._replace(target) 493 self.contact_list._replace(target)
495 494
496 def askConfirmation(self, type, id, data): 495 def askConfirmation(self, type, id, data):