Commit 829892f4 authored by Yann Leboulanger's avatar Yann Leboulanger

[misc] ability to request voice in moderated rooms. Fixes #2266

parent 03c13ab6
......@@ -66,6 +66,19 @@
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="request_voice_separator">
<property name="no_show_all">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="request_voice_menuitem">
<property name="label" translatable="yes">_Request Voice</property>
<property name="visible">True</property>
<property name="use_underline">True</property>
<property name="use_stock">False</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="bookmark_separator">
<property name="no_show_all">True</property>
......
......@@ -2496,6 +2496,22 @@ def send_invite(self, room, to, reason='', continue_tag=False):
c.setTagData('reason', reason)
self.connection.send(message)
def request_voice(self, room, nick):
"""
Request voice in a moderated room
"""
message = common.xmpp.Message(to=room)
x = xmpp.DataForm(typ='submit')
x.addChild(node=xmpp.DataField(name='FORM_TYPE',
value=common.xmpp.NS_MUC + '#request'))
x.addChild(node=xmpp.DataField(name='muc#role', value='participant',
typ='text-single'))
message.addChild(node=x)
self.connection.send(message)
def check_pingalive(self):
if self.awaiting_xmpp_ping_id:
# We haven't got the pong in time, disco and reconnect
......
......@@ -789,8 +789,10 @@ def prepare_context_menu(self, hide_buttonbar_items=False):
change_subject_menuitem = xml.get_object('change_subject_menuitem')
history_menuitem = xml.get_object('history_menuitem')
minimize_menuitem = xml.get_object('minimize_menuitem')
request_voice_menuitem = xml.get_object('request_voice_menuitem')
bookmark_separator = xml.get_object('bookmark_separator')
separatormenuitem2 = xml.get_object('separatormenuitem2')
request_voice_separator = xml.get_object('request_voice_separator')
if hide_buttonbar_items:
change_nick_menuitem.hide()
......@@ -840,12 +842,17 @@ def prepare_context_menu(self, hide_buttonbar_items=False):
destroy_room_menuitem.set_sensitive(True)
change_subject_menuitem.set_sensitive(True)
change_nick_menuitem.set_sensitive(True)
if c.role == 'visitor':
request_voice_menuitem.set_sensitive(True)
else:
request_voice_menuitem.set_sensitive(False)
else:
# We are not connected to this groupchat, disable unusable menuitems
configure_room_menuitem.set_sensitive(False)
destroy_room_menuitem.set_sensitive(False)
change_subject_menuitem.set_sensitive(False)
change_nick_menuitem.set_sensitive(False)
request_voice_menuitem.set_sensitive(False)
# connect the menuitems to their respective functions
id_ = bookmark_room_menuitem.connect('activate',
......@@ -872,6 +879,10 @@ def prepare_context_menu(self, hide_buttonbar_items=False):
self._on_history_menuitem_activate)
self.handlers[id_] = history_menuitem
id_ = request_voice_menuitem.connect('activate',
self._on_request_voice_menuitem_activate)
self.handlers[id_] = request_voice_menuitem
id_ = minimize_menuitem.connect('toggled',
self.on_minimize_menuitem_toggled)
self.handlers[id_] = minimize_menuitem
......@@ -2068,6 +2079,12 @@ def _on_bookmark_room_menuitem_activate(self, widget):
gajim.interface.add_gc_bookmark(self.account, self.name, self.room_jid,\
'0', '0', password, self.nick)
def _on_request_voice_menuitem_activate(self, widget):
"""
Request voice in the current room
"""
gajim.connections[self.account].request_voice(self.room_jid)
def _on_drag_data_received(self, widget, context, x, y, selection,
target_type, timestamp):
# Invite contact to groupchat
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment