annotate icon.c @ 309:e922ad73c07e

wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 02 Jul 2009 05:54:58 +0900
parents bc7d8baf79dd
children aa1f0dd1a723
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1 #include "pidgin-twitter.h"
272
2f053c23ee50 a better way to get an extension for icon image.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
2 #include "purple_internal.h"
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
3
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
4 extern GHashTable *icon_hash[];
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
5 extern GRegex *regp[];
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
6
308
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
7 static gchar *ext_list[] = {
309
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
8 ".png",
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
9 ".gif",
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
10 ".jpg",
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
11 ".bmp",
308
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
12 NULL
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
13 };
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
14
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
15 /* prototypes */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
16 static void insert_icon_at_mark(GtkTextMark *requested_mark, gpointer user_data);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
17 static void insert_requested_icon(const gchar *user_name, gint service);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18 static void got_icon_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
19 static GdkPixbuf *make_scaled_pixbuf(const gchar *url_text, gsize len);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
20 static void got_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
21
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
22 /* functions */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
23 static void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
24 insert_icon_at_mark(GtkTextMark *requested_mark, gpointer user_data)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
25 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 got_icon_data *gotdata = (got_icon_data *)user_data;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
27
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
28 gchar *user_name = gotdata->user_name;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29 gint service = gotdata->service;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
30
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
31 GList *win_list;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
32 GtkIMHtml *target_imhtml = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
33 GtkTextBuffer *target_buffer = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
34 GtkTextIter insertion_point;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
35 icon_data *data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
36 GHashTable *hash = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
37
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
38 twitter_debug("called: service = %d\n", service);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
39
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
40 /* find the conversation that contains the mark */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
41 for(win_list = pidgin_conv_windows_get_list(); win_list;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42 win_list = win_list->next) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 PidginWindow *win = win_list->data;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
44 GList *conv_list;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
45
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
46 for(conv_list = pidgin_conv_window_get_gtkconvs(win); conv_list;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
47 conv_list = conv_list->next) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
48 PidginConversation *conv = conv_list->data;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49 PurpleConversation *purple_conv = conv->active_conv;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
50
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
51 gint service = get_service_type(purple_conv);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
52
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 if(service != unknown_service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
54 GtkIMHtml *current_imhtml = GTK_IMHTML(conv->imhtml);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
55 GtkTextBuffer *current_buffer = gtk_text_view_get_buffer(
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
56 GTK_TEXT_VIEW(current_imhtml));
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
57
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
58 if(current_buffer == gtk_text_mark_get_buffer(requested_mark)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
59 target_imhtml = current_imhtml;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60 target_buffer = current_buffer;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
61 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
62 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
63 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
64 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
65 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
66
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
67 if(!(target_imhtml && target_buffer)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
68 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
69 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
70
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71 /* insert icon to the mark */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72 gtk_text_buffer_get_iter_at_mark(target_buffer,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
73 &insertion_point, requested_mark);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
74
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
75 /* insert icon */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 switch(service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77 case twitter_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
78 case wassr_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
79 case identica_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
80 case jisko_service:
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
81 case ffeed_service:
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
82 hash = icon_hash[service];
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
83 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84 default:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85 twitter_debug("unknown service\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
87
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
88 if(hash)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
89 data = (icon_data *)g_hash_table_lookup(hash, user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
91 /* in this function, we put an icon for pending marks. we should
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 * not invalidate the icon here, otherwise it may result in
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 * thrashing. --yaz */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
94
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
95 if(!data || !data->pixbuf) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
96 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
97 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
98
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99 /* insert icon actually */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
100 if(purple_prefs_get_bool(OPT_SHOW_ICON)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101 gtk_text_buffer_insert_pixbuf(target_buffer,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
102 &insertion_point,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
103 data->pixbuf);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104 data->use_count++;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
105 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
106 gtk_text_buffer_delete_mark(target_buffer, requested_mark);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
107 requested_mark = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
108 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
109
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
110 static void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
111 insert_requested_icon(const gchar *user_name, gint service)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
112 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
113 icon_data *data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
114 GList *mark_list = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
115 GHashTable *hash = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
116
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
117 twitter_debug("called\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119 switch(service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120 case twitter_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121 case wassr_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 case identica_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123 case jisko_service:
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
124 case ffeed_service:
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
125 hash = icon_hash[service];
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
126 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127 default:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128 twitter_debug("unknown service\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
130 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 if(hash)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133 data = (icon_data *)g_hash_table_lookup(hash, user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
135 if(!data)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
136 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 mark_list = data->request_list;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
139
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
140 got_icon_data *gotdata = g_new0(got_icon_data, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141 gotdata->user_name = g_strdup(user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 gotdata->service = service;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144 twitter_debug("about to insert icon for pending requests\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
146 if(mark_list) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 g_list_foreach(mark_list, (GFunc) insert_icon_at_mark, gotdata);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 mark_list = g_list_remove_all(mark_list, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
149 g_list_free(mark_list);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
150 data->request_list = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 g_free(gotdata->user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
154 g_free(gotdata);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
155 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157 /* this function will be called when profile page has been retrieved */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158 static void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 got_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 const gchar *url_text, gsize len, const gchar *error_message)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
161 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162 got_icon_data *gotdata = (got_icon_data *)user_data;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
163 gchar *user_name = gotdata->user_name;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164 gint service = gotdata->service;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
165 GMatchInfo *match_info = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
166 icon_data *data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 gchar *url = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
168 gint regp_id = -1;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
170 twitter_debug("called\n");
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
171
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
172 if(service == twitter_service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 data = (icon_data *)g_hash_table_lookup(
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
174 icon_hash[service], user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 regp_id = IMAGE_TWITTER;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
176 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
177 else if(service == wassr_service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178 data = (icon_data *)g_hash_table_lookup(
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
179 icon_hash[service], user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
180 regp_id = IMAGE_WASSR;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
182 else if(service == identica_service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 data = (icon_data *)g_hash_table_lookup(
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
184 icon_hash[service], user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
185 regp_id = IMAGE_IDENTICA;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
186 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 else if(service == jisko_service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
188 data = (icon_data *)g_hash_table_lookup(
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
189 icon_hash[service], user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190 regp_id = IMAGE_JISKO;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
191 }
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
192 else if(service == ffeed_service) {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
193 data = (icon_data *)g_hash_table_lookup(
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
194 icon_hash[service], user_name);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
195 regp_id = IMAGE_FFEED;
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
196 }
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
198 /* retrieved nothing or got a bad response */
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
199 if(!url_text ||
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
200 (!strstr(url_text, "HTTP/1.1 200 OK") &&
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
201 !strstr(url_text, "HTTP/1.0 200 OK"))) {
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
202 if(data) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
203 data->requested = FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 data->fetch_data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206 g_free(gotdata->user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
207 g_free(gotdata);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
208 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
210
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
211 /* setup image url */
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
212 g_regex_match(regp[regp_id], url_text, 0, &match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
213 if(!g_match_info_matches(match_info)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
214 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
215
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
216 if(service == twitter_service) {
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
217 twitter_debug("fall back to twitter default icon: %s\n",
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
218 gotdata->user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
219 url = g_strdup(TWITTER_DEFAULT_ICON_URL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
220 }
258
2145f975ef69 - fixed a glitch in identi.ca icon pattern
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
221 else if(service == identica_service) {
263
b2c64cd550da added error check code for testing in got_page_cb().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 262
diff changeset
222 twitter_debug("fall back to identica default icon: %s\n",
b2c64cd550da added error check code for testing in got_page_cb().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 262
diff changeset
223 gotdata->user_name);
258
2145f975ef69 - fixed a glitch in identi.ca icon pattern
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
224 url = g_strdup(IDENTICA_DEFAULT_ICON_URL);
2145f975ef69 - fixed a glitch in identi.ca icon pattern
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 254
diff changeset
225 }
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 else if(service == jisko_service) {
263
b2c64cd550da added error check code for testing in got_page_cb().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 262
diff changeset
227 twitter_debug("fall back to jisko default icon: %s\n",
b2c64cd550da added error check code for testing in got_page_cb().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 262
diff changeset
228 gotdata->user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
229 url = g_strdup(JISKO_DEFAULT_ICON_URL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
230 }
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
231 else if(service == ffeed_service) {
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
232 twitter_debug("fall back to ffeed default icon: %s\n",
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
233 gotdata->user_name);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
234 url = g_strdup(FFEED_DEFAULT_ICON_URL);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
235 }
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
237 twitter_debug("no image url found\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
238 if(data) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
239 data->requested = FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
240 data->fetch_data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
241 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
242 g_free(gotdata->user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
243 g_free(gotdata);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
244 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
245 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
246 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
247 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
248 url = g_match_info_fetch(match_info, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
249 g_match_info_free(match_info);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
250 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
251
273
add1e454b87f fixed a breakage in 2f053c23ee50
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 272
diff changeset
252 /* separate url into basename and the rest */
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253 gchar *slash = strrchr(url, '/');
273
add1e454b87f fixed a breakage in 2f053c23ee50
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 272
diff changeset
254 *slash = '\0';
add1e454b87f fixed a breakage in 2f053c23ee50
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 272
diff changeset
255
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
256 gchar *tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
257 /* url encode basename. twitter needs this. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
258 if(service == twitter_service)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
259 tmp = g_strdup_printf("%s/%s", url,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
260 purple_url_encode(slash+1));
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
261 else if(service == wassr_service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
262 gchar *tmp0 = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
263 tmp0 = g_regex_replace(regp[SIZE_128_WASSR], slash+1,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
264 -1, 0, ".64.", 0, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
265 tmp = g_strdup_printf("http://wassr.jp%s/%s", url,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
266 tmp0 ? tmp0 : slash+1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
267 g_free(tmp0);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
268 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
269 else {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
270 tmp = g_strdup_printf("%s/%s", url, slash+1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
271 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
272
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
273 g_free(url);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
274 url = tmp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
275
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
276 /* if requesting icon url is the same as old, return. */
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
277 if(data && data->pixbuf &&
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
278 url && data->icon_url && !strcmp(data->icon_url, url)) {
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
279 twitter_debug("old url = %s new url = %s\n", data->icon_url, url);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
280 data->requested = FALSE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
281 data->fetch_data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
282 g_free(url);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
283 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
284 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
285
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
286 if(data && data->pixbuf) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
287 gdk_pixbuf_unref(data->pixbuf);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
288 data->pixbuf = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
289 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
290
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
291 g_free(data->icon_url);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
292 data->icon_url = g_strdup(url);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
293
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
294 data->use_count = 0;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
295 data->mtime = time(NULL); /* xxx is there a better way? */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
296
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
297 twitter_debug("requested url=%s\n", url);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
298
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
299 /* request fetch image */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
300 if(url) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
301 /* reuse gotdata. just pass given one */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
302 /* gotdata will be released in got_icon_cb */
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
303 data->fetch_data =
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
304 purple_util_fetch_url_request(url, TRUE, NULL, TRUE, NULL,
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
305 FALSE, got_icon_cb, gotdata);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
306 twitter_debug("request %s's icon\n", user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
307 g_free(url);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
308 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
309 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
310
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
311 static GdkPixbuf *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
312 make_scaled_pixbuf(const gchar *url_text, gsize len)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
313 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
314 /* make pixbuf */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
315 GdkPixbufLoader *loader;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
316 GdkPixbuf *src = NULL, *dest = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
317 gint size;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
318
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
319 g_return_val_if_fail(url_text != NULL, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
320 g_return_val_if_fail(len > 0, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
321
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
322 loader = gdk_pixbuf_loader_new();
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
323 gdk_pixbuf_loader_write(loader, (guchar *)url_text, len, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
324 gdk_pixbuf_loader_close(loader, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
325
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
326 src = gdk_pixbuf_loader_get_pixbuf(loader);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
327 if(!src)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
328 return NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
329
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
330 size = purple_prefs_get_int(OPT_ICON_SIZE);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
331 if(size == 0)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
332 size = DEFAULT_ICON_SIZE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
333
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
334 dest = gdk_pixbuf_scale_simple(src, size, size, GDK_INTERP_HYPER);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
335 gdk_pixbuf_unref(src);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
336
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
337 return dest;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
338 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
339
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
340 /* this function will be called when requested icon has been retrieved */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
341 static void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
342 got_icon_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
343 const gchar *url_text, gsize len, const gchar *error_message)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
344 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
345 got_icon_data *gotdata = (got_icon_data *)user_data;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
346 gchar *user_name = gotdata->user_name;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
347 gint service = gotdata->service;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
348
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
349 icon_data *data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
350 GHashTable *hash = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
351 GdkPixbuf *pixbuf = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
352 const gchar *dirname = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
353
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
354 twitter_debug("called: service = %d\n", service);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
355
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
356 switch(service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
357 case twitter_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
358 case wassr_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
359 case identica_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
360 case jisko_service:
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
361 case ffeed_service:
262
e9a7c018a952 reduce redundancy
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 259
diff changeset
362 hash = icon_hash[service];
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
363 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
364 default:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
365 twitter_debug("unknown service\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
366 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
367
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
368 if(hash)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
369 data = (icon_data *)g_hash_table_lookup(hash, user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
370
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
371 if(!data) {
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
372 twitter_debug("cannot retrieve icon_data from hash (should not be called)\n");
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
373 goto fin_got_icon_cb;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
374 }
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
375
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
376 /* return if download failed */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
377 if(!url_text) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
378 twitter_debug("downloading %s's icon failed : %s\n",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
379 user_name, error_message);
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
380
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
381 data->requested = FALSE;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
382
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
383 goto fin_got_icon_cb;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
384 }
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
385
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
386 /* remove download request */
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
387 data->requested = FALSE;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
388 data->fetch_data = NULL;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
389
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
390 /* return if user's icon has been downloaded */
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
391 if(data->pixbuf) {
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
392 twitter_debug("%s's icon has already been downloaded\n",
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
393 user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
394 goto fin_got_icon_cb;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
395 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
396
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
397 pixbuf = make_scaled_pixbuf(url_text, len);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
398
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
399 if(!pixbuf) {
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
400 twitter_debug("cannot make pixbuf from downloaded data\n");
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
401
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
402 /* ask to download default icon instead */
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
403 got_icon_data *gotdata2 = g_new0(got_icon_data, 1);
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
404 const gchar *url = NULL;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
405
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
406 gotdata2->user_name = g_strdup(gotdata->user_name);
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
407 gotdata2->service = service;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
408
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
409 switch(service) {
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
410 case twitter_service:
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
411 url = TWITTER_DEFAULT_ICON_URL;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
412 break;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
413 case identica_service:
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
414 url = IDENTICA_DEFAULT_ICON_URL;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
415 break;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
416 case jisko_service:
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
417 url = JISKO_DEFAULT_ICON_URL;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
418 case ffeed_service:
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
419 url = FFEED_DEFAULT_ICON_URL;
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
420 break;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
421 }
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
422
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
423 g_free(data->icon_url);
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
424 data->icon_url = g_strdup(url);
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
425
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
426 data->requested = TRUE;
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
427 data->fetch_data =
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
428 purple_util_fetch_url_request(url, TRUE, NULL, TRUE, NULL,
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
429 FALSE, got_icon_cb, gotdata2);
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
430 goto fin_got_icon_cb;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
431 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
432
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
433 data->pixbuf = pixbuf;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
434
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
435 twitter_debug("new icon pixbuf = %p size = %d\n",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
436 pixbuf,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
437 gdk_pixbuf_get_rowstride(pixbuf) *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
438 gdk_pixbuf_get_height(pixbuf));
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
439
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
440 if(hash)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
441 g_hash_table_insert(hash, g_strdup(user_name), data);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
442
272
2f053c23ee50 a better way to get an extension for icon image.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
443 /* find out extension */
2f053c23ee50 a better way to get an extension for icon image.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
444 gchar *slash = strrchr(url_data->url, '/');
308
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
445 gchar *lower = g_ascii_strdown(purple_url_decode(slash+1), -1);
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
446
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
447 gchar **extp;
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
448 data->img_type = NULL;
272
2f053c23ee50 a better way to get an extension for icon image.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
449
309
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
450 for(extp = ext_list; *extp; extp++) {
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
451 if(g_strrstr(lower, *extp)) {
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
452 data->img_type = *extp+1;
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
453 break;
308
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
454 }
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
455 }
309
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
456 if(!data->img_type && g_strrstr(lower, ".jpeg"))
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
457 data->img_type = ext_list[2]+1; /* jpg */
e922ad73c07e wassr's icon url does not end with an extension, so we must use a strstr variants to detect image format.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 308
diff changeset
458
308
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
459 g_free(lower);
272
2f053c23ee50 a better way to get an extension for icon image.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
460
308
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
461 /* return if no suitable image found */
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
462 if(!data->img_type) {
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
463 g_free(gotdata->user_name);
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
464 g_free(gotdata);
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
465 return;
bc7d8baf79dd more robust image type detection.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 300
diff changeset
466 }
272
2f053c23ee50 a better way to get an extension for icon image.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 266
diff changeset
467
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
468 dirname = purple_prefs_get_string(OPT_ICON_DIR);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
469
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
470 /* store retrieved image to a file in icon dir */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
471 if(ensure_path_exists(dirname)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
472 gchar *filename = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
473 gchar *path = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
474 const gchar *suffix = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
475 gchar **extp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
476
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
477 switch(service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
478 case twitter_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
479 suffix = "twitter";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
480 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
481 case wassr_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
482 suffix = "wassr";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
483 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
484 case identica_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
485 suffix = "identica";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
486 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
487 case jisko_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
488 suffix = "jisko";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
489 break;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
490 case ffeed_service:
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
491 suffix = "ffeed";
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
492 break;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
493 default:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
494 twitter_debug("unknown service\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
495 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
496 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
497
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
498 /* remove old file first */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
499 for(extp = ext_list; *extp; extp++) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
500 filename = g_strdup_printf("%s_%s.%s",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
501 user_name, suffix, *extp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
502 path = g_build_filename(dirname, filename, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
503 g_remove(path);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
504
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
505 g_free(filename);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
506 g_free(path);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
507 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
508
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
509 /* setup path */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
510 filename = g_strdup_printf("%s_%s.%s",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
511 user_name, suffix, data->img_type);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
512
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
513 path = g_build_filename(dirname, filename, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
514 g_free(filename); filename = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
515
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
516 g_file_set_contents(path, url_text, len, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
517 g_free(path); path = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
518
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
519 data->mtime = time(NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
520 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
521
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
522 twitter_debug("Downloading %s's icon has been complete.\n",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
523 user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
524
259
d45dd3589560 little clean up
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 258
diff changeset
525 /* Insert the icon to messages that has been received. */
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
526 insert_requested_icon(user_name, service);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
527
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
528 fin_got_icon_cb:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
529 g_free(gotdata->user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
530 g_free(gotdata);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
531 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
532
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
533 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
534 request_icon(const char *user_name, gint service, gboolean renew)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
535 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
536 gchar *url = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
537
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
538 /* look local icon cache for the requested icon */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
539 gchar *path = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
540 icon_data *data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
541 GHashTable *hash = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
542 const gchar *suffix = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
543
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
544 switch(service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
545 case twitter_service:
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
546 hash = icon_hash[service];
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
547 suffix = "twitter";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
548 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
549 case wassr_service:
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
550 hash = icon_hash[service];
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
551 suffix = "wassr";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
552 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
553 case identica_service:
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
554 hash = icon_hash[service];
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
555 suffix = "identica";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
556 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
557 case jisko_service:
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
558 hash = icon_hash[service];
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
559 suffix = "jisko";
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
560 break;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
561 case ffeed_service:
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
562 hash = icon_hash[service];
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
563 suffix = "ffeed";
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
564 break;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
565 default:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
566 twitter_debug("unknown service\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
567 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
568 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
569
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
570 if(!hash)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
571 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
572
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
573 /* since this function is called after mark_icon_for_user(), data
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
574 * must exist here. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
575 data = (icon_data *)g_hash_table_lookup(hash, user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
576
259
d45dd3589560 little clean up
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 258
diff changeset
577 /* if the image is in a hash, just return */
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
578 if(data && data->pixbuf && !renew)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
579 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
580
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
581 /* check if saved file exists */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
582 if(suffix && !renew) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
583 gchar *filename = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
584 gchar **extp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
585
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
586 for(extp = ext_list; *extp; extp++) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
587 filename = g_strdup_printf("%s_%s.%s", user_name, suffix, *extp);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
588 path = g_build_filename(purple_prefs_get_string(OPT_ICON_DIR),
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
589 filename, NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
590 g_free(filename);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
591
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
592 twitter_debug("path = %s\n", path);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
593
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
594 /* build image from file, if file exists */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
595 if(g_file_test(path, G_FILE_TEST_EXISTS)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
596 gchar *imgdata = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
597 size_t len;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
598 GError *err = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
599 GdkPixbuf *pixbuf = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
600 struct stat buf;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
601
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
602 if (!g_file_get_contents(path, &imgdata, &len, &err)) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
603 twitter_debug("Error reading %s: %s\n",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
604 path, err->message);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
605 g_error_free(err);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
606 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
607
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
608 if(stat(path, &buf))
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
609 data->mtime = buf.st_mtime;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
610
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
611 pixbuf = make_scaled_pixbuf(imgdata, len);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
612 g_free(imgdata);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
613
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
614 if(pixbuf) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
615 data->pixbuf = pixbuf;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
616
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
617 twitter_debug("new icon pixbuf = %p size = %d\n",
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
618 pixbuf,
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
619 gdk_pixbuf_get_rowstride(pixbuf) *
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
620 gdk_pixbuf_get_height(pixbuf));
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
621
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
622 data->img_type = *extp;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
623
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
624 twitter_debug("icon data has been loaded from file\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
625 insert_requested_icon(user_name, service);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
626 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
627
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
628 g_free(path);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
629 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
630 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
631
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
632 g_free(path);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
633
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
634 } /* for */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
635 } /* suffix */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
636
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
637 /* Return if user's icon has been requested already. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
638 if(data->requested)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
639 return;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
640 else
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
641 data->requested = TRUE;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
642
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
643 /* Create the URL for an user's icon. */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
644 switch(service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
645 case twitter_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
646 url = g_strdup_printf("http://twitter.com/%s", user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
647 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
648 case wassr_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
649 url = g_strdup_printf("http://wassr.jp/user/%s", user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
650 break;
266
d3e2b2e58828 adapted for laconica 0.6.4 in identi.ca service.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 265
diff changeset
651 case identica_service: /* make use of Version0 API */
d3e2b2e58828 adapted for laconica 0.6.4 in identi.ca service.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 265
diff changeset
652 url = g_strdup_printf("http://identi.ca/%s/avatar/96", user_name);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
653 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
654 case jisko_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
655 url = g_strdup_printf("http://jisko.net/%s", user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
656 break;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
657 case ffeed_service:
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
658 url = g_strdup_printf("http://friendfeed.com/%s", user_name);
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
659 break;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
660 default:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
661 twitter_debug("unknown service\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
662 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
663 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
664
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
665 if(url) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
666 got_icon_data *gotdata = g_new0(got_icon_data, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
667 gotdata->user_name = g_strdup(user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
668 gotdata->service = service;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
669
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
670 /* gotdata will be released in got_icon_cb */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
671 if(service == twitter_service ||
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
672 service == wassr_service ||
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
673 service == jisko_service ||
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
674 service == ffeed_service) {
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
675 data->fetch_data =
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
676 purple_util_fetch_url_request(url, TRUE, NULL, TRUE, NULL,
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
677 TRUE, got_page_cb, gotdata);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
678 }
266
d3e2b2e58828 adapted for laconica 0.6.4 in identi.ca service.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 265
diff changeset
679 else { /* typically, identica_service */
264
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
680 data->fetch_data =
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
681 purple_util_fetch_url_request(url, TRUE, NULL, TRUE, NULL,
b7ac562d758c - changed the pattern for twitter icons so that it may match to protected user's icon link too.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 263
diff changeset
682 FALSE, got_icon_cb, gotdata);
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
683 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
684 g_free(url); url = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
685
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
686 twitter_debug("request %s's icon\n", user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
687 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
688 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
689
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
690 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
691 mark_icon_for_user(GtkTextMark *mark, const gchar *user_name, gint service)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
692 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
693 icon_data *data = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
694 GHashTable *hash = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
695
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
696 twitter_debug("called\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
697
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
698 switch(service) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
699 case twitter_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
700 hash = icon_hash[twitter_service];
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
701 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
702 case wassr_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
703 hash = icon_hash[wassr_service];
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
704 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
705 case identica_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
706 hash = icon_hash[identica_service];
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
707 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
708 case jisko_service:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
709 hash = icon_hash[jisko_service];
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
710 break;
300
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
711 case ffeed_service:
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
712 hash = icon_hash[ffeed_service];
42cdddf0f747 added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 273
diff changeset
713 break;
254
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
714 default:
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
715 twitter_debug("unknown service\n");
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
716 break;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
717 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
718
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
719 if(hash)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
720 data = (icon_data *)g_hash_table_lookup(hash, user_name);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
721
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
722 /* proper place to allocate icon_data */
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
723 if(!data) {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
724 data = g_new0(icon_data, 1);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
725 g_hash_table_insert(hash, g_strdup(user_name), data);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
726 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
727
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
728 data->request_list = g_list_prepend(data->request_list, mark);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
729 }
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
730
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
731 void
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
732 invalidate_icon_data_func(gpointer key, gpointer value, gpointer user_data)
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
733 {
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
734 icon_data *data = (icon_data *)value;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
735
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
736 g_return_if_fail(data != NULL);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
737
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
738 g_object_unref(data->pixbuf);
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
739 data->pixbuf = NULL;
c2620a99622b - divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
740 }