revert [10593]. see #4449
This commit is contained in:
		
							parent
							
								
									7aa4dd860d
								
							
						
					
					
						commit
						8babbb1de3
					
				
					 5 changed files with 33 additions and 64 deletions
				
			
		| 
						 | 
				
			
			@ -1132,16 +1132,9 @@ class Connection(ConnectionHandlers):
 | 
			
		|||
 | 
			
		||||
		# XEP-0172: user_nickname
 | 
			
		||||
		if user_nick:
 | 
			
		||||
			msg_iq.setTag('nick', namespace=common.xmpp.NS_NICK).setData(
 | 
			
		||||
			msg_iq.setTag('nick', namespace = common.xmpp.NS_NICK).setData(
 | 
			
		||||
				user_nick)
 | 
			
		||||
 | 
			
		||||
		# XEP-0107: User Mood
 | 
			
		||||
		if 'mood' in self.mood and not self.pep_supported:
 | 
			
		||||
			mood_iq = msg_iq.setTag('mood', namespace=common.xmpp.NS_MOOD)
 | 
			
		||||
			mood_iq.setTag(self.mood['mood'])
 | 
			
		||||
			if 'text' in self.mood and self.mood['text']:
 | 
			
		||||
				mood_iq.setTagData('text', self.mood['text'])
 | 
			
		||||
 | 
			
		||||
		# TODO: We might want to write a function so we don't need to
 | 
			
		||||
		#	reproduce that ugly if somewhere else.
 | 
			
		||||
		if resource:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1805,18 +1805,6 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
 | 
			
		|||
			session.control.conv_textview.hide_xep0184_warning(
 | 
			
		||||
				msg.getID())
 | 
			
		||||
 | 
			
		||||
		# Check mood in message
 | 
			
		||||
		if msg.getTag('mood', namespace=common.xmpp.NS_MOOD):
 | 
			
		||||
			mood_iq = msg.getTag('mood', namespace=common.xmpp.NS_MOOD)
 | 
			
		||||
			mood = None
 | 
			
		||||
			text = None
 | 
			
		||||
			for ch in mood_iq.getChildren():
 | 
			
		||||
				if ch.getName() != 'text':
 | 
			
		||||
					mood = ch.getName()
 | 
			
		||||
				else:
 | 
			
		||||
					text = ch.getData()
 | 
			
		||||
			pep.handle_mood(self.name, jid, mood=mood, text=text, retract=False)
 | 
			
		||||
 | 
			
		||||
		if encTag and self.USE_GPG:
 | 
			
		||||
			encmsg = encTag.getData()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -207,18 +207,10 @@ def user_mood(items, name, jid):
 | 
			
		|||
					text = ch.getData()
 | 
			
		||||
	if items.getTag('retract') is not None:
 | 
			
		||||
		retract = True
 | 
			
		||||
	if has_child or retract:
 | 
			
		||||
		handle_mood(name, jid, mood=mood, text=text, retract=retract)
 | 
			
		||||
 | 
			
		||||
def handle_mood(account, jid, mood=None, text=None, retract=False):
 | 
			
		||||
	if jid == gajim.get_jid_from_account(account):
 | 
			
		||||
		acc = gajim.connections[account]
 | 
			
		||||
		if retract:
 | 
			
		||||
			if 'mood' in acc.mood:
 | 
			
		||||
				del acc.mood['mood']
 | 
			
		||||
			if 'text' in acc.mood:
 | 
			
		||||
				del acc.mood['text']
 | 
			
		||||
		else:
 | 
			
		||||
	if jid == gajim.get_jid_from_account(name):
 | 
			
		||||
		acc = gajim.connections[name]
 | 
			
		||||
		if has_child:
 | 
			
		||||
			if 'mood' in acc.mood:
 | 
			
		||||
				del acc.mood['mood']
 | 
			
		||||
			if 'text' in acc.mood:
 | 
			
		||||
| 
						 | 
				
			
			@ -227,15 +219,15 @@ def handle_mood(account, jid, mood=None, text=None, retract=False):
 | 
			
		|||
				acc.mood['mood'] = mood
 | 
			
		||||
			if text is not None:
 | 
			
		||||
				acc.mood['text'] = text
 | 
			
		||||
		elif retract:
 | 
			
		||||
			if 'mood' in acc.mood:
 | 
			
		||||
				del acc.mood['mood']
 | 
			
		||||
			if 'text' in acc.mood:
 | 
			
		||||
				del acc.mood['text']
 | 
			
		||||
 | 
			
		||||
	(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
 | 
			
		||||
	for contact in gajim.contacts.get_contacts(account, user):
 | 
			
		||||
		if retract:
 | 
			
		||||
			if 'mood' in contact.mood:
 | 
			
		||||
				del contact.mood['mood']
 | 
			
		||||
			if 'text' in contact.mood:
 | 
			
		||||
				del contact.mood['text']
 | 
			
		||||
		else:
 | 
			
		||||
	for contact in gajim.contacts.get_contacts(name, user):
 | 
			
		||||
		if has_child:
 | 
			
		||||
			if 'mood' in contact.mood:
 | 
			
		||||
				del contact.mood['mood']
 | 
			
		||||
			if 'text' in contact.mood:
 | 
			
		||||
| 
						 | 
				
			
			@ -244,12 +236,17 @@ def handle_mood(account, jid, mood=None, text=None, retract=False):
 | 
			
		|||
				contact.mood['mood'] = mood
 | 
			
		||||
			if text is not None:
 | 
			
		||||
				contact.mood['text'] = text
 | 
			
		||||
		elif retract:
 | 
			
		||||
			if 'mood' in contact.mood:
 | 
			
		||||
				del contact.mood['mood']
 | 
			
		||||
			if 'text' in contact.mood:
 | 
			
		||||
				del contact.mood['text']
 | 
			
		||||
 | 
			
		||||
	if jid == gajim.get_jid_from_account(account):
 | 
			
		||||
		gajim.interface.roster.draw_account(account)
 | 
			
		||||
	gajim.interface.roster.draw_mood(user, account)
 | 
			
		||||
	ctrl = gajim.interface.msg_win_mgr.get_control(user, account)
 | 
			
		||||
	if ctrl and ctrl.type_id == 'chat':
 | 
			
		||||
	if jid == gajim.get_jid_from_account(name):
 | 
			
		||||
		gajim.interface.roster.draw_account(name)
 | 
			
		||||
	gajim.interface.roster.draw_mood(user, name)
 | 
			
		||||
	ctrl = gajim.interface.msg_win_mgr.get_control(user, name)
 | 
			
		||||
	if ctrl:
 | 
			
		||||
		ctrl.update_mood()
 | 
			
		||||
 | 
			
		||||
def user_tune(items, name, jid):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -528,19 +528,10 @@ class ChangeMoodDialog:
 | 
			
		|||
	def on_ok_button_clicked(self, widget):
 | 
			
		||||
		'''Return mood and messsage (None if no mood selected)'''
 | 
			
		||||
		message = self.entry.get_text().decode('utf-8')
 | 
			
		||||
		if gajim.connections[self.account].pep_supported:
 | 
			
		||||
			if self.mood is None:
 | 
			
		||||
				pep.user_retract_mood(self.account)
 | 
			
		||||
			else:
 | 
			
		||||
				pep.user_send_mood(self.account, self.mood, message)
 | 
			
		||||
		if self.mood is None:
 | 
			
		||||
			pep.user_retract_mood(self.account)
 | 
			
		||||
		else:
 | 
			
		||||
			# Do as we we sent through pep and got the answer
 | 
			
		||||
			our_jid = gajim.get_jid_from_account(self.account)
 | 
			
		||||
			if self.mood is None:
 | 
			
		||||
				pep.handle_mood(self.account, our_jid, retract=True)
 | 
			
		||||
			else:
 | 
			
		||||
				pep.handle_mood(self.account, our_jid, mood=self.mood,
 | 
			
		||||
					text=message)
 | 
			
		||||
			pep.user_send_mood(self.account, self.mood, message)
 | 
			
		||||
		self.window.destroy()
 | 
			
		||||
 | 
			
		||||
	def on_cancel_button_clicked(self, widget):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4857,11 +4857,11 @@ class RosterWindow:
 | 
			
		|||
			item.connect('activate', self.change_status, account, 'offline')
 | 
			
		||||
 | 
			
		||||
			pep_menuitem = xml.get_widget('pep_menuitem')
 | 
			
		||||
			pep_submenu = gtk.Menu()
 | 
			
		||||
			pep_menuitem.set_submenu(pep_submenu)
 | 
			
		||||
			if gajim.connections[account].pep_supported:
 | 
			
		||||
				have_tune = gajim.config.get_per('accounts', account,
 | 
			
		||||
					'publish_tune')
 | 
			
		||||
				pep_submenu = gtk.Menu()
 | 
			
		||||
				pep_menuitem.set_submenu(pep_submenu)
 | 
			
		||||
				item = gtk.CheckMenuItem(_('Publish Tune'))
 | 
			
		||||
				pep_submenu.append(item)
 | 
			
		||||
				if not dbus_support.supported:
 | 
			
		||||
| 
						 | 
				
			
			@ -4869,13 +4869,10 @@ class RosterWindow:
 | 
			
		|||
				else:
 | 
			
		||||
					item.set_active(have_tune)
 | 
			
		||||
					item.connect('toggled', self.on_publish_tune_toggled, account)
 | 
			
		||||
 | 
			
		||||
			item = gtk.CheckMenuItem(_('Mood'))
 | 
			
		||||
			pep_submenu.append(item)
 | 
			
		||||
			item.set_active(len(gajim.connections[account].mood) > 0)
 | 
			
		||||
			item.connect('activate', self.on_change_mood_activate, account)
 | 
			
		||||
 | 
			
		||||
			if gajim.connections[account].pep_supported:
 | 
			
		||||
				item = gtk.CheckMenuItem(_('Mood'))
 | 
			
		||||
				pep_submenu.append(item)
 | 
			
		||||
				item.set_active(len(gajim.connections[account].mood) > 0)
 | 
			
		||||
				item.connect('activate', self.on_change_mood_activate, account)
 | 
			
		||||
				item = gtk.CheckMenuItem(_('Activity'))
 | 
			
		||||
				pep_submenu.append(item)
 | 
			
		||||
				item.set_active(len(gajim.connections[account].activity) > 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -4892,6 +4889,9 @@ class RosterWindow:
 | 
			
		|||
					gtk.ICON_SIZE_MENU)
 | 
			
		||||
				pep_config.set_image(img)
 | 
			
		||||
 | 
			
		||||
			else:
 | 
			
		||||
				pep_menuitem.set_sensitive(False)
 | 
			
		||||
 | 
			
		||||
			if not gajim.connections[account].gmail_url:
 | 
			
		||||
				open_gmail_inbox_menuitem.set_no_show_all(True)
 | 
			
		||||
				open_gmail_inbox_menuitem.hide()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue