diff --git a/src/common/connection.py b/src/common/connection.py index 2b5a5990b40b5eaa495bdc0c791d8eceb3be623d..6269489166e14b4667b7ca340530c4ca9c75defc 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -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: diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 652f2a411a984b94691c0b060f74d3df94fc7b3b..1aa57e95dfb40dfb0bfbc27d87b1092777d086bf 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -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() diff --git a/src/common/pep.py b/src/common/pep.py index 49698454bfa69835c14074162018aedceacd5860..7fdba4feeac0929f7231d88a80faaad806c2127b 100644 --- a/src/common/pep.py +++ b/src/common/pep.py @@ -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): diff --git a/src/dialogs.py b/src/dialogs.py index c34c30f46fba15d9c4dae0ba3457e6d030580bef..485ba838b7d40d2f17750e31577a594017ee168d 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -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): diff --git a/src/roster_window.py b/src/roster_window.py index 6d96919f16024e7a2653d2bc9c037d957d437294..9c958998d22939b24739ba1354a4780e71d5f4d1 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -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()