/soc/2015/jgeboski/facebook: 7201f07fe8f7: facebook: gobjectifie...

James Geboski jgeboski at gmail.com
Tue Aug 18 19:58:49 EDT 2015


Changeset: 7201f07fe8f79f0ac2b29e96544b2e1c4ad9ed91
Author:	 James Geboski <jgeboski at gmail.com>
Date:	 2015-08-18 19:58 -0400
Branch:	 facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/7201f07fe8f7

Description:

facebook: gobjectified the FbJsonValues interface

diffstat:

 libpurple/protocols/facebook/api.c  |   72 +++++++-------
 libpurple/protocols/facebook/json.c |  176 +++++++++++++++++++++++------------
 libpurple/protocols/facebook/json.h |   74 ++++++--------
 3 files changed, 181 insertions(+), 141 deletions(-)

diffs (truncated from 714 to 300 lines):

diff --git a/libpurple/protocols/facebook/api.c b/libpurple/protocols/facebook/api.c
--- a/libpurple/protocols/facebook/api.c
+++ b/libpurple/protocols/facebook/api.c
@@ -519,7 +519,7 @@ fb_api_json_chk(FbApi *api, gconstpointe
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);
 		json_node_free(root);
 		return FALSE
 	);
@@ -550,7 +550,7 @@ fb_api_json_chk(FbApi *api, gconstpointe
 		priv->stoken = NULL;
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 
 	for (msg = NULL, i = 0; i < G_N_ELEMENTS(exprs); i++) {
 		msg = fb_json_node_get_str(root, exprs[i], NULL);
@@ -944,7 +944,7 @@ fb_api_cb_seqid(PurpleHttpConnection *co
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);
 		json_node_free(root);
 		return;
 	);
@@ -954,7 +954,7 @@ fb_api_cb_seqid(PurpleHttpConnection *co
 	priv->unread = fb_json_values_next_int(values, 0);
 
 	fb_api_connect_queue(api);
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -1019,7 +1019,7 @@ fb_api_cb_publish_mark(FbApi *api, GByte
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);
 		json_node_free(root);
 		return;
 	);
@@ -1029,7 +1029,7 @@ fb_api_cb_publish_mark(FbApi *api, GByte
 		             _("Failed to mark thread as read"));
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -1073,7 +1073,7 @@ fb_api_event_parse(FbApi *api, FbApiEven
 			}
 		}
 
-		fb_json_values_free(values);
+		g_object_unref(values);
 
 		if (G_UNLIKELY(err != NULL)) {
 			g_propagate_error(error, err);
@@ -1120,7 +1120,7 @@ fb_api_cb_mercury(FbApi *api, GByteArray
 	}
 
 	g_slist_free_full(events, (GDestroyNotify) fb_api_event_free);
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 
 }
@@ -1146,7 +1146,7 @@ fb_api_cb_publish_typing(FbApi *api, GBy
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);
 		json_node_free(root);
 		return;
 	);
@@ -1162,7 +1162,7 @@ fb_api_cb_publish_typing(FbApi *api, GBy
 		}
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -1185,7 +1185,7 @@ fb_api_xma_parse(FbApi *api, FbApiMessag
 
 	if (G_UNLIKELY(err != NULL)) {
 		g_propagate_error(error, err);
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
@@ -1202,11 +1202,11 @@ fb_api_xma_parse(FbApi *api, FbApiMessag
 
 	if (fb_http_urlcmp(body, msg->text, FALSE)) {
 		g_free(msg->text);
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	return TRUE;
 }
 
@@ -1284,7 +1284,7 @@ fb_api_message_parse_attach(FbApi *api, 
 		g_propagate_error(error, err);
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	return msgs;
 }
 
@@ -1340,14 +1340,14 @@ fb_api_cb_publish_ms(FbApi *api, GByteAr
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);
 		json_node_free(root);
 		return;
 	);
 
 	priv->sid = fb_json_values_next_int(values, 0);
 	stoken = fb_json_values_next_str_dup(values, NULL);
-	fb_json_values_free(values);
+	g_object_unref(values);
 
 	if (G_UNLIKELY(stoken != NULL)) {
 		g_free(priv->stoken);
@@ -1434,7 +1434,7 @@ fb_api_cb_publish_ms(FbApi *api, GByteAr
 	}
 
 	g_slist_free_full(msgs, (GDestroyNotify) fb_api_message_free);
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -1688,7 +1688,7 @@ fb_api_cb_auth(PurpleHttpConnection *con
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);
 		json_node_free(root);
 		return;
 	);
@@ -1698,7 +1698,7 @@ fb_api_cb_auth(PurpleHttpConnection *con
 	priv->uid = fb_json_values_next_int(values, 0);
 
 	g_signal_emit_by_name(api, "auth");
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -1739,7 +1739,7 @@ fb_api_contact_parse(FbApi *api, FbApiUs
 
 	if (G_UNLIKELY(err != NULL)) {
 		g_propagate_error(error, err);
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
@@ -1758,7 +1758,7 @@ fb_api_contact_parse(FbApi *api, FbApiUs
 	    !purple_strequal(str, "ARE_FRIENDS") &&
 	    (user->uid != priv->uid))
 	{
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
@@ -1769,7 +1769,7 @@ fb_api_contact_parse(FbApi *api, FbApiUs
 	user->csum = fb_http_params_dup_str(params, "oh", &err);
 	fb_http_params_free(params);
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	return TRUE;
 }
 
@@ -1890,7 +1890,7 @@ fb_api_cb_contacts(PurpleHttpConnection 
 
 	g_free(writeid);
 	g_slist_free_full(users, (GDestroyNotify) fb_api_user_free);
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -2103,7 +2103,7 @@ fb_api_cb_unread_parse_attach(FbApi *api
 		g_propagate_error(error, err);
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	return msgs;
 }
 
@@ -2144,14 +2144,14 @@ fb_api_cb_unread_msgs(PurpleHttpConnecti
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return;
 	);
 
 	fb_api_message_reset(&msg, FALSE);
 	str = fb_json_values_next_str(values, "0");
 	tid = FB_ID_FROM_STR(str);
-	fb_json_values_free(values);
+	g_object_unref(values);
 
 	values = fb_json_values_new(node);
 	fb_json_values_add(values, FB_JSON_TYPE_BOOL, TRUE, "$.unread");
@@ -2222,7 +2222,7 @@ fb_api_cb_unread_msgs(PurpleHttpConnecti
 	}
 
 	g_slist_free_full(msgs, (GDestroyNotify) fb_api_message_free);
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -2282,7 +2282,7 @@ fb_api_cb_unread(PurpleHttpConnection *c
 		fb_api_error_emit(api, err);
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	json_node_free(root);
 }
 
@@ -2329,20 +2329,20 @@ fb_api_thread_parse(FbApi *api, FbApiThr
 
 	if (G_UNLIKELY(err != NULL)) {
 		g_propagate_error(error, err);
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
 	str = fb_json_values_next_str(values, NULL);
 
 	if (str == NULL) {
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
 	thrd->tid = FB_ID_FROM_STR(str);
 	thrd->topic = fb_json_values_next_str_dup(values, NULL);
-	fb_json_values_free(values);
+	g_object_unref(values);
 
 	values = fb_json_values_new(root);
 	fb_json_values_add(values, FB_JSON_TYPE_STR, TRUE,
@@ -2368,17 +2368,17 @@ fb_api_thread_parse(FbApi *api, FbApiThr
 	if (G_UNLIKELY(err != NULL)) {
 		g_propagate_error(error, err);
 		fb_api_thread_reset(thrd, TRUE);
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
 	if ((g_slist_length(thrd->users) < 2) || !haself) {
 		fb_api_thread_reset(thrd, TRUE);
-		fb_json_values_free(values);
+		g_object_unref(values);
 		return FALSE;
 	}
 
-	fb_json_values_free(values);
+	g_object_unref(values);
 	return TRUE;
 }
 
@@ -2478,7 +2478,7 @@ fb_api_cb_thread_create(PurpleHttpConnec
 	fb_json_values_update(values, &err);
 
 	FB_API_ERROR_EMIT(api, err,
-		fb_json_values_free(values);
+		g_object_unref(values);



More information about the Commits mailing list