diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py
index e134aa003..cb9197d5e 100644
--- a/src/common/connection_handlers.py
+++ b/src/common/connection_handlers.py
@@ -46,11 +46,10 @@ import common.xmpp
from common import helpers
from common import gajim
-from common import atom
-from common import pep
from common import exceptions
from common.commands import ConnectionCommands
from common.pubsub import ConnectionPubSub
+from common.pep import ConnectionPEP
from common.caps import ConnectionCaps
if gajim.HAVE_FARSIGHT:
from common.jingle import ConnectionJingle
@@ -1453,7 +1452,7 @@ sent a message to.'''
return sess
-class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, ConnectionCommands, ConnectionPubSub, ConnectionCaps, ConnectionHandlersBase, ConnectionJingle):
+class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, ConnectionCommands, ConnectionPubSub, ConnectionPEP, ConnectionCaps, ConnectionHandlersBase, ConnectionJingle):
def __init__(self):
ConnectionVcard.__init__(self)
ConnectionBytestream.__init__(self)
@@ -1874,15 +1873,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
def _messageCB(self, con, msg):
'''Called when we receive a message'''
log.debug('MessageCB')
-
mtype = msg.getType()
- # check if the message is pubsub#event
- if msg.getTag('event') is not None:
- if mtype == 'groupchat':
- return
- if msg.getTag('error') is None:
- self._pubsubEventCB(con, msg)
- return
# check if the message is a roster item exchange (XEP-0144)
if msg.getTag('x', namespace=common.xmpp.NS_ROSTERX):
@@ -2148,42 +2139,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
self.dispatch('GC_INVITATION',(frm, jid_from, reason, password,
is_continued))
- def _pubsubEventCB(self, con, msg):
- ''' Called when we receive with pubsub event. '''
- # TODO: Logging? (actually services where logging would be useful, should
- # TODO: allow to access archives remotely...)
- jid = helpers.get_full_jid_from_iq(msg)
- event = msg.getTag('event')
-
- # XEP-0107: User Mood
- items = event.getTag('items', {'node': common.xmpp.NS_MOOD})
- if items: pep.user_mood(items, self.name, jid)
- # XEP-0118: User Tune
- items = event.getTag('items', {'node': common.xmpp.NS_TUNE})
- if items: pep.user_tune(items, self.name, jid)
- # XEP-0080: User Geolocation
- items = event.getTag('items', {'node': common.xmpp.NS_GEOLOC})
- if items: pep.user_geoloc(items, self.name, jid)
- # XEP-0108: User Activity
- items = event.getTag('items', {'node': common.xmpp.NS_ACTIVITY})
- if items: pep.user_activity(items, self.name, jid)
- # XEP-0172: User Nickname
- items = event.getTag('items', {'node': common.xmpp.NS_NICK})
- if items: pep.user_nickname(items, self.name, jid)
-
- items = event.getTag('items')
- if items is None: return
-
- for item in items.getTags('item'):
- entry = item.getTag('entry')
- if entry is not None:
- # for each entry in feed (there shouldn't be more than one,
- # but to be sure...
- self.dispatch('ATOM_ENTRY', (atom.OldEntry(node=entry),))
- continue
- # unknown type... probably user has another client who understands that event
- raise common.xmpp.NodeProcessed
-
def _presenceCB(self, con, prs):
'''Called when we receive a presence'''
ptype = prs.getType()
@@ -2751,6 +2706,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
con.RegisterHandler('message', self._messageCB)
con.RegisterHandler('presence', self._presenceCB)
con.RegisterHandler('presence', self._capsPresenceCB)
+ con.RegisterHandler('message', self._pubsubEventCB,
+ ns=common.xmpp.NS_PUBSUB_EVENT)
con.RegisterHandler('iq', self._vCardCB, 'result',
common.xmpp.NS_VCARD)
con.RegisterHandler('iq', self._rosterSetCB, 'set',
diff --git a/src/common/pep.py b/src/common/pep.py
index 54012514f..fe67d578a 100644
--- a/src/common/pep.py
+++ b/src/common/pep.py
@@ -192,6 +192,56 @@ ACTIVITIES = {
'studying': _('Studying'),
'writing': _('Writing')}}
+import logging
+log = logging.getLogger('gajim.c.pep')
+
+import helpers
+import atom
+
+class ConnectionPEP:
+
+ def _pubsubEventCB(self, xmpp_dispatcher, msg):
+ ''' Called when we receive with pubsub event. '''
+
+ if msg.getTag('error'):
+ log.warning('Pep Error CB')
+ return
+
+ # TODO: Logging? (actually services where logging would be useful, should
+ # TODO: allow to access archives remotely...)
+ jid = helpers.get_full_jid_from_iq(msg)
+ event = msg.getTag('event')
+
+ # XEP-0107: User Mood
+ items = event.getTag('items', {'node': common.xmpp.NS_MOOD})
+ if items: user_mood(items, self.name, jid)
+ # XEP-0118: User Tune
+ items = event.getTag('items', {'node': common.xmpp.NS_TUNE})
+ if items: user_tune(items, self.name, jid)
+ # XEP-0080: User Geolocation
+ items = event.getTag('items', {'node': common.xmpp.NS_GEOLOC})
+ if items: user_geoloc(items, self.name, jid)
+ # XEP-0108: User Activity
+ items = event.getTag('items', {'node': common.xmpp.NS_ACTIVITY})
+ if items: user_activity(items, self.name, jid)
+ # XEP-0172: User Nickname
+ items = event.getTag('items', {'node': common.xmpp.NS_NICK})
+ if items: user_nickname(items, self.name, jid)
+
+ items = event.getTag('items')
+ if items is None: return
+
+ for item in items.getTags('item'):
+ entry = item.getTag('entry')
+ if entry is not None:
+ # for each entry in feed (there shouldn't be more than one,
+ # but to be sure...
+ self.dispatch('ATOM_ENTRY', (atom.OldEntry(node=entry),))
+ continue
+ # unknown type... probably user has another client who understands that event
+
+ raise common.xmpp.NodeProcessed
+
def user_mood(items, name, jid):
has_child = False
retract = False
diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py
index 619771409..5eb31b7d3 100644
--- a/src/common/xmpp/protocol.py
+++ b/src/common/xmpp/protocol.py
@@ -88,6 +88,7 @@ NS_PRIVACY ='jabber:iq:privacy'
NS_PRIVATE ='jabber:iq:private'
NS_PROFILE ='http://jabber.org/protocol/profile' # XEP-0154
NS_PUBSUB ='http://jabber.org/protocol/pubsub' # XEP-0060
+NS_PUBSUB_EVENT = 'http://jabber.org/protocol/pubsub#event'
NS_PUBSUB_PUBLISH_OPTIONS = NS_PUBSUB + '#publish-options' # XEP-0060
NS_PUBSUB_OWNER ='http://jabber.org/protocol/pubsub#owner' # JEP-0060
NS_REGISTER ='jabber:iq:register'