add support for sending invite stanza /invite jid [reason]. I improved patch by Sef

This commit is contained in:
Nikos Kouremenos 2005-09-09 22:00:01 +00:00
parent 0bf0c36323
commit a648d44fd3
2 changed files with 23 additions and 2 deletions

View file

@ -1935,6 +1935,16 @@ class Connection:
q = iq.setTag(common.xmpp.NS_REGISTER + ' query').setTag('remove')
self.to_be_sent.append(iq)
def send_invite(self, room, to, reason=''):
'''sends invitation'''
message=common.xmpp.Message(to = room)
message.addChild(name = 'x',namespace = common.xmpp.NS_MUC_USER)
message.getChildren()[0].addChild(name = 'invite', attrs={'to' : to})
if reason != '':
message.getChildren()[0].getChildren()[0].addChild(name = 'reason')
message.getChildren()[0].getChildren()[0].getChildren()[0].addData(reason)
self.to_be_sent.append(message)
def send_keepalive(self):
# nothing received for the last foo seconds (60 secs by default)
self.to_be_sent.append(' ')

View file

@ -49,8 +49,8 @@ class GroupchatWindow(chat.Chat):
chat.Chat.__init__(self, plugin, account, 'groupchat_window')
# alphanum sorted
self.muc_cmds = ['ban', 'chat', 'clear', 'close', 'compact', 'kick',
'leave', 'me', 'msg', 'nick', 'part', 'topic']
self.muc_cmds = ['ban', 'chat', 'clear', 'close', 'compact', 'invite',
'kick', 'leave', 'me', 'msg', 'nick', 'part', 'topic']
self.nicks = {} # our nick for each groupchat we are in
self.list_treeview = {}
@ -664,6 +664,17 @@ class GroupchatWindow(chat.Chat):
self.print_conversation(self.subjects[room_jid], room_jid)
return # don't print the command
elif message.startswith('/invite'):
# /invite JID reason
after_command = message[7:] # 7 is len('/invite')
splitted_arg = after_command.split()
if len(splitted_arg):
jid_to_invite = splitted_arg[0]
reason = ' '.join(a[1:])
gajim.connections[self.account].send_invite(room_jid,
jid_to_invite, reason)
return # don't print the command
#FIXME: we lack /join to adhere to JEP
elif message.startswith('/leave') or message.startswith('/part')\