summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÁlvaro Peña <alvaropg@gmail.com>2014-04-14 20:12:31 +0200
committerÁlvaro Peña <alvaropg@gmail.com>2014-04-14 20:12:31 +0200
commit77968e1676cc38bb3116242c20ce3497331dfbff (patch)
tree92e7b754dc6356ade3ee3f05e4c5df6d7ae060f1
parentebc61ab79d952c88b64953ab3b2f06895f68e52c (diff)
downloadlibgfbgraph-77968e1676cc38bb3116242c20ce3497331dfbff.tar.gz
User: Added "email" property
-rw-r--r--gfbgraph/gfbgraph-user.c43
-rw-r--r--gfbgraph/gfbgraph-user.h5
2 files changed, 44 insertions, 4 deletions
diff --git a/gfbgraph/gfbgraph-user.c b/gfbgraph/gfbgraph-user.c
index 07a9876..7af2fc1 100644
--- a/gfbgraph/gfbgraph-user.c
+++ b/gfbgraph/gfbgraph-user.c
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
/*
* libgfbgraph - GObject library for Facebook Graph API
- * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com>
+ * Copyright (C) 2013-2014 Álvaro Peña <alvaropg@gmail.com>
*
* GFBGraph is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -38,11 +38,13 @@
enum {
PROP_0,
- PROP_NAME
+ PROP_NAME,
+ PROP_EMAIL
};
struct _GFBGraphUserPrivate {
gchar *name;
+ gchar *email;
};
typedef struct {
@@ -101,6 +103,18 @@ gfbgraph_user_class_init (GFBGraphUserClass *klass)
"User's full name", "The full name of the user",
"",
G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+ /**
+ * GFBGraphUser:email:
+ *
+ * The email of the user if available
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_EMAIL,
+ g_param_spec_string ("email",
+ "User's email", "The user primary email if available",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_WRITABLE));
}
static void
@@ -122,6 +136,11 @@ gfbgraph_user_set_property (GObject *object, guint prop_id, const GValue *value,
g_free (priv->name);
priv->name = g_strdup (g_value_get_string (value));
break;
+ case PROP_EMAIL:
+ if (priv->email)
+ g_free (priv->email);
+ priv->email = g_strdup (g_value_get_string (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -139,6 +158,9 @@ gfbgraph_user_get_property (GObject *object, guint prop_id, GValue *value, GPara
case PROP_NAME:
g_value_set_string (value, priv->name);
break;
+ case PROP_EMAIL:
+ g_value_set_string (value, priv->email);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -429,3 +451,20 @@ gfbgraph_user_get_name (GFBGraphUser *user)
return user->priv->name;
}
+
+/**
+ * gfbgraph_user_get_email:
+ * @user: a #GFBGraphUser.
+ *
+ * Get the user email. To retrieve this propertie, you need 'email' extended
+ * permission.
+ *
+ * Returns: (transfer none): a const #gchar with the user email, or %NULL.
+ **/
+const gchar*
+gfbgraph_user_get_email (GFBGraphUser *user)
+{
+ g_return_val_if_fail (GFBGRAPH_IS_USER (user), NULL);
+
+ return user->priv->email;
+}
diff --git a/gfbgraph/gfbgraph-user.h b/gfbgraph/gfbgraph-user.h
index b1134fe..722d366 100644
--- a/gfbgraph/gfbgraph-user.h
+++ b/gfbgraph/gfbgraph-user.h
@@ -1,7 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
/*
* libgfbgraph - GObject library for Facebook Graph API
- * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com>
+ * Copyright (C) 2013-2014 Álvaro Peña <alvaropg@gmail.com>
*
* GFBGraph is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -61,7 +61,8 @@ GList* gfbgraph_user_get_albums (GFBGraphUser *user, GFBGrap
void gfbgraph_user_get_albums_async (GFBGraphUser *user, GFBGraphAuthorizer *authorizer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
GList* gfbgraph_user_get_albums_async_finish (GFBGraphUser *user, GAsyncResult *result, GError **error);
-const gchar* gfbgraph_user_get_name (GFBGraphUser *user);
+const gchar* gfbgraph_user_get_name (GFBGraphUser *user);
+const gchar* gfbgraph_user_get_email (GFBGraphUser *user);
G_END_DECLS