diff plugins/icq/gaim_icq.c @ 1898:73d73939f698

[gaim-migrate @ 1908] this is part one of three. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 28 May 2001 03:36:04 +0000
parents a02584b98823
children 8ed70631ed15
line wrap: on
line diff
--- a/plugins/icq/gaim_icq.c	Fri May 25 23:07:22 2001 +0000
+++ b/plugins/icq/gaim_icq.c	Mon May 28 03:36:04 2001 +0000
@@ -19,6 +19,7 @@
 struct icq_data {
 	ICQLINK *link;
 	int cur_status;
+	GSList *thru_serv;
 };
 
 static guint ack_timer = 0;
@@ -298,15 +299,22 @@
 	icq_Logout(id->link);
 	icq_Disconnect(id->link);
 	icq_ICQLINKDelete(id->link);
+	g_slist_free(id->thru_serv);
 	g_free(id);
 }
 
-static struct prpl *my_protocol = NULL;
-
 static void icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int away) {
-	struct icq_data *id = (struct icq_data *)gc->proto_data;
-	if (!away && (strlen(msg) > 0))
-		icq_SendMessage(id->link, atol(who), msg, ICQ_SEND_BESTWAY);
+	if (!away && (strlen(msg) > 0)) {
+		struct icq_data *id = (struct icq_data *)gc->proto_data;
+		GSList *l = id->thru_serv;
+		long w = atol(who);
+		while (l) {
+			if (w == (long)l->data)
+				break;
+			l = l->next;
+		}
+		icq_SendMessage(id->link, w, msg, l ? ICQ_SEND_THRUSERVER : ICQ_SEND_BESTWAY);
+	}
 }
 
 static void icq_keepalive(struct gaim_connection *gc) {
@@ -471,6 +479,44 @@
 	return m;
 }
 
+static void toggle_thru_serv(GtkToggleButton *button, struct conversation *c)
+{
+	struct gaim_connection *gc = gtk_object_get_user_data(GTK_OBJECT(button));
+	struct icq_data *id = gc->proto_data;
+	GSList *l = id->thru_serv;
+	long who = atol(c->name);
+
+	while (l) {
+		if (who == (long)l->data)
+			break;
+		l = l->next;
+	}
+	if (l)
+		id->thru_serv = g_slist_remove(id->thru_serv, (void *)who);
+	else
+		id->thru_serv = g_slist_append(id->thru_serv, (void *)who);
+}
+
+static void icq_insert_convo(struct gaim_connection *gc, struct conversation *c)
+{
+	GtkWidget *button;
+
+	button = gtk_check_button_new_with_label("Send message through server");
+	gtk_box_pack_start(GTK_BOX(c->lbox), button, FALSE, FALSE, 5);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_thru_serv), c);
+	gtk_object_set_user_data(GTK_OBJECT(button), gc);
+	gtk_widget_show(button);
+}
+
+static void icq_remove_convo(struct gaim_connection *gc, struct conversation *c)
+{
+	while (GTK_BOX(c->lbox)->children)
+		gtk_container_remove(GTK_CONTAINER(c->lbox),
+				     ((GtkBoxChild *)GTK_BOX(c->lbox)->children->data)->widget);
+}
+
+static struct prpl *my_protocol = NULL;
+
 static void icq_init(struct prpl *ret) {
 	ret->protocol = PROTO_ICQ;
 	ret->name = icq_name;
@@ -478,6 +524,8 @@
 	ret->away_states = icq_away_states;
 	ret->buddy_menu = icq_buddy_menu;
 	ret->user_opts = icq_user_opts;
+	ret->insert_convo = icq_insert_convo;
+	ret->remove_convo = icq_remove_convo;
 	ret->login = icq_login;
 	ret->close = icq_close;
 	ret->send_im = icq_send_msg;