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.

This commit is contained in:
Stephan Erb 2008-01-23 16:10:28 +00:00
parent 39fe7fc4c0
commit 4bb29675a8
3 changed files with 9 additions and 28 deletions

View File

@ -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

View File

@ -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

View File

@ -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])