From: Don S. <ri...@us...> - 2005-01-27 21:26:57
|
Update of /cvsroot/gaim-bnet/gaim-bnet/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29492/src Modified Files: bnet.c bnet.h buddy.c conn.c conn.h proto.c proto.h Log Message: Patch #1110361 Index: conn.h =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/conn.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** conn.h 21 Jan 2005 05:45:52 -0000 1.6 --- conn.h 27 Jan 2005 21:26:41 -0000 1.7 *************** *** 74,77 **** --- 74,78 ---- gboolean welcome; gboolean fl_listing; + gchar *vw_nick; // verbose where - nick }; Index: bnet.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/bnet.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** bnet.c 21 Jan 2005 05:45:52 -0000 1.33 --- bnet.c 27 Jan 2005 21:26:41 -0000 1.34 *************** *** 42,45 **** --- 42,67 ---- *****************************************************************************/ static void + bnet_check_info_cb(GaimConnection *gc, char *nick) { + if (g_list_find(gaim_connections_get_all(), gc)) { + gaim_debug_info("bnet", "bnet_check_status_cb: nick \"%s\"\n", nick); + + bnet_user_info(gc, nick); + } + } + + static void bnet_check_info(GaimPluginAction *action) { + GaimConnection *gc = (GaimConnection*)action->context; + + gaim_debug_info("bnet", "bnet_check_status\n"); + + gaim_request_input(gc, _("Get user info"), + _("Retrieve info about a user"), + _("Type the nick here"), + NULL, FALSE, FALSE, NULL, + _("OK"), G_CALLBACK(bnet_check_info_cb), + _("Cancel"), NULL, gc); + } + + static void bnet_raw_request_cb(GaimConnection *gc, char *msg) { BNetConn *conn = BNET_CONN(gc->proto_data); *************** *** 72,75 **** --- 94,101 ---- GaimPluginAction *act; + act = gaim_plugin_action_new(_("Get user info"), + bnet_check_info); + m = g_list_append(m, act); + act = gaim_plugin_action_new(_("Send raw command..."), bnet_send_raw_cmd); Index: conn.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/conn.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** conn.c 21 Jan 2005 05:45:52 -0000 1.9 --- conn.c 27 Jan 2005 21:26:41 -0000 1.10 *************** *** 36,39 **** --- 36,50 ---- }; + /****************************************************************************** + * Raw Procedures + *****************************************************************************/ + static void + bnet_list_destroy_all(gpointer data, gpointer user_data) { + free(data); + } + + /****************************************************************************** + * Connection API + *****************************************************************************/ void bnet_conn_send(BNetConn *conn, const gchar *fmt, ...) { *************** *** 68,74 **** while (queue && (cur = queue->data, !conn->flood_sent || conn->flood_sent + strlen(cur) < BNET_FLOOD_MAX)) { ! ret = send(conn->fd, cur, strlen(cur), 0); ! if (ret > 0) ! conn->flood_sent += ret; g_free(cur); --- 79,90 ---- while (queue && (cur = queue->data, !conn->flood_sent || conn->flood_sent + strlen(cur) < BNET_FLOOD_MAX)) { ! ret = write(conn->fd, cur, strlen(cur)); ! if (ret < 0) { ! gaim_connection_error(gaim_account_get_connection(conn->account), ! _("Write error")); ! return; ! } ! ! conn->flood_sent += ret; g_free(cur); *************** *** 319,322 **** --- 335,340 ---- if (conn->last_stat.nick) g_free(conn->last_stat.nick); + if (conn->vw_nick) + g_free(conn->vw_nick); g_hash_table_destroy(conn->users); *************** *** 325,328 **** --- 343,348 ---- if (conn->flood_timer) gaim_timeout_remove(conn->flood_timer); + g_list_foreach(conn->out_queue, bnet_list_destroy_all, NULL); + g_list_free(conn->out_queue); g_free(conn); Index: proto.h =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/proto.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** proto.h 13 Jan 2005 08:25:39 -0000 1.7 --- proto.h 27 Jan 2005 21:26:41 -0000 1.8 *************** *** 30,33 **** --- 30,34 ---- typedef struct _BNetWhispFromProcInfo BNetWhispFromProcInfo; typedef struct _BNetInfoProcInfo BNetInfoProcInfo; + typedef struct _BNetInfoProcInfo BNetErrorProcInfo; #include "conn.h" Index: bnet.h =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/bnet.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** bnet.h 8 Jan 2005 11:24:00 -0000 1.9 --- bnet.h 27 Jan 2005 21:26:41 -0000 1.10 *************** *** 35,40 **** #include <glib.h> #include <string.h> - #include <sys/socket.h> - #include <sys/types.h> #include <unistd.h> --- 35,38 ---- Index: proto.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/proto.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** proto.c 26 Jan 2005 16:48:29 -0000 1.18 --- proto.c 27 Jan 2005 21:26:41 -0000 1.19 *************** *** 125,129 **** p = (gchar *)(w + strlen(w)); else { ! if (!(p = strstr(w, k+1))) { err = TRUE; break; --- 125,129 ---- p = (gchar *)(w + strlen(w)); else { ! if (!(p = memmem(w, strlen(w), k+1, tt))) { err = TRUE; break; *************** *** 288,292 **** using = w->data; w = g_list_next(w); ! chan = w->data; /* We receive this message in reply to a /WHERE or /WHOIS command --- 288,292 ---- using = w->data; w = g_list_next(w); ! chan = w?w->data:"*Private Channel*"; /* We receive this message in reply to a /WHERE or /WHOIS command *************** *** 301,304 **** --- 301,322 ---- if (b) bnet_buddy_set_info(b, using, chan); + + if (conn->vw_nick && !strcmp(conn->vw_nick, norm)) { + gchar *msg; + + msg = g_strdup_printf("%s: %s\n%s: %s\n", + _("Game"), using, + _("Location"), chan); + + gaim_notify_message(NULL, + GAIM_NOTIFY_MSG_INFO, + _("Information"), + _("User is ONLINE"), + msg, NULL, NULL); + + g_free(msg); + g_free(conn->vw_nick); + conn->vw_nick = 0; + } } *************** *** 406,409 **** --- 424,428 ---- { "$x: $x, using $x in the game $x.", bnet_proto_info_fl_online }, { "$x: $x, offline", bnet_proto_info_fl_offline }, + { "$x is using $x in a private channel.", bnet_proto_info_where }, { "$x is using $x in the channel $x.", bnet_proto_info_where }, { "You are $x, using $x in the channel $x.", bnet_proto_info_whoami }, *************** *** 416,419 **** --- 435,468 ---- /****************************************************************************** + * Error Processing + *****************************************************************************/ + static void + bnet_proto_error_not_logged(BNetConn *conn, GList *args) { + gaim_debug_info("bnet", "bnet_proto_info_welcome\n"); + + if (conn->vw_nick) { + gchar *msg; + + msg = g_strdup_printf("%s %s\n", _("Nothing about"), conn->vw_nick); + + gaim_notify_message(NULL, + GAIM_NOTIFY_MSG_INFO, + _("Information"), + _("User is OFFLINE"), + msg, NULL, NULL); + + g_free(msg); + g_free(conn->vw_nick); + conn->vw_nick = 0; + } + } + + static BNetErrorProcInfo epi[] = { + { "That user is not logged on.", bnet_proto_error_not_logged } + }; + + #define PROTO_ERROR_MSGS_N (sizeof(epi) / sizeof(epi[0])) + + /****************************************************************************** * Proto Messages Processing *****************************************************************************/ *************** *** 585,590 **** --- 634,656 ---- bnet_proto_msg_error(BNetConn *conn, const gchar** args) { const gchar* error = args[0]; + const gchar *info[2] = { NULL, error }; + GList *w_args; + gint i; gaim_debug_info("bnet", "ERROR %s\n", error); + + for (i=0; i < PROTO_ERROR_MSGS_N; i++) { + if (bnet_proto_model_compare(conn, epi[i].model, (const gchar**)info, + &w_args)) { + epi[i].func(conn, w_args); + + if (w_args) { + g_list_foreach(w_args, bnet_list_destroy_all, NULL); + g_list_free(w_args); + } + + break; + } + } } Index: buddy.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/buddy.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** buddy.c 21 Jan 2005 05:45:52 -0000 1.13 --- buddy.c 27 Jan 2005 21:26:41 -0000 1.14 *************** *** 83,87 **** BNetConn *conn = BNET_CONN(gc->proto_data); ! bnet_conn_send(conn, "/whois %s\n", who); } --- 83,91 ---- BNetConn *conn = BNET_CONN(gc->proto_data); ! if (conn->vw_nick) ! g_free(conn->vw_nick); ! conn->vw_nick = g_strdup(gaim_normalize(conn->account, who)); ! ! bnet_conn_send(conn, "/where %s\n", who); } *************** *** 238,246 **** void bnet_buddy_set_info(BNetBuddy *b, const gchar *game, const gchar *location) { ! if (!b->game || strcmp(b->game, game)) { g_free(b->game); b->game = g_strdup(game); } ! if (!b->location || strcmp(b->location, location)) { g_free(b->location); b->location = g_strdup(location); --- 242,250 ---- void bnet_buddy_set_info(BNetBuddy *b, const gchar *game, const gchar *location) { ! if (game && (!b->game || strcmp(b->game, game))) { g_free(b->game); b->game = g_strdup(game); } ! if (location && (!b->location || strcmp(b->location, location))) { g_free(b->location); b->location = g_strdup(location); |