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