From: Gary K. <amc...@us...> - 2005-01-21 05:46:03
|
Update of /cvsroot/gaim-bnet/gaim-bnet/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15620/src Modified Files: bnet.c buddy.c buddy.h conn.c conn.h proto.c Log Message: updated from dario.. Index: bnet.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/bnet.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** bnet.c 17 Jan 2005 01:56:50 -0000 1.32 --- bnet.c 21 Jan 2005 05:45:52 -0000 1.33 *************** *** 126,132 **** --- 126,147 ---- } + static GList *bnet_away_states(GaimConnection *gc) { + return g_list_append(NULL, (gpointer)GAIM_AWAY_CUSTOM); + } + static void bnet_set_away(GaimConnection *gc, const char *state, const char *msg) { + BNetConn *conn = BNET_CONN(gc->proto_data); + if (gc->away) { + g_free(gc->away); + gc->away = NULL; + } + if (msg) { + gc->away = g_strdup(msg); + bnet_conn_send(conn, "/away %s\n", msg); + } else + bnet_conn_send(conn, "/away\n"); + } /****************************************************************************** *************** *** 146,151 **** bnet_buddy_emblems, /* list_emblems */ NULL, /* status_text */ ! NULL, /* tooltip_text */ ! NULL, /* away_states */ blist_node_menu, /* blist_node_menu */ bnet_chat_info, /* chat_info */ --- 161,166 ---- bnet_buddy_emblems, /* list_emblems */ NULL, /* status_text */ ! bnet_buddy_tooltip_text, /* tooltip_text */ ! bnet_away_states, /* away_states */ blist_node_menu, /* blist_node_menu */ bnet_chat_info, /* chat_info */ *************** *** 157,161 **** NULL, /* send_typing */ bnet_user_info, /* get_info */ ! NULL, /* set_away */ NULL, /* set_idle */ NULL, /* change_password */ --- 172,176 ---- NULL, /* send_typing */ bnet_user_info, /* get_info */ ! bnet_set_away, /* set_away */ NULL, /* set_idle */ NULL, /* change_password */ Index: conn.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/conn.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** conn.c 17 Jan 2005 01:56:50 -0000 1.8 --- conn.c 21 Jan 2005 05:45:52 -0000 1.9 *************** *** 66,70 **** queue = conn->out_queue; ! while (queue && conn->flood_sent + strlen(cur = queue->data) < BNET_FLOOD_MAX) { ret = send(conn->fd, cur, strlen(cur), 0); if (ret > 0) --- 66,71 ---- queue = conn->out_queue; ! 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) *************** *** 89,94 **** else conn->flood_sent = 0; - gaim_debug_info("bnet", "conn->flood_sent now %u (queue %p)\n", - conn->flood_sent, conn->out_queue); bnet_conn_out_queue_check(conn); --- 90,93 ---- *************** *** 129,132 **** --- 128,135 ---- static void bnet_conn_parse_msg(BNetConn *conn, const gchar *msg) { + GaimConnection *gc; + + gc = gaim_account_get_connection(conn->account); + switch(conn->state) { case BNET_CS_SOCK: *************** *** 147,155 **** break; case BNET_CS_VRFY: ! if (!strstr(msg, "incorrect")) { ! GaimConnection *gc; ! ! gc = gaim_account_get_connection(conn->account); bnet_conn_update_progress(conn, BNET_CS_CONN); gaim_connection_set_state(gc, GAIM_CONNECTED); --- 150,156 ---- break; case BNET_CS_VRFY: ! conn->vrfy_attempts++; + if (!strstr(msg, "incorrect")) { bnet_conn_update_progress(conn, BNET_CS_CONN); gaim_connection_set_state(gc, GAIM_CONNECTED); *************** *** 157,160 **** --- 158,166 ---- bnet_conn_request_friends_list(conn); } else { + if (conn->vrfy_attempts > 1) + /* We must stop to try... our user/pass are not valid + */ + gaim_connection_error(gc, _("Invalid user/pass")); + bnet_conn_update_progress(conn, BNET_CS_USER); } *************** *** 311,316 **** if (conn->chan) g_free(conn->chan); - if (conn->away) - g_free(conn->away); if (conn->last_stat.nick) g_free(conn->last_stat.nick); --- 317,320 ---- Index: conn.h =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/conn.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** conn.h 17 Jan 2005 01:56:50 -0000 1.5 --- conn.h 21 Jan 2005 05:45:52 -0000 1.6 *************** *** 50,53 **** --- 50,54 ---- BNetConnState state; + guint vrfy_attempts; gint fd; *************** *** 64,69 **** GHashTable *users; - gchar *away; - struct { gchar *nick; --- 65,68 ---- *************** *** 73,76 **** --- 72,76 ---- GHashTable *buddies; + gboolean welcome; gboolean fl_listing; }; Index: proto.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/proto.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** proto.c 17 Jan 2005 01:56:50 -0000 1.15 --- proto.c 21 Jan 2005 05:45:52 -0000 1.16 *************** *** 51,57 **** if (buddy->fl_position == -1) { ! bnet_conn_send(conn, "/friends add %s\n", buddy->name); ! bnet_conn_send(conn, "/where %s\n", buddy->name); ! buddy->fl_position = 0; } } --- 51,70 ---- if (buddy->fl_position == -1) { ! if (!buddy->new_entry) { ! /* Consider server list authoritative... if buddy was added by ! * local list and don't exist on server, then delete it ! */ ! GaimBuddy *gb = gaim_find_buddy(conn->account, buddy->name); ! g_return_if_fail(gb); ! ! gaim_blist_remove_buddy(gb); ! g_hash_table_remove(conn->buddies, buddy->name); ! } else { ! /* Buddy is added manually now... then we should add it to ! * the server list too ! */ ! bnet_conn_send(conn, "/friends add %s\n", buddy->name); ! bnet_conn_send(conn, "/where %s\n", buddy->name); ! } } } *************** *** 63,71 **** static void ! bnet_stat_resolve(BNetGameStat *stat, const gchar *msg) ! { bzero(stat, sizeof(BNetGameStat)); - - gaim_debug_info("bnet", "msg(%s)\n", msg); sscanf(msg, "%u-%u-%u", &stat->win, &stat->loss, &stat->disc); } --- 76,81 ---- static void ! bnet_stat_resolve(BNetGameStat *stat, const gchar *msg) { bzero(stat, sizeof(BNetGameStat)); sscanf(msg, "%u-%u-%u", &stat->win, &stat->loss, &stat->disc); } *************** *** 73,78 **** static gboolean bnet_proto_model_compare(BNetConn *conn, const gchar* model, ! const gchar **msginfo, GList **args) ! { const gchar *nick = msginfo[0]; const gchar *msg = msginfo[1]; --- 83,87 ---- static gboolean bnet_proto_model_compare(BNetConn *conn, const gchar* model, ! const gchar **msginfo, GList **args) { const gchar *nick = msginfo[0]; const gchar *msg = msginfo[1]; *************** *** 162,171 **** 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 */ gaim_debug_info("bnet", "bnet_proto_whispf_join\n"); } --- 171,195 ---- gc = gaim_account_get_connection(conn->account); serv_got_update(gc, nick, TRUE, 0, 0, 0, 0); + + bnet_conn_send(conn, "/where %s\n", nick); } static void bnet_proto_whispf_join(BNetConn *conn, const gchar *nick, GList *args) { ! BNetBuddy *b; ! GList *w = args; ! ! gchar *game, *room; ! gaim_debug_info("bnet", "bnet_proto_whispf_join\n"); + + game = w->data; + w = g_list_next(w); + room = w->data; + + b = bnet_buddy_hard_lookup(conn, nick); + g_return_if_fail(b); + + bnet_buddy_set_info(b, game, room); } *************** *** 194,197 **** --- 218,223 ---- bnet_proto_info_welcome(BNetConn *conn, GList *args) { gaim_debug_info("bnet", "bnet_proto_info_welcome\n"); + + conn->welcome = TRUE; } *************** *** 219,222 **** --- 245,249 ---- sscanf(n, "%u", &b->fl_position); + bnet_buddy_set_info(b, using, chan); gc = gaim_account_get_connection(conn->account); *************** *** 250,254 **** --- 277,283 ---- bnet_proto_info_where(BNetConn *conn, GList *args) { GaimConnection *gc; + BNetBuddy *b; GList *w = args; + const gchar *norm; gchar *nick, *using, *chan; *************** *** 266,269 **** --- 295,304 ---- gc = gaim_account_get_connection(conn->account); serv_got_update(gc, nick, TRUE, 0, 0, 0, 0); + + norm = gaim_normalize(conn->account, nick); + b = g_hash_table_lookup(conn->buddies, norm); + + if (b) + bnet_buddy_set_info(b, using, chan); } Index: buddy.c =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/buddy.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** buddy.c 17 Jan 2005 01:56:50 -0000 1.12 --- buddy.c 21 Jan 2005 05:45:52 -0000 1.13 *************** *** 116,121 **** buddy->norm = g_strdup(norm); buddy->name = g_strdup(name); - buddy->flags = 0; - buddy->location = 0; buddy->fl_position = -1; --- 116,119 ---- *************** *** 129,133 **** g_free(buddy->norm); g_free(buddy->name); ! g_free(buddy->flags); g_free(buddy->location); g_free(buddy); --- 127,131 ---- g_free(buddy->norm); g_free(buddy->name); ! g_free(buddy->game); g_free(buddy->location); g_free(buddy); *************** *** 146,149 **** --- 144,149 ---- if (!g_hash_table_lookup(conn->buddies, norm)) { b = bnet_buddy_new(norm, buddy->name); + if (conn->welcome) + b->new_entry = TRUE; g_hash_table_insert(conn->buddies, b->norm, b); *************** *** 178,181 **** --- 178,182 ---- b = bnet_buddy_new(norm, name); + b->new_entry = TRUE; g_hash_table_insert(conn->buddies, b->norm, b); } *************** *** 201,204 **** --- 202,251 ---- } + gchar * + bnet_buddy_tooltip_text(GaimBuddy *b) { + BNetConn *conn; + BNetBuddy *bb; + GString *ret = g_string_new(""); + const gchar *norm; + + conn = BNET_CONN(b->account->gc->proto_data); + norm = gaim_normalize(conn->account, b->name); + + if ((bb = g_hash_table_lookup(conn->buddies, norm))) { + switch (b->present) { + case GAIM_BUDDY_SIGNING_OFF: + break; + case GAIM_BUDDY_OFFLINE: + g_string_append_printf(ret, + "\n<b>%s:</b> Offline", _("Status")); + break; + case GAIM_BUDDY_ONLINE: + if (bb->game) + g_string_append_printf(ret, + "\n<b>%s:</b> %s", _("Game"), bb->game); + if (bb->location) + g_string_append_printf(ret, + "\n<b>%s:</b> %s", _("Location"), bb->location); + break; + case GAIM_BUDDY_SIGNING_ON: + break; + } + } + + return g_string_free(ret, FALSE); + } + + 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); + } + } + /****************************************************************************** * Buddies API Index: buddy.h =================================================================== RCS file: /cvsroot/gaim-bnet/gaim-bnet/src/buddy.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** buddy.h 13 Jan 2005 15:50:54 -0000 1.8 --- buddy.h 21 Jan 2005 05:45:52 -0000 1.9 *************** *** 41,47 **** gchar* norm; gchar* name; ! gchar* flags; gchar* location; gint fl_position; }; --- 41,48 ---- gchar* norm; gchar* name; ! gchar* game; gchar* location; gint fl_position; + gboolean new_entry; }; *************** *** 66,69 **** --- 67,72 ---- void bnet_buddy_remove(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group); void bnet_buddy_emblems(GaimBuddy *buddy, char **se, char **sw, char **nw, char **ne); + gchar *bnet_buddy_tooltip_text(GaimBuddy *b); + void bnet_buddy_set_info(BNetBuddy *b, const gchar *game, const gchar *location); /* Buddies API */ |