comparison src/protocols/icq/gaim_icq.c @ 2231:8c4ff1a368bd

[gaim-migrate @ 2241] blue:~/gaim/app/src/protocols $ ./gtk icq: 0 irc: 0 jabber: 52 msn: 0 napster: 0 oscar: 7 toc: 17 yahoo: 0 zephyr: 1 committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 07 Sep 2001 08:09:22 +0000
parents 3a6fd1e8f00a
children f5bf315e6104
comparison
equal deleted inserted replaced
2230:cfc9abe45db2 2231:8c4ff1a368bd
1 #include <gtk/gtk.h>
2 #include <string.h> 1 #include <string.h>
3 #include <stdlib.h> 2 #include <stdlib.h>
4 #include "icq.h" /* well, we're doing ICQ, right? */ 3 #include "icq.h" /* well, we're doing ICQ, right? */
5 #include "multi.h" /* needed for gaim_connection */ 4 #include "multi.h" /* needed for gaim_connection */
6 #include "prpl.h" /* needed for prpl */ 5 #include "prpl.h" /* needed for prpl */
17 #define USEROPT_NICK 0 16 #define USEROPT_NICK 0
18 17
19 struct icq_data { 18 struct icq_data {
20 icq_Link *link; 19 icq_Link *link;
21 int cur_status; 20 int cur_status;
22 GSList *thru_serv;
23 }; 21 };
24 22
25 static guint ack_timer = 0; 23 static guint ack_timer = 0;
26 24
27 static char *icq_name() { 25 static char *icq_name() {
324 struct icq_data *id = (struct icq_data *)gc->proto_data; 322 struct icq_data *id = (struct icq_data *)gc->proto_data;
325 323
326 icq_Logout(id->link); 324 icq_Logout(id->link);
327 icq_Disconnect(id->link); 325 icq_Disconnect(id->link);
328 icq_ICQLINKDelete(id->link); 326 icq_ICQLINKDelete(id->link);
329 g_slist_free(id->thru_serv);
330 g_free(id); 327 g_free(id);
331 } 328 }
332 329
333 static int icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int away) { 330 static int icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int flags) {
334 if (!away && (strlen(msg) > 0)) { 331 if (!(flags & IM_FLAG_AWAY) && (strlen(msg) > 0)) {
335 struct icq_data *id = (struct icq_data *)gc->proto_data; 332 struct icq_data *id = (struct icq_data *)gc->proto_data;
336 GSList *l = id->thru_serv;
337 long w = atol(who); 333 long w = atol(who);
338 while (l) { 334 icq_SendMessage(id->link, w, msg,
339 if (w == (long)l->data) 335 (flags & IM_FLAG_CHECKBOX) ? ICQ_SEND_THRUSERVER : ICQ_SEND_BESTWAY);
340 break;
341 l = l->next;
342 }
343 icq_SendMessage(id->link, w, msg, l ? ICQ_SEND_THRUSERVER : ICQ_SEND_BESTWAY);
344 } 336 }
345 return 0; 337 return 0;
346 } 338 }
347 339
348 static void icq_keepalive(struct gaim_connection *gc) { 340 static void icq_keepalive(struct gaim_connection *gc) {
473 m = g_list_append(m, "Invisible"); 465 m = g_list_append(m, "Invisible");
474 466
475 return m; 467 return m;
476 } 468 }
477 469
478 static void toggle_thru_serv(GtkToggleButton *button, struct conversation *c)
479 {
480 struct gaim_connection *gc = gtk_object_get_user_data(GTK_OBJECT(button));
481 struct icq_data *id = gc->proto_data;
482 GSList *l = id->thru_serv;
483 long who = atol(c->name);
484
485 while (l) {
486 if (who == (long)l->data)
487 break;
488 l = l->next;
489 }
490 if (l)
491 id->thru_serv = g_slist_remove(id->thru_serv, (void *)who);
492 else
493 id->thru_serv = g_slist_append(id->thru_serv, (void *)who);
494 }
495
496 static void icq_insert_convo(struct gaim_connection *gc, struct conversation *c)
497 {
498 GtkWidget *button;
499 struct icq_data *id = gc->proto_data;
500 GSList *l = id->thru_serv;
501 long who = atol(c->name);
502
503 button = gtk_check_button_new_with_label("Send message through server");
504 gtk_box_pack_start(GTK_BOX(c->lbox), button, FALSE, FALSE, 5);
505 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_thru_serv), c);
506 gtk_object_set_user_data(GTK_OBJECT(button), gc);
507 while (l) {
508 if (who == (long)l->data)
509 break;
510 l = l->next;
511 }
512 if (l)
513 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
514 gtk_widget_show(button);
515 }
516
517 static void icq_remove_convo(struct gaim_connection *gc, struct conversation *c)
518 {
519 while (GTK_BOX(c->lbox)->children)
520 gtk_container_remove(GTK_CONTAINER(c->lbox),
521 ((GtkBoxChild *)GTK_BOX(c->lbox)->children->data)->widget);
522 }
523
524 static struct prpl *my_protocol = NULL; 470 static struct prpl *my_protocol = NULL;
525 471
526 void icq_init(struct prpl *ret) { 472 void icq_init(struct prpl *ret) {
527 ret->protocol = PROTO_ICQ; 473 ret->protocol = PROTO_ICQ;
474 ret->checkbox = "Send message through server";
528 ret->name = icq_name; 475 ret->name = icq_name;
529 ret->list_icon = icq_list_icon; 476 ret->list_icon = icq_list_icon;
530 ret->away_states = icq_away_states; 477 ret->away_states = icq_away_states;
531 ret->buddy_menu = icq_buddy_menu; 478 ret->buddy_menu = icq_buddy_menu;
532 ret->user_opts = icq_user_opts; 479 ret->user_opts = icq_user_opts;
533 ret->insert_convo = icq_insert_convo;
534 ret->remove_convo = icq_remove_convo;
535 ret->login = icq_login; 480 ret->login = icq_login;
536 ret->close = icq_close; 481 ret->close = icq_close;
537 ret->send_im = icq_send_msg; 482 ret->send_im = icq_send_msg;
538 ret->add_buddy = icq_add_buddy; 483 ret->add_buddy = icq_add_buddy;
539 ret->add_buddies = icq_add_buddies; 484 ret->add_buddies = icq_add_buddies;