add show_self_contact ACE option to show / hide self_contact row as we want. Fixes #4796

This commit is contained in:
Yann Leboulanger 2009-10-16 19:51:29 +02:00
parent f8654b95b4
commit f2aee9e7cb
4 changed files with 36 additions and 15 deletions

View File

@ -271,6 +271,7 @@ class Config:
'uri_schemes': [opt_str, 'aaa aaas acap cap cid crid data dav dict dns fax file ftp go gopher h323 http https icap im imap info ipp iris iris.beep iris.xpc iris.xpcs iris.lwz ldap mid modem msrp msrps mtqp mupdate news nfs nntp opaquelocktoken pop pres rtsp service shttp sip sips snmp soap.beep soap.beeps tag tel telnet tftp thismessage tip tv urn vemmi xmlrpc.beep xmlrpc.beeps z39.50r z39.50s about cvs daap ed2k feed fish git iax2 irc ircs ldaps magnet mms rsync ssh svn sftp smb webcal', _('Valid uri schemes. Only schemes in this list will be accepted as "real" uri. (mailto and xmpp are handled separately)'), True],
'ask_offline_status_on_connection': [ opt_bool, False, _('Ask offline status message to all offline contacts when connection to an accoutn is established. WARNING: This causes a lot of requests to be sent!') ],
'shell_like_completion': [ opt_bool, False, _('If True, completion in groupchats will be like a shell auto-completion')],
'show_self_contact': [opt_str, 'when_other_resource', _('When is self contact row displayed. Can be "always", "when_other_resource" or "never"'), True],
}
__options_per_key = {

View File

@ -2641,7 +2641,8 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
gajim.logger.replace_roster(self.name, roster_version, roster)
if received_from_server:
for contact in gajim.contacts.iter_contacts(self.name):
if not contact.is_groupchat() and contact.jid not in roster:
if not contact.is_groupchat() and contact.jid not in roster and \
contact.jid != gajim.get_jid_from_account(self.name):
self.dispatch('ROSTER_INFO', (contact.jid, None, None, None,
()))
for jid in roster:

View File

@ -603,10 +603,10 @@ class Interface:
def unblock_signed_in_notifications(self, account):
gajim.block_signed_in_notifications[account] = False
def handle_event_status(self, account, status): # OUR status
#('STATUS', account, status)
def handle_event_status(self, account, show): # OUR status
#('STATUS', account, show)
model = self.roster.status_combobox.get_model()
if status in ('offline', 'error'):
if show in ('offline', 'error'):
for name in self.instances[account]['online_dialog'].keys():
# .keys() is needed to not have a dictionary length changed during
# iteration error
@ -618,7 +618,7 @@ class Interface:
# .keys() is needed because dict changes during loop
for account in self.pass_dialog.keys():
self.pass_dialog[account].window.destroy()
if status == 'offline':
if show == 'offline':
# sensitivity for this menuitem
if gajim.get_number_of_connected_accounts() == 0:
model[self.roster.status_message_menuitem_iter][3] = False
@ -639,7 +639,7 @@ class Interface:
ctrls += self.minimized_controls[account].values()
for ctrl in ctrls:
if ctrl.account == account:
if status == 'offline' or (status == 'invisible' and \
if show == 'offline' or (show == 'invisible' and \
gajim.connections[account].is_zeroconf):
ctrl.got_disconnected()
else:
@ -649,12 +649,12 @@ class Interface:
if ctrl.parent_win:
ctrl.parent_win.redraw_tab(ctrl)
self.roster.on_status_changed(account, status)
if account in self.show_vcard_when_connect and status not in ('offline',
self.roster.on_status_changed(account, show)
if account in self.show_vcard_when_connect and show not in ('offline',
'error'):
self.edit_own_details(account)
if self.remote_ctrl:
self.remote_ctrl.raise_signal('AccountPresence', (status, account))
self.remote_ctrl.raise_signal('AccountPresence', (show, account))
def edit_own_details(self, account):
jid = gajim.get_jid_from_account(account)

View File

@ -676,7 +676,12 @@ class RosterWindow:
return
if jid == gajim.get_jid_from_account(account):
if contact.resource != gajim.connections[account].server_resource:
show_self_contact = gajim.config.get('show_self_contact')
if show_self_contact == 'never':
return
if (contact.resource != gajim.connections[account].server_resource and\
show_self_contact == 'when_other_resource') or show_self_contact == \
'always':
return self._add_self_contact(account)
return
@ -1733,6 +1738,12 @@ class RosterWindow:
gajim.contacts.add_account(account)
if account not in gajim.groups:
gajim.groups[account] = {}
if gajim.config.get('show_self_contact') == 'always':
self_jid = gajim.get_jid_from_account(account)
if gajim.connections[account].server_resource:
self_jid += '/' + gajim.connections[account].server_resource
array[self_jid] = {'name': gajim.nicks[account],
'groups': ['self_contact'], 'subscription': 'both', 'ask': 'none'}
# .keys() is needed
for jid in array.keys():
# Remove the contact in roster. It might has changed
@ -2058,9 +2069,10 @@ class RosterWindow:
elif contact.jid == gajim.get_jid_from_account(account) and \
show in ('offline', 'error'):
# SelfContact went offline. Remove him when last pending
# message was read
self.remove_contact(contact.jid, account, backend=True)
if gajim.config.get('show_self_contact') != 'never':
# SelfContact went offline. Remove him when last pending
# message was read
self.remove_contact(contact.jid, account, backend=True)
uf_show = helpers.get_uf_show(show)
@ -2087,13 +2099,20 @@ class RosterWindow:
self.adjust_and_draw_contact_context(contact.jid, account)
def on_status_changed(self, account, status):
def on_status_changed(self, account, show):
'''the core tells us that our status has changed'''
if account not in gajim.contacts.get_accounts():
return
child_iterA = self._get_account_iter(account, self.model)
if gajim.config.get('show_self_contact') == 'always':
self_resource = gajim.connections[account].server_resource
self_contact = gajim.contacts.get_contact(account,
gajim.get_jid_from_account(account), resource=self_resource)
if self_contact:
status = gajim.connections[account].status
self.chg_contact_status(self_contact, show, status, account)
self.set_account_status_icon(account)
if status == 'offline':
if show == 'offline':
if self.quit_on_next_offline > -1:
# we want to quit, we are waiting for all accounts to be offline
self.quit_on_next_offline -= 1