MUC update to follow wokkel's MUC branch update

- bridge methods have been updated (API change)
- plugin XEP-0045 has been updated
This commit is contained in:
Goffi 2011-10-08 18:43:17 +02:00
commit b7b7c60e33
4 changed files with 59 additions and 70 deletions

View file

@ -160,14 +160,16 @@ class DBusBridgeFrontend(BridgeFrontend):
#methods from plugins
def getRoomJoined(self, profile_key='@DEFAULT@'):
return self.db_plugin_iface.getRoomJoined(profile_key)
def getRoomsJoined(self, profile_key='@DEFAULT@'):
return self.db_plugin_iface.getRoomsJoined(profile_key)
def getRoomSubjects(self, profile_key='@DEFAULT@'):
return self.db_plugin_iface.getRoomSubjects(profile_key)
def getRoomsSubjectss(self, profile_key='@DEFAULT@'):
return self.db_plugin_iface.getRoomsSubjectss(profile_key)
def joinMUC(self, service, roomId, nick, profile_key='@DEFAULT@'):
return self.db_plugin_iface.joinMUC(service, roomId, nick, profile_key)
def joinMUC(self, room_jid, nick, options, profile_key='@DEFAULT@'):
if options == None:
options = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature
return self.db_plugin_iface.joinMUC(room_jid, nick, options, profile_key)
def tarotGameLaunch(self, players, profile_key='@DEFAULT@'):
return self.db_plugin_iface.tarotGameLaunch(players, profile_key)

View file

@ -435,7 +435,7 @@ class PrimitivusApp(QuickApp):
self.removePopUp()
room_jid = JID(edit.get_edit_text())
if room_jid.is_valid():
self.bridge.joinMUC(room_jid.domain, room_jid.node, self.profiles[self.profile]['whoami'].node, self.profile)
self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile)
else:
message = _("'%s' is an invalid JID !") % room_jid
error (message)

View file

@ -160,10 +160,10 @@ class QuickApp():
self.subscribe(waitingSub[sub], sub, profile)
#Now we open the MUC window where we already are:
for room_args in self.bridge.getRoomJoined(profile):
for room_args in self.bridge.getRoomsJoined(profile):
self.roomJoined(*room_args, profile=profile)
for subject_args in self.bridge.getRoomSubjects(profile):
for subject_args in self.bridge.getRoomsSubjectss(profile):
self.roomNewSubject(*subject_args, profile=profile)
if autoconnect and not self.bridge.isConnected(profile_key):
@ -283,41 +283,37 @@ class QuickApp():
if not self.CM.isConnected(from_jid):
self.contactList.disconnect(from_jid)
def roomJoined(self, room_id, room_service, room_nicks, user_nick, profile):
def roomJoined(self, room_jid, room_nicks, user_nick, profile):
"""Called when a MUC room is joined"""
if not self.check_profile(profile):
return
debug (_("Room [%(room_name)s] joined by %(profile)s, users presents:%(users)s") % {'room_name':room_id+'@'+room_service, 'profile': profile, 'users':room_nicks})
room_jid=room_id+'@'+room_service
debug (_("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s") % {'room_jid':room_jid, 'profile': profile, 'users':room_nicks})
self.chat_wins[room_jid].setUserNick(user_nick)
self.chat_wins[room_jid].setType("group")
self.chat_wins[room_jid].id = room_jid
self.chat_wins[room_jid].setPresents(list(set([user_nick]+room_nicks)))
def roomUserJoined(self, room_id, room_service, user_nick, user_data, profile):
def roomUserJoined(self, room_jid, user_nick, user_data, profile):
"""Called when an user joined a MUC room"""
if not self.check_profile(profile):
return
room_jid=room_id+'@'+room_service
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].replaceUser(user_nick)
debug (_("user [%(user_nick)s] joined room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid})
def roomUserLeft(self, room_id, room_service, user_nick, user_data, profile):
def roomUserLeft(self, room_jid, user_nick, user_data, profile):
"""Called when an user joined a MUC room"""
if not self.check_profile(profile):
return
room_jid=room_id+'@'+room_service
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].removeUser(user_nick)
debug (_("user [%(user_nick)s] left room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid})
def roomNewSubject(self, room_id, room_service, subject, profile):
def roomNewSubject(self, room_jid, subject, profile):
"""Called when subject of MUC room change"""
if not self.check_profile(profile):
return
room_jid=room_id+'@'+room_service
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].setSubject(subject)
debug (_("new subject for room [%(room_jid)s]: %(subject)s") % {'room_jid':room_jid, "subject":subject})

View file

@ -190,9 +190,6 @@ class MainWindow(wx.Frame, QuickApp):
def newMessage(self, from_jid, msg, type, to_jid, profile):
QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile)
def roomJoined(self, room_id, room_service, room_nicks, user_nick, profile):
super(MainWindow, self).roomJoined(room_id, room_service, room_nicks, user_nick, profile)
def showAlert(self, message):
# TODO: place this in a separate class
popup=wx.PopupWindow(self)
@ -464,7 +461,7 @@ class MainWindow(wx.Frame, QuickApp):
if dlg.ShowModal() == wx.ID_OK:
room_jid=JID(dlg.GetValue())
if room_jid.is_valid():
self.bridge.joinMUC(room_jid.domain, room_jid.node, self.profiles[self.profile]['whoami'].node, self.profile)
self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile)
else:
error (_("'%s' is an invalid JID !"), room_jid)