improve pubsub support. fixes #3103
This commit is contained in:
		
							parent
							
								
									fc153017ec
								
							
						
					
					
						commit
						abcb48d1e0
					
				
					 3 changed files with 24 additions and 23 deletions
				
			
		| 
						 | 
					@ -63,11 +63,12 @@ class OldEntry(xmpp.Node, object):
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			main_feed = None
 | 
								main_feed = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if self.getTag('source-feed') is not None:
 | 
							if self.getTag('feed') is not None:
 | 
				
			||||||
			source_feed = self.getTag('source-feed').getTagData('title')
 | 
								source_feed = self.getTag('feed').getTagData('title')
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			source_feed = None
 | 
								source_feed = None
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if main_feed is not None and source_feed is not None:
 | 
							if main_feed is not None and source_feed is not None:
 | 
				
			||||||
			return u'%s: %s' % (main_feed, source_feed)
 | 
								return u'%s: %s' % (main_feed, source_feed)
 | 
				
			||||||
		elif main_feed is not None:
 | 
							elif main_feed is not None:
 | 
				
			||||||
| 
						 | 
					@ -78,14 +79,13 @@ class OldEntry(xmpp.Node, object):
 | 
				
			||||||
			return u''
 | 
								return u''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	feed_title = property(get_feed_title, None, None, 
 | 
						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. ''')
 | 
							which delivered this entry. ''')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def get_feed_link(self):
 | 
						def get_feed_link(self):
 | 
				
			||||||
		''' Get a link to main page of feed (in pubsub.com: second link of rel='alternate',
 | 
							''' Get source link '''
 | 
				
			||||||
		first contains raw xml data). '''
 | 
					 | 
				
			||||||
		try:
 | 
							try:
 | 
				
			||||||
			return self.getTag('source-feed').getTags('link', {'rel':'alternate'})[1].getData()
 | 
								return self.getTag('feed').getTags('link',{'rel':'alternate'})[1].getData()
 | 
				
			||||||
		except:
 | 
							except:
 | 
				
			||||||
			return None
 | 
								return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1557,20 +1557,13 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
 | 
				
			||||||
		if items is None: return
 | 
							if items is None: return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for item in items.getTags('item'):
 | 
							for item in items.getTags('item'):
 | 
				
			||||||
			# check for event type (for now only one type supported: pubsub.com events)
 | 
								entry = item.getTag('entry')
 | 
				
			||||||
			child = item.getTag('pubsub-message')
 | 
								if entry is not None:
 | 
				
			||||||
			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,
 | 
									# for each entry in feed (there shouldn't be more than one,
 | 
				
			||||||
				# but to be sure...
 | 
									# but to be sure...
 | 
				
			||||||
				self.dispatch('ATOM_ENTRY', (atom.OldEntry(node=entry),))
 | 
									self.dispatch('ATOM_ENTRY', (atom.OldEntry(node=entry),))
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			# unknown type... probably user has another client who understands that event
 | 
								# unknown type... probably user has another client who understands that event
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		raise common.xmpp.NodeProcessed
 | 
							raise common.xmpp.NodeProcessed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def _presenceCB(self, con, prs):
 | 
						def _presenceCB(self, con, prs):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								src/disco.py
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								src/disco.py
									
										
									
									
									
								
							| 
						 | 
					@ -76,7 +76,7 @@ def _gen_agent_type_info():
 | 
				
			||||||
		('_jid', 'weather'):			(False, 'weather.png'),
 | 
							('_jid', 'weather'):			(False, 'weather.png'),
 | 
				
			||||||
		('gateway', 'sip'):			(False, 'sip.png'),
 | 
							('gateway', 'sip'):			(False, 'sip.png'),
 | 
				
			||||||
		('directory', 'user'):		(None, 'jud.png'),
 | 
							('directory', 'user'):		(None, 'jud.png'),
 | 
				
			||||||
		('pubsub', 'generic'):		(None, 'pubsub.png'),
 | 
							('pubsub', 'generic'):		(PubSubBrowser, 'pubsub.png'),
 | 
				
			||||||
		('pubsub', 'service'):		(PubSubBrowser, 'pubsub.png'),
 | 
							('pubsub', 'service'):		(PubSubBrowser, 'pubsub.png'),
 | 
				
			||||||
		('proxy', 'bytestreams'):	(None, 'bytestreams.png'), # Socks5 FT proxy
 | 
							('proxy', 'bytestreams'):	(None, 'bytestreams.png'), # Socks5 FT proxy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1792,7 +1792,8 @@ class DiscussionGroupsBrowser(AgentBrowser):
 | 
				
			||||||
		''' Create treemodel for the window. '''
 | 
							''' Create treemodel for the window. '''
 | 
				
			||||||
		# JID, node, name (with description) - pango markup, dont have info?, subscribed?
 | 
							# JID, node, name (with description) - pango markup, dont have info?, subscribed?
 | 
				
			||||||
		self.model = gtk.ListStore(str, str, str, bool, bool)
 | 
							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)
 | 
							self.window.services_treeview.set_model(self.model)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Name column
 | 
							# Name column
 | 
				
			||||||
| 
						 | 
					@ -1804,6 +1805,7 @@ class DiscussionGroupsBrowser(AgentBrowser):
 | 
				
			||||||
		col.set_attributes(renderer, markup=2)
 | 
							col.set_attributes(renderer, markup=2)
 | 
				
			||||||
		col.set_resizable(True)
 | 
							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
 | 
							# Subscription state
 | 
				
			||||||
		renderer = gtk.CellRendererToggle()
 | 
							renderer = gtk.CellRendererToggle()
 | 
				
			||||||
| 
						 | 
					@ -1813,7 +1815,13 @@ class DiscussionGroupsBrowser(AgentBrowser):
 | 
				
			||||||
		col.set_resizable(False)
 | 
							col.set_resizable(False)
 | 
				
			||||||
		self.window.services_treeview.insert_column(col, -1)
 | 
							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):
 | 
						def _add_item(self, jid, node, item, force):
 | 
				
			||||||
		''' Called when we got basic information about new node from query.
 | 
							''' Called when we got basic information about new node from query.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue