changeset 272:2f053c23ee50

a better way to get an extension for icon image.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 12 Dec 2008 21:36:38 +0900
parents 7aad61f56c48
children add1e454b87f
files icon.c purple_internal.h
diffstat 2 files changed, 55 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/icon.c	Fri Dec 12 20:23:24 2008 +0900
+++ b/icon.c	Fri Dec 12 21:36:38 2008 +0900
@@ -1,4 +1,5 @@
 #include "pidgin-twitter.h"
+#include "purple_internal.h"
 
 extern GHashTable *icon_hash[];
 extern GRegex *regp[];
@@ -228,10 +229,8 @@
         g_match_info_free(match_info);
     }
 
-    /* find out basename */
+    /* find out extension */
     gchar *slash = strrchr(url, '/');
-    *slash = '\0';
-
     gchar *lower = g_ascii_strdown(slash+1, -1);
 
     if(strstr(lower, ".png"))
@@ -387,7 +386,6 @@
     if(data->pixbuf) {
         twitter_debug("%s's icon has already been downloaded\n",
                       user_name);
-
         goto fin_got_icon_cb;
     }
 
@@ -435,6 +433,19 @@
     if(hash)
         g_hash_table_insert(hash, g_strdup(user_name), data);
 
+    /* find out extension */
+    gchar *slash = strrchr(url_data->url, '/');
+    gchar *lower = g_ascii_strdown(slash+1, -1);
+
+    if(strstr(lower, ".png"))
+        data->img_type = "png";
+    else if(strstr(lower, ".gif"))
+        data->img_type = "gif";
+    else if(strstr(lower, ".jpg") || strstr(lower, ".jpeg"))
+        data->img_type = "jpg";
+
+    g_free(lower);
+
     dirname = purple_prefs_get_string(OPT_ICON_DIR);
 
     /* store retrieved image to a file in icon dir */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/purple_internal.h	Fri Dec 12 21:36:38 2008 +0900
@@ -0,0 +1,40 @@
+#ifndef _PIDGIN_TWITTER_PURPLE_INTERNAL_H_
+#define _PIDGIN_TWITTER_PURPLE_INTERNAL_H_
+
+struct _PurpleUtilFetchUrlData
+{
+	PurpleUtilFetchUrlCallback callback;
+	void *user_data;
+
+	struct
+	{
+		char *user;
+		char *passwd;
+		char *address;
+		int port;
+		char *page;
+
+	} website;
+
+	char *url;
+	int num_times_redirected;
+	gboolean full;
+	char *user_agent;
+	gboolean http11;
+	char *request;
+	gsize request_written;
+	gboolean include_headers;
+
+	PurpleProxyConnectData *connect_data;
+	int fd;
+	guint inpa;
+
+	gboolean got_headers;
+	gboolean has_explicit_data_len;
+	char *webdata;
+	unsigned long len;
+	unsigned long data_len;
+	gssize max_len;
+};
+
+#endif