Mercurial > libervia-backend
diff src/plugins/plugin_xep_0045.py @ 916:1a759096ccbd
core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 21 Mar 2014 16:27:09 +0100 |
parents | 1fe00f0c9a91 |
children | d609581bf74a |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0045.py Fri Mar 21 16:19:46 2014 +0100 +++ b/src/plugins/plugin_xep_0045.py Fri Mar 21 16:27:09 2014 +0100 @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from sat.core.i18n import _ +from sat.core.constants import Const as C from logging import debug, info, warning, error from twisted.internet import defer from twisted.words.protocols.jabber import jid @@ -116,7 +117,7 @@ self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile) raise failure - def getRoomsJoined(self, profile_key='@DEFAULT@'): + def getRoomsJoined(self, profile_key=C.PROF_KEY_NONE): """Return room where user is""" profile = self.host.memory.getProfileName(profile_key) result = [] @@ -126,7 +127,7 @@ result.append((room.roomJID.userhost(), [user.nick for user in room.roster.values()], room.nick)) return result - def getRoomNick(self, room_jid_s, profile_key='@DEFAULT@'): + def getRoomNick(self, room_jid_s, profile_key=C.PROF_KEY_NONE): """return nick used in room by user @param room_jid_s: unicode room id @profile_key: profile @@ -174,12 +175,12 @@ nicks.append(nick) return nicks, missing - def _configureRoom(self, room_jid_s, profile_key='@NONE@'): + def _configureRoom(self, room_jid_s, profile_key=C.PROF_KEY_NONE): d = self.configureRoom(jid.JID(room_jid_s), profile_key) d.addCallback(lambda xmlui: xmlui.toXml()) return d - def configureRoom(self, room_jid, profile_key='@NONE@'): + def configureRoom(self, room_jid, profile_key=C.PROF_KEY_NONE): """ return the room configuration form @param room: jid of the room to configure @param profile_key: %(doc_profile_key)s @@ -228,7 +229,7 @@ raise UnknownRoom("This room has not been joined") return self.clients[profile].joined_rooms[room_jid.userhost()].inRoster(muc.User(nick)) - def getRoomsSubjects(self, profile_key='@DEFAULT@'): + def getRoomsSubjects(self, profile_key=C.PROF_KEY_NONE): """Return received subjects of rooms""" profile = self.host.memory.getProfileName(profile_key) if not self.__check_profile(profile): @@ -248,7 +249,7 @@ break return muc_service - def getUniqueName(self, muc_service="", profile_key='@DEFAULT@'): + def getUniqueName(self, muc_service="", profile_key=C.PROF_KEY_NONE): """Return unique name for room, avoiding collision @param muc_service: leave empty string to use the default service @return: unique room userhost, or '' if an error occured. @@ -268,7 +269,7 @@ muc_service = muc_service.userhost() return "%s@%s" % (room_name, muc_service) - def join(self, room_jid, nick, options, profile_key='@DEFAULT@'): + def join(self, room_jid, nick, options, profile_key=C.PROF_KEY_NONE): def _errDeferred(exc_obj=Exception, txt='Error while joining room'): d = defer.Deferred() d.errback(exc_obj(txt)) @@ -291,7 +292,7 @@ # > /usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py(480)_startRunCallbacks() # -> raise AlreadyCalledError(extra) - def _join(self, room_jid_s, nick, options={}, profile_key='@DEFAULT@'): + def _join(self, room_jid_s, nick, options={}, profile_key=C.PROF_KEY_NONE): """join method used by bridge: use the join method, but doesn't return any deferred @return the room userhost (given value or unique generated name) """ @@ -335,11 +336,11 @@ raise UnknownRoom("This room has not been joined") return self.clients[profile].subject(room_jid, subject) - def mucNick(self, room_jid_s, nick, profile_key='@DEFAULT@'): + def mucNick(self, room_jid_s, nick, profile_key=C.PROF_KEY_NONE): """Change nickname in a room""" return self.nick(jid.JID(room_jid_s), nick, profile_key) - def mucLeave(self, room_jid_s, profile_key='@DEFAULT@'): + def mucLeave(self, room_jid_s, profile_key=C.PROF_KEY_NONE): """Leave a room""" return self.leave(jid.JID(room_jid_s), profile_key)