coding standards

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

View file

@ -124,8 +124,8 @@ 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})
@ -140,9 +140,9 @@ 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):
@ -153,8 +153,8 @@ 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,
@ -190,7 +190,8 @@ class ConnectionDisco:
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')
@ -320,12 +321,10 @@ 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)
@ -341,9 +340,11 @@ 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:
# ejabberd doesn't send identities when we browse online users
#FIXME: see http://www.jabber.ru/bugzilla/show_bug.cgi?id=225 #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_':
@ -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,15 +398,16 @@ 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)
@ -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,12 +604,13 @@ 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[
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)
@ -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)
@ -992,7 +999,8 @@ class ConnectionHandlersBase:
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
@ -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,7 +1419,8 @@ 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)
@ -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)
@ -1446,7 +1455,8 @@ 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'):
@ -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)
@ -1564,8 +1578,8 @@ ConnectionJingle, ConnectionIBBytestream):
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):
@ -1601,9 +1615,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))
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt, self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
tim, session)) tim, session))
@ -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):
@ -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')
@ -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)
@ -2185,7 +2204,6 @@ ConnectionJingle, ConnectionIBBytestream):
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,23 +2222,18 @@ 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',
@ -2241,12 +2254,10 @@ ConnectionJingle, ConnectionIBBytestream):
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',
@ -2273,8 +2284,7 @@ ConnectionJingle, ConnectionIBBytestream):
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',
@ -2284,12 +2294,12 @@ ConnectionJingle, ConnectionIBBytestream):
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)