Mercurial > pidgin
changeset 1500:a054c28735fb
[gaim-migrate @ 1510]
You can now select your active id in yahoo. still need a good way to show what your active id is though.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 24 Feb 2001 09:23:56 +0000 |
parents | de0b946e86a4 |
children | 5c701857ba07 |
files | TODO plugins/yay/yay.c src/prpl.c src/prpl.h |
diffstat | 4 files changed, 110 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/TODO Fri Feb 23 23:58:35 2001 +0000 +++ b/TODO Sat Feb 24 09:23:56 2001 +0000 @@ -1,7 +1,5 @@ --- STUFF FOR 0.11.0 RELEASE --- - Make Yahoo plugin let you have two identities in the same connection - (different from multiple connections) File transfer for IRC? Maybe later? Chat for Yahoo/ICQ File transfer for Yahoo/ICQ/Oscar/Napster
--- a/plugins/yay/yay.c Fri Feb 23 23:58:35 2001 +0000 +++ b/plugins/yay/yay.c Sat Feb 24 09:23:56 2001 +0000 @@ -54,6 +54,7 @@ GHashTable *hash; GtkWidget *email_win; GtkWidget *email_label; + char *active_id; }; static char *yahoo_name() { @@ -306,6 +307,8 @@ } } + yd->active_id = g_strdup(gc->username); + gc->inpa = gdk_input_add(ctxt->sockfd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, yahoo_callback, gc); } @@ -325,13 +328,14 @@ yahoo_cmd_logoff(yd->ctxt); g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); g_hash_table_destroy(yd->hash); + g_free(yd->active_id); g_free(yd); } 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; - yahoo_cmd_msg(yd->ctxt, gc->username, who, message); + yahoo_cmd_msg(yd->ctxt, yd->active_id, who, message); } static void yahoo_set_away(struct gaim_connection *gc, char *state, char *msg) { @@ -437,7 +441,7 @@ } if (group) - yahoo_add_buddy(yd->ctxt, name, gc->username, group, ""); + yahoo_add_buddy(yd->ctxt, name, yd->active_id, group, ""); } static void yahoo_add_buddies(struct gaim_connection *gc, GList *buddies) { @@ -461,7 +465,7 @@ } if (group) - yahoo_remove_buddy(yd->ctxt, name, gc->username, group, ""); + yahoo_remove_buddy(yd->ctxt, name, yd->active_id, group, ""); } static char **yahoo_list_icon(int uc) { @@ -511,6 +515,30 @@ return m; } +static void yahoo_act_id(gpointer data, char *entry) { + struct gaim_connection *gc = data; + struct yahoo_data *yd = gc->proto_data; + + yahoo_cmd_activate_id(yd->ctxt, entry); + if (yd->active_id) + g_free(yd->active_id); + yd->active_id = g_strdup(entry); +} + +static void yahoo_do_action(struct gaim_connection *gc, char *act) { + if (!strcmp(act, "Activate ID")) { + do_prompt_dialog("Activate which ID:", gc, yahoo_act_id, NULL); + } +} + +static GList *yahoo_actions() { + GList *m = NULL; + + m = g_list_append(m, "Activate ID"); + + return m; +} + static struct prpl *my_protocol = NULL; void Yahoo_init(struct prpl *ret) { @@ -519,6 +547,8 @@ ret->name = yahoo_name; ret->list_icon = yahoo_list_icon; ret->away_states = yahoo_away_states; + ret->actions = yahoo_actions; + ret->do_action = yahoo_do_action; ret->buddy_menu = yahoo_buddy_menu; ret->user_opts = NULL; ret->login = yahoo_login;
--- a/src/prpl.c Fri Feb 23 23:58:35 2001 +0000 +++ b/src/prpl.c Sat Feb 24 09:23:56 2001 +0000 @@ -36,6 +36,14 @@ GtkWidget *protomenu = NULL; +struct _prompt { + GtkWidget *window; + GtkWidget *entry; + void (*doit)(void *, char *); + void (*dont)(void *); + void *data; +}; + struct prpl *find_prpl(int prot) { GSList *e = protocols; @@ -159,6 +167,74 @@ gtk_widget_show_all(window); } +static void des_prompt(GtkWidget *w, struct _prompt *p) +{ + if (p->dont) + (p->dont)(p->data); + gtk_widget_destroy(p->window); + g_free(p); +} + +static void act_prompt(GtkWidget *w, struct _prompt *p) +{ + if (p->doit) + (p->doit)(p->data, gtk_entry_get_text(GTK_ENTRY(p->entry))); + gtk_widget_destroy(p->window); +} + +void do_prompt_dialog(const char *text, void *data, void *doit, void *dont) +{ + GtkWidget *window; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *entry; + GtkWidget *button; + struct _prompt *p; + + p = g_new0(struct _prompt, 1); + p->data = data; + p->doit = doit; + p->dont = dont; + + window = gtk_window_new(GTK_WINDOW_DIALOG); + p->window = window; + gtk_window_set_wmclass(GTK_WINDOW(window), "prompt", "Gaim"); + gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE); + gtk_window_set_title(GTK_WINDOW(window), _("Gaim - Prompt")); + gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(des_prompt), p); + gtk_widget_realize(window); + aol_icon(window->window); + + vbox = gtk_vbox_new(FALSE, 5); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); + gtk_container_add(GTK_CONTAINER(window), vbox); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new(text); + gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); + + entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(act_prompt), p); + p->entry = entry; + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + button = picture_button(window, _("Cancel"), cancel_xpm); + gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(des_win), window); + + button = picture_button(window, _("Accept"), ok_xpm); + gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(act_prompt), p); + + gtk_widget_show_all(window); +} + static void delete_reg(gpointer a, gpointer b) { GtkWidget *tmp = regdialog;