changeset 22627:c240e7eb379d

merge of 'b2b2efabbafab6588e02ceb16509419dcb0c79e9' and 'b426234bbef68ed60bc6f15fc35ea1690d5a8ed1'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 04 Apr 2008 06:11:09 +0000
parents eccdd341dc6e (diff) 357809e70305 (current diff)
children 29f20ae16bf9 98775a5b4817
files
diffstat 11 files changed, 114 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/autogen.sh	Fri Apr 04 06:09:21 2008 +0000
+++ b/autogen.sh	Fri Apr 04 06:11:09 2008 +0000
@@ -134,5 +134,5 @@
 ###############################################################################
 # Run configure
 ###############################################################################
-echo "running ./configure ${CONFIGURE_ARGS} $@"
-./configure ${CONFIGURE_ARGS} $@
+echo "running ./configure ${CONFIGURE_FLAGS} $@"
+./configure ${CONFIGURE_FLAGS} $@
--- a/libpurple/buddyicon.c	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/buddyicon.c	Fri Apr 04 06:11:09 2008 +0000
@@ -1,5 +1,5 @@
 /**
- * @file icon.c Buddy Icon API
+ * @file buddyicon.c Buddy Icon API
  * @ingroup core
  */
 
@@ -31,36 +31,85 @@
 #include "imgstore.h"
 #include "util.h"
 
-typedef struct _PurpleBuddyIconData PurpleBuddyIconData;
-
 /* NOTE: Instances of this struct are allocated without zeroing the memory, so
  * NOTE: be sure to update purple_buddy_icon_new() if you add members. */
 struct _PurpleBuddyIcon
 {
 	PurpleAccount *account;    /**< The account the user is on.          */
-	PurpleStoredImage *img;    /**< The id of the stored image with the
+	PurpleStoredImage *img;    /**< The stored image containing
 	                                the icon data.                       */
 	char *username;            /**< The username the icon belongs to.    */
 	char *checksum;            /**< The protocol checksum.               */
 	int ref_count;             /**< The buddy icon reference count.      */
 };
 
+/**
+ * This is the big grand daddy hash table that contains references to
+ * everybody's buddy icons.
+ *
+ * Key is a PurpleAccount.
+ * Value is another hash table, usually referred to as "icon_cache."
+ * For this inner hash table:
+ *    Key is the username of the buddy whose icon is being stored.
+ *    Value is the PurpleBuddyIcon for this buddy.
+ */
 static GHashTable *account_cache = NULL;
+
+/**
+ * This hash table contains a bunch of PurpleStoredImages that are
+ * shared across all accounts.
+ *
+ * Key is the filename for this image as constructed by
+ * purple_util_get_image_filename().  So it is the base16 encoded
+ * sha-1 hash plus an appropriate file extension.  For example:
+ *   "0f4972d17d1e70e751c43c90c948e72efbff9796.gif"
+ *
+ * The value is a PurpleStoredImage containing the icon data.  These
+ * images are reference counted, and when the count reaches 0
+ * imgstore.c emits the image-deleting signal and we remove the image
+ * from the hash table (but it might still be saved on disk, if the
+ * icon is being used by offline accounts or some such).
+ */
 static GHashTable *icon_data_cache = NULL;
+
+/**
+ * This hash table contains references counts for how many times each
+ * icon in the ~/.purple/icons/ directory is being used.  It's pretty
+ * crazy.  It maintains the reference count across sessions, too, so
+ * if you exit Pidgin then this hash table is reconstructed the next
+ * time Pidgin starts.
+ *
+ * Key is the filename for this image as constructed by
+ * purple_util_get_image_filename().  So it is the base16 encoded
+ * sha-1 hash plus an appropriate file extension.  For example:
+ *   "0f4972d17d1e70e751c43c90c948e72efbff9796.gif"
+ *
+ * The value is a GINT_TO_POINTER count of the number of times this
+ * icon is used.  So if four of your buddies are using an icon, and
+ * you have the icon set for two of your accounts, then this number
+ * will be six.  When this reference count reaches 0 the icon will
+ * be deleted from disk.
+ */
 static GHashTable *icon_file_cache = NULL;
 
-static void delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name);
-
 /* This one is used for both custom buddy icons
  * on PurpleContacts and account icons. */
 static GHashTable *pointer_icon_cache = NULL;
 
 static char       *cache_dir     = NULL;
+
+/** "Should icons be cached to disk?" */
 static gboolean    icon_caching  = TRUE;
 
 /* For ~/.gaim to ~/.purple migration. */
 static char *old_icons_dir = NULL;
 
+static void delete_buddy_icon_settings(PurpleBlistNode *node, const char *setting_name);
+
+/*
+ * Begin functions for dealing with the on-disk icon cache
+ */
+
 static void
 ref_filename(const char *filename)
 {
@@ -158,6 +207,14 @@
 	g_free(path);
 }
 
+/*
+ * End functions for dealing with the on-disk icon cache
+ */
+
+/*
+ * Begin functions for dealing with the in-memory icon cache
+ */
+
 static gboolean
 value_equals(gpointer key, gpointer value, gpointer user_data)
 {
@@ -222,6 +279,10 @@
 	return img;
 }
 
+/*
+ * End functions for dealing with the in-memory icon cache
+ */
+
 static PurpleBuddyIcon *
 purple_buddy_icon_create(PurpleAccount *account, const char *username)
 {
--- a/libpurple/buddyicon.h	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/buddyicon.h	Fri Apr 04 06:11:09 2008 +0000
@@ -45,7 +45,7 @@
 /*@{*/
 
 /**
- * Creates a new buddy icon structure and populate it.
+ * Creates a new buddy icon structure and populates it.
  *
  * If the buddy icon already exists, you'll get a reference to that structure,
  * which will have been updated with the data supplied.
--- a/libpurple/imgstore.c	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/imgstore.c	Fri Apr 04 06:11:09 2008 +0000
@@ -34,11 +34,9 @@
 #include "util.h"
 
 static GHashTable *imgstore;
-static int nextid = 0;
+static unsigned int nextid = 0;
 
-/**
- * Stored image
- *
+/*
  * NOTE: purple_imgstore_add() creates these without zeroing the memory, so
  * NOTE: make sure to update that function when adding members.
  */
@@ -75,7 +73,14 @@
 {
 	PurpleStoredImage *img = purple_imgstore_add(data, size, filename);
 	if (img) {
-		img->id = ++nextid;
+		/*
+		 * Use the next unused id number.  We do it in a loop on the
+		 * off chance that nextid wraps back around to 0 and the hash
+		 * table still contains entries from the first time around.
+		 */
+		do {
+			img->id = ++nextid;
+		} while (img->id == 0 || g_hash_table_lookup(imgstore, &(img->id)) != NULL);
 
 		g_hash_table_insert(imgstore, &(img->id), img);
 	}
--- a/libpurple/imgstore.h	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/imgstore.h	Fri Apr 04 06:11:09 2008 +0000
@@ -51,7 +51,11 @@
  *                      ownership of and free as appropriate.  If you want a
  *                      copy of the data, make it before calling this function.
  * @param size		Image data's size.
- * @param filename	Filename associated with image.
+ * @param filename	Filename associated with image.  This is for your
+ *                  convenience.  It could be the full path to the
+ *                  image or, more commonly, the filename of the image
+ *                  without any directory information.  It can also be
+ *                  NULL, if you don't need to keep track of a filename.
  *
  * @return The stored image.
  */
@@ -69,9 +73,14 @@
  *                      ownership of and free as appropriate.  If you want a
  *                      copy of the data, make it before calling this function.
  * @param size		Image data's size.
- * @param filename	Filename associated with image.
+ * @param filename	Filename associated with image.  This is for your
+ *                  convenience.  It could be the full path to the
+ *                  image or, more commonly, the filename of the image
+ *                  without any directory information.  It can also be
+ *                  NULL, if you don't need to keep track of a filename.
 
- * @return ID for the image.
+ * @return ID for the image.  This is a unique number that can be used
+ *         within libpurple to reference the image.
  */
 int purple_imgstore_add_with_id(gpointer data, size_t size, const char *filename);
 
@@ -116,11 +125,13 @@
 const char *purple_imgstore_get_filename(const PurpleStoredImage *img);
 
 /**
- * Returns an extension corresponding to the image's file type.
+ * Looks at the magic numbers of the image data (the first few bytes)
+ * and returns an extension corresponding to the image's file type.
  *
  * @param img  The image.
  *
- * @return The icon's extension or "icon" if unknown.
+ * @return The image's extension (for example "png") or "icon"
+ *         if unknown.
  */
 const char *purple_imgstore_get_extension(PurpleStoredImage *img);
 
--- a/libpurple/notify.c	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/notify.c	Fri Apr 04 06:11:09 2008 +0000
@@ -586,7 +586,7 @@
 }
 
 
-gchar *
+const gchar *
 purple_notify_user_info_entry_get_label(PurpleNotifyUserInfoEntry *user_info_entry)
 {
 	g_return_val_if_fail(user_info_entry != NULL, NULL);
@@ -603,7 +603,7 @@
 	user_info_entry->label = g_strdup(label);
 }
 
-gchar *
+const gchar *
 purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry)
 {
 	g_return_val_if_fail(user_info_entry != NULL, NULL);
--- a/libpurple/notify.h	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/notify.h	Fri Apr 04 06:11:09 2008 +0000
@@ -596,7 +596,7 @@
  *
  * @result                    The label
  */
-gchar *purple_notify_user_info_entry_get_label(PurpleNotifyUserInfoEntry *user_info_entry);
+const gchar *purple_notify_user_info_entry_get_label(PurpleNotifyUserInfoEntry *user_info_entry);
 
 /**
  * Set the label for a PurpleNotifyUserInfoEntry
@@ -613,7 +613,7 @@
  *
  * @result                    The value
  */
-gchar *purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry);
+const gchar *purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry);
 
 /**
  * Set the value for a PurpleNotifyUserInfoEntry
--- a/libpurple/protocols/jabber/jabber.c	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Fri Apr 04 06:11:09 2008 +0000
@@ -2377,7 +2377,7 @@
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
 	                  PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
 	                  jabber_cmd_chat_ban,
-	                  _("ban &lt;user&gt; [room]:  Ban a user from the room."),
+	                  _("ban &lt;user&gt; [reason]:  Ban a user from the room."),
 	                  NULL);
 	purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL,
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
@@ -2401,13 +2401,13 @@
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
 	                  PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
 	                  jabber_cmd_chat_join,
-	                  _("join: &lt;room&gt; [server]:  Join a chat on this server."),
+	                  _("join: &lt;room&gt; [password]:  Join a chat on this server."),
 	                  NULL);
 	purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL,
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
 	                  PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
 	                  jabber_cmd_chat_kick,
-	                  _("kick &lt;user&gt; [room]:  Kick a user from the room."),
+	                  _("kick &lt;user&gt; [reason]:  Kick a user from the room."),
 	                  NULL);
 	purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL,
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
--- a/libpurple/protocols/oscar/family_locate.c	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/protocols/oscar/family_locate.c	Fri Apr 04 06:11:09 2008 +0000
@@ -1354,7 +1354,7 @@
 }
 
 /*
- * Subtype 0x0015 - Request the info a user using the short method.  This is
+ * Subtype 0x0015 - Request the info of a user using the short method.  This is
  * what iChat uses.  It normally is VERY leniently rate limited.
  *
  * @param sn The screen name whose info you wish to request.
--- a/libpurple/protocols/oscar/oscar.c	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Fri Apr 04 06:11:09 2008 +0000
@@ -3629,7 +3629,11 @@
 	if (purple_account_get_user_info(account) != NULL)
 		serv_set_info(gc, purple_account_get_user_info(account));
 
-	if (!od->icq)
+	if (!od->icq && strcmp(purple_account_get_username(account), purple_connection_get_display_name(gc)) != 0)
+		/*
+		 * Format the screen name for AIM accounts if it's different
+		 * than what's currently set.
+		 */
 		oscar_format_screenname(gc, account->username);
 
 	/* Set our available message based on the current status */
--- a/libpurple/util.h	Fri Apr 04 06:09:21 2008 +0000
+++ b/libpurple/util.h	Fri Apr 04 06:11:09 2008 +0000
@@ -702,8 +702,11 @@
 purple_util_get_image_extension(gconstpointer data, size_t len);
 
 /**
- * Returns a SHA-1 hash string of the data passed in with the correct file
- * extention appended.
+ * @return A hex encoded version of the SHA-1 hash of the data passed
+ *         in with the correct file extention appended.  The file
+ *         extension is determined by calling
+ *         purple_util_get_image_extension().  This return value must
+ *         be g_freed by the caller.
  */
 char *purple_util_get_image_filename(gconstpointer image_data, size_t image_len);