Fix a few things in common.connection_handlers_events.
This commit is contained in:
parent
ad9370afa8
commit
eb51184a95
|
@ -18,34 +18,33 @@
|
|||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
from calendar import timegm
|
||||
import datetime
|
||||
import hashlib
|
||||
import hmac
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
from time import time as time_time
|
||||
from calendar import timegm
|
||||
import hmac
|
||||
import hashlib
|
||||
|
||||
import nbxmpp
|
||||
from nbxmpp.protocol import NS_CHATSTATES
|
||||
from common import atom
|
||||
from common import nec
|
||||
from common import helpers
|
||||
from common import gajim
|
||||
from common import i18n
|
||||
import nbxmpp
|
||||
from common import dataforms
|
||||
from common import exceptions
|
||||
from common.zeroconf import zeroconf
|
||||
from common.zeroconf.zeroconf import Constant
|
||||
from common.logger import LOG_DB_PATH
|
||||
from common.pep import SUPPORTED_PERSONAL_USER_EVENTS
|
||||
from nbxmpp.protocol import NS_CHATSTATES
|
||||
from common.jingle_transport import JingleTransportSocks5
|
||||
from common.file_props import FilesProp
|
||||
|
||||
if gajim.HAVE_PYOPENSSL:
|
||||
import OpenSSL.crypto
|
||||
|
||||
import logging
|
||||
log = logging.getLogger('gajim.c.connection_handlers_events')
|
||||
|
||||
CONDITION_TO_CODE = {
|
||||
|
@ -281,8 +280,7 @@ class GMailQueryReceivedEvent(nec.NetworkIncomingEvent):
|
|||
gmail_messages = mb.getTags('mail-thread-info')
|
||||
for gmessage in gmail_messages:
|
||||
unread_senders = []
|
||||
for sender in gmessage.getTag('senders').getTags(
|
||||
'sender'):
|
||||
for sender in gmessage.getTag('senders').getTags('sender'):
|
||||
if sender.getAttr('unread') != '1':
|
||||
continue
|
||||
if sender.getAttr('name'):
|
||||
|
@ -310,8 +308,7 @@ class GMailQueryReceivedEvent(nec.NetworkIncomingEvent):
|
|||
self.conn.gmail_last_time = int(mb.getAttr('result-time'))
|
||||
|
||||
self.jid = gajim.get_jid_from_account(self.name)
|
||||
log.debug(('You have %s new gmail e-mails on %s.') % (self.newmsgs,
|
||||
self.jid))
|
||||
log.debug('You have %s new gmail e-mails on %s.', self.newmsgs, self.jid)
|
||||
return True
|
||||
|
||||
class RosterItemExchangeEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||
|
@ -778,7 +775,8 @@ PresenceHelperEvent):
|
|||
sig_msg = sig_tag.getData()
|
||||
self.keyID = self.conn.gpg.verify(self.status, sig_msg)
|
||||
self.keyID = helpers.prepare_and_validate_gpg_keyID(self.conn.name,
|
||||
self.jid, self.keyID)
|
||||
self.jid,
|
||||
self.keyID)
|
||||
|
||||
def _generate_prio(self):
|
||||
self.prio = self.stanza.getPriority()
|
||||
|
@ -857,8 +855,10 @@ PresenceHelperEvent):
|
|||
self.errmsg = self.stanza.getErrorMsg()
|
||||
|
||||
if self.is_gc:
|
||||
gajim.nec.push_incoming_event(GcPresenceReceivedEvent(None,
|
||||
conn=self.conn, stanza=self.stanza, presence_obj=self))
|
||||
gajim.nec.push_incoming_event(
|
||||
GcPresenceReceivedEvent(
|
||||
None, conn=self.conn, stanza=self.stanza,
|
||||
presence_obj=self))
|
||||
return
|
||||
|
||||
if self.ptype == 'subscribe':
|
||||
|
@ -878,8 +878,7 @@ PresenceHelperEvent):
|
|||
|
||||
if not self.ptype or self.ptype == 'unavailable':
|
||||
our_jid = gajim.get_jid_from_account(self.conn.name)
|
||||
if self.jid == our_jid and self.resource == \
|
||||
self.conn.server_resource:
|
||||
if self.jid == our_jid and self.resource == self.conn.server_resource:
|
||||
# We got our own presence
|
||||
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self.conn,
|
||||
show=self.show))
|
||||
|
@ -948,11 +947,9 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
# we know real jid, save it in db
|
||||
st += ' (%s)' % jid
|
||||
try:
|
||||
gajim.logger.write('gcstatus', self.fjid, st,
|
||||
self.show)
|
||||
gajim.logger.write('gcstatus', self.fjid, st, self.show)
|
||||
except exceptions.PysqliteOperationalError as e:
|
||||
self.conn.dispatch('DB_ERROR', (_('Disk Write Error'),
|
||||
str(e)))
|
||||
self.conn.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
|
||||
except exceptions.DatabaseMalformed:
|
||||
pritext = _('Database Error')
|
||||
sectext = _('The database file (%s) cannot be read. '
|
||||
|
@ -1261,7 +1258,8 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
|||
self.session = self.conn.get_latest_session(self.fjid)
|
||||
if not self.session:
|
||||
self.session = self.conn.make_new_session(self.fjid,
|
||||
self.thread_id, type_='pm')
|
||||
self.thread_id,
|
||||
type_='pm')
|
||||
else:
|
||||
self.session = self.conn.get_or_create_session(self.fjid,
|
||||
self.thread_id)
|
||||
|
@ -1351,7 +1349,7 @@ class GcInvitationReceivedEvent(nec.NetworkIncomingEvent):
|
|||
try:
|
||||
self.room_jid = helpers.parse_jid(invite_tag.getAttr('jid'))
|
||||
except helpers.InvalidFormat:
|
||||
log.warning('Invalid JID: %s, ignoring it' % invite_tag.getAttr(
|
||||
log.warning('Invalid JID: %s, ignoring it', invite_tag.getAttr(
|
||||
'jid'))
|
||||
return
|
||||
self.jid_from = self.msg_obj.fjid
|
||||
|
|
Loading…
Reference in New Issue