Mercurial > pidgin
comparison src/prpl.c @ 5563:9eb5b13fd412
[gaim-migrate @ 5965]
Just a taste of what's coming.
Standard "This won't compile" thing. Plugin authors, you're going to hate
me, but that's okay, because I have friends too!
It's really late. My brain resembles that of fish swimming in jello pudding
with neon lights flying around chanting musicals. I'm not on drugs. I'm
just that tired.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 30 May 2003 09:38:29 +0000 |
parents | f7dc3f656f03 |
children | 5e7de337a053 |
comparison
equal
deleted
inserted
replaced
5562:3c8d34574601 | 5563:9eb5b13fd412 |
---|---|
76 { | 76 { |
77 GtkWidget *menuitem; | 77 GtkWidget *menuitem; |
78 GtkWidget *submenu; | 78 GtkWidget *submenu; |
79 GaimPluginProtocolInfo *prpl_info = NULL; | 79 GaimPluginProtocolInfo *prpl_info = NULL; |
80 GList *l; | 80 GList *l; |
81 GSList *c = connections; | 81 GList *c; |
82 struct proto_actions_menu *pam; | 82 struct proto_actions_menu *pam; |
83 struct gaim_connection *gc = NULL; | 83 GaimConnection *gc = NULL; |
84 int count = 0; | 84 int count = 0; |
85 char buf[256]; | 85 char buf[256]; |
86 | 86 |
87 if (!protomenu) | 87 if (!protomenu) |
88 return; | 88 return; |
95 g_free(pam); | 95 g_free(pam); |
96 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem)); | 96 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem)); |
97 l = l->next; | 97 l = l->next; |
98 } | 98 } |
99 | 99 |
100 while (c) { | 100 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { |
101 gc = c->data; | 101 gc = c->data; |
102 | 102 |
103 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | 103 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
104 | 104 |
105 if (prpl_info->actions && gc->login_time) | 105 if (prpl_info->actions && gc->login_time) |
106 count++; | 106 count++; |
107 | 107 } |
108 c = g_slist_next(c); | |
109 } | |
110 c = connections; | |
111 | 108 |
112 if (!count) { | 109 if (!count) { |
113 g_snprintf(buf, sizeof(buf), _("No actions available")); | 110 g_snprintf(buf, sizeof(buf), _("No actions available")); |
114 menuitem = gtk_menu_item_new_with_label(buf); | 111 menuitem = gtk_menu_item_new_with_label(buf); |
115 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); | 112 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); |
117 return; | 114 return; |
118 } | 115 } |
119 | 116 |
120 if (count == 1) { | 117 if (count == 1) { |
121 GList *act; | 118 GList *act; |
122 while (c) { | 119 |
120 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { | |
123 gc = c->data; | 121 gc = c->data; |
124 | 122 |
125 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | 123 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
126 | 124 |
127 if (prpl_info->actions && gc->login_time) | 125 if (prpl_info->actions && gc->login_time) |
128 break; | 126 break; |
129 | |
130 c = g_slist_next(c); | |
131 } | 127 } |
132 | 128 |
133 act = prpl_info->actions(gc); | 129 act = prpl_info->actions(gc); |
134 | 130 |
135 while (act) { | 131 while (act) { |
145 gaim_separator(protomenu); | 141 gaim_separator(protomenu); |
146 } | 142 } |
147 act = g_list_next(act); | 143 act = g_list_next(act); |
148 } | 144 } |
149 } else { | 145 } else { |
150 while (c) { | 146 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { |
147 GaimAccount *account; | |
151 GList *act; | 148 GList *act; |
152 GdkPixbuf *pixbuf, *scale; | 149 GdkPixbuf *pixbuf, *scale; |
153 GtkWidget *image; | 150 GtkWidget *image; |
154 | 151 |
155 gc = c->data; | 152 gc = c->data; |
156 | 153 |
157 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | 154 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
158 | 155 |
159 if (!prpl_info->actions || !gc->login_time) { | 156 if (!prpl_info->actions || !gc->login_time) |
160 c = g_slist_next(c); | |
161 continue; | 157 continue; |
162 } | 158 |
159 account = gaim_connection_get_account(gc); | |
163 | 160 |
164 g_snprintf(buf, sizeof(buf), "%s (%s)", | 161 g_snprintf(buf, sizeof(buf), "%s (%s)", |
165 gc->username, gc->prpl->info->name); | 162 gaim_account_get_username(account), |
163 gc->prpl->info->name); | |
164 | |
166 menuitem = gtk_image_menu_item_new_with_label(buf); | 165 menuitem = gtk_image_menu_item_new_with_label(buf); |
167 | 166 |
168 pixbuf = create_prpl_icon(gc->account); | 167 pixbuf = create_prpl_icon(gc->account); |
169 if(pixbuf) { | 168 if(pixbuf) { |
170 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | 169 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
198 } else { | 197 } else { |
199 gaim_separator(submenu); | 198 gaim_separator(submenu); |
200 } | 199 } |
201 act = g_list_next(act); | 200 act = g_list_next(act); |
202 } | 201 } |
203 c = g_slist_next(c); | |
204 } | 202 } |
205 } | 203 } |
206 } | 204 } |
207 | 205 |
208 struct icon_data { | 206 struct icon_data { |
209 struct gaim_connection *gc; | 207 GaimConnection *gc; |
210 char *who; | 208 char *who; |
211 void *data; | 209 void *data; |
212 int len; | 210 int len; |
213 }; | 211 }; |
214 | 212 |
220 const struct icon_data *y = b; | 218 const struct icon_data *y = b; |
221 | 219 |
222 return ((x->gc != y->gc) || gaim_utf8_strcasecmp(x->who, y->who)); | 220 return ((x->gc != y->gc) || gaim_utf8_strcasecmp(x->who, y->who)); |
223 } | 221 } |
224 | 222 |
225 void set_icon_data(struct gaim_connection *gc, const char *who, void *data, int len) | 223 void set_icon_data(GaimConnection *gc, const char *who, void *data, int len) |
226 { | 224 { |
227 struct gaim_conversation *conv; | 225 struct gaim_conversation *conv; |
228 struct icon_data tmp; | 226 struct icon_data tmp; |
229 GList *l; | 227 GList *l; |
230 struct icon_data *id; | 228 struct icon_data *id; |
323 gaim_gtkconv_update_buddy_icon(conv); | 321 gaim_gtkconv_update_buddy_icon(conv); |
324 | 322 |
325 g_free(realwho); | 323 g_free(realwho); |
326 } | 324 } |
327 | 325 |
328 void remove_icon_data(struct gaim_connection *gc) | 326 void remove_icon_data(GaimConnection *gc) |
329 { | 327 { |
330 GList *list = icons; | 328 GList *list = icons; |
331 struct icon_data *id; | 329 struct icon_data *id; |
332 | 330 |
333 while (list) { | 331 while (list) { |
340 } else | 338 } else |
341 list = list->next; | 339 list = list->next; |
342 } | 340 } |
343 } | 341 } |
344 | 342 |
345 void *get_icon_data(struct gaim_connection *gc, const char *who, int *len) | 343 void *get_icon_data(GaimConnection *gc, const char *who, int *len) |
346 { | 344 { |
347 struct icon_data tmp = { gc, normalize(who), NULL, 0 }; | 345 struct icon_data tmp = { gc, normalize(who), NULL, 0 }; |
348 GList *l = g_list_find_custom(icons, &tmp, find_icon_data); | 346 GList *l = g_list_find_custom(icons, &tmp, find_icon_data); |
349 struct icon_data *id = l ? l->data : NULL; | 347 struct icon_data *id = l ? l->data : NULL; |
350 | 348 |
356 *len = 0; | 354 *len = 0; |
357 return NULL; | 355 return NULL; |
358 } | 356 } |
359 | 357 |
360 struct got_add { | 358 struct got_add { |
361 struct gaim_connection *gc; | 359 GaimConnection *gc; |
362 char *who; | 360 char *who; |
363 char *alias; | 361 char *alias; |
364 }; | 362 }; |
365 | 363 |
366 static void dont_add(struct got_add *ga) | 364 static void dont_add(struct got_add *ga) |
371 g_free(ga); | 369 g_free(ga); |
372 } | 370 } |
373 | 371 |
374 static void do_add(struct got_add *ga) | 372 static void do_add(struct got_add *ga) |
375 { | 373 { |
376 if (g_slist_find(connections, ga->gc)) | 374 if (g_list_find(gaim_connections_get_all(), ga->gc)) |
377 show_add_buddy(ga->gc, ga->who, NULL, ga->alias); | 375 show_add_buddy(ga->gc, ga->who, NULL, ga->alias); |
378 dont_add(ga); | 376 dont_add(ga); |
379 } | 377 } |
380 | 378 |
381 void show_got_added(struct gaim_connection *gc, const char *id, | 379 void show_got_added(GaimConnection *gc, const char *id, |
382 const char *who, const char *alias, const char *msg) | 380 const char *who, const char *alias, const char *msg) |
383 { | 381 { |
382 GaimAccount *account; | |
384 char buf[BUF_LONG]; | 383 char buf[BUF_LONG]; |
385 struct got_add *ga = g_new0(struct got_add, 1); | 384 struct got_add *ga; |
386 struct buddy *b = gaim_find_buddy(gc->account, who); | 385 struct buddy *b; |
387 | 386 |
388 ga->gc = gc; | 387 account = gaim_connection_get_account(gc); |
389 ga->who = g_strdup(who); | 388 b = gaim_find_buddy(gc->account, who); |
390 ga->alias = alias ? g_strdup(alias) : NULL; | 389 |
390 ga = g_new0(struct got_add, 1); | |
391 ga->gc = gc; | |
392 ga->who = g_strdup(who); | |
393 ga->alias = (alias ? g_strdup(alias) : NULL); | |
391 | 394 |
392 | 395 |
393 g_snprintf(buf, sizeof(buf), _("%s%s%s%s has made %s his or her buddy%s%s%s"), | 396 g_snprintf(buf, sizeof(buf), _("%s%s%s%s has made %s his or her buddy%s%s%s"), |
394 who, | 397 who, |
395 alias ? " (" : "", | 398 alias ? " (" : "", |
396 alias ? alias : "", | 399 alias ? alias : "", |
397 alias ? ")" : "", | 400 alias ? ")" : "", |
398 id ? id : gc->displayname[0] ? gc->displayname : gc->username, | 401 (id |
402 ? id | |
403 : (gaim_connection_get_display_name(gc) | |
404 ? gaim_connection_get_display_name(gc) | |
405 : gaim_account_get_username(account))), | |
399 msg ? ": " : ".", | 406 msg ? ": " : ".", |
400 msg ? msg : "", | 407 msg ? msg : "", |
401 b ? "" : _("\n\nDo you wish to add him or her to your buddy list?")); | 408 b ? "" : _("\n\nDo you wish to add him or her to your buddy list?")); |
402 | 409 |
403 if (b) { | 410 if (b) { |