comparison frontends/quick_frontend/quick_app.py @ 72:f271fff3a713

MUC implementation: first draft /!\ the experimental muc branche of wokkel must be used - bridge: new roomJoined signal - wix: contact list widget is now in a separate file, and manage different kinds of presentation - wix: chat window now manage group chat (first draft, not working yet) - wix: constants are now in a separate class, so then can be accessible from everywhere - wix: new menu to join room (do nothing yet, except entering in a test room) - new plugin for xep 0045 (MUC), use wokkel experimental MUC branch - plugins: the profile is now given for get_handler, cause it can be used internally by a plugin (e.g.: xep-0045 plugin)
author Goffi <goffi@goffi.org>
date Sun, 21 Mar 2010 10:28:55 +1100
parents efe81b61673c
children 7322a41f8a8e
comparison
equal deleted inserted replaced
71:efe81b61673c 72:f271fff3a713
40 self.bridge.register("connected", self.connected) 40 self.bridge.register("connected", self.connected)
41 self.bridge.register("disconnected", self.disconnected) 41 self.bridge.register("disconnected", self.disconnected)
42 self.bridge.register("newContact", self.newContact) 42 self.bridge.register("newContact", self.newContact)
43 self.bridge.register("newMessage", self.newMessage) 43 self.bridge.register("newMessage", self.newMessage)
44 self.bridge.register("presenceUpdate", self.presenceUpdate) 44 self.bridge.register("presenceUpdate", self.presenceUpdate)
45 self.bridge.register("roomJoined", self.roomJoined)
45 self.bridge.register("subscribe", self.subscribe) 46 self.bridge.register("subscribe", self.subscribe)
46 self.bridge.register("paramUpdate", self.paramUpdate) 47 self.bridge.register("paramUpdate", self.paramUpdate)
47 self.bridge.register("contactDeleted", self.contactDeleted) 48 self.bridge.register("contactDeleted", self.contactDeleted)
48 self.bridge.register("updatedValue", self.updatedValue, "request") 49 self.bridge.register("updatedValue", self.updatedValue, "request")
49 self.bridge.register("askConfirmation", self.askConfirmation, "request") 50 self.bridge.register("askConfirmation", self.askConfirmation, "request")
78 self.profiles[profile]['watched']=self.bridge.getParamA("Watched", "Misc", profile).split() #TODO: put this in a plugin 79 self.profiles[profile]['watched']=self.bridge.getParamA("Watched", "Misc", profile).split() #TODO: put this in a plugin
79 80
80 ## misc ## 81 ## misc ##
81 self.profiles[profile]['onlineContact'] = set() #FIXME: temporary 82 self.profiles[profile]['onlineContact'] = set() #FIXME: temporary
82 83
83 #TODO: managed multi-profiles here 84 #TODO: gof: managed multi-profiles here
84 if self.bridge.isConnected(profile): 85 if self.bridge.isConnected(profile):
85 self.setStatusOnline(True) 86 self.setStatusOnline(True)
86 else: 87 else:
87 self.setStatusOnline(False) 88 self.setStatusOnline(False)
88 return 89 return
151 152
152 def presenceUpdate(self, jabber_id, show, priority, statuses, profile): 153 def presenceUpdate(self, jabber_id, show, priority, statuses, profile):
153 if not self.__check_profile(profile): 154 if not self.__check_profile(profile):
154 return 155 return
155 print "check ok" 156 print "check ok"
156 debug (_("presence update for %(jid)s (show=%(show)s, statuses=%(statuses)s)") % {'jid':jabber_id, 'show':show, 'statuses':statuses}); 157 debug (_("presence update for %(jid)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]") % {'jid':jabber_id, 'show':show, 'priority':priority, 'statuses':statuses, 'profile':profile});
157 from_jid=JID(jabber_id) 158 from_jid=JID(jabber_id)
158 debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short}) 159 debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short})
159 160
160 if from_jid.short==self.profiles[profile]['whoami'].short: 161 if from_jid.short==self.profiles[profile]['whoami'].short:
161 if not type: 162 if not type:
185 cache = self.bridge.getCardCache(from_jid) 186 cache = self.bridge.getCardCache(from_jid)
186 if cache.has_key('nick'): 187 if cache.has_key('nick'):
187 self.CM.update(from_jid, 'nick', cache['nick']) 188 self.CM.update(from_jid, 'nick', cache['nick'])
188 if cache.has_key('avatar'): 189 if cache.has_key('avatar'):
189 self.CM.update(from_jid, 'avatar', self.bridge.getAvatarFile(cache['avatar'])) 190 self.CM.update(from_jid, 'avatar', self.bridge.getAvatarFile(cache['avatar']))
190 self.contactList.replace(from_jid) 191 self.contactList.replace(from_jid, self.CM.getAttr(from_jid, 'groups'))
191 192
192 if show=="unavailable" and from_jid in self.profiles[profile]['onlineContact']: 193 if show=="unavailable" and from_jid in self.profiles[profile]['onlineContact']:
193 self.profiles[profile]['onlineContact'].remove(from_jid) 194 self.profiles[profile]['onlineContact'].remove(from_jid)
194 self.CM.remove(from_jid) 195 self.CM.remove(from_jid)
195 if not self.CM.isConnected(from_jid): 196 if not self.CM.isConnected(from_jid):
196 self.contactList.disconnect(from_jid) 197 self.contactList.disconnect(from_jid)
198
199 def roomJoined(self, room_id, room_service, room_nicks, user_nick, profile):
200 """Called when a MUC room is joined"""
201 debug (_("Room [%(room_name)s] joined by %(profile)s") % {'room_name':room_id+'@'+room_service, 'profile': profile})
202
203
197 204
198 def subscribe(self, type, raw_jid, profile): 205 def subscribe(self, type, raw_jid, profile):
199 """Called when a subsciption maangement signal is received""" 206 """Called when a subsciption maangement signal is received"""
200 if not self.__check_profile(profile): 207 if not self.__check_profile(profile):
201 return 208 return