no need of GUI classes in connection_handlers.py, socks5.py and secrets.py
This commit is contained in:
parent
ea99cb3682
commit
1e8e0f6067
5 changed files with 15 additions and 22 deletions
|
@ -55,10 +55,6 @@ if dbus_support.supported:
|
|||
import dbus
|
||||
from music_track_listener import MusicTrackListener
|
||||
|
||||
from session import ChatControlSession
|
||||
|
||||
gajim.default_session_type = ChatControlSession
|
||||
|
||||
STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
|
||||
'invisible', 'error']
|
||||
# kind of events we can wait for an answer
|
||||
|
@ -1791,7 +1787,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
elif invite is not None:
|
||||
self.dispatch_invite_message(invite, frm)
|
||||
else:
|
||||
if isinstance(session, ChatControlSession):
|
||||
if isinstance(session, gajim.default_session_type):
|
||||
session.received(frm, msgtxt, tim, encrypted, msg)
|
||||
else:
|
||||
session.received(msg)
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
import socket
|
||||
import struct
|
||||
import sha
|
||||
from dialogs import BindPortError
|
||||
|
||||
from errno import EWOULDBLOCK
|
||||
from errno import ENOBUFS
|
||||
|
@ -52,7 +51,8 @@ SEND_TIMEOUT = 180
|
|||
|
||||
class SocksQueue:
|
||||
''' queue for all file requests objects '''
|
||||
def __init__(self, idlequeue, complete_transfer_cb = None, progress_transfer_cb = None):
|
||||
def __init__(self, idlequeue, complete_transfer_cb=None,
|
||||
progress_transfer_cb=None, error_cb=None):
|
||||
self.connected = 0
|
||||
self.readers = {}
|
||||
self.files_props = {}
|
||||
|
@ -65,6 +65,7 @@ class SocksQueue:
|
|||
self.idlequeue = idlequeue
|
||||
self.complete_transfer_cb = complete_transfer_cb
|
||||
self.progress_transfer_cb = progress_transfer_cb
|
||||
self.error_cb = error_cb
|
||||
self.on_success = None
|
||||
self.on_failure = None
|
||||
|
||||
|
@ -77,11 +78,12 @@ class SocksQueue:
|
|||
self.listener = Socks5Listener(self.idlequeue, port)
|
||||
self.listener.queue = self
|
||||
self.listener.bind()
|
||||
if self.listener.started is False:
|
||||
if self.listener.started is False or True:
|
||||
self.listener = None
|
||||
# We cannot bind port, call error
|
||||
# dialog from dialogs.py and fail
|
||||
BindPortError(port)
|
||||
# We cannot bind port, call error callback and fail
|
||||
self.error_cb(_('Unable to bind to port %s.') % port,
|
||||
_('Maybe you have another running instance of Gajim. File '
|
||||
'Transfer will be cancelled.'))
|
||||
return None
|
||||
self.connected += 1
|
||||
return self.listener
|
||||
|
|
|
@ -1186,12 +1186,6 @@ class FileChooserDialog(gtk.FileChooserDialog):
|
|||
def just_destroy(self, widget):
|
||||
self.destroy()
|
||||
|
||||
class BindPortError:
|
||||
def __init__(self, port):
|
||||
ErrorDialog(_('Unable to bind to port %s.') % port,
|
||||
_('Maybe you have another running instance of Gajim. '
|
||||
'File Transfer will be cancelled.'))
|
||||
|
||||
class AspellDictError:
|
||||
def __init__(self, lang):
|
||||
ErrorDialog(
|
||||
|
|
|
@ -1644,6 +1644,9 @@ class Interface:
|
|||
notify.popup(event_type, jid, account, 'file-request',
|
||||
path_to_image = path, title = event_type, text = txt)
|
||||
|
||||
def handle_event_file_error(self, title, message):
|
||||
dialogs.ErrorDialog(title, message)
|
||||
|
||||
def handle_event_file_progress(self, account, file_props):
|
||||
if time.time() - self.last_ftwindow_update > 0.5:
|
||||
# update ft window every 500ms
|
||||
|
@ -3122,8 +3125,10 @@ class Interface:
|
|||
gajim.resolver = nslookup.Resolver(gajim.idlequeue)
|
||||
gajim.socks5queue = socks5.SocksQueue(gajim.idlequeue,
|
||||
self.handle_event_file_rcv_completed,
|
||||
self.handle_event_file_progress)
|
||||
self.handle_event_file_progress,
|
||||
self.handle_event_file_error)
|
||||
gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue)
|
||||
gajim.default_session_type = ChatControlSession
|
||||
self.register_handlers()
|
||||
if gajim.config.get('enable_zeroconf'):
|
||||
gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME)
|
||||
|
|
|
@ -24,13 +24,9 @@ from common.configpaths import gajimpaths
|
|||
from common import crypto
|
||||
from common import exceptions
|
||||
|
||||
import dialogs
|
||||
|
||||
import os
|
||||
import pickle
|
||||
|
||||
import gtk
|
||||
|
||||
secrets_filename = gajimpaths['SECRETS_FILE']
|
||||
secrets_cache = None
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue