use NEC to handle jingle incoming events
This commit is contained in:
parent
ffa7cbda9c
commit
ab2ddc4935
|
@ -1113,3 +1113,12 @@ class GcMessageReceivedEvent(nec.NetworkIncomingEvent):
|
||||||
class AnonymousAuthEvent(nec.NetworkIncomingEvent):
|
class AnonymousAuthEvent(nec.NetworkIncomingEvent):
|
||||||
name = 'anonymous-auth'
|
name = 'anonymous-auth'
|
||||||
base_network_events = []
|
base_network_events = []
|
||||||
|
|
||||||
|
class JingleReceivedEvent(nec.NetworkIncomingEvent):
|
||||||
|
name = 'jingle-received'
|
||||||
|
base_network_events = []
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
self.jid = self.jingle_session.peerjid
|
||||||
|
self.sid = self.jingle_session.sid
|
||||||
|
return True
|
|
@ -30,6 +30,7 @@ import gajim #Get rid of that?
|
||||||
import xmpp
|
import xmpp
|
||||||
from jingle_transport import get_jingle_transport
|
from jingle_transport import get_jingle_transport
|
||||||
from jingle_content import get_jingle_content, JingleContentSetupException
|
from jingle_content import get_jingle_content, JingleContentSetupException
|
||||||
|
from common.connection_handlers_events import JingleReceivedEvent
|
||||||
|
|
||||||
# FIXME: Move it to JingleSession.States?
|
# FIXME: Move it to JingleSession.States?
|
||||||
class JingleStates(object):
|
class JingleStates(object):
|
||||||
|
@ -407,8 +408,8 @@ class JingleSession(object):
|
||||||
self.__content_reject(content)
|
self.__content_reject(content)
|
||||||
self.contents[(content.creator, content.name)].destroy()
|
self.contents[(content.creator, content.name)].destroy()
|
||||||
|
|
||||||
self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
|
gajim.nec.push_incoming_event(JingleReceivedEvent(None,
|
||||||
contents))
|
conn=self.connection, jingle_session=self, contents=contents))
|
||||||
|
|
||||||
def __on_session_initiate(self, stanza, jingle, error, action):
|
def __on_session_initiate(self, stanza, jingle, error, action):
|
||||||
"""
|
"""
|
||||||
|
@ -453,8 +454,8 @@ class JingleSession(object):
|
||||||
self.state = JingleStates.pending
|
self.state = JingleStates.pending
|
||||||
|
|
||||||
# Send event about starting a session
|
# Send event about starting a session
|
||||||
self.connection.dispatch('JINGLE_INCOMING', (self.peerjid, self.sid,
|
gajim.nec.push_incoming_event(JingleReceivedEvent(None,
|
||||||
contents))
|
conn=self.connection, jingle_session=self, contents=contents))
|
||||||
|
|
||||||
def __broadcast(self, stanza, jingle, error, action):
|
def __broadcast(self, stanza, jingle, error, action):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1495,14 +1495,13 @@ class Interface:
|
||||||
'resource. Please type a new one'), resource=proposed_resource,
|
'resource. Please type a new one'), resource=proposed_resource,
|
||||||
ok_handler=on_ok)
|
ok_handler=on_ok)
|
||||||
|
|
||||||
def handle_event_jingle_incoming(self, account, data):
|
def handle_event_jingle_incoming(self, obj):
|
||||||
# ('JINGLE_INCOMING', account, peer jid, sid, tuple-of-contents==(type,
|
# ('JINGLE_INCOMING', account, peer jid, sid, tuple-of-contents==(type,
|
||||||
# data...))
|
# data...))
|
||||||
# TODO: conditional blocking if peer is not in roster
|
# TODO: conditional blocking if peer is not in roster
|
||||||
|
|
||||||
# unpack data
|
account = obj.conn.name
|
||||||
peerjid, sid, contents = data
|
content_types = set(c[0] for c in obj.contents)
|
||||||
content_types = set(c[0] for c in contents)
|
|
||||||
|
|
||||||
# check type of jingle session
|
# check type of jingle session
|
||||||
if 'audio' in content_types or 'video' in content_types:
|
if 'audio' in content_types or 'video' in content_types:
|
||||||
|
@ -1514,35 +1513,36 @@ class Interface:
|
||||||
# unknown session type... it should be declined in common/jingle.py
|
# unknown session type... it should be declined in common/jingle.py
|
||||||
return
|
return
|
||||||
|
|
||||||
jid = gajim.get_jid_without_resource(peerjid)
|
jid = gajim.get_jid_without_resource(obj.jid)
|
||||||
resource = gajim.get_resource_from_jid(peerjid)
|
resource = gajim.get_resource_from_jid(obj.jid)
|
||||||
ctrl = (self.msg_win_mgr.get_control(peerjid, account)
|
ctrl = (self.msg_win_mgr.get_control(obj.jid, account)
|
||||||
or self.msg_win_mgr.get_control(jid, account))
|
or self.msg_win_mgr.get_control(jid, account))
|
||||||
if ctrl:
|
if ctrl:
|
||||||
if 'audio' in content_types:
|
if 'audio' in content_types:
|
||||||
ctrl.set_audio_state('connection_received', sid)
|
ctrl.set_audio_state('connection_received', obj.sid)
|
||||||
if 'video' in content_types:
|
if 'video' in content_types:
|
||||||
ctrl.set_video_state('connection_received', sid)
|
ctrl.set_video_state('connection_received', obj.sid)
|
||||||
|
|
||||||
dlg = dialogs.VoIPCallReceivedDialog.get_dialog(peerjid, sid)
|
dlg = dialogs.VoIPCallReceivedDialog.get_dialog(obj.jid, obj.sid)
|
||||||
if dlg:
|
if dlg:
|
||||||
dlg.add_contents(content_types)
|
dlg.add_contents(content_types)
|
||||||
return
|
return
|
||||||
|
|
||||||
if helpers.allow_popup_window(account):
|
if helpers.allow_popup_window(account):
|
||||||
dialogs.VoIPCallReceivedDialog(account, peerjid, sid, content_types)
|
dialogs.VoIPCallReceivedDialog(account, obj.jid, obj.sid,
|
||||||
|
content_types)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.add_event(account, peerjid, 'jingle-incoming', (peerjid, sid,
|
self.add_event(account, obj.jid, 'jingle-incoming', (obj.jid, obj.sid,
|
||||||
content_types))
|
content_types))
|
||||||
|
|
||||||
if helpers.allow_showing_notification(account):
|
if helpers.allow_showing_notification(account):
|
||||||
# TODO: we should use another pixmap ;-)
|
# TODO: we should use another pixmap ;-)
|
||||||
txt = _('%s wants to start a voice chat.') % \
|
txt = _('%s wants to start a voice chat.') % \
|
||||||
gajim.get_name_from_jid(account, peerjid)
|
gajim.get_name_from_jid(account, obj.jid)
|
||||||
path = gtkgui_helpers.get_icon_path('gajim-mic_active', 48)
|
path = gtkgui_helpers.get_icon_path('gajim-mic_active', 48)
|
||||||
event_type = _('Voice Chat Request')
|
event_type = _('Voice Chat Request')
|
||||||
notify.popup(event_type, peerjid, account, 'jingle-incoming',
|
notify.popup(event_type, obj.jid, account, 'jingle-incoming',
|
||||||
path_to_image=path, title=event_type, text=txt)
|
path_to_image=path, title=event_type, text=txt)
|
||||||
|
|
||||||
def handle_event_jingle_connected(self, account, data):
|
def handle_event_jingle_connected(self, account, data):
|
||||||
|
@ -1894,7 +1894,6 @@ class Interface:
|
||||||
'INSECURE_SSL_CONNECTION': \
|
'INSECURE_SSL_CONNECTION': \
|
||||||
[self.handle_event_insecure_ssl_connection],
|
[self.handle_event_insecure_ssl_connection],
|
||||||
'INSECURE_PASSWORD': [self.handle_event_insecure_password],
|
'INSECURE_PASSWORD': [self.handle_event_insecure_password],
|
||||||
'JINGLE_INCOMING': [self.handle_event_jingle_incoming],
|
|
||||||
'JINGLE_CONNECTED': [self.handle_event_jingle_connected],
|
'JINGLE_CONNECTED': [self.handle_event_jingle_connected],
|
||||||
'JINGLE_DISCONNECTED': [self.handle_event_jingle_disconnected],
|
'JINGLE_DISCONNECTED': [self.handle_event_jingle_disconnected],
|
||||||
'JINGLE_ERROR': [self.handle_event_jingle_error],
|
'JINGLE_ERROR': [self.handle_event_jingle_error],
|
||||||
|
@ -1908,6 +1907,7 @@ class Interface:
|
||||||
'gmail-notify': [self.handle_event_gmail_notify],
|
'gmail-notify': [self.handle_event_gmail_notify],
|
||||||
'http-auth-received': [self.handle_event_http_auth],
|
'http-auth-received': [self.handle_event_http_auth],
|
||||||
'iq-error-received': [self.handle_event_iq_error],
|
'iq-error-received': [self.handle_event_iq_error],
|
||||||
|
'jingle-received': [self.handle_event_jingle_incoming],
|
||||||
'last-result-received': [self.handle_event_last_status_time],
|
'last-result-received': [self.handle_event_last_status_time],
|
||||||
'muc-admin-received': [self.handle_event_gc_affiliation],
|
'muc-admin-received': [self.handle_event_gc_affiliation],
|
||||||
'muc-owner-received': [self.handle_event_gc_config],
|
'muc-owner-received': [self.handle_event_gc_config],
|
||||||
|
|
Loading…
Reference in New Issue