pidgin: 8236b21b: Always store custom smileys with hashed ...

sadrul at pidgin.im sadrul at pidgin.im
Sun May 25 12:20:54 EDT 2008


-----------------------------------------------------------------
Revision: 8236b21b0ace69ab22e8e92711a7f8062e277abf
Ancestor: 0b9d3da51576b05d37b8902cbf1cbac591f22eb1
Author: ml at update.uu.se
Date: 2008-05-25T16:16:22
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8236b21b0ace69ab22e8e92711a7f8062e277abf

Modified files:
        libpurple/smiley.c libpurple/smiley.h pidgin/gtksmiley.c

ChangeLog: 

Always store custom smileys with hashed filenames. Closes #5913.

-------------- next part --------------
============================================================
--- libpurple/smiley.c	d44f77ec339202ad23e409db223a3c712815f23b
+++ libpurple/smiley.c	d1e3ba9688f482d1e5c4c30a7872a16400aeed00
@@ -119,7 +119,7 @@ purple_smiley_set_data_impl(PurpleSmiley
 
 static void
 purple_smiley_set_data_impl(PurpleSmiley *smiley, guchar *smiley_data,
-		size_t smiley_data_len, const char *filename);
+		size_t smiley_data_len);
 
 static void
 purple_smiley_data_store(PurpleStoredImage *stored_img);
@@ -499,7 +499,7 @@ purple_smiley_load_file(const char *shor
 
 	if (read_smiley_file(fullpath, &smiley_data, &smiley_data_len))
 		purple_smiley_set_data_impl(smiley, smiley_data,
-				smiley_data_len, filename);
+				smiley_data_len);
 	else
 		purple_smiley_delete(smiley);
 
@@ -617,7 +617,7 @@ purple_smiley_set_data_impl(PurpleSmiley
 
 static void
 purple_smiley_set_data_impl(PurpleSmiley *smiley, guchar *smiley_data,
-				size_t smiley_data_len, const char *filename)
+				size_t smiley_data_len)
 {
 	PurpleStoredImage *old_img, *new_img;
 	const char *old_filename = NULL;
@@ -629,10 +629,7 @@ purple_smiley_set_data_impl(PurpleSmiley
 
 	old_img = smiley->img;
 
-	if (filename)
-		new_img = purple_imgstore_add(smiley_data, smiley_data_len, filename);
-	else
-		new_img = purple_smiley_data_new(smiley_data, smiley_data_len);
+	new_img = purple_smiley_data_new(smiley_data, smiley_data_len);
 
 	g_object_set(G_OBJECT(smiley), PROP_IMGSTORE_S, new_img, NULL);
 
@@ -688,7 +685,7 @@ purple_smiley_new_from_stream(const char
 
 static PurpleSmiley *
 purple_smiley_new_from_stream(const char *shortcut, guchar *smiley_data,
-			size_t smiley_data_len, const char *filename)
+			size_t smiley_data_len)
 {
 	PurpleSmiley *smiley;
 
@@ -705,7 +702,7 @@ purple_smiley_new_from_stream(const char
 	if (!smiley)
 		return NULL;
 
-	purple_smiley_set_data_impl(smiley, smiley_data, smiley_data_len, filename);
+	purple_smiley_set_data_impl(smiley, smiley_data, smiley_data_len);
 
 	purple_smiley_data_store(smiley->img);
 
@@ -718,17 +715,15 @@ purple_smiley_new_from_file(const char *
 	PurpleSmiley *smiley = NULL;
 	guchar *smiley_data;
 	size_t smiley_data_len;
-	char *filename;
 
 	g_return_val_if_fail(shortcut  != NULL,  NULL);
 	g_return_val_if_fail(filepath != NULL,  NULL);
 
-	filename = g_path_get_basename(filepath);
-	if (read_smiley_file(filepath, &smiley_data, &smiley_data_len))
+	if (read_smiley_file(filepath, &smiley_data, &smiley_data_len)) {
 		smiley = purple_smiley_new_from_stream(shortcut, smiley_data,
-				smiley_data_len, filename);
-	g_free(filename);
-
+				smiley_data_len);
+	}
+	
 	return smiley;
 }
 
@@ -769,7 +764,7 @@ purple_smiley_set_data(PurpleSmiley *smi
 
 void
 purple_smiley_set_data(PurpleSmiley *smiley, guchar *smiley_data,
-			   size_t smiley_data_len, gboolean keepfilename)
+			   size_t smiley_data_len)
 {
 	g_return_if_fail(smiley     != NULL);
 	g_return_if_fail(smiley_data != NULL);
@@ -779,14 +774,7 @@ purple_smiley_set_data(PurpleSmiley *smi
 	g_hash_table_remove(smiley_checksum_index, smiley->checksum);
 
 	/* Update the file data. This also updates the checksum. */
-	if ((keepfilename) && (smiley->img) &&
-			(purple_imgstore_get_filename(smiley->img)))
-		purple_smiley_set_data_impl(smiley, smiley_data,
-				smiley_data_len,
-				purple_imgstore_get_filename(smiley->img));
-	else
-		purple_smiley_set_data_impl(smiley, smiley_data,
-				smiley_data_len, NULL);
+	purple_smiley_set_data_impl(smiley, smiley_data, smiley_data_len);
 
 	/* Reinsert the index item. */
 	g_hash_table_insert(smiley_checksum_index, g_strdup(smiley->checksum), smiley);
============================================================
--- libpurple/smiley.h	0a4eb7c01d47365cb21729126d1b21402490015d
+++ libpurple/smiley.h	4902b9db64402a319cdcd8ae154dee876f2b433d
@@ -128,12 +128,10 @@ purple_smiley_set_shortcut(PurpleSmiley 
  * @param smiley             The custom smiley.
  * @param smiley_data        The custom smiley data.
  * @param smiley_data_len    The custom smiley data length.
- * @param keepfilename      The current custom smiley's filename must be
- *                           kept.
  */
 void
 purple_smiley_set_data(PurpleSmiley *smiley, guchar *smiley_data,
-                                           size_t smiley_data_len, gboolean keepfilename);
+                                           size_t smiley_data_len);
 
 /**
  * Returns the custom smiley's associated shortcut.
============================================================
--- pidgin/gtksmiley.c	752a7bc1724ba5b7553837ec4b77684cdbd25889
+++ pidgin/gtksmiley.c	e7e5a9231c48f62ed45460716ed6c4127cfb37e5
@@ -229,7 +229,7 @@ static void do_add(GtkWidget *widget, Pi
 
 				return;
 			}
-			purple_smiley_set_data(s->smiley, (guchar*)data, len, FALSE);
+			purple_smiley_set_data(s->smiley, (guchar*)data, len);
 		}
 		purple_smiley_set_shortcut(s->smiley, entry);
 	} else {
@@ -329,8 +329,8 @@ pidgin_smiley_edit(GtkWidget *widget, Pu
 	window = gtk_dialog_new_with_buttons(smiley ? _("Edit Smiley") : _("Add Smiley"),
 			widget ? GTK_WINDOW(widget) : NULL,
 			GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,							 
 			smiley ? GTK_STOCK_SAVE : GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
-			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 			NULL);
 	s->parent = window;
 


More information about the Commits mailing list