Commit 344bd6e3 authored by Alexander's avatar Alexander

[stickers] Remove namespace declarations

parent fb3dbf48
......@@ -39,8 +39,4 @@ def dump_hashes(hashes):
ANIMATED_MIME_TYPES = ['image/gif']
STICKERS_NAMESPACE = 'urn:xmpp:stickers:0'
SFS_NAMESPACE = 'urn:xmpp:sfs:0'
FME_NAMESPACE = 'urn:xmpp:file:metadata:0'
URL_DATA_NAMESPACE = 'http://jabber.org/protocol/url-data'
PUBSUB_MAX_FEATURE = 'http://jabber.org/protocol/pubsub#config-node-max'
......@@ -31,10 +31,6 @@ from stickers.utils import body
from stickers.common import Sticker
from stickers.common import StickerPack
from stickers.common import Hash
from stickers.common import STICKERS_NAMESPACE
from stickers.common import SFS_NAMESPACE
from stickers.common import FME_NAMESPACE
from stickers.common import URL_DATA_NAMESPACE
from stickers.common import PUBSUB_MAX_FEATURE
log = logging.getLogger('gajim.p.stickers.module')
......@@ -62,7 +58,7 @@ def parse_sticker_pack(item):
stickers = []
for sticker in pack.iterTags('item'):
file_ = sticker.getTag('file', namespace=FME_NAMESPACE)
file_ = sticker.getTag('file', namespace=Namespace.FILE_METADATA)
suggests = [x.getPayload()[0] for x in sticker.getTags('suggest')]
hashes = list(map(parse_hash_node, file_.getTags('hash', namespace=Namespace.HASHES_2)))
size = body(file_, 'size')
......@@ -71,7 +67,7 @@ def parse_sticker_pack(item):
type_ = body(file_, 'media-type')
# TODO: Multiple sources types
sources = sticker.getTag('sources', namespace=SFS_NAMESPACE)
sources = sticker.getTag('sources', namespace=Namespace.SFS)
is_http_url = lambda x: x.getAttr('target').startswith('http')
url_node = find_one(is_http_url, sources.getTags('url-data'))
url = ''
......@@ -113,7 +109,7 @@ class StickersModule(BaseModule):
jid: The JID to request the sticker packs from
'''
self._nbxmpp('PubSub').request_items(callback=self._sticker_packs_request_done,
node=STICKERS_NAMESPACE,
node=Namespace.STICKERS,
jid=jid)
def _sticker_packs_request_done(self, task):
......@@ -137,7 +133,7 @@ class StickersModule(BaseModule):
jid: The JID to request the sticker pack from
'''
self._nbxmpp('PubSub').request_item(callback=self._sticker_pack_request_done,
node=STICKERS_NAMESPACE,
node=Namespace.STICKERS,
id_=id_,
jid=jid)
......@@ -160,7 +156,7 @@ class StickersModule(BaseModule):
id_: The ID of the sticker pack to retract
'''
self._nbxmpp('PubSub').retract(callback=self._sticker_pack_retract_done,
node=STICKERS_NAMESPACE,
node=Namespace.STICKERS,
id_=id_,
user_data=id_)
......@@ -212,7 +208,7 @@ class StickersModule(BaseModule):
'''
pack_node = Node(tag='pack',
attrs={
'xmlns': STICKERS_NAMESPACE
'xmlns': Namespace.STICKERS,
})
pack_node.setTagData('name', sticker_pack.name)
pack_node.setTagData('summary', sticker_pack.summary)
......@@ -228,7 +224,7 @@ class StickersModule(BaseModule):
file_ = Node(tag='file',
attrs={
'xmlns': FME_NAMESPACE
'xmlns': Namespace.FILE_METADATA
})
file_.setTagData('media-type', sticker.type)
file_.setTagData('desc', sticker.desc)
......@@ -247,13 +243,13 @@ class StickersModule(BaseModule):
sources = Node(tag='sources',
attrs={
'xmlns': SFS_NAMESPACE
'xmlns': Namespace.SFS
})
sources.setTag('url-data',
attrs={
'target': sticker.url,
},
namespace=URL_DATA_NAMESPACE)
namespace=Namespace.URL_DATA)
item.addChild(node=sources)
pack_node.addChild(node=item)
......@@ -265,7 +261,7 @@ class StickersModule(BaseModule):
log.debug('Publishing %s on PubSub', sticker_pack.id_)
self._nbxmpp('PubSub').publish(callback=self._sticker_pack_publish_done,
node=STICKERS_NAMESPACE,
node=Namespace.STICKERS,
item=pack_node,
id_=sticker_pack.id_,
options=node_options,
......
......@@ -71,10 +71,6 @@ from stickers.common import Hash
from stickers.common import StickerPack
from stickers.common import parse_hashes
from stickers.common import dump_hashes
from stickers.common import STICKERS_NAMESPACE
from stickers.common import SFS_NAMESPACE
from stickers.common import FME_NAMESPACE
from stickers.common import URL_DATA_NAMESPACE
from stickers.common import ANIMATED_MIME_TYPES
log = logging.getLogger('gajim.p.stickers')
......@@ -825,15 +821,15 @@ class StickersButton(Gtk.Button):
sticker_node = Node(tag='sticker',
attrs={
'id': pack_id,
'xmlns': STICKERS_NAMESPACE,
'xmlns': Namespace.STICKERS,
})
sfs_node = Node(tag='file-sharing',
attrs={
'xmlns': SFS_NAMESPACE
'xmlns': Namespace.SFS
})
file_node = Node(tag='file',
attrs={
'xmlns': FME_NAMESPACE
'xmlns': Namespace.FILE_METADATA
})
file_node.setTagData('media-type', sticker.type)
file_node.setTagData('desc', sticker.desc)
......@@ -850,7 +846,7 @@ class StickersButton(Gtk.Button):
sources_node = Node(tag='sources')
sources_node.addChild(name='url-data',
namespace=URL_DATA_NAMESPACE,
namespace=Namespace.URL_DATA,
attrs={
'target': sticker.url
})
......
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