Commit 77775cf0 authored by Yann Leboulanger's avatar Yann Leboulanger

Gajim now uses python-nbxmpp library instead of embedding it.

parent 0c6117a7
......@@ -16,6 +16,7 @@
<ul>
<li>python2.5 or higher</li>
<li>pygtk2.22 or higher</li>
<li>python-nbxmpp</li>
</ul>
<h2>Optional Runtime Requirements</h2>
......
......@@ -28,7 +28,9 @@
import gobject
import gtk
from common import xmpp, gajim, dataforms
import nbxmpp
from common import gajim
from common import dataforms
import gtkgui_helpers
import dialogs
......@@ -386,7 +388,7 @@ class CommandWindow:
self.send_command(action)
def stage3_next_form(self, command):
if not isinstance(command, xmpp.Node):
if not isinstance(command, nbxmpp.Node):
self.stage5(error=_('Service sent malformed data'), senderror=True)
return
......@@ -506,8 +508,8 @@ class CommandWindow:
if errorid:
# we've got error code, display appropriate message
try:
errorname = xmpp.NS_STANZAS + ' ' + str(errorid)
errordesc = xmpp.ERRORS[errorname][2]
errorname = nbxmpp.NS_STANZAS + ' ' + str(errorid)
errordesc = nbxmpp.ERRORS[errorname][2]
error = errordesc.decode('utf-8')
del errorname, errordesc
except KeyError: # when stanza doesn't have error description
......@@ -570,9 +572,9 @@ class CommandWindow:
"""
Request the command list. Change stage on delivery
"""
query = xmpp.Iq(typ='get', to=xmpp.JID(self.jid),
queryNS=xmpp.NS_DISCO_ITEMS)
query.setQuerynode(xmpp.NS_COMMANDS)
query = nbxmpp.Iq(typ='get', to=xmpp.JID(self.jid),
queryNS=nbxmpp.NS_DISCO_ITEMS)
query.setQuerynode(nbxmpp.NS_COMMANDS)
def callback(response):
'''Called on response to query.'''
......@@ -580,14 +582,14 @@ class CommandWindow:
# is error => error stage
error = response.getError()
if error:
# extracting error description from xmpp/protocol.py
self.stage5(errorid = error)
# extracting error description
self.stage5(errorid=error)
return
# no commands => no commands stage
# commands => command selection stage
query = response.getTag('query')
if query and query.getAttr('node') == xmpp.NS_COMMANDS:
if query and query.getAttr('node') == nbxmpp.NS_COMMANDS:
items = query.getTags('item')
else:
items = []
......@@ -609,9 +611,9 @@ class CommandWindow:
assert isinstance(self.commandnode, unicode)
assert action in ('execute', 'prev', 'next', 'complete')
stanza = xmpp.Iq(typ='set', to=self.jid)
cmdnode = stanza.addChild('command', namespace=xmpp.NS_COMMANDS, attrs={
'node':self.commandnode, 'action':action})
stanza = nbxmpp.Iq(typ='set', to=self.jid)
cmdnode = stanza.addChild('command', namespace=nbxmpp.NS_COMMANDS,
attrs={'node':self.commandnode, 'action':action})
if self.sessionid:
cmdnode.setAttr('sessionid', self.sessionid)
......@@ -636,8 +638,8 @@ class CommandWindow:
assert self.commandnode
if self.sessionid and self.account.connection:
# we already have sessionid, so the service sent at least one reply.
stanza = xmpp.Iq(typ='set', to=self.jid)
stanza.addChild('command', namespace=xmpp.NS_COMMANDS, attrs={
stanza = nbxmpp.Iq(typ='set', to=self.jid)
stanza.addChild('command', namespace=nbxmpp.NS_COMMANDS, attrs={
'node':self.commandnode,
'sessionid':self.sessionid,
'action':'cancel'
......
......@@ -51,10 +51,11 @@ from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
from common.contacts import GC_Contact
from common.logger import constants
from common.pep import MOODS, ACTIVITIES
from common.xmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION
from common.xmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER
from common.xmpp.protocol import NS_CHATSTATES
from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
from nbxmpp.protocol import NS_RECEIPTS, NS_ESESSION
from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO
from nbxmpp.protocol import NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER
from nbxmpp.protocol import NS_CHATSTATES
from common.connection_handlers_events import MessageOutgoingEvent
from common.exceptions import GajimGeneralException
......
......@@ -29,10 +29,10 @@ if you need
# suggestion: rewrite functions that return dates to return standard python time tuples,
# exteneded to contain timezone
import xmpp
import nbxmpp
import time
class PersonConstruct(xmpp.Node, object):
class PersonConstruct(nb.Node, object):
"""
Not used for now, as we don't need authors/contributors in pubsub.com feeds.
They rarely exist there
......@@ -40,7 +40,7 @@ class PersonConstruct(xmpp.Node, object):
def __init__(self, node):
''' Create person construct from node. '''
xmpp.Node.__init__(self, node=node)
nbxmpp.Node.__init__(self, node=node)
def get_name(self):
return self.getTagData('name')
......@@ -63,14 +63,14 @@ class PersonConstruct(xmpp.Node, object):
'''Conveys an e-mail address associated with the person. Might be None when
not set.''')
class Entry(xmpp.Node, object):
class Entry(nbxmpp.Node, object):
def __init__(self, node=None):
xmpp.Node.__init__(self, 'entry', node=node)
nbxmpp.Node.__init__(self, 'entry', node=node)
def __repr__(self):
return '<Atom:Entry object of id="%r">' % self.getAttr('id')
class OldEntry(xmpp.Node, object):
class OldEntry(nbxmpp.Node, object):
"""
Parser for feeds from pubsub.com. They use old Atom 0.3 format with their
extensions
......@@ -78,7 +78,7 @@ class OldEntry(xmpp.Node, object):
def __init__(self, node=None):
''' Create new Atom 0.3 entry object. '''
xmpp.Node.__init__(self, 'entry', node=node)
nbxmpp.Node.__init__(self, 'entry', node=node)
def __repr__(self):
return '<Atom0.3:Entry object of id="%r">' % self.getAttr('id')
......
......@@ -37,11 +37,13 @@ import hashlib
import logging
log = logging.getLogger('gajim.c.caps_cache')
from common.xmpp import (NS_XHTML_IM, NS_RECEIPTS, NS_ESESSION, NS_CHATSTATES,
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_CAPS, NS_JINGLE_FILE_TRANSFER)
from nbxmpp import (NS_XHTML_IM, NS_RECEIPTS, NS_ESESSION, NS_CHATSTATES,
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_CAPS,
NS_JINGLE_FILE_TRANSFER)
# Features where we cannot safely assume that the other side supports them
FEATURE_BLACKLIST = [NS_CHATSTATES, NS_XHTML_IM, NS_RECEIPTS, NS_ESESSION,
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_JINGLE_FILE_TRANSFER]
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO,
NS_JINGLE_FILE_TRANSFER]
# Query entry status codes
NEW = 0
......@@ -96,7 +98,7 @@ def compute_caps_hash(identities, features, dataforms=[], hash_method='sha-1'):
"""
Compute caps hash according to XEP-0115, V1.5
dataforms are xmpp.DataForms objects as common.dataforms don't allow several
dataforms are nbxmpp.DataForms objects as common.dataforms don't allow several
values without a field type list-multi
"""
def sort_identities_func(i1, i2):
......
......@@ -22,7 +22,7 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
import xmpp
import nbxmpp
import helpers
import dataforms
import gajim
......@@ -33,7 +33,7 @@ log = logging.getLogger('gajim.c.commands')
class AdHocCommand:
commandnode = 'command'
commandname = 'The Command'
commandfeatures = (xmpp.NS_DATA,)
commandfeatures = (nbxmpp.NS_DATA,)
@staticmethod
def isVisibleFor(samejid):
......@@ -56,7 +56,7 @@ class AdHocCommand:
assert status in ('executing', 'completed', 'canceled')
response = request.buildReply('result')
cmd = response.getTag('command', namespace=xmpp.NS_COMMANDS)
cmd = response.getTag('command', namespace=nbxmpp.NS_COMMANDS)
cmd.setAttr('sessionid', self.sessionid)
cmd.setAttr('node', self.commandnode)
cmd.setAttr('status', status)
......@@ -72,8 +72,8 @@ class AdHocCommand:
return response, cmd
def badRequest(self, stanza):
self.connection.connection.send(xmpp.Error(stanza, xmpp.NS_STANZAS + \
' bad-request'))
self.connection.connection.send(nbxmpp.Error(stanza,
nbxmpp.NS_STANZAS + ' bad-request'))
def cancel(self, request):
response = self.buildResponse(request, status = 'canceled')[0]
......@@ -354,14 +354,14 @@ class ConnectionCommands:
"""
Test if the bare jid given is the same as our bare jid
"""
return xmpp.JID(jid).getStripped() == self.getOurBareJID()
return nbxmpp.JID(jid).getStripped() == self.getOurBareJID()
def commandListQuery(self, con, iq_obj):
iq = iq_obj.buildReply('result')
jid = helpers.get_full_jid_from_iq(iq_obj)
q = iq.getTag('query')
# buildReply don't copy the node attribute. Re-add it
q.setAttr('node', xmpp.NS_COMMANDS)
q.setAttr('node', nbxmpp.NS_COMMANDS)
for node, cmd in self.__commands.iteritems():
if cmd.isVisibleFor(self.isSameJID(jid)):
......@@ -394,7 +394,7 @@ class ConnectionCommands:
q.addChild('identity', attrs = {'type': 'command-node',
'category': 'automation',
'name': cmd.commandname})
q.addChild('feature', attrs = {'var': xmpp.NS_COMMANDS})
q.addChild('feature', attrs = {'var': nbxmpp.NS_COMMANDS})
for feature in cmd.commandfeatures:
q.addChild('feature', attrs = {'var': feature})
......@@ -436,8 +436,8 @@ class ConnectionCommands:
# and command exist
if node not in self.__commands.keys():
self.connection.send(
xmpp.Error(iq_obj, xmpp.NS_STANZAS + ' item-not-found'))
raise xmpp.NodeProcessed
nbxmpp.Error(iq_obj, nbxmpp.NS_STANZAS + ' item-not-found'))
raise nbxmpp.NodeProcessed
newcmd = self.__commands[node]
if not newcmd.isVisibleFor(self.isSameJID(jid)):
......@@ -451,7 +451,7 @@ class ConnectionCommands:
rc = obj.execute(iq_obj)
if rc:
self.__sessions[(jid, sessionid, node)] = obj
raise xmpp.NodeProcessed
raise nbxmpp.NodeProcessed
else:
# the command is already running, check for it
magictuple = (jid, sessionid, node)
......@@ -486,4 +486,4 @@ class ConnectionCommands:
if not rc:
del self.__sessions[magictuple]
raise xmpp.NodeProcessed
raise nbxmpp.NodeProcessed
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -26,19 +26,19 @@ This module contains wrappers for different parts of data forms (JEP 0004). For
information how to use them, read documentation
"""
import xmpp
import nbxmpp
import helpers
# exceptions used in this module
# base class
class Error(Exception): pass
# when we get xmpp.Node which we do not understand
# when we get nbxmpp.Node which we do not understand
class UnknownDataForm(Error): pass
# when we get xmpp.Node which contains bad fields
# when we get nbxmpp.Node which contains bad fields
class WrongFieldValue(Error): pass
# helper class to change class of already existing object
class ExtendedNode(xmpp.Node, object):
class ExtendedNode(nbxmpp.Node, object):
@classmethod
def __new__(cls, *a, **b):
if 'extend' not in b.keys() or not b['extend']:
......@@ -234,7 +234,7 @@ class DataField(ExtendedNode):
Media data
"""
def fget(self):
media = self.getTag('media', namespace=xmpp.NS_DATA_MEDIA)
media = self.getTag('media', namespace=nbxmpp.NS_DATA_MEDIA)
if media:
return Media(media)
......@@ -252,9 +252,9 @@ class DataField(ExtendedNode):
def is_valid(self):
return True
class Uri(xmpp.Node):
class Uri(nbxmpp.Node):
def __init__(self, uri_tag):
xmpp.Node.__init__(self, node=uri_tag)
nbxmpp.Node.__init__(self, node=uri_tag)
@nested_property
def type_():
......@@ -288,9 +288,9 @@ class Uri(xmpp.Node):
return locals()
class Media(xmpp.Node):
class Media(nbxmpp.Node):
def __init__(self, media_tag):
xmpp.Node.__init__(self, node=media_tag)
nbxmpp.Node.__init__(self, node=media_tag)
@nested_property
def uris():
......@@ -522,12 +522,12 @@ class DataRecord(ExtendedNode):
self.vars = {}
if extend is None:
# we have to build this object from scratch
xmpp.Node.__init__(self)
nbxmpp.Node.__init__(self)
if fields is not None:
self.fields = fields
else:
# we already have xmpp.Node inside - try to convert all
# we already have nbxmpp.Node inside - try to convert all
# fields into DataField objects
if fields is None:
for field in self.iterTags('field'):
......@@ -588,7 +588,7 @@ class DataForm(ExtendedNode):
def __init__(self, type_=None, title=None, instructions=None, extend=None):
if extend is None:
# we have to build form from scratch
xmpp.Node.__init__(self, 'x', attrs={'xmlns': xmpp.NS_DATA})
nbxmpp.Node.__init__(self, 'x', attrs={'xmlns': nbxmpp.NS_DATA})
if type_ is not None:
self.type_=type_
......@@ -700,7 +700,7 @@ class MultipleDataForm(DataForm):
if items is not None:
self.items = items
else:
# we already have xmpp.Node inside - try to convert all
# we already have nbxmpp.Node inside - try to convert all
# fields into DataField objects
if items is None:
self.items = list(self.iterTags('item'))
......
......@@ -32,7 +32,7 @@ import logging
import locale
import config
import xmpp
import nbxmpp
import defs
import common.ged
......@@ -203,15 +203,16 @@ except ImportError:
gajim_identity = {'type': 'pc', 'category': 'client', 'name': 'Gajim'}
gajim_common_features = [xmpp.NS_BYTESTREAM, xmpp.NS_SI, xmpp.NS_FILE,
xmpp.NS_MUC, xmpp.NS_MUC_USER, xmpp.NS_MUC_ADMIN, xmpp.NS_MUC_OWNER,
xmpp.NS_MUC_CONFIG, xmpp.NS_COMMANDS, xmpp.NS_DISCO_INFO, 'ipv6',
'jabber:iq:gateway', xmpp.NS_LAST, xmpp.NS_PRIVACY, xmpp.NS_PRIVATE,
xmpp.NS_REGISTER, xmpp.NS_VERSION, xmpp.NS_DATA, xmpp.NS_ENCRYPTED, 'msglog',
'sslc2s', 'stringprep', xmpp.NS_PING, xmpp.NS_TIME_REVISED, xmpp.NS_SSN,
xmpp.NS_MOOD, xmpp.NS_ACTIVITY, xmpp.NS_NICK, xmpp.NS_ROSTERX, xmpp.NS_SECLABEL,
xmpp.NS_HASHES, xmpp.NS_HASHES_MD5, xmpp.NS_HASHES_SHA1,
xmpp.NS_HASHES_SHA256, xmpp.NS_HASHES_SHA512]
gajim_common_features = [nbxmpp.NS_BYTESTREAM, nbxmpp.NS_SI, nbxmpp.NS_FILE,
nbxmpp.NS_MUC, nbxmpp.NS_MUC_USER, nbxmpp.NS_MUC_ADMIN, nbxmpp.NS_MUC_OWNER,
nbxmpp.NS_MUC_CONFIG, nbxmpp.NS_COMMANDS, nbxmpp.NS_DISCO_INFO, 'ipv6',
'jabber:iq:gateway', nbxmpp.NS_LAST, nbxmpp.NS_PRIVACY, nbxmpp.NS_PRIVATE,
nbxmpp.NS_REGISTER, nbxmpp.NS_VERSION, nbxmpp.NS_DATA, nbxmpp.NS_ENCRYPTED,
'msglog', 'sslc2s', 'stringprep', nbxmpp.NS_PING, nbxmpp.NS_TIME_REVISED,
nbxmpp.NS_SSN, nbxmpp.NS_MOOD, nbxmpp.NS_ACTIVITY, nbxmpp.NS_NICK,
nbxmpp.NS_ROSTERX, nbxmpp.NS_SECLABEL, nbxmpp.NS_HASHES,
nbxmpp.NS_HASHES_MD5, nbxmpp.NS_HASHES_SHA1, nbxmpp.NS_HASHES_SHA256,
nbxmpp.NS_HASHES_SHA512]
# Optional features gajim supports per account
gajim_optional_features = {}
......
......@@ -27,7 +27,7 @@ Global Events Dispatcher module.
import traceback
from common.xmpp import NodeProcessed
from nbxmpp import NodeProcessed
import logging
log = logging.getLogger('gajim.c.ged')
......
......@@ -142,7 +142,7 @@ def parse_resource(resource):
"""
if resource:
try:
from xmpp.stringprepare import resourceprep
from nbxmpp.stringprepare import resourceprep
return resourceprep.prepare(unicode(resource))
except UnicodeError:
raise InvalidFormat, 'Invalid character in resource.'
......@@ -157,7 +157,7 @@ def prep(user, server, resource):
if len(user) < 1 or len(user) > 1023:
raise InvalidFormat, _('Username must be between 1 and 1023 chars')
try:
from xmpp.stringprepare import nodeprep
from nbxmpp.stringprepare import nodeprep
user = nodeprep.prepare(unicode(user))
except UnicodeError:
raise InvalidFormat, _('Invalid character in username.')
......@@ -168,7 +168,7 @@ def prep(user, server, resource):
if len(server) < 1 or len(server) > 1023:
raise InvalidFormat, _('Server must be between 1 and 1023 chars')
try:
from xmpp.stringprepare import nameprep
from nbxmpp.stringprepare import nameprep
server = nameprep.prepare(unicode(server))
except UnicodeError:
raise InvalidFormat, _('Invalid character in hostname.')
......@@ -179,7 +179,7 @@ def prep(user, server, resource):
if len(resource) < 1 or len(resource) > 1023:
raise InvalidFormat, _('Resource must be between 1 and 1023 chars')
try:
from xmpp.stringprepare import resourceprep
from nbxmpp.stringprepare import resourceprep
resource = resourceprep.prepare(unicode(resource))
except UnicodeError:
raise InvalidFormat, _('Invalid character in resource.')
......@@ -1300,7 +1300,7 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID):
return keyID
def update_optional_features(account = None):
import xmpp
import nbxmpp
if account:
accounts = [account]
else:
......@@ -1308,38 +1308,41 @@ def update_optional_features(account = None):
for a in accounts:
gajim.gajim_optional_features[a] = []
if gajim.config.get_per('accounts', a, 'subscribe_mood'):
gajim.gajim_optional_features[a].append(xmpp.NS_MOOD + '+notify')
gajim.gajim_optional_features[a].append(nbxmpp.NS_MOOD + '+notify')
if gajim.config.get_per('accounts', a, 'subscribe_activity'):
gajim.gajim_optional_features[a].append(xmpp.NS_ACTIVITY + '+notify')
gajim.gajim_optional_features[a].append(nbxmpp.NS_ACTIVITY + \
'+notify')
if gajim.config.get_per('accounts', a, 'publish_tune'):
gajim.gajim_optional_features[a].append(xmpp.NS_TUNE)
gajim.gajim_optional_features[a].append(nbxmpp.NS_TUNE)
if gajim.config.get_per('accounts', a, 'publish_location'):
gajim.gajim_optional_features[a].append(xmpp.NS_LOCATION)
gajim.gajim_optional_features[a].append(nbxmpp.NS_LOCATION)
if gajim.config.get_per('accounts', a, 'subscribe_tune'):
gajim.gajim_optional_features[a].append(xmpp.NS_TUNE + '+notify')
gajim.gajim_optional_features[a].append(nbxmpp.NS_TUNE + '+notify')
if gajim.config.get_per('accounts', a, 'subscribe_nick'):
gajim.gajim_optional_features[a].append(xmpp.NS_NICK + '+notify')
gajim.gajim_optional_features[a].append(nbxmpp.NS_NICK + '+notify')
if gajim.config.get_per('accounts', a, 'subscribe_location'):
gajim.gajim_optional_features[a].append(xmpp.NS_LOCATION + '+notify')
gajim.gajim_optional_features[a].append(nbxmpp.NS_LOCATION + \
'+notify')
if gajim.config.get('outgoing_chat_state_notifactions') != 'disabled':
gajim.gajim_optional_features[a].append(xmpp.NS_CHATSTATES)
gajim.gajim_optional_features[a].append(nbxmpp.NS_CHATSTATES)
if not gajim.config.get('ignore_incoming_xhtml'):
gajim.gajim_optional_features[a].append(xmpp.NS_XHTML_IM)
gajim.gajim_optional_features[a].append(nbxmpp.NS_XHTML_IM)
if gajim.HAVE_PYCRYPTO \
and gajim.config.get_per('accounts', a, 'enable_esessions'):
gajim.gajim_optional_features[a].append(xmpp.NS_ESESSION)
gajim.gajim_optional_features[a].append(nbxmpp.NS_ESESSION)
if gajim.config.get_per('accounts', a, 'answer_receipts'):
gajim.gajim_optional_features[a].append(xmpp.NS_RECEIPTS)
gajim.gajim_optional_features[a].append(nbxmpp.NS_RECEIPTS)
if gajim.HAVE_FARSTREAM:
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_RTP)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_RTP_AUDIO)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_RTP_VIDEO)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_ICE_UDP)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_FILE_TRANSFER)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_XTLS)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_BYTESTREAM)
gajim.gajim_optional_features[a].append(xmpp.NS_JINGLE_IBB)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP_AUDIO)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_RTP_VIDEO)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_ICE_UDP)
gajim.gajim_optional_features[a].append(
nbxmpp.NS_JINGLE_FILE_TRANSFER)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_XTLS)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_BYTESTREAM)
gajim.gajim_optional_features[a].append(nbxmpp.NS_JINGLE_IBB)
gajim.caps_hash[a] = caps_cache.compute_caps_hash([gajim.gajim_identity],
gajim.gajim_common_features + gajim.gajim_optional_features[a])
# re-send presence with new hash
......@@ -1381,7 +1384,7 @@ def get_subscription_request_msg(account=None):
return s
def replace_dataform_media(form, stanza):
import xmpp
import nbxmpp
found = False
for field in form.getTags('field'):
for media in field.getTags('media'):
......@@ -1389,7 +1392,7 @@ def replace_dataform_media(form, stanza):
uri_data = uri.getData()
if uri_data.startswith('cid:'):
uri_data = uri_data[4:]
for data in stanza.getTags('data', namespace=xmpp.NS_BOB):
for data in stanza.getTags('data', namespace=nbxmpp.NS_BOB):
if data.getAttr('cid') == uri_data:
uri.setData(data.getData())
found = True
......
......@@ -26,7 +26,7 @@ Handles the jingle signalling protocol
# * config:
# - codecs
import xmpp
import nbxmpp
import helpers
import gajim
......@@ -80,7 +80,7 @@ class ConnectionJingle(object):
if (jid, id_) in self.__iq_responses.keys():
self.__iq_responses[(jid, id_)].on_stanza(stanza)
del self.__iq_responses[(jid, id_)]
raise xmpp.NodeProcessed
raise nbxmpp.NodeProcessed
jingle = stanza.getTag('jingle')
# a jingle element is not necessary in iq-result stanza
# don't check for that
......@@ -105,7 +105,7 @@ class ConnectionJingle(object):
if sid in self._sessions and \
self._sessions[sid].state == JingleStates.ended:
self.delete_jingle_session(sid)
raise xmpp.NodeProcessed
raise nbxmpp.NodeProcessed
def start_audio(self, jid):
if self.get_jingle_session(jid, media='audio'):
......@@ -143,15 +143,15 @@ class ConnectionJingle(object):
contact = gajim.contacts.get_gc_contact(self.name, gcc[0], gcc[1])
if contact is None:
return
use_security = contact.supports(xmpp.NS_JINGLE_XTLS)
use_security = contact.supports(nbxmpp.NS_JINGLE_XTLS)
jingle = JingleSession(self, weinitiate=True, jid=jid, werequest=request)
# this is a file transfer
jingle.session_type_FT = True
self._sessions[jingle.sid] = jingle
file_props.sid = jingle.sid
if contact.supports(xmpp.NS_JINGLE_BYTESTREAM):
if contact.supports(nbxmpp.NS_JINGLE_BYTESTREAM):
transport = JingleTransportSocks5()
elif contact.supports(xmpp.NS_JINGLE_IBB):
elif contact.supports(nbxmpp.NS_JINGLE_IBB):
transport = JingleTransportIBB()
c = JingleFileTransfer(jingle, transport=transport,
file_props=file_props, use_security=use_security)
......@@ -161,14 +161,14 @@ class ConnectionJingle(object):
return c.transport.sid
def __hash_support(self, contact):
if contact.supports(xmpp.NS_HASHES):
if contact.supports(xmpp.NS_HASHES_MD5):
if contact.supports(nbxmpp.NS_HASHES):
if contact.supports(nbxmpp.NS_HASHES_MD5):
return 'md5'
elif contact.supports(xmpp.NS_HASHES_SHA1):
elif contact.supports(nbxmpp.NS_HASHES_SHA1):
return 'sha-1'
elif contact.supports(xmpp.NS_HASHES_SHA256):
elif contact.supports(nbxmpp.NS_HASHES_SHA256):
return 'sha-256'
elif contact.supports(xmpp.NS_HASHES_SHA512):
elif contact.supports(nbxmpp.NS_HASHES_SHA512):
return 'sha-512'
return None
......
......@@ -16,7 +16,7 @@ Handles Jingle contents (XEP 0166)
"""
import gajim
import xmpp
import nbxmpp
from jingle_transport import JingleTransportIBB
contents = {}
......@@ -127,7 +127,7 @@ class JingleContent(object):
"""
Build a XML content-wrapper for our data
"""
return xmpp.Node('content',
return nbxmpp.Node('content',
attrs={'name': self.name, 'creator': self.creator},
payload=payload)
......@@ -164,29 +164,29 @@ class JingleContent(object):
content.addChild(node=self.transport.make_transport())
def _fill_content(self, content):
description_node = xmpp.simplexml.Node(
tag=xmpp.NS_JINGLE_FILE_TRANSFER + ' description')
description_node = nbxmpp.simplexml.Node(
tag=nbxmpp.NS_JINGLE_FILE_TRANSFER + ' description')
if self.session.werequest:
simode = xmpp.simplexml.Node(tag='request')
simode = nbxmpp.simplexml.Node(tag='request')
else:
simode = xmpp.simplexml.Node(tag='offer')
file_tag = simode.setTag('file', namespace=xmpp.NS_FILE)
simode = nbxmpp.simplexml.Node(tag='offer')
file_tag = simode.setTag('file', namespace=nbxmpp.NS_FILE)
if self.file_props.name:
node = xmpp.simplexml.Node(tag='name')
node = nbxmpp.simplexml.Node(tag='name')
node.addData(self.file_props.name)
file_tag.addChild(node=node)
if self.file_props.date:
node = xmpp.simplexml.Node(tag='date')
node = nbxmpp.simplexml.Node(tag='date')
node.addData(self.file_props.date)
file_tag.addChild(node=node)
if self.file_props.size:
node = xmpp.simplexml.Node(tag='size')
node = nbxmpp.simplexml.Node(tag='size')
node.addData(self.file_props.size)
file_tag.addChild(node=node)
if self.file_props.type_ == 'r':
if self.file_props.hash_:
h = file_tag.addChild('hash', attrs={
'algo': self.file_props.algo}, namespace=xmpp.NS_HASHES,
'algo': self.file_props.algo}, namespace=nbxmpp.NS_HASHES,
payload=self.file_props.hash_)
else:
# if the file is less than 10 mb, then it is small
......@@ -209,11 +209,11 @@ class JingleContent(object):
desc.setData(self.file_props.desc)
description_node.addChild(node=simode)
if self.use_security:
security = xmpp.simplexml.Node(
tag=xmpp.NS_JINGLE_XTLS + ' security')
security = nbxmpp.simplexml.Node(
tag=nbxmpp.NS_JINGLE_XTLS + ' security')
# TODO: add fingerprint element
for m in ('x509', ): # supported authentication methods
method = xmpp.simplexml.Node(tag='method')
method = nbxmpp.simplexml.Node(tag='method')
method.setAttr('name', m)
security.addChild(node=method)
content.addChild(node=security)
......
......@@ -21,7 +21,7 @@ Handles Jingle File Transfer (XEP 0234)
import hashlib
import gajim
import xmpp
import nbxmpp
from jingle_content import contents, JingleContent
from jingle_transport import *
from common import helpers
......@@ -70,7 +70,7 @@ class JingleFileTransfer(JingleContent):
self.use_security = use_security
self.file_props = file_props
self.weinitiate = self.session.weinitiate
self.werequest = self.session.werequest
self.werequest = self.session.werequest
if self.file_props is not None:
if self.session.werequest:
self.file_props.sender = self.session.peerjid
......@@ -130,9 +130,9 @@ class JingleFileTransfer(JingleContent):
def __send_hash(self):
# Send hash in a session info
checksum = xmpp.Node(tag='checksum', payload=[xmpp.Node(tag='file',
checksum = nbxmpp.Node(tag='checksum', payload=[nbxmpp.Node(tag='file',
payload=[self._calcHash()])])
checksum.setNamespace(xmpp.NS_JINGLE_FILE_TRANSFER)
checksum.setNamespace(nbxmpp.NS_JINGLE_FILE_TRANSFER)
self.session.__session_info(checksum )