coding standards

This commit is contained in:
Yann Leboulanger 2010-10-06 21:11:23 +02:00
parent 3876638860
commit d39a962157

View file

@ -100,19 +100,19 @@ class ConnectionDisco:
Holds xmpppy handlers and public methods for discover services Holds xmpppy handlers and public methods for discover services
""" """
def discoverItems(self, jid, node = None, id_prefix = None): def discoverItems(self, jid, node=None, id_prefix=None):
""" """
According to XEP-0030: According to XEP-0030:
jid is mandatory; jid is mandatory;
name, node, action is optional. name, node, action is optional.
""" """
self._discover(common.xmpp.NS_DISCO_ITEMS, jid, node, id_prefix) self._discover(common.xmpp.NS_DISCO_ITEMS, jid, node, id_prefix)
def discoverInfo(self, jid, node = None, id_prefix = None): def discoverInfo(self, jid, node=None, id_prefix=None):
""" """
According to XEP-0030: According to XEP-0030:
For identity: category, type is mandatory, name is optional. For identity: category, type is mandatory, name is optional.
For feature: var is mandatory. For feature: var is mandatory.
""" """
self._discover(common.xmpp.NS_DISCO_INFO, jid, node, id_prefix) self._discover(common.xmpp.NS_DISCO_INFO, jid, node, id_prefix)
@ -124,15 +124,15 @@ class ConnectionDisco:
iq.setID(id_) iq.setID(id_)
# Wait the answer during 30 secondes # Wait the answer during 30 secondes
self.awaiting_timeouts[gajim.idlequeue.current_time() + 30] = (id_, self.awaiting_timeouts[gajim.idlequeue.current_time() + 30] = (id_,
_('Registration information for transport %s has not arrived in time')\ _('Registration information for transport %s has not arrived in '
% agent) 'time') % agent)
self.connection.SendAndCallForResponse(iq, self._ReceivedRegInfo, self.connection.SendAndCallForResponse(iq, self._ReceivedRegInfo,
{'agent': agent}) {'agent': agent})
def _agent_registered_cb(self, con, resp, agent): def _agent_registered_cb(self, con, resp, agent):
if resp.getType() == 'result': if resp.getType() == 'result':
self.dispatch('INFORMATION', (_('Registration succeeded'), self.dispatch('INFORMATION', (_('Registration succeeded'),
_('Registration with agent %s succeeded') % agent)) _('Registration with agent %s succeeded') % agent))
self.request_subscription(agent, auto_auth=True) self.request_subscription(agent, auto_auth=True)
self.agent_registrations[agent]['roster_push'] = True self.agent_registrations[agent]['roster_push'] = True
if self.agent_registrations[agent]['sub_received']: if self.agent_registrations[agent]['sub_received']:
@ -140,12 +140,12 @@ class ConnectionDisco:
p = self.add_sha(p) p = self.add_sha(p)
self.connection.send(p) self.connection.send(p)
if resp.getType() == 'error': if resp.getType() == 'error':
self.dispatch('ERROR', (_('Registration failed'), _('Registration with' self.dispatch('ERROR', (_('Registration failed'), _('Registration '
' agent %(agent)s failed with error %(error)s: %(error_msg)s') % { 'with agent %(agent)s failed with error %(error)s: '
'agent': agent, 'error': resp.getError(), '%(error_msg)s') % {'agent': agent, 'error': resp.getError(),
'error_msg': resp.getErrorMsg()})) 'error_msg': resp.getErrorMsg()}))
def register_agent(self, agent, info, is_form = False): def register_agent(self, agent, info, is_form=False):
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
if is_form: if is_form:
@ -153,14 +153,14 @@ class ConnectionDisco:
query = iq.getTag('query') query = iq.getTag('query')
info.setAttr('type', 'submit') info.setAttr('type', 'submit')
query.addChild(node=info) query.addChild(node=info)
self.connection.SendAndCallForResponse(iq, self._agent_registered_cb, self.connection.SendAndCallForResponse(iq,
{'agent': agent}) self._agent_registered_cb, {'agent': agent})
else: else:
# fixed: blocking # fixed: blocking
common.xmpp.features_nb.register(self.connection, agent, info, common.xmpp.features_nb.register(self.connection, agent, info,
self._agent_registered_cb, {'agent': agent}) self._agent_registered_cb, {'agent': agent})
self.agent_registrations[agent] = {'roster_push': False, self.agent_registrations[agent] = {'roster_push': False,
'sub_received': False} 'sub_received': False}
def _discover(self, ns, jid, node=None, id_prefix=None): def _discover(self, ns, jid, node=None, id_prefix=None):
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
@ -187,10 +187,11 @@ class ConnectionDisco:
to = unicode(iq_obj.getAttr('to')) to = unicode(iq_obj.getAttr('to'))
id_ = unicode(iq_obj.getAttr('id')) id_ = unicode(iq_obj.getAttr('id'))
iq = common.xmpp.Iq(to=frm, typ='result', queryNS=common.xmpp.NS_DISCO, iq = common.xmpp.Iq(to=frm, typ='result', queryNS=common.xmpp.NS_DISCO,
frm=to) frm=to)
iq.setAttr('id', id_) iq.setAttr('id', id_)
query = iq.setTag('query') query = iq.setTag('query')
query.setAttr('node', 'http://gajim.org#' + gajim.version.split('-', 1)[0]) query.setAttr('node', 'http://gajim.org#' + gajim.version.split('-', 1)[
0])
for f in (common.xmpp.NS_BYTESTREAM, common.xmpp.NS_SI, for f in (common.xmpp.NS_BYTESTREAM, common.xmpp.NS_SI,
common.xmpp.NS_FILE, common.xmpp.NS_COMMANDS): common.xmpp.NS_FILE, common.xmpp.NS_COMMANDS):
feature = common.xmpp.Node('feature') feature = common.xmpp.Node('feature')
@ -252,7 +253,7 @@ class ConnectionDisco:
result = iq_obj.buildReply('result') result = iq_obj.buildReply('result')
self.connection.send(result) self.connection.send(result)
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
if node==common.xmpp.NS_COMMANDS: if node == common.xmpp.NS_COMMANDS:
self.commandListQuery(con, iq_obj) self.commandListQuery(con, iq_obj)
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
@ -275,14 +276,14 @@ class ConnectionDisco:
q = iq.getTag('query') q = iq.getTag('query')
if node: if node:
q.setAttr('node', node) q.setAttr('node', node)
q.addChild('identity', attrs = gajim.gajim_identity) q.addChild('identity', attrs=gajim.gajim_identity)
client_version = 'http://gajim.org#' + gajim.caps_hash[self.name] client_version = 'http://gajim.org#' + gajim.caps_hash[self.name]
if node in (None, client_version): if node in (None, client_version):
for f in gajim.gajim_common_features: for f in gajim.gajim_common_features:
q.addChild('feature', attrs = {'var': f}) q.addChild('feature', attrs={'var': f})
for f in gajim.gajim_optional_features[self.name]: for f in gajim.gajim_optional_features[self.name]:
q.addChild('feature', attrs = {'var': f}) q.addChild('feature', attrs={'var': f})
if q.getChildren(): if q.getChildren():
self.connection.send(iq) self.connection.send(iq)
@ -320,13 +321,11 @@ class ConnectionDisco:
attr = {} attr = {}
for key in i.getAttrs().keys(): for key in i.getAttrs().keys():
attr[key] = i.getAttr(key) attr[key] = i.getAttr(key)
if 'category' in attr and \ if 'category' in attr and attr['category'] in ('gateway',
attr['category'] in ('gateway', 'headline') and \ 'headline') and 'type' in attr:
'type' in attr:
transport_type = attr['type'] transport_type = attr['type']
if 'category' in attr and \ if 'category' in attr and attr['category'] == 'conference' and \
attr['category'] == 'conference' and \ 'type' in attr and attr['type'] == 'text':
'type' in attr and attr['type'] == 'text':
is_muc = True is_muc = True
identities.append(attr) identities.append(attr)
elif i.getName() == 'feature': elif i.getName() == 'feature':
@ -341,10 +340,12 @@ class ConnectionDisco:
gajim.logger.save_transport_type(jid, transport_type) gajim.logger.save_transport_type(jid, transport_type)
id_ = iq_obj.getID() id_ = iq_obj.getID()
if id_ is None: if id_ is None:
log.warn('Invalid IQ received without an ID. Ignoring it: %s' % iq_obj) log.warn('Invalid IQ received without an ID. Ignoring it: %s' % \
iq_obj)
return return
if not identities: # ejabberd doesn't send identities when we browse online users if not identities:
#FIXME: see http://www.jabber.ru/bugzilla/show_bug.cgi?id=225 # ejabberd doesn't send identities when we browse online users
#FIXME: see http://www.jabber.ru/bugzilla/show_bug.cgi?id=225
identities = [{'category': 'server', 'type': 'im', 'name': node}] identities = [{'category': 'server', 'type': 'im', 'name': node}]
if id_[:6] == 'Gajim_': if id_[:6] == 'Gajim_':
if jid == gajim.config.get_per('accounts', self.name, 'hostname'): if jid == gajim.config.get_per('accounts', self.name, 'hostname'):
@ -354,8 +355,8 @@ class ConnectionDisco:
if features.__contains__(common.xmpp.NS_SECLABEL): if features.__contains__(common.xmpp.NS_SECLABEL):
self.seclabel_supported = True self.seclabel_supported = True
for identity in identities: for identity in identities:
if identity['category'] == 'pubsub' and identity.get('type') == \ if identity['category'] == 'pubsub' and identity.get(
'pep': 'type') == 'pep':
self.pep_supported = True self.pep_supported = True
break break
if features.__contains__(common.xmpp.NS_VCARD): if features.__contains__(common.xmpp.NS_VCARD):
@ -397,18 +398,19 @@ class ConnectionDisco:
self.privacy_rules_requested = True self.privacy_rules_requested = True
self._request_privacy() self._request_privacy()
self.dispatch('AGENT_INFO_INFO', (jid, node, identities, self.dispatch('AGENT_INFO_INFO', (jid, node, identities, features,
features, data)) data))
self._capsDiscoCB(jid, node, identities, features, data) self._capsDiscoCB(jid, node, identities, features, data)
class ConnectionVcard: class ConnectionVcard:
def __init__(self): def __init__(self):
self.vcard_sha = None self.vcard_sha = None
self.vcard_shas = {} # sha of contacts self.vcard_shas = {} # sha of contacts
self.room_jids = [] # list of gc jids so that vcard are saved in a folder # list of gc jids so that vcard are saved in a folder
self.room_jids = []
def add_sha(self, p, send_caps = True): def add_sha(self, p, send_caps=True):
c = p.setTag('x', namespace = common.xmpp.NS_VCARD_UPDATE) c = p.setTag('x', namespace=common.xmpp.NS_VCARD_UPDATE)
if self.vcard_sha is not None: if self.vcard_sha is not None:
c.setTagData('photo', self.vcard_sha) c.setTagData('photo', self.vcard_sha)
if send_caps: if send_caps:
@ -417,7 +419,7 @@ class ConnectionVcard:
def _add_caps(self, p): def _add_caps(self, p):
''' advertise our capabilities in presence stanza (xep-0115)''' ''' advertise our capabilities in presence stanza (xep-0115)'''
c = p.setTag('c', namespace = common.xmpp.NS_CAPS) c = p.setTag('c', namespace=common.xmpp.NS_CAPS)
c.setAttr('hash', 'sha-1') c.setAttr('hash', 'sha-1')
c.setAttr('node', 'http://gajim.org') c.setAttr('node', 'http://gajim.org')
c.setAttr('ver', gajim.caps_hash[self.name]) c.setAttr('ver', gajim.caps_hash[self.name])
@ -514,7 +516,7 @@ class ConnectionVcard:
""" """
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
iq = common.xmpp.Iq(typ = 'get') iq = common.xmpp.Iq(typ='get')
if jid: if jid:
iq.setTo(jid) iq.setTo(jid)
iq.setTag(common.xmpp.NS_VCARD + ' vCard') iq.setTag(common.xmpp.NS_VCARD + ' vCard')
@ -535,7 +537,7 @@ class ConnectionVcard:
def send_vcard(self, vcard): def send_vcard(self, vcard):
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
iq = common.xmpp.Iq(typ = 'set') iq = common.xmpp.Iq(typ='set')
iq2 = iq.setTag(common.xmpp.NS_VCARD + ' vCard') iq2 = iq.setTag(common.xmpp.NS_VCARD + ' vCard')
for i in vcard: for i in vcard:
if i == 'jid': if i == 'jid':
@ -591,7 +593,8 @@ class ConnectionVcard:
if iq_obj.getType() == 'result': if iq_obj.getType() == 'result':
vcard_iq = self.awaiting_answers[id_][1] vcard_iq = self.awaiting_answers[id_][1]
# Save vcard to HD # Save vcard to HD
if vcard_iq.getTag('PHOTO') and vcard_iq.getTag('PHOTO').getTag('SHA'): if vcard_iq.getTag('PHOTO') and vcard_iq.getTag('PHOTO').getTag(
'SHA'):
new_sha = vcard_iq.getTag('PHOTO').getTagData('SHA') new_sha = vcard_iq.getTag('PHOTO').getTagData('SHA')
else: else:
new_sha = '' new_sha = ''
@ -601,14 +604,15 @@ class ConnectionVcard:
self._save_vcard_to_hd(our_jid, vcard_iq) self._save_vcard_to_hd(our_jid, vcard_iq)
# Send new presence if sha changed and we are not invisible # Send new presence if sha changed and we are not invisible
if self.vcard_sha != new_sha and gajim.SHOW_LIST[self.connected] !=\ if self.vcard_sha != new_sha and gajim.SHOW_LIST[
'invisible': self.connected] != 'invisible':
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
self.vcard_sha = new_sha self.vcard_sha = new_sha
sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected]) sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[
p = common.xmpp.Presence(typ = None, priority = self.priority, self.connected])
show = sshow, status = self.status) p = common.xmpp.Presence(typ=None, priority=self.priority,
show=sshow, status=self.status)
p = self.add_sha(p) p = self.add_sha(p)
self.connection.send(p) self.connection.send(p)
self.dispatch('VCARD_PUBLISHED', ()) self.dispatch('VCARD_PUBLISHED', ())
@ -696,11 +700,13 @@ class ConnectionVcard:
self.get_privacy_list('block') self.get_privacy_list('block')
elif self.continue_connect_info: elif self.continue_connect_info:
if self.continue_connect_info[0] == 'invisible': if self.continue_connect_info[0] == 'invisible':
# Trying to login as invisible but privacy list not supported # Trying to login as invisible but privacy list not
# supported
self.disconnect(on_purpose=True) self.disconnect(on_purpose=True)
self.dispatch('STATUS', 'offline') self.dispatch('STATUS', 'offline')
self.dispatch('ERROR', (_('Invisibility not supported'), self.dispatch('ERROR', (_('Invisibility not supported'),
_('Account %s doesn\'t support invisibility.') % self.name)) _('Account %s doesn\'t support invisibility.') % \
self.name))
return return
# Ask metacontacts before roster # Ask metacontacts before roster
self.get_metacontacts() self.get_metacontacts()
@ -825,7 +831,8 @@ class ConnectionVcard:
# Save it to file # Save it to file
self._save_vcard_to_hd(who, card) self._save_vcard_to_hd(who, card)
# Save the decoded avatar to a separate file too, and generate files for dbus notifications # Save the decoded avatar to a separate file too, and generate files
# for dbus notifications
puny_jid = helpers.sanitize_filename(frm) puny_jid = helpers.sanitize_filename(frm)
puny_nick = None puny_nick = None
begin_path = os.path.join(gajim.AVATAR_PATH, puny_jid) begin_path = os.path.join(gajim.AVATAR_PATH, puny_jid)
@ -851,7 +858,7 @@ class ConnectionVcard:
del self.vcard_shas[frm] del self.vcard_shas[frm]
else: else:
for ext in ('.jpeg', '.png', '_notif_size_bw.png', for ext in ('.jpeg', '.png', '_notif_size_bw.png',
'_notif_size_colored.png'): '_notif_size_colored.png'):
path = begin_path + ext path = begin_path + ext
if os.path.isfile(path): if os.path.isfile(path):
os.remove(path) os.remove(path)
@ -870,8 +877,8 @@ class ConnectionVcard:
if not self.connection: if not self.connection:
return return
sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected]) sshow = helpers.get_xmpp_show(gajim.SHOW_LIST[self.connected])
p = common.xmpp.Presence(typ = None, priority = self.priority, p = common.xmpp.Presence(typ=None, priority=self.priority,
show = sshow, status = self.status) show=sshow, status=self.status)
p = self.add_sha(p) p = self.add_sha(p)
self.connection.send(p) self.connection.send(p)
else: else:
@ -988,11 +995,12 @@ class ConnectionHandlersBase:
# filter out everything except the default session type # filter out everything except the default session type
chat_sessions = [s for s in idless if isinstance(s, chat_sessions = [s for s in idless if isinstance(s,
gajim.default_session_type)] gajim.default_session_type)]
if chat_sessions: if chat_sessions:
# return the session that we last sent a message in # return the session that we last sent a message in
return sorted(chat_sessions, key=operator.attrgetter("last_send"))[-1] return sorted(chat_sessions, key=operator.attrgetter('last_send'))[
-1]
else: else:
return None return None
@ -1005,7 +1013,7 @@ class ConnectionHandlersBase:
# filter out everything except the default session type # filter out everything except the default session type
chat_sessions = [s for s in sessions if isinstance(s, chat_sessions = [s for s in sessions if isinstance(s,
gajim.default_session_type)] gajim.default_session_type)]
orphaned = [s for s in chat_sessions if not s.control] orphaned = [s for s in chat_sessions if not s.control]
@ -1053,10 +1061,10 @@ ConnectionJingle, ConnectionIBBytestream):
ConnectionCommands.__init__(self) ConnectionCommands.__init__(self)
ConnectionPubSub.__init__(self) ConnectionPubSub.__init__(self)
ConnectionPEP.__init__(self, account=self.name, dispatcher=self, ConnectionPEP.__init__(self, account=self.name, dispatcher=self,
pubsub_connection=self) pubsub_connection=self)
ConnectionCaps.__init__(self, account=self.name, ConnectionCaps.__init__(self, account=self.name,
dispatch_event=self.dispatch, capscache=capscache.capscache, dispatch_event=self.dispatch, capscache=capscache.capscache,
client_caps_factory=capscache.create_suitable_client_caps) client_caps_factory=capscache.create_suitable_client_caps)
ConnectionJingle.__init__(self) ConnectionJingle.__init__(self)
ConnectionHandlersBase.__init__(self) ConnectionHandlersBase.__init__(self)
self.gmail_url = None self.gmail_url = None
@ -1074,7 +1082,6 @@ ConnectionJingle, ConnectionIBBytestream):
try: try:
self.sleeper = common.sleepy.Sleepy() self.sleeper = common.sleepy.Sleepy()
# idle.init()
HAS_IDLE = True HAS_IDLE = True
except Exception: except Exception:
HAS_IDLE = False HAS_IDLE = False
@ -1237,8 +1244,8 @@ ConnectionJingle, ConnectionIBBytestream):
for jid in obj.items: for jid in obj.items:
item = obj.items[jid] item = obj.items[jid]
gajim.nec.push_incoming_event(RosterInfoEvent(None, conn=self, gajim.nec.push_incoming_event(RosterInfoEvent(None, conn=self,
jid=jid, nickname=item['name'], sub=item['sub'], ask=item['ask'], jid=jid, nickname=item['name'], sub=item['sub'],
groups=item['groups'])) ask=item['ask'], groups=item['groups']))
account_jid = gajim.get_jid_from_account(self.name) account_jid = gajim.get_jid_from_account(self.name)
gajim.logger.add_or_update_contact(account_jid, jid, item['name'], gajim.logger.add_or_update_contact(account_jid, jid, item['name'],
item['sub'], item['ask'], item['groups']) item['sub'], item['ask'], item['groups'])
@ -1250,8 +1257,8 @@ ConnectionJingle, ConnectionIBBytestream):
log.debug('VersionCB') log.debug('VersionCB')
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
gajim.nec.push_incoming_event(VersionRequestEvent(None, gajim.nec.push_incoming_event(VersionRequestEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
def _nec_version_request_received(self, obj): def _nec_version_request_received(self, obj):
@ -1270,8 +1277,8 @@ ConnectionJingle, ConnectionIBBytestream):
log.debug('LastCB') log.debug('LastCB')
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
gajim.nec.push_incoming_event(LastRequestEvent(None, gajim.nec.push_incoming_event(LastRequestEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
def _nec_last_request_received(self, obj): def _nec_last_request_received(self, obj):
@ -1299,8 +1306,8 @@ ConnectionJingle, ConnectionIBBytestream):
log.debug('TimeCB') log.debug('TimeCB')
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
gajim.nec.push_incoming_event(TimeRequestEvent(None, gajim.nec.push_incoming_event(TimeRequestEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
def _nec_time_request_received(self, obj): def _nec_time_request_received(self, obj):
@ -1318,8 +1325,8 @@ ConnectionJingle, ConnectionIBBytestream):
log.debug('TimeRevisedCB') log.debug('TimeRevisedCB')
if not self.connection or self.connected < 2: if not self.connection or self.connected < 2:
return return
gajim.nec.push_incoming_event(TimeRevisedRequestEvent(None, gajim.nec.push_incoming_event(TimeRevisedRequestEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
def _nec_time_revised_request_received(self, obj): def _nec_time_revised_request_received(self, obj):
@ -1336,16 +1343,16 @@ ConnectionJingle, ConnectionIBBytestream):
def _TimeRevisedResultCB(self, con, iq_obj): def _TimeRevisedResultCB(self, con, iq_obj):
log.debug('TimeRevisedResultCB') log.debug('TimeRevisedResultCB')
gajim.nec.push_incoming_event(TimeResultReceivedEvent(None, gajim.nec.push_incoming_event(TimeResultReceivedEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
def _gMailNewMailCB(self, con, iq_obj): def _gMailNewMailCB(self, con, iq_obj):
""" """
Called when we get notified of new mail messages in gmail account Called when we get notified of new mail messages in gmail account
""" """
log.debug('gMailNewMailCB') log.debug('gMailNewMailCB')
gajim.nec.push_incoming_event(GmailNewMailReceivedEvent(None, gajim.nec.push_incoming_event(GmailNewMailReceivedEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
def _nec_gmail_new_mail_received(self, obj): def _nec_gmail_new_mail_received(self, obj):
@ -1373,8 +1380,8 @@ ConnectionJingle, ConnectionIBBytestream):
in gmail account in gmail account
""" """
log.debug('gMailQueryCB') log.debug('gMailQueryCB')
gajim.nec.push_incoming_event(GMailQueryReceivedEvent(None, gajim.nec.push_incoming_event(GMailQueryReceivedEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
def _rosterItemExchangeCB(self, con, msg): def _rosterItemExchangeCB(self, con, msg):
@ -1382,8 +1389,8 @@ ConnectionJingle, ConnectionIBBytestream):
XEP-0144 Roster Item Echange XEP-0144 Roster Item Echange
""" """
log.debug('rosterItemExchangeCB') log.debug('rosterItemExchangeCB')
gajim.nec.push_incoming_event(RosterItemExchangeEvent(None, gajim.nec.push_incoming_event(RosterItemExchangeEvent(None, conn=self,
conn=self, iq_obj=msg)) iq_obj=msg))
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
def _messageCB(self, con, msg): def _messageCB(self, con, msg):
@ -1412,10 +1419,11 @@ ConnectionJingle, ConnectionIBBytestream):
jid = helpers.get_jid_from_iq(msg) jid = helpers.get_jid_from_iq(msg)
except helpers.InvalidFormat: except helpers.InvalidFormat:
self.dispatch('ERROR', (_('Invalid Jabber ID'), self.dispatch('ERROR', (_('Invalid Jabber ID'),
_('A message from a non-valid JID arrived, it has been ignored.'))) _('A message from a non-valid JID arrived, it has been '
'ignored.')))
return return
addressTag = msg.getTag('addresses', namespace = common.xmpp.NS_ADDRESS) addressTag = msg.getTag('addresses', namespace=common.xmpp.NS_ADDRESS)
# Be sure it comes from one of our resource, else ignore address element # Be sure it comes from one of our resource, else ignore address element
if addressTag and jid == gajim.get_jid_from_account(self.name): if addressTag and jid == gajim.get_jid_from_account(self.name):
@ -1424,7 +1432,8 @@ ConnectionJingle, ConnectionIBBytestream):
try: try:
frm = helpers.parse_jid(address.getAttr('jid')) frm = helpers.parse_jid(address.getAttr('jid'))
except common.helpers.InvalidFormat: except common.helpers.InvalidFormat:
log.warn('Invalid JID: %s, ignoring it' % address.getAttr('jid')) log.warn('Invalid JID: %s, ignoring it' % address.getAttr(
'jid'))
return return
jid = gajim.get_jid_without_resource(frm) jid = gajim.get_jid_without_resource(frm)
@ -1433,7 +1442,7 @@ ConnectionJingle, ConnectionIBBytestream):
encTag = msg.getTag('x', namespace=common.xmpp.NS_ENCRYPTED) encTag = msg.getTag('x', namespace=common.xmpp.NS_ENCRYPTED)
if not encTag: if not encTag:
invite = msg.getTag('x', namespace = common.xmpp.NS_MUC_USER) invite = msg.getTag('x', namespace=common.xmpp.NS_MUC_USER)
if invite and not invite.getTag('invite'): if invite and not invite.getTag('invite'):
invite = None invite = None
@ -1446,13 +1455,14 @@ ConnectionJingle, ConnectionIBBytestream):
try: try:
room_jid = helpers.parse_jid(xtag.getAttr('jid')) room_jid = helpers.parse_jid(xtag.getAttr('jid'))
except common.helpers.InvalidFormat: except common.helpers.InvalidFormat:
log.warn('Invalid JID: %s, ignoring it' % xtag.getAttr('jid')) log.warn('Invalid JID: %s, ignoring it' % xtag.getAttr(
'jid'))
continue continue
is_continued = False is_continued = False
if xtag.getTag('continue'): if xtag.getTag('continue'):
is_continued = True is_continued = True
self.dispatch('GC_INVITATION', (room_jid, frm, '', None, self.dispatch('GC_INVITATION', (room_jid, frm, '', None,
is_continued)) is_continued))
return return
thread_id = msg.getThread() thread_id = msg.getThread()
@ -1463,7 +1473,8 @@ ConnectionJingle, ConnectionIBBytestream):
msgtxt = msg.getBody() msgtxt = msg.getBody()
encrypted = False encrypted = False
xep_200_encrypted = msg.getTag('c', namespace=common.xmpp.NS_STANZA_CRYPTO) xep_200_encrypted = msg.getTag('c',
namespace=common.xmpp.NS_STANZA_CRYPTO)
session = None session = None
gc_control = gajim.interface.msg_win_mgr.get_gc_control(jid, self.name) gc_control = gajim.interface.msg_win_mgr.get_gc_control(jid, self.name)
@ -1485,7 +1496,8 @@ ConnectionJingle, ConnectionIBBytestream):
# check if the message is a XEP-0020 feature negotiation request # check if the message is a XEP-0020 feature negotiation request
if msg.getTag('feature', namespace=common.xmpp.NS_FEATURE): if msg.getTag('feature', namespace=common.xmpp.NS_FEATURE):
if gajim.HAVE_PYCRYPTO: if gajim.HAVE_PYCRYPTO:
feature = msg.getTag(name='feature', namespace=common.xmpp.NS_FEATURE) feature = msg.getTag(name='feature',
namespace=common.xmpp.NS_FEATURE)
form = common.xmpp.DataForm(node=feature.getTag('x')) form = common.xmpp.DataForm(node=feature.getTag('x'))
if form['FORM_TYPE'] == 'urn:xmpp:ssn': if form['FORM_TYPE'] == 'urn:xmpp:ssn':
@ -1495,7 +1507,8 @@ ConnectionJingle, ConnectionIBBytestream):
reply.setType('error') reply.setType('error')
reply.addChild(feature) reply.addChild(feature)
err = common.xmpp.ErrorNode('service-unavailable', typ='cancel') err = common.xmpp.ErrorNode('service-unavailable',
typ='cancel')
reply.addChild(node=err) reply.addChild(node=err)
con.send(reply) con.send(reply)
@ -1505,7 +1518,8 @@ ConnectionJingle, ConnectionIBBytestream):
return return
if msg.getTag('init', namespace=common.xmpp.NS_ESESSION_INIT): if msg.getTag('init', namespace=common.xmpp.NS_ESESSION_INIT):
init = msg.getTag(name='init', namespace=common.xmpp.NS_ESESSION_INIT) init = msg.getTag(name='init',
namespace=common.xmpp.NS_ESESSION_INIT)
form = common.xmpp.DataForm(node=init.getTag('x')) form = common.xmpp.DataForm(node=init.getTag('x'))
session.handle_negotiation(form) session.handle_negotiation(form)
@ -1561,11 +1575,11 @@ ConnectionJingle, ConnectionIBBytestream):
encrypted = 'xep27' encrypted = 'xep27'
return (msgtxt, encrypted) return (msgtxt, encrypted)
gajim.thread_interface(decrypt_thread, [encmsg, keyID], gajim.thread_interface(decrypt_thread, [encmsg, keyID],
self._on_message_decrypted, [mtype, msg, session, frm, jid, self._on_message_decrypted, [mtype, msg, session, frm, jid,
invite, tim]) invite, tim])
return return
self._on_message_decrypted((msgtxt, encrypted), mtype, msg, session, frm, self._on_message_decrypted((msgtxt, encrypted), mtype, msg, session,
jid, invite, tim) frm, jid, invite, tim)
def _on_message_decrypted(self, output, mtype, msg, session, frm, jid, def _on_message_decrypted(self, output, mtype, msg, session, frm, jid,
invite, tim): invite, tim):
@ -1596,17 +1610,18 @@ ConnectionJingle, ConnectionIBBytestream):
if session.is_loggable(): if session.is_loggable():
try: try:
gajim.logger.write('error', frm, error_msg, tim=tim, gajim.logger.write('error', frm, error_msg, tim=tim,
subject=subject) subject=subject)
except exceptions.PysqliteOperationalError, e: except exceptions.PysqliteOperationalError, e:
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e))) self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed: except exceptions.DatabaseMalformed:
pritext = _('Database Error') pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to repair ' sectext = _('The database file (%s) cannot be read. Try to '
'it (see http://trac.gajim.org/wiki/DatabaseBackup) or remove ' 'repair it (see http://trac.gajim.org/wiki/DatabaseBackup) '
'it (all history will be lost).') % common.logger.LOG_DB_PATH 'or remove it (all history will be lost).') % \
common.logger.LOG_DB_PATH
self.dispatch('DB_ERROR', (pritext, sectext)) self.dispatch('DB_ERROR', (pritext, sectext))
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt, self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
tim, session)) tim, session))
def _on_bob_received(self, conn, result, cid): def _on_bob_received(self, conn, result, cid):
""" """
@ -1680,7 +1695,9 @@ ConnectionJingle, ConnectionIBBytestream):
displaymarking = None displaymarking = None
seclabel = msg.getTag('securitylabel') seclabel = msg.getTag('securitylabel')
if seclabel and seclabel.getNamespace() == common.xmpp.NS_SECLABEL: if seclabel and seclabel.getNamespace() == common.xmpp.NS_SECLABEL:
displaymarking = seclabel.getTag('displaymarking') # Ignore message from room in which we are not # Ignore message from room in which we are not
displaymarking = seclabel.getTag('displaymarking')
if jid not in self.last_history_time: if jid not in self.last_history_time:
return return
@ -1724,9 +1741,10 @@ ConnectionJingle, ConnectionIBBytestream):
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e))) self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed: except exceptions.DatabaseMalformed:
pritext = _('Database Error') pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to repair ' sectext = _('The database file (%s) cannot be read. Try to '
'it (see http://trac.gajim.org/wiki/DatabaseBackup) or remove ' 'repair it (see http://trac.gajim.org/wiki/DatabaseBackup) '
'it (all history will be lost).') % common.logger.LOG_DB_PATH 'or remove it (all history will be lost).') % \
common.logger.LOG_DB_PATH
self.dispatch('DB_ERROR', (pritext, sectext)) self.dispatch('DB_ERROR', (pritext, sectext))
def dispatch_invite_message(self, invite, frm): def dispatch_invite_message(self, invite, frm):
@ -1744,7 +1762,7 @@ ConnectionJingle, ConnectionIBBytestream):
if invite.getTag('invite').getTag('continue'): if invite.getTag('invite').getTag('continue'):
is_continued = True is_continued = True
self.dispatch('GC_INVITATION', (frm, jid_from, reason, password, self.dispatch('GC_INVITATION', (frm, jid_from, reason, password,
is_continued)) is_continued))
def _presenceCB(self, con, prs): def _presenceCB(self, con, prs):
""" """
@ -1914,9 +1932,8 @@ ConnectionJingle, ConnectionIBBytestream):
except exceptions.DatabaseMalformed: except exceptions.DatabaseMalformed:
pritext = _('Database Error') pritext = _('Database Error')
sectext = _('The database file (%s) cannot be read. Try to ' sectext = _('The database file (%s) cannot be read. Try to '
'repair it (see ' 'repair it (see http://trac.gajim.org/wiki/DatabaseBackup) '
'http://trac.gajim.org/wiki/DatabaseBackup) or remove ' 'or remove it (all history will be lost).') % LOG_DB_PATH
'it (all history will be lost).') % LOG_DB_PATH
self.dispatch('DB_ERROR', (pritext, sectext)) self.dispatch('DB_ERROR', (pritext, sectext))
our_jid = gajim.get_jid_from_account(self.name) our_jid = gajim.get_jid_from_account(self.name)
@ -2013,13 +2030,13 @@ ConnectionJingle, ConnectionIBBytestream):
def _MucOwnerCB(self, con, iq_obj): def _MucOwnerCB(self, con, iq_obj):
log.debug('MucOwnerCB') log.debug('MucOwnerCB')
gajim.nec.push_incoming_event(MucOwnerReceivedEvent(None, gajim.nec.push_incoming_event(MucOwnerReceivedEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
def _MucAdminCB(self, con, iq_obj): def _MucAdminCB(self, con, iq_obj):
log.debug('MucAdminCB') log.debug('MucAdminCB')
gajim.nec.push_incoming_event(MucAdminReceivedEvent(None, gajim.nec.push_incoming_event(MucAdminReceivedEvent(None, conn=self,
conn=self, iq_obj=iq_obj)) iq_obj=iq_obj))
def _IqPingCB(self, con, iq_obj): def _IqPingCB(self, con, iq_obj):
log.debug('IqPingCB') log.debug('IqPingCB')
@ -2057,13 +2074,13 @@ ConnectionJingle, ConnectionIBBytestream):
return return
self.connection.getRoster(self._on_roster_set) self.connection.getRoster(self._on_roster_set)
self.discoverItems(gajim.config.get_per('accounts', self.name, self.discoverItems(gajim.config.get_per('accounts', self.name,
'hostname'), id_prefix='Gajim_') 'hostname'), id_prefix='Gajim_')
if gajim.config.get_per('accounts', self.name, 'use_ft_proxies'): if gajim.config.get_per('accounts', self.name, 'use_ft_proxies'):
self.discover_ft_proxies() self.discover_ft_proxies()
def discover_ft_proxies(self): def discover_ft_proxies(self):
cfg_proxies = gajim.config.get_per('accounts', self.name, cfg_proxies = gajim.config.get_per('accounts', self.name,
'file_transfer_proxies') 'file_transfer_proxies')
our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name) + \ our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name) + \
'/' + self.server_resource) '/' + self.server_resource)
if cfg_proxies: if cfg_proxies:
@ -2085,11 +2102,13 @@ ConnectionJingle, ConnectionIBBytestream):
signed = '' signed = ''
send_first_presence = True send_first_presence = True
if sign_msg: if sign_msg:
signed = self.get_signed_presence(msg, self._send_first_presence) signed = self.get_signed_presence(msg,
self._send_first_presence)
if signed is None: if signed is None:
self.dispatch('GPG_PASSWORD_REQUIRED', self.dispatch('GPG_PASSWORD_REQUIRED',
(self._send_first_presence,)) (self._send_first_presence,))
# _send_first_presence will be called when user enter passphrase # _send_first_presence will be called when user enter
# passphrase
send_first_presence = False send_first_presence = False
if send_first_presence: if send_first_presence:
self._send_first_presence(signed) self._send_first_presence(signed)
@ -2114,7 +2133,7 @@ ConnectionJingle, ConnectionIBBytestream):
sub=info['subscription'], ask=info['ask'], sub=info['subscription'], ask=info['ask'],
groups=info['groups'])) groups=info['groups']))
def _send_first_presence(self, signed = ''): def _send_first_presence(self, signed=''):
show = self.continue_connect_info[0] show = self.continue_connect_info[0]
msg = self.continue_connect_info[1] msg = self.continue_connect_info[1]
sign_msg = self.continue_connect_info[2] sign_msg = self.continue_connect_info[2]
@ -2137,7 +2156,7 @@ ConnectionJingle, ConnectionIBBytestream):
vcard = self.get_cached_vcard(our_jid) vcard = self.get_cached_vcard(our_jid)
if vcard and 'PHOTO' in vcard and 'SHA' in vcard['PHOTO']: if vcard and 'PHOTO' in vcard and 'SHA' in vcard['PHOTO']:
self.vcard_sha = vcard['PHOTO']['SHA'] self.vcard_sha = vcard['PHOTO']['SHA']
p = common.xmpp.Presence(typ = None, priority = priority, show = sshow) p = common.xmpp.Presence(typ=None, priority=priority, show=sshow)
p = self.add_sha(p) p = self.add_sha(p)
if msg: if msg:
p.setStatus(msg) p.setStatus(msg)
@ -2170,8 +2189,8 @@ ConnectionJingle, ConnectionIBBytestream):
# inform the server that we want e-mail notifications # inform the server that we want e-mail notifications
our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name)) our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name))
log.debug(('%s is a gmail account. Setting option ' log.debug(('%s is a gmail account. Setting option '
'to get e-mail notifications on the server.') % (our_jid)) 'to get e-mail notifications on the server.') % (our_jid))
iq = common.xmpp.Iq(typ = 'set', to = our_jid) iq = common.xmpp.Iq(typ='set', to=our_jid)
iq.setAttr('id', 'MailNotify') iq.setAttr('id', 'MailNotify')
query = iq.setTag('usersetting') query = iq.setTag('usersetting')
query.setNamespace(common.xmpp.NS_GTALKSETTING) query.setNamespace(common.xmpp.NS_GTALKSETTING)
@ -2179,13 +2198,12 @@ ConnectionJingle, ConnectionIBBytestream):
query.setAttr('value', 'true') query.setAttr('value', 'true')
self.connection.send(iq) self.connection.send(iq)
# Ask how many messages there are now # Ask how many messages there are now
iq = common.xmpp.Iq(typ = 'get') iq = common.xmpp.Iq(typ='get')
iq.setID(self.connection.getAnID()) iq.setID(self.connection.getAnID())
query = iq.setTag('query') query = iq.setTag('query')
query.setNamespace(common.xmpp.NS_GMAILNOTIFY) query.setNamespace(common.xmpp.NS_GMAILNOTIFY)
self.connection.send(iq) self.connection.send(iq)
def _SearchCB(self, con, iq_obj): def _SearchCB(self, con, iq_obj):
log.debug('SearchCB') log.debug('SearchCB')
gajim.nec.push_incoming_event(SearchFormReceivedEvent(None, gajim.nec.push_incoming_event(SearchFormReceivedEvent(None,
@ -2204,92 +2222,84 @@ ConnectionJingle, ConnectionIBBytestream):
con.RegisterHandler('presence', self._capsPresenceCB) con.RegisterHandler('presence', self._capsPresenceCB)
# We use makefirst so that this handler is called before _messageCB, and # We use makefirst so that this handler is called before _messageCB, and
# can prevent calling it when it's not needed. # can prevent calling it when it's not needed.
# We also don't check for namespace, else it cannot stop _messageCB to be # We also don't check for namespace, else it cannot stop _messageCB to
# called # be called
con.RegisterHandler('message', self._pubsubEventCB, makefirst=True) con.RegisterHandler('message', self._pubsubEventCB, makefirst=True)
con.RegisterHandler('iq', self._vCardCB, 'result', con.RegisterHandler('iq', self._vCardCB, 'result', common.xmpp.NS_VCARD)
common.xmpp.NS_VCARD)
con.RegisterHandler('iq', self._rosterSetCB, 'set', con.RegisterHandler('iq', self._rosterSetCB, 'set',
common.xmpp.NS_ROSTER) common.xmpp.NS_ROSTER)
con.RegisterHandler('iq', self._siSetCB, 'set', con.RegisterHandler('iq', self._siSetCB, 'set', common.xmpp.NS_SI)
common.xmpp.NS_SI)
con.RegisterHandler('iq', self._rosterItemExchangeCB, 'set', con.RegisterHandler('iq', self._rosterItemExchangeCB, 'set',
common.xmpp.NS_ROSTERX) common.xmpp.NS_ROSTERX)
con.RegisterHandler('iq', self._siErrorCB, 'error', con.RegisterHandler('iq', self._siErrorCB, 'error', common.xmpp.NS_SI)
common.xmpp.NS_SI) con.RegisterHandler('iq', self._siResultCB, 'result', common.xmpp.NS_SI)
con.RegisterHandler('iq', self._siResultCB, 'result', con.RegisterHandler('iq', self._discoGetCB, 'get', common.xmpp.NS_DISCO)
common.xmpp.NS_SI)
con.RegisterHandler('iq', self._discoGetCB, 'get',
common.xmpp.NS_DISCO)
con.RegisterHandler('iq', self._bytestreamSetCB, 'set', con.RegisterHandler('iq', self._bytestreamSetCB, 'set',
common.xmpp.NS_BYTESTREAM) common.xmpp.NS_BYTESTREAM)
con.RegisterHandler('iq', self._bytestreamResultCB, 'result', con.RegisterHandler('iq', self._bytestreamResultCB, 'result',
common.xmpp.NS_BYTESTREAM) common.xmpp.NS_BYTESTREAM)
con.RegisterHandler('iq', self._bytestreamErrorCB, 'error', con.RegisterHandler('iq', self._bytestreamErrorCB, 'error',
common.xmpp.NS_BYTESTREAM) common.xmpp.NS_BYTESTREAM)
con.RegisterHandlerOnce('iq', self.IBBAllIqHandler) con.RegisterHandlerOnce('iq', self.IBBAllIqHandler)
con.RegisterHandler('iq', self.IBBIqHandler, ns=common.xmpp.NS_IBB) con.RegisterHandler('iq', self.IBBIqHandler, ns=common.xmpp.NS_IBB)
con.RegisterHandler('message', self.IBBMessageHandler, con.RegisterHandler('message', self.IBBMessageHandler,
ns=common.xmpp.NS_IBB) ns=common.xmpp.NS_IBB)
con.RegisterHandler('iq', self._DiscoverItemsCB, 'result', con.RegisterHandler('iq', self._DiscoverItemsCB, 'result',
common.xmpp.NS_DISCO_ITEMS) common.xmpp.NS_DISCO_ITEMS)
con.RegisterHandler('iq', self._DiscoverItemsErrorCB, 'error', con.RegisterHandler('iq', self._DiscoverItemsErrorCB, 'error',
common.xmpp.NS_DISCO_ITEMS) common.xmpp.NS_DISCO_ITEMS)
con.RegisterHandler('iq', self._DiscoverInfoCB, 'result', con.RegisterHandler('iq', self._DiscoverInfoCB, 'result',
common.xmpp.NS_DISCO_INFO) common.xmpp.NS_DISCO_INFO)
con.RegisterHandler('iq', self._DiscoverInfoErrorCB, 'error', con.RegisterHandler('iq', self._DiscoverInfoErrorCB, 'error',
common.xmpp.NS_DISCO_INFO) common.xmpp.NS_DISCO_INFO)
con.RegisterHandler('iq', self._VersionCB, 'get', con.RegisterHandler('iq', self._VersionCB, 'get',
common.xmpp.NS_VERSION) common.xmpp.NS_VERSION)
con.RegisterHandler('iq', self._TimeCB, 'get', con.RegisterHandler('iq', self._TimeCB, 'get', common.xmpp.NS_TIME)
common.xmpp.NS_TIME)
con.RegisterHandler('iq', self._TimeRevisedCB, 'get', con.RegisterHandler('iq', self._TimeRevisedCB, 'get',
common.xmpp.NS_TIME_REVISED) common.xmpp.NS_TIME_REVISED)
con.RegisterHandler('iq', self._LastCB, 'get', con.RegisterHandler('iq', self._LastCB, 'get', common.xmpp.NS_LAST)
common.xmpp.NS_LAST)
con.RegisterHandler('iq', self._LastResultCB, 'result', con.RegisterHandler('iq', self._LastResultCB, 'result',
common.xmpp.NS_LAST) common.xmpp.NS_LAST)
con.RegisterHandler('iq', self._VersionResultCB, 'result', con.RegisterHandler('iq', self._VersionResultCB, 'result',
common.xmpp.NS_VERSION) common.xmpp.NS_VERSION)
con.RegisterHandler('iq', self._TimeRevisedResultCB, 'result', con.RegisterHandler('iq', self._TimeRevisedResultCB, 'result',
common.xmpp.NS_TIME_REVISED) common.xmpp.NS_TIME_REVISED)
con.RegisterHandler('iq', self._MucOwnerCB, 'result', con.RegisterHandler('iq', self._MucOwnerCB, 'result',
common.xmpp.NS_MUC_OWNER) common.xmpp.NS_MUC_OWNER)
con.RegisterHandler('iq', self._MucAdminCB, 'result', con.RegisterHandler('iq', self._MucAdminCB, 'result',
common.xmpp.NS_MUC_ADMIN) common.xmpp.NS_MUC_ADMIN)
con.RegisterHandler('iq', self._PrivateCB, 'result', con.RegisterHandler('iq', self._PrivateCB, 'result',
common.xmpp.NS_PRIVATE) common.xmpp.NS_PRIVATE)
con.RegisterHandler('iq', self._SecLabelCB, 'result', con.RegisterHandler('iq', self._SecLabelCB, 'result',
common.xmpp.NS_SECLABEL_CATALOG) common.xmpp.NS_SECLABEL_CATALOG)
con.RegisterHandler('iq', self._HttpAuthCB, 'get', con.RegisterHandler('iq', self._HttpAuthCB, 'get',
common.xmpp.NS_HTTP_AUTH) common.xmpp.NS_HTTP_AUTH)
con.RegisterHandler('iq', self._CommandExecuteCB, 'set', con.RegisterHandler('iq', self._CommandExecuteCB, 'set',
common.xmpp.NS_COMMANDS) common.xmpp.NS_COMMANDS)
con.RegisterHandler('iq', self._gMailNewMailCB, 'set', con.RegisterHandler('iq', self._gMailNewMailCB, 'set',
common.xmpp.NS_GMAILNOTIFY) common.xmpp.NS_GMAILNOTIFY)
con.RegisterHandler('iq', self._gMailQueryCB, 'result', con.RegisterHandler('iq', self._gMailQueryCB, 'result',
common.xmpp.NS_GMAILNOTIFY) common.xmpp.NS_GMAILNOTIFY)
con.RegisterHandler('iq', self._DiscoverInfoGetCB, 'get', con.RegisterHandler('iq', self._DiscoverInfoGetCB, 'get',
common.xmpp.NS_DISCO_INFO) common.xmpp.NS_DISCO_INFO)
con.RegisterHandler('iq', self._DiscoverItemsGetCB, 'get', con.RegisterHandler('iq', self._DiscoverItemsGetCB, 'get',
common.xmpp.NS_DISCO_ITEMS) common.xmpp.NS_DISCO_ITEMS)
con.RegisterHandler('iq', self._IqPingCB, 'get', con.RegisterHandler('iq', self._IqPingCB, 'get', common.xmpp.NS_PING)
common.xmpp.NS_PING)
con.RegisterHandler('iq', self._SearchCB, 'result', con.RegisterHandler('iq', self._SearchCB, 'result',
common.xmpp.NS_SEARCH) common.xmpp.NS_SEARCH)
con.RegisterHandler('iq', self._PrivacySetCB, 'set', con.RegisterHandler('iq', self._PrivacySetCB, 'set',
common.xmpp.NS_PRIVACY) common.xmpp.NS_PRIVACY)
con.RegisterHandler('iq', self._ArchiveCB, ns=common.xmpp.NS_ARCHIVE) con.RegisterHandler('iq', self._ArchiveCB, ns=common.xmpp.NS_ARCHIVE)
con.RegisterHandler('iq', self._PubSubCB, 'result') con.RegisterHandler('iq', self._PubSubCB, 'result')
con.RegisterHandler('iq', self._PubSubErrorCB, 'error') con.RegisterHandler('iq', self._PubSubErrorCB, 'error')
con.RegisterHandler('iq', self._JingleCB, 'result') con.RegisterHandler('iq', self._JingleCB, 'result')
con.RegisterHandler('iq', self._JingleCB, 'error') con.RegisterHandler('iq', self._JingleCB, 'error')
con.RegisterHandler('iq', self._JingleCB, 'set', con.RegisterHandler('iq', self._JingleCB, 'set', common.xmpp.NS_JINGLE)
common.xmpp.NS_JINGLE)
con.RegisterHandler('iq', self._ErrorCB, 'error') con.RegisterHandler('iq', self._ErrorCB, 'error')
con.RegisterHandler('iq', self._IqCB) con.RegisterHandler('iq', self._IqCB)
con.RegisterHandler('iq', self._StanzaArrivedCB) con.RegisterHandler('iq', self._StanzaArrivedCB)
con.RegisterHandler('iq', self._ResultCB, 'result') con.RegisterHandler('iq', self._ResultCB, 'result')
con.RegisterHandler('presence', self._StanzaArrivedCB) con.RegisterHandler('presence', self._StanzaArrivedCB)
con.RegisterHandler('message', self._StanzaArrivedCB) con.RegisterHandler('message', self._StanzaArrivedCB)
con.RegisterHandler('unknown', self._StreamCB, 'urn:ietf:params:xml:ns:xmpp-streams', xmlns='http://etherx.jabber.org/streams') con.RegisterHandler('unknown', self._StreamCB,
common.xmpp.NS_XMPP_STREAMS, xmlns=common.xmpp.NS_STREAMS)