adium.1-3: 0abea35d: Updated to pidgin-facebook 1.50
evands at pidgin.im
evands at pidgin.im
Mon Apr 13 16:05:28 EDT 2009
-----------------------------------------------------------------
Revision: 0abea35d4ed593a616bca769020b9f196d4853de
Ancestor: 9f01c862b0f46e33311b5b8e990bc2bf259a9ece
Author: evands at pidgin.im
Date: 2009-04-13T20:01:40
Branch: im.pidgin.adium.1-3
URL: http://d.pidgin.im/viewmtn/revision/info/0abea35d4ed593a616bca769020b9f196d4853de
Modified files:
libpurple/protocols/facebook/facebook.nsi
libpurple/protocols/facebook/fb_blist.c
libpurple/protocols/facebook/fb_connection.c
libpurple/protocols/facebook/fb_messages.c
libpurple/protocols/facebook/fb_messages.h
libpurple/protocols/facebook/libfacebook.c
libpurple/protocols/facebook/libfacebook.h
ChangeLog:
Updated to pidgin-facebook 1.50
-------------- next part --------------
============================================================
--- libpurple/protocols/facebook/facebook.nsi 9c3e03e1b45493d9c9b6ae54cd588ad173a9ad09
+++ libpurple/protocols/facebook/facebook.nsi 3fcdc6328140c152a720ace476cd1a7922e7f1e4
@@ -6,7 +6,7 @@ SetCompress off
; todo: SetBrandingImage
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "pidgin-facebookchat"
-!define PRODUCT_VERSION "1.47"
+!define PRODUCT_VERSION "1.50"
!define PRODUCT_PUBLISHER "Eion Robb"
!define PRODUCT_WEB_SITE "http://pidgin-facebookchat.googlecode.com/"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
============================================================
--- libpurple/protocols/facebook/fb_blist.c 243c33eccaca15743e5259770e56c278a2883520
+++ libpurple/protocols/facebook/fb_blist.c c8ae76955f130eb0d93fbea79efe34bf98007be3
@@ -373,7 +373,7 @@ gboolean fb_get_buddy_list(gpointer data
fba = data;
postdata = g_strdup_printf(
- "user=%d&popped_out=false&force_render=true&buddy_list=1",
+ "user=%d&popped_out=true&force_render=true&buddy_list=1",
fba->uid);
fb_post_or_get(fba, FB_METHOD_POST, NULL, "/ajax/presence/update.php",
postdata, got_buddy_list_cb, NULL, FALSE);
============================================================
--- libpurple/protocols/facebook/fb_connection.c 003c7d50824f5dc7e64f7a8a914c3cd7411befb0
+++ libpurple/protocols/facebook/fb_connection.c 404289452b1ede585959c8ae9561b9e730af6af9
@@ -425,6 +425,8 @@ void fb_post_or_get(FacebookAccount *fba
gchar *real_url;
gboolean is_proxy = FALSE;
const gchar *user_agent;
+ const gchar* const *languages;
+ gchar *language_names;
/* TODO: Fix keepalive and use it as much as possible */
keepalive = FALSE;
@@ -470,6 +472,12 @@ void fb_post_or_get(FacebookAccount *fba
g_string_append_printf(request, "Accept-Encoding: gzip\r\n");
#endif
+ /* Tell the server what language we accept, so that we get error messages in our language (rather than our IP's) */
+ languages = g_get_language_names();
+ language_names = g_strjoinv(", ", (gchar **)languages);
+ purple_util_chrreplace(language_names, '_', '-');
+ g_string_append_printf(request, "Accept-Language: %s\r\n", language_names);
+ g_free(language_names);
purple_debug_misc("facebook", "sending request headers:\n%s\n",
request->str);
============================================================
--- libpurple/protocols/facebook/fb_messages.c 63dd1c9053fb8cae9d8edd3f1f17d3292b8a47d2
+++ libpurple/protocols/facebook/fb_messages.c 6831ce6a6068eedeba1fe863b4610515b3394807
@@ -30,42 +30,11 @@ struct _FacebookOutgoingMessage {
gchar *message;
gint msg_id;
guint retry_count;
- guint resend_timer;
};
static gboolean fb_send_im_fom(FacebookOutgoingMessage *msg);
-static gboolean fb_resend_im_fom(FacebookOutgoingMessage *msg);
static gboolean fb_get_new_messages(FacebookAccount *fba);
-static FacebookOutgoingMessage *fb_msg_create(FacebookAccount *fba)
-{
- FacebookOutgoingMessage *msg;
-
- msg = g_new0(FacebookOutgoingMessage, 1);
- msg->fba = fba;
-
- return msg;
-}
-
-static void fb_msg_destroy(FacebookOutgoingMessage *msg)
-{
- if (msg->resend_timer) {
- purple_timeout_remove(msg->resend_timer);
- }
- g_free(msg->who);
- g_free(msg->message);
- g_free(msg);
-}
-
-void fb_cancel_resending_messages(FacebookAccount *fba)
-{
- while (fba->resending_messages != NULL) {
- FacebookOutgoingMessage *msg = fba->resending_messages->data;
- fba->resending_messages = g_slist_remove(fba->resending_messages, msg);
- fb_msg_destroy(msg);
- }
-}
-
static void got_new_messages(FacebookAccount *fba, gchar *data,
gsize data_len, gpointer userdata)
{
@@ -136,16 +105,15 @@ static void got_new_messages(FacebookAcc
/* Continue looping, waiting for more messages */
purple_debug_error("facebook",
"got data back, but it's not even json\n");
-
- fb_get_new_messages(fba);
+
+ purple_timeout_add_seconds(1, (GSourceFunc)fb_get_new_messages, fba);
return;
}
/* refresh means that the session or post_form_id is invalid */
if (g_str_equal(data, "for (;;);{\"t\":\"refresh\"}"))
{
- if (fba->post_form_id_refresh_timer == 0)
- fba->post_form_id_refresh_timer = purple_timeout_add_seconds(1, (GSourceFunc)fb_get_post_form_id, fba);
+ purple_timeout_add_seconds(1, (GSourceFunc)fb_get_post_form_id, fba);
return;
}
@@ -153,7 +121,7 @@ static void got_new_messages(FacebookAcc
if (g_str_equal(data, "for (;;);{\"t\":\"continue\"}"))
{
/* Continue looping, waiting for more messages */
- fb_get_new_messages(fba);
+ purple_timeout_add_seconds(1, (GSourceFunc)fb_get_new_messages, fba);
return;
}
@@ -239,8 +207,6 @@ static void got_new_messages(FacebookAcc
purple_debug_info("facebook", "i: %d\n", i);
if (i == FB_LAST_MESSAGE_MAX)
{
- gchar *postdata;
-
/* if we're here, it must be a new message */
fba->last_messages[fba->next_message_pointer++] = msgID;
if (fba->next_message_pointer >= FB_LAST_MESSAGE_MAX)
@@ -277,6 +243,7 @@ static void got_new_messages(FacebookAcc
serv_got_im(pc, from, message_text, PURPLE_MESSAGE_RECV, atoi(message_time));
+
/*
* Acknowledge receipt of the message by simulating
* focusing the window. Not sure what the window_id
@@ -284,13 +251,18 @@ static void got_new_messages(FacebookAcc
* something internal to the Facebook javascript that
* is used for maintaining UI state across page loads?
*/
- postdata = g_strdup_printf(
- "focus_chat=%s&window_id=12345&post_form_id=%s",
- from, fba->post_form_id);
- fb_post_or_get(fba, FB_METHOD_POST, NULL,
- "/ajax/chat/settings.php?_ecdc=false",
- postdata, NULL, NULL, FALSE);
- g_free(postdata);
+ if (!fba->is_idle)
+ {
+ gchar *postdata;
+
+ postdata = g_strdup_printf(
+ "focus_chat=%s&window_id=12345&post_form_id=%s",
+ from, fba->post_form_id);
+ fb_post_or_get(fba, FB_METHOD_POST, NULL,
+ "/ajax/chat/settings.php?_ecdc=false",
+ postdata, NULL, NULL, FALSE);
+ g_free(postdata);
+ }
g_free(message_text);
g_free(message_time);
@@ -433,8 +405,7 @@ static void fb_send_im_cb(FacebookAccoun
/* there was an error, either report it or retry */
if (msg->retry_count++ < FB_MAX_MSG_RETRY)
{
- msg->resend_timer = purple_timeout_add_seconds(1, (GSourceFunc)fb_resend_im_fom, msg);
- fba->resending_messages = g_slist_prepend(fba->resending_messages, msg);
+ purple_timeout_add_seconds(1, (GSourceFunc)fb_send_im_fom, msg);
g_free(error_summary);
return;
}
@@ -451,7 +422,9 @@ static void fb_send_im_cb(FacebookAccoun
}
g_free(error_summary);
- fb_msg_destroy(msg);
+ g_free(msg->who);
+ g_free(msg->message);
+ g_free(msg);
}
static gboolean fb_send_im_fom(FacebookOutgoingMessage *msg)
@@ -472,24 +445,19 @@ static gboolean fb_send_im_fom(FacebookO
return FALSE;
}
-static gboolean fb_resend_im_fom(FacebookOutgoingMessage *msg)
-{
- msg->fba->resending_messages = g_slist_remove(msg->fba->resending_messages, msg);
-
- return fb_send_im_fom(msg);
-}
-
int fb_send_im(PurpleConnection *pc, const gchar *who, const gchar *message, PurpleMessageFlags flags)
{
FacebookOutgoingMessage *msg;
- msg = fb_msg_create(pc->proto_data);
+ msg = g_new0(FacebookOutgoingMessage, 1);
+ msg->fba = pc->proto_data;
/* convert html to plaintext, removing trailing spaces */
msg->message = purple_markup_strip_html(message);
if (strlen(msg->message) > 999)
{
- fb_msg_destroy(msg);
+ g_free(msg->message);
+ g_free(msg);
return -E2BIG;
}
@@ -583,7 +551,6 @@ gboolean fb_get_post_form_id(FacebookAcc
gboolean fb_get_post_form_id(FacebookAccount *fba)
{
- fba->post_form_id_refresh_timer = 0;
- fb_post_or_get(fba, FB_METHOD_GET, NULL, "/home.php", NULL, got_form_id_page, NULL, FALSE);
+ fb_post_or_get(fba, FB_METHOD_GET, NULL, "/presence/popout.php", NULL, got_form_id_page, NULL, FALSE);
return FALSE;
}
============================================================
--- libpurple/protocols/facebook/fb_messages.h 79be7f4f904b524f43c1c45564065564b4cc1e96
+++ libpurple/protocols/facebook/fb_messages.h 44345656bb5ce15bc8a1a50d66aaa6ed88426dff
@@ -27,6 +27,4 @@ int fb_send_im(PurpleConnection *pc, con
int fb_send_im(PurpleConnection *pc, const gchar *who, const gchar *message,
PurpleMessageFlags flags);
-void fb_cancel_resending_messages(FacebookAccount *fba);
-
#endif /* FACEBOOK_MESSAGES_H */
============================================================
--- libpurple/protocols/facebook/libfacebook.c f92cb984ed2d987621f48d5753f224ec7411097e
+++ libpurple/protocols/facebook/libfacebook.c 845e5f8dd761ecab24105b9ccd26ea8b052cdc58
@@ -175,6 +175,10 @@ static GList *fb_statuses(PurpleAccount
"message_date", _("Message changed"),
purple_value_new(PURPLE_TYPE_STRING), NULL);
types = g_list_append(types, status);
+
+ /* Cave into feature requests and allow people to set themselves to be idle */
+ status = purple_status_type_new_full(PURPLE_STATUS_AWAY, NULL, _("Idle"), FALSE, TRUE, FALSE);
+ types = g_list_append(types, status);
/* Offline people dont have messages */
status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, _("Offline"), FALSE, TRUE, FALSE);
@@ -312,6 +316,9 @@ static void fb_close(PurpleConnection *p
purple_debug_info("facebook", "disconnecting account\n");
+ g_return_if_fail(pc != NULL);
+ g_return_if_fail(pc->proto_data != NULL);
+
fba = pc->proto_data;
/* Tell Facebook that we've logged out. */
@@ -360,9 +367,6 @@ static void fb_close(PurpleConnection *p
if (fba->perpetual_messages_timer) {
purple_timeout_remove(fba->perpetual_messages_timer);
}
- if (fba->post_form_id_refresh_timer) {
- purple_timeout_remove(fba->post_form_id_refresh_timer);
- }
purple_debug_info("facebook", "destroying %d incomplete connections\n",
g_slist_length(fba->conns));
@@ -377,10 +381,6 @@ static void fb_close(PurpleConnection *p
fba->dns_queries = g_slist_remove(fba->dns_queries, dns_query);
purple_dnsquery_destroy(dns_query);
}
-
- if (fba->resending_messages != NULL) {
- fb_cancel_resending_messages(fba);
- }
g_hash_table_destroy(fba->cookie_table);
g_hash_table_destroy(fba->hostname_ip_cache);
@@ -466,7 +466,14 @@ static void fb_set_status_p(PurpleAccoun
{
const gchar *message;
gchar *stripped;
+ FacebookAccount *fba = account->gc->proto_data;
+ /* if "away" set idle */
+ if (fba && purple_status_type_get_primitive(purple_status_get_type(status)) == PURPLE_STATUS_AWAY)
+ {
+ fba->is_idle = TRUE;
+ }
+
/* first check that we actually want to set this through Pidgin */
if (!purple_account_get_bool(account,
"facebook_set_status_through_pidgin", FALSE))
============================================================
--- libpurple/protocols/facebook/libfacebook.h e3cc22c0e4235b0ccd35bd750d5023af6a0ce0ef
+++ libpurple/protocols/facebook/libfacebook.h bb3ffbaac4c4edba105d1b79dd840c5744838ebf
@@ -21,7 +21,7 @@
#ifndef LIBFACEBOOK_H
#define LIBFACEBOOK_H
-#define FACEBOOK_PLUGIN_VERSION "1.47"
+#define FACEBOOK_PLUGIN_VERSION "1.50"
#include <glib.h>
@@ -90,7 +90,6 @@ struct _FacebookAccount {
GSList *dns_queries;
GHashTable *cookie_table;
gchar *post_form_id;
- guint post_form_id_refresh_timer;
gint32 uid;
guint buddy_list_timer;
guint friend_request_timer;
@@ -98,7 +97,6 @@ struct _FacebookAccount {
guint message_fetch_sequence;
gint64 last_messages[FB_LAST_MESSAGE_MAX];
guint16 next_message_pointer;
- GSList *resending_messages;
GSList *auth_buddies;
GHashTable *hostname_ip_cache;
guint notifications_timer;
More information about the Commits
mailing list