comparison src/plugins/plugin_xep_0249.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 f3513c8cc2e6
children 75f3b3b430ff
comparison
equal deleted inserted replaced
915:6f96ee4d8cc0 916:1a759096ccbd
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from sat.core.constants import Const as C
21 from logging import debug, info, warning, error 22 from logging import debug, info, warning, error
22 from twisted.words.xish import domish 23 from twisted.words.xish import domish
23 from twisted.internet import protocol, defer 24 from twisted.internet import protocol, defer
24 from twisted.words.protocols.jabber import client, jid, xmlstream 25 from twisted.words.protocols.jabber import client, jid, xmlstream
25 26
80 host.bridge.addMethod("inviteMUC", ".plugin", in_sign='sssa{ss}s', out_sign='', method=self._invite) 81 host.bridge.addMethod("inviteMUC", ".plugin", in_sign='sssa{ss}s', out_sign='', method=self._invite)
81 82
82 def getHandler(self, profile): 83 def getHandler(self, profile):
83 return XEP_0249_handler(self) 84 return XEP_0249_handler(self)
84 85
85 def invite(self, target, room, options={}, profile_key='@DEFAULT@'): 86 def invite(self, target, room, options={}, profile_key=C.PROF_KEY_NONE):
86 """ 87 """
87 Invite a user to a room 88 Invite a user to a room
88 @param target: jid of the user to invite 89 @param target: jid of the user to invite
89 @param room: jid of the room where the user is invited 90 @param room: jid of the room where the user is invited
90 @options: attribute with extra info (reason, password) as in #XEP-0249 91 @options: attribute with extra info (reason, password) as in #XEP-0249
100 x_elt['jid'] = room.userhost() 101 x_elt['jid'] = room.userhost()
101 for opt in options: 102 for opt in options:
102 x_elt[opt] = options[opt] 103 x_elt[opt] = options[opt]
103 self.host.profiles[profile].xmlstream.send(message) 104 self.host.profiles[profile].xmlstream.send(message)
104 105
105 def _invite(self, target, service, roomId, options={}, profile_key='@DEFAULT@'): 106 def _invite(self, target, service, roomId, options={}, profile_key=C.PROF_KEY_NONE):
106 """ 107 """
107 Invite an user to a room 108 Invite an user to a room
108 @param target: jid of the user to invite 109 @param target: jid of the user to invite
109 @param service: jid of the MUC service 110 @param service: jid of the MUC service
110 @param roomId: name of the room 111 @param roomId: name of the room
111 @param profile_key: %(doc_profile_key)s 112 @param profile_key: %(doc_profile_key)s
112 """ 113 """
113 #TODO: check parameters validity 114 #TODO: check parameters validity
114 self.invite(jid.JID(target), jid.JID("%s@%s" % (roomId, service)), options, profile_key) 115 self.invite(jid.JID(target), jid.JID("%s@%s" % (roomId, service)), options, profile_key)
115 116
116 def _accept(self, room, profile_key='@DEFAULT@'): 117 def _accept(self, room, profile_key=C.PROF_KEY_NONE):
117 """ 118 """
118 Accept the invitation to join a MUC 119 Accept the invitation to join a MUC
119 @param room: room jid as string 120 @param room: room jid as string
120 """ 121 """
121 profile = self.host.memory.getProfileName(profile_key) 122 profile = self.host.memory.getProfileName(profile_key)