Mercurial > pidgin
changeset 2009:ac9dd6b00b34
[gaim-migrate @ 2019]
different way of specifying offline messages. Jeremy, I'm just about to look at your patch
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 13 Jun 2001 21:28:03 +0000 |
parents | 6f049002d963 |
children | dff412b306b8 |
files | plugins/yay/outgoing.c plugins/yay/yay.c plugins/yay/yay.h |
diffstat | 3 files changed, 89 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/yay/outgoing.c Wed Jun 13 07:26:16 2001 +0000 +++ b/plugins/yay/outgoing.c Wed Jun 13 21:28:03 2001 +0000 @@ -115,6 +115,29 @@ return 0; ret = yahoo_write_cmd(session, conn, YAHOO_SERVICE_MESSAGE, + active_id ? active_id : session->name, buf, 0); + g_free(buf); + + return ret; +} + +int yahoo_send_message_offline(struct yahoo_session *session, const char *active_id, + const char *user, const char *msg) +{ + struct yahoo_conn *conn; + char *buf; + int ret; + + if (!session || !user || !msg) + return 0; + + if (!(conn = yahoo_getconn_type(session, YAHOO_CONN_TYPE_MAIN))) + return 0; + + if (!(buf = g_strconcat(user, ",", msg, NULL))) + return 0; + + ret = yahoo_write_cmd(session, conn, YAHOO_SERVICE_MESSAGE, active_id ? active_id : session->name, buf, YAHOO_MESSAGE_SEND); g_free(buf);
--- a/plugins/yay/yay.c Wed Jun 13 07:26:16 2001 +0000 +++ b/plugins/yay/yay.c Wed Jun 13 21:28:03 2001 +0000 @@ -71,6 +71,7 @@ char *active_id; GList *conns; gboolean logged_in; + GSList *offline; }; static char *yahoo_name() { @@ -431,6 +432,10 @@ static void yahoo_close(struct gaim_connection *gc) { struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; + while (yd->offline) { + g_free(yd->offline->data); + yd->offline = g_slist_remove(yd->offline, yd->offline->data); + } g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); g_hash_table_destroy(yd->hash); yahoo_disconnect(yd->sess); @@ -440,10 +445,20 @@ static void yahoo_send_im(struct gaim_connection *gc, char *who, char *message, int away) { struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; + GSList *l = yd->offline; if (away || !strlen(message)) return; - yahoo_send_message(yd->sess, yd->active_id, who, message); + while (l) { + if (!strcmp(who, l->data)) + break; + l = l->next; + } + + if (l) + yahoo_send_message(yd->sess, yd->active_id, who, message); + else + yahoo_send_message_offline(yd->sess, yd->active_id, who, message); } static void yahoo_set_away(struct gaim_connection *gc, char *state, char *msg) { @@ -726,6 +741,52 @@ yahoo_protoopt_button("Notify me of new Yahoo! Mail", user, USEROPT_MAIL, vbox); } +static void toggle_offline(GtkToggleButton *button, struct conversation *c) +{ + struct gaim_connection *gc = gtk_object_get_user_data(GTK_OBJECT(button)); + struct yahoo_data *yd = gc->proto_data; + GSList *l = yd->offline; + + while (l) { + if (!strcmp(c->name, l->data)) + break; + l = l->next; + } + if (l) { + g_free(l->data); + yd->offline = g_slist_remove(yd->offline, l->data); + } else + yd->offline = g_slist_append(yd->offline, g_strdup(c->name)); +} + +static void yahoo_insert_convo(struct gaim_connection *gc, struct conversation *c) +{ + GtkWidget *button; + struct yahoo_data *yd = gc->proto_data; + GSList *l = yd->offline; + struct buddy *b = find_buddy(gc, c->name); + + button = gtk_check_button_new_with_label("Send offline message"); + gtk_box_pack_start(GTK_BOX(c->lbox), button, FALSE, FALSE, 5); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_offline), c); + gtk_object_set_user_data(GTK_OBJECT(button), gc); + while (l) { + if (!strcmp(c->name, l->data)) + break; + l = l->next; + } + if (l || (b && !b->present)) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); + gtk_widget_show(button); +} + +static void yahoo_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; void Yahoo_init(struct prpl *ret) { @@ -738,6 +799,8 @@ ret->do_action = yahoo_do_action; ret->buddy_menu = yahoo_buddy_menu; ret->user_opts = yahoo_user_opts; + ret->insert_convo = yahoo_insert_convo; + ret->remove_convo = yahoo_remove_convo; ret->login = yahoo_login; ret->close = yahoo_close; ret->send_im = yahoo_send_im;
--- a/plugins/yay/yay.h Wed Jun 13 07:26:16 2001 +0000 +++ b/plugins/yay/yay.h Wed Jun 13 21:28:03 2001 +0000 @@ -73,6 +73,8 @@ int yahoo_activate_id(struct yahoo_session *session, char *id); int yahoo_deactivate_id(struct yahoo_session *session, char *id); int yahoo_send_message(struct yahoo_session *session, const char *id, const char *user, const char *msg); +int yahoo_send_message_offline(struct yahoo_session *session, const char *id, + const char *user, const char *msg); int yahoo_away(struct yahoo_session *session, enum yahoo_status stats, char *msg); int yahoo_back(struct yahoo_session *session, enum yahoo_status stats, char *msg); int yahoo_ping(struct yahoo_session *session);