Commit 46a00a6a authored by Philipp Hörist's avatar Philipp Hörist

Remove invisible feature

- This feature stems from the single device age
- Depends on deprecated Privacy Lists (XEP-0016)
- No support in other clients makes it in the current multiple device world useless
- Hard to maintain, prevents us to use even basic features like MUC because it would leak presence
parent 4f4624e0
......@@ -437,8 +437,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
def _nec_our_status(self, obj):
if self.account != obj.conn.name:
return
if obj.show == 'offline' or (obj.show == 'invisible' and \
obj.conn.is_zeroconf):
if obj.show == 'offline':
self.got_disconnected()
else:
# Other code rejoins all GCs, so we don't do it here
......
......@@ -133,7 +133,7 @@ status_before_autoaway = {} # type: Dict[str, str]
proxy65_manager = None
SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
'invisible', 'error']
'error']
# zeroconf account name
ZEROCONF_ACC_NAME = 'Local'
......@@ -492,9 +492,6 @@ def account_is_connected(account):
# 0 is offline, 1 is connecting
return connections[account].state.is_connected
def is_invisible(account):
return SHOW_LIST[connections[account].connected] == 'invisible'
def account_is_disconnected(account):
return not account_is_connected(account)
......@@ -652,7 +649,7 @@ def get_priority(account, show):
if not show:
show = 'online'
if show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible') and \
if show in ('online', 'chat', 'away', 'xa', 'dnd') and \
config.get_per('accounts', account, 'adjust_priority_with_status'):
prio = config.get_per('accounts', account, 'autopriority_' + show)
else:
......
......@@ -294,9 +294,8 @@ class Config:
'autopriority_away': [opt_int, 40],
'autopriority_xa': [opt_int, 30],
'autopriority_dnd': [opt_int, 20],
'autopriority_invisible': [opt_int, 10],
'autoconnect': [opt_bool, False, '', True],
'autoconnect_as': [opt_str, 'online', _('Status to be used automatically when connecting. Can be \'online\', \'chat\', \'away\', \'xa\', \'dnd\' or \'invisible\'. NOTE: This option is used only if \'restore_last_status\' is disabled.'), True],
'autoconnect_as': [opt_str, 'online', _('Status to be used automatically when connecting. Can be \'online\', \'chat\', \'away\', \'xa\' or \'dnd\'. NOTE: This option is used only if \'restore_last_status\' is disabled.'), True],
'restore_last_status': [opt_bool, False, _('If enabled, the last status will be restored.')],
'autoauth': [opt_bool, False, _('If enabled, contacts requesting authorization will be accepted automatically.')],
'active': [opt_bool, True, _('If disabled, this account will be disabled and will not appear in the contact list window.'), True],
......@@ -428,7 +427,6 @@ class Config:
'_last_away': ['', '', '', '', '', ''],
'_last_xa': ['', '', '', '', '', ''],
'_last_dnd': ['', '', '', '', '', ''],
'_last_invisible': ['', '', '', '', '', ''],
'_last_offline': ['', '', '', '', '', ''],
}
......@@ -438,7 +436,6 @@ class Config:
'away': [False, _('Be right back.')],
'xa': [False, _('I\'m not available.')],
'dnd': [False, _('Do not disturb.')],
'invisible': [False, _('Bye!')],
'offline': [False, _('Bye!')],
}
......
......@@ -212,9 +212,6 @@ class CommonConnection:
if not msg:
msg = ''
if show != 'invisible':
# We save it only when privacy list is accepted
self.status = msg
if show != 'offline' and self._state.is_disconnected:
# set old_show to requested 'show' in case we need to
# recconect before we auth to server
......@@ -235,12 +232,9 @@ class CommonConnection:
return
if show != 'offline' and self._state.is_connected:
if show == 'invisible':
self._change_to_invisible(msg)
return
if show not in ['offline', 'online', 'chat', 'away', 'xa', 'dnd']:
return -1
was_invisible = self.connected == app.SHOW_LIST.index('invisible')
self.connected = app.SHOW_LIST.index(show)
idle_time = None
if auto:
......@@ -248,8 +242,7 @@ class CommonConnection:
idle_sec = idle.Monitor.get_idle_sec()
idle_time = time.strftime('%Y-%m-%dT%H:%M:%SZ',
time.gmtime(time.time() - idle_sec))
if was_invisible:
self._change_from_invisible()
self._update_status(show, msg, idle_time=idle_time)
......@@ -1152,66 +1145,6 @@ class Connection(CommonConnection, ConnectionHandlers):
if self.connection:
self.connection.send(' ')
def send_invisible_presence(self, msg, initial=False):
if not self._state.is_connected:
return
if not self.get_module('PrivacyLists').supported:
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
show=app.SHOW_LIST[self.connected]))
app.nec.push_incoming_event(InformationEvent(
None, dialog_name='invisibility-not-supported', args=self.name))
return
# If we are already connected, and privacy rules are supported, send
# offline presence first as it's required by XEP-0126
if self.get_module('PrivacyLists').supported:
self.get_module('Bytestream').remove_all_transfers()
self.get_module('Presence').send_presence(
typ='unavailable',
status=msg,
caps=False)
# try to set the privacy rule
self.get_module('PrivacyLists').set_invisible_rule(
callback=self._continue_invisible,
msg=msg,
initial=initial)
def _continue_invisible(self, _nbxmpp_client, iq_obj, msg, signed, initial):
if iq_obj.getType() == 'error': # server doesn't support privacy lists
return
# active the privacy rule
self.get_module('PrivacyLists').set_active_list('invisible')
self.connected = app.SHOW_LIST.index('invisible')
self.status = msg
priority = app.get_priority(self.name, 'invisible')
self.get_module('Presence').send_presence(
priority=priority,
status=msg)
self.priority = priority
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
show='invisible'))
if initial:
if not self.avatar_conversion:
# ask our VCard
self.get_module('VCardTemp').request_vcard()
# Get bookmarks
self.get_module('Bookmarks').request_bookmarks()
# Enable Software Version
self.get_module('SoftwareVersion').set_enabled(True)
# Get annotations
self.get_module('Annotations').request_annotations()
# Blocking
self.get_module('Blocking').get_blocking_list()
# Inform GUI we just signed in
app.nec.push_incoming_event(NetworkEvent('signed-in', conn=self))
def connect_and_auth(self):
self.on_connect_success = self._connect_success
self.on_connect_failure = self._connect_failure
......@@ -1274,9 +1207,6 @@ class Connection(CommonConnection, ConnectionHandlers):
self.connected = app.SHOW_LIST.index(show)
sshow = helpers.get_xmpp_show(show)
# send our presence
if show == 'invisible':
self.send_invisible_presence(msg, True)
return
if show not in ['offline', 'online', 'chat', 'away', 'xa', 'dnd']:
return
priority = app.get_priority(self.name, sshow)
......@@ -1305,13 +1235,6 @@ class Connection(CommonConnection, ConnectionHandlers):
modules.send_stored_publish(self.name)
self.continue_connect_info = None
def _change_to_invisible(self, msg):
self.send_invisible_presence(msg)
def _change_from_invisible(self):
if self.get_module('PrivacyLists').supported:
self.get_module('PrivacyLists').set_active_list(None)
def _update_status(self, show, msg, idle_time=None):
xmpp_show = helpers.get_xmpp_show(show)
priority = app.get_priority(self.name, xmpp_show)
......
......@@ -897,7 +897,7 @@ class MetacontactManager():
Data is {'jid': jid, 'account': account, 'order': order} order is
optional
"""
show_list = ['not in roster', 'error', 'offline', 'invisible', 'dnd',
show_list = ['not in roster', 'error', 'offline', 'dnd',
'xa', 'away', 'chat', 'online', 'requested', 'message']
jid = data['jid']
......
......@@ -312,11 +312,6 @@ def get_uf_show(show, use_mnemonic=False):
uf_show = _('_Offline')
else:
uf_show = _('Offline')
elif show == 'invisible':
if use_mnemonic:
uf_show = _('_Invisible')
else:
uf_show = _('Invisible')
elif show == 'not in roster':
uf_show = _('Not in contact list')
elif show == 'requested':
......@@ -326,7 +321,7 @@ def get_uf_show(show, use_mnemonic=False):
return uf_show
def get_css_show_color(show):
if show in ('online', 'chat', 'invisible'):
if show in ('online', 'chat'):
return 'status-online'
if show in ('offline', 'not in roster', 'requested'):
return None
......@@ -1057,9 +1052,8 @@ def update_optional_features(account=None):
return
connected = app.connections[account_].connected
if app.SHOW_LIST[connected] != 'invisible':
app.connections[account_].change_status(
app.SHOW_LIST[connected], app.connections[account_].status)
app.connections[account_].change_status(
app.SHOW_LIST[connected], app.connections[account_].status)
def jid_is_blocked(account, jid):
con = app.connections[account]
......
......@@ -278,9 +278,6 @@ class Bookmarks(BaseModule):
def auto_join_bookmarks(self,
bookmarks: Optional[List[Any]] = None) -> None:
if app.is_invisible(self._account):
return
if bookmarks is None:
bookmarks = self._bookmarks.values()
......
......@@ -40,9 +40,6 @@ class EntityTime(BaseModule):
def request_entity_time(self, jid, resource):
if not app.account_is_connected(self._account):
return
# If we are invisible, do not request
if app.is_invisible(self._account):
return
if resource:
jid += '/' + resource
......
......@@ -314,7 +314,7 @@ class MUC(BaseModule):
def _send_presence(self, muc_data, auto):
show = app.SHOW_LIST[self._con.connected]
if show in ('invisible', 'offline'):
if show == 'offline':
# FIXME: Check if this
return
......
......@@ -140,7 +140,7 @@ class Presence(BaseModule):
resource = properties.jid.getResource()
status_strings = ['offline', 'error', 'online', 'chat', 'away',
'xa', 'dnd', 'invisible']
'xa', 'dnd']
event.new_show = status_strings.index(event.show)
......
......@@ -239,23 +239,6 @@ class PrivacyLists(BaseModule):
if not nbxmpp.isResultNode(stanza):
self._log.warning('Operation failed: %s', stanza.getError())
@staticmethod
def _build_invisible_rule():
node = nbxmpp.Node('list', {'name': 'invisible'})
iq = nbxmpp.Iq('set', nbxmpp.NS_PRIVACY, payload=[node])
item = node.setTag('item', {'action': 'deny', 'order': '3'})
item.setTag('presence-out')
return iq
def set_invisible_rule(self, callback=None, **kwargs):
self._log.info('Update invisible list')
iq = self._build_invisible_rule()
if callback is None:
callback = self._default_result_handler
self._con.connection.SendAndCallForResponse(
iq, callback, kwargs)
def _get_max_blocked_list_order(self):
max_order = 0
for rule in self.blocked_list:
......@@ -363,8 +346,7 @@ class PrivacyLists(BaseModule):
show = app.SHOW_LIST[self._con.connected]
else: # accounts merged
show = helpers.get_global_show()
if show == 'invisible':
return
for contact in contact_list:
self._con.get_module('Presence').send_presence(
contact.jid, show=show, status=self._con.status)
......@@ -425,8 +407,7 @@ class PrivacyLists(BaseModule):
show = app.SHOW_LIST[self._con.connected]
else: # accounts merged
show = helpers.get_global_show()
if show == 'invisible':
return
for contact in contact_list:
self._con.get_module('Presence').send_presence(
contact.jid, show=show, status=self._con.status)
......
......@@ -145,7 +145,7 @@ class VCardTemp(BaseModule):
if stanza.getType() == 'result':
current_sha = app.config.get_per(
'accounts', self._account, 'avatar_sha')
if (current_sha != sha and not app.is_invisible(self._account)):
if current_sha != sha:
if not app.account_is_connected(self._account):
return
app.config.set_per(
......
......@@ -35,8 +35,7 @@ from gajim.common.modules.misc import parse_xhtml
log = logging.getLogger('gajim.c.z.connection_handlers_zeroconf')
STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
'invisible']
STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd']
class ConnectionHandlersZeroconf(connection_handlers.ConnectionHandlersBase):
......
......@@ -189,7 +189,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
jid = event.jid
status_strings = ['offline', 'error', 'online', 'chat', 'away',
'xa', 'dnd', 'invisible']
'xa', 'dnd']
event.new_show = status_strings.index(event.show)
......@@ -342,8 +342,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
self.disconnect()
if not self.connect(self.status, last_msg):
return
if self.status != 'invisible':
self.connection.announce()
self.connection.announce()
else:
self.reannounce()
......@@ -352,10 +351,8 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
check = True
if not self.connect(show, msg):
return
if show != 'invisible':
check = self.connection.announce()
else:
self.connected = STATUS_LIST.index(show)
check = self.connection.announce()
# stay offline when zeroconf does something wrong
if check:
......@@ -374,22 +371,6 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
title=_('Could not change status of account "%s"') % self.name,
msg=_('Please check if avahi-daemon is running.')))
def _change_to_invisible(self, msg):
if self.connection.remove_announce():
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
show='invisible'))
else:
# show notification that avahi or system bus is down
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
show='offline'))
self.status = 'offline'
app.nec.push_incoming_event(ConnectionLostEvent(None, conn=self,
title=_('Could not change status of account "%s"') % self.name,
msg=_('Please check if avahi-daemon is running.')))
def _change_from_invisible(self):
self.connection.announce()
def _update_status(self, show, msg, idle_time=None):
if self.connection.set_show_msg(show, msg):
app.nec.push_incoming_event(OurShowEvent(None, conn=self,
......
......@@ -1085,7 +1085,7 @@
</child>
<child>
<object class="GtkCheckButton" id="auto_popup_away_checkbutton">
<property name="label" translatable="yes">Allow popups/notifications when I'm _away, not available, busy, or invisible</property>
<property name="label" translatable="yes">Allow popups/notifications when I'm _away, not available or busy</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
......
......@@ -45,12 +45,6 @@
<col id="2">dnd</col>
<col id="3">True</col>
</row>
<row>
<col id="0">invisible</col>
<col id="1">invisible</col>
<col id="2">invisible</col>
<col id="3">True</col>
</row>
<row>
<col id="0">SEPARATOR</col>
<col id="1">None</col>
......
......@@ -49,11 +49,6 @@ messages = {
_('The form is not filled correctly.'),
ErrorDialog),
'join-while-invisible': Message(
_('Invisible'),
_('You cannot join a group chat while being invisible.'),
ErrorDialog),
'not-connected-while-sending': Message(
_('No Connection Available'),
_('Your message can not be sent until you are connected.'),
......
......@@ -96,8 +96,8 @@ class GajimRemote:
'change_status': [
_('Changes the status of account(s)'),
[
#offline, online, chat, away, xa, dnd, invisible should not be translated
(Q_('?CLI:status'), _('one of: offline, online, chat, away, xa, dnd, invisible. If not set, use account\'s previous status'), False),
#offline, online, chat, away, xa, dnd should not be translated
(Q_('?CLI:status'), _('one of: offline, online, chat, away, xa, dnd. If not set, use account\'s previous status'), False),
(Q_('?CLI:message'), _('status message'), False),
(Q_('?CLI:account'), _('change status of account "account". '
'If not specified, try to change status of all accounts that have '
......
......@@ -188,7 +188,7 @@ class StatusIcon:
self.popup_menus.append(sub_menu)
status_menuitem.set_submenu(sub_menu)
for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
for show in ('online', 'chat', 'away', 'xa', 'dnd'):
uf_show = helpers.get_uf_show(show, use_mnemonic=True)
item = Gtk.MenuItem.new_with_mnemonic(uf_show)
sub_menu.append(item)
......@@ -356,7 +356,7 @@ class StatusIcon:
def _on_show(_widget, show):
# we all add some fake (we cannot select those nor have them as show)
# but this helps to align with roster's status_combobox index positions
status = ['online', 'chat', 'away', 'xa', 'dnd', 'invisible',
status = ['online', 'chat', 'away', 'xa', 'dnd',
'SEPARATOR', 'CHANGE_STATUS_MSG_MENUITEM', 'SEPARATOR',
'offline']
index = status.index(show)
......
......@@ -846,9 +846,6 @@ class Interface:
if obj.conn.get_module('MAM').available:
obj.conn.get_module('MAM').request_archive_on_signin()
# We cannot join rooms if we are invisible
if app.is_invisible(account):
return
# send currently played music
if (pep_supported and sys.platform not in ('win32', 'darwin') and
app.config.get_per('accounts', account, 'publish_tune')):
......@@ -1483,11 +1480,6 @@ class Interface:
self.join_groupchat(account, room_jid, **kwargs)
def join_groupchat(self, account, room_jid, password=None, minimized=False):
if app.is_invisible(account):
ErrorDialog(
_('You cannot join a group chat while you are invisible'))
return
if not app.account_is_connected(account):
return
......@@ -1613,7 +1605,7 @@ class Interface:
win.set_active_tab(ctrl)
if app.connections[account].is_zeroconf and \
app.connections[account].status in ('offline', 'invisible'):
app.connections[account].status == 'offline':
ctrl = win.get_control(fjid, account)
if ctrl:
ctrl.got_disconnected()
......
......@@ -632,8 +632,7 @@ class GajimRemote(Server):
change_status(status, message, account). Account is optional - if not
specified status is changed for all accounts
"""
if status not in ('offline', 'online', 'chat', 'away', 'xa', 'dnd',
'invisible'):
if status not in ('offline', 'online', 'chat', 'away', 'xa', 'dnd'):
status = ''
if account:
if not status:
......
......@@ -1751,7 +1751,7 @@ class RosterWindow:
if type1 == 'contact' and type2 == 'contact' and \
app.config.get('sort_by_show_in_roster'):
cshow = {'chat':0, 'online': 1, 'away': 2, 'xa': 3, 'dnd': 4,
'invisible': 5, 'offline': 6, 'not in roster': 7, 'error': 8}
'offline': 6, 'not in roster': 7, 'error': 8}
s = self.get_show(lcontact1)
show1 = cshow.get(s, 9)
s = self.get_show(lcontact2)
......@@ -2110,15 +2110,11 @@ class RosterWindow:
status == 'offline':
app.sleeper_state[account] = 'off'
if status in ('invisible', 'offline'):
if status == 'offline':
self.delete_pep(app.get_jid_from_account(account), account)
was_invisible = app.is_invisible(account)
app.connections[account].change_status(status, txt, auto)
app.connections[account].get_module('MUC').update_presence(auto)
if was_invisible and status != 'offline':
# We come back from invisible, join bookmarks
con = app.connections[account]
con.get_module('Bookmarks').auto_join_bookmarks()
def chg_contact_status(self, contact, show, status, account):
"""
......@@ -2232,7 +2228,7 @@ class RosterWindow:
on_response(msg, empty_pep)
return
if not always_ask and ((show == 'online' and not app.config.get(
'ask_online_status')) or (show in ('offline', 'invisible') and not \
'ask_online_status')) or (show == 'offline' and not \
app.config.get('ask_offline_status'))):
on_response('', empty_pep)
return
......@@ -2241,35 +2237,18 @@ class RosterWindow:
dlg.dialog.present() # show it on current workspace
def change_status(self, widget, account, status):
def _change(account, status):
def on_response(message, pep_dict):
if message is None:
# user pressed Cancel to change status message dialog
return
self.send_status(account, status, message)
self.send_pep(account, pep_dict)
self.get_status_message(status, on_response)
if status == 'invisible' and self.connected_rooms(account):
NewConfirmationDialog(
_('Disconnect for Invisibility'),
_('You are participating in one or more group chats'),
_('Changing your status to invisible will result in '
'you leaving those group chats.\n'
'Are you sure you want to go invisible?'),
[DialogButton.make('Cancel'),
DialogButton.make('Remove',
text=_('_Disconnect'),
callback=_change,
args=[account,
status])]).show()
else:
_change(account, status)
def on_response(message, pep_dict):
if message is None:
# user pressed Cancel to change status message dialog
return
self.send_status(account, status, message)
self.send_pep(account, pep_dict)
self.get_status_message(status, on_response)
def update_status_combobox(self):
# table to change index in connection.connected to index in combobox
table = {'offline':9, 'connecting':9, 'online':0, 'chat':1, 'away':2,
'xa':3, 'dnd':4, 'invisible':5}
table = {'offline':8, 'connecting':8, 'online':0, 'chat':1, 'away':2,
'xa':3, 'dnd':4}
liststore = self.status_combobox.get_model()
# we check if there are more options in the combobox that it should
......@@ -2592,7 +2571,7 @@ class RosterWindow:
def _nec_our_show(self, obj):
model = self.status_combobox.get_model()
iter_ = model.get_iter_from_string('7')
iter_ = model.get_iter_from_string('6')
if obj.show == 'offline':
# sensitivity for this menuitem
if app.get_number_of_connected_accounts() == 0:
......@@ -3427,7 +3406,6 @@ class RosterWindow:
# after user chooses "Change status message" menuitem
# we can return to this show
self.previous_status_combobox_active = active
connected_accounts = app.get_number_of_connected_accounts()
def on_continue(message, pep_dict):
if message is None:
......@@ -3455,38 +3433,6 @@ class RosterWindow:
self.send_pep(account, pep_dict)
self.update_status_combobox()
if status == 'invisible':
bug_user = False
for account in accounts:
if connected_accounts < 1 or app.account_is_connected(
account):
if not app.config.get_per('accounts', account,
'sync_with_global_status'):
continue
# We're going to change our status to invisible
if self.connected_rooms(account):
bug_user = True
break
if bug_user:
def on_ok():
self.get_status_message(status, on_continue, show_pep=False)
def on_cancel():
self.update_status_combobox()
NewConfirmationDialog(