/soc/2015/jgeboski/facebook: ccd151aed9f9: facebook: use persist...

James Geboski jgeboski at gmail.com
Thu Jul 9 18:01:34 EDT 2015


Changeset: ccd151aed9f9811eb1555c8d39820f5be5b6e2b5
Author:	 James Geboski <jgeboski at gmail.com>
Date:	 2015-07-09 18:01 -0400
Branch:	 facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/ccd151aed9f9

Description:

facebook: use persistent chat identifiers

diffstat:

 libpurple/protocols/facebook/data.c     |  12 ------------
 libpurple/protocols/facebook/data.h     |   3 ---
 libpurple/protocols/facebook/facebook.c |  15 ++++++++++++---
 3 files changed, 12 insertions(+), 18 deletions(-)

diffs (80 lines):

diff --git a/libpurple/protocols/facebook/data.c b/libpurple/protocols/facebook/data.c
--- a/libpurple/protocols/facebook/data.c
+++ b/libpurple/protocols/facebook/data.c
@@ -29,7 +29,6 @@ struct _FbDataPrivate
 	FbApi *api;
 	PurpleConnection *gc;
 	PurpleRoomlist *roomlist;
-	gint chatid;
 	GHashTable *icons;
 	GHashTable *icona;
 };
@@ -215,17 +214,6 @@ fb_data_get_api(FbData *fata)
 	return priv->api;
 }
 
-gint
-fb_data_get_chatid(FbData *fata)
-{
-	FbDataPrivate *priv;
-
-	g_return_val_if_fail(FB_IS_DATA(fata), 0);
-	priv = fata->priv;
-
-	return priv->chatid++;
-}
-
 PurpleConnection *
 fb_data_get_connection(FbData *fata)
 {
diff --git a/libpurple/protocols/facebook/data.h b/libpurple/protocols/facebook/data.h
--- a/libpurple/protocols/facebook/data.h
+++ b/libpurple/protocols/facebook/data.h
@@ -75,9 +75,6 @@ fb_data_save(FbData *fata);
 FbApi *
 fb_data_get_api(FbData *fata);
 
-gint
-fb_data_get_chatid(FbData *fata);
-
 PurpleConnection *
 fb_data_get_connection(FbData *fata);
 
diff --git a/libpurple/protocols/facebook/facebook.c b/libpurple/protocols/facebook/facebook.c
--- a/libpurple/protocols/facebook/facebook.c
+++ b/libpurple/protocols/facebook/facebook.c
@@ -275,7 +275,7 @@ fb_cb_api_thread_info(FbApi *api, FbApiT
 	PurpleConnection *gc;
 
 	gc = fb_data_get_connection(fata);
-	id = fb_data_get_chatid(fata);
+	id = fb_id_hash(&thrd->tid);
 	FB_ID_TO_STR(thrd->tid, tid);
 
 	chat = purple_serv_got_joined_chat(gc, id, tid);
@@ -618,14 +618,23 @@ fb_chat_join(PurpleConnection *gc, GHash
 	FbApi *api;
 	FbData *fata;
 	FbId tid;
+	gint id;
+	PurpleChatConversation *chat;
 
 	name = g_hash_table_lookup(data, "name");
 	g_return_if_fail(name != NULL);
 
+	tid = FB_ID_FROM_STR(name);
+	id = fb_id_hash(&tid);
+	chat = purple_conversations_find_chat(gc, id);
+
+	if (chat != NULL) {
+		purple_conversation_present(PURPLE_CONVERSATION(chat));
+		return;
+	}
+
 	fata = purple_connection_get_protocol_data(gc);
 	api = fb_data_get_api(fata);
-	tid = FB_ID_FROM_STR(name);
-
 	fb_api_thread_info(api, tid);
 }
 



More information about the Commits mailing list