improve pubsub support. fixes #3103
This commit is contained in:
parent
fc153017ec
commit
abcb48d1e0
|
@ -63,10 +63,11 @@ class OldEntry(xmpp.Node, object):
|
|||
else:
|
||||
main_feed = None
|
||||
|
||||
if self.getTag('source-feed') is not None:
|
||||
source_feed = self.getTag('source-feed').getTagData('title')
|
||||
if self.getTag('feed') is not None:
|
||||
source_feed = self.getTag('feed').getTagData('title')
|
||||
else:
|
||||
source_feed = None
|
||||
|
||||
|
||||
if main_feed is not None and source_feed is not None:
|
||||
return u'%s: %s' % (main_feed, source_feed)
|
||||
|
@ -78,14 +79,13 @@ class OldEntry(xmpp.Node, object):
|
|||
return u''
|
||||
|
||||
feed_title = property(get_feed_title, None, None,
|
||||
''' Title of feed. It is built from entry's original feed title and title of feed
|
||||
''' Title of feed. It is built from entry''s original feed title and title of feed
|
||||
which delivered this entry. ''')
|
||||
|
||||
def get_feed_link(self):
|
||||
''' Get a link to main page of feed (in pubsub.com: second link of rel='alternate',
|
||||
first contains raw xml data). '''
|
||||
''' Get source link '''
|
||||
try:
|
||||
return self.getTag('source-feed').getTags('link', {'rel':'alternate'})[1].getData()
|
||||
return self.getTag('feed').getTags('link',{'rel':'alternate'})[1].getData()
|
||||
except:
|
||||
return None
|
||||
|
||||
|
|
|
@ -1557,20 +1557,13 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
if items is None: return
|
||||
|
||||
for item in items.getTags('item'):
|
||||
# check for event type (for now only one type supported: pubsub.com events)
|
||||
child = item.getTag('pubsub-message')
|
||||
if child is not None:
|
||||
# we have pubsub.com notification
|
||||
child = child.getTag('feed')
|
||||
if child is None: continue
|
||||
|
||||
for entry in child.getTags('entry'):
|
||||
# for each entry in feed (there shouldn't be more than one,
|
||||
# but to be sure...
|
||||
self.dispatch('ATOM_ENTRY', (atom.OldEntry(node=entry),))
|
||||
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):
|
||||
|
|
18
src/disco.py
18
src/disco.py
|
@ -76,7 +76,7 @@ def _gen_agent_type_info():
|
|||
('_jid', 'weather'): (False, 'weather.png'),
|
||||
('gateway', 'sip'): (False, 'sip.png'),
|
||||
('directory', 'user'): (None, 'jud.png'),
|
||||
('pubsub', 'generic'): (None, 'pubsub.png'),
|
||||
('pubsub', 'generic'): (PubSubBrowser, 'pubsub.png'),
|
||||
('pubsub', 'service'): (PubSubBrowser, 'pubsub.png'),
|
||||
('proxy', 'bytestreams'): (None, 'bytestreams.png'), # Socks5 FT proxy
|
||||
|
||||
|
@ -1792,7 +1792,8 @@ class DiscussionGroupsBrowser(AgentBrowser):
|
|||
''' Create treemodel for the window. '''
|
||||
# JID, node, name (with description) - pango markup, dont have info?, subscribed?
|
||||
self.model = gtk.ListStore(str, str, str, bool, bool)
|
||||
self.model.set_sort_column_id(3, gtk.SORT_ASCENDING)
|
||||
# sort by name
|
||||
self.model.set_sort_column_id(2, gtk.SORT_ASCENDING)
|
||||
self.window.services_treeview.set_model(self.model)
|
||||
|
||||
# Name column
|
||||
|
@ -1803,7 +1804,8 @@ class DiscussionGroupsBrowser(AgentBrowser):
|
|||
col.pack_start(renderer)
|
||||
col.set_attributes(renderer, markup=2)
|
||||
col.set_resizable(True)
|
||||
self.window.services_treeview.insert_column(col, -1)
|
||||
self.window.services_treeview.insert_column(col, -1)
|
||||
self.window.services_treeview.set_headers_visible(True)
|
||||
|
||||
# Subscription state
|
||||
renderer = gtk.CellRendererToggle()
|
||||
|
@ -1813,7 +1815,13 @@ class DiscussionGroupsBrowser(AgentBrowser):
|
|||
col.set_resizable(False)
|
||||
self.window.services_treeview.insert_column(col, -1)
|
||||
|
||||
self.window.services_treeview.set_headers_visible(True)
|
||||
# Node Column
|
||||
renderer = gtk.CellRendererText()
|
||||
col = gtk.TreeViewColumn(_('Node'))
|
||||
col.pack_start(renderer)
|
||||
col.set_attributes(renderer, markup=1)
|
||||
col.set_resizable(True)
|
||||
self.window.services_treeview.insert_column(col, -1)
|
||||
|
||||
def _add_item(self, jid, node, item, force):
|
||||
''' Called when we got basic information about new node from query.
|
||||
|
@ -1829,7 +1837,7 @@ class DiscussionGroupsBrowser(AgentBrowser):
|
|||
|
||||
name = gobject.markup_escape_text(name)
|
||||
name = '<b>%s</b>' % name
|
||||
|
||||
|
||||
self.model.append((jid, node, name, dunno, subscribed))
|
||||
|
||||
def _add_actions(self):
|
||||
|
|
Loading…
Reference in New Issue