comparison src/plugins/plugin_xep_0045.py @ 1256:4b27b9bf31b0

plugin XEP-0045: use HISTORY_LIMIT param to retrieve the MUC history
author souliane <souliane@mailoo.org>
date Wed, 22 Oct 2014 14:16:01 +0200
parents 1f0ae61536aa
children be3a301540c0
comparison
equal deleted inserted replaced
1255:38fb8823cee8 1256:4b27b9bf31b0
340 if room_jid.userhost() in self.clients[profile].joined_rooms: 340 if room_jid.userhost() in self.clients[profile].joined_rooms:
341 log.warning(_('%(profile)s is already in room %(room_jid)s') % {'profile': profile, 'room_jid': room_jid.userhost()}) 341 log.warning(_('%(profile)s is already in room %(room_jid)s') % {'profile': profile, 'room_jid': room_jid.userhost()})
342 return _errDeferred() 342 return _errDeferred()
343 log.info(_("[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick}) 343 log.info(_("[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick})
344 344
345 history_options = options["history"] == "True" if "history" in options else None 345 if "history" in options:
346 history_limit = int(options["history"])
347 else:
348 history_limit = int(self.host.memory.getParamA(C.HISTORY_LIMIT, 'General', profile_key=profile))
349 # http://xmpp.org/extensions/xep-0045.html#enter-managehistory
350 history_options = muc.HistoryOptions(maxStanzas=history_limit)
346 password = options["password"] if "password" in options else None 351 password = options["password"] if "password" in options else None
347 352
348 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile]) 353 return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile])
349 # FIXME: how to set the cancel method on the Deferred created by wokkel? 354 # FIXME: how to set the cancel method on the Deferred created by wokkel?
350 # This happens when the room is not reachable, e.g. no internet connection: 355 # This happens when the room is not reachable, e.g. no internet connection:
688 self.userChangedNick(room, user, presence.nick) 693 self.userChangedNick(room, user, presence.nick)
689 else: 694 else:
690 self.__changing_nicks.discard(presence.nick) 695 self.__changing_nicks.discard(presence.nick)
691 self.userLeftRoom(room, user) 696 self.userLeftRoom(room, user)
692 697
693 def receivedGroupChat(self, room, user, body):
694 log.debug('receivedGroupChat: room=%s user=%s body=%s' % (room, user, body))
695
696 def userJoinedRoom(self, room, user): 698 def userJoinedRoom(self, room, user):
697 self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", self.parent.profile) 699 self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", self.parent.profile)
698 if user.nick in self.__changing_nicks: 700 if user.nick in self.__changing_nicks:
699 self.__changing_nicks.remove(user.nick) 701 self.__changing_nicks.remove(user.nick)
700 else: 702 else:
724 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile) 726 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile)
725 727
726 def userUpdatedStatus(self, room, user, show, status): 728 def userUpdatedStatus(self, room, user, show, status):
727 self.host.bridge.presenceUpdate(room.roomJID.userhost() + '/' + user.nick, show or '', 0, {'default': status or ''}, self.parent.profile) 729 self.host.bridge.presenceUpdate(room.roomJID.userhost() + '/' + user.nick, show or '', 0, {'default': status or ''}, self.parent.profile)
728 730
731 def receivedGroupChat(self, room, user, body):
732 log.debug('receivedGroupChat: room=%s user=%s body=%s' % (room.roomJID.full(), user, body))
733
734 def receivedHistory(self, room, user, message):
735 # http://xmpp.org/extensions/xep-0045.html#enter-history
736 #log.debug('receivedHistory: room=%s user=%s body=%s' % (room.roomJID.full(), user, message))
737 pass
738
729 def receivedSubject(self, room, user, subject): 739 def receivedSubject(self, room, user, subject):
740 # http://xmpp.org/extensions/xep-0045.html#enter-subject
730 log.debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject}) 741 log.debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})
731 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject) 742 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
732 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile) 743 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)