/soc/2015/jgeboski/facebook: 68bc0091a347: facebook: set an init...
James Geboski
jgeboski at gmail.com
Fri Jun 5 21:26:43 EDT 2015
Changeset: 68bc0091a3476dc0645248406a9dd97c0159ca89
Author: James Geboski <jgeboski at gmail.com>
Date: 2015-06-05 09:30 -0400
Branch: facebook
URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/68bc0091a347
Description:
facebook: set an initial private alias for the user
diffstat:
libpurple/protocols/facebook/api.c | 5 -----
libpurple/protocols/facebook/facebook.c | 14 ++++++++++++++
2 files changed, 14 insertions(+), 5 deletions(-)
diffs (61 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
@@ -971,7 +971,6 @@ fb_api_cb_contacts(PurpleHttpConnection
const gchar *name;
const gchar *uid;
FbApi *api = data;
- FbApiPrivate *priv = api->priv;
FbApiUser user;
GError *err = NULL;
GList *elms = NULL;
@@ -1000,10 +999,6 @@ fb_api_cb_contacts(PurpleHttpConnection
FB_API_ERROR_CHK(api, err, goto finish);
user.uid = FB_ID_FROM_STR(uid);
- if (user.uid == priv->uid) {
- continue;
- }
-
name = fb_json_node_get_str(node, "$.structured_name.text",
&err);
FB_API_ERROR_CHK(api, err, goto finish);
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
@@ -162,9 +162,12 @@ fb_cb_api_connect(FbApi *api, gpointer d
static void
fb_cb_api_contacts(FbApi *api, GSList *users, gpointer data)
{
+ const gchar *alias;
FbApiUser *user;
+ FbId muid;
gchar uid[FB_ID_STRMAX];
GSList *l;
+ GValue val = G_VALUE_INIT;
PurpleAccount *acct;
PurpleBuddy *bdy;
PurpleConnection *gc = data;
@@ -172,11 +175,22 @@ fb_cb_api_contacts(FbApi *api, GSList *u
acct = purple_connection_get_account(gc);
grp = purple_blist_get_default_group();
+ alias = purple_account_get_private_alias(acct);
+
+ g_value_init(&val, FB_TYPE_ID);
+ g_object_get_property(G_OBJECT(api), "uid", &val);
+ muid = g_value_get_int64(&val);
+ g_value_unset(&val);
for (l = users; l != NULL; l = l->next) {
user = l->data;
FB_ID_TO_STR(user->uid, uid);
+ if (G_UNLIKELY((user->uid == muid) && (alias == NULL))) {
+ purple_account_set_private_alias(acct, user->name);
+ continue;
+ }
+
if (purple_blist_find_buddy(acct, uid) == NULL) {
bdy = purple_buddy_new(acct, uid, user->name);
purple_blist_add_buddy(bdy, NULL, grp, NULL);
More information about the Commits
mailing list