Mercurial > pidgin-twitter
annotate icon.c @ 319:c5b2c6bc2815
use API to obtain icon in friendfeed service
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 02 Sep 2009 02:48:55 +0900 |
parents | aa1f0dd1a723 |
children | f021bd3431a6 |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
7 /* prototypes */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
8 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
|
9 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
|
10 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
|
11 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
|
12 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
|
13 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
14 /* functions */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
15 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
16 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 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
18 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
|
19 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
20 gchar *user_name = gotdata->user_name; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
21 gint service = gotdata->service; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
22 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
23 GList *win_list; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
24 GtkIMHtml *target_imhtml = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
25 GtkTextBuffer *target_buffer = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
26 GtkTextIter insertion_point; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
27 icon_data *data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
28 GHashTable *hash = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
29 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
30 twitter_debug("called: service = %d\n", service); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
31 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
32 /* find the conversation that contains the mark */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
33 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
|
34 win_list = win_list->next) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
35 PidginWindow *win = win_list->data; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
36 GList *conv_list; |
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 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
|
39 conv_list = conv_list->next) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
40 PidginConversation *conv = conv_list->data; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
41 PurpleConversation *purple_conv = conv->active_conv; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
42 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
43 gint service = get_service_type(purple_conv); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
44 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
45 if(service != unknown_service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
46 GtkIMHtml *current_imhtml = GTK_IMHTML(conv->imhtml); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
47 GtkTextBuffer *current_buffer = gtk_text_view_get_buffer( |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
48 GTK_TEXT_VIEW(current_imhtml)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
49 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
50 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
|
51 target_imhtml = current_imhtml; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
52 target_buffer = current_buffer; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
53 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
54 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
55 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
56 } |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
59 if(!(target_imhtml && target_buffer)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
60 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
61 } |
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 /* insert icon to the mark */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
64 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
|
65 &insertion_point, requested_mark); |
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 /* insert icon */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
68 switch(service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
69 case twitter_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
70 case wassr_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
71 case identica_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
72 case jisko_service: |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
73 case ffeed_service: |
262 | 74 hash = icon_hash[service]; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
75 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
76 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
77 twitter_debug("unknown service\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
78 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
79 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
80 if(hash) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
81 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
|
82 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
83 /* 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
|
84 * 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
|
85 * thrashing. --yaz */ |
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 if(!data || !data->pixbuf) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
88 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
89 } |
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 /* insert icon actually */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
92 if(purple_prefs_get_bool(OPT_SHOW_ICON)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
93 gtk_text_buffer_insert_pixbuf(target_buffer, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
94 &insertion_point, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
95 data->pixbuf); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
96 data->use_count++; |
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 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
|
99 requested_mark = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
100 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
101 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
102 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
103 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
|
104 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
105 icon_data *data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
106 GList *mark_list = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
107 GHashTable *hash = 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 twitter_debug("called\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
110 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
111 switch(service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
112 case twitter_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
113 case wassr_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
114 case identica_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
115 case jisko_service: |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
116 case ffeed_service: |
262 | 117 hash = icon_hash[service]; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
118 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
119 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
120 twitter_debug("unknown service\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
121 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
122 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
123 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
124 if(hash) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
125 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
|
126 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
127 if(!data) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
128 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
129 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
130 mark_list = data->request_list; |
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 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
|
133 gotdata->user_name = g_strdup(user_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
134 gotdata->service = service; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
135 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
136 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
|
137 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
138 if(mark_list) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
139 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
|
140 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
|
141 g_list_free(mark_list); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
142 data->request_list = NULL; |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
145 g_free(gotdata->user_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
146 g_free(gotdata); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
147 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
148 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
149 /* 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
|
150 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
151 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
|
152 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
|
153 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
154 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
|
155 gchar *user_name = gotdata->user_name; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
156 gint service = gotdata->service; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
157 GMatchInfo *match_info = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
158 icon_data *data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
159 gchar *url = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
160 gint regp_id = -1; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
161 |
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
|
162 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
|
163 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
164 if(service == twitter_service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
165 data = (icon_data *)g_hash_table_lookup( |
262 | 166 icon_hash[service], user_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
167 regp_id = IMAGE_TWITTER; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
168 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
169 else if(service == wassr_service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
170 data = (icon_data *)g_hash_table_lookup( |
262 | 171 icon_hash[service], user_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
172 regp_id = IMAGE_WASSR; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
173 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
174 else if(service == identica_service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
175 data = (icon_data *)g_hash_table_lookup( |
262 | 176 icon_hash[service], user_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
177 regp_id = IMAGE_IDENTICA; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
178 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
179 else if(service == jisko_service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
180 data = (icon_data *)g_hash_table_lookup( |
262 | 181 icon_hash[service], user_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
182 regp_id = IMAGE_JISKO; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
183 } |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
184 else if(service == ffeed_service) { |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
185 data = (icon_data *)g_hash_table_lookup( |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
186 icon_hash[service], user_name); |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
187 regp_id = IMAGE_FFEED; |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
188 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
189 |
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
|
190 /* 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
|
191 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
|
192 (!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
|
193 !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
|
194 if(data) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
195 data->requested = FALSE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
196 data->fetch_data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
197 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
198 g_free(gotdata->user_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
199 g_free(gotdata); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
200 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
201 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
202 |
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
|
203 /* setup image url */ |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
204 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
|
205 if(!g_match_info_matches(match_info)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
206 g_match_info_free(match_info); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
207 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
208 if(service == twitter_service) { |
262 | 209 twitter_debug("fall back to twitter default icon: %s\n", |
210 gotdata->user_name); | |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
211 url = g_strdup(TWITTER_DEFAULT_ICON_URL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
212 } |
258
2145f975ef69
- fixed a glitch in identi.ca icon pattern
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
213 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
|
214 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
|
215 gotdata->user_name); |
258
2145f975ef69
- fixed a glitch in identi.ca icon pattern
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
254
diff
changeset
|
216 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
|
217 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
218 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
|
219 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
|
220 gotdata->user_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
221 url = g_strdup(JISKO_DEFAULT_ICON_URL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
222 } |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
223 else if(service == ffeed_service) { |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
224 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
|
225 gotdata->user_name); |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
226 url = g_strdup(FFEED_DEFAULT_ICON_URL); |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
227 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
228 else { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
229 twitter_debug("no image url found\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
230 if(data) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
231 data->requested = FALSE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
232 data->fetch_data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
233 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
234 g_free(gotdata->user_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
235 g_free(gotdata); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
236 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
237 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
238 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
239 else { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
240 url = g_match_info_fetch(match_info, 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
241 g_match_info_free(match_info); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
242 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
243 |
273
add1e454b87f
fixed a breakage in 2f053c23ee50
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
272
diff
changeset
|
244 /* separate url into basename and the rest */ |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
245 gchar *slash = strrchr(url, '/'); |
273
add1e454b87f
fixed a breakage in 2f053c23ee50
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
272
diff
changeset
|
246 *slash = '\0'; |
add1e454b87f
fixed a breakage in 2f053c23ee50
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
272
diff
changeset
|
247 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
248 gchar *tmp; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
249 /* url encode basename. twitter needs this. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
250 if(service == twitter_service) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
251 tmp = g_strdup_printf("%s/%s", url, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
252 purple_url_encode(slash+1)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
253 else if(service == wassr_service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
254 gchar *tmp0 = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
255 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
|
256 -1, 0, ".64.", 0, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
257 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
|
258 tmp0 ? tmp0 : slash+1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
259 g_free(tmp0); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
260 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
261 else { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
262 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
|
263 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
264 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
265 g_free(url); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
266 url = tmp; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
267 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
268 /* 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
|
269 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
|
270 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
|
271 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
|
272 data->requested = FALSE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
273 data->fetch_data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
274 g_free(url); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
275 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
276 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
277 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
278 if(data && data->pixbuf) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
279 gdk_pixbuf_unref(data->pixbuf); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
280 data->pixbuf = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
281 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
282 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
283 g_free(data->icon_url); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
284 data->icon_url = g_strdup(url); |
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 data->use_count = 0; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
287 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
|
288 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
289 /* request fetch image */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
290 if(url) { |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
291 twitter_debug("request %s's icon\n", user_name); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
292 twitter_debug("requested url = %s\n", url); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
293 /* reuse gotdata. just pass given one */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
294 /* 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
|
295 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
|
296 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
|
297 FALSE, got_icon_cb, gotdata); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
298 g_free(url); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
299 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
300 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
301 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
302 static GdkPixbuf * |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
303 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
|
304 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
305 /* make pixbuf */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
306 GdkPixbufLoader *loader; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
307 GdkPixbuf *src = NULL, *dest = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
308 gint size; |
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 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
|
311 g_return_val_if_fail(len > 0, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
312 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
313 loader = gdk_pixbuf_loader_new(); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
314 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
|
315 gdk_pixbuf_loader_close(loader, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
316 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
317 src = gdk_pixbuf_loader_get_pixbuf(loader); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
318 if(!src) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
319 return NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
320 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
321 size = purple_prefs_get_int(OPT_ICON_SIZE); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
322 if(size == 0) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
323 size = DEFAULT_ICON_SIZE; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
324 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
325 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
|
326 gdk_pixbuf_unref(src); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
327 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
328 return dest; |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
331 /* 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
|
332 static void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
333 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
|
334 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
|
335 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
336 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
|
337 gchar *user_name = gotdata->user_name; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
338 gint service = gotdata->service; |
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 icon_data *data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
341 GHashTable *hash = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
342 GdkPixbuf *pixbuf = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
343 const gchar *dirname = NULL; |
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 twitter_debug("called: service = %d\n", service); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
346 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
347 switch(service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
348 case twitter_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
349 case wassr_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
350 case identica_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
351 case jisko_service: |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
352 case ffeed_service: |
262 | 353 hash = icon_hash[service]; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
354 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
355 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
356 twitter_debug("unknown service\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
357 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
358 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
359 if(hash) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
360 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
|
361 |
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
|
362 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
|
363 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
|
364 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
|
365 } |
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
|
366 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
367 /* return if download failed */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
368 if(!url_text) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
369 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
|
370 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
|
371 |
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 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
|
373 |
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 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
|
375 } |
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
|
376 |
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
|
377 /* 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
|
378 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
|
379 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
|
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 /* 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
|
382 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
|
383 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
|
384 user_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
385 goto fin_got_icon_cb; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
386 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
387 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
388 pixbuf = make_scaled_pixbuf(url_text, len); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
389 |
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
|
390 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
|
391 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
|
392 |
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
|
393 /* 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
|
394 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
|
395 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
|
396 |
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
|
397 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
|
398 gotdata2->service = service; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
399 |
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
|
400 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
|
401 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
|
402 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
|
403 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
|
404 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
|
405 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
|
406 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
|
407 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
|
408 url = JISKO_DEFAULT_ICON_URL; |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
409 case ffeed_service: |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
410 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
|
411 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
|
412 } |
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 |
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 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
|
415 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
|
416 |
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 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
|
418 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
|
419 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
|
420 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
|
421 goto fin_got_icon_cb; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
422 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
423 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
424 data->pixbuf = pixbuf; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
425 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
426 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
|
427 pixbuf, |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
428 gdk_pixbuf_get_rowstride(pixbuf) * |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
429 gdk_pixbuf_get_height(pixbuf)); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
430 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
431 if(hash) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
432 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
|
433 |
272
2f053c23ee50
a better way to get an extension for icon image.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
266
diff
changeset
|
434 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
435 dirname = purple_prefs_get_string(OPT_ICON_DIR); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
436 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
437 /* 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
|
438 if(ensure_path_exists(dirname)) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
439 gchar *filename = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
440 gchar *path = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
441 const gchar *suffix = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
442 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
443 switch(service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
444 case twitter_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
445 suffix = "twitter"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
446 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
447 case wassr_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
448 suffix = "wassr"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
449 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
450 case identica_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
451 suffix = "identica"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
452 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
453 case jisko_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
454 suffix = "jisko"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
455 break; |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
456 case ffeed_service: |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
457 suffix = "ffeed"; |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
458 break; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
459 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
460 twitter_debug("unknown service\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
461 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
462 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
463 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
464 /* remove old file first */ |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
465 filename = g_strdup_printf("%s_%s.dat", |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
466 user_name, suffix); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
467 path = g_build_filename(dirname, filename, NULL); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
468 g_remove(path); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
469 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
470 g_free(filename); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
471 g_free(path); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
472 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
473 /* setup path */ |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
474 filename = g_strdup_printf("%s_%s.dat", |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
475 user_name, suffix); |
254
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 path = g_build_filename(dirname, filename, NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
478 g_free(filename); filename = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
479 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
480 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
|
481 g_free(path); path = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
482 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
483 data->mtime = time(NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
484 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
485 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
486 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
|
487 user_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
488 |
259 | 489 /* 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
|
490 insert_requested_icon(user_name, service); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
491 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
492 fin_got_icon_cb: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
493 g_free(gotdata->user_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
494 g_free(gotdata); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
495 } |
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 void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
498 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
|
499 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
500 gchar *url = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
501 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
502 /* look local icon cache for the requested icon */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
503 gchar *path = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
504 icon_data *data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
505 GHashTable *hash = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
506 const gchar *suffix = NULL; |
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 switch(service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
509 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
|
510 hash = icon_hash[service]; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
511 suffix = "twitter"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
512 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
513 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
|
514 hash = icon_hash[service]; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
515 suffix = "wassr"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
516 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
517 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
|
518 hash = icon_hash[service]; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
519 suffix = "identica"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
520 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
521 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
|
522 hash = icon_hash[service]; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
523 suffix = "jisko"; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
524 break; |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
525 case ffeed_service: |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
526 hash = icon_hash[service]; |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
527 suffix = "ffeed"; |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
528 break; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
529 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
530 twitter_debug("unknown service\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
531 break; |
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 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
534 if(!hash) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
535 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
536 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
537 /* 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
|
538 * must exist here. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
539 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
|
540 |
259 | 541 /* 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
|
542 if(data && data->pixbuf && !renew) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
543 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
544 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
545 /* check if saved file exists */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
546 if(suffix && !renew) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
547 gchar *filename = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
548 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
549 filename = g_strdup_printf("%s_%s.dat", user_name, suffix); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
550 path = g_build_filename(purple_prefs_get_string(OPT_ICON_DIR), |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
551 filename, NULL); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
552 g_free(filename); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
553 |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
554 twitter_debug("path = %s\n", path); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
555 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
556 /* build image from file, if file exists */ |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
557 if(g_file_test(path, G_FILE_TEST_EXISTS)) { |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
558 gchar *imgdata = NULL; |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
559 size_t len; |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
560 GError *err = NULL; |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
561 GdkPixbuf *pixbuf = NULL; |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
562 struct stat buf; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
563 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
564 if (!g_file_get_contents(path, &imgdata, &len, &err)) { |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
565 twitter_debug("Error reading %s: %s\n", |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
566 path, err->message); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
567 g_error_free(err); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
568 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
569 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
570 if(stat(path, &buf)) |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
571 data->mtime = buf.st_mtime; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
572 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
573 pixbuf = make_scaled_pixbuf(imgdata, len); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
574 g_free(imgdata); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
575 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
576 if(pixbuf) { |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
577 data->pixbuf = pixbuf; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
578 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
579 twitter_debug("new icon pixbuf = %p size = %d\n", |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
580 pixbuf, |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
581 gdk_pixbuf_get_rowstride(pixbuf) * |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
582 gdk_pixbuf_get_height(pixbuf)); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
583 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
584 twitter_debug("icon data has been loaded from file\n"); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
585 insert_requested_icon(user_name, service); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
586 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
587 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
588 g_free(path); |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
589 return; |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
590 } |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
591 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
592 g_free(path); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
593 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
594 } /* suffix */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
595 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
596 /* 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
|
597 if(data->requested) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
598 return; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
599 else |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
600 data->requested = TRUE; |
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 /* Create the URL for an user's icon. */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
603 switch(service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
604 case twitter_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
605 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
|
606 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
607 case wassr_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
608 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
|
609 break; |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
610 case identica_service: |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
611 url = g_strdup_printf("http://identi.ca/%s", user_name); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
612 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
613 case jisko_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
614 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
|
615 break; |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
616 case ffeed_service: |
319
c5b2c6bc2815
use API to obtain icon in friendfeed service
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
310
diff
changeset
|
617 url = g_strdup_printf("http://friendfeed-api.com/v2/picture/%s", user_name); |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
618 break; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
619 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
620 twitter_debug("unknown service\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
621 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
622 } |
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 if(url) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
625 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
|
626 gotdata->user_name = g_strdup(user_name); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
627 gotdata->service = service; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
628 |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
629 twitter_debug("request %s's icon\n", user_name); |
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
630 |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
631 /* gotdata will be released in got_icon_cb */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
632 if(service == twitter_service || |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
633 service == wassr_service || |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
634 service == identica_service || |
319
c5b2c6bc2815
use API to obtain icon in friendfeed service
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
310
diff
changeset
|
635 service == 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
|
636 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
|
637 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
|
638 TRUE, got_page_cb, gotdata); |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
639 twitter_debug("requested url = %s\n", url); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
640 } |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
641 else { /* probably it is unnecessary */ |
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
|
642 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
|
643 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
|
644 FALSE, got_icon_cb, gotdata); |
310
aa1f0dd1a723
use .dat extension for icons uniformly.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
309
diff
changeset
|
645 twitter_debug("requested url = %s\n", url); |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
646 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
647 g_free(url); url = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
648 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
649 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
650 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
651 void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
652 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
|
653 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
654 icon_data *data = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
655 GHashTable *hash = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
656 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
657 twitter_debug("called\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
658 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
659 switch(service) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
660 case twitter_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
661 hash = icon_hash[twitter_service]; |
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 case wassr_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
664 hash = icon_hash[wassr_service]; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
665 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
666 case identica_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
667 hash = icon_hash[identica_service]; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
668 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
669 case jisko_service: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
670 hash = icon_hash[jisko_service]; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
671 break; |
300
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
672 case ffeed_service: |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
673 hash = icon_hash[ffeed_service]; |
42cdddf0f747
added preliminary support for friendfeed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
273
diff
changeset
|
674 break; |
254
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
675 default: |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
676 twitter_debug("unknown service\n"); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
677 break; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
678 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
679 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
680 if(hash) |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
681 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
|
682 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
683 /* proper place to allocate icon_data */ |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
684 if(!data) { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
685 data = g_new0(icon_data, 1); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
686 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
|
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 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
|
690 } |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
691 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
692 void |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
693 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
|
694 { |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
695 icon_data *data = (icon_data *)value; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
696 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
697 g_return_if_fail(data != NULL); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
698 |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
699 g_object_unref(data->pixbuf); |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
700 data->pixbuf = NULL; |
c2620a99622b
- divided the source file into several parts.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
701 } |