From: <the...@us...> - 2006-08-26 19:12:12
|
Revision: 17050 Author: thekingant Date: 2006-08-26 12:12:05 -0700 (Sat, 26 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=17050&view=rev Log Message: ----------- Use GSList in a few places instead of GList, and use g_list_prepend and then g_list_reverse in a few places instead of g_list_append Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_chat.c trunk/libgaim/protocols/oscar/family_oservice.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.c trunk/libgaim/protocols/oscar/oscar.h trunk/libgaim/protocols/oscar/oscar_data.c trunk/libgaim/protocols/oscar/peer.c Modified: trunk/libgaim/protocols/oscar/family_chat.c =================================================================== --- trunk/libgaim/protocols/oscar/family_chat.c 2006-08-26 17:28:30 UTC (rev 17049) +++ trunk/libgaim/protocols/oscar/family_chat.c 2006-08-26 19:12:05 UTC (rev 17050) @@ -67,7 +67,7 @@ FlapConnection * aim_chat_getconn(OscarData *od, const char *name) { - GList *cur; + GSList *cur; for (cur = od->oscar_connections; cur; cur = cur->next) { Modified: trunk/libgaim/protocols/oscar/family_oservice.c =================================================================== --- trunk/libgaim/protocols/oscar/family_oservice.c 2006-08-26 17:28:30 UTC (rev 17049) +++ trunk/libgaim/protocols/oscar/family_oservice.c 2006-08-26 19:12:05 UTC (rev 17050) @@ -33,7 +33,7 @@ { FlapFrame *frame; aim_snacid_t snacid; - GList *cur; + GSList *cur; frame = flap_frame_new(od, 0x02, 1152); @@ -82,7 +82,7 @@ while (byte_stream_empty(bs)) { group = byte_stream_get16(bs); - conn->groups = g_list_prepend(conn->groups, GUINT_TO_POINTER(group)); + conn->groups = g_slist_prepend(conn->groups, GUINT_TO_POINTER(group)); } /* @@ -500,7 +500,7 @@ { FlapFrame *frame; aim_snacid_t snacid; - GList *cur; + GSList *cur; frame = flap_frame_new(od, 0x02, 1024); @@ -742,7 +742,7 @@ { FlapFrame *frame; aim_snacid_t snacid; - GList *cur; + GSList *cur; frame = flap_frame_new(od, 0x02, 1152); Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-08-26 17:28:30 UTC (rev 17049) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-08-26 19:12:05 UTC (rev 17050) @@ -124,7 +124,7 @@ conn->subtype = -1; conn->type = type; - od->oscar_connections = g_list_prepend(od->oscar_connections, conn); + od->oscar_connections = g_slist_prepend(od->oscar_connections, conn); return conn; } @@ -220,10 +220,10 @@ if (conn->type == SNAC_FAMILY_CHAT) flap_connection_destroy_chat(od, conn); - g_list_free(conn->groups); + g_slist_free(conn->groups); flap_connection_destroy_rates(conn->rates); - od->oscar_connections = g_list_remove(od->oscar_connections, conn); + od->oscar_connections = g_slist_remove(od->oscar_connections, conn); account = gaim_connection_get_account(od->gc); @@ -351,12 +351,12 @@ FlapConnection * flap_connection_findbygroup(OscarData *od, guint16 group) { - GList *cur; + GSList *cur; for (cur = od->oscar_connections; cur != NULL; cur = cur->next) { FlapConnection *conn; - GList *l; + GSList *l; conn = cur->data; @@ -385,7 +385,7 @@ FlapConnection * flap_connection_getbytype(OscarData *od, int type) { - GList *cur; + GSList *cur; for (cur = od->oscar_connections; cur != NULL; cur = cur->next) { @@ -401,7 +401,7 @@ FlapConnection * flap_connection_getbytype_all(OscarData *od, int type) { - GList *cur; + GSList *cur; for (cur = od->oscar_connections; cur; cur = cur->next) { Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-08-26 17:28:30 UTC (rev 17049) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-08-26 19:12:05 UTC (rev 17050) @@ -972,7 +972,7 @@ } else if (conn->type == SNAC_FAMILY_CHAT) { - od->oscar_chats = g_slist_append(od->oscar_chats, conn->new_conn_data); + od->oscar_chats = g_slist_prepend(od->oscar_chats, conn->new_conn_data); conn->new_conn_data = NULL; } } @@ -5174,7 +5174,7 @@ gaim_debug_info("oscar", "chatnav does not exist, opening chatnav\n"); cr->exchange = atoi(exchange); cr->name = g_strdup(name); - od->create_rooms = g_slist_append(od->create_rooms, cr); + od->create_rooms = g_slist_prepend(od->create_rooms, cr); aim_reqservice(od, SNAC_FAMILY_CHATNAV); } } @@ -5600,24 +5600,24 @@ NULL, TRUE, TRUE, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, OSCAR_STATUS_ID_FREE4CHAT, _("Free For Chat"), TRUE, is_icq, FALSE); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, OSCAR_STATUS_ID_AWAY, NULL, TRUE, TRUE, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); type = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, OSCAR_STATUS_ID_INVISIBLE, NULL, TRUE, TRUE, FALSE); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); /* ICQ-specific status types */ type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, @@ -5625,27 +5625,29 @@ _("Occupied"), TRUE, is_icq, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, OSCAR_STATUS_ID_DND, _("Do Not Disturb"), TRUE, is_icq, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, OSCAR_STATUS_ID_NA, _("Not Available"), TRUE, is_icq, FALSE, "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, OSCAR_STATUS_ID_OFFLINE, NULL, TRUE, TRUE, FALSE); - status_types = g_list_append(status_types, type); + status_types = g_list_prepend(status_types, type); + status_types = g_list_reverse(status_types); + return status_types; } @@ -5779,27 +5781,27 @@ GaimConnection *gc; OscarData *od; - GList *m; + GList *menu; GaimMenuAction *act; aim_userinfo_t *userinfo; gc = gaim_account_get_connection(buddy->account); od = gc->proto_data; userinfo = aim_locate_finduserinfo(od, buddy->name); - m = NULL; + menu = NULL; if (od->icq && aim_sn_is_icq(gaim_buddy_get_name(buddy))) { act = gaim_menu_action_new(_("Get AIM Info"), GAIM_CALLBACK(oscar_get_aim_info_cb), NULL, NULL); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } act = gaim_menu_action_new(_("Edit Buddy Comment"), GAIM_CALLBACK(oscar_buddycb_edit_comment), NULL, NULL); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); #if 0 if (od->icq) @@ -5807,7 +5809,7 @@ act = gaim_menu_action_new(_("Get Status Msg"), GAIM_CALLBACK(oscar_get_icqstatusmsg), NULL, NULL); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } #endif @@ -5820,7 +5822,7 @@ act = gaim_menu_action_new(_("Direct IM"), GAIM_CALLBACK(oscar_ask_directim), NULL, NULL); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } #if 0 /* TODO: This menu item should be added by the core */ @@ -5828,7 +5830,7 @@ act = gaim_menu_action_new(_("Get File"), GAIM_CALLBACK(oscar_ask_getfile), NULL, NULL); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } #endif } @@ -5842,11 +5844,13 @@ act = gaim_menu_action_new(_("Re-request Authorization"), GAIM_CALLBACK(gaim_auth_sendrequest_menu), NULL, NULL); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } } - return m; + menu = g_list_reverse(menu); + + return menu; } @@ -6213,83 +6217,85 @@ { GaimConnection *gc = (GaimConnection *) context; OscarData *od = gc->proto_data; - GList *m = NULL; + GList *menu = NULL; GaimPluginAction *act; act = gaim_plugin_action_new(_("Set User Info..."), oscar_show_set_info); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); if (od->icq) { act = gaim_plugin_action_new(_("Set User Info (URL)..."), oscar_show_set_info_icqurl); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } act = gaim_plugin_action_new(_("Change Password..."), oscar_change_pass); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); if (od->authinfo->chpassurl != NULL) { act = gaim_plugin_action_new(_("Change Password (URL)"), oscar_show_chpassurl); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), oscar_show_imforwardingurl); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } - m = g_list_append(m, NULL); + menu = g_list_prepend(menu, NULL); if (od->icq) { /* ICQ actions */ act = gaim_plugin_action_new(_("Set Privacy Options..."), oscar_show_icq_privacy_opts); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } else { /* AIM actions */ act = gaim_plugin_action_new(_("Format Screen Name..."), oscar_show_format_screenname); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); act = gaim_plugin_action_new(_("Confirm Account"), oscar_confirm_account); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); act = gaim_plugin_action_new(_("Display Currently Registered E-Mail Address"), oscar_show_email); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); act = gaim_plugin_action_new(_("Change Currently Registered E-Mail Address..."), oscar_show_change_email); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); } - m = g_list_append(m, NULL); + menu = g_list_prepend(menu, NULL); act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), oscar_show_awaitingauth); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); - m = g_list_append(m, NULL); + menu = g_list_prepend(menu, NULL); act = gaim_plugin_action_new(_("Search for Buddy by E-Mail Address..."), oscar_show_find_email); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); #if 0 act = gaim_plugin_action_new(_("Search for Buddy by Information"), show_find_info); - m = g_list_append(m, act); + menu = g_list_prepend(menu, act); #endif - return m; + menu = g_list_reverse(menu); + + return menu; } static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-08-26 17:28:30 UTC (rev 17049) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-08-26 19:12:05 UTC (rev 17050) @@ -383,7 +383,7 @@ guint16 subtype; flap_seqnum_t seqnum; guint32 status; - GList *groups; + GSList *groups; struct rateclass *rates; void *internal; /* internal conn-specific libfaim data */ @@ -492,13 +492,13 @@ } ssi; /* TODO: Implement this as a HashTable for HUGE speed improvement! */ - GList *handlerlist; + GSList *handlerlist; /** A linked list containing FlapConnections. */ - GList *oscar_connections; + GSList *oscar_connections; /** A linked list containing PeerConnections. */ - GList *peer_connections; + GSList *peer_connections; }; /* Valid for calling aim_icq_setstatus() and for aim_userinfo_t->icqinfo.status */ Modified: trunk/libgaim/protocols/oscar/oscar_data.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar_data.c 2006-08-26 17:28:30 UTC (rev 17049) +++ trunk/libgaim/protocols/oscar/oscar_data.c 2006-08-26 19:12:05 UTC (rev 17050) @@ -139,7 +139,7 @@ snac_handler->flags = flags; snac_handler->handler = newhandler; - od->handlerlist = g_list_prepend(od->handlerlist, snac_handler); + od->handlerlist = g_slist_prepend(od->handlerlist, snac_handler); return 0; } @@ -152,7 +152,7 @@ while (od->handlerlist != NULL) { snac_handler = od->handlerlist->data; - od->handlerlist = g_list_remove(od->handlerlist, snac_handler); + od->handlerlist = g_slist_remove(od->handlerlist, snac_handler); g_free(snac_handler); } od->handlerlist = NULL; @@ -161,7 +161,7 @@ aim_rxcallback_t aim_callhandler(OscarData *od, guint16 family, guint16 type) { - GList *cur; + GSList *cur; SnacHandler *snac_handler; for (cur = od->handlerlist; cur != NULL; cur = cur->next) Modified: trunk/libgaim/protocols/oscar/peer.c =================================================================== --- trunk/libgaim/protocols/oscar/peer.c 2006-08-26 17:28:30 UTC (rev 17049) +++ trunk/libgaim/protocols/oscar/peer.c 2006-08-26 19:12:05 UTC (rev 17050) @@ -71,7 +71,7 @@ PeerConnection * peer_connection_find_by_type(OscarData *od, const char *sn, OscarCapability type) { - GList *cur; + GSList *cur; PeerConnection *conn; for (cur = od->peer_connections; cur != NULL; cur = cur->next) @@ -90,7 +90,7 @@ PeerConnection * peer_connection_find_by_cookie(OscarData *od, const char *sn, const guchar *cookie) { - GList *cur; + GSList *cur; PeerConnection *conn; for (cur = od->peer_connections; cur != NULL; cur = cur->next) @@ -126,7 +126,7 @@ else if (type == OSCAR_CAPABILITY_SENDFILE) memcpy(conn->magic, "OFT2", 4); - od->peer_connections = g_list_prepend(od->peer_connections, conn); + od->peer_connections = g_slist_prepend(od->peer_connections, conn); return conn; } @@ -224,7 +224,7 @@ g_free(conn->verifiedip); gaim_circ_buffer_destroy(conn->buffer_outgoing); - conn->od->peer_connections = g_list_remove(conn->od->peer_connections, conn); + conn->od->peer_connections = g_slist_remove(conn->od->peer_connections, conn); g_free(conn); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-09-01 08:53:56
|
Revision: 17110 http://svn.sourceforge.net/gaim/?rev=17110&view=rev Author: thekingant Date: 2006-09-01 01:52:23 -0700 (Fri, 01 Sep 2006) Log Message: ----------- Make peer disconnection error messages a little better for oscar ft and direct connect Modified Paths: -------------- trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/odc.c trunk/libgaim/protocols/oscar/oft.c trunk/libgaim/protocols/oscar/oscar.c trunk/libgaim/protocols/oscar/oscar_data.c trunk/libgaim/protocols/oscar/peer.c trunk/libgaim/protocols/oscar/peer.h Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-09-01 08:19:31 UTC (rev 17109) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-09-01 08:52:23 UTC (rev 17110) @@ -316,6 +316,7 @@ gaim_debug_info("oscar", "Scheduling destruction of FLAP " "connection of type 0x%04hx\n", conn->type); conn->disconnect_reason = reason; + g_free(conn->error_message); conn->error_message = g_strdup(error_message); conn->destroy_timeout = gaim_timeout_add(0, flap_connection_destroy_cb, conn); } Modified: trunk/libgaim/protocols/oscar/odc.c =================================================================== --- trunk/libgaim/protocols/oscar/odc.c 2006-09-01 08:19:31 UTC (rev 17109) +++ trunk/libgaim/protocols/oscar/odc.c 2006-09-01 08:52:23 UTC (rev 17110) @@ -34,18 +34,19 @@ void peer_odc_close(PeerConnection *conn) { - const gchar *tmp; + gchar *tmp; if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_CLOSED) - tmp = _("The remote user has closed the connection."); + tmp = g_strdup(_("The remote user has closed the connection.")); else if (conn->disconnect_reason == OSCAR_DISCONNECT_REMOTE_REFUSED) - tmp = _("The remote user has declined your request."); + tmp = g_strdup(_("The remote user has declined your request.")); else if (conn->disconnect_reason == OSCAR_DISCONNECT_LOST_CONNECTION) - tmp = _("Lost connection with the remote user for an unknown reason."); + tmp = g_strdup_printf(_("Lost connection with the remote user:<br>%s"), + conn->error_message); else if (conn->disconnect_reason == OSCAR_DISCONNECT_INVALID_DATA) - tmp = _("Received invalid data on connection with remote user."); + tmp = g_strdup(_("Received invalid data on connection with remote user.")); else if (conn->disconnect_reason == OSCAR_DISCONNECT_COULD_NOT_CONNECT) - tmp = _("Could not establish a connection with the remote user."); + tmp = g_strdup(_("Could not establish a connection with the remote user.")); else /* * We shouldn't print a message for some disconnect_reasons. @@ -61,6 +62,7 @@ account = gaim_connection_get_account(conn->od->gc); conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, conn->sn); gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); + g_free(tmp); } if (conn->frame != NULL) @@ -442,7 +444,7 @@ /* Check if the remote user closed the connection */ if (read == 0) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); return; } @@ -452,7 +454,8 @@ /* No worries */ return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; } @@ -526,7 +529,8 @@ */ gaim_debug_info("oscar", "Received an incorrect cookie. " "Closing connection.\n"); - peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_INVALID_DATA, NULL); g_free(frame); return; } Modified: trunk/libgaim/protocols/oscar/oft.c =================================================================== --- trunk/libgaim/protocols/oscar/oft.c 2006-09-01 08:19:31 UTC (rev 17109) +++ trunk/libgaim/protocols/oscar/oft.c 2006-09-01 08:52:23 UTC (rev 17110) @@ -269,7 +269,7 @@ if (gaim_circ_buffer_get_max_read(conn->buffer_outgoing) == 0) { conn->sending_data_timer = 0; - peer_connection_destroy(conn, conn->disconnect_reason); + peer_connection_destroy(conn, conn->disconnect_reason, NULL); return FALSE; } @@ -307,7 +307,7 @@ { gaim_debug_info("oscar", "Received an incorrect cookie. " "Closing connection.\n"); - peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA); + peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA, NULL); return; } @@ -521,7 +521,7 @@ if (conn == NULL) return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); } /*******************************************************************/ Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-09-01 08:19:31 UTC (rev 17109) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-09-01 08:52:23 UTC (rev 17110) @@ -2044,7 +2044,7 @@ */ if (conn != NULL) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); } } else if (args->status == AIM_RENDEZVOUS_CONNECTED) @@ -2275,6 +2275,7 @@ msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); for (i=0; msg1[i]; i++) { gaim_str_strip_char(msg1[i], '\r'); + /* TODO: Should use an encoding other than ASCII? */ msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); } msg2[i] = NULL; @@ -2583,7 +2584,7 @@ } else { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_REFUSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_REFUSED, NULL); } } else @@ -6349,7 +6350,7 @@ if (!conn->ready) aim_im_sendch2_cancel(conn); - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); } } Modified: trunk/libgaim/protocols/oscar/oscar_data.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar_data.c 2006-09-01 08:19:31 UTC (rev 17109) +++ trunk/libgaim/protocols/oscar/oscar_data.c 2006-09-01 08:52:23 UTC (rev 17110) @@ -113,7 +113,7 @@ while (od->peer_connections != NULL) peer_connection_destroy(od->peer_connections->data, - OSCAR_DISCONNECT_LOCAL_CLOSED); + OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); if (od->handlerlist != NULL) aim_clearhandlers(od); Modified: trunk/libgaim/protocols/oscar/peer.c =================================================================== --- trunk/libgaim/protocols/oscar/peer.c 2006-09-01 08:19:31 UTC (rev 17109) +++ trunk/libgaim/protocols/oscar/peer.c 2006-09-01 08:52:23 UTC (rev 17110) @@ -219,6 +219,8 @@ conn->xfer = NULL; } + g_free(conn->sn); + g_free(conn->error_message); g_free(conn->proxyip); g_free(conn->clientip); g_free(conn->verifiedip); @@ -232,16 +234,18 @@ } void -peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason) +peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message) { - conn->disconnect_reason = reason; if (conn->destroy_timeout != 0) gaim_timeout_remove(conn->destroy_timeout); + conn->disconnect_reason = reason; + g_free(conn->error_message); + conn->error_message = g_strdup(error_message); peer_connection_destroy_cb(conn); } void -peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason) +peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message) { if (conn->destroy_timeout != 0) /* Already taken care of */ @@ -249,6 +253,8 @@ gaim_debug_info("oscar", "Scheduling destruction of peer connection\n"); conn->disconnect_reason = reason; + g_free(conn->error_message); + conn->error_message = g_strdup(error_message); conn->destroy_timeout = gaim_timeout_add(0, peer_connection_destroy_cb, conn); } @@ -289,7 +295,7 @@ /* Check if the remote user closed the connection */ if (read == 0) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); return; } @@ -300,7 +306,8 @@ /* No worries */ return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; } @@ -321,7 +328,7 @@ "Closing connection.\n", conn->magic[0], conn->magic[1], conn->magic[2], conn->magic[3], header[0], header[1], header[2], header[3]); - peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA); + peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA, NULL); return; } @@ -340,7 +347,7 @@ /* Check if the remote user closed the connection */ if (read == 0) { - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); return; } @@ -350,7 +357,8 @@ /* No worries */ return; - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; } @@ -407,7 +415,8 @@ return; if (conn->ready) - peer_connection_schedule_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION); + peer_connection_schedule_destroy(conn, + OSCAR_DISCONNECT_LOST_CONNECTION, NULL); else { /* @@ -810,7 +819,7 @@ } /* Give up! */ - peer_connection_destroy(conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); + peer_connection_destroy(conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT, NULL); } /** @@ -842,7 +851,7 @@ } /* Cancel the old connection and try again */ - peer_connection_destroy(conn, OSCAR_DISCONNECT_RETRYING); + peer_connection_destroy(conn, OSCAR_DISCONNECT_RETRYING, NULL); } } @@ -885,7 +894,7 @@ aim_im_denytransfer(conn->od, conn->sn, conn->cookie, AIM_TRANSFER_DENY_DECLINE); - peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); } /** @@ -938,7 +947,7 @@ /* Close the old direct IM and start a new one */ gaim_debug_info("oscar", "Received new direct IM request " "from %s. Destroying old connection.\n", sn); - peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED); + peer_connection_destroy(conn, OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); } } Modified: trunk/libgaim/protocols/oscar/peer.h =================================================================== --- trunk/libgaim/protocols/oscar/peer.h 2006-09-01 08:19:31 UTC (rev 17109) +++ trunk/libgaim/protocols/oscar/peer.h 2006-09-01 08:52:23 UTC (rev 17110) @@ -147,6 +147,7 @@ time_t lastactivity; /**< Time of last transmit. */ guint destroy_timeout; OscarDisconnectReason disconnect_reason; + char *error_message; /** * A pointer to either an OdcFrame or an OftFrame. @@ -221,8 +222,8 @@ */ PeerConnection *peer_connection_new(OscarData *od, OscarCapability type, const char *sn); -void peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason); -void peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason); +void peer_connection_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message); +void peer_connection_schedule_destroy(PeerConnection *conn, OscarDisconnectReason reason, const gchar *error_message); PeerConnection *peer_connection_find_by_type(OscarData *od, const char *sn, OscarCapability type); PeerConnection *peer_connection_find_by_cookie(OscarData *od, const char *sn, const guchar *cookie); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-09-14 18:50:36
|
Revision: 17275 http://svn.sourceforge.net/gaim/?rev=17275&view=rev Author: thekingant Date: 2006-09-14 11:50:32 -0700 (Thu, 14 Sep 2006) Log Message: ----------- Advertise the same capabilities for both AIM and ICQ Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_oservice.c trunk/libgaim/protocols/oscar/oscar.c Modified: trunk/libgaim/protocols/oscar/family_oservice.c =================================================================== --- trunk/libgaim/protocols/oscar/family_oservice.c 2006-09-14 07:52:26 UTC (rev 17274) +++ trunk/libgaim/protocols/oscar/family_oservice.c 2006-09-14 18:50:32 UTC (rev 17275) @@ -801,6 +801,8 @@ * * These are the same TLVs seen in user info. You can * also set 0x0008 and 0x000c. + * + * TODO: Combine this with the function below. */ int aim_setextstatus(OscarData *od, guint32 status) @@ -843,6 +845,8 @@ * * These are the same TLVs seen in user info. You can * also set 0x0008 and 0x000c. + * + * TODO: Combine this with the above function. */ int aim_srv_setstatusmsg(OscarData *od, const char *msg) @@ -850,38 +854,31 @@ FlapConnection *conn; FlapFrame *frame; aim_snacid_t snacid; + int msglen; if (!od || !(conn = flap_connection_findbygroup(od, 0x0004))) return -EINVAL; - if ((msg != NULL) && *msg != '\0') { - frame = flap_frame_new(od, 0x02, 10 + 4 + strlen(msg) + 8); + if (msg == NULL) + msglen = 0; + else + msglen = strlen(msg); - snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0); - aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid); + frame = flap_frame_new(od, 0x02, 10 + 4 + msglen + 8); - byte_stream_put16(&frame->data, 0x001d); /* userinfo TLV type */ - byte_stream_put16(&frame->data, strlen(msg)+8); /* total length of userinfo TLV data */ - byte_stream_put16(&frame->data, 0x0002); - byte_stream_put8(&frame->data, 0x04); - byte_stream_put8(&frame->data, strlen(msg)+4); - byte_stream_put16(&frame->data, strlen(msg)); + snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0); + aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid); + + byte_stream_put16(&frame->data, 0x001d); /* userinfo TLV type */ + byte_stream_put16(&frame->data, msglen + 8); /* total length of userinfo TLV data */ + byte_stream_put16(&frame->data, 0x0002); + byte_stream_put8(&frame->data, 0x04); + byte_stream_put8(&frame->data, msglen+4); + byte_stream_put16(&frame->data, msglen); + if (msglen > 0) byte_stream_putstr(&frame->data, msg); - byte_stream_put16(&frame->data, 0x0000); - } else { - frame = flap_frame_new(od, 0x02, 10 + 4 + 8); + byte_stream_put16(&frame->data, 0x0000); - snacid = aim_cachesnac(od, 0x0001, 0x001e, 0x0000, NULL, 0); - aim_putsnac(&frame->data, 0x0001, 0x001e, 0x0000, snacid); - - byte_stream_put16(&frame->data, 0x001d); - byte_stream_put16(&frame->data, 0x0008); - byte_stream_put16(&frame->data, 0x0002); - byte_stream_put16(&frame->data, 0x0404); - byte_stream_put16(&frame->data, 0x0000); - byte_stream_put16(&frame->data, 0x0000); - } - flap_connection_send(conn, frame); return 0; Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-09-14 07:52:26 UTC (rev 17274) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-09-14 18:50:32 UTC (rev 17275) @@ -68,8 +68,7 @@ #define OSCAR_DEFAULT_WEB_AWARE FALSE #define OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY FALSE -static int caps_aim = OSCAR_CAPABILITY_CHAT | OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT; -static int caps_icq = OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_ICQUTF8 | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT; +static OscarCapability gaim_caps = OSCAR_CAPABILITY_CHAT | OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_ICQUTF8 | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT; static guint8 features_aim[] = {0x01, 0x01, 0x01, 0x02}; static guint8 features_icq[] = {0x01, 0x06}; @@ -584,7 +583,7 @@ return g_string_free(cpy, FALSE); } -static gchar *oscar_caps_to_string(guint caps) +static gchar *oscar_caps_to_string(OscarCapability caps) { GString *str; const gchar *tmp; @@ -1806,9 +1805,9 @@ static void gaim_check_comment(OscarData *od, const char *str) { if ((str == NULL) || strcmp(str, (const char *)ck)) - aim_locate_setcaps(od, caps_aim); + aim_locate_setcaps(od, gaim_caps); else - aim_locate_setcaps(od, caps_aim | OSCAR_CAPABILITY_SECUREIM); + aim_locate_setcaps(od, gaim_caps | OSCAR_CAPABILITY_SECUREIM); } static int gaim_parse_offgoing(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { @@ -3470,10 +3469,7 @@ od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; - if (od->icq) - aim_locate_setcaps(od, caps_icq); - else - aim_locate_setcaps(od, caps_aim); + aim_locate_setcaps(od, gaim_caps); oscar_set_info_and_status(account, TRUE, account->user_info, TRUE, gaim_account_get_active_status(account)); @@ -4804,8 +4800,11 @@ } if (!aim_sncmp(curitem->name, account->username)) { char *comment = aim_ssi_getcomment(od->ssi.local, gname, curitem->name); - gaim_check_comment(od, comment); - g_free(comment); + if (comment != NULL) + { + gaim_check_comment(od, comment); + g_free(comment); + } } g_free(gname_utf8); g_free(alias_utf8); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-09-14 22:22:01
|
Revision: 17280 http://svn.sourceforge.net/gaim/?rev=17280&view=rev Author: thekingant Date: 2006-09-14 15:21:52 -0700 (Thu, 14 Sep 2006) Log Message: ----------- Fix a misnamed define. UTF8 is wrong. The actual encoding used is UCS-2BE. No functionality change. Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_locate.c trunk/libgaim/protocols/oscar/oscar.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_locate.c =================================================================== --- trunk/libgaim/protocols/oscar/family_locate.c 2006-09-14 21:53:30 UTC (rev 17279) +++ trunk/libgaim/protocols/oscar/family_locate.c 2006-09-14 22:21:52 UTC (rev 17280) @@ -172,11 +172,11 @@ {0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, - {OSCAR_CAPABILITY_ICQUTF8, + {OSCAR_CAPABILITY_UNICODE, {0x09, 0x46, 0x13, 0x4e, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, - {OSCAR_CAPABILITY_ICQUTF8OLD, + {OSCAR_CAPABILITY_UNICODEOLD, {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8, 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}}, Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-09-14 21:53:30 UTC (rev 17279) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-09-14 22:21:52 UTC (rev 17280) @@ -68,7 +68,7 @@ #define OSCAR_DEFAULT_WEB_AWARE FALSE #define OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY FALSE -static OscarCapability gaim_caps = OSCAR_CAPABILITY_CHAT | OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_ICQUTF8 | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT; +static OscarCapability gaim_caps = OSCAR_CAPABILITY_CHAT | OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_UNICODE | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT; static guint8 features_aim[] = {0x01, 0x01, 0x01, 0x02}; static guint8 features_icq[] = {0x01, 0x06}; @@ -460,7 +460,7 @@ if ((destsn != NULL) && aim_sn_is_icq(destsn)) userinfo = aim_locate_finduserinfo(od, destsn); - if ((userinfo != NULL) && (userinfo->capabilities & OSCAR_CAPABILITY_ICQUTF8)) + if ((userinfo != NULL) && (userinfo->capabilities & OSCAR_CAPABILITY_UNICODE)) { GaimBuddy *b; b = gaim_find_buddy(account, destsn); @@ -639,13 +639,13 @@ case OSCAR_CAPABILITY_ICQSERVERRELAY: tmp = _("ICQ Server Relay"); break; - case OSCAR_CAPABILITY_ICQUTF8OLD: + case OSCAR_CAPABILITY_UNICODEOLD: tmp = _("Old ICQ UTF8"); break; case OSCAR_CAPABILITY_TRILLIANCRYPT: tmp = _("Trillian Encryption"); break; - case OSCAR_CAPABILITY_ICQUTF8: + case OSCAR_CAPABILITY_UNICODE: tmp = _("ICQ UTF8"); break; case OSCAR_CAPABILITY_HIPTOP: Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-09-14 21:53:30 UTC (rev 17279) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-09-14 22:21:52 UTC (rev 17280) @@ -315,9 +315,9 @@ OSCAR_CAPABILITY_ICQRTF = 0x00001000, OSCAR_CAPABILITY_EMPTY = 0x00002000, OSCAR_CAPABILITY_ICQSERVERRELAY = 0x00004000, - OSCAR_CAPABILITY_ICQUTF8OLD = 0x00008000, + OSCAR_CAPABILITY_UNICODEOLD = 0x00008000, OSCAR_CAPABILITY_TRILLIANCRYPT = 0x00010000, - OSCAR_CAPABILITY_ICQUTF8 = 0x00020000, + OSCAR_CAPABILITY_UNICODE = 0x00020000, OSCAR_CAPABILITY_INTEROPERATE = 0x00040000, OSCAR_CAPABILITY_ICHAT = 0x00080000, OSCAR_CAPABILITY_HIPTOP = 0x00100000, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-11-07 02:53:46
|
Revision: 17690 http://svn.sourceforge.net/gaim/?rev=17690&view=rev Author: thekingant Date: 2006-11-06 18:53:42 -0800 (Mon, 06 Nov 2006) Log Message: ----------- gbooleanize some things. No functionality change. Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_feedbag.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_feedbag.c =================================================================== --- trunk/libgaim/protocols/oscar/family_feedbag.c 2006-11-07 02:50:09 UTC (rev 17689) +++ trunk/libgaim/protocols/oscar/family_feedbag.c 2006-11-07 02:53:42 UTC (rev 17690) @@ -570,7 +570,7 @@ /* Make sure we don't send anything else between now * and when we receive the ack for the following operation */ - od->ssi.waiting_for_ack = 1; + od->ssi.waiting_for_ack = TRUE; /* Now go mail off our data and wait 4 to 6 weeks */ aim_ssi_addmoddel(od); @@ -1316,7 +1316,7 @@ for (cur=od->ssi.official; cur; cur=cur->next) aim_ssi_itemlist_add(&od->ssi.local, cur->name, cur->gid, cur->bid, cur->type, cur->data); - od->ssi.received_data = 1; + od->ssi.received_data = TRUE; if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) ret = userfunc(od, conn, frame, fmtver, od->ssi.numitems, od->ssi.timestamp); @@ -1645,7 +1645,7 @@ /* If we're not waiting for any more acks, then send more SNACs */ if (!od->ssi.pending) { - od->ssi.waiting_for_ack = 0; + od->ssi.waiting_for_ack = FALSE; aim_ssi_sync(od); } @@ -1664,7 +1664,7 @@ int ret = 0; aim_rxcallback_t userfunc; - od->ssi.received_data = 1; + od->ssi.received_data = TRUE; if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) ret = userfunc(od, conn, frame); Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-11-07 02:50:09 UTC (rev 17689) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-11-07 02:53:42 UTC (rev 17690) @@ -478,18 +478,18 @@ struct aim_userinfo_s *userinfo; struct userinfo_node *torequest; struct userinfo_node *requested; - int waiting_for_response; + gboolean waiting_for_response; } locate; /* Server-stored information (ssi) */ struct { - int received_data; + gboolean received_data; guint16 numitems; struct aim_ssi_item *official; struct aim_ssi_item *local; struct aim_ssi_tmp *pending; time_t timestamp; - int waiting_for_ack; + gboolean waiting_for_ack; } ssi; /* TODO: Implement this as a HashTable for HUGE speed improvement! */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-11-07 07:05:15
|
Revision: 17693 http://svn.sourceforge.net/gaim/?rev=17693&view=rev Author: thekingant Date: 2006-11-06 23:04:41 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Make sure we send the "starting to edit your buddylist" snac. I thought this would make it so we wouldn't need to re-request authorization when moving someone between groups, but it doesn't. I don't know what the deal is with that. Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_feedbag.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_feedbag.c =================================================================== --- trunk/libgaim/protocols/oscar/family_feedbag.c 2006-11-07 05:52:41 UTC (rev 17692) +++ trunk/libgaim/protocols/oscar/family_feedbag.c 2006-11-07 07:04:41 UTC (rev 17693) @@ -565,9 +565,18 @@ /* We're out of stuff to do, so tell the AIM servers we're done and exit */ if (!od->ssi.pending) { aim_ssi_modend(od); + od->ssi.in_transaction = FALSE; return 0; } + /* If this is the first in a series of add/mod/del + * requests then send the "begin transaction" message. */ + if (!od->ssi.in_transaction) + { + aim_ssi_modbegin(od); + od->ssi.in_transaction = TRUE; + } + /* Make sure we don't send anything else between now * and when we receive the ack for the following operation */ od->ssi.waiting_for_ack = TRUE; Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-11-07 05:52:41 UTC (rev 17692) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-11-07 07:04:41 UTC (rev 17693) @@ -490,6 +490,7 @@ struct aim_ssi_tmp *pending; time_t timestamp; gboolean waiting_for_ack; + gboolean in_transaction; } ssi; /* TODO: Implement this as a HashTable for HUGE speed improvement! */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-11-29 05:27:49
|
Revision: 17844 http://svn.sourceforge.net/gaim/?rev=17844&view=rev Author: datallah Date: 2006-11-28 21:27:49 -0800 (Tue, 28 Nov 2006) Log Message: ----------- On win32, use the current locale charset as the default fallback for oscar. Sean suggested this, it is based on the idea that you're likely to be talking people using a similar locale to you - so if they are using an ICQ client that just sends it in the current locale encoding, it will just work. For the en_US locale, this becomes the "CP1252" encoding. I also removed some duplicate definitions. Modified Paths: -------------- trunk/libgaim/protocols/oscar/oscar.c trunk/libgaim/protocols/oscar/oscarcommon.h Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-11-29 01:20:34 UTC (rev 17843) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-11-29 05:27:49 UTC (rev 17844) @@ -62,13 +62,6 @@ #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" #define OSCAR_CONNECT_STEPS 6 -#define OSCAR_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" -#define OSCAR_DEFAULT_LOGIN_PORT 5190 -#define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" -#define OSCAR_DEFAULT_AUTHORIZATION TRUE -#define OSCAR_DEFAULT_HIDE_IP TRUE -#define OSCAR_DEFAULT_WEB_AWARE FALSE -#define OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY FALSE static OscarCapability gaim_caps = OSCAR_CAPABILITY_CHAT | OSCAR_CAPABILITY_BUDDYICON | OSCAR_CAPABILITY_DIRECTIM | OSCAR_CAPABILITY_SENDFILE | OSCAR_CAPABILITY_UNICODE | OSCAR_CAPABILITY_INTEROPERATE | OSCAR_CAPABILITY_ICHAT; @@ -215,6 +208,15 @@ g_free(data); } +#ifdef _WIN32 +const char *oscar_get_locale_charset(void) { + static const char *charset = NULL; + if (charset == NULL) + g_get_charset(&charset); + return charset; +} +#endif + /** * Determine how we can send this message. Per the warnings elsewhere * in this file, these little checks determine the simplest encoding @@ -2316,12 +2318,10 @@ if (i >= 6) { struct name_data *data = g_new(struct name_data, 1); gchar *sn = g_strdup_printf("%u", args->uin); - gchar *reason; + gchar *reason = NULL; if (msg2[5] != NULL) reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5])); - else - reason = NULL; gaim_debug_info("oscar", "Received an authorization request from UIN %u\n", @@ -2329,7 +2329,7 @@ data->gc = gc; data->name = sn; data->nick = NULL; - + gaim_account_request_authorization(gaim_connection_get_account(gc), sn, NULL, NULL, reason, G_CALLBACK(gaim_auth_grant), G_CALLBACK(gaim_auth_dontgrant_msgprompt), data); g_free(reason); @@ -3503,9 +3503,9 @@ aim_clientready(od, conn); - if (gaim_account_get_user_info(account) != NULL) - serv_set_info(gc, gaim_account_get_user_info(account)); - + if (gaim_account_get_user_info(account) != NULL) + serv_set_info(gc, gaim_account_get_user_info(account)); + /* Set our available message based on the current status */ status = gaim_account_get_active_status(account); if (gaim_status_is_available(status)) @@ -5031,7 +5031,7 @@ data->name = g_strdup(sn); data->nick = NULL; - gaim_account_request_authorization(gaim_connection_get_account(gc), nombre, NULL, NULL, reason, + gaim_account_request_authorization(gaim_connection_get_account(gc), nombre, NULL, NULL, reason, G_CALLBACK(gaim_auth_grant), G_CALLBACK(gaim_auth_dontgrant_msgprompt), data); g_free(nombre); g_free(reason); Modified: trunk/libgaim/protocols/oscar/oscarcommon.h =================================================================== --- trunk/libgaim/protocols/oscar/oscarcommon.h 2006-11-29 01:20:34 UTC (rev 17843) +++ trunk/libgaim/protocols/oscar/oscarcommon.h 2006-11-29 05:27:49 UTC (rev 17844) @@ -31,12 +31,19 @@ #define OSCAR_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" #define OSCAR_DEFAULT_LOGIN_PORT 5190 +#ifndef _WIN32 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" +#else +#define OSCAR_DEFAULT_CUSTOM_ENCODING oscar_get_locale_charset() +#endif #define OSCAR_DEFAULT_AUTHORIZATION TRUE #define OSCAR_DEFAULT_HIDE_IP TRUE #define OSCAR_DEFAULT_WEB_AWARE FALSE #define OSCAR_DEFAULT_ALWAYS_USE_RV_PROXY FALSE +#ifdef _WIN32 +const char *oscar_get_locale_charset(void); +#endif const char *oscar_list_icon_icq(GaimAccount *a, GaimBuddy *b); const char *oscar_list_icon_aim(GaimAccount *a, GaimBuddy *b); void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ev...@us...> - 2006-11-29 22:36:08
|
Revision: 17847 http://svn.sourceforge.net/gaim/?rev=17847&view=rev Author: evands Date: 2006-11-29 14:36:03 -0800 (Wed, 29 Nov 2006) Log Message: ----------- Fixed static compilation; libaim and libicq need to have unique plugin names, and those names should preferably match the names defined by the info struct Modified Paths: -------------- trunk/libgaim/protocols/oscar/libaim.c trunk/libgaim/protocols/oscar/libicq.c Modified: trunk/libgaim/protocols/oscar/libaim.c =================================================================== --- trunk/libgaim/protocols/oscar/libaim.c 2006-11-29 18:05:25 UTC (rev 17846) +++ trunk/libgaim/protocols/oscar/libaim.c 2006-11-29 22:36:03 UTC (rev 17847) @@ -146,4 +146,4 @@ gaim_prefs_remove("/plugins/prpl/oscar/always_use_rv_proxy"); } -GAIM_INIT_PLUGIN(oscar, init_plugin, info); +GAIM_INIT_PLUGIN(aim, init_plugin, info); Modified: trunk/libgaim/protocols/oscar/libicq.c =================================================================== --- trunk/libgaim/protocols/oscar/libicq.c 2006-11-29 18:05:25 UTC (rev 17846) +++ trunk/libgaim/protocols/oscar/libicq.c 2006-11-29 22:36:03 UTC (rev 17847) @@ -150,4 +150,4 @@ gaim_prefs_remove("/plugins/prpl/oscar/always_use_rv_proxy"); } -GAIM_INIT_PLUGIN(oscar, init_plugin, info); +GAIM_INIT_PLUGIN(icq, init_plugin, info); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-02 08:07:37
|
Revision: 17871 http://svn.sourceforge.net/gaim/?rev=17871&view=rev Author: thekingant Date: 2006-12-02 00:03:45 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Minor cleanup. Mostly make some functions void instead of int where the return value was always 0 and wasn't used Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_admin.c trunk/libgaim/protocols/oscar/family_advert.c trunk/libgaim/protocols/oscar/family_bos.c trunk/libgaim/protocols/oscar/family_feedbag.c trunk/libgaim/protocols/oscar/family_oservice.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/misc.c trunk/libgaim/protocols/oscar/oscar.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_admin.c =================================================================== --- trunk/libgaim/protocols/oscar/family_admin.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/family_admin.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -207,10 +207,10 @@ * get the TRIAL flag removed from your account. * */ -int +void aim_admin_reqconfirm(OscarData *od, FlapConnection *conn) { - return aim_genericreq_n(od, conn, 0x0007, 0x0006); + aim_genericreq_n(od, conn, 0x0007, 0x0006); } /* Modified: trunk/libgaim/protocols/oscar/family_advert.c =================================================================== --- trunk/libgaim/protocols/oscar/family_advert.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/family_advert.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -25,9 +25,10 @@ #include "oscar.h" -int aim_ads_requestads(OscarData *od, FlapConnection *conn) +void +aim_ads_requestads(OscarData *od, FlapConnection *conn) { - return aim_genericreq_n(od, conn, 0x0005, 0x0002); + aim_genericreq_n(od, conn, 0x0005, 0x0002); } static int snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) Modified: trunk/libgaim/protocols/oscar/family_bos.c =================================================================== --- trunk/libgaim/protocols/oscar/family_bos.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/family_bos.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -78,9 +78,10 @@ * a bitwise OR of all the user classes you want to see you. * */ -int aim_bos_setgroupperm(OscarData *od, FlapConnection *conn, guint32 mask) +void +aim_bos_setgroupperm(OscarData *od, FlapConnection *conn, guint32 mask) { - return aim_genericreq_l(od, conn, 0x0009, 0x0004, &mask); + aim_genericreq_l(od, conn, 0x0009, 0x0004, &mask); } /* Modified: trunk/libgaim/protocols/oscar/family_feedbag.c =================================================================== --- trunk/libgaim/protocols/oscar/family_feedbag.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/family_feedbag.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -1350,7 +1350,9 @@ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG))) return -EINVAL; - return aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, 0x0007); + aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, 0x0007); + + return 0; } /* @@ -1694,7 +1696,9 @@ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG))) return -EINVAL; - return aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_EDITSTART); + aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_EDITSTART); + + return 0; } /* @@ -1710,7 +1714,9 @@ if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG))) return -EINVAL; - return aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_EDITSTOP); + aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_EDITSTOP); + + return 0; } /* Modified: trunk/libgaim/protocols/oscar/family_oservice.c =================================================================== --- trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -93,19 +93,20 @@ * give it. * */ - aim_setversions(od, conn); + aim_srv_setversions(od, conn); return 1; } /* Subtype 0x0004 - Service request */ -int aim_reqservice(OscarData *od, guint16 serviceid) +void +aim_srv_requestnew(OscarData *od, guint16 serviceid) { FlapConnection *conn; conn = flap_connection_findbygroup(od, SNAC_FAMILY_BOS); - return aim_genericreq_s(od, conn, 0x0001, 0x0004, &serviceid); + aim_genericreq_s(od, conn, 0x0001, 0x0004, &serviceid); } /* @@ -205,7 +206,7 @@ /* Subtype 0x0006 - Request Rate Information. */ void -aim_reqrates(OscarData *od, FlapConnection *conn) +aim_srv_reqrates(OscarData *od, FlapConnection *conn) { aim_genericreq_n_snacid(od, conn, 0x0001, 0x0006); } @@ -256,6 +257,9 @@ * system is how the actual numbers relate to the passing of time. This * seems to be a big mystery. * + * See joscar's javadoc for the RateClassInfo class for a great + * explanation. You might be able to find it at + * http://dscoder.com/RateClassInfo.html */ static void @@ -383,7 +387,7 @@ * Last step in the conn init procedure is to acknowledge that we * agree to these draconian limitations. */ - aim_rates_addparam(od, conn); + aim_srv_rates_addparam(od, conn); /* * Finally, tell the client it's ready to go... @@ -396,7 +400,7 @@ /* Subtype 0x0008 - Add Rate Parameter */ void -aim_rates_addparam(OscarData *od, FlapConnection *conn) +aim_srv_rates_addparam(OscarData *od, FlapConnection *conn) { FlapFrame *frame; aim_snacid_t snacid; @@ -415,7 +419,7 @@ /* Subtype 0x0009 - Delete Rate Parameter */ void -aim_rates_delparam(OscarData *od, FlapConnection *conn) +aim_srv_rates_delparam(OscarData *od, FlapConnection *conn) { FlapFrame *frame; aim_snacid_t snacid; @@ -487,7 +491,7 @@ /* * Subtype 0x000c - Service Pause Acknowledgement * - * It is rather important that aim_sendpauseack() gets called for the exact + * It is rather important that aim_srv_sendpauseack() gets called for the exact * same connection that the Server Pause callback was called for, since * libfaim extracts the data for the SNAC from the connection structure. * @@ -496,7 +500,7 @@ * */ void -aim_sendpauseack(OscarData *od, FlapConnection *conn) +aim_srv_sendpauseack(OscarData *od, FlapConnection *conn) { FlapFrame *frame; aim_snacid_t snacid; @@ -533,7 +537,7 @@ /* Subtype 0x000e - Request self-info */ void -aim_reqpersonalinfo(OscarData *od, FlapConnection *conn) +aim_srv_reqpersonalinfo(OscarData *od, FlapConnection *conn) { aim_genericreq_n_snacid(od, conn, 0x0001, 0x000e); } @@ -589,15 +593,13 @@ * call it again with zero when you're back. * */ -int +void aim_srv_setidle(OscarData *od, guint32 idletime) { FlapConnection *conn; - if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_BOS))) - return -EINVAL; - - return aim_genericreq_l(od, conn, 0x0001, 0x0011, &idletime); + conn = flap_connection_findbygroup(od, SNAC_FAMILY_BOS); + aim_genericreq_l(od, conn, 0x0001, 0x0011, &idletime); } /* @@ -703,10 +705,10 @@ * Bit 2: Allows other AIM users to see how long you've been a member. * */ -int -aim_bos_setprivacyflags(OscarData *od, FlapConnection *conn, guint32 flags) +void +aim_srv_setprivacyflags(OscarData *od, FlapConnection *conn, guint32 flags) { - return aim_genericreq_l(od, conn, 0x0001, 0x0014, &flags); + aim_genericreq_l(od, conn, 0x0001, 0x0014, &flags); } /* @@ -718,10 +720,10 @@ * Wha? No? Since when? I think WinAIM sends an empty channel 5 * FLAP as a no-op... */ -int -aim_nop(OscarData *od, FlapConnection *conn) +void +aim_srv_nop(OscarData *od, FlapConnection *conn) { - return aim_genericreq_n(od, conn, 0x0001, 0x0016); + aim_genericreq_n(od, conn, 0x0001, 0x0016); } /* @@ -738,7 +740,7 @@ * */ void -aim_setversions(OscarData *od, FlapConnection *conn) +aim_srv_setversions(OscarData *od, FlapConnection *conn) { FlapFrame *frame; aim_snacid_t snacid; @@ -782,7 +784,7 @@ /* * Now request rates. */ - aim_reqrates(od, conn); + aim_srv_reqrates(od, conn); return 1; } @@ -805,7 +807,7 @@ * TODO: Combine this with the function below. */ int -aim_setextstatus(OscarData *od, guint32 status) +aim_srv_setextstatus(OscarData *od, guint32 status) { FlapConnection *conn; FlapFrame *frame; Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -681,6 +681,8 @@ break; } + /* TODO: Verify the sequence number sent by the server. */ + /* Initialize a new temporary FlapFrame for incoming data */ conn->buffer_incoming.channel = aimutil_get8(&header[1]); conn->buffer_incoming.seqnum = aimutil_get16(&header[2]); Modified: trunk/libgaim/protocols/oscar/misc.c =================================================================== --- trunk/libgaim/protocols/oscar/misc.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/misc.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -36,7 +36,7 @@ * back to the single. I don't see any advantage to doing it either way. * */ -int +void aim_genericreq_n(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype) { FlapFrame *frame; @@ -47,8 +47,6 @@ aim_putsnac(&frame->data, family, subtype, 0x0000, snacid); flap_connection_send(conn, frame); - - return 0; } void @@ -65,7 +63,7 @@ flap_connection_send(conn, frame); } -int +void aim_genericreq_l(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *longdata) { FlapFrame *frame; @@ -82,11 +80,9 @@ byte_stream_put32(&frame->data, *longdata); flap_connection_send(conn, frame); - - return 0; } -int +void aim_genericreq_s(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 *shortdata) { FlapFrame *frame; @@ -103,8 +99,6 @@ byte_stream_put16(&frame->data, *shortdata); flap_connection_send(conn, frame); - - return 0; } /* Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-12-02 08:03:45 UTC (rev 17871) @@ -1000,7 +1000,7 @@ { GaimConnection *gc = od->gc; - aim_reqpersonalinfo(od, conn); + aim_srv_reqpersonalinfo(od, conn); gaim_debug_info("oscar", "ssi: requesting rights and list\n"); aim_ssi_reqrights(od); @@ -3202,7 +3202,7 @@ conn = flap_connection_getbytype(od, SNAC_FAMILY_BART); if (!conn) { if (!od->iconconnecting) { - aim_reqservice(od, SNAC_FAMILY_BART); + aim_srv_requestnew(od, SNAC_FAMILY_BART); od->iconconnecting = TRUE; } return FALSE; @@ -3527,7 +3527,7 @@ gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE)); } - aim_reqservice(od, SNAC_FAMILY_CHATNAV); + aim_srv_requestnew(od, SNAC_FAMILY_CHATNAV); /* * The "if" statement here is a pathetic attempt to not attempt to @@ -3539,7 +3539,7 @@ * of an annoying error at signon for @anythingelse.com accounts. */ if ((od->authinfo->email != NULL) && ((strchr(gc->account->username, '@') == NULL))) - aim_reqservice(od, SNAC_FAMILY_ALERT); + aim_srv_requestnew(od, SNAC_FAMILY_ALERT); return 1; } @@ -4299,7 +4299,7 @@ else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY; - aim_setextstatus(od, data); + aim_srv_setextstatus(od, data); } static void @@ -5174,7 +5174,7 @@ cr->exchange = atoi(exchange); cr->name = g_strdup(name); od->create_rooms = g_slist_prepend(od->create_rooms, cr); - aim_reqservice(od, SNAC_FAMILY_CHATNAV); + aim_srv_requestnew(od, SNAC_FAMILY_CHATNAV); } } @@ -5493,7 +5493,7 @@ if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) { od->iconconnecting = TRUE; od->set_icon = TRUE; - aim_reqservice(od, SNAC_FAMILY_BART); + aim_srv_requestnew(od, SNAC_FAMILY_BART); } else { struct stat st; char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); @@ -5935,7 +5935,7 @@ if (!flap_connection_getbytype(od, SNAC_FAMILY_ADMIN)) { od->setnick = TRUE; od->newsn = g_strdup(nick); - aim_reqservice(od, SNAC_FAMILY_ADMIN); + aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); } else { aim_admin_setnick(od, flap_connection_getbytype(od, SNAC_FAMILY_ADMIN), nick); } @@ -5969,7 +5969,7 @@ aim_admin_reqconfirm(od, conn); } else { od->conf = TRUE; - aim_reqservice(od, SNAC_FAMILY_ADMIN); + aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); } } @@ -5983,7 +5983,7 @@ aim_admin_getinfo(od, conn, 0x11); } else { od->reqemail = TRUE; - aim_reqservice(od, SNAC_FAMILY_ADMIN); + aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); } } @@ -5997,7 +5997,7 @@ } else { od->setemail = TRUE; od->email = g_strdup(email); - aim_reqservice(od, SNAC_FAMILY_ADMIN); + aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); } } @@ -6328,7 +6328,7 @@ od->chpass = TRUE; od->oldp = g_strdup(old); od->newp = g_strdup(new); - aim_reqservice(od, SNAC_FAMILY_ADMIN); + aim_srv_requestnew(od, SNAC_FAMILY_ADMIN); } } } Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 03:12:57 UTC (rev 17870) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 08:03:45 UTC (rev 17871) @@ -63,7 +63,6 @@ typedef struct _IcbmArgsCh2 IcbmArgsCh2; typedef guint32 aim_snacid_t; -typedef guint16 flap_seqnum_t; #include "snactypes.h" @@ -355,7 +354,7 @@ struct _FlapFrame { guint8 channel; - flap_seqnum_t seqnum; + guint16 seqnum; ByteStream data; /* payload stream */ }; @@ -382,7 +381,7 @@ guint16 type; guint16 subtype; - flap_seqnum_t seqnum; + guint16 seqnum; /**< The sequence number of most recent outgoing packet. */ guint32 status; GSList *groups; struct rateclass *rates; @@ -585,16 +584,10 @@ void flap_connection_send_keepalive(OscarData *od, FlapConnection *conn); FlapFrame *flap_frame_new(OscarData *od, guint16 channel, int datalen); - OscarData *oscar_data_new(void); void oscar_data_destroy(OscarData *); -/* 0x0001 - family_oservice.c */ -int aim_srv_setstatusmsg(OscarData *od, const char *msg); -int aim_srv_setidle(OscarData *od, guint32 idletime); - /* misc.c */ - #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 #define AIM_VISIBILITYCHANGE_DENYADD 0x07 @@ -605,15 +598,29 @@ #define AIM_WARN_ANON 0x01 -int aim_nop(OscarData *, FlapConnection *); -int aim_bos_changevisibility(OscarData *, FlapConnection *, int, const char *); -int aim_bos_setgroupperm(OscarData *, FlapConnection *, guint32 mask); -int aim_bos_setprivacyflags(OscarData *, FlapConnection *, guint32); -void aim_reqpersonalinfo(OscarData *, FlapConnection *); -int aim_reqservice(OscarData *, guint16); -void aim_bos_reqrights(OscarData *, FlapConnection *); -int aim_setextstatus(OscarData *od, guint32 status); + +/* 0x0001 - family_oservice.c */ +/* 0x0004 */ void aim_srv_requestnew(OscarData *od, guint16 serviceid); +/* 0x0006 */ void aim_srv_reqrates(OscarData *od, FlapConnection *conn); +/* 0x0008 */ void aim_srv_rates_addparam(OscarData *od, FlapConnection *conn); +/* 0x0009 */ void aim_srv_rates_delparam(OscarData *od, FlapConnection *conn); +/* 0x000c */ void aim_srv_sendpauseack(OscarData *od, FlapConnection *conn); +/* 0x000e */ void aim_srv_reqpersonalinfo(OscarData *od, FlapConnection *conn); +/* 0x0011 */ void aim_srv_setidle(OscarData *od, guint32 idletime); +/* 0x0014 */ void aim_srv_setprivacyflags(OscarData *od, FlapConnection *conn, guint32); +/* 0x0016 */ void aim_srv_nop(OscarData *od, FlapConnection *conn); +/* 0x0017 */ void aim_srv_setversions(OscarData *od, FlapConnection *conn); +/* 0x001e */ int aim_srv_setstatusmsg(OscarData *od, const char *msg); +/* 0x001e */ int aim_srv_setextstatus(OscarData *od, guint32 status); + + +void aim_bos_reqrights(OscarData *od, FlapConnection *conn); +int aim_bos_changevisibility(OscarData *od, FlapConnection *conn, int, const char *); +void aim_bos_setgroupperm(OscarData *od, FlapConnection *conn, guint32 mask); + + + #define AIM_CLIENTTYPE_UNKNOWN 0x0000 #define AIM_CLIENTTYPE_MC 0x0001 #define AIM_CLIENTTYPE_WINAIM 0x0002 @@ -625,7 +632,7 @@ #define AIM_RATE_CODE_WARNING 0x0002 #define AIM_RATE_CODE_LIMIT 0x0003 #define AIM_RATE_CODE_CLEARLIMIT 0x0004 -int aim_ads_requestads(OscarData *od, FlapConnection *conn); +void aim_ads_requestads(OscarData *od, FlapConnection *conn); @@ -1292,7 +1299,7 @@ /* 0x0017 - family_auth.c */ void aim_sendcookie(OscarData *, FlapConnection *, const guint16 length, const guint8 *); int aim_admin_changepasswd(OscarData *, FlapConnection *, const char *newpw, const char *curpw); -int aim_admin_reqconfirm(OscarData *od, FlapConnection *conn); +void aim_admin_reqconfirm(OscarData *od, FlapConnection *conn); int aim_admin_getinfo(OscarData *od, FlapConnection *conn, guint16 info); int aim_admin_setemail(OscarData *od, FlapConnection *conn, const char *newemail); int aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick); @@ -1489,10 +1496,10 @@ int icq_modfirst(OscarData *od, aim_module_t *mod); int email_modfirst(OscarData *od, aim_module_t *mod); -int aim_genericreq_n(OscarData *, FlapConnection *conn, guint16 family, guint16 subtype); -void aim_genericreq_n_snacid(OscarData *, FlapConnection *conn, guint16 family, guint16 subtype); -int aim_genericreq_l(OscarData *, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *); -int aim_genericreq_s(OscarData *, FlapConnection *conn, guint16 family, guint16 subtype, guint16 *); +void aim_genericreq_n(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype); +void aim_genericreq_n_snacid(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype); +void aim_genericreq_l(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint32 *); +void aim_genericreq_s(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 *); /* bstream.c */ int byte_stream_init(ByteStream *bs, guint8 *data, int len); @@ -1582,17 +1589,6 @@ void flap_connection_destroy_chat(OscarData *od, FlapConnection *conn); -/* These are all handled internally now. */ -void aim_setversions(OscarData *od, FlapConnection *conn); -void aim_reqrates(OscarData *, FlapConnection *); -void aim_rates_addparam(OscarData *, FlapConnection *); -void aim_rates_delparam(OscarData *, FlapConnection *); -void aim_sendpauseack(OscarData *od, FlapConnection *conn); - - - - - #ifdef __cplusplus } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-02 08:41:16
|
Revision: 17872 http://svn.sourceforge.net/gaim/?rev=17872&view=rev Author: thekingant Date: 2006-12-02 00:37:24 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Use GSLists in two places instead of self-made linked lists. I find this to be much more readable. 3 files changed, 67 insertions(+), 88 deletions(-) Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_oservice.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_oservice.c =================================================================== --- trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 08:03:45 UTC (rev 17871) +++ trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 08:37:24 UTC (rev 17872) @@ -262,57 +262,32 @@ * http://dscoder.com/RateClassInfo.html */ -static void -rc_addclass(struct rateclass **head, struct rateclass *inrc) -{ - struct rateclass *rc, *rc2; - - rc = g_memdup(inrc, sizeof(struct rateclass)); - rc->next = NULL; - - for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next) - ; - - if (!rc2) - *head = rc; - else - rc2->next = rc; - - return; -} - static struct rateclass * -rc_findclass(struct rateclass **head, guint16 id) +rateclass_find(GSList *rateclasses, guint16 id) { - struct rateclass *rc; + GSList *tmp; + struct rateclass *rateclass; - for (rc = *head; rc; rc = rc->next) { - if (rc->classid == id) - return rc; + for (tmp = rateclasses; tmp != NULL; tmp = tmp->next) + { + rateclass = tmp->data; + if (rateclass->classid == id) + return rateclass; } return NULL; } static void -rc_addpair(struct rateclass *rc, guint16 group, guint16 type) +rateclass_addpair(struct rateclass *rateclass, guint16 group, guint16 type) { - struct snacpair *sp, *sp2; + struct snacpair *snacpair; - sp = g_new0(struct snacpair, 1); - sp->group = group; - sp->subtype = type; - sp->next = NULL; + snacpair = g_new(struct snacpair, 1); + snacpair->group = group; + snacpair->subtype = type; - for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next) - ; - - if (!sp2) - rc->members = sp; - else - sp2->next = sp; - - return; + rateclass->members = g_slist_prepend(rateclass->members, snacpair); } /* Subtype 0x0007 - Rate Parameters */ @@ -326,19 +301,20 @@ * First are the parameters for each rate class. */ numclasses = byte_stream_get16(bs); - for (i = 0; i < numclasses; i++) { - struct rateclass rc; + for (i = 0; i < numclasses; i++) + { + struct rateclass *rateclass; - memset(&rc, 0, sizeof(struct rateclass)); + rateclass = g_new0(struct rateclass, 1); - rc.classid = byte_stream_get16(bs); - rc.windowsize = byte_stream_get32(bs); - rc.clear = byte_stream_get32(bs); - rc.alert = byte_stream_get32(bs); - rc.limit = byte_stream_get32(bs); - rc.disconnect = byte_stream_get32(bs); - rc.current = byte_stream_get32(bs); - rc.max = byte_stream_get32(bs); + rateclass->classid = byte_stream_get16(bs); + rateclass->windowsize = byte_stream_get32(bs); + rateclass->clear = byte_stream_get32(bs); + rateclass->alert = byte_stream_get32(bs); + rateclass->limit = byte_stream_get32(bs); + rateclass->disconnect = byte_stream_get32(bs); + rateclass->current = byte_stream_get32(bs); + rateclass->max = byte_stream_get32(bs); /* * The server will send an extra five bytes of parameters @@ -348,39 +324,43 @@ * the new version hardcoded here. */ if (mod->version >= 3) - byte_stream_getrawbuf(bs, rc.unknown, sizeof(rc.unknown)); + byte_stream_getrawbuf(bs, rateclass->unknown, sizeof(rateclass->unknown)); - rc_addclass(&conn->rates, &rc); + conn->rateclasses = g_slist_prepend(conn->rateclasses, rateclass); } + conn->rateclasses = g_slist_reverse(conn->rateclasses); /* * Then the members of each class. */ - for (i = 0; i < numclasses; i++) { + for (i = 0; i < numclasses; i++) + { guint16 classid, count; - struct rateclass *rc; + struct rateclass *rateclass; int j; classid = byte_stream_get16(bs); count = byte_stream_get16(bs); - rc = rc_findclass(&conn->rates, classid); + rateclass = rateclass_find(conn->rateclasses, classid); - for (j = 0; j < count; j++) { + for (j = 0; j < count; j++) + { guint16 group, subtype; group = byte_stream_get16(bs); subtype = byte_stream_get16(bs); - if (rc) - rc_addpair(rc, group, subtype); + if (rateclass != NULL) + rateclass_addpair(rateclass, group, subtype); } + rateclass->members = g_slist_reverse(rateclass->members); } /* * We don't pass the rate information up to the client, as it really * doesn't care. The information is stored in the connection, however - * so that we can do more fun stuff later (not really). + * so that we can do rate limiting management when sending SNACs. */ /* @@ -404,15 +384,19 @@ { FlapFrame *frame; aim_snacid_t snacid; - struct rateclass *rc; + GSList *tmp; frame = flap_frame_new(od, 0x02, 512); snacid = aim_cachesnac(od, 0x0001, 0x0008, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0001, 0x0008, 0x0000, snacid); - for (rc = conn->rates; rc; rc = rc->next) - byte_stream_put16(&frame->data, rc->classid); + for (tmp = conn->rateclasses; tmp != NULL; tmp = tmp->next) + { + struct rateclass *rateclass; + rateclass = tmp->data; + byte_stream_put16(&frame->data, rateclass->classid); + } flap_connection_send(conn, frame); } @@ -423,15 +407,19 @@ { FlapFrame *frame; aim_snacid_t snacid; - struct rateclass *rc; + GSList *tmp; frame = flap_frame_new(od, 0x02, 512); snacid = aim_cachesnac(od, 0x0001, 0x0009, 0x0000, NULL, 0); aim_putsnac(&frame->data, 0x0001, 0x0009, 0x0000, snacid); - for (rc = conn->rates; rc; rc = rc->next) - byte_stream_put16(&frame->data, rc->classid); + for (tmp = conn->rateclasses; tmp != NULL; tmp = tmp->next) + { + struct rateclass *rateclass; + rateclass = tmp->data; + byte_stream_put16(&frame->data, rateclass->classid); + } flap_connection_send(conn, frame); } Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 08:03:45 UTC (rev 17871) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 08:37:24 UTC (rev 17872) @@ -184,28 +184,15 @@ } static void -flap_connection_destroy_rates(struct rateclass *head) +flap_connection_destroy_rateclass(struct rateclass *rateclass) { - struct rateclass *rc; - - for (rc = head; rc; ) + while (rateclass->members != NULL) { - struct rateclass *tmp; - struct snacpair *sp; - - tmp = rc->next; - - for (sp = rc->members; sp; ) { - struct snacpair *tmpsp; - - tmpsp = sp->next; - free(sp); - sp = tmpsp; - } - free(rc); - - rc = tmp; + g_free(rateclass->members->data); + rateclass->members = g_slist_delete_link(rateclass->members, rateclass->members); } + + free(rateclass); } static gboolean @@ -269,7 +256,11 @@ flap_connection_destroy_chat(od, conn); g_slist_free(conn->groups); - flap_connection_destroy_rates(conn->rates); + while (conn->rateclasses != NULL) + { + flap_connection_destroy_rateclass(conn->rateclasses->data); + conn->rateclasses = g_slist_delete_link(conn->rateclasses, conn->rateclasses); + } g_free(conn); Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 08:03:45 UTC (rev 17871) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 08:37:24 UTC (rev 17872) @@ -384,7 +384,8 @@ guint16 seqnum; /**< The sequence number of most recent outgoing packet. */ guint32 status; GSList *groups; - struct rateclass *rates; + GSList *rateclasses; /* Contains nodes of struct rateclass */ + /* TODO: Maybe use a GHashTable for rateclasses */ void *internal; /* internal conn-specific libfaim data */ }; @@ -1560,7 +1561,6 @@ struct snacpair { guint16 group; guint16 subtype; - struct snacpair *next; }; struct rateclass { @@ -1573,8 +1573,8 @@ guint32 current; guint32 max; guint8 unknown[5]; /* only present in versions >= 3 */ - struct snacpair *members; - struct rateclass *next; + GSList *members; /* Contains node of struct snacpair */ + /* TODO: Maybe use a GHashTable for members */ }; int aim_cachecookie(OscarData *od, IcbmCookie *cookie); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-02 09:51:20
|
Revision: 17874 http://svn.sourceforge.net/gaim/?rev=17874&view=rev Author: thekingant Date: 2006-12-02 01:44:53 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Add a flap_connection_send_snac() helper function that makes it a little easier/cleaner to send a SNAC-based FLAP command. Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_icbm.c trunk/libgaim/protocols/oscar/family_locate.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_icbm.c =================================================================== --- trunk/libgaim/protocols/oscar/family_icbm.c 2006-12-02 08:56:35 UTC (rev 17873) +++ trunk/libgaim/protocols/oscar/family_icbm.c 2006-12-02 09:44:53 UTC (rev 17874) @@ -269,8 +269,8 @@ int aim_im_sendch1_ext(OscarData *od, struct aim_sendimext_args *args) { FlapConnection *conn; - FlapFrame *frame; aim_snacid_t snacid; + ByteStream data; guchar cookie[8]; int msgtlvlen; static const guint8 deffeatures[] = { 0x01, 0x01, 0x01, 0x02 }; @@ -313,30 +313,26 @@ msgtlvlen += 4 /* charset */ + args->msglen; } - frame = flap_frame_new(od, 0x02, msgtlvlen+128); + byte_stream_init(&data, g_malloc(msgtlvlen + 128), msgtlvlen + 128); - /* XXX - should be optional */ - snacid = aim_cachesnac(od, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1); - aim_putsnac(&frame->data, 0x0004, 0x0006, 0x0000, snacid); - /* Generate an ICBM cookie */ aim_icbm_makecookie(cookie); /* ICBM header */ - aim_im_puticbm(&frame->data, cookie, 0x0001, args->destsn); + aim_im_puticbm(&data, cookie, 0x0001, args->destsn); /* Message TLV (type 0x0002) */ - byte_stream_put16(&frame->data, 0x0002); - byte_stream_put16(&frame->data, msgtlvlen); + byte_stream_put16(&data, 0x0002); + byte_stream_put16(&data, msgtlvlen); /* Features TLV (type 0x0501) */ - byte_stream_put16(&frame->data, 0x0501); + byte_stream_put16(&data, 0x0501); if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) { - byte_stream_put16(&frame->data, args->featureslen); - byte_stream_putraw(&frame->data, args->features, args->featureslen); + byte_stream_put16(&data, args->featureslen); + byte_stream_putraw(&data, args->features, args->featureslen); } else { - byte_stream_put16(&frame->data, sizeof(deffeatures)); - byte_stream_putraw(&frame->data, deffeatures, sizeof(deffeatures)); + byte_stream_put16(&data, sizeof(deffeatures)); + byte_stream_putraw(&data, deffeatures, sizeof(deffeatures)); } if (args->flags & AIM_IMFLAGS_MULTIPART) { @@ -344,42 +340,42 @@ /* Insert each message part in a TLV (type 0x0101) */ for (sec = args->mpmsg->parts; sec; sec = sec->next) { - byte_stream_put16(&frame->data, 0x0101); - byte_stream_put16(&frame->data, sec->datalen + 4); - byte_stream_put16(&frame->data, sec->charset); - byte_stream_put16(&frame->data, sec->charsubset); - byte_stream_putraw(&frame->data, (guchar *)sec->data, sec->datalen); + byte_stream_put16(&data, 0x0101); + byte_stream_put16(&data, sec->datalen + 4); + byte_stream_put16(&data, sec->charset); + byte_stream_put16(&data, sec->charsubset); + byte_stream_putraw(&data, (guchar *)sec->data, sec->datalen); } } else { /* Insert message text in a TLV (type 0x0101) */ - byte_stream_put16(&frame->data, 0x0101); + byte_stream_put16(&data, 0x0101); /* Message block length */ - byte_stream_put16(&frame->data, args->msglen + 0x04); + byte_stream_put16(&data, args->msglen + 0x04); /* Character set */ - byte_stream_put16(&frame->data, args->charset); - byte_stream_put16(&frame->data, args->charsubset); + byte_stream_put16(&data, args->charset); + byte_stream_put16(&data, args->charsubset); /* Message. Not terminated */ - byte_stream_putraw(&frame->data, (guchar *)args->msg, args->msglen); + byte_stream_putraw(&data, (guchar *)args->msg, args->msglen); } /* Set the Autoresponse flag */ if (args->flags & AIM_IMFLAGS_AWAY) { - byte_stream_put16(&frame->data, 0x0004); - byte_stream_put16(&frame->data, 0x0000); + byte_stream_put16(&data, 0x0004); + byte_stream_put16(&data, 0x0000); } else if (args->flags & AIM_IMFLAGS_ACK) { /* Set the Request Acknowledge flag */ - byte_stream_put16(&frame->data, 0x0003); - byte_stream_put16(&frame->data, 0x0000); + byte_stream_put16(&data, 0x0003); + byte_stream_put16(&data, 0x0000); } if (args->flags & AIM_IMFLAGS_OFFLINE) { - byte_stream_put16(&frame->data, 0x0006); - byte_stream_put16(&frame->data, 0x0000); + byte_stream_put16(&data, 0x0006); + byte_stream_put16(&data, 0x0000); } /* @@ -388,12 +384,12 @@ * IMs and when you change your icon. */ if (args->flags & AIM_IMFLAGS_HASICON) { - byte_stream_put16(&frame->data, 0x0008); - byte_stream_put16(&frame->data, 0x000c); - byte_stream_put32(&frame->data, args->iconlen); - byte_stream_put16(&frame->data, 0x0001); - byte_stream_put16(&frame->data, args->iconsum); - byte_stream_put32(&frame->data, args->iconstamp); + byte_stream_put16(&data, 0x0008); + byte_stream_put16(&data, 0x000c); + byte_stream_put32(&data, args->iconlen); + byte_stream_put16(&data, 0x0001); + byte_stream_put16(&data, args->iconsum); + byte_stream_put32(&data, args->iconstamp); } /* @@ -401,12 +397,16 @@ * XXX - Every time? Surely not... */ if (args->flags & AIM_IMFLAGS_BUDDYREQ) { - byte_stream_put16(&frame->data, 0x0009); - byte_stream_put16(&frame->data, 0x0000); + byte_stream_put16(&data, 0x0009); + byte_stream_put16(&data, 0x0000); } - flap_connection_send(conn, frame); + /* XXX - should be optional */ + snacid = aim_cachesnac(od, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1); + flap_connection_send_snac(od, conn, 0x0004, 0x0006, 0x0000, snacid, &data); + g_free(data.data); + /* clean out SNACs over 60sec old */ aim_cleansnacs(od, 60); Modified: trunk/libgaim/protocols/oscar/family_locate.c =================================================================== --- trunk/libgaim/protocols/oscar/family_locate.c 2006-12-02 08:56:35 UTC (rev 17873) +++ trunk/libgaim/protocols/oscar/family_locate.c 2006-12-02 09:44:53 UTC (rev 17874) @@ -1356,23 +1356,24 @@ aim_locate_getinfoshort(OscarData *od, const char *sn, guint32 flags) { FlapConnection *conn; - FlapFrame *frame; + unsigned int length; + ByteStream data; aim_snacid_t snacid; if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !sn) return -EINVAL; - frame = flap_frame_new(od, 0x02, 10+4+1+strlen(sn)); + length = 4 + 1 + strlen(sn); + byte_stream_init(&data, g_malloc(length), length); + byte_stream_put32(&data, flags); + byte_stream_put8(&data, strlen(sn)); + byte_stream_putstr(&data, sn); snacid = aim_cachesnac(od, 0x0002, 0x0015, 0x0000, sn, strlen(sn)+1); + flap_connection_send_snac(od, conn, 0x0002, 0x0015, 0x0000, snacid, &data); - aim_putsnac(&frame->data, 0x0002, 0x0015, 0x0000, snacid); - byte_stream_put32(&frame->data, flags); - byte_stream_put8(&frame->data, strlen(sn)); - byte_stream_putstr(&frame->data, sn); + g_free(data.data); - flap_connection_send(conn, frame); - return 0; } Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 08:56:35 UTC (rev 17873) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 09:44:53 UTC (rev 17874) @@ -51,7 +51,7 @@ } /** - * This sends a channel 1 SNAC containing the FLAP version and + * This sends a channel 1 FLAP containing the FLAP version and * the authentication cookie. This is sent when connecting to * any FLAP server after the initial connection to the auth * server. It is always the very first packet sent by both the @@ -73,7 +73,35 @@ } /** - * This sends an empty channel 4 SNAC. This is sent to signify + * This sends a channel 2 FLAP containing a SNAC. The SNAC family and + * subtype are looked up in the rate info for this connection, and if + * sending this SNAC will induce rate limiting then we delay sending + * of the SNAC by putting it into an outgoing holding queue. + */ +void +flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data) +{ + FlapFrame *frame; + guint32 length; + + length = data != NULL ? data->offset : 0; + + frame = flap_frame_new(od, 0x02, 10 + length); + aim_putsnac(&frame->data, family, subtype, flags, snacid); + + if (length > 0) + { + byte_stream_rewind(data); + byte_stream_putbs(&frame->data, data, length); + } + + /* TODO: Outgoing message throttling */ + + flap_connection_send(conn, frame); +} + +/** + * This sends an empty channel 4 FLAP. This is sent to signify * that we're logging off. This shouldn't really be necessary-- * usually the AIM server will detect that the TCP connection has * been destroyed--but it's good practice. @@ -88,7 +116,7 @@ } /** - * This sends an empty channel 5 SNAC. This is used as a keepalive + * This sends an empty channel 5 FLAP. This is used as a keepalive * packet in FLAP connections. WinAIM 4.x and higher send these * _every minute_ to keep the connection alive. */ Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 08:56:35 UTC (rev 17873) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 09:44:53 UTC (rev 17874) @@ -582,6 +582,7 @@ void flap_connection_send(FlapConnection *conn, FlapFrame *frame); void flap_connection_send_version(OscarData *od, FlapConnection *conn); void flap_connection_send_version_with_cookie(OscarData *od, FlapConnection *conn, guint16 length, const guint8 *chipsahoy); +void flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data); void flap_connection_send_keepalive(OscarData *od, FlapConnection *conn); FlapFrame *flap_frame_new(OscarData *od, guint16 channel, int datalen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-02 10:17:15
|
Revision: 17875 http://svn.sourceforge.net/gaim/?rev=17875&view=rev Author: thekingant Date: 2006-12-02 02:17:13 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Add a helper function byte_stream_new() that allocates memory for a bytestream in addition to just initializing the data structure. 9 files changed, 56 insertions(+), 91 deletions(-) Modified Paths: -------------- trunk/libgaim/protocols/oscar/bstream.c trunk/libgaim/protocols/oscar/family_icbm.c trunk/libgaim/protocols/oscar/family_locate.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/odc.c trunk/libgaim/protocols/oscar/oft.c trunk/libgaim/protocols/oscar/oscar.h trunk/libgaim/protocols/oscar/peer_proxy.c trunk/libgaim/protocols/oscar/tlv.c Modified: trunk/libgaim/protocols/oscar/bstream.c =================================================================== --- trunk/libgaim/protocols/oscar/bstream.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/bstream.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -24,10 +24,18 @@ #include "oscar.h" +int byte_stream_new(ByteStream *bs, guint32 len) +{ + if (bs == NULL) + return -1; + + return byte_stream_init(bs, g_malloc(len), len); +} + int byte_stream_init(ByteStream *bs, guint8 *data, int len) { - if (!bs) + if (bs == NULL) return -1; bs->data = data; Modified: trunk/libgaim/protocols/oscar/family_icbm.c =================================================================== --- trunk/libgaim/protocols/oscar/family_icbm.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/family_icbm.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -313,7 +313,7 @@ msgtlvlen += 4 /* charset */ + args->msglen; } - byte_stream_init(&data, g_malloc(msgtlvlen + 128), msgtlvlen + 128); + byte_stream_new(&data, msgtlvlen + 128); /* Generate an ICBM cookie */ aim_icbm_makecookie(cookie); @@ -452,8 +452,6 @@ struct aim_invite_priv *priv; guchar cookie[8]; aim_tlvlist_t *otl = NULL, *itl = NULL; - guint8 *hdr; - int hdrlen; ByteStream hdrbs; if (!od || !(conn = flap_connection_findbygroup(od, 0x0004))) @@ -494,9 +492,7 @@ * raw data, followed by a series of TLVs. * */ - hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2; - hdr = malloc(hdrlen); - byte_stream_init(&hdrbs, hdr, hdrlen); + byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2); byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */ byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */ @@ -508,11 +504,11 @@ aim_tlvlist_add_chatroom(&itl, 0x2711, exchange, roomname, instance); aim_tlvlist_write(&hdrbs, &itl); - aim_tlvlist_add_raw(&otl, 0x0005, byte_stream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&otl, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); + g_free(hdrbs.data); aim_tlvlist_write(&frame->data, &otl); - free(hdr); aim_tlvlist_free(&itl); aim_tlvlist_free(&otl); @@ -694,8 +690,6 @@ FlapFrame *frame; aim_snacid_t snacid; aim_tlvlist_t *tl = NULL, *itl = NULL; - int hdrlen; - guint8 *hdr; ByteStream hdrbs; od = peer_conn->od; @@ -713,9 +707,7 @@ aim_tlvlist_add_noval(&tl, 0x0003); - hdrlen = 64; - hdr = malloc(hdrlen); - byte_stream_init(&hdrbs, hdr, hdrlen); + byte_stream_new(&hdrbs, 64); byte_stream_put16(&hdrbs, AIM_RENDEZVOUS_CANCEL); byte_stream_putraw(&hdrbs, peer_conn->cookie, 8); @@ -725,11 +717,11 @@ aim_tlvlist_add_16(&itl, 0x000b, 0x0001); aim_tlvlist_write(&hdrbs, &itl); - aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); + g_free(hdrbs.data); aim_tlvlist_write(&frame->data, &tl); - free(hdr); aim_tlvlist_free(&itl); aim_tlvlist_free(&tl); @@ -784,8 +776,6 @@ FlapFrame *frame; aim_snacid_t snacid; aim_tlvlist_t *tl = NULL, *itl = NULL; - int hdrlen; - guint8 *hdr; ByteStream hdrbs; conn = flap_connection_findbygroup(od, 0x0004); @@ -802,9 +792,7 @@ aim_tlvlist_add_noval(&tl, 0x0003); - hdrlen = 128; - hdr = malloc(hdrlen); - byte_stream_init(&hdrbs, hdr, hdrlen); + byte_stream_new(&hdrbs, 128); byte_stream_put16(&hdrbs, AIM_RENDEZVOUS_PROPOSE); byte_stream_putraw(&hdrbs, cookie, 8); @@ -817,11 +805,11 @@ aim_tlvlist_add_noval(&itl, 0x000f); aim_tlvlist_write(&hdrbs, &itl); - aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); + g_free(hdrbs.data); aim_tlvlist_write(&frame->data, &tl); - free(hdr); aim_tlvlist_free(&itl); aim_tlvlist_free(&tl); @@ -839,8 +827,6 @@ FlapFrame *frame; aim_snacid_t snacid; aim_tlvlist_t *tl = NULL, *itl = NULL; - int hdrlen; - guint8 *hdr; ByteStream hdrbs; guint8 ip_comp[4]; @@ -858,9 +844,7 @@ aim_tlvlist_add_noval(&tl, 0x0003); - hdrlen = 128; - hdr = malloc(hdrlen); - byte_stream_init(&hdrbs, hdr, hdrlen); + byte_stream_new(&hdrbs, 128); byte_stream_put16(&hdrbs, AIM_RENDEZVOUS_PROPOSE); byte_stream_putraw(&hdrbs, cookie, 8); @@ -883,11 +867,11 @@ aim_tlvlist_write(&hdrbs, &itl); - aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); + g_free(hdrbs.data); aim_tlvlist_write(&frame->data, &tl); - free(hdr); aim_tlvlist_free(&itl); aim_tlvlist_free(&tl); @@ -905,8 +889,6 @@ FlapFrame *frame; aim_snacid_t snacid; aim_tlvlist_t *tl = NULL, *itl = NULL; - int hdrlen, buflen; - guint8 *hdr; ByteStream hdrbs; conn = flap_connection_findbygroup(od, 0x0004); @@ -923,9 +905,7 @@ aim_tlvlist_add_noval(&tl, 0x0003); - hdrlen = 512; - hdr = malloc(hdrlen); - byte_stream_init(&hdrbs, hdr, hdrlen); + byte_stream_new(&hdrbs, 512); byte_stream_put16(&hdrbs, AIM_RENDEZVOUS_PROPOSE); byte_stream_putraw(&hdrbs, cookie, 8); @@ -954,8 +934,7 @@ ByteStream bs; /* Begin TLV t(2711) */ - buflen = 2+2+4+strlen(filename)+1; - byte_stream_init(&bs, malloc(buflen), buflen); + byte_stream_new(&bs, 2+2+4+strlen(filename)+1); byte_stream_put16(&bs, (numfiles > 1) ? 0x0002 : 0x0001); byte_stream_put16(&bs, numfiles); byte_stream_put32(&bs, size); @@ -965,16 +944,16 @@ byte_stream_put8(&bs, 0x00); aim_tlvlist_add_raw(&itl, 0x2711, bs.len, bs.data); - free(bs.data); + g_free(bs.data); /* End TLV t(2711) */ } aim_tlvlist_write(&hdrbs, &itl); - aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); + g_free(hdrbs.data); aim_tlvlist_write(&frame->data, &tl); - free(hdr); aim_tlvlist_free(&itl); aim_tlvlist_free(&tl); @@ -992,8 +971,6 @@ FlapFrame *frame; aim_snacid_t snacid; aim_tlvlist_t *tl = NULL, *itl = NULL; - int hdrlen, buflen; - guint8 *hdr; ByteStream hdrbs; guint8 ip_comp[4]; @@ -1011,9 +988,7 @@ aim_tlvlist_add_noval(&tl, 0x0003); - hdrlen = 512; - hdr = malloc(hdrlen); - byte_stream_init(&hdrbs, hdr, hdrlen); + byte_stream_new(&hdrbs, 512); byte_stream_put16(&hdrbs, AIM_RENDEZVOUS_PROPOSE); byte_stream_putraw(&hdrbs, cookie, 8); @@ -1050,8 +1025,7 @@ ByteStream bs; /* Begin TLV t(2711) */ - buflen = 2+2+4+strlen(filename)+1; - byte_stream_init(&bs, malloc(buflen), buflen); + byte_stream_new(&bs, 2+2+4+strlen(filename)+1); byte_stream_put16(&bs, (numfiles > 1) ? 0x0002 : 0x0001); byte_stream_put16(&bs, numfiles); byte_stream_put32(&bs, size); @@ -1061,17 +1035,17 @@ byte_stream_put8(&bs, 0x00); aim_tlvlist_add_raw(&itl, 0x2711, bs.len, bs.data); - free(bs.data); + g_free(bs.data); /* End TLV t(2711) */ } aim_tlvlist_write(&hdrbs, &itl); - aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&tl, 0x0005, byte_stream_curpos(&hdrbs), hdrbs.data); + g_free(hdrbs.data); aim_tlvlist_write(&frame->data, &tl); - free(hdr); aim_tlvlist_free(&itl); aim_tlvlist_free(&tl); Modified: trunk/libgaim/protocols/oscar/family_locate.c =================================================================== --- trunk/libgaim/protocols/oscar/family_locate.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/family_locate.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -1356,15 +1356,13 @@ aim_locate_getinfoshort(OscarData *od, const char *sn, guint32 flags) { FlapConnection *conn; - unsigned int length; ByteStream data; aim_snacid_t snacid; if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)) || !sn) return -EINVAL; - length = 4 + 1 + strlen(sn); - byte_stream_init(&data, g_malloc(length), length); + byte_stream_new(&data, 4 + 1 + strlen(sn)); byte_stream_put32(&data, flags); byte_stream_put8(&data, strlen(sn)); byte_stream_putstr(&data, sn); Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -480,11 +480,7 @@ frame->channel = channel; if (datalen > 0) - { - guint8 *data; - data = g_malloc(datalen); - byte_stream_init(&frame->data, data, datalen); - } + byte_stream_new(&frame->data, datalen); return frame; } @@ -819,7 +815,7 @@ payloadlen = byte_stream_curpos(&frame->data); - byte_stream_init(&bs, malloc(6 + payloadlen), 6 + payloadlen); + byte_stream_new(&bs, 6 + payloadlen); /* FLAP header */ byte_stream_put8(&bs, 0x2a); @@ -835,7 +831,7 @@ byte_stream_rewind(&bs); flap_connection_send_byte_stream(&bs, conn, bslen); - free(bs.data); /* XXX byte_stream_free */ + g_free(bs.data); /* XXX byte_stream_free */ } void Modified: trunk/libgaim/protocols/oscar/odc.c =================================================================== --- trunk/libgaim/protocols/oscar/odc.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/odc.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -96,8 +96,7 @@ memcpy(frame->cookie, conn->cookie, 8); length = 76; - byte_stream_init(&bs, malloc(length + frame->payload.len), - length + frame->payload.len); + byte_stream_new(&bs, length + frame->payload.len); byte_stream_putraw(&bs, conn->magic, 4); byte_stream_put16(&bs, length); byte_stream_put16(&bs, frame->type); @@ -120,7 +119,7 @@ peer_connection_send(conn, &bs); - free(bs.data); + g_free(bs.data); } /** @@ -188,7 +187,7 @@ frame.payload.len = len; frame.encoding = encoding; frame.flags = autoreply; - byte_stream_init(&frame.payload, malloc(len), len); + byte_stream_new(&frame.payload, len); byte_stream_putraw(&frame.payload, (guint8 *)msg, len); peer_odc_send(conn, &frame); Modified: trunk/libgaim/protocols/oscar/oft.c =================================================================== --- trunk/libgaim/protocols/oscar/oft.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/oft.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -160,7 +160,7 @@ ByteStream bs; length = 192 + MAX(64, frame->name_length + 1); - byte_stream_init(&bs, malloc(length), length); + byte_stream_new(&bs, length); byte_stream_putraw(&bs, conn->magic, 4); byte_stream_put16(&bs, length); byte_stream_put16(&bs, frame->type); @@ -197,7 +197,7 @@ peer_connection_send(conn, &bs); - free(bs.data); + g_free(bs.data); } void Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 10:17:13 UTC (rev 17875) @@ -1504,6 +1504,7 @@ void aim_genericreq_s(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 *); /* bstream.c */ +int byte_stream_new(ByteStream *bs, guint32 len); int byte_stream_init(ByteStream *bs, guint8 *data, int len); int byte_stream_empty(ByteStream *bs); int byte_stream_curpos(ByteStream *bs); Modified: trunk/libgaim/protocols/oscar/peer_proxy.c =================================================================== --- trunk/libgaim/protocols/oscar/peer_proxy.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/peer_proxy.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -38,7 +38,7 @@ frame->flags, frame->payload.len); length = 12 + frame->payload.len; - byte_stream_init(&bs, malloc(length), length); + byte_stream_new(&bs, length); byte_stream_put16(&bs, length - 2); byte_stream_put16(&bs, PEER_PROXY_PACKET_VERSION); byte_stream_put16(&bs, frame->type); @@ -48,7 +48,7 @@ peer_connection_send(conn, &bs); - free(bs.data); + g_free(bs.data); } /** @@ -65,7 +65,6 @@ GaimAccount *account; const gchar *sn; guint8 sn_length; - size_t length; memset(&frame, 0, sizeof(ProxyFrame)); frame.type = PEER_PROXY_TYPE_CREATE; @@ -74,8 +73,7 @@ account = gaim_connection_get_account(conn->od->gc); sn = gaim_account_get_username(account); sn_length = strlen(sn); - length = 1 + sn_length + 8 + 20; - byte_stream_init(&frame.payload, malloc(length), length); + byte_stream_new(&frame.payload, 1 + sn_length + 8 + 20); byte_stream_put8(&frame.payload, sn_length); byte_stream_putraw(&frame.payload, (const guint8 *)sn, sn_length); byte_stream_putraw(&frame.payload, conn->cookie, 8); @@ -103,7 +101,6 @@ GaimAccount *account; const gchar *sn; guint8 sn_length; - size_t length; memset(&frame, 0, sizeof(ProxyFrame)); frame.type = PEER_PROXY_TYPE_JOIN; @@ -112,8 +109,7 @@ account = gaim_connection_get_account(conn->od->gc); sn = gaim_account_get_username(account); sn_length = strlen(sn); - length = 1 + sn_length + 2 + 8 + 20; - byte_stream_init(&frame.payload, malloc(length), length); + byte_stream_new(&frame.payload, 1 + sn_length + 2 + 8 + 20); byte_stream_put8(&frame.payload, sn_length); byte_stream_putraw(&frame.payload, (const guint8 *)sn, sn_length); byte_stream_put16(&frame.payload, pin); Modified: trunk/libgaim/protocols/oscar/tlv.c =================================================================== --- trunk/libgaim/protocols/oscar/tlv.c 2006-12-02 09:44:53 UTC (rev 17874) +++ trunk/libgaim/protocols/oscar/tlv.c 2006-12-02 10:17:13 UTC (rev 17875) @@ -264,8 +264,8 @@ if (aim_tlvlist_size(&one) != aim_tlvlist_size(&two)) return 1; - byte_stream_init(&bs1, ((guint8 *)malloc(aim_tlvlist_size(&one)*sizeof(guint8))), aim_tlvlist_size(&one)); - byte_stream_init(&bs2, ((guint8 *)malloc(aim_tlvlist_size(&two)*sizeof(guint8))), aim_tlvlist_size(&two)); + byte_stream_new(&bs1, aim_tlvlist_size(&one)); + byte_stream_new(&bs2, aim_tlvlist_size(&two)); aim_tlvlist_write(&bs1, &one); aim_tlvlist_write(&bs2, &two); @@ -276,8 +276,8 @@ return 1; } - free(bs1.data); - free(bs2.data); + g_free(bs1.data); + g_free(bs2.data); return 0; } @@ -512,23 +512,19 @@ */ int aim_tlvlist_add_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance) { - guint8 *buf; int len; ByteStream bs; - len = 2 + 1 + strlen(roomname) + 2; + byte_stream_new(&bs, 2 + 1 + strlen(roomname) + 2); - buf = malloc(len); - byte_stream_init(&bs, buf, len); - byte_stream_put16(&bs, exchange); byte_stream_put8(&bs, strlen(roomname)); byte_stream_putstr(&bs, roomname); byte_stream_put16(&bs, instance); - len = aim_tlvlist_add_raw(list, type, byte_stream_curpos(&bs), buf); + len = aim_tlvlist_add_raw(list, type, byte_stream_curpos(&bs), bs.data); - free(buf); + g_free(bs.data); return len; } @@ -563,7 +559,6 @@ */ int aim_tlvlist_add_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl) { - guint8 *buf; int buflen; ByteStream bs; @@ -572,15 +567,13 @@ if (buflen <= 0) return 0; - buf = malloc(buflen); + byte_stream_new(&bs, buflen); - byte_stream_init(&bs, buf, buflen); - aim_tlvlist_write(&bs, tl); - aim_tlvlist_add_raw(list, type, byte_stream_curpos(&bs), buf); + aim_tlvlist_add_raw(list, type, byte_stream_curpos(&bs), bs.data); - free(buf); + g_free(bs.data); return buflen; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-02 10:43:09
|
Revision: 17876 http://svn.sourceforge.net/gaim/?rev=17876&view=rev Author: thekingant Date: 2006-12-02 02:43:06 -0800 (Sat, 02 Dec 2006) Log Message: ----------- First stab at attempting to keep track of our rate limiting average Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_oservice.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_oservice.c =================================================================== --- trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 10:17:13 UTC (rev 17875) +++ trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 10:43:06 UTC (rev 17876) @@ -266,10 +266,10 @@ rateclass_find(GSList *rateclasses, guint16 id) { GSList *tmp; - struct rateclass *rateclass; for (tmp = rateclasses; tmp != NULL; tmp = tmp->next) { + struct rateclass *rateclass; rateclass = tmp->data; if (rateclass->classid == id) return rateclass; Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 10:17:13 UTC (rev 17875) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 10:43:06 UTC (rev 17876) @@ -72,6 +72,42 @@ flap_connection_send(conn, frame); } +static void +update_rate_class(FlapConnection *conn, guint16 family, guint16 subtype) +{ + GSList *tmp1, *tmp2; + + for (tmp1 = conn->rateclasses; tmp1 != NULL; tmp1 = tmp1->next) + { + struct rateclass *rateclass; + rateclass = tmp1->data; + + for (tmp2 = rateclass->members; tmp2 != NULL; tmp2 = tmp2->next) + { + struct snacpair *snacpair; + snacpair = tmp2->data; + if ((snacpair->group == family) && (snacpair->subtype == subtype)) + { + /* + * We've found the rateclass for this SNAC family and + * subtype! Update our "current" average by calculating + * a rolling average. This is pretty shoddy. We should + * really keep track of the times when the last last + * windowsize messages that were sent and just calculate + * the REAL average. + */ + time_t now; + now = time(NULL); + /* This formula is taken from the joscar API docs. */ + rateclass->current = MIN(((rateclass->current * (rateclass->windowsize - 1)) + (now - rateclass->last)) / rateclass->windowsize, rateclass->max); + rateclass->last = now; + return; + } + } + } +} + + /** * This sends a channel 2 FLAP containing a SNAC. The SNAC family and * subtype are looked up in the rate info for this connection, and if @@ -96,6 +132,7 @@ } /* TODO: Outgoing message throttling */ + update_rate_class(conn, family, subtype); flap_connection_send(conn, frame); } Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 10:17:13 UTC (rev 17875) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 10:43:06 UTC (rev 17876) @@ -1577,6 +1577,8 @@ guint8 unknown[5]; /* only present in versions >= 3 */ GSList *members; /* Contains node of struct snacpair */ /* TODO: Maybe use a GHashTable for members */ + + time_t last; /**< The time when we last sent a SNAC of this rate class. */ }; int aim_cachecookie(OscarData *od, IcbmCookie *cookie); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-02 19:57:47
|
Revision: 17877 http://svn.sourceforge.net/gaim/?rev=17877&view=rev Author: thekingant Date: 2006-12-02 11:57:47 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Millisecond accuracy for the rolling average thing. It still seems pretty inaccurate. Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_oservice.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_oservice.c =================================================================== --- trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 10:43:06 UTC (rev 17876) +++ trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-02 19:57:47 UTC (rev 17877) @@ -326,6 +326,8 @@ if (mod->version >= 3) byte_stream_getrawbuf(bs, rateclass->unknown, sizeof(rateclass->unknown)); + rateclass->last.tv_sec = 0; + rateclass->last.tv_usec = 0; conn->rateclasses = g_slist_prepend(conn->rateclasses, rateclass); } conn->rateclasses = g_slist_reverse(conn->rateclasses); Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 10:43:06 UTC (rev 17876) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-02 19:57:47 UTC (rev 17877) @@ -89,18 +89,25 @@ if ((snacpair->group == family) && (snacpair->subtype == subtype)) { /* - * We've found the rateclass for this SNAC family and - * subtype! Update our "current" average by calculating - * a rolling average. This is pretty shoddy. We should - * really keep track of the times when the last last - * windowsize messages that were sent and just calculate - * the REAL average. + * We've found the rateclass for this SNAC family + * and subtype! Update our "current" average by + * calculating a rolling average. This is pretty + * shoddy. We should really keep track of the times + * when the last windowsize messages that were sent + * and just calculate the REAL average. */ - time_t now; - now = time(NULL); + struct timeval now; + struct timezone tz; + unsigned long timediff; /* In milliseconds */ + + gettimeofday(&now, &tz); + timediff = MIN((now.tv_sec - rateclass->last.tv_sec) * 1000 + (now.tv_usec - rateclass->last.tv_usec) / 1000, rateclass->max); + /* This formula is taken from the joscar API docs. */ - rateclass->current = MIN(((rateclass->current * (rateclass->windowsize - 1)) + (now - rateclass->last)) / rateclass->windowsize, rateclass->max); - rateclass->last = now; + rateclass->current = MIN(((rateclass->current * (rateclass->windowsize - 1)) + timediff) / rateclass->windowsize, rateclass->max); + rateclass->last.tv_sec = now.tv_sec; + rateclass->last.tv_usec = now.tv_usec; + return; } } Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 10:43:06 UTC (rev 17876) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-02 19:57:47 UTC (rev 17877) @@ -1578,7 +1578,7 @@ GSList *members; /* Contains node of struct snacpair */ /* TODO: Maybe use a GHashTable for members */ - time_t last; /**< The time when we last sent a SNAC of this rate class. */ + struct timeval last; /**< The time when we last sent a SNAC of this rate class. */ }; int aim_cachecookie(OscarData *od, IcbmCookie *cookie); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-04 07:47:58
|
Revision: 17891 http://svn.sourceforge.net/gaim/?rev=17891&view=rev Author: thekingant Date: 2006-12-03 23:47:50 -0800 (Sun, 03 Dec 2006) Log Message: ----------- Outgoing message throttling. If we're sending messages too quickly, and Gaim thinks that sending another message will make AIM give us a warning, then delay sending the message a little bit. Currently only activated for IMs. Let me know if you see any problems. Modified Paths: -------------- trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-04 04:52:46 UTC (rev 17890) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-04 07:47:50 UTC (rev 17891) @@ -72,8 +72,8 @@ flap_connection_send(conn, frame); } -static void -update_rate_class(FlapConnection *conn, guint16 family, guint16 subtype) +static struct rateclass * +flap_connection_get_rateclass(FlapConnection *conn, guint16 family, guint16 subtype) { GSList *tmp1, *tmp2; @@ -88,44 +88,85 @@ snacpair = tmp2->data; if ((snacpair->group == family) && (snacpair->subtype == subtype)) { - /* - * We've found the rateclass for this SNAC family - * and subtype! Update our "current" average by - * calculating a rolling average. This is pretty - * shoddy. We should really keep track of the times - * when the last windowsize messages that were sent - * and just calculate the REAL average. - */ - struct timeval now; - struct timezone tz; - unsigned long timediff; /* In milliseconds */ + return rateclass; + } + } + } - gettimeofday(&now, &tz); - timediff = MIN((now.tv_sec - rateclass->last.tv_sec) * 1000 + (now.tv_usec - rateclass->last.tv_usec) / 1000, rateclass->max); + return NULL; +} - /* This formula is taken from the joscar API docs. */ - rateclass->current = MIN(((rateclass->current * (rateclass->windowsize - 1)) + timediff) / rateclass->windowsize, rateclass->max); - rateclass->last.tv_sec = now.tv_sec; - rateclass->last.tv_usec = now.tv_usec; +/* + * Attempt to calculate what our new current average would be if we + * were to send a SNAC in this rateclass at the given time. + */ +static guint32 +rateclass_get_new_current(FlapConnection *conn, struct rateclass *rateclass, struct timeval now) +{ + unsigned long timediff; /* In milliseconds */ - return; - } + timediff = (now.tv_sec - rateclass->last.tv_sec) * 1000 + (now.tv_usec - rateclass->last.tv_usec) / 1000; + + /* This formula is taken from the joscar API docs. Preesh. */ + return MIN(((rateclass->current * (rateclass->windowsize - 1)) + timediff) / rateclass->windowsize, rateclass->max); +} + +static gboolean flap_connection_send_queued(gpointer data) +{ + FlapConnection *conn; + struct timeval now; + + conn = data; + gettimeofday(&now, NULL); + + while (conn->queued_snacs != NULL) + { + QueuedSnac *queued_snac; + struct rateclass *rateclass; + + queued_snac = conn->queued_snacs->data; + + rateclass = flap_connection_get_rateclass(conn, queued_snac->family, queued_snac->subtype); + if (rateclass != NULL) + { + guint32 new_current; + + new_current = rateclass_get_new_current(conn, rateclass, now); + + if (new_current < rateclass->alert) + /* Not ready to send this SNAC yet--keep waiting. */ + return TRUE; + + rateclass->current = new_current; + rateclass->last.tv_sec = now.tv_sec; + rateclass->last.tv_usec = now.tv_usec; } + + flap_connection_send(conn, queued_snac->frame); + g_free(queued_snac); + conn->queued_snacs = g_slist_delete_link(conn->queued_snacs, conn->queued_snacs); } + + conn->outgoing_timeout = 0; + return FALSE; } - /** * This sends a channel 2 FLAP containing a SNAC. The SNAC family and * subtype are looked up in the rate info for this connection, and if * sending this SNAC will induce rate limiting then we delay sending * of the SNAC by putting it into an outgoing holding queue. + * + * @param data The optional bytestream that makes up the data portion + * of this SNAC. For empty SNACs this should be NULL. */ void flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data) { FlapFrame *frame; guint32 length; + gboolean enqueue = FALSE; + struct rateclass *rateclass; length = data != NULL ? data->offset : 0; @@ -138,9 +179,45 @@ byte_stream_putbs(&frame->data, data, length); } - /* TODO: Outgoing message throttling */ - update_rate_class(conn, family, subtype); + if (conn->outgoing_timeout != 0) + enqueue = TRUE; + else if ((rateclass = flap_connection_get_rateclass(conn, family, subtype)) != NULL) + { + struct timeval now; + guint32 new_current; + gettimeofday(&now, NULL); + new_current = rateclass_get_new_current(conn, rateclass, now); + + if (new_current < rateclass->alert) + { + enqueue = TRUE; + } + else + { + rateclass->current = new_current; + rateclass->last.tv_sec = now.tv_sec; + rateclass->last.tv_usec = now.tv_usec; + } + } + + if (enqueue) + { + /* We've been sending too fast, so delay this message */ + QueuedSnac *queued_snac; + + queued_snac = g_new(QueuedSnac, 1); + queued_snac->family = family; + queued_snac->subtype = subtype; + queued_snac->frame = frame; + conn->queued_snacs = g_slist_append(conn->queued_snacs, queued_snac); + + if (conn->outgoing_timeout == 0) + conn->outgoing_timeout = gaim_timeout_add(500, flap_connection_send_queued, conn); + + return; + } + flap_connection_send(conn, frame); } @@ -267,6 +344,18 @@ free(rateclass); } +/** + * Free a FlapFrame + * + * @param frame The frame to free. + */ +static void +flap_frame_destroy(FlapFrame *frame) +{ + free(frame->data.data); + free(frame); +} + static gboolean flap_connection_destroy_cb(gpointer data) { @@ -334,6 +423,17 @@ conn->rateclasses = g_slist_delete_link(conn->rateclasses, conn->rateclasses); } + while (conn->queued_snacs != NULL) + { + QueuedSnac *queued_snac; + queued_snac = conn->queued_snacs->data; + flap_frame_destroy(queued_snac->frame); + g_free(queued_snac); + conn->queued_snacs = g_slist_delete_link(conn->queued_snacs, conn->queued_snacs); + } + if (conn->outgoing_timeout > 0) + gaim_timeout_remove(conn->outgoing_timeout); + g_free(conn); return FALSE; @@ -529,22 +629,7 @@ return frame; } -/** - * Free a FlapFrame - * - * @param frame The frame to free. - * @return -1 on error; 0 on success. - */ static void -flap_frame_destroy(FlapFrame *frame) -{ - free(frame->data.data); - free(frame); - - return; -} - -static void parse_snac(OscarData *od, FlapConnection *conn, FlapFrame *frame) { aim_module_t *cur; Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-04 04:52:46 UTC (rev 17890) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-04 07:47:50 UTC (rev 17891) @@ -56,11 +56,12 @@ typedef struct _ByteStream ByteStream; typedef struct _ClientInfo ClientInfo; +typedef struct _FlapConnection FlapConnection; typedef struct _FlapFrame FlapFrame; +typedef struct _IcbmArgsCh2 IcbmArgsCh2; typedef struct _IcbmCookie IcbmCookie; -typedef struct _FlapConnection FlapConnection; typedef struct _OscarData OscarData; -typedef struct _IcbmArgsCh2 IcbmArgsCh2; +typedef struct _QueuedSnac QueuedSnac; typedef guint32 aim_snacid_t; @@ -351,6 +352,13 @@ guint32 offset; }; +struct _QueuedSnac +{ + guint16 family; + guint16 subtype; + FlapFrame *frame; +}; + struct _FlapFrame { guint8 channel; @@ -383,9 +391,13 @@ guint16 subtype; guint16 seqnum; /**< The sequence number of most recent outgoing packet. */ GSList *groups; - GSList *rateclasses; /* Contains nodes of struct rateclass */ + GSList *rateclasses; /* Contains nodes of struct rateclass. */ /* TODO: Maybe use a GHashTable for rateclasses */ + GSList *queued_snacs; /**< Contains QueuedSnacs. */ + guint outgoing_timeout; + /* TODO: Maybe use a GQueue for outgoing_snacs */ + void *internal; /* internal conn-specific libfaim data */ }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-04 11:14:12
|
Revision: 17892 http://svn.sourceforge.net/gaim/?rev=17892&view=rev Author: thekingant Date: 2006-12-04 03:14:11 -0800 (Mon, 04 Dec 2006) Log Message: ----------- Use GHashTable and GQueue instead of GSList in a few places in oscar. The speed improvements probably won't be noticeable. 4 files changed, 48 insertions(+), 106 deletions(-) Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_oservice.c trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.h trunk/libgaim/protocols/oscar/oscar_data.c Modified: trunk/libgaim/protocols/oscar/family_oservice.c =================================================================== --- trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-04 07:47:50 UTC (rev 17891) +++ trunk/libgaim/protocols/oscar/family_oservice.c 2006-12-04 11:14:11 UTC (rev 17892) @@ -278,18 +278,6 @@ return NULL; } -static void -rateclass_addpair(struct rateclass *rateclass, guint16 group, guint16 type) -{ - struct snacpair *snacpair; - - snacpair = g_new(struct snacpair, 1); - snacpair->group = group; - snacpair->subtype = type; - - rateclass->members = g_slist_prepend(rateclass->members, snacpair); -} - /* Subtype 0x0007 - Rate Parameters */ static int rateresp(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) @@ -326,6 +314,7 @@ if (mod->version >= 3) byte_stream_getrawbuf(bs, rateclass->unknown, sizeof(rateclass->unknown)); + rateclass->members = g_hash_table_new(g_direct_hash, g_direct_equal); rateclass->last.tv_sec = 0; rateclass->last.tv_usec = 0; conn->rateclasses = g_slist_prepend(conn->rateclasses, rateclass); @@ -354,9 +343,10 @@ subtype = byte_stream_get16(bs); if (rateclass != NULL) - rateclass_addpair(rateclass, group, subtype); + g_hash_table_insert(rateclass->members, + GUINT_TO_POINTER((group << 16) + subtype), + GUINT_TO_POINTER(TRUE)); } - rateclass->members = g_slist_reverse(rateclass->members); } /* Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-04 07:47:50 UTC (rev 17891) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-04 11:14:11 UTC (rev 17892) @@ -75,22 +75,18 @@ static struct rateclass * flap_connection_get_rateclass(FlapConnection *conn, guint16 family, guint16 subtype) { - GSList *tmp1, *tmp2; + GSList *tmp1; + gconstpointer key; + key = GUINT_TO_POINTER((family << 16) + subtype); + for (tmp1 = conn->rateclasses; tmp1 != NULL; tmp1 = tmp1->next) { struct rateclass *rateclass; rateclass = tmp1->data; - for (tmp2 = rateclass->members; tmp2 != NULL; tmp2 = tmp2->next) - { - struct snacpair *snacpair; - snacpair = tmp2->data; - if ((snacpair->group == family) && (snacpair->subtype == subtype)) - { - return rateclass; - } - } + if (g_hash_table_lookup(rateclass->members, key)) + return rateclass; } return NULL; @@ -119,12 +115,12 @@ conn = data; gettimeofday(&now, NULL); - while (conn->queued_snacs != NULL) + while (!g_queue_is_empty(conn->queued_snacs)) { QueuedSnac *queued_snac; struct rateclass *rateclass; - queued_snac = conn->queued_snacs->data; + queued_snac = g_queue_peek_head(conn->queued_snacs); rateclass = flap_connection_get_rateclass(conn, queued_snac->family, queued_snac->subtype); if (rateclass != NULL) @@ -144,10 +140,10 @@ flap_connection_send(conn, queued_snac->frame); g_free(queued_snac); - conn->queued_snacs = g_slist_delete_link(conn->queued_snacs, conn->queued_snacs); + g_queue_pop_head(conn->queued_snacs); } - conn->outgoing_timeout = 0; + conn->queued_timeout = 0; return FALSE; } @@ -179,7 +175,7 @@ byte_stream_putbs(&frame->data, data, length); } - if (conn->outgoing_timeout != 0) + if (conn->queued_timeout != 0) enqueue = TRUE; else if ((rateclass = flap_connection_get_rateclass(conn, family, subtype)) != NULL) { @@ -210,10 +206,10 @@ queued_snac->family = family; queued_snac->subtype = subtype; queued_snac->frame = frame; - conn->queued_snacs = g_slist_append(conn->queued_snacs, queued_snac); + g_queue_push_tail(conn->queued_snacs, queued_snac); - if (conn->outgoing_timeout == 0) - conn->outgoing_timeout = gaim_timeout_add(500, flap_connection_send_queued, conn); + if (conn->queued_timeout == 0) + conn->queued_timeout = gaim_timeout_add(500, flap_connection_send_queued, conn); return; } @@ -272,6 +268,7 @@ conn->fd = -1; conn->subtype = -1; conn->type = type; + conn->queued_snacs = g_queue_new(); od->oscar_connections = g_slist_prepend(od->oscar_connections, conn); @@ -335,13 +332,8 @@ static void flap_connection_destroy_rateclass(struct rateclass *rateclass) { - while (rateclass->members != NULL) - { - g_free(rateclass->members->data); - rateclass->members = g_slist_delete_link(rateclass->members, rateclass->members); - } - - free(rateclass); + g_hash_table_destroy(rateclass->members); + g_free(rateclass); } /** @@ -352,8 +344,8 @@ static void flap_frame_destroy(FlapFrame *frame) { - free(frame->data.data); - free(frame); + g_free(frame->data.data); + g_free(frame); } static gboolean @@ -423,16 +415,16 @@ conn->rateclasses = g_slist_delete_link(conn->rateclasses, conn->rateclasses); } - while (conn->queued_snacs != NULL) + while (!g_queue_is_empty(conn->queued_snacs)) { QueuedSnac *queued_snac; - queued_snac = conn->queued_snacs->data; + queued_snac = g_queue_pop_head(conn->queued_snacs); flap_frame_destroy(queued_snac->frame); g_free(queued_snac); - conn->queued_snacs = g_slist_delete_link(conn->queued_snacs, conn->queued_snacs); } - if (conn->outgoing_timeout > 0) - gaim_timeout_remove(conn->outgoing_timeout); + g_queue_free(conn->queued_snacs); + if (conn->queued_timeout > 0) + gaim_timeout_remove(conn->queued_timeout); g_free(conn); Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-04 07:47:50 UTC (rev 17891) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-04 11:14:11 UTC (rev 17892) @@ -392,11 +392,9 @@ guint16 seqnum; /**< The sequence number of most recent outgoing packet. */ GSList *groups; GSList *rateclasses; /* Contains nodes of struct rateclass. */ - /* TODO: Maybe use a GHashTable for rateclasses */ - GSList *queued_snacs; /**< Contains QueuedSnacs. */ - guint outgoing_timeout; - /* TODO: Maybe use a GQueue for outgoing_snacs */ + GQueue *queued_snacs; /**< Contains QueuedSnacs. */ + guint queued_timeout; void *internal; /* internal conn-specific libfaim data */ }; @@ -504,8 +502,7 @@ gboolean in_transaction; } ssi; - /* TODO: Implement this as a HashTable for HUGE speed improvement! */ - GSList *handlerlist; + GHashTable *handlerlist; /** A linked list containing FlapConnections. */ GSList *oscar_connections; @@ -578,8 +575,8 @@ void aim_cleansnacs(OscarData *, int maxage); -int oscar_data_addhandler(OscarData *od, guint16 family, guint16 type, aim_rxcallback_t newhandler, guint16 flags); -void aim_clearhandlers(OscarData *od); +void oscar_data_addhandler(OscarData *od, guint16 family, guint16 subtype, aim_rxcallback_t newhandler, guint16 flags); +aim_rxcallback_t aim_callhandler(OscarData *od, guint16 family, guint16 subtype); /* flap_connection.c */ FlapConnection *flap_connection_new(OscarData *, int type); @@ -1542,9 +1539,6 @@ int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, int len); int byte_stream_putcaps(ByteStream *bs, guint32 caps); -/* rxhandlers.c */ -aim_rxcallback_t aim_callhandler(OscarData *od, guint16 family, guint16 type); - /* * Generic SNAC structure. Rarely if ever used. */ @@ -1571,11 +1565,6 @@ guint16 instance; }; -struct snacpair { - guint16 group; - guint16 subtype; -}; - struct rateclass { guint16 classid; guint32 windowsize; @@ -1586,8 +1575,7 @@ guint32 current; guint32 max; guint8 unknown[5]; /* only present in versions >= 3 */ - GSList *members; /* Contains node of struct snacpair */ - /* TODO: Maybe use a GHashTable for members */ + GHashTable *members; /* Key is family and subtype, value is TRUE. */ struct timeval last; /**< The time when we last sent a SNAC of this rate class. */ }; Modified: trunk/libgaim/protocols/oscar/oscar_data.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar_data.c 2006-12-04 07:47:50 UTC (rev 17891) +++ trunk/libgaim/protocols/oscar/oscar_data.c 2006-12-04 11:14:11 UTC (rev 17892) @@ -25,18 +25,11 @@ struct _SnacHandler { guint16 family; - guint16 type; + guint16 subtype; aim_rxcallback_t handler; guint16 flags; }; -static void -oscar_free_buddyinfo(void *data) -{ - struct buddyinfo *bi = data; - g_free(bi); -} - /** * Allocates a new OscarData and initializes it with default values. */ @@ -49,7 +42,8 @@ aim_initsnachash(od); od->snacid_next = 0x00000001; - od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); + od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + od->handlerlist = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); /* * Register all the modules for this session... @@ -115,61 +109,39 @@ peer_connection_destroy(od->peer_connections->data, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); - if (od->handlerlist != NULL) - aim_clearhandlers(od); - aim__shutdownmodules(od); g_hash_table_destroy(od->buddyinfo); + g_hash_table_destroy(od->handlerlist); g_free(od); } -int -oscar_data_addhandler(OscarData *od, guint16 family, guint16 type, aim_rxcallback_t newhandler, guint16 flags) +void +oscar_data_addhandler(OscarData *od, guint16 family, guint16 subtype, aim_rxcallback_t newhandler, guint16 flags) { SnacHandler *snac_handler; - gaim_debug_misc("oscar", "Adding handler for %04x/%04x\n", family, type); + gaim_debug_misc("oscar", "Adding handler for %04x/%04x\n", family, subtype); snac_handler = g_new0(SnacHandler, 1); snac_handler->family = family; - snac_handler->type = type; + snac_handler->subtype = subtype; snac_handler->flags = flags; snac_handler->handler = newhandler; - od->handlerlist = g_slist_prepend(od->handlerlist, snac_handler); - - return 0; + g_hash_table_insert(od->handlerlist, + GUINT_TO_POINTER((family << 16) + subtype), + snac_handler); } -void -aim_clearhandlers(OscarData *od) -{ - SnacHandler *snac_handler; - - while (od->handlerlist != NULL) - { - snac_handler = od->handlerlist->data; - od->handlerlist = g_slist_remove(od->handlerlist, snac_handler); - g_free(snac_handler); - } - od->handlerlist = NULL; -} - aim_rxcallback_t -aim_callhandler(OscarData *od, guint16 family, guint16 type) +aim_callhandler(OscarData *od, guint16 family, guint16 subtype) { - GSList *cur; SnacHandler *snac_handler; - for (cur = od->handlerlist; cur != NULL; cur = cur->next) - { - snac_handler = cur->data; - if ((snac_handler->family == family) && (snac_handler->type == type)) - return snac_handler->handler; - } + snac_handler = g_hash_table_lookup(od->handlerlist, GUINT_TO_POINTER((family << 16) + subtype)); - return NULL; + return snac_handler ? snac_handler->handler : NULL; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-04 11:36:46
|
Revision: 17893 http://svn.sourceforge.net/gaim/?rev=17893&view=rev Author: thekingant Date: 2006-12-04 03:36:31 -0800 (Mon, 04 Dec 2006) Log Message: ----------- Minor documentation changes Modified Paths: -------------- trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oft.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-04 11:14:11 UTC (rev 17892) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-04 11:36:31 UTC (rev 17893) @@ -817,7 +817,17 @@ break; } - /* TODO: Verify the sequence number sent by the server. */ + /* Verify the sequence number sent by the server. */ +#if 0 + /* TODO: Need to initialize conn->seqnum_in somewhere before we can use this. */ + if (aimutil_get16(&header[1]) != conn->seqnum_in++) + { + /* Received an out-of-order FLAP! */ + flap_connection_schedule_destroy(conn, + OSCAR_DISCONNECT_INVALID_DATA, NULL); + break; + } +#endif /* Initialize a new temporary FlapFrame for incoming data */ conn->buffer_incoming.channel = aimutil_get8(&header[1]); @@ -958,7 +968,7 @@ void flap_connection_send(FlapConnection *conn, FlapFrame *frame) { - frame->seqnum = ++(conn->seqnum); + frame->seqnum = ++(conn->seqnum_out); sendframe_flap(conn, frame); flap_frame_destroy(frame); } Modified: trunk/libgaim/protocols/oscar/oft.c =================================================================== --- trunk/libgaim/protocols/oscar/oft.c 2006-12-04 11:14:11 UTC (rev 17892) +++ trunk/libgaim/protocols/oscar/oft.c 2006-12-04 11:36:31 UTC (rev 17893) @@ -550,7 +550,7 @@ /* End GaimXfer callbacks for use when sending and receiving */ /*******************************************************************/ -#if 0 +#ifdef TODOFT /* * This little area in oscar.c is the nexus of file transfer code, * so I wrote a little explanation of what happens. I am such a Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-04 11:14:11 UTC (rev 17892) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-04 11:36:31 UTC (rev 17893) @@ -389,7 +389,8 @@ guint16 type; guint16 subtype; - guint16 seqnum; /**< The sequence number of most recent outgoing packet. */ + guint16 seqnum_out; /**< The sequence number of most recently sent packet. */ + guint16 seqnum_in; /**< The sequence number of most recently received packet. */ GSList *groups; GSList *rateclasses; /* Contains nodes of struct rateclass. */ @@ -502,6 +503,7 @@ gboolean in_transaction; } ssi; + /** Contains pointers to handler functions for each family/subtype. */ GHashTable *handlerlist; /** A linked list containing FlapConnections. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-05 06:23:47
|
Revision: 17896 http://svn.sourceforge.net/gaim/?rev=17896&view=rev Author: thekingant Date: 2006-12-04 22:23:43 -0800 (Mon, 04 Dec 2006) Log Message: ----------- Lower the away-message fetching timeout from 10 seconds to half a second. The rate limiting stuff will hopefully kick in if needed. Let me know if you have problems. Like rate-related error messages or GUI components not redrawing. Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_locate.c trunk/libgaim/protocols/oscar/flap_connection.c Modified: trunk/libgaim/protocols/oscar/family_locate.c =================================================================== --- trunk/libgaim/protocols/oscar/family_locate.c 2006-12-04 21:56:32 UTC (rev 17895) +++ trunk/libgaim/protocols/oscar/family_locate.c 2006-12-05 06:23:43 UTC (rev 17896) @@ -393,7 +393,7 @@ * requesting away messages and info too quickly. */ if (od->getinfotimer == 0) - od->getinfotimer = gaim_timeout_add(10000, + od->getinfotimer = gaim_timeout_add(500, gaim_reqinfo_timeout_cb, od); } Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-04 21:56:32 UTC (rev 17895) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-05 06:23:43 UTC (rev 17896) @@ -97,11 +97,11 @@ * were to send a SNAC in this rateclass at the given time. */ static guint32 -rateclass_get_new_current(FlapConnection *conn, struct rateclass *rateclass, struct timeval now) +rateclass_get_new_current(FlapConnection *conn, struct rateclass *rateclass, struct timeval *now) { unsigned long timediff; /* In milliseconds */ - timediff = (now.tv_sec - rateclass->last.tv_sec) * 1000 + (now.tv_usec - rateclass->last.tv_usec) / 1000; + timediff = (now->tv_sec - rateclass->last.tv_sec) * 1000 + (now->tv_usec - rateclass->last.tv_usec) / 1000; /* This formula is taken from the joscar API docs. Preesh. */ return MIN(((rateclass->current * (rateclass->windowsize - 1)) + timediff) / rateclass->windowsize, rateclass->max); @@ -127,7 +127,7 @@ { guint32 new_current; - new_current = rateclass_get_new_current(conn, rateclass, now); + new_current = rateclass_get_new_current(conn, rateclass, &now); if (new_current < rateclass->alert) /* Not ready to send this SNAC yet--keep waiting. */ @@ -183,7 +183,7 @@ guint32 new_current; gettimeofday(&now, NULL); - new_current = rateclass_get_new_current(conn, rateclass, now); + new_current = rateclass_get_new_current(conn, rateclass, &now); if (new_current < rateclass->alert) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sea...@us...> - 2006-12-06 00:39:28
|
Revision: 17897 http://svn.sourceforge.net/gaim/?rev=17897&view=rev Author: seanegan Date: 2006-12-05 16:39:27 -0800 (Tue, 05 Dec 2006) Log Message: ----------- In the worst case, OSCAR file transfer waited 60 seconds before proxying. I've brought it down to 10 Modified Paths: -------------- trunk/libgaim/protocols/oscar/peer.c trunk/libgaim/protocols/oscar/peer.h trunk/libgaim/protocols/oscar/peer_proxy.c Modified: trunk/libgaim/protocols/oscar/peer.c =================================================================== --- trunk/libgaim/protocols/oscar/peer.c 2006-12-05 06:23:43 UTC (rev 17896) +++ trunk/libgaim/protocols/oscar/peer.c 2006-12-06 00:39:27 UTC (rev 17897) @@ -139,12 +139,18 @@ else if (conn->type == OSCAR_CAPABILITY_SENDFILE) peer_oft_close(conn); - if (conn->connect_data != NULL) + if (conn->verified_connect_data != NULL) { - gaim_proxy_connect_cancel(conn->connect_data); - conn->connect_data = NULL; + gaim_proxy_connect_cancel(conn->verified_connect_data); + conn->verified_connect_data = NULL; } + if (conn->client_connect_data != NULL) + { + gaim_proxy_connect_cancel(conn->client_connect_data); + conn->client_connect_data = NULL; + } + if (conn->listen_data != NULL) { gaim_network_listen_cancel(conn->listen_data); @@ -497,13 +503,17 @@ * either connected or failed to connect. */ static void -peer_connection_established_cb(gpointer data, gint source, const gchar *error_message) +peer_connection_common_established_cb(gpointer data, gint source, const gchar *error_message, gboolean verified) { PeerConnection *conn; conn = data; - conn->connect_data = NULL; + if (verified) + conn->verified_connect_data = NULL; + else + conn->client_connect_data = NULL; + gaim_timeout_remove(conn->connect_timeout_timer); conn->connect_timeout_timer = 0; @@ -512,12 +522,32 @@ peer_connection_trynext(conn); return; } - + + if (verified) { + gaim_proxy_connect_cancel(conn->client_connect_data); + conn->client_connect_data = NULL; + } else { + gaim_proxy_connect_cancel(conn->verified_connect_data); + conn->verified_connect_data = NULL; + } + conn->fd = source; peer_connection_finalize_connection(conn); } +static void +peer_connection_verified_established_cb(gpointer data, gint source, const gchar *error_message) +{ + peer_connection_common_established_cb(data, source, error_message, TRUE); +} + +static void +peer_connection_client_established_cb(gpointer data, gint source, const gchar *error_message) +{ + peer_connection_common_established_cb(data, source, error_message, FALSE); +} + /** * This is the watcher callback for any listening socket that is * waiting for a peer to connect. When a peer connects we set the @@ -639,7 +669,7 @@ /** * This is a callback function used when we're connecting to a peer * using either the client IP or the verified IP and the connection - * took longer than 15 seconds to complete. We do this because + * took longer than 5 seconds to complete. We do this because * waiting for the OS to time out the connection attempt is not * practical--the default timeout on many OSes can be 3 minutes or * more, and users are impatient. @@ -653,6 +683,12 @@ * I suppose this line of thinking is discriminatory against people * with very high lag but decent throughput who are transferring * large files. But we don't care about those people. + * + * I (Sean) changed the timeout from 15 to 5 seconds, as 60 seconds is + * too long for a user to wait to send a file. I'm also parallelizing + * requests when possible. The longest we should have to wait now is 10 + * seconds. We shouldn't make it shorter than this. + * */ static gboolean peer_connection_tooktoolong(gpointer data) @@ -689,12 +725,14 @@ peer_connection_close(conn); /* - * 1. Attempt to connect to the remote user using their verifiedip. + * 1. Attempt to connect to the remote user using their verifiedip and clientip. + * We try these at the same time and use whichever succeeds first, so we don't + * have to wait for a timeout. */ - if (!(conn->flags & PEER_CONNECTION_FLAG_TRIED_VERIFIEDIP) && + if (!(conn->flags & PEER_CONNECTION_FLAG_TRIED_DIRECT) && (conn->verifiedip != NULL) && (conn->port != 0) && (!conn->use_proxy)) { - conn->flags |= PEER_CONNECTION_FLAG_TRIED_VERIFIEDIP; + conn->flags |= PEER_CONNECTION_FLAG_TRIED_DIRECT; if (conn->type == OSCAR_CAPABILITY_DIRECTIM) { @@ -708,48 +746,26 @@ g_free(tmp); } - conn->connect_data = gaim_proxy_connect(NULL, account, + conn->verified_connect_data = gaim_proxy_connect(NULL, account, conn->verifiedip, conn->port, - peer_connection_established_cb, conn); - if (conn->connect_data != NULL) + peer_connection_verified_established_cb, conn); + if (conn->verified_connect_data != NULL) { /* Connecting... */ - conn->connect_timeout_timer = gaim_timeout_add(15000, + conn->connect_timeout_timer = gaim_timeout_add(5000, peer_connection_tooktoolong, conn); - return; } - } - /* - * 2. Attempt to connect to the remote user using their clientip. - */ - if (!(conn->flags & PEER_CONNECTION_FLAG_TRIED_CLIENTIP) && - (conn->clientip != NULL) && (conn->port != 0) && (!conn->use_proxy)) - { - conn->flags |= PEER_CONNECTION_FLAG_TRIED_CLIENTIP; - if ((conn->verifiedip == NULL) || strcmp(conn->verifiedip, conn->clientip)) { - if (conn->type == OSCAR_CAPABILITY_DIRECTIM) - { - gchar *tmp; - GaimConversation *conv; - tmp = g_strdup_printf(_("Attempting to connect to %s:%hu."), - conn->clientip, conn->port); - conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, conn->sn); - gaim_conversation_write(conv, NULL, tmp, - GAIM_MESSAGE_SYSTEM, time(NULL)); - g_free(tmp); - } - - conn->connect_data = gaim_proxy_connect(NULL, account, + conn->client_connect_data = gaim_proxy_connect(NULL, account, conn->clientip, conn->port, - peer_connection_established_cb, conn); - if (conn->connect_data != NULL) + peer_connection_client_established_cb, conn); + if (conn->connect_timeout_timer == 0 && conn->verified_connect_data != NULL) { /* Connecting... */ - conn->connect_timeout_timer = gaim_timeout_add(15000, + conn->connect_timeout_timer = gaim_timeout_add(5000, peer_connection_tooktoolong, conn); return; } @@ -757,7 +773,7 @@ } /* - * 3. Attempt to have the remote user connect to us (using both + * 2. Attempt to have the remote user connect to us (using both * our verifiedip and our clientip). */ if (!(conn->flags & PEER_CONNECTION_FLAG_TRIED_INCOMING) && @@ -781,7 +797,7 @@ } /* - * 4. Attempt to have both users connect to an intermediate proxy + * 3. Attempt to have both users connect to an intermediate proxy * server. */ if (!(conn->flags & PEER_CONNECTION_FLAG_TRIED_PROXY)) @@ -807,11 +823,11 @@ g_free(tmp); } - conn->connect_data = gaim_proxy_connect(NULL, account, + conn->verified_connect_data = gaim_proxy_connect(NULL, account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, peer_proxy_connection_established_cb, conn); - if (conn->connect_data != NULL) + if (conn->verified_connect_data != NULL) { /* Connecting... */ return; Modified: trunk/libgaim/protocols/oscar/peer.h =================================================================== --- trunk/libgaim/protocols/oscar/peer.h 2006-12-05 06:23:43 UTC (rev 17896) +++ trunk/libgaim/protocols/oscar/peer.h 2006-12-06 00:39:27 UTC (rev 17897) @@ -36,11 +36,10 @@ #define PEER_CONNECTION_FLAG_INITIATED_BY_ME 0x0001 #define PEER_CONNECTION_FLAG_APPROVED 0x0002 -#define PEER_CONNECTION_FLAG_TRIED_VERIFIEDIP 0x0004 -#define PEER_CONNECTION_FLAG_TRIED_CLIENTIP 0x0008 -#define PEER_CONNECTION_FLAG_TRIED_INCOMING 0x0010 -#define PEER_CONNECTION_FLAG_TRIED_PROXY 0x0020 -#define PEER_CONNECTION_FLAG_IS_INCOMING 0x0040 +#define PEER_CONNECTION_FLAG_TRIED_DIRECT 0x0004 +#define PEER_CONNECTION_FLAG_TRIED_INCOMING 0x0008 +#define PEER_CONNECTION_FLAG_TRIED_PROXY 0x0010 +#define PEER_CONNECTION_FLAG_IS_INCOMING 0x0020 #define PEER_TYPE_PROMPT 0x0101 /* "I am going to send you this file, is that ok?" */ #define PEER_TYPE_RESUMESOMETHING 0x0106 /* I really don't know */ @@ -157,8 +156,9 @@ /** * This is only used when the peer connection is being established. */ - GaimProxyConnectData *connect_data; - + GaimProxyConnectData *client_connect_data; + GaimProxyConnectData *verified_connect_data; + /** * This is only used when the peer connection is being established. */ Modified: trunk/libgaim/protocols/oscar/peer_proxy.c =================================================================== --- trunk/libgaim/protocols/oscar/peer_proxy.c 2006-12-05 06:23:43 UTC (rev 17896) +++ trunk/libgaim/protocols/oscar/peer_proxy.c 2006-12-06 00:39:27 UTC (rev 17897) @@ -328,7 +328,7 @@ conn = data; - conn->connect_data = NULL; + conn->verified_connect_data = NULL; if (source < 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-07 08:29:46
|
Revision: 17915 http://svn.sourceforge.net/gaim/?rev=17915&view=rev Author: thekingant Date: 2006-12-07 00:23:18 -0800 (Thu, 07 Dec 2006) Log Message: ----------- * Add a little cushion to the rate average calculation to hopefully account for any inaccuracies due to network lag and stuff * If one of our connections is disconnected, close the socket and don't try to write to it again. This will hopefully fix a weird race condition that Kevin was running into? Modified Paths: -------------- trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/peer.c Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-07 08:06:48 UTC (rev 17914) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-07 08:23:18 UTC (rev 17915) @@ -129,7 +129,8 @@ new_current = rateclass_get_new_current(conn, rateclass, &now); - if (new_current < rateclass->alert) + if (new_current < rateclass->alert + 100) + /* (Add 100ms padding to account for inaccuracies in the calculation) */ /* Not ready to send this SNAC yet--keep waiting. */ return TRUE; @@ -185,8 +186,9 @@ gettimeofday(&now, NULL); new_current = rateclass_get_new_current(conn, rateclass, &now); - if (new_current < rateclass->alert) + if (new_current < rateclass->alert + 100) { + /* (Add 100ms padding to account for inaccuracies in the calculation) */ enqueue = TRUE; } else @@ -905,6 +907,10 @@ return; /* Error! */ + gaim_input_remove(conn->watcher_outgoing); + conn->watcher_outgoing = 0; + close(conn->fd); + conn->fd = -1; flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; @@ -930,7 +936,7 @@ gaim_circ_buffer_append(conn->buffer_outgoing, bs->data, count); /* If we haven't already started writing stuff, then start the cycle */ - if (conn->watcher_outgoing == 0) + if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) { conn->watcher_outgoing = gaim_input_add(conn->fd, GAIM_INPUT_WRITE, send_cb, conn); Modified: trunk/libgaim/protocols/oscar/peer.c =================================================================== --- trunk/libgaim/protocols/oscar/peer.c 2006-12-07 08:06:48 UTC (rev 17914) +++ trunk/libgaim/protocols/oscar/peer.c 2006-12-07 08:23:18 UTC (rev 17915) @@ -421,8 +421,14 @@ return; if (conn->ready) + { + gaim_input_remove(conn->watcher_outgoing); + conn->watcher_outgoing = 0; + close(conn->fd); + conn->fd = -1; peer_connection_schedule_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION, NULL); + } else { /* @@ -450,7 +456,7 @@ gaim_circ_buffer_append(conn->buffer_outgoing, bs->data, bs->len); /* If we haven't already started writing stuff, then start the cycle */ - if (conn->watcher_outgoing == 0) + if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) { conn->watcher_outgoing = gaim_input_add(conn->fd, GAIM_INPUT_WRITE, send_cb, conn); @@ -708,8 +714,6 @@ gaim_debug_info("oscar", "Peer connection timed out after 5 seconds. " "Trying next method...\n"); - peer_connection_close(conn); - peer_connection_trynext(conn); /* Cancel this timer. It'll be added again, if needed. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-13 10:11:35
|
Revision: 17983 http://svn.sourceforge.net/gaim/?rev=17983&view=rev Author: thekingant Date: 2006-12-13 02:11:31 -0800 (Wed, 13 Dec 2006) Log Message: ----------- Move away from using MSG_PEEK when recv'ing data over oscar sockets. It's possible this was causing problems with a small number of Windows users? People seem to frown pretty heavily upon MSG_PEEK in general, for some reason. Modified Paths: -------------- trunk/libgaim/protocols/oscar/flap_connection.c trunk/libgaim/protocols/oscar/oscar.h trunk/libgaim/protocols/oscar/peer.c trunk/libgaim/protocols/oscar/peer.h trunk/libgaim/protocols/oscar/peer_proxy.c Modified: trunk/libgaim/protocols/oscar/flap_connection.c =================================================================== --- trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-13 08:45:57 UTC (rev 17982) +++ trunk/libgaim/protocols/oscar/flap_connection.c 2006-12-13 10:11:31 UTC (rev 17983) @@ -770,7 +770,6 @@ { FlapConnection *conn; ssize_t read; - guint8 header[6]; conn = data; @@ -780,8 +779,9 @@ /* Start reading a new FLAP */ if (conn->buffer_incoming.data.data == NULL) { - /* Peek at the first 6 bytes to get the length */ - read = recv(conn->fd, &header, 6, MSG_PEEK); + /* Read the first 6 bytes (the FLAP header) */ + read = recv(conn->fd, conn->header + conn->header_received, + 6 - conn->header_received, 0); /* Check if the FLAP server closed the connection */ if (read == 0) @@ -805,14 +805,12 @@ } /* If we don't even have a complete FLAP header then do nothing */ - if (read < 6) + conn->header_received += read; + if (conn->header_received < 6) break; - /* Read the first 6 bytes (the FLAP header) */ - read = recv(conn->fd, &header, 6, 0); - /* All FLAP frames must start with the byte 0x2a */ - if (aimutil_get8(&header[0]) != 0x2a) + if (aimutil_get8(&conn->header[0]) != 0x2a) { flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA, NULL); @@ -822,7 +820,7 @@ /* Verify the sequence number sent by the server. */ #if 0 /* TODO: Need to initialize conn->seqnum_in somewhere before we can use this. */ - if (aimutil_get16(&header[1]) != conn->seqnum_in++) + if (aimutil_get16(&conn->header[1]) != conn->seqnum_in++) { /* Received an out-of-order FLAP! */ flap_connection_schedule_destroy(conn, @@ -832,9 +830,9 @@ #endif /* Initialize a new temporary FlapFrame for incoming data */ - conn->buffer_incoming.channel = aimutil_get8(&header[1]); - conn->buffer_incoming.seqnum = aimutil_get16(&header[2]); - conn->buffer_incoming.data.len = aimutil_get16(&header[4]); + conn->buffer_incoming.channel = aimutil_get8(&conn->header[1]); + conn->buffer_incoming.seqnum = aimutil_get16(&conn->header[2]); + conn->buffer_incoming.data.len = aimutil_get16(&conn->header[4]); conn->buffer_incoming.data.data = g_new(guint8, conn->buffer_incoming.data.len); conn->buffer_incoming.data.offset = 0; } @@ -880,6 +878,8 @@ g_free(conn->buffer_incoming.data.data); conn->buffer_incoming.data.data = NULL; + + conn->header_received = 0; } } Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-13 08:45:57 UTC (rev 17982) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-13 10:11:31 UTC (rev 17983) @@ -382,6 +382,8 @@ gpointer new_conn_data; int fd; + guint8 header[6]; + ssize_t header_received; FlapFrame buffer_incoming; GaimCircBuffer *buffer_outgoing; guint watcher_incoming; Modified: trunk/libgaim/protocols/oscar/peer.c =================================================================== --- trunk/libgaim/protocols/oscar/peer.c 2006-12-13 08:45:57 UTC (rev 17982) +++ trunk/libgaim/protocols/oscar/peer.c 2006-12-13 10:11:31 UTC (rev 17983) @@ -288,15 +288,15 @@ { PeerConnection *conn; ssize_t read; - guint8 header[6]; conn = data; /* Start reading a new ODC/OFT frame */ if (conn->buffer_incoming.data == NULL) { - /* Peek at the first 6 bytes to get the length */ - read = recv(conn->fd, &header, 6, MSG_PEEK); + /* Read the first 6 bytes (magic string and frame length) */ + read = recv(conn->fd, conn->header + conn->header_received, + 6 - conn->header_received, 0); /* Check if the remote user closed the connection */ if (read == 0) @@ -320,26 +320,25 @@ conn->lastactivity = time(NULL); /* If we don't even have the first 6 bytes then do nothing */ - if (read < 6) + conn->header_received += read; + if (conn->header_received < 6) return; - /* Read the first 6 bytes (magic string and frame length) */ - read = recv(conn->fd, &header, 6, 0); - /* All ODC/OFT frames must start with a magic string */ - if (memcmp(conn->magic, header, 4)) + if (memcmp(conn->magic, conn->header, 4)) { gaim_debug_warning("oscar", "Expecting magic string to " "be %c%c%c%c but received magic string %c%c%c%c. " "Closing connection.\n", conn->magic[0], conn->magic[1], conn->magic[2], - conn->magic[3], header[0], header[1], header[2], header[3]); + conn->magic[3], conn->header[0], conn->header[1], + conn->header[2], conn->header[3]); peer_connection_destroy(conn, OSCAR_DISCONNECT_INVALID_DATA, NULL); return; } /* Initialize a new temporary ByteStream for incoming data */ - conn->buffer_incoming.len = aimutil_get16(&header[4]) - 6; + conn->buffer_incoming.len = aimutil_get16(&conn->header[4]) - 6; conn->buffer_incoming.data = g_new(guint8, conn->buffer_incoming.len); conn->buffer_incoming.offset = 0; } @@ -384,8 +383,11 @@ { peer_oft_recv_frame(conn, &conn->buffer_incoming); } + g_free(conn->buffer_incoming.data); conn->buffer_incoming.data = NULL; + + conn->header_received = 0; } /*******************************************************************/ Modified: trunk/libgaim/protocols/oscar/peer.h =================================================================== --- trunk/libgaim/protocols/oscar/peer.h 2006-12-13 08:45:57 UTC (rev 17982) +++ trunk/libgaim/protocols/oscar/peer.h 2006-12-13 10:11:31 UTC (rev 17983) @@ -158,7 +158,7 @@ */ GaimProxyConnectData *client_connect_data; GaimProxyConnectData *verified_connect_data; - + /** * This is only used when the peer connection is being established. */ @@ -177,13 +177,15 @@ int listenerfd; int fd; - + guint8 header[6]; + ssize_t header_received; + guint8 proxy_header[12]; + ssize_t proxy_header_received; + ByteStream buffer_incoming; + GaimCircBuffer *buffer_outgoing; guint watcher_incoming; guint watcher_outgoing; - ByteStream buffer_incoming; - GaimCircBuffer *buffer_outgoing; - /** * IP address of the proxy server, if applicable. */ Modified: trunk/libgaim/protocols/oscar/peer_proxy.c =================================================================== --- trunk/libgaim/protocols/oscar/peer_proxy.c 2006-12-13 08:45:57 UTC (rev 17982) +++ trunk/libgaim/protocols/oscar/peer_proxy.c 2006-12-13 10:11:31 UTC (rev 17983) @@ -203,7 +203,6 @@ { PeerConnection *conn; ssize_t read; - guint8 header[12]; ProxyFrame *frame; conn = data; @@ -212,8 +211,9 @@ /* Start reading a new proxy frame */ if (frame == NULL) { - /* Peek at the first 12 bytes to get the length */ - read = recv(conn->fd, &header, 12, MSG_PEEK); + /* Read the first 12 bytes (frame length and header) */ + read = recv(conn->fd, conn->proxy_header + conn->proxy_header_received, + 12 - conn->proxy_header_received, 0); /* Check if the proxy server closed the connection */ if (read == 0) @@ -238,30 +238,28 @@ conn->lastactivity = time(NULL); /* If we don't even have the first 12 bytes then do nothing */ - if (read < 12) + conn->proxy_header_received += read; + if (conn->proxy_header_received < 12) return; - /* Read the first 12 bytes (frame length and header) */ - read = recv(conn->fd, &header, 12, 0); - /* We only support a specific version of the proxy protocol */ - if (aimutil_get16(&header[2]) != PEER_PROXY_PACKET_VERSION) + if (aimutil_get16(&conn->proxy_header[2]) != PEER_PROXY_PACKET_VERSION) { gaim_debug_warning("oscar", "Expected peer proxy protocol " "version %u but received version %u. Closing " "connection.\n", PEER_PROXY_PACKET_VERSION, - aimutil_get16(&header[2])); + aimutil_get16(&conn->proxy_header[2])); peer_connection_trynext(conn); return; } /* Initialize a new temporary ProxyFrame for incoming data */ frame = g_new0(ProxyFrame, 1); - frame->payload.len = aimutil_get16(&header[0]) - 10; - frame->version = aimutil_get16(&header[2]); - frame->type = aimutil_get16(&header[4]); - frame->unknown = aimutil_get16(&header[6]); - frame->flags = aimutil_get16(&header[10]); + frame->payload.len = aimutil_get16(&conn->proxy_header[0]) - 10; + frame->version = aimutil_get16(&conn->proxy_header[2]); + frame->type = aimutil_get16(&conn->proxy_header[4]); + frame->unknown = aimutil_get16(&conn->proxy_header[6]); + frame->flags = aimutil_get16(&conn->proxy_header[10]); if (frame->payload.len > 0) frame->payload.data = g_new(guint8, frame->payload.len); conn->frame = frame; @@ -313,8 +311,11 @@ conn->frame = NULL; byte_stream_rewind(&frame->payload); peer_proxy_recv_frame(conn, frame); + g_free(frame->payload.data); g_free(frame); + + conn->proxy_header_received = 0; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-15 02:42:22
|
Revision: 18002 http://svn.sourceforge.net/gaim/?rev=18002&view=rev Author: thekingant Date: 2006-12-14 18:42:07 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Two parameters being passed to strncpy() were backwards Modified Paths: -------------- trunk/libgaim/protocols/oscar/libaim.c trunk/libgaim/protocols/oscar/oscar.c Modified: trunk/libgaim/protocols/oscar/libaim.c =================================================================== --- trunk/libgaim/protocols/oscar/libaim.c 2006-12-15 02:40:27 UTC (rev 18001) +++ trunk/libgaim/protocols/oscar/libaim.c 2006-12-15 02:42:07 UTC (rev 18002) @@ -31,6 +31,7 @@ OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, NULL, /* user_splits */ NULL, /* protocol_options */ + /* The mimimum icon size below is not needed in AIM 6.0 */ {"gif,jpeg,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ oscar_list_icon_aim, /* list_icon */ Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-12-15 02:40:27 UTC (rev 18001) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-12-15 02:42:07 UTC (rev 18002) @@ -430,7 +430,7 @@ char *str, *salvage; str = g_malloc(datalen + 1); - strncpy(str, datalen, data); + strncpy(str, data, datalen); str[datalen] = '\0'; salvage = gaim_utf8_salvage(str); ret = g_strdup_printf("%s %s", salvage, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-21 08:58:55
|
Revision: 18036 http://svn.sourceforge.net/gaim/?rev=18036&view=rev Author: thekingant Date: 2006-12-21 00:58:55 -0800 (Thu, 21 Dec 2006) Log Message: ----------- * Convert or validate the chat room name in chat room invites as UTF8 * Bail out if the ICBM cookie doesn't match the rendezvous ICBM cookie Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_chat.c trunk/libgaim/protocols/oscar/family_icbm.c trunk/libgaim/protocols/oscar/oscar.c trunk/libgaim/protocols/oscar/oscar.h Modified: trunk/libgaim/protocols/oscar/family_chat.c =================================================================== --- trunk/libgaim/protocols/oscar/family_chat.c 2006-12-21 08:14:05 UTC (rev 18035) +++ trunk/libgaim/protocols/oscar/family_chat.c 2006-12-21 08:58:55 UTC (rev 18036) @@ -116,14 +116,12 @@ int aim_chat_readroominfo(ByteStream *bs, struct aim_chat_roominfo *outinfo) { - int namelen; - if (!bs || !outinfo) return 0; outinfo->exchange = byte_stream_get16(bs); - namelen = byte_stream_get8(bs); - outinfo->name = byte_stream_getstr(bs, namelen); + outinfo->namelen = byte_stream_get8(bs); + outinfo->name = byte_stream_getraw(bs, outinfo->namelen); outinfo->instance = byte_stream_get16(bs); return 0; Modified: trunk/libgaim/protocols/oscar/family_icbm.c =================================================================== --- trunk/libgaim/protocols/oscar/family_icbm.c 2006-12-21 08:14:05 UTC (rev 18035) +++ trunk/libgaim/protocols/oscar/family_icbm.c 2006-12-21 08:58:55 UTC (rev 18036) @@ -1915,7 +1915,12 @@ */ cookie2 = byte_stream_getraw(&bbs, 8); if (memcmp(cookie, cookie2, 8) != 0) - gaim_debug_misc("oscar", "rend: warning cookies don't match!\n"); + { + gaim_debug_warning("oscar", + "Cookies don't match in rendezvous ICBM, bailing out.\n"); + free(cookie2); + return 1; + } memcpy(args.cookie, cookie2, 8); free(cookie2); Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-12-21 08:14:05 UTC (rev 18035) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-12-21 08:58:55 UTC (rev 18036) @@ -845,10 +845,13 @@ return NULL; x = strchr(name, '-'); + if (!x) + return NULL; - if (!x) return NULL; - x = strchr(++x, '-'); - if (!x) return NULL; + x = strchr(x + 1, '-'); + if (!x) + return NULL; + tmp = g_strdup(++x); for (i = 0, j = 0; x[i]; i++) { @@ -857,7 +860,8 @@ tmp[j++] = x[i]; continue; } - strncpy(hex, x + ++i, 2); hex[2] = 0; + strncpy(hex, x + ++i, 2); + hex[2] = 0; i++; tmp[j++] = strtol(hex, NULL, 16); } @@ -2046,27 +2050,36 @@ if (args->type & OSCAR_CAPABILITY_CHAT) { - char *name; + char *encoding, *utf8name, *tmp; GHashTable *components; if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { g_free(message); return 1; } + encoding = args->encoding ? oscar_encoding_extract(args->encoding) : NULL; + utf8name = oscar_encoding_to_utf8(encoding, + args->info.chat.roominfo.name, + args->info.chat.roominfo.namelen); + g_free(encoding); + + tmp = extract_name(utf8name); + if (tmp != NULL) + { + g_free(utf8name); + utf8name = tmp; + } + components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - name = extract_name(args->info.chat.roominfo.name); - g_hash_table_replace(components, g_strdup("room"), - g_strdup(name ? name : args->info.chat.roominfo.name)); + g_hash_table_replace(components, g_strdup("room"), utf8name); g_hash_table_replace(components, g_strdup("exchange"), g_strdup_printf("%d", args->info.chat.roominfo.exchange)); serv_got_chat_invite(gc, - name ? name : args->info.chat.roominfo.name, + utf8name, userinfo->sn, message, components); - if (name) - g_free(name); } else if ((args->type & OSCAR_CAPABILITY_SENDFILE) || Modified: trunk/libgaim/protocols/oscar/oscar.h =================================================================== --- trunk/libgaim/protocols/oscar/oscar.h 2006-12-21 08:14:05 UTC (rev 18035) +++ trunk/libgaim/protocols/oscar/oscar.h 2006-12-21 08:58:55 UTC (rev 18036) @@ -698,6 +698,7 @@ { guint16 exchange; char *name; + guint8 namelen; guint16 instance; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-12-21 09:21:32
|
Revision: 18038 http://svn.sourceforge.net/gaim/?rev=18038&view=rev Author: thekingant Date: 2006-12-21 01:21:32 -0800 (Thu, 21 Dec 2006) Log Message: ----------- Correct 2 tiny spelling mistakes Modified Paths: -------------- trunk/libgaim/protocols/oscar/family_chatnav.c trunk/libgaim/protocols/oscar/oscar.c Modified: trunk/libgaim/protocols/oscar/family_chatnav.c =================================================================== --- trunk/libgaim/protocols/oscar/family_chatnav.c 2006-12-21 09:14:53 UTC (rev 18037) +++ trunk/libgaim/protocols/oscar/family_chatnav.c 2006-12-21 09:21:32 UTC (rev 18038) @@ -417,7 +417,7 @@ } if (snac2->family != 0x000d) { - gaim_debug_misc("oscar", "faim: chatnav_parse_info: recieved response that maps to corrupt request! (fam=%04x)\n", snac2->family); + gaim_debug_misc("oscar", "faim: chatnav_parse_info: received response that maps to corrupt request! (fam=%04x)\n", snac2->family); return 0; } Modified: trunk/libgaim/protocols/oscar/oscar.c =================================================================== --- trunk/libgaim/protocols/oscar/oscar.c 2006-12-21 09:14:53 UTC (rev 18037) +++ trunk/libgaim/protocols/oscar/oscar.c 2006-12-21 09:21:32 UTC (rev 18038) @@ -3330,7 +3330,7 @@ } /* - * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option. + * Received in response to an IM sent with the AIM_IMFLAGS_ACK option. */ static int gaim_parse_msgack(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { va_list ap; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |