From abcb48d1e0e76563231295fb9e553ae2d645a41c Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 24 Jun 2007 22:33:00 +0000 Subject: [PATCH] improve pubsub support. fixes #3103 --- src/common/atom.py | 12 ++++++------ src/common/connection_handlers.py | 17 +++++------------ src/disco.py | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/common/atom.py b/src/common/atom.py index 7490f3bc7..86c75c5ba 100644 --- a/src/common/atom.py +++ b/src/common/atom.py @@ -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 diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index ea469b219..32b4d2bf5 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -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): diff --git a/src/disco.py b/src/disco.py index 33b217efd..710f4ad13 100644 --- a/src/disco.py +++ b/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 = '%s' % name - + self.model.append((jid, node, name, dunno, subscribed)) def _add_actions(self):