From fac2a002c72ff25c20743042ae0efdef9e402afa Mon Sep 17 00:00:00 2001
From: Nikos Kouremenos <kourem@gmail.com>
Date: Tue, 15 Nov 2005 23:26:22 +0000
Subject: [PATCH] [sef] ask avatars on startup ace

---
 src/common/config.py  |  1 +
 src/gtkgui_helpers.py |  4 ++--
 src/roster_window.py  | 14 +++++++-------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/common/config.py b/src/common/config.py
index b7caf4eb18..f8a1cb974b 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -159,6 +159,7 @@ class Config:
 		'show_unread_tab_icon': [opt_bool, False, _('If True, Gajim will display an icon on each tab containing unread messages. Depending on the theme, this icon may be animated.')],
 		'show_status_msgs_in_roster': [opt_bool, True, _('If True, Gajim will display the status message, if not empty, for every contact under the contact name in roster window')],
 		'show_avatars_in_roster': [opt_bool, True],
+		'ask_avatars_on_startup': [opt_bool, True, _('If True, Gajim will ask for avatar each contact that did not have an avatar last time or has one cache that is too old.')],
 		'print_status_in_chats': [opt_bool, True, _('If False, you will no longer see status line in chats when a contact changes his or her status and/or his status message.')],
 	}
 
diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py
index 7ab95f680a..b6e3bd520c 100644
--- a/src/gtkgui_helpers.py
+++ b/src/gtkgui_helpers.py
@@ -424,8 +424,8 @@ def get_scaled_pixbuf(pixbuf, type):
 def get_avatar_pixbuf_from_cache(jid):
 	'''checks if jid has cached avatar and if that avatar is valid image
 	(can be shown)
-	return None if there is no image in vcard
-	return 'ask' if vcard is too old or if we don't have the vcard'''
+	returns None if there is no image in vcard
+	returns 'ask' if vcard is old (we have new sha) or if we don't have the vcard'''
 	if jid not in os.listdir(gajim.VCARDPATH):
 		return 'ask'
 
diff --git a/src/roster_window.py b/src/roster_window.py
index 14b755233a..4805f5df2e 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -646,13 +646,13 @@ class RosterWindow:
 				else:
 					ishidden = True
 				gajim.groups[account][g] = { 'expand': ishidden }
-
-			pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(ji)
-			if pixbuf == 'ask':
-				jid_with_resource = contact1.jid
-				if contact1.resource:
-					jid_with_resource += '/' + contact1.resource
-				gajim.connections[account].request_vcard(jid_with_resource)
+			if gajim.config.get('ask_avatars_on_startup'):
+				pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(ji)
+				if pixbuf == 'ask':
+					jid_with_resource = contact1.jid
+					if contact1.resource:
+						jid_with_resource += '/' + contact1.resource
+					gajim.connections[account].request_vcard(jid_with_resource)
 
 	def chg_contact_status(self, contact, show, status, account):
 		'''When a contact changes his or her status'''
-- 
GitLab