show invitation to groupchats in chat window info bar. Fixes #1804

This commit is contained in:
Yann Leboulanger 2012-04-09 21:26:35 +02:00
parent 444bed2784
commit 07b8d1a358
1 changed files with 45 additions and 3 deletions

View File

@ -56,6 +56,7 @@ from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION
from common.xmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_JINGLE_ICE_UDP from common.xmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_JINGLE_ICE_UDP
from common.xmpp.protocol import NS_CHATSTATES from common.xmpp.protocol import NS_CHATSTATES
from common.connection_handlers_events import MessageOutgoingEvent from common.connection_handlers_events import MessageOutgoingEvent
from common.exceptions import GajimGeneralException
from command_system.implementation.middleware import ChatCommandProcessor from command_system.implementation.middleware import ChatCommandProcessor
from command_system.implementation.middleware import CommandTools from command_system.implementation.middleware import CommandTools
@ -3246,6 +3247,36 @@ class ChatControl(ChatControlBase):
b.connect('clicked', self._on_ok, file_props, type_) b.connect('clicked', self._on_ok, file_props, type_)
self._add_info_bar_message(markup, [b], file_props, gtk.MESSAGE_ERROR) self._add_info_bar_message(markup, [b], file_props, gtk.MESSAGE_ERROR)
def _on_accept_gc_invitation(self, widget, event):
room_jid = event.parameters[0]
password = event.parameters[2]
is_continued = event.parameters[3]
try:
if is_continued:
gajim.interface.join_gc_room(self.account, room_jid,
gajim.nicks[self.account], password, is_continued=True)
else:
dialogs.JoinGroupchatWindow(self.account, room_jid)
except GajimGeneralException:
pass
gajim.events.remove_events(self.account, self.contact.jid, event=event)
def _on_cancel_gc_invitation(self, widget, event):
gajim.events.remove_events(self.account, self.contact.jid, event=event)
def _get_gc_invitation(self, event):
room_jid = event.parameters[0]
comment = event.parameters[1]
markup = '<b>%s:</b> %s' % (_('Groupchat Invitation'), room_jid)
if comment:
markup += ' (%s)' % comment
b1 = gtk.Button(_('_Join'))
b1.connect('clicked', self._on_accept_gc_invitation, event)
b2 = gtk.Button(stock=gtk.STOCK_CANCEL)
b2.connect('clicked', self._on_cancel_gc_invitation, event)
self._add_info_bar_message(markup, [b1, b2], event.parameters,
gtk.MESSAGE_QUESTION)
def on_event_added(self, event): def on_event_added(self, event):
if event.account != self.account: if event.account != self.account:
return return
@ -3267,6 +3298,8 @@ class ChatControl(ChatControlBase):
self._got_file_error(event.parameters, event.type_, self._got_file_error(event.parameters, event.type_,
_('File transfer cancelled'), _('File transfer cancelled'),
_('Connection with peer cannot be established.')) _('Connection with peer cannot be established.'))
elif event.type_ == 'gc-invitation':
self._get_gc_invitation(event)
def on_event_removed(self, event_list): def on_event_removed(self, event_list):
""" """
@ -3278,12 +3311,21 @@ class ChatControl(ChatControlBase):
if ev.jid != self.contact.jid: if ev.jid != self.contact.jid:
continue continue
if ev.type_ not in ('file-request', 'file-completed', 'file-error', if ev.type_ not in ('file-request', 'file-completed', 'file-error',
'file-stopped', 'file-request-error', 'file-send-error'): 'file-stopped', 'file-request-error', 'file-send-error',
'gc-invitation'):
continue continue
i = 0 i = 0
removed = False
for ib_msg in self.info_bar_queue: for ib_msg in self.info_bar_queue:
if ib_msg[2] == ev.parameters: if ev.type_ == 'gc-invitation':
self.info_bar_queue.remove(ib_msg) if ev.parameters[0] == ib_msg[2][0]:
self.info_bar_queue.remove(ib_msg)
removed = True
else: # file-*
if ib_msg[2] == ev.parameters:
self.info_bar_queue.remove(ib_msg)
removed = True
if removed:
if i == 0: if i == 0:
# We are removing the one currently displayed # We are removing the one currently displayed
self.info_bar.set_no_show_all(True) self.info_bar.set_no_show_all(True)