Mercurial > pidgin
changeset 1401:bf041349b11e
[gaim-migrate @ 1411]
abliity to set accounts away independent of each other. also allows for all the other states (like in yahoo and icq). probably breaks MSN, so don't use it until rob fixes it.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 10 Jan 2001 22:15:24 +0000 |
parents | 476b24cdfa32 |
children | 65f4a0325022 |
files | plugins/icq/gaim_icq.c plugins/yay/yay.c src/away.c src/buddy.c src/conversation.c src/gaim.h src/idle.c src/multi.c src/oscar.c src/prpl.h src/server.c src/toc.c |
diffstat | 12 files changed, 321 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/icq/gaim_icq.c Wed Jan 10 19:56:39 2001 +0000 +++ b/plugins/icq/gaim_icq.c Wed Jan 10 22:15:24 2001 +0000 @@ -314,14 +314,26 @@ icq_ContactRemove(id->link, atol(who)); } -static void icq_set_away(struct gaim_connection *gc, char *msg) { +static void icq_set_away(struct gaim_connection *gc, char *state, char *msg) { struct icq_data *id = (struct icq_data *)gc->proto_data; - if (msg && msg[0]) { + if (!strcmp(state, "Online")) + icq_ChangeStatus(id->link, STATUS_ONLINE); + else if (!strcmp(state, "Away")) + icq_ChangeStatus(id->link, STATUS_AWAY); + else if (!strcmp(state, "Do Not Disturb")) + icq_ChangeStatus(id->link, STATUS_DND); + else if (!strcmp(state, "Not Available")) icq_ChangeStatus(id->link, STATUS_NA); - } else { - icq_ChangeStatus(id->link, STATUS_ONLINE); - } + else if (!strcmp(state, "Occupied")) + icq_ChangeStatus(id->link, STATUS_OCCUPIED); + else if (!strcmp(state, "Free For Chat")) + icq_ChangeStatus(id->link, STATUS_FREE_CHAT); + else if (!strcmp(state, "Invisible")) + icq_ChangeStatus(id->link, STATUS_INVISIBLE); + else if (!strcmp(state, GAIM_AWAY_CUSTOM)) + /* we have to do this even though we don't have a custom state */ + icq_ChangeStatus(id->link, STATUS_NA); } static char **icq_list_icon(int uc) { @@ -411,10 +423,23 @@ gtk_widget_show(hbox); } +static GList *icq_away_states() { + GList *m = NULL; + + m = g_list_append(m, "Online"); + m = g_list_append(m, "Away"); + m = g_list_append(m, "Do Not Disturb"); + m = g_list_append(m, "Not Available"); + m = g_list_append(m, "Occupied"); + m = g_list_append(m, "Free For Chat"); + m = g_list_append(m, "Invisible"); +} + static void icq_init(struct prpl *ret) { ret->protocol = PROTO_ICQ; ret->name = icq_name; ret->list_icon = icq_list_icon; + ret->away_states = icq_away_states; ret->action_menu = icq_action_menu; ret->user_opts = icq_user_opts; ret->login = icq_login;
--- a/plugins/yay/yay.c Wed Jan 10 19:56:39 2001 +0000 +++ b/plugins/yay/yay.c Wed Jan 10 22:15:24 2001 +0000 @@ -299,12 +299,47 @@ yahoo_cmd_msg(yd->ctxt, gc->username, who, message); } -static void yahoo_set_away(struct gaim_connection *gc, char *msg) { +static void yahoo_set_away(struct gaim_connection *gc, char *state, char *msg) { struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; if (msg) { yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_CUSTOM, msg); yd->current_status = YAHOO_STATUS_CUSTOM; + } else if (state) { + if (!strcmp(state, "Available")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_AVAILABLE, msg); + yd->current_status = YAHOO_STATUS_AVAILABLE; + } else if (!strcmp(state, "Be Right Back")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_BRB, msg); + yd->current_status = YAHOO_STATUS_BRB; + } else if (!strcmp(state, "Busy")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_BUSY, msg); + yd->current_status = YAHOO_STATUS_BUSY; + } else if (!strcmp(state, "Not At Home")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_NOTATHOME, msg); + yd->current_status = YAHOO_STATUS_NOTATHOME; + } else if (!strcmp(state, "Not At Desk")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_NOTATDESK, msg); + yd->current_status = YAHOO_STATUS_NOTATDESK; + } else if (!strcmp(state, "Not In Office")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_NOTINOFFICE, msg); + yd->current_status = YAHOO_STATUS_NOTINOFFICE; + } else if (!strcmp(state, "On Phone")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_ONPHONE, msg); + yd->current_status = YAHOO_STATUS_ONPHONE; + } else if (!strcmp(state, "On Vacation")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_ONVACATION, msg); + yd->current_status = YAHOO_STATUS_ONVACATION; + } else if (!strcmp(state, "Out To Lunch")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_OUTTOLUNCH, msg); + yd->current_status = YAHOO_STATUS_OUTTOLUNCH; + } else if (!strcmp(state, "Stepped Out")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_STEPPEDOUT, msg); + yd->current_status = YAHOO_STATUS_STEPPEDOUT; + } else if (!strcmp(state, "Invisible")) { + yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_INVISIBLE, msg); + yd->current_status = YAHOO_STATUS_INVISIBLE; + } } else if (gc->is_idle) { yahoo_cmd_set_away_mode(yd->ctxt, YAHOO_STATUS_IDLE, NULL); yd->current_status = YAHOO_STATUS_IDLE; @@ -399,6 +434,25 @@ gtk_widget_show(button); } +static GList *yahoo_away_states() { + GList *m = NULL; + + m = g_list_append(m, "Available"); + m = g_list_append(m, "Be Right Back"); + m = g_list_append(m, "Busy"); + m = g_list_append(m, "Not At Home"); + m = g_list_append(m, "Not At Desk"); + m = g_list_append(m, "Not In Office"); + m = g_list_append(m, "On Phone"); + m = g_list_append(m, "On Vacation"); + m = g_list_append(m, "Out To Lunch"); + m = g_list_append(m, "Stepped Out"); + m = g_list_append(m, "Invisible"); + m = g_list_append(m, GAIM_AWAY_CUSTOM); + + return m; +} + static struct prpl *my_protocol = NULL; void Yahoo_init(struct prpl *ret) { @@ -406,6 +460,7 @@ ret->protocol = PROTO_YAHOO; ret->name = yahoo_name; ret->list_icon = yahoo_list_icon; + ret->away_states = yahoo_away_states; ret->action_menu = yahoo_action_menu; ret->user_opts = NULL; ret->login = yahoo_login;
--- a/src/away.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/away.c Wed Jan 10 22:15:24 2001 +0000 @@ -34,6 +34,7 @@ #include <gtk/gtk.h> #include "gaim.h" +#include "prpl.h" #include "pixmaps/join.xpm" GtkWidget *imaway = NULL; @@ -59,7 +60,7 @@ plugin_event(event_back, 0, 0, 0, 0); } - serv_set_away(NULL); + serv_set_away_all(NULL); awaymessage = NULL; #ifdef USE_APPLET applet_widget_unregister_callback(APPLET_WIDGET(applet), "away"); @@ -156,7 +157,7 @@ buf2 = g_malloc(strlen(awaymessage->message) * 4 + 1); strncpy_withhtml(buf2, awaymessage->message, strlen(awaymessage->message) * 4 + 1); - serv_set_away(buf2); + serv_set_away_all(buf2); g_free(buf2); gtk_widget_show(imaway); plugin_event(event_away, 0, 0, 0, 0); @@ -187,11 +188,28 @@ save_prefs(); } +static void set_gc_away(GtkObject *obj, struct gaim_connection *gc) +{ + struct away_message *awy = gtk_object_get_user_data(obj); + + if (awy) + serv_set_away(gc, GAIM_AWAY_CUSTOM, awy->message); + else + serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL); +} + +static void set_gc_state(GtkObject *obj, struct gaim_connection *gc) +{ + char *awy = gtk_object_get_user_data(obj); + + serv_set_away(gc, awy, NULL); +} void do_away_menu() { GtkWidget *menuitem; - static GtkWidget *remmenu; + GtkWidget *remmenu; + GtkWidget *submenu, *submenu2; GtkWidget *remitem; GtkWidget *label; GtkWidget *sep; @@ -199,6 +217,9 @@ GtkWidget *list_item; GSList *awy = away_messages; struct away_message *a; + GSList *con = connections; + struct gaim_connection *gc; + int count = 0; #ifdef USE_APPLET remove_applet_away(); @@ -276,19 +297,186 @@ gtk_widget_show(menuitem); gtk_widget_show(sep); - awy = away_messages; + while (con) { + gc = con->data; + if (gc->prpl->away_states && gc->prpl->set_away) + count++; + con = g_slist_next(con); + } + con = connections; + + if (count == 0) { + } else if (count == 1) { + GList *msgs, *tmp; + while (con) { + gc = con->data; + if (gc->prpl->away_states && gc->prpl->set_away) + break; + con = g_slist_next(con); + } + + tmp = msgs = (*gc->prpl->away_states)(); + + if ((g_list_length(msgs) == 1) && !strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { + awy = away_messages; + + while (awy) { + a = (struct away_message *)awy->data; + + menuitem = gtk_menu_item_new_with_label(a->name); + gtk_object_set_user_data(GTK_OBJECT(menuitem), a); + gtk_menu_append(GTK_MENU(awaymenu), menuitem); + gtk_widget_show(menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(do_away_message), a); + + awy = g_slist_next(awy); + } + } else while (msgs) { + awy = away_messages; + + menuitem = gtk_menu_item_new_with_label(msgs->data); + gtk_object_set_user_data(GTK_OBJECT(menuitem), msgs->data); + gtk_menu_append(GTK_MENU(awaymenu), menuitem); + gtk_widget_show(menuitem); + + if (strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(set_gc_state), gc); + } else { + submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); + gtk_widget_show(submenu); + + while (awy) { + a = (struct away_message *)awy->data; + + menuitem = gtk_menu_item_new_with_label(a->name); + gtk_object_set_user_data(GTK_OBJECT(menuitem), a); + gtk_menu_append(GTK_MENU(submenu), menuitem); + gtk_widget_show(menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(set_gc_away), gc); + + awy = g_slist_next(awy); + } + } + msgs = g_list_next(msgs); + } + } else { + while (con) { + char buf[256]; + GList *msgs, *tmp; + gc = con->data; + + if (!gc->prpl->away_states || !gc->prpl->set_away) + continue; - while (awy) { - a = (struct away_message *)awy->data; + g_snprintf(buf, sizeof(buf), "%s (%s)", + gc->username, (*gc->prpl->name)()); + menuitem = gtk_menu_item_new_with_label(buf); + gtk_menu_append(GTK_MENU(awaymenu), menuitem); + gtk_widget_show(menuitem); + + submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); + gtk_widget_show(submenu); + + tmp = msgs = (*gc->prpl->away_states)(); + + if ((g_list_length(msgs) == 1) && + (!strcmp(msgs->data, GAIM_AWAY_CUSTOM))) { + menuitem = gtk_menu_item_new_with_label(_("Back")); + gtk_menu_append(GTK_MENU(submenu), menuitem); + gtk_widget_show(menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(set_gc_away), gc); + + sep = gtk_hseparator_new(); + menuitem = gtk_menu_item_new(); + gtk_menu_append(GTK_MENU(submenu), menuitem); + gtk_container_add(GTK_CONTAINER(menuitem), sep); + gtk_widget_set_sensitive(menuitem, FALSE); + gtk_widget_show(menuitem); + gtk_widget_show(sep); + + awy = away_messages; + + while (awy) { + a = (struct away_message *)awy->data; + + menuitem = gtk_menu_item_new_with_label(a->name); + gtk_object_set_user_data(GTK_OBJECT(menuitem), a); + gtk_menu_append(GTK_MENU(submenu), menuitem); + gtk_widget_show(menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(set_gc_away), gc); - menuitem = gtk_menu_item_new_with_label(a->name); + awy = g_slist_next(awy); + } + } else while (msgs) { + awy = away_messages; + + menuitem = gtk_menu_item_new_with_label(msgs->data); + gtk_object_set_user_data(GTK_OBJECT(menuitem), msgs->data); + gtk_menu_append(GTK_MENU(submenu), menuitem); + gtk_widget_show(menuitem); + + if (strcmp(msgs->data, GAIM_AWAY_CUSTOM)) { + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(set_gc_state), gc); + } else { + submenu2 = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), + submenu2); + gtk_widget_show(submenu2); + + while (awy) { + a = (struct away_message *)awy->data; + + menuitem = gtk_menu_item_new_with_label(a->name); + gtk_object_set_user_data(GTK_OBJECT(menuitem), + a); + gtk_menu_append(GTK_MENU(submenu2), menuitem); + gtk_widget_show(menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), + "activate", + GTK_SIGNAL_FUNC(set_gc_away), + gc); + + awy = g_slist_next(awy); + } + } + msgs = g_list_next(msgs); + } + + g_list_free(tmp); + + con = g_slist_next(con); + } + + menuitem = gtk_menu_item_new_with_label(_("Set All Away")); gtk_menu_append(GTK_MENU(awaymenu), menuitem); gtk_widget_show(menuitem); - gtk_signal_connect(GTK_OBJECT(menuitem), "activate", - GTK_SIGNAL_FUNC(do_away_message), a); + + submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); + gtk_widget_show(submenu); + + awy = away_messages; + + while (awy) { + a = (struct away_message *)awy->data; - awy = g_slist_next(awy); + menuitem = gtk_menu_item_new_with_label(a->name); + gtk_object_set_user_data(GTK_OBJECT(menuitem), a); + gtk_menu_append(GTK_MENU(submenu), menuitem); + gtk_widget_show(menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(do_away_message), a); + awy = g_slist_next(awy); + } } } if (prefs_away_menu) {
--- a/src/buddy.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/buddy.c Wed Jan 10 22:15:24 2001 +0000 @@ -284,6 +284,7 @@ update_keepalive(gc, FALSE); serv_close(gc); redo_buddy_list(); + do_away_menu(); #ifdef USE_APPLET if (connections) set_user_state(online);
--- a/src/conversation.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/conversation.c Wed Jan 10 22:15:24 2001 +0000 @@ -706,7 +706,7 @@ quiet_set(c->link, FALSE); if ((general_options & OPT_GEN_BACK_ON_IM) && awaymessage != NULL) { - do_im_back(); + serv_set_away(c->gc, GAIM_AWAY_CUSTOM, NULL); } gtk_widget_grab_focus(c->entry);
--- a/src/gaim.h Wed Jan 10 19:56:39 2001 +0000 +++ b/src/gaim.h Wed Jan 10 22:15:24 2001 +0000 @@ -593,7 +593,8 @@ extern void serv_get_dir(struct gaim_connection *, char *); extern void serv_set_idle(struct gaim_connection *, int); extern void serv_set_info(struct gaim_connection *, char *); -extern void serv_set_away(char *); +extern void serv_set_away(struct gaim_connection *, char *, char *); +extern void serv_set_all_away(char *); extern void serv_change_passwd(struct gaim_connection *, char *, char *); extern void serv_add_buddy(struct gaim_connection *, char *); extern void serv_add_buddies(struct gaim_connection *, GList *);
--- a/src/idle.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/idle.c Wed Jan 10 22:15:24 2001 +0000 @@ -34,6 +34,7 @@ #include "multi.h" #include "gaim.h" +#include "prpl.h" int auto_is_away = 0; @@ -74,12 +75,12 @@ set_default_away((GtkWidget*)NULL, (gpointer)g_slist_index(away_messages, default_away)); - do_away_message((GtkWidget*)NULL, default_away); + serv_set_away(gc, GAIM_AWAY_CUSTOM, default_away->message); auto_is_away = 1; } else if (auto_is_away == 1 && idle_time < 60 * auto_away) { auto_is_away = 0; if (awaymessage != NULL) - do_im_back((GtkWidget *)NULL, (GtkWidget *)NULL); + serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL); }
--- a/src/multi.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/multi.c Wed Jan 10 22:15:24 2001 +0000 @@ -707,6 +707,7 @@ setup_buddy_chats(); update_connection_dependent_prefs(); + do_away_menu(); redo_convo_menus(); gaim_setup(gc); @@ -717,6 +718,8 @@ away_on_login(opt_away_arg); /* don't do it again */ opt_away = 0; + } else if (awaymessage) { + serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message); } if (opt_away_arg != NULL) { g_free (opt_away_arg);
--- a/src/oscar.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/oscar.c Wed Jan 10 22:15:24 2001 +0000 @@ -1739,7 +1739,7 @@ NULL, gaim_caps); } -static void oscar_set_away(struct gaim_connection *g, char *message) { +static void oscar_set_away(struct gaim_connection *g, char *state, char *message) { struct oscar_data *odata = (struct oscar_data *)g->proto_data; aim_bos_setprofile(odata->sess, odata->conn, g->user->user_info, message, gaim_caps); } @@ -2274,11 +2274,17 @@ open_url(NULL, "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); } +static GList *oscar_away_states() +{ + return g_list_append(NULL, GAIM_AWAY_CUSTOM); +} + void oscar_init(struct prpl *ret) { ret->protocol = PROTO_OSCAR; ret->options = OPT_PROTO_HTML; ret->name = oscar_name; ret->list_icon = oscar_list_icon; + ret->away_states = oscar_away_states; ret->action_menu = oscar_action_menu; ret->user_opts = oscar_user_opts; ret->draw_new_user = oscar_draw_new_user;
--- a/src/prpl.h Wed Jan 10 19:56:39 2001 +0000 +++ b/src/prpl.h Wed Jan 10 22:15:24 2001 +0000 @@ -40,6 +40,8 @@ * plugins can't do (for example, TOC and Oscar and Jabber can do HTML in messages, * but IRC etc can't, so TOC/Oscar/Jabber have _HTML set but not IRC. */ +#define GAIM_AWAY_CUSTOM "Custom" + typedef void (*proto_init)(struct prpl *); struct prpl { @@ -49,6 +51,7 @@ /* returns the XPM associated with the given user class */ char **(* list_icon)(int); + GList *(* away_states)(); /* when UI plugins come, these will have to be reconciled by returning * structs indicating what kinds of information they want displayed. */ @@ -63,7 +66,7 @@ void (* send_im) (struct gaim_connection *, char *who, char *message, int away); void (* set_info) (struct gaim_connection *, char *info); void (* get_info) (struct gaim_connection *, char *who); - void (* set_away) (struct gaim_connection *, char *message); + void (* set_away) (struct gaim_connection *, char *state, char *message); void (* get_away_msg) (struct gaim_connection *, char *who); void (* set_dir) (struct gaim_connection *, char *first, char *middle,
--- a/src/server.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/server.c Wed Jan 10 22:15:24 2001 +0000 @@ -158,7 +158,13 @@ } -void serv_set_away(char *message) +void serv_set_away(struct gaim_connection *gc, char *state, char *message) +{ + if (gc && gc->prpl && gc->prpl->set_away) + (*gc->prpl->set_away)(gc, state, message); +} + +void serv_set_away_all(char *message) { GSList *c = connections; struct gaim_connection *g; @@ -166,7 +172,7 @@ while (c) { g = (struct gaim_connection *)c->data; if (g->prpl && g->prpl->set_away) - (*g->prpl->set_away)(g, message); + (*g->prpl->set_away)(g, GAIM_AWAY_CUSTOM, message); c = c->next; } }
--- a/src/toc.c Wed Jan 10 19:56:39 2001 +0000 +++ b/src/toc.c Wed Jan 10 22:15:24 2001 +0000 @@ -46,7 +46,7 @@ #include "pixmaps/dt_icon.xpm" #include "pixmaps/free_icon.xpm" -#define REVISION "gaim:$Revision: 1393 $" +#define REVISION "gaim:$Revision: 1411 $" #define TYPE_SIGNON 1 #define TYPE_DATA 2 @@ -712,7 +712,7 @@ sflap_send(g, buf, -1, TYPE_DATA); } -static void toc_set_away(struct gaim_connection *g, char *message) +static void toc_set_away(struct gaim_connection *g, char *state, char *message) { char buf[MSG_LEN]; if (message) { @@ -1169,12 +1169,18 @@ open_url(NULL, "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); } +static GList *toc_away_states() +{ + return g_list_append(NULL, GAIM_AWAY_CUSTOM); +} + void toc_init(struct prpl *ret) { ret->protocol = PROTO_TOC; ret->options = OPT_PROTO_HTML; ret->name = toc_name; ret->list_icon = toc_list_icon; + ret->away_states = toc_away_states; ret->action_menu = toc_action_menu; ret->user_opts = toc_user_opts; ret->draw_new_user = toc_draw_new_user;