hack in order to register our Event handler as soon as Dispatcher is pluged in
This commit is contained in:
parent
004cb9c5d3
commit
6d3fe8e459
|
@ -1487,7 +1487,7 @@ class Connection:
|
||||||
else:
|
else:
|
||||||
proxy = None
|
proxy = None
|
||||||
if gajim.verbose:
|
if gajim.verbose:
|
||||||
con = common.xmpp.Client(hostname)
|
con = common.xmpp.Client(hostname, caller = self)
|
||||||
else:
|
else:
|
||||||
con = common.xmpp.Client(hostname, debug = [])
|
con = common.xmpp.Client(hostname, debug = [])
|
||||||
common.xmpp.dispatcher.DefaultTimeout = try_connecting_for_foo_secs
|
common.xmpp.dispatcher.DefaultTimeout = try_connecting_for_foo_secs
|
||||||
|
@ -1617,7 +1617,6 @@ class Connection:
|
||||||
con.RegisterHandler('iq', self._StanzaArrivedCB)
|
con.RegisterHandler('iq', self._StanzaArrivedCB)
|
||||||
con.RegisterHandler('presence', self._StanzaArrivedCB)
|
con.RegisterHandler('presence', self._StanzaArrivedCB)
|
||||||
con.RegisterHandler('message', self._StanzaArrivedCB)
|
con.RegisterHandler('message', self._StanzaArrivedCB)
|
||||||
con.RegisterEventHandler(self._event_dispatcher)
|
|
||||||
|
|
||||||
name = gajim.config.get_per('accounts', self.name, 'name')
|
name = gajim.config.get_per('accounts', self.name, 'name')
|
||||||
hostname = gajim.config.get_per('accounts', self.name, 'hostname')
|
hostname = gajim.config.get_per('accounts', self.name, 'hostname')
|
||||||
|
@ -1636,7 +1635,6 @@ class Connection:
|
||||||
return None
|
return None
|
||||||
if hasattr(con, 'Resource'):
|
if hasattr(con, 'Resource'):
|
||||||
self.server_resource = con.Resource
|
self.server_resource = con.Resource
|
||||||
con.RegisterEventHandler(self._event_dispatcher)
|
|
||||||
if auth:
|
if auth:
|
||||||
con.initRoster()
|
con.initRoster()
|
||||||
self.last_io = time.time()
|
self.last_io = time.time()
|
||||||
|
@ -1937,7 +1935,6 @@ class Connection:
|
||||||
(_('Could not connect to "%s"') % config['hostname']))
|
(_('Could not connect to "%s"') % config['hostname']))
|
||||||
return
|
return
|
||||||
|
|
||||||
con.RegisterEventHandler(self._event_dispatcher)
|
|
||||||
self.new_account_info = config
|
self.new_account_info = config
|
||||||
self.connection = con
|
self.connection = con
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
|
@ -87,7 +87,7 @@ class PlugIn:
|
||||||
import transports,dispatcher,auth,roster
|
import transports,dispatcher,auth,roster
|
||||||
class CommonClient:
|
class CommonClient:
|
||||||
""" Base for Client and Component classes."""
|
""" Base for Client and Component classes."""
|
||||||
def __init__(self,server,port=5222,debug=['always', 'nodebuilder']):
|
def __init__(self,server,port=5222,debug=['always', 'nodebuilder'],caller=None):
|
||||||
""" Caches server name and (optionally) port to connect to. "debug" parameter specifies
|
""" Caches server name and (optionally) port to connect to. "debug" parameter specifies
|
||||||
the debug IDs that will go into debug output. You can either specifiy an "include"
|
the debug IDs that will go into debug output. You can either specifiy an "include"
|
||||||
or "exclude" list. The latter is done via adding "always" pseudo-ID to the list.
|
or "exclude" list. The latter is done via adding "always" pseudo-ID to the list.
|
||||||
|
@ -99,6 +99,9 @@ class CommonClient:
|
||||||
self.disconnect_handlers=[]
|
self.disconnect_handlers=[]
|
||||||
self.Server=server
|
self.Server=server
|
||||||
self.Port=port
|
self.Port=port
|
||||||
|
# Who initiated this client
|
||||||
|
# Used to register the EventDispatcher
|
||||||
|
self._caller=caller
|
||||||
if debug and type(debug)<>list: debug=['always', 'nodebuilder']
|
if debug and type(debug)<>list: debug=['always', 'nodebuilder']
|
||||||
self._DEBUG=Debug.Debug(debug)
|
self._DEBUG=Debug.Debug(debug)
|
||||||
self.DEBUG=self._DEBUG.Show
|
self.DEBUG=self._DEBUG.Show
|
||||||
|
|
|
@ -69,6 +69,8 @@ class Dispatcher(PlugIn):
|
||||||
self.RegisterProtocol('presence',Presence)
|
self.RegisterProtocol('presence',Presence)
|
||||||
self.RegisterProtocol('message',Message)
|
self.RegisterProtocol('message',Message)
|
||||||
self.RegisterDefaultHandler(self.returnStanzaHandler)
|
self.RegisterDefaultHandler(self.returnStanzaHandler)
|
||||||
|
# Register Gajim's event handler as soon as dispatcher begins
|
||||||
|
self.RegisterEventHandler(self._owner._caller._event_dispatcher)
|
||||||
# self.RegisterHandler('error',self.streamErrorHandler,xmlns=NS_STREAMS)
|
# self.RegisterHandler('error',self.streamErrorHandler,xmlns=NS_STREAMS)
|
||||||
|
|
||||||
def plugin(self, owner):
|
def plugin(self, owner):
|
||||||
|
|
Loading…
Reference in New Issue