/soc/2015/jgeboski/facebook: 0519eee7aebf: facebook: implemented...

James Geboski jgeboski at gmail.com
Fri Aug 7 23:49:32 EDT 2015


Changeset: 0519eee7aebfeef95fab7cad76987b0f8a776dfc
Author:	 James Geboski <jgeboski at gmail.com>
Date:	 2015-08-07 23:49 -0400
Branch:	 facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/0519eee7aebf

Description:

facebook: implemented the retrieval of unread messages

diffstat:

 libpurple/protocols/facebook/api (jgeboski's conflicted copy 2015-08-07).c |  2430 ++++++++++
 libpurple/protocols/facebook/api.c                                         |   314 +-
 libpurple/protocols/facebook/api.h                                         |     3 +
 libpurple/protocols/facebook/facebook.c                                    |    10 +
 4 files changed, 2733 insertions(+), 24 deletions(-)

diffs (truncated from 2908 to 300 lines):

diff --git a/libpurple/protocols/facebook/api (jgeboski's conflicted copy 2015-08-07).c b/libpurple/protocols/facebook/api (jgeboski's conflicted copy 2015-08-07).c
new file mode 100644
--- /dev/null
+++ b/libpurple/protocols/facebook/api (jgeboski's conflicted copy 2015-08-07).c	
@@ -0,0 +1,2430 @@
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#include <json-glib/json-glib.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "glibcompat.h"
+
+#include "api.h"
+#include "http.h"
+#include "json.h"
+#include "marshal.h"
+#include "thrift.h"
+#include "util.h"
+
+enum
+{
+	PROP_0,
+
+	PROP_CID,
+	PROP_DID,
+	PROP_MID,
+	PROP_STOKEN,
+	PROP_TOKEN,
+	PROP_UID,
+
+	PROP_N
+};
+
+struct _FbApiPrivate
+{
+	PurpleConnection *gc;
+	FbMqtt *mqtt;
+
+	FbId uid;
+	gint64 sid;
+	guint64 mid;
+	gchar *cid;
+	gchar *did;
+	gchar *stoken;
+	gchar *token;
+
+	GHashTable *msgids;
+	guint unread;
+
+};
+
+static void
+fb_api_contacts_after(FbApi *api, const gchar *writeid);
+
+G_DEFINE_TYPE(FbApi, fb_api, G_TYPE_OBJECT);
+
+static void
+fb_api_set_property(GObject *obj, guint prop, const GValue *val,
+                    GParamSpec *pspec)
+{
+	FbApiPrivate *priv = FB_API(obj)->priv;
+
+	switch (prop) {
+	case PROP_CID:
+		g_free(priv->cid);
+		priv->cid = g_value_dup_string(val);
+		break;
+	case PROP_DID:
+		g_free(priv->did);
+		priv->did = g_value_dup_string(val);
+		break;
+	case PROP_MID:
+		priv->mid = g_value_get_uint64(val);
+		break;
+	case PROP_STOKEN:
+		g_free(priv->stoken);
+		priv->stoken = g_value_dup_string(val);
+		break;
+	case PROP_TOKEN:
+		g_free(priv->token);
+		priv->token = g_value_dup_string(val);
+		break;
+	case PROP_UID:
+		priv->uid = g_value_get_int64(val);
+		break;
+
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop, pspec);
+		break;
+	}
+}
+
+static void
+fb_api_get_property(GObject *obj, guint prop, GValue *val, GParamSpec *pspec)
+{
+	FbApiPrivate *priv = FB_API(obj)->priv;
+
+	switch (prop) {
+	case PROP_CID:
+		g_value_set_string(val, priv->cid);
+		break;
+	case PROP_DID:
+		g_value_set_string(val, priv->did);
+		break;
+	case PROP_MID:
+		g_value_set_uint64(val, priv->mid);
+		break;
+	case PROP_STOKEN:
+		g_value_set_string(val, priv->stoken);
+		break;
+	case PROP_TOKEN:
+		g_value_set_string(val, priv->token);
+		break;
+	case PROP_UID:
+		g_value_set_int64(val, priv->uid);
+		break;
+
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop, pspec);
+		break;
+	}
+}
+
+
+static void
+fb_api_dispose(GObject *obj)
+{
+	FbApiPrivate *priv = FB_API(obj)->priv;
+
+	if (G_LIKELY(priv->gc != NULL)) {
+		purple_http_conn_cancel_all(priv->gc);
+	}
+
+	if (G_UNLIKELY(priv->mqtt != NULL)) {
+		g_object_unref(priv->mqtt);
+	}
+
+	g_hash_table_destroy(priv->msgids);
+
+	g_free(priv->cid);
+	g_free(priv->did);
+	g_free(priv->stoken);
+	g_free(priv->token);
+}
+
+static void
+fb_api_class_init(FbApiClass *klass)
+{
+	GObjectClass *gklass = G_OBJECT_CLASS(klass);
+	GParamSpec *props[PROP_N] = {NULL};
+
+	gklass->set_property = fb_api_set_property;
+	gklass->get_property = fb_api_get_property;
+	gklass->dispose = fb_api_dispose;
+	g_type_class_add_private(klass, sizeof (FbApiPrivate));
+
+	props[PROP_CID] = g_param_spec_string(
+		"cid",
+		"Client ID",
+		"Client identifier for MQTT",
+		NULL,
+		G_PARAM_READWRITE);
+	props[PROP_DID] = g_param_spec_string(
+		"did",
+		"Device ID",
+		"Device identifier",
+		NULL,
+		G_PARAM_READWRITE);
+	props[PROP_MID] = g_param_spec_uint64(
+		"mid",
+		"MQTT ID",
+		"MQTT identifier for the MQTT queuer",
+		0, G_MAXUINT64, 0,
+		G_PARAM_READWRITE);
+	props[PROP_STOKEN] = g_param_spec_string(
+		"stoken",
+		"Sync Token",
+		"Synchronization token for the MQTT queue",
+		NULL,
+		G_PARAM_READWRITE);
+	props[PROP_TOKEN] = g_param_spec_string(
+		"token",
+		"Access Token",
+		"Access token from authenticating",
+		NULL,
+		G_PARAM_READWRITE);
+	props[PROP_UID] = g_param_spec_int64(
+		"uid",
+		"User ID",
+		"User identifier",
+		0, G_MAXINT64, 0,
+		G_PARAM_READWRITE);
+	g_object_class_install_properties(gklass, PROP_N, props);
+
+	g_signal_new("auth",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__VOID,
+	             G_TYPE_NONE,
+	             0);
+	g_signal_new("connect",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__VOID,
+	             G_TYPE_NONE,
+	             0);
+	g_signal_new("contacts",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__POINTER_BOOLEAN,
+	             G_TYPE_NONE,
+	             2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+	g_signal_new("error",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__OBJECT,
+	             G_TYPE_NONE,
+	             1, G_TYPE_ERROR);
+	g_signal_new("message",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__POINTER,
+	             G_TYPE_NONE,
+	             1, G_TYPE_POINTER);
+	g_signal_new("presence",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__POINTER,
+	             G_TYPE_NONE,
+	             1, G_TYPE_POINTER);
+	g_signal_new("thread-create",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__INT64,
+	             G_TYPE_NONE,
+	             1, FB_TYPE_ID);
+	g_signal_new("thread-info",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__POINTER,
+	             G_TYPE_NONE,
+	             1, G_TYPE_POINTER);
+	g_signal_new("thread-list",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__POINTER,
+	             G_TYPE_NONE,
+	             1, G_TYPE_POINTER);
+	g_signal_new("typing",
+	             G_TYPE_FROM_CLASS(klass),
+	             G_SIGNAL_ACTION,
+	             0,
+	             NULL, NULL,
+	             fb_marshal_VOID__POINTER,
+	             G_TYPE_NONE,
+	             1, G_TYPE_POINTER);
+}
+
+static void
+fb_api_init(FbApi *api)
+{
+	FbApiPrivate *priv;



More information about the Commits mailing list