adium: 819def05: Adding two missing files for pidgin-face...

zacw at adiumx.com zacw at adiumx.com
Thu Nov 5 00:15:40 EST 2009


-----------------------------------------------------------------
Revision: 819def05dc18c6db262eb9d956a9090c9837ece4
Ancestor: d49ed78a4b14b42c77a5eca7b0ee204cf96fe91b
Author: zacw at adiumx.com
Date: 2009-11-05T05:10:33
Branch: im.pidgin.adium
URL: http://d.pidgin.im/viewmtn/revision/info/819def05dc18c6db262eb9d956a9090c9837ece4

Added files:
        libpurple/protocols/facebook/fb_json.c
        libpurple/protocols/facebook/fb_json.h

ChangeLog: 

Adding two missing files for pidgin-facebookchat.

-------------- next part --------------
============================================================
--- libpurple/protocols/facebook/fb_json.c	8f00941d8e1906a3108dfedc7e4eed52e262240e
+++ libpurple/protocols/facebook/fb_json.c	8f00941d8e1906a3108dfedc7e4eed52e262240e
@@ -0,0 +1,87 @@
+/*
+ * libfacebook
+ *
+ * libfacebook is the property of its developers.  See the COPYRIGHT file
+ * for more details.
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "fb_json.h"
+
+#ifdef USE_JSONC
+
+JsonParser *
+json_parser_new(void)
+{
+	JsonParser *parser;
+	
+	parser = g_new0(JsonParser, 1);
+	parser->tok = json_tokener_new();
+	
+	return parser;
+}
+
+gboolean 
+json_parser_load_from_data(JsonParser *parser, const gchar *data,
+                           gssize length, GError **error)
+{
+	if (parser->tok == NULL)
+		return FALSE;
+
+	parser->root = json_tokener_parse_ex(parser->tok, (char*)data, (int)length);
+	
+	if (parser->tok->err != json_tokener_success)
+	{
+		json_object_put(parser->root);
+		parser->root = NULL;
+		return FALSE;
+	}
+	
+	return TRUE;
+}
+
+void
+json_parser_free(JsonParser *parser)
+{
+	json_tokener_free(parser->tok);
+	json_object_put(parser->root);
+	g_free(parser);
+}
+
+JsonNode *
+json_parser_get_root(JsonParser *parser)
+{
+	return parser->root;
+}
+
+GList *
+json_object_get_members(JsonObject *obj)
+{
+	GList *keys = NULL;
+	struct lh_entry *entry;	
+
+	for (entry = json_object_get_object(obj)->head;
+		entry;
+		entry = entry->next)
+	{
+		keys = g_list_prepend(keys, entry->k);
+	}
+	
+	keys = g_list_reverse(keys);
+	
+	return keys;
+}
+
+#endif
============================================================
--- libpurple/protocols/facebook/fb_json.h	373c5e457a7ce6b4dabf392d453de5647fa6de86
+++ libpurple/protocols/facebook/fb_json.h	373c5e457a7ce6b4dabf392d453de5647fa6de86
@@ -0,0 +1,64 @@
+/*
+ * libfacebook
+ *
+ * libfacebook is the property of its developers.  See the COPYRIGHT file
+ * for more details.
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FACEBOOK_JSON_H
+#define FACEBOOK_JSON_H
+
+#ifndef USE_JSONC
+#	include <json-glib/json-glib.h>
+#define json_parser_free(parser) g_object_unref(parser)
+#else /* USE_JSONC */
+#	include <glib.h>
+#	include <json/json.h>
+typedef struct json_object JsonNode;
+typedef struct json_object JsonObject;
+typedef struct json_object JsonArray;
+typedef struct {
+	struct json_tokener *tok;
+	struct json_object *root;
+} JsonParser;
+
+gboolean json_parser_load_from_data(JsonParser *parser,
+									const gchar *data,
+                                    gssize length,
+                                    GError **error);
+
+JsonNode* json_parser_get_root(JsonParser *parser);
+JsonParser* json_parser_new(void);
+void json_parser_free(JsonParser *parser);
+
+#define json_object_has_member(obj, key) ((gboolean)json_object_object_get(obj, key))
+#define json_object_get_member(obj, key) json_object_object_get(obj, key)
+GList* json_object_get_members(JsonObject *object);
+
+#define json_node_get_array(node) (node)
+#define json_node_get_object(node) (node)
+#define json_node_get_boolean(node) json_object_get_boolean(node)
+#define json_node_get_double(node) json_object_get_double(node)
+#define json_node_get_int(node) json_object_get_int(node)
+#define json_node_get_string(node) json_object_get_string(node)
+
+#define json_array_get_element(array, index) json_object_array_get_idx(array, index)
+#define json_array_get_length(array) json_object_array_length(array)
+
+#endif /* USE_JSONC */
+
+#endif /* FACEBOOK_JSON_H */
+


More information about the Commits mailing list