From: Gary K. <amc...@us...> - 2005-01-12 23:27:58
|
Update of /cvsroot/gaim-bnet/gaim-bnet/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31418/src Modified Files: buddy.c proto.c proto.h Log Message: Pulling a luke and committing with out looking... Well actually, I'll be looking after this.. :) Index: proto.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/proto.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** proto.c 9 Jan 2005 05:00:56 -0000 1.10 --- proto.c 12 Jan 2005 23:27:47 -0000 1.11 *************** *** 27,30 **** --- 27,32 ---- #endif + #define _GNU_SOURCE + #include <string.h> *************** *** 35,38 **** --- 37,43 ---- #define IS_NUM(c) ((c) >= '0' && (c) <= '9') + /****************************************************************************** + * Raw Procedures + *****************************************************************************/ static gboolean bnet_hash_destroy_all(gpointer key, gpointer value, gpointer user_data) { *************** *** 41,44 **** --- 46,163 ---- static void + bnet_list_destroy_all(gpointer data, gpointer user_data) { + free(data); + } + + /****************************************************************************** + * Whispear From Processing + *****************************************************************************/ + static void + bnet_proto_whispf_login(BNetConn *conn, const gchar *nick, GList *args) { + GaimConnection *gc; + gc = gaim_account_get_connection(conn->account); + serv_got_update(gc, nick, TRUE, 0, 0, 0, 0); + } + + static void + bnet_proto_whispf_join(BNetConn *conn, const gchar *nick, GList *args) { + /* Nothing to do here */ + } + + static void + bnet_proto_whispf_logout(BNetConn *conn, const gchar *nick, GList *args) { + GaimConnection *gc; + gc = gaim_account_get_connection(conn->account); + serv_got_update(gc, nick, FALSE, 0, 0, 0, 0); + } + + static gboolean + bnet_proto_compare_whispf(BNetConn *conn, const gchar* model, const gchar **whisp, + GList **args) { + const gchar *nick = whisp[0]; + const gchar *msg = whisp[1]; + + const gchar *w, *k; + gchar *p, *q; + gint t, tt; + GList *al = NULL; + + gboolean err = FALSE; + + for (w = msg, k = model; !err && *w && *k; w++, k++) { + if (*k == '$') { + k++; + + switch (*k) { + case 'n': + t = strlen(nick); + if (memcmp(w, nick, t)) { + err = TRUE; + break; + } + w += t-1; + break; + + case 'x': + if (!(p = strchr(k, '$'))) + tt = strlen(k) - 1; + else + tt = p-k - 1; + + if (!(p = memmem(w, strlen(w), k+1, tt))) { + err = TRUE; + break; + } + + q = (gchar*)malloc(p-w+1); + memcpy(q, w, p-w); + q[p-w] = 0; + + al = g_list_append(al, q); + + w += p-w + tt - 1; + k += tt; + break; + + case 0: /* Error in model */ + default: + break; + } + + /* Maybe err == TRUE here */ + } + else { + if (*w != *k) { + err = TRUE; + break; + } + } + } + + if (err || *w || *k) { + if (al) { + g_list_foreach(al, bnet_list_destroy_all, NULL); + g_list_free(al); + } + + return FALSE; + } + + *args = al; + return TRUE; + } + + static BNetWhispFromProcInfo wfpi[] = { + { "Your friend $n has entered Battle.net.", bnet_proto_whispf_login }, + { "Your friend $n has entered a $x game called $x", bnet_proto_whispf_join }, + { "Your friend $n has exited Battle.net.", bnet_proto_whispf_logout } + }; + + #define PROTO_WHISP_MSG_N (sizeof(wfpi) / sizeof(wfpi[0])) + + /****************************************************************************** + * Proto Messages Processing + *****************************************************************************/ + static void bnet_proto_msg_join_user(BNetConn *conn, const gchar* nick, const gchar* flags, const gchar* game, gboolean new_arrival) { BNetUser *u; *************** *** 73,78 **** bnet_proto_msg_leave(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! const gchar* game = args[1]; ! const gchar* flags = args[2]; GaimConversation *convo; --- 192,197 ---- bnet_proto_msg_leave(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! //const gchar* game = args[1]; ! //const gchar* flags = args[2]; GaimConversation *convo; *************** *** 91,127 **** bnet_proto_msg_whispearf(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! const gchar* game = args[1]; const gchar* msg = args[2]; ! GaimConnection *gc; ! gchar *tmp; ! gint len; gaim_debug_info("bnet", "WHISP FROM %s - %s\n", nick, msg); ! gc = gaim_account_get_connection(conn->account); ! ! tmp = g_strdup_printf("Your friend %s ", nick); ! if (!memcmp(msg,tmp,len=strlen(tmp))) { ! gchar *p = tmp+len; ! if (!memcmp(p, "has entered ", 12)) { ! p += 8; ! if (!strcmp(p, "Battle.net.")) { ! serv_got_update(gc, nick, TRUE, 0, 0, 0, 0); ! } else if (!memcmp(p, "a *** game called ", 10)) { ! /* What to do here? */ ! } else { ! gaim_debug_info("bnet", "** UNKNOWN SERVER WHISP\n"); } ! } else if (!strcmp(p, "has exited Battle.net.")) { ! serv_got_update(gc, nick, FALSE, 0, 0, 0, 0); ! } else { ! gaim_debug_info("bnet", "** UNKNOWN SERVER WHISP\n"); } ! } else { serv_got_im(gc, nick, msg, 0, time(NULL)); } - g_free(tmp); } --- 210,241 ---- bnet_proto_msg_whispearf(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! //const gchar* game = args[1]; const gchar* msg = args[2]; ! const gchar *whisp[2] = { nick, msg }; ! GList *w_args; ! gint i; gaim_debug_info("bnet", "WHISP FROM %s - %s\n", nick, msg); ! for (i=0; i < PROTO_WHISP_MSG_N; i++) { ! if (bnet_proto_compare_whispf(conn, wfpi[i].model, (const gchar**)whisp, ! &w_args)) { ! wfpi[i].func(conn, nick, w_args); ! if (w_args) { ! g_list_foreach(w_args, bnet_list_destroy_all, NULL); ! g_list_free(w_args); } ! ! break; } ! } ! ! if (i == PROTO_WHISP_MSG_N) { ! GaimConnection *gc; ! gc = gaim_account_get_connection(conn->account); serv_got_im(gc, nick, msg, 0, time(NULL)); } } *************** *** 129,133 **** bnet_proto_msg_talk(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! const gchar* game = args[1]; const gchar* msg = args[2]; GaimConversation *convo; --- 243,247 ---- bnet_proto_msg_talk(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! //const gchar* game = args[1]; const gchar* msg = args[2]; GaimConversation *convo; *************** *** 169,173 **** bnet_proto_msg_whispeart(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! const gchar* game = args[1]; const gchar* msg = args[2]; --- 283,287 ---- bnet_proto_msg_whispeart(BNetConn *conn, const gchar** args) { const gchar* nick = args[0]; ! //const gchar* game = args[1]; const gchar* msg = args[2]; Index: buddy.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/buddy.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** buddy.c 9 Jan 2005 09:59:59 -0000 1.7 --- buddy.c 12 Jan 2005 23:27:47 -0000 1.8 *************** *** 131,136 **** BNetConn *conn = BNET_CONN(gc->proto_data); BNetBuddy *b = bnet_buddy_new(buddy->name); ! g_hash_table_insert(conn->buddies, b->name, b); } --- 131,140 ---- BNetConn *conn = BNET_CONN(gc->proto_data); BNetBuddy *b = bnet_buddy_new(buddy->name); + const gchar *name; ! name = gaim_normalize(gc->account, buddy->name); ! ! if(!g_hash_table_lookup(conn->buddies, name)) ! g_hash_table_insert(conn->buddies, (gchar *)name, b); } Index: proto.h =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/proto.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** proto.h 8 Jan 2005 10:34:46 -0000 1.5 --- proto.h 12 Jan 2005 23:27:48 -0000 1.6 *************** *** 27,31 **** #include "bnet.h" ! typedef struct _BNetProtoProcInfo BNetProtoProcInfo; #include "conn.h" --- 27,33 ---- #include "bnet.h" ! typedef struct _BNetProtoProcInfo BNetProtoProcInfo; ! typedef struct _BNetWhispFromProcInfo BNetWhispFromProcInfo; ! //typedef struct _BNetInfoProcInfo BNetInfoProcInfo; #include "conn.h" *************** *** 39,42 **** --- 41,51 ---- }; + typedef void (*BNetWhispFromProcFunc)(BNetConn *, const gchar *, GList *args); + + struct _BNetWhispFromProcInfo { + const gchar* model; + BNetWhispFromProcFunc func; + }; + #ifdef __cplusplus extern "C" { |