Remove custom status per contact feature
This commit is contained in:
parent
9f8492ae69
commit
9dbac0f098
6 changed files with 2 additions and 171 deletions
|
@ -242,23 +242,6 @@ class PrivacyLists(BaseModule):
|
||||||
def _build_invisible_rule(self):
|
def _build_invisible_rule(self):
|
||||||
node = nbxmpp.Node('list', {'name': 'invisible'})
|
node = nbxmpp.Node('list', {'name': 'invisible'})
|
||||||
iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVACY, payload=[node])
|
iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVACY, payload=[node])
|
||||||
if (self._account in app.interface.status_sent_to_groups and
|
|
||||||
app.interface.status_sent_to_groups[self._account]):
|
|
||||||
for group in app.interface.status_sent_to_groups[self._account]:
|
|
||||||
item = node.setTag('item', {'type': 'group',
|
|
||||||
'value': group,
|
|
||||||
'action': 'allow',
|
|
||||||
'order': '1'})
|
|
||||||
item.setTag('presence-out')
|
|
||||||
|
|
||||||
if (self._account in app.interface.status_sent_to_users and
|
|
||||||
app.interface.status_sent_to_users[self._account]):
|
|
||||||
for jid in app.interface.status_sent_to_users[self._account]:
|
|
||||||
item = node.setTag('item', {'type': 'jid',
|
|
||||||
'value': jid,
|
|
||||||
'action': 'allow',
|
|
||||||
'order': '2'})
|
|
||||||
item.setTag('presence-out')
|
|
||||||
|
|
||||||
item = node.setTag('item', {'action': 'deny', 'order': '3'})
|
item = node.setTag('item', {'action': 'deny', 'order': '3'})
|
||||||
item.setTag('presence-out')
|
item.setTag('presence-out')
|
||||||
|
|
|
@ -51,21 +51,6 @@
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkMenuItem" id="send_custom_status_menuitem">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">Send Cus_tom Status</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<child type="submenu">
|
|
||||||
<object class="GtkMenu" id="menu5">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkMenuItem" id="execute_command_menuitem">
|
<object class="GtkMenuItem" id="execute_command_menuitem">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -311,13 +311,6 @@ class Interface:
|
||||||
account = obj.conn.name
|
account = obj.conn.name
|
||||||
jid = obj.jid
|
jid = obj.jid
|
||||||
|
|
||||||
# unset custom status
|
|
||||||
if (obj.old_show == 0 and obj.new_show > 1) or \
|
|
||||||
(obj.old_show > 1 and obj.new_show == 0 and obj.conn.connected > 1):
|
|
||||||
if account in self.status_sent_to_users and \
|
|
||||||
jid in self.status_sent_to_users[account]:
|
|
||||||
del self.status_sent_to_users[account][jid]
|
|
||||||
|
|
||||||
if app.jid_is_transport(jid):
|
if app.jid_is_transport(jid):
|
||||||
# It must be an agent
|
# It must be an agent
|
||||||
|
|
||||||
|
@ -2272,8 +2265,6 @@ class Interface:
|
||||||
# This is the manager and factory of message windows set by the module
|
# This is the manager and factory of message windows set by the module
|
||||||
self.msg_win_mgr = None
|
self.msg_win_mgr = None
|
||||||
self.minimized_controls = {}
|
self.minimized_controls = {}
|
||||||
self.status_sent_to_users = {}
|
|
||||||
self.status_sent_to_groups = {}
|
|
||||||
self.pass_dialog = {}
|
self.pass_dialog = {}
|
||||||
self.db_error_dialog = None
|
self.db_error_dialog = None
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,6 @@ control=None, gc_contact=None, is_anonymous=True):
|
||||||
send_file_menuitem = xml.get_object('send_file_menuitem')
|
send_file_menuitem = xml.get_object('send_file_menuitem')
|
||||||
information_menuitem = xml.get_object('information_menuitem')
|
information_menuitem = xml.get_object('information_menuitem')
|
||||||
history_menuitem = xml.get_object('history_menuitem')
|
history_menuitem = xml.get_object('history_menuitem')
|
||||||
send_custom_status_menuitem = xml.get_object('send_custom_status_menuitem')
|
|
||||||
send_single_message_menuitem = xml.get_object('send_single_message_menuitem')
|
send_single_message_menuitem = xml.get_object('send_single_message_menuitem')
|
||||||
invite_menuitem = xml.get_object('invite_menuitem')
|
invite_menuitem = xml.get_object('invite_menuitem')
|
||||||
block_menuitem = xml.get_object('block_menuitem')
|
block_menuitem = xml.get_object('block_menuitem')
|
||||||
|
@ -327,7 +326,7 @@ control=None, gc_contact=None, is_anonymous=True):
|
||||||
|
|
||||||
# Zeroconf Account
|
# Zeroconf Account
|
||||||
if app.config.get_per('accounts', account, 'is_zeroconf'):
|
if app.config.get_per('accounts', account, 'is_zeroconf'):
|
||||||
for item in (send_custom_status_menuitem, send_single_message_menuitem,
|
for item in (send_single_message_menuitem,
|
||||||
invite_menuitem, block_menuitem, unblock_menuitem, ignore_menuitem,
|
invite_menuitem, block_menuitem, unblock_menuitem, ignore_menuitem,
|
||||||
unignore_menuitem, subscription_menuitem,
|
unignore_menuitem, subscription_menuitem,
|
||||||
manage_contact_menuitem, convert_to_gc_menuitem):
|
manage_contact_menuitem, convert_to_gc_menuitem):
|
||||||
|
@ -348,22 +347,6 @@ control=None, gc_contact=None, is_anonymous=True):
|
||||||
|
|
||||||
# normal account
|
# normal account
|
||||||
|
|
||||||
# send custom status icon
|
|
||||||
blocked = False
|
|
||||||
if helpers.jid_is_blocked(account, jid):
|
|
||||||
blocked = True
|
|
||||||
else:
|
|
||||||
for group in contact.get_shown_groups():
|
|
||||||
if helpers.group_is_blocked(account, group):
|
|
||||||
blocked = True
|
|
||||||
break
|
|
||||||
transport = app.get_transport_name_from_jid(jid, use_config_setting=False)
|
|
||||||
if transport and transport != 'jabber':
|
|
||||||
# Transport contact, send custom status unavailable
|
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
|
||||||
elif blocked:
|
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
|
||||||
|
|
||||||
if gc_contact:
|
if gc_contact:
|
||||||
if not gc_contact.jid:
|
if not gc_contact.jid:
|
||||||
# it's a pm and we don't know real JID
|
# it's a pm and we don't know real JID
|
||||||
|
@ -387,16 +370,6 @@ control=None, gc_contact=None, is_anonymous=True):
|
||||||
if app.account_is_disconnected(account):
|
if app.account_is_disconnected(account):
|
||||||
invite_menuitem.set_sensitive(False)
|
invite_menuitem.set_sensitive(False)
|
||||||
|
|
||||||
# One or several resource, we do the same for send_custom_status
|
|
||||||
status_menuitems = Gtk.Menu()
|
|
||||||
send_custom_status_menuitem.set_submenu(status_menuitems)
|
|
||||||
for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
|
|
||||||
# icon MUST be different instance for every item
|
|
||||||
status_menuitem = Gtk.MenuItem.new_with_label(helpers.get_uf_show(s))
|
|
||||||
status_menuitem.connect('activate', roster.on_send_custom_status,
|
|
||||||
[(contact, account)], s)
|
|
||||||
status_menuitems.append(status_menuitem)
|
|
||||||
|
|
||||||
send_single_message_menuitem.connect('activate',
|
send_single_message_menuitem.connect('activate',
|
||||||
roster.on_send_single_message_menuitem_activate, account, contact)
|
roster.on_send_single_message_menuitem_activate, account, contact)
|
||||||
|
|
||||||
|
@ -447,7 +420,7 @@ control=None, gc_contact=None, is_anonymous=True):
|
||||||
if app.account_is_disconnected(account):
|
if app.account_is_disconnected(account):
|
||||||
for widget in (send_single_message_menuitem, subscription_menuitem,
|
for widget in (send_single_message_menuitem, subscription_menuitem,
|
||||||
add_to_roster_menuitem, remove_from_roster_menuitem,
|
add_to_roster_menuitem, remove_from_roster_menuitem,
|
||||||
execute_command_menuitem, send_custom_status_menuitem):
|
execute_command_menuitem):
|
||||||
widget.set_sensitive(False)
|
widget.set_sensitive(False)
|
||||||
|
|
||||||
|
|
||||||
|
@ -507,24 +480,6 @@ def get_transport_menu(contact, account):
|
||||||
if helpers.jid_is_blocked(account, jid):
|
if helpers.jid_is_blocked(account, jid):
|
||||||
blocked = True
|
blocked = True
|
||||||
|
|
||||||
# Send Custom Status
|
|
||||||
send_custom_status_menuitem = Gtk.MenuItem.new_with_mnemonic(
|
|
||||||
_('Send Cus_tom Status'))
|
|
||||||
if blocked:
|
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
|
||||||
else:
|
|
||||||
status_menuitems = Gtk.Menu()
|
|
||||||
send_custom_status_menuitem.set_submenu(status_menuitems)
|
|
||||||
for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
|
|
||||||
status_menuitem = Gtk.MenuItem.new_with_label(helpers.get_uf_show(
|
|
||||||
s))
|
|
||||||
status_menuitem.connect('activate', roster.on_send_custom_status,
|
|
||||||
[(contact, account)], s)
|
|
||||||
status_menuitems.append(status_menuitem)
|
|
||||||
menu.append(send_custom_status_menuitem)
|
|
||||||
if app.account_is_disconnected(account):
|
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
|
||||||
|
|
||||||
item = Gtk.SeparatorMenuItem.new() # separator
|
item = Gtk.SeparatorMenuItem.new() # separator
|
||||||
menu.append(item)
|
menu.append(item)
|
||||||
|
|
||||||
|
|
|
@ -2113,10 +2113,6 @@ class RosterWindow:
|
||||||
app.SHOW_LIST.index('invisible')
|
app.SHOW_LIST.index('invisible')
|
||||||
app.connections[account].change_status(status, txt, auto)
|
app.connections[account].change_status(status, txt, auto)
|
||||||
|
|
||||||
if account in app.interface.status_sent_to_users:
|
|
||||||
app.interface.status_sent_to_users[account] = {}
|
|
||||||
if account in app.interface.status_sent_to_groups:
|
|
||||||
app.interface.status_sent_to_groups[account] = {}
|
|
||||||
for gc_control in app.interface.msg_win_mgr.get_controls(
|
for gc_control in app.interface.msg_win_mgr.get_controls(
|
||||||
message_control.TYPE_GC) + \
|
message_control.TYPE_GC) + \
|
||||||
list(app.interface.minimized_controls[account].values()):
|
list(app.interface.minimized_controls[account].values()):
|
||||||
|
@ -3362,67 +3358,6 @@ class RosterWindow:
|
||||||
'offline.') % jids
|
'offline.') % jids
|
||||||
ConfirmationDialog(pritext, sectext, on_response_ok=on_ok2)
|
ConfirmationDialog(pritext, sectext, on_response_ok=on_ok2)
|
||||||
|
|
||||||
def on_send_custom_status(self, widget, contact_list, show, group=None):
|
|
||||||
"""
|
|
||||||
Send custom status
|
|
||||||
"""
|
|
||||||
# contact_list has only one element except if group != None
|
|
||||||
def on_response(message, pep_dict):
|
|
||||||
if message is None: # None if user pressed Cancel
|
|
||||||
return
|
|
||||||
account_list = []
|
|
||||||
for (contact, account) in contact_list:
|
|
||||||
if account not in account_list:
|
|
||||||
account_list.append(account)
|
|
||||||
# 1. update status_sent_to_[groups|users] list
|
|
||||||
if group:
|
|
||||||
for account in account_list:
|
|
||||||
if account not in app.interface.status_sent_to_groups:
|
|
||||||
app.interface.status_sent_to_groups[account] = {}
|
|
||||||
app.interface.status_sent_to_groups[account][group] = show
|
|
||||||
else:
|
|
||||||
for (contact, account) in contact_list:
|
|
||||||
if account not in app.interface.status_sent_to_users:
|
|
||||||
app.interface.status_sent_to_users[account] = {}
|
|
||||||
app.interface.status_sent_to_users[account][contact.jid] \
|
|
||||||
= show
|
|
||||||
|
|
||||||
# 2. update privacy lists if main status is invisible
|
|
||||||
for account in account_list:
|
|
||||||
if app.SHOW_LIST[app.connections[account].connected] == \
|
|
||||||
'invisible':
|
|
||||||
con = app.connections[account]
|
|
||||||
con.get_module('PrivacyLists').set_invisible_rule()
|
|
||||||
|
|
||||||
# 3. send directed presence
|
|
||||||
for (contact, account) in contact_list:
|
|
||||||
our_jid = app.get_jid_from_account(account)
|
|
||||||
jid = contact.jid
|
|
||||||
if jid == our_jid:
|
|
||||||
jid += '/' + contact.resource
|
|
||||||
self.send_status(account, show, message, to=jid)
|
|
||||||
|
|
||||||
def send_it(is_checked=None):
|
|
||||||
if is_checked is not None: # dialog has been shown
|
|
||||||
if is_checked: # user does not want to be asked again
|
|
||||||
app.config.set('confirm_custom_status', 'no')
|
|
||||||
else:
|
|
||||||
app.config.set('confirm_custom_status', 'yes')
|
|
||||||
self.get_status_message(show, on_response, show_pep=False,
|
|
||||||
always_ask=True)
|
|
||||||
|
|
||||||
confirm_custom_status = app.config.get('confirm_custom_status')
|
|
||||||
if confirm_custom_status == 'no':
|
|
||||||
send_it()
|
|
||||||
return
|
|
||||||
pritext = _('You are about to send a custom status. Are you sure you '
|
|
||||||
'want to continue?')
|
|
||||||
sectext = _('This contact will temporarily see you as %(status)s, '
|
|
||||||
'but only until you change your status. Then they will see '
|
|
||||||
'your global status.') % {'status': show}
|
|
||||||
ConfirmationDialogCheck(pritext, sectext,
|
|
||||||
_('_Do not ask me again'), on_response_ok=send_it)
|
|
||||||
|
|
||||||
def on_status_combobox_changed(self, widget):
|
def on_status_combobox_changed(self, widget):
|
||||||
"""
|
"""
|
||||||
When we change our status via the combobox
|
When we change our status via the combobox
|
||||||
|
@ -5025,30 +4960,13 @@ class RosterWindow:
|
||||||
list_online, show_bookmarked=show_bookmarked)
|
list_online, show_bookmarked=show_bookmarked)
|
||||||
menu.append(invite_menuitem)
|
menu.append(invite_menuitem)
|
||||||
|
|
||||||
# Send Custom Status
|
|
||||||
send_custom_status_menuitem = Gtk.MenuItem.new_with_mnemonic(
|
|
||||||
_('Send Cus_tom Status'))
|
|
||||||
if helpers.group_is_blocked(account, group):
|
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
|
||||||
status_menuitems = Gtk.Menu()
|
|
||||||
send_custom_status_menuitem.set_submenu(status_menuitems)
|
|
||||||
for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
|
|
||||||
status_menuitem = Gtk.MenuItem.new_with_label(
|
|
||||||
helpers.get_uf_show(s))
|
|
||||||
status_menuitem.connect('activate', self.on_send_custom_status,
|
|
||||||
list_, s, group)
|
|
||||||
status_menuitems.append(status_menuitem)
|
|
||||||
menu.append(send_custom_status_menuitem)
|
|
||||||
|
|
||||||
# there is no singlemessage and custom status for zeroconf
|
# there is no singlemessage and custom status for zeroconf
|
||||||
if app.config.get_per('accounts', account, 'is_zeroconf'):
|
if app.config.get_per('accounts', account, 'is_zeroconf'):
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
|
||||||
send_group_message_item.set_sensitive(False)
|
send_group_message_item.set_sensitive(False)
|
||||||
|
|
||||||
if app.connections[account].connected < 2:
|
if app.connections[account].connected < 2:
|
||||||
send_group_message_item.set_sensitive(False)
|
send_group_message_item.set_sensitive(False)
|
||||||
invite_menuitem.set_sensitive(False)
|
invite_menuitem.set_sensitive(False)
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
|
||||||
|
|
||||||
if not group in helpers.special_groups:
|
if not group in helpers.special_groups:
|
||||||
item = Gtk.SeparatorMenuItem.new() # separator
|
item = Gtk.SeparatorMenuItem.new() # separator
|
||||||
|
|
|
@ -104,7 +104,6 @@ class MockInterface(Mock):
|
||||||
|
|
||||||
self.instances = {}
|
self.instances = {}
|
||||||
self.minimized_controls = {}
|
self.minimized_controls = {}
|
||||||
self.status_sent_to_users = Mock()
|
|
||||||
|
|
||||||
|
|
||||||
class MockLogger(Mock):
|
class MockLogger(Mock):
|
||||||
|
|
Loading…
Add table
Reference in a new issue