Merge the commits I've made yesterday with asterik's ones

This commit is contained in:
Thibaut GIRKA 2009-09-26 12:25:36 +02:00
commit 62d6f408c2
6 changed files with 62 additions and 30 deletions

View File

@ -13,7 +13,7 @@
<property name="buttons">yes-no</property>
<property name="text">&lt;b&gt;&lt;big&gt;Incoming call&lt;/big&gt;&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="secondary_text">%(contact)s wants to start a voice chat with you. Do you want to answer the call?</property>
<signal name="destroy" handler="on_voip_call_received_messagedialog_destroy"/>
<signal name="close" handler="on_voip_call_received_messagedialog_close"/>
<signal name="response" handler="on_voip_call_received_messagedialog_response"/>
<child internal-child="vbox">

View File

@ -1831,7 +1831,7 @@ class ChatControl(ChatControlBase, ChatCommands):
self.set_audio_state('connecting', sid)
else:
session = gajim.connections[self.account].get_jingle_session(
self.contact.get_full_jid(), self.video_sid)
self.contact.get_full_jid(), self.audio_sid)
if session:
content = session.get_content('audio')
if content:

View File

@ -46,7 +46,7 @@ class Event:
gc-invitation: [room_jid, reason, password, is_continued]
subscription_request: [text, nick]
unsubscribed: contact
jingle-*: (fulljid, sessionid)
jingle-incoming: (fulljid, sessionid, content_types)
'''
self.type_ = type_
self.time_ = time_

View File

@ -54,6 +54,7 @@
import gajim
import xmpp
import helpers
import farsight, gst
@ -91,7 +92,7 @@ class JingleSession(object):
# our full jid
self.ourjid = gajim.get_jid_from_account(self.connection.name) + '/' + \
con.server_resource
self.peerjid = str(jid) # jid we connect to
self.peerjid = jid # jid we connect to
# jid we use as the initiator
self.initiator = weinitiate and self.ourjid or self.peerjid
# jid we use as the responder
@ -1037,7 +1038,7 @@ class ConnectionJingle(object):
route it adequatelly.'''
# get data
jid = stanza.getFrom()
jid = helpers.get_full_jid_from_iq(stanza)
id = stanza.getID()
if (jid, id) in self.__iq_responses.keys():

View File

@ -4443,14 +4443,14 @@ class GPGInfoWindow:
self.window.destroy()
class VoIPCallReceivedDialog(object):
instances = WeakValueDictionary()
instances = {}
def __init__(self, account, contact_jid, sid):
def __init__(self, account, contact_jid, sid, content_types):
self.instances[(contact_jid, sid)] = self
self.account = account
self.fjid = contact_jid
self.sid = sid
self.instances[(contact_jid, sid)] = self
self.content_types = content_types
xml = gtkgui_helpers.get_glade('voip_call_received_dialog.glade')
xml.signal_autoconnect(self)
@ -4458,17 +4458,14 @@ class VoIPCallReceivedDialog(object):
jid = gajim.get_jid_without_resource(self.fjid)
contact = gajim.contacts.get_first_contact_from_jid(account, jid)
if contact and contact.name:
contact_text = '%s (%s)' % (contact.name, jid)
self.contact_text = '%s (%s)' % (contact.name, jid)
else:
contact_text = contact_jid
self.contact_text = contact_jid
# do the substitution
dialog = xml.get_widget('voip_call_received_messagedialog')
dialog.set_property('secondary-text',
dialog.get_property('secondary-text') % {'contact': contact_text})
self._dialog = dialog
self.dialog = xml.get_widget('voip_call_received_messagedialog')
self.set_secondary_text()
dialog.show_all()
self.dialog.show_all()
@classmethod
def get_dialog(cls, jid, sid):
@ -4477,6 +4474,29 @@ class VoIPCallReceivedDialog(object):
else:
return None
def set_secondary_text(self):
if 'audio' in self.content_types and 'video' in self.content_types:
types_text = _('an audio and video')
elif 'audio' in self.content_types:
types_text = _('an audio')
elif 'video' in self.content_types:
types_text = _('a video')
# do the substitution
self.dialog.set_property('secondary-text',
_('%(contact)s wants to start %(type)s session with you. Do you want '
'to answer the call?') % {'contact': self.contact_text, 'type': types_text})
def add_contents(self, content_types):
for type_ in content_types:
if type_ not in self.content_types:
self.content_types.append(type_)
self.set_secondary_text()
def on_voip_call_received_messagedialog_destroy(self, dialog):
if (self.fjid, self.sid) in self.instances:
del self.instances[(self.fjid, self.sid)]
def on_voip_call_received_messagedialog_close(self, dialog):
return self.on_voip_call_received_messagedialog_response(dialog,
gtk.RESPONSE_NO)
@ -4485,8 +4505,13 @@ class VoIPCallReceivedDialog(object):
# we've got response from user, either stop connecting or accept the call
session = gajim.connections[self.account].get_jingle_session(self.fjid,
self.sid)
if response==gtk.RESPONSE_YES:
session.approve_session()
if not session:
return
if response == gtk.RESPONSE_YES:
if not session.accepted:
session.approve_session()
for content in self.content_types:
session.approve_content(content)
jid = gajim.get_jid_without_resource(self.fjid)
resource = gajim.get_resource_from_jid(self.fjid)
ctrl = gajim.interface.msg_win_mgr.get_control(self.fjid, self.account)

View File

@ -2098,7 +2098,7 @@ class Interface:
# ('JINGLE_INCOMING', account, peer jid, sid, tuple-of-contents==(type,
# data...))
# TODO: conditional blocking if peer is not in roster
# unpack data
peerjid, sid, contents = data
content_types = set(c[0] for c in contents)
@ -2124,11 +2124,17 @@ class Interface:
if 'video' in content_types:
ctrl.set_video_state('connection_received', sid)
if helpers.allow_popup_window(account):
dialogs.VoIPCallReceivedDialog(account, peerjid, sid)
dlg = dialogs.VoIPCallReceivedDialog.get_dialog(peerjid, sid)
if dlg:
dlg.add_contents(content_types)
return
self.add_event(account, peerjid, 'voip-incoming', (peerjid, sid,))
if helpers.allow_popup_window(account):
dialogs.VoIPCallReceivedDialog(account, peerjid, sid, content_types)
return
self.add_event(account, peerjid, 'jingle-incoming', (peerjid, sid,
content_types))
if helpers.allow_showing_notification(account):
# TODO: we should use another pixmap ;-)
@ -2138,7 +2144,7 @@ class Interface:
account, peerjid)
path = gtkgui_helpers.get_path_to_generic_or_avatar(img)
event_type = _('Voice Chat Request')
notify.popup(event_type, peerjid, account, 'voip-incoming',
notify.popup(event_type, peerjid, account, 'jingle-incoming',
path_to_image = path, title = event_type, text = txt)
def handle_event_jingle_connected(self, account, data):
@ -2169,7 +2175,7 @@ class Interface:
ctrl.set_video_state('stop', sid=sid, reason=reason)
dialog = dialogs.VoIPCallReceivedDialog.get_dialog(peerjid, sid)
if dialog:
dialog._dialog.destroy()
dialog.dialog.destroy()
def handle_event_jingle_error(self, account, data):
# ('JINGLE_ERROR', account, (peerjid, sid, reason))
@ -2457,7 +2463,7 @@ class Interface:
jid = gajim.get_jid_without_resource(jid)
no_queue = len(gajim.events.get_events(account, jid)) == 0
# type_ can be gc-invitation file-send-error file-error file-request-error
# file-request file-completed file-stopped voip-incoming
# file-request file-completed file-stopped jingle-incoming
# event_type can be in advancedNotificationWindow.events_list
event_types = {'file-request': 'ft_request',
'file-completed': 'ft_finished'}
@ -2617,10 +2623,10 @@ class Interface:
self.show_unsubscribed_dialog(account, contact)
gajim.events.remove_events(account, jid, event)
self.roster.draw_contact(jid, account)
elif type_ == 'voip-incoming':
event = gajim.events.get_first_event(account, jid, type_)
peerjid, sid = event.parameters
dialogs.VoIPCallReceivedDialog(account, peerjid, sid)
elif type_ == 'jingle-incoming':
event = gajim.events.get_first_event(account, jid, type_)
peerjid, sid, content_types = event.parameters
dialogs.VoIPCallReceivedDialog(account, peerjid, sid, content_types)
gajim.events.remove_events(account, jid, event)
if w:
w.set_active_tab(ctrl)