From 4bb29675a8fdf2cb529c941eb89b8831a9c0bbcc Mon Sep 17 00:00:00 2001 From: Stephan Erb Date: Wed, 23 Jan 2008 16:10:28 +0000 Subject: [PATCH] padlock icon in merged accounts mode: show when all connected accounts are connected securely, don't show it when one is not secured, do no care about offline accounts. --- src/common/gajim.py | 5 +++-- src/gajim.py | 1 + src/roster_window.py | 31 +++++-------------------------- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/common/gajim.py b/src/common/gajim.py index 9c8f9752a..0e11a9ee4 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -268,13 +268,14 @@ def account_is_disconnected(account): def get_number_of_securely_connected_accounts(): '''returns the number of the accounts that are SSL/TLS connected''' num_of_secured = 0 - for account in connections: + for account in connections.keys(): if account_is_securely_connected(account): num_of_secured += 1 return num_of_secured def account_is_securely_connected(account): - if account in con_types and con_types[account] in ('tls', 'ssl'): + if account_is_connected(account) and \ + account in con_types and con_types[account] in ('tls', 'ssl'): return True else: return False diff --git a/src/gajim.py b/src/gajim.py index d40fa9506..dde618e65 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1876,6 +1876,7 @@ class Interface: # block signed in notifications for 30 seconds gajim.block_signed_in_notifications[account] = True self.roster.set_actions_menu_needs_rebuild() + self.roster.draw_account(account) if self.sleeper.getState() != common.sleepy.STATE_UNKNOWN and \ gajim.connections[account].connected in (2, 3): # we go online or free for chat, so we activate auto status diff --git a/src/roster_window.py b/src/roster_window.py index c3981e77b..a35b40eed 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -211,34 +211,14 @@ class RosterWindow: def draw_account(self, account): model = self.tree.get_model() iter = self.get_account_iter(account) - if self.regroup: - accounts = gajim.connections.keys() - else: - accounts = [account] - num_of_accounts = len(accounts) + + num_of_accounts = gajim.get_number_of_connected_accounts() num_of_secured = gajim.get_number_of_securely_connected_accounts() - if num_of_secured and gajim.con_types.has_key(account) and \ - gajim.con_types[account] in ('tls', 'ssl'): + + if gajim.account_is_securely_connected(account) and not self.regroup or \ + self.regroup and num_of_secured and num_of_secured == num_of_accounts: tls_pixbuf = self.window.render_icon(gtk.STOCK_DIALOG_AUTHENTICATION, gtk.ICON_SIZE_MENU) # the only way to create a pixbuf from stock - if num_of_secured < num_of_accounts: - # Make it transparent - colorspace = tls_pixbuf.get_colorspace() - bps = tls_pixbuf.get_bits_per_sample() - rowstride = tls_pixbuf.get_rowstride() - pixels = tls_pixbuf.get_pixels() - new_pixels = '' - width = tls_pixbuf.get_width() - height = tls_pixbuf.get_height() - for i in range(0, width*height): - rgb = pixels[4*i:4*i+3] - new_pixels += rgb - if rgb == chr(0)*3: - new_pixels += chr(0) - else: - new_pixels += chr(128) - tls_pixbuf = gtk.gdk.pixbuf_new_from_data(new_pixels, colorspace, - True, bps, width, height, rowstride) model[iter][C_PADLOCK_PIXBUF] = tls_pixbuf else: model[iter][C_PADLOCK_PIXBUF] = None @@ -1440,7 +1420,6 @@ class RosterWindow: return info[contact.jid] = vcard.ZeroconfVcardWindow(contact, account) - def show_tooltip(self, contact): pointer = self.tree.get_pointer() props = self.tree.get_path_at_pos(pointer[0], pointer[1])