comparison src/plugins/plugin_xep_0045.py @ 1409:3265a2639182

massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
author souliane <souliane@mailoo.org>
date Thu, 16 Apr 2015 14:57:57 +0200
parents 77f07ea90420
children 176de79c8c39
comparison
equal deleted inserted replaced
1408:8a7145138330 1409:3265a2639182
104 104
105 If profile was using MUC feature but is now disconnected, remove it from the client list. 105 If profile was using MUC feature but is now disconnected, remove it from the client list.
106 @param profile: profile to check 106 @param profile: profile to check
107 @return: True if the profile is connected and has used the MUC feature, else False""" 107 @return: True if the profile is connected and has used the MUC feature, else False"""
108 if not profile or profile not in self.clients or not self.host.isConnected(profile): 108 if not profile or profile not in self.clients or not self.host.isConnected(profile):
109 log.error(_('Unknown or disconnected profile (%s)') % profile) 109 log.error(_(u'Unknown or disconnected profile (%s)') % profile)
110 if profile in self.clients: 110 if profile in self.clients:
111 del self.clients[profile] 111 del self.clients[profile]
112 return False 112 return False
113 return True 113 return True
114 114
136 if room.locked: 136 if room.locked:
137 # FIXME: the current behaviour is to create an instant room 137 # FIXME: the current behaviour is to create an instant room
138 # and send the signal only when the room is unlocked 138 # and send the signal only when the room is unlocked
139 # a proper configuration management should be done 139 # a proper configuration management should be done
140 print "room locked !" 140 print "room locked !"
141 self.clients[profile].configure(room.roomJID, {}).addCallbacks(_sendBridgeSignal, lambda x: log.error(_('Error while configuring the room'))) 141 self.clients[profile].configure(room.roomJID, {}).addCallbacks(_sendBridgeSignal, lambda x: log.error(_(u'Error while configuring the room')))
142 else: 142 else:
143 _sendBridgeSignal() 143 _sendBridgeSignal()
144 return room 144 return room
145 145
146 def __err_joining_room(self, failure, room_jid, nick, history_options, password, profile): 146 def __err_joining_room(self, failure, room_jid, nick, history_options, password, profile):
357 357
358 profile = self.host.memory.getProfileName(profile_key) 358 profile = self.host.memory.getProfileName(profile_key)
359 if not self.checkClient(profile): 359 if not self.checkClient(profile):
360 return _errDeferred() 360 return _errDeferred()
361 if room_jid in self.clients[profile].joined_rooms: 361 if room_jid in self.clients[profile].joined_rooms:
362 log.warning(_('%(profile)s is already in room %(room_jid)s') % {'profile': profile, 'room_jid': room_jid.userhost()}) 362 log.warning(_(u'%(profile)s is already in room %(room_jid)s') % {'profile': profile, 'room_jid': room_jid.userhost()})
363 return _errDeferred() 363 return _errDeferred()
364 log.info(_("[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick}) 364 log.info(_(u"[%(profile)s] is joining room %(room)s with nick %(nick)s") % {'profile': profile, 'room': room_jid.userhost(), 'nick': nick})
365 365
366 if "history" in options: 366 if "history" in options:
367 history_limit = int(options["history"]) 367 history_limit = int(options["history"])
368 else: 368 else:
369 history_limit = int(self.host.memory.getParamA(C.HISTORY_LIMIT, 'General', profile_key=profile)) 369 history_limit = int(self.host.memory.getParamA(C.HISTORY_LIMIT, 'General', profile_key=profile))
707 def userJoinedRoom(self, room, user): 707 def userJoinedRoom(self, room, user):
708 self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", profile_key=self.parent.profile) 708 self.host.memory.updateEntityData(room.roomJID, "type", "chatroom", profile_key=self.parent.profile)
709 if user.nick in self.__changing_nicks: 709 if user.nick in self.__changing_nicks:
710 self.__changing_nicks.remove(user.nick) 710 self.__changing_nicks.remove(user.nick)
711 else: 711 else:
712 log.debug(_("user %(nick)s has joined room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()}) 712 log.debug(_(u"user %(nick)s has joined room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
713 if not self.host.trigger.point("MUC user joined", room, user, self.parent.profile): 713 if not self.host.trigger.point("MUC user joined", room, user, self.parent.profile):
714 return 714 return
715 user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role} 715 user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role}
716 self.host.bridge.roomUserJoined(room.roomJID.userhost(), user.nick, user_data, self.parent.profile) 716 self.host.bridge.roomUserJoined(room.roomJID.userhost(), user.nick, user_data, self.parent.profile)
717 717
719 if not self.host.trigger.point("MUC user left", room, user, self.parent.profile): 719 if not self.host.trigger.point("MUC user left", room, user, self.parent.profile):
720 return 720 return
721 if user.nick == room.nick: 721 if user.nick == room.nick:
722 # we left the room 722 # we left the room
723 room_jid_s = room.roomJID.userhost() 723 room_jid_s = room.roomJID.userhost()
724 log.info(_("Room [%(room)s] left (%(profile)s))") % {"room": room_jid_s, 724 log.info(_(u"Room [%(room)s] left (%(profile)s))") % {"room": room_jid_s,
725 "profile": self.parent.profile}) 725 "profile": self.parent.profile})
726 self.host.memory.delEntityCache(room.roomJID, profile_key=self.parent.profile) 726 self.host.memory.delEntityCache(room.roomJID, profile_key=self.parent.profile)
727 self.host.bridge.roomLeft(room.roomJID.userhost(), self.parent.profile) 727 self.host.bridge.roomLeft(room.roomJID.userhost(), self.parent.profile)
728 else: 728 else:
729 log.debug(_("user %(nick)s left room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()}) 729 log.debug(_(u"user %(nick)s left room (%(room_id)s)") % {'nick': user.nick, 'room_id': room.occupantJID.userhost()})
730 user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role} 730 user_data = {'entity': user.entity.full() if user.entity else '', 'affiliation': user.affiliation, 'role': user.role}
731 self.host.bridge.roomUserLeft(room.roomJID.userhost(), user.nick, user_data, self.parent.profile) 731 self.host.bridge.roomUserLeft(room.roomJID.userhost(), user.nick, user_data, self.parent.profile)
732 732
733 def userChangedNick(self, room, user, new_nick): 733 def userChangedNick(self, room, user, new_nick):
734 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile) 734 self.host.bridge.roomUserChangedNick(room.roomJID.userhost(), user.nick, new_nick, self.parent.profile)
735 735
736 def userUpdatedStatus(self, room, user, show, status): 736 def userUpdatedStatus(self, room, user, show, status):
737 self.host.bridge.presenceUpdate(room.roomJID.userhost() + '/' + user.nick, show or '', 0, {'default': status or ''}, self.parent.profile) 737 self.host.bridge.presenceUpdate(room.roomJID.userhost() + '/' + user.nick, show or '', 0, {'default': status or ''}, self.parent.profile)
738 738
739 def receivedGroupChat(self, room, user, body): 739 def receivedGroupChat(self, room, user, body):
740 log.debug('receivedGroupChat: room=%s user=%s body=%s' % (room.roomJID.full(), user, body)) 740 log.debug(u'receivedGroupChat: room=%s user=%s body=%s' % (room.roomJID.full(), user, body))
741 741
742 def receivedHistory(self, room, user, message): 742 def receivedHistory(self, room, user, message):
743 # http://xmpp.org/extensions/xep-0045.html#enter-history 743 # http://xmpp.org/extensions/xep-0045.html#enter-history
744 # log.debug('receivedHistory: room=%s user=%s body=%s' % (room.roomJID.full(), user, message)) 744 # log.debug(u'receivedHistory: room=%s user=%s body=%s' % (room.roomJID.full(), user, message))
745 pass 745 pass
746 746
747 def receivedSubject(self, room, user, subject): 747 def receivedSubject(self, room, user, subject):
748 # http://xmpp.org/extensions/xep-0045.html#enter-subject 748 # http://xmpp.org/extensions/xep-0045.html#enter-subject
749 log.debug(_("New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject}) 749 log.debug(_(u"New subject for room (%(room_id)s): %(subject)s") % {'room_id': room.roomJID.full(), 'subject': subject})
750 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject) 750 self.rec_subjects[room.roomJID.userhost()] = (room.roomJID.userhost(), subject)
751 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile) 751 self.host.bridge.roomNewSubject(room.roomJID.userhost(), subject, self.parent.profile)