# HG changeset patch # User Eric Warmenhoven # Date 973070047 0 # Node ID 8a4290984d1e89ad7a0ae1508f40a066b89782b4 # Parent ab8ef0fc1417df9e29603a6fefd68034890624d7 [gaim-migrate @ 1052] lalala committer: Tailor Script diff -r ab8ef0fc1417 -r 8a4290984d1e plugins/oscar.c --- a/plugins/oscar.c Wed Nov 01 09:12:57 2000 +0000 +++ b/plugins/oscar.c Wed Nov 01 09:14:07 2000 +0000 @@ -43,8 +43,11 @@ #include "aim.h" #include "gnome_applet_mgr.h" -#include "pixmaps/cancel.xpm" -#include "pixmaps/ok.xpm" +#include "pixmaps/admin_icon.xpm" +#include "pixmaps/aol_icon.xpm" +#include "pixmaps/away_icon.xpm" +#include "pixmaps/dt_icon.xpm" +#include "pixmaps/free_icon.xpm" int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE | AIM_CAPS_VOICE | AIM_CAPS_IMIMAGE | AIM_CAPS_BUDDYICON; @@ -159,10 +162,6 @@ static int gaim_parse_buddyrights(struct aim_session_t *, struct command_rx_struct *, ...); static int gaim_parse_locerr (struct aim_session_t *, struct command_rx_struct *, ...); -static int gaim_directim_incoming(struct aim_session_t *, struct command_rx_struct *, ...); -static int gaim_directim_typing (struct aim_session_t *, struct command_rx_struct *, ...); -static int gaim_directim_initiate(struct aim_session_t *, struct command_rx_struct *, ...); - static char *msgerrreason[] = { "Invalid error", "Invalid SNAC", @@ -219,16 +218,7 @@ if (aim_get_command(odata->sess, conn) >= 0) { aim_rxdispatch(odata->sess); } else { - if (conn->type == AIM_CONN_TYPE_RENDEZVOUS && - conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) { - struct conversation *cnv = - find_conversation(((struct aim_directim_priv *)conn->priv)->sn); - debug_print("connection error for directim\n"); - if (cnv) { - make_direct(cnv, FALSE, NULL, 0); - } - aim_conn_kill(odata->sess, &conn); - } else if ((conn->type == AIM_CONN_TYPE_BOS) || + if ((conn->type == AIM_CONN_TYPE_BOS) || !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { debug_print(_("major connection error\n")); hide_login_progress(gc, _("Disconnected.")); @@ -269,6 +259,7 @@ char buf[256]; struct gaim_connection *gc = new_gaim_conn(PROTO_OSCAR, user->username, user->password); struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); + gc->user = user; sprintf(debug_buff, _("Logging in %s\n"), user->username); debug_print(debug_buff); @@ -325,7 +316,17 @@ void oscar_close(struct gaim_connection *gc) { struct oscar_data *odata = (struct oscar_data *)gc->proto_data; + GSList *c = odata->oscar_chats; + struct chat_connection *n; if (gc->protocol != PROTO_OSCAR) return; + + while (c) { + n = (struct chat_connection *)c->data; + gdk_input_remove(n->inpa); + g_free(n->name); + c = g_slist_remove(c, n); + g_free(n); + } if (gc->inpa > 0) gdk_input_remove(gc->inpa); if (odata->cnpa > 0) @@ -350,19 +351,22 @@ switch (sess->logininfo.errorcode) { case 0x18: /* connecting too frequently */ - do_error_dialog(_("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."), _("Gaim - Error")); + hide_login_progress(gc, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); plugin_event(event_error, (void *)983, 0, 0, 0); break; case 0x05: /* Incorrect nick/password */ - do_error_dialog(_("Incorrect nickname or password."), _("Gaim - Error")); + hide_login_progress(gc, _("Incorrect nickname or password.")); plugin_event(event_error, (void *)980, 0, 0, 0); break; case 0x1c: /* client too old */ - do_error_dialog(_("The client version you are using is too old. Please upgrade at http://www.marko.net/gaim/"), _("Gaim - Error")); + hide_login_progress(gc, _("The client version you are using is too old. Please upgrade at http://www.marko.net/gaim/")); plugin_event(event_error, (void *)989, 0, 0, 0); break; + default: + hide_login_progress(gc, _("Authentication Failed")); + break; } sprintf(debug_buff, "Login Error Code 0x%04x\n", sess->logininfo.errorcode); @@ -373,8 +377,6 @@ #ifdef USE_APPLET set_user_state(offline); #endif - gdk_input_remove(gc->inpa); - hide_login_progress(gc, _("Authentication Failed")); signoff(gc); return 0; } @@ -483,7 +485,6 @@ serv_got_joined_chat(gc, id++, aim_chat_getname(command->conn)); break; case AIM_CONN_TYPE_RENDEZVOUS: - aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); break; default: /* huh? */ sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type); @@ -581,6 +582,7 @@ struct aim_userinfo_s *info; time_t time_idle; int type = 0; + struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); va_list ap; va_start(ap, command); @@ -604,7 +606,7 @@ } else time_idle = 0; - serv_got_update(info->sn, 1, info->warnlevel/10, info->onlinesince, + serv_got_update(gc, info->sn, 1, info->warnlevel/10, info->onlinesince, time_idle, type, info->capabilities); return 1; @@ -614,99 +616,17 @@ struct command_rx_struct *command, ...) { char *sn; va_list ap; + struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); va_start(ap, command); sn = va_arg(ap, char *); va_end(ap); - serv_got_update(sn, 0, 0, 0, 0, 0, 0); + serv_got_update(gc, sn, 0, 0, 0, 0, 0, 0); return 1; } -static void accept_directim(GtkWidget *w, GtkWidget *m) -{ - struct aim_conn_t *newconn; - struct aim_directim_priv *priv; - struct gaim_connection *gc; - struct oscar_data *odata; - int watcher; - - priv = (struct aim_directim_priv *)gtk_object_get_user_data(GTK_OBJECT(m)); - gc = (struct gaim_connection *)gtk_object_get_user_data(GTK_OBJECT(w)); - odata = (struct oscar_data *)gc->proto_data; - gtk_widget_destroy(m); - - if (!(newconn = aim_directim_connect(odata->sess, odata->conn, priv))) { - debug_print("imimage: could not connect\n"); - return; - } - - aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); - aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_directim_typing, 0); - - watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, - oscar_callback, newconn); - - sprintf(debug_buff, "DirectIM: connected to %s\n", priv->sn); - debug_print(debug_buff); - - serv_got_imimage(gc, priv->sn, priv->cookie, priv->ip, newconn, watcher); - - g_free(priv); -} - -static void cancel_directim(GtkWidget *w, GtkWidget *m) -{ - gtk_widget_destroy(m); -} - -static void directim_dialog(struct gaim_connection *gc, struct aim_directim_priv *priv) -{ - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *yes; - GtkWidget *no; - char buf[BUF_LONG]; - - window = gtk_window_new(GTK_WINDOW_DIALOG); - gtk_window_set_title(GTK_WINDOW(window), _("Accept Direct IM?")); - gtk_window_set_wmclass(GTK_WINDOW(window), "directim", "Gaim"); - gtk_widget_realize(window); - aol_icon(window->window); - gtk_object_set_user_data(GTK_OBJECT(window), (void *)priv); - - vbox = gtk_vbox_new(TRUE, 5); - gtk_container_add(GTK_CONTAINER(window), vbox); - gtk_widget_show(vbox); - - sprintf(buf, _("%s has requested to directly connect to your computer. " - "Do you accept?"), priv->sn); - label = gtk_label_new(buf); - gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); - gtk_widget_show(label); - - hbox = gtk_hbox_new(TRUE, 10); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); - gtk_widget_show(hbox); - - yes = picture_button(window, _("Accept"), ok_xpm); - gtk_box_pack_start(GTK_BOX(hbox), yes, FALSE, FALSE, 5); - gtk_object_set_user_data(GTK_OBJECT(yes), gc); - - no = picture_button(window, _("Cancel"), cancel_xpm); - gtk_box_pack_end(GTK_BOX(hbox), no, FALSE, FALSE, 5); - - gtk_signal_connect(GTK_OBJECT(yes), "clicked", - GTK_SIGNAL_FUNC(accept_directim), window); - gtk_signal_connect(GTK_OBJECT(no), "clicked", - GTK_SIGNAL_FUNC(cancel_directim), window); - - gtk_widget_show(window); -} - int gaim_parse_incoming_im(struct aim_session_t *sess, struct command_rx_struct *command, ...) { int channel; @@ -763,20 +683,6 @@ /* bah */ } else if (rendtype & AIM_CAPS_IMIMAGE) { /* DirectIM stuff */ - struct aim_directim_priv *priv, *priv2; - - userinfo = va_arg(ap, struct aim_userinfo_s *); - priv = va_arg(ap, struct aim_directim_priv *); - va_end(ap); - - sprintf(debug_buff, "DirectIM request from %s (%s)\n", userinfo->sn, priv->ip); - debug_print(debug_buff); - - priv2 = g_new0(struct aim_directim_priv, 1); - strcpy(priv2->cookie, priv->cookie); - strcpy(priv2->sn, priv->sn); - strcpy(priv2->ip, priv->ip); - directim_dialog(gc, priv2); } else { sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); debug_print(debug_buff); @@ -952,9 +858,9 @@ while (i < exchangecount) { sprintf(debug_buff, "chat info: \t\t%x: %s (%s/%s)\n", exchanges[i].number, - exchanges[i].name, - exchanges[i].charset1, - exchanges[i].lang1); + exchanges[i].name ? exchanges[i].name : "NULL", + exchanges[i].charset1 ? exchanges[i].charset1 : "NULL", + exchanges[i].lang1 ? exchanges[i].lang1 : "NULL"); debug_print(debug_buff); i++; } @@ -1162,34 +1068,14 @@ aim_bos_setprofile(sess, command->conn, gc->user_info, NULL, gaim_caps); aim_bos_reqbuddyrights(sess, command->conn); - if (mainwindow) - gtk_widget_hide(mainwindow); - show_buddy_list(); - -#ifdef USE_APPLET - if (general_options & OPT_GEN_APP_BUDDY_SHOW) { - refresh_buddy_window(); - createOnlinePopup(); - applet_buddy_show = TRUE; - } else { - gtk_widget_hide(blist); - applet_buddy_show = FALSE; - } - set_user_state(online); -#else - refresh_buddy_window(); -#endif - + account_online(gc->user, gc); /* this is an awkward hack */ serv_finish_login(gc); - gaim_setup(gc); if (bud_list_cache_exists(gc)) do_import(NULL, gc); debug_print("buddy list loaded\n"); - setup_buddy_chats(); - aim_addicbmparam(sess, command->conn); aim_bos_reqicbmparaminfo(sess, command->conn); @@ -1252,80 +1138,6 @@ return 1; } -int gaim_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - char *sn = NULL, *msg = NULL; - struct aim_conn_t *conn; - struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); - - va_start(ap, command); - conn = va_arg(ap, struct aim_conn_t *); - sn = va_arg(ap, char *); - msg = va_arg(ap, char *); - va_end(ap); - - sprintf(debug_buff, "Got DirectIM message from %s\n", sn); - debug_print(debug_buff); - - serv_got_im(gc, sn, msg, 0); - - return 1; -} - -/* this is such a f*cked up function */ -int gaim_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - struct aim_directim_priv *priv; - struct aim_conn_t *newconn; - struct conversation *cnv; - int watcher; - - va_start(ap, command); - newconn = va_arg(ap, struct aim_conn_t *); - va_end(ap); - - priv = (struct aim_directim_priv *)newconn->priv; - - sprintf(debug_buff, "DirectIM: initiate success to %s\n", priv->sn); - debug_print(debug_buff); - - cnv = find_conversation(priv->sn); - gdk_input_remove(cnv->watcher); - watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, - oscar_callback, newconn); - make_direct(cnv, TRUE, newconn, watcher); - - aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); - aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_directim_typing, 0); - - return 1; -} - -int gaim_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...) { - va_list ap; - char *sn; - - va_start(ap, command); - sn = va_arg(ap, char *); - va_end(ap); - - /* I had to leave this. It's just too funny. It reminds me of my sister. */ - sprintf(debug_buff, "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); - debug_print(debug_buff); - - return 1; -} - -void oscar_do_directim(struct gaim_connection *gc, char *name) { - struct oscar_data *odata = (struct oscar_data *)gc->proto_data; - struct aim_conn_t *newconn = aim_directim_initiate(odata->sess, odata->conn, NULL, name); - struct conversation *cnv = find_conversation(name); /* this will never be null because - it just got set up */ - cnv->conn = newconn; - cnv->watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, oscar_callback, newconn); - aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, gaim_directim_initiate, 0); -} - static void oscar_keepalive(struct gaim_connection *gc) { struct oscar_data *odata = (struct oscar_data *)gc->proto_data; aim_flap_nop(odata->sess, odata->conn); @@ -1337,16 +1149,10 @@ static void oscar_send_im(struct gaim_connection *gc, char *name, char *message, int away) { struct oscar_data *odata = (struct oscar_data *)gc->proto_data; - struct conversation *cnv = find_conversation(name); - if (cnv && cnv->is_direct) { - debug_printf("Sending DirectIM to %s\n", name); - aim_send_im_direct(odata->sess, cnv->conn, message); - } else { - if (away) - aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_AWAY, message); - else - aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_ACK, message); - } + if (away) + aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_AWAY, message); + else + aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_ACK, message); } static void oscar_get_info(struct gaim_connection *g, char *name) { @@ -1524,9 +1330,53 @@ aim_chat_send_im(odata->sess, cn, message); } +static char **oscar_list_icon(int uc) { + if (uc & UC_UNAVAILABLE) + return (char **)away_icon_xpm; + if (uc & UC_AOL) + return (char **)aol_icon_xpm; + if (uc & UC_NORMAL) + return (char **)free_icon_xpm; + if (uc & UC_ADMIN) + return (char **)admin_icon_xpm; + if (uc & UC_UNCONFIRMED) + return (char **)dt_icon_xpm; + return NULL; +} + +static void oscar_info(GtkObject *obj, char *who) { + struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(obj); + serv_get_info(gc, who); +} + +static void oscar_away_msg(GtkObject *obj, char *who) { + struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(obj); + serv_get_away_msg(gc, who); +} + +static void oscar_action_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) { + GtkWidget *button; + + button = gtk_menu_item_new_with_label(_("Get Info")); + gtk_signal_connect(GTK_OBJECT(button), "activate", + GTK_SIGNAL_FUNC(oscar_info), who); + gtk_object_set_user_data(GTK_OBJECT(button), gc); + gtk_menu_append(GTK_MENU(menu), button); + gtk_widget_show(button); + + button = gtk_menu_item_new_with_label(_("Get Away Msg")); + gtk_signal_connect(GTK_OBJECT(button), "activate", + GTK_SIGNAL_FUNC(oscar_away_msg), who); + gtk_object_set_user_data(GTK_OBJECT(button), gc); + gtk_menu_append(GTK_MENU(menu), button); + gtk_widget_show(button); +} + void oscar_init(struct prpl *ret) { ret->protocol = PROTO_OSCAR; ret->name = oscar_name; + ret->list_icon = oscar_list_icon; + ret->action_menu = oscar_action_menu; ret->login = oscar_login; ret->close = oscar_close; ret->send_im = oscar_send_im; @@ -1544,6 +1394,9 @@ ret->remove_buddy = oscar_remove_buddy; ret->add_permit = NULL; /* Oscar's permit/deny stuff is messed up */ ret->add_deny = NULL; /* at least, i can't figure it out :-P */ + ret->rem_permit = NULL; + ret->rem_deny = NULL; + ret->set_permit_deny = NULL; ret->warn = oscar_warn; ret->accept_chat = NULL; /* oscar doesn't have accept, it just joins */ ret->join_chat = oscar_join_chat;