core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
This commit is contained in:
parent
2a40da1664
commit
005ec59a8a
1 changed files with 123 additions and 101 deletions
|
|
@ -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 @@ class XEP_0045(object):
|
|||
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 @@ class XEP_0045(object):
|
|||
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 @@ class XEP_0045(object):
|
|||
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 @@ class XEP_0045(object):
|
|||
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 @@ class XEP_0045(object):
|
|||
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 @@ class XEP_0045(object):
|
|||
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 @@ class XEP_0045(object):
|
|||
# > /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 @@ class XEP_0045(object):
|
|||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue