Mercurial > pidgin
changeset 515:b33ed0a7f49b
[gaim-migrate @ 525]
DirectIM. fun. bleh.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 21 Jul 2000 06:01:35 +0000 |
parents | 44123888a941 |
children | ee4e18868584 |
files | src/buddy.c src/conversation.c src/gaim.h src/oscar.c src/server.c |
diffstat | 5 files changed, 75 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddy.c Fri Jul 21 01:21:38 2000 +0000 +++ b/src/buddy.c Fri Jul 21 06:01:35 2000 +0000 @@ -472,19 +472,17 @@ gtk_widget_show(button); if (USE_OSCAR) { + button = gtk_menu_item_new_with_label(_("Direct IM")); + gtk_signal_connect(GTK_OBJECT(button), "activate", + GTK_SIGNAL_FUNC(serv_do_imimage), b->name); + gtk_menu_append(GTK_MENU(menu), button); + gtk_widget_show(button); + button = gtk_menu_item_new_with_label(_("Away Msg")); gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(pressed_away_msg), b); gtk_menu_append(GTK_MENU(menu), button); gtk_widget_show(button); - -#if 0 - button = gtk_menu_item_new_with_label(_("Direct IM")); - gtk_signal_connect(GTK_OBJECT(button), "activate", - GTK_SIGNAL_FUNC(serv_do_imimage), b->name); - gtk_menu_append(GTK_MENU(menu), button); - gtk_widget_show(button); -#endif } button = gtk_menu_item_new_with_label(_("Toggle Logging")); @@ -913,6 +911,7 @@ b->pix = gtk_pixmap_new(pm, bm); b->idle = 0; + b->caps = 0; gtk_widget_show(b->pix);
--- a/src/conversation.c Fri Jul 21 01:21:38 2000 +0000 +++ b/src/conversation.c Fri Jul 21 06:01:35 2000 +0000 @@ -306,7 +306,10 @@ if (!USE_OSCAR) { /* FIXME */ } else { - aim_conn_kill(c->conn); + gdk_input_remove(c->watcher); + sprintf(debug_buff, "Closing DirectIM conversation (0x%x)\n", c->conn); + debug_print(debug_buff); + aim_conn_kill(gaim_sess, &c->conn); } } delete_conversation(c);
--- a/src/gaim.h Fri Jul 21 01:21:38 2000 +0000 +++ b/src/gaim.h Fri Jul 21 06:01:35 2000 +0000 @@ -278,6 +278,7 @@ /* DirectIM stuff */ gboolean is_direct; struct aim_conn_t *conn; /* needed for Oscar */ + int watcher; }; struct file_header { @@ -380,7 +381,7 @@ #define TYPE_SIGNOFF 4 #define TYPE_KEEPALIVE 5 -#define REVISION "gaim:$Revision: 523 $" +#define REVISION "gaim:$Revision: 525 $" #define FLAPON "FLAPON\r\n\r\n" #define ROAST "Tic/Toc"
--- a/src/oscar.c Fri Jul 21 01:21:38 2000 +0000 +++ b/src/oscar.c Fri Jul 21 06:01:35 2000 +0000 @@ -85,8 +85,9 @@ static int gaim_parse_msgack (struct aim_session_t *, struct command_rx_struct *, ...); static int gaim_parse_ratechange (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_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 *, ...); extern void auth_failed(); @@ -104,14 +105,28 @@ } if (condition & GDK_INPUT_READ) { if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { + debug_print("got information on rendezvous\n"); if (aim_handlerendconnect(gaim_sess, conn) < 0) { debug_print(_("connection error (rend)\n")); } } else { + char *direct = NULL; + if (conn->type == AIM_CONN_TYPE_RENDEZVOUS && + conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) + direct = g_strdup(((struct aim_directim_priv *)conn->priv)->sn); if (aim_get_command(gaim_sess, conn) >= 0) { aim_rxdispatch(gaim_sess); } else { debug_print(_("connection error!\n")); + if (direct) { + struct conversation *cnv = find_conversation(direct); + debug_print("connection error for directim\n"); + if (cnv) { + cnv->is_direct = 0; + cnv->conn = NULL; + gdk_input_remove(cnv->watcher); + } + } aim_conn_kill(gaim_sess, &conn); if (!aim_getconn_type(gaim_sess, AIM_CONN_TYPE_BOS)) { debug_print(_("major connection error\n")); @@ -122,6 +137,7 @@ gdk_input_remove(inpa); } } + if (direct) g_free(direct); } } } @@ -587,6 +603,7 @@ /* DirectIM stuff */ struct aim_directim_priv *priv; struct aim_conn_t *newconn; + int watcher; userinfo = va_arg(ap, struct aim_userinfo_s *); priv = va_arg(ap, struct aim_directim_priv *); @@ -603,13 +620,13 @@ 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); - gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, - oscar_callback, newconn); + watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, + oscar_callback, newconn); sprintf(debug_buff, "DirectIM: connected to %s\n", userinfo->sn); debug_print(debug_buff); - serv_got_imimage(priv->sn, priv->cookie, priv->ip, newconn); + serv_got_imimage(priv->sn, priv->cookie, priv->ip, newconn, watcher); } else { sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); debug_print(debug_buff); @@ -905,6 +922,34 @@ 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; + + 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); + cnv->conn = newconn; + gdk_input_remove(cnv->watcher); + cnv->watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, + oscar_callback, newconn); + + 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; @@ -922,5 +967,9 @@ void oscar_do_directim(char *name) { struct aim_conn_t *newconn = aim_directim_initiate(gaim_sess, gaim_conn, NULL, name); - gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, oscar_callback, newconn); + struct conversation *cnv = find_conversation(name); /* this will never be null because it just got set up */ + cnv->is_direct = TRUE; + cnv->conn = newconn; + cnv->watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, oscar_callback, newconn); + aim_conn_addhandler(gaim_sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, gaim_directim_initiate, 0); }
--- a/src/server.c Fri Jul 21 01:21:38 2000 +0000 +++ b/src/server.c Fri Jul 21 06:01:35 2000 +0000 @@ -822,7 +822,7 @@ } #endif b->uc = type; - b->caps = caps; + if (caps) b->caps = caps; b->signon = signon; @@ -1104,13 +1104,17 @@ } void serv_do_imimage(GtkWidget *w, char *name) { + struct conversation *cnv = find_conversation(name); + if (!cnv) cnv = new_conversation(name); + if (!USE_OSCAR) { + /* FIXME */ } else { oscar_do_directim(name); } } -void serv_got_imimage(char *name, char *cookie, char *ip, struct aim_conn_t *conn) +void serv_got_imimage(char *name, char *cookie, char *ip, struct aim_conn_t *conn, int watcher) { if (!USE_OSCAR) { /* FIXME */ @@ -1119,5 +1123,6 @@ if (!cnv) cnv = new_conversation(name); cnv->is_direct = 1; cnv->conn = conn; + cnv->watcher = watcher; } }