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)
This commit is contained in:
parent
c9c7c483dc
commit
724a97b14d
3 changed files with 432 additions and 194 deletions
|
|
@ -42,6 +42,7 @@ class QuickApp():
|
|||
self.bridge.register("newContact", self.newContact)
|
||||
self.bridge.register("newMessage", self.newMessage)
|
||||
self.bridge.register("presenceUpdate", self.presenceUpdate)
|
||||
self.bridge.register("roomJoined", self.roomJoined)
|
||||
self.bridge.register("subscribe", self.subscribe)
|
||||
self.bridge.register("paramUpdate", self.paramUpdate)
|
||||
self.bridge.register("contactDeleted", self.contactDeleted)
|
||||
|
|
@ -80,7 +81,7 @@ class QuickApp():
|
|||
## misc ##
|
||||
self.profiles[profile]['onlineContact'] = set() #FIXME: temporary
|
||||
|
||||
#TODO: managed multi-profiles here
|
||||
#TODO: gof: managed multi-profiles here
|
||||
if self.bridge.isConnected(profile):
|
||||
self.setStatusOnline(True)
|
||||
else:
|
||||
|
|
@ -153,7 +154,7 @@ class QuickApp():
|
|||
if not self.__check_profile(profile):
|
||||
return
|
||||
print "check ok"
|
||||
debug (_("presence update for %(jid)s (show=%(show)s, statuses=%(statuses)s)") % {'jid':jabber_id, 'show':show, 'statuses':statuses});
|
||||
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});
|
||||
from_jid=JID(jabber_id)
|
||||
debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short})
|
||||
|
||||
|
|
@ -187,13 +188,19 @@ class QuickApp():
|
|||
self.CM.update(from_jid, 'nick', cache['nick'])
|
||||
if cache.has_key('avatar'):
|
||||
self.CM.update(from_jid, 'avatar', self.bridge.getAvatarFile(cache['avatar']))
|
||||
self.contactList.replace(from_jid)
|
||||
self.contactList.replace(from_jid, self.CM.getAttr(from_jid, 'groups'))
|
||||
|
||||
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 roomJoined(self, room_id, room_service, room_nicks, user_nick, profile):
|
||||
"""Called when a MUC room is joined"""
|
||||
debug (_("Room [%(room_name)s] joined by %(profile)s") % {'room_name':room_id+'@'+room_service, 'profile': profile})
|
||||
|
||||
|
||||
|
||||
def subscribe(self, type, raw_jid, profile):
|
||||
"""Called when a subsciption maangement signal is received"""
|
||||
|
|
|
|||
|
|
@ -26,14 +26,21 @@ from tools.jid import JID
|
|||
|
||||
class QuickChat():
|
||||
|
||||
def __init__(self, to_jid, host):
|
||||
self.to_jid = to_jid
|
||||
def __init__(self, target, host, type='one2one'):
|
||||
self.target = target
|
||||
self.host = host
|
||||
self.type = type
|
||||
|
||||
def setType(self, type):
|
||||
"""Set the type of the chat
|
||||
@param type: can be 'one2one' for single conversation or 'group' for chat à la IRC
|
||||
"""
|
||||
self.type = type
|
||||
|
||||
def historyPrint(self, size=20, keep_last=False, profile='@NONE@'):
|
||||
"""Print the initial history"""
|
||||
debug (_("now we print history"))
|
||||
history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.to_jid, 20)
|
||||
history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.target, 20)
|
||||
stamps=history.keys()
|
||||
stamps.sort()
|
||||
for stamp in stamps:
|
||||
|
|
|
|||
|
|
@ -49,6 +49,6 @@ class QuickContactList():
|
|||
"""remove a contact from the list"""
|
||||
raise NotImplementedError
|
||||
|
||||
def add(self, jid):
|
||||
def add(self, jid, param_groups=None):
|
||||
"""add a contact to the list"""
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
Loading…
Reference in a new issue