Commit fe2e49d2 authored by Philipp Hörist's avatar Philipp Hörist

Merge branch 'removeSuffix' into 'master'

Remove "_nb" suffix

See merge request !30
parents 7d1b7f39 09b64b9f
......@@ -9,9 +9,9 @@ Thanks and credits to the xmpppy developers. See: http://xmpppy.sourceforge.net/
"""
from .protocol import *
from . import simplexml, protocol, auth, transports_nb, roster_nb
from . import dispatcher_nb, features_nb, idlequeue, bosh, tls_nb, proxy_connectors
from .client_nb import NonBlockingClient
from . import simplexml, protocol, auth, transports, roster
from . import dispatcher, features, idlequeue, bosh, tls, proxy_connectors
from .client import NonBlockingClient
from .plugin import PlugIn
from .smacks import Smacks
......
......@@ -23,7 +23,7 @@ import locale
import logging
from hashlib import sha1
from .transports_nb import NonBlockingTransport, NonBlockingHTTPBOSH,\
from .transports import NonBlockingTransport, NonBlockingHTTPBOSH,\
CONNECTED, CONNECTING, DISCONNECTED, DISCONNECTING,\
urisplit, DISCONNECT_TIMEOUT_SECONDS
from .protocol import BOSHBody, Protocol, NS_CLIENT
......
## client_nb.py
## based on client.py, changes backported up to revision 1.60
## client.py
##
## Copyright (C) 2003-2005 Alexey "Snake" Nezhdanov
## modified by Dimitur Kirov <dkirov@gmail.com>
......@@ -21,7 +20,7 @@ Client class establishes connection to XMPP Server and handles authentication
import socket
import logging
from . import transports_nb, dispatcher_nb, roster_nb, protocol, bosh
from . import transports, dispatcher, roster, protocol, bosh
from .protocol import NS_TLS
from .protocol import JID
from .auth import SASL
......@@ -31,7 +30,7 @@ from .const import Realm
from .const import Event
log = logging.getLogger('nbxmpp.client_nb')
log = logging.getLogger('nbxmpp.client')
class NonBlockingClient:
......@@ -207,7 +206,7 @@ class NonBlockingClient:
'tls' - TLS established after negotiation with starttls, or
'plain'.
cacerts, mycerts, tls_version, cipher_list, alpn
see tls_nb.NonBlockingTLS constructor for more details
see tls.NonBlockingTLS constructor for more details
"""
self.on_connect = on_connect
self.on_connect_failure=on_connect_failure
......@@ -244,7 +243,7 @@ class NonBlockingClient:
# tcp_host is hostname of machine used for socket connection
# (DNS request will be done for proxy or BOSH CM hostname)
tcp_host, tcp_port, proxy_user, proxy_pass = \
transports_nb.get_proxy_data_from_dict(proxy)
transports.get_proxy_data_from_dict(proxy)
if proxy['type'] == 'bosh':
# Setup BOSH transport
......@@ -271,7 +270,7 @@ class NonBlockingClient:
if not proxy or proxy['type'] != 'bosh':
# Setup ordinary TCP transport
self.socket = transports_nb.NonBlockingTCP.get_instance(
self.socket = transports.NonBlockingTCP.get_instance(
on_disconnect=self.disconnect,
raise_event=self.raise_event,
idlequeue=self.idlequeue,
......@@ -377,7 +376,7 @@ class NonBlockingClient:
if 'Dispatcher' in self.__dict__:
self.Dispatcher.PlugOut()
self.got_features = False
dispatcher_nb.Dispatcher.get_instance().PlugIn(self)
dispatcher.Dispatcher.get_instance().PlugIn(self)
on_next_receive('RECEIVE_DOCUMENT_ATTRIBUTES')
elif mode == 'FAILURE':
......@@ -572,7 +571,7 @@ class NonBlockingClient:
Plug in the roster
"""
if 'NonBlockingRoster' not in self.__dict__:
return roster_nb.NonBlockingRoster.get_instance(
return roster.NonBlockingRoster.get_instance(
version=version).PlugIn(self, request=request)
def getRoster(self, on_ready=None, force=False):
......@@ -591,8 +590,8 @@ class NonBlockingClient:
"""
if requestRoster:
# FIXME: used somewhere?
roster_nb.NonBlockingRoster.get_instance().PlugIn(self)
self.send(dispatcher_nb.Presence(to=jid, typ=typ))
roster.NonBlockingRoster.get_instance().PlugIn(self)
self.send(dispatcher.Presence(to=jid, typ=typ))
###############################################################################
### following methods are moved from blocking client class of xmpppy
......
## dispatcher_nb.py
## based on dispatcher.py
## dispatcher.py
##
## Copyright (C) 2003-2005 Alexey "Snake" Nezhdanov
## modified by Dimitur Kirov <dkirov@gmail.com>
......@@ -72,7 +71,7 @@ from nbxmpp.modules.misc import unwrap_mam
from nbxmpp.util import get_properties_struct
log = logging.getLogger('nbxmpp.dispatcher_nb')
log = logging.getLogger('nbxmpp.dispatcher')
#: default timeout to wait for response for our id
DEFAULT_TIMEOUT_SECONDS = 25
......
## proxy_connectors.py
## based on transports_nb.py
##
## Copyright (C) 2003-2004 Alexey "Snake" Nezhdanov
## modified by Dimitur Kirov <dkirov@gmail.com>
......
## roster_nb.py
## based on roster.py
## roster.py
##
## Copyright (C) 2003-2005 Alexey "Snake" Nezhdanov
## modified by Dimitur Kirov <dkirov@gmail.com>
......@@ -25,7 +24,7 @@ from .protocol import JID, Iq, Presence, Node, NS_MUC_USER, NS_ROSTER
from .plugin import PlugIn
log = logging.getLogger('nbxmpp.roster_nb')
log = logging.getLogger('nbxmpp.roster')
class NonBlockingRoster(PlugIn):
......
......@@ -21,7 +21,7 @@ import logging
from nbxmpp.protocol import NS_STREAM_MGMT
from nbxmpp.protocol import NS_DELAY2
from nbxmpp.simplexml import Node
from nbxmpp.transports_nb import DISCONNECTING
from nbxmpp.transports import DISCONNECTING
from nbxmpp.plugin import PlugIn
from nbxmpp.const import Realm
from nbxmpp.const import Event
......
## tls_nb.py
## based on transports_nb.py
## tls.py
##
## Copyright (C) 2003-2004 Alexey "Snake" Nezhdanov
## modified by Dimitur Kirov <dkirov@gmail.com>
......@@ -23,7 +22,7 @@ import logging
from .plugin import PlugIn
log = logging.getLogger('nbxmpp.tls_nb')
log = logging.getLogger('nbxmpp.tls')
PYOPENSSL = 'PYOPENSSL'
......
## transports_nb.py
## based on transports.py
## transports.py
##
## Copyright (C) 2003-2004 Alexey "Snake" Nezhdanov
## modified by Dimitur Kirov <dkirov@gmail.com>
......@@ -37,9 +36,9 @@ from urllib.parse import urlparse
from .plugin import PlugIn
from .idlequeue import IdleObject
from . import proxy_connectors
from . import tls_nb
from . import tls
log = logging.getLogger('nbxmpp.transports_nb')
log = logging.getLogger('nbxmpp.transports')
def urisplit(uri):
"""
......@@ -130,7 +129,7 @@ class NonBlockingTransport(PlugIn):
:param estabilish_tls: boolean whether to estabilish TLS connection
after TCP connection is done
:param certs: tuple of (cacerts, mycerts) see constructor
of tls_nb.NonBlockingTLS for more details
of tls.NonBlockingTLS for more details
:param tls_version: The lowest supported TLS version.
:param cipher_list: list of ciphers used to connect to server
"""
......@@ -429,7 +428,7 @@ class NonBlockingTCP(NonBlockingTransport, IdleObject):
NonBlockingTLS module
"""
cacerts, mycerts = self.certs
result = tls_nb.NonBlockingTLS.get_instance(cacerts, mycerts,
result = tls.NonBlockingTLS.get_instance(cacerts, mycerts,
self.tls_version, self.cipher_list, self.alpn).PlugIn(self)
if result:
on_succ()
......@@ -607,7 +606,7 @@ class NonBlockingTCP(NonBlockingTransport, IdleObject):
try:
# get as many bites, as possible, but not more than RECV_BUFSIZE
received = self._recv(RECV_BUFSIZE)
except tls_nb.SSLWrapper.Error as e:
except tls.SSLWrapper.Error as e:
log.info("_do_receive, caught SSL error, got %s:" % received,
exc_info=True)
errnum, errstr = e.errno,\
......@@ -619,7 +618,7 @@ class NonBlockingTCP(NonBlockingTransport, IdleObject):
errstr = 'zero bytes on recv'
if (self.ssl_lib is None and received == '') or \
(self.ssl_lib == tls_nb.PYOPENSSL and errnum == -1 ):
(self.ssl_lib == tls.PYOPENSSL and errnum == -1 ):
# -1 in pyopenssl: errstr == Unexpected EOF
log.info("Disconnected by remote server: #%s, %s" % (errnum, errstr))
self.on_remote_disconnect()
......
......@@ -4,7 +4,7 @@ Tests for smacks.py Stream Management
import unittest
from unittest.mock import Mock
from nbxmpp import dispatcher_nb
from nbxmpp import dispatcher
from nbxmpp import protocol
from nbxmpp import smacks
......@@ -14,7 +14,7 @@ class TestDispatcherNB(unittest.TestCase):
into a mock client
'''
def setUp(self):
self.dispatcher = dispatcher_nb.XMPPDispatcher()
self.dispatcher = dispatcher.XMPPDispatcher()
# Setup mock client
self.client = Mock()
......
import unittest
from unittest.mock import Mock
from nbxmpp import dispatcher_nb
from nbxmpp import dispatcher
class XMLVulnerability(unittest.TestCase):
......@@ -9,7 +9,7 @@ class XMLVulnerability(unittest.TestCase):
def setUp(self):
self.client = Mock()
self.client.Connection = Mock()
self.dispatcher = dispatcher_nb.XMPPDispatcher()
self.dispatcher = dispatcher.XMPPDispatcher()
self.dispatcher.PlugIn(self.client)
self.dispatcher.StreamInit()
......
'''
Testing script for NonBlockingClient class (src/common/xmpp/client_nb.py)
Testing script for NonBlockingClient class (nbxmpp/client.py)
It actually connects to a xmpp server.
'''
......@@ -9,7 +9,7 @@ from unittest.mock import Mock
from test.lib.xmpp_mocks import MockConnection, IdleQueueThread
from nbxmpp import client_nb
from nbxmpp import client
# (XMPP server hostname, c2s port). Script will connect to the machine.
xmpp_server_port = ('gajim.org', 5222)
......@@ -54,7 +54,7 @@ class TestNonBlockingClient(unittest.TestCase):
def on_connect_failure(self):
pass
self.client = client_nb.NonBlockingClient(
self.client = client.NonBlockingClient(
domain=server_port[0],
idlequeue=self.idlequeue_thread.iq,
caller=Mock(spec=TempConnection))
......
'''
Tests for dispatcher_nb.py
Tests for dispatcher.py
'''
import unittest
from unittest.mock import Mock
from test import lib
from nbxmpp import dispatcher_nb
from nbxmpp import dispatcher
from nbxmpp import protocol
from nbxmpp.protocol import JID
......@@ -17,7 +17,7 @@ class TestDispatcherNB(unittest.TestCase):
into a mock client
'''
def setUp(self):
self.dispatcher = dispatcher_nb.XMPPDispatcher()
self.dispatcher = dispatcher.XMPPDispatcher()
# Setup mock client
self.client = Mock()
......
......@@ -4,7 +4,7 @@ Unit test for tranports classes.
import unittest
from nbxmpp import transports_nb
from nbxmpp import transports
class TestModuleLevelFunctions(unittest.TestCase):
......@@ -13,7 +13,7 @@ class TestModuleLevelFunctions(unittest.TestCase):
'''
def test_urisplit(self):
def check_uri(uri, proto, host, port, path):
_proto, _host, _port, _path = transports_nb.urisplit(uri)
_proto, _host, _port, _path = transports.urisplit(uri)
self.assertEqual(proto, _proto)
self.assertEqual(host, _host)
self.assertEqual(path, _path)
......@@ -30,7 +30,7 @@ class TestModuleLevelFunctions(unittest.TestCase):
def test_get_proxy_data_from_dict(self):
def check_dict(proxy_dict, host, port, user, passwd):
_host, _port, _user, _passwd = transports_nb.get_proxy_data_from_dict(
_host, _port, _user, _passwd = transports.get_proxy_data_from_dict(
proxy_dict)
self.assertEqual(_host, host)
self.assertEqual(_port, port)
......
......@@ -7,7 +7,7 @@ import unittest
import socket
from test.lib.xmpp_mocks import IdleQueueThread, IdleMock
from nbxmpp import transports_nb
from nbxmpp import transports
class AbstractTransportTest(unittest.TestCase):
......@@ -72,7 +72,7 @@ class TestNonBlockingTCP(AbstractTransportTest):
except socket.error as e:
self.testcase.fail(msg=str(e))
self.socket = transports_nb.NonBlockingTCP(
self.socket = transports.NonBlockingTCP(
raise_event=lambda event_type, data: self.testcase.assertTrue(
event_type and data),
on_disconnect=lambda: self.on_success(mode='SocketDisconnect'),
......@@ -210,7 +210,7 @@ class TestNonBlockingHTTP(AbstractTransportTest):
}
def _get_transport(self, http_dict, proxy_dict=None):
return transports_nb.NonBlockingHTTP(
return transports.NonBlockingHTTP(
raise_event=None,
on_disconnect=None,
idlequeue=self.idlequeue_thread.iq,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment