aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2012-07-18 19:50:46 +0800
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-07-18 20:26:27 +0800
commitb98648af1d450203cd1a59ac45155e93f2216b19 (patch)
treec101e51c98dae616bf2e8ad294511fddfe03ad83 /libempathy
parent2e74f7c0c092d4930fe690085d76a6fbd7d27e29 (diff)
downloadgsoc2013-empathy-b98648af1d450203cd1a59ac45155e93f2216b19.tar
gsoc2013-empathy-b98648af1d450203cd1a59ac45155e93f2216b19.tar.gz
gsoc2013-empathy-b98648af1d450203cd1a59ac45155e93f2216b19.tar.bz2
gsoc2013-empathy-b98648af1d450203cd1a59ac45155e93f2216b19.tar.lz
gsoc2013-empathy-b98648af1d450203cd1a59ac45155e93f2216b19.tar.xz
gsoc2013-empathy-b98648af1d450203cd1a59ac45155e93f2216b19.tar.zst
gsoc2013-empathy-b98648af1d450203cd1a59ac45155e93f2216b19.zip
Implement Google X-OAUTH2 SASL mechanism
https://bugzilla.gnome.org/show_bug.cgi?id=680160
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-sasl-mechanisms.c38
-rw-r--r--libempathy/empathy-sasl-mechanisms.h7
2 files changed, 45 insertions, 0 deletions
diff --git a/libempathy/empathy-sasl-mechanisms.c b/libempathy/empathy-sasl-mechanisms.c
index 5bdc7590f..78bb59b10 100644
--- a/libempathy/empathy-sasl-mechanisms.c
+++ b/libempathy/empathy-sasl-mechanisms.c
@@ -30,6 +30,7 @@
#define MECH_FACEBOOK "X-FACEBOOK-PLATFORM"
#define MECH_WLM "X-MESSENGER-OAUTH2"
+#define MECH_GOOGLE "X-OAUTH2"
typedef struct
{
@@ -40,6 +41,7 @@ typedef struct
static SupportedMech supported_mechanisms[] = {
{ EMPATHY_SASL_MECHANISM_FACEBOOK, MECH_FACEBOOK },
{ EMPATHY_SASL_MECHANISM_WLM, MECH_WLM },
+ { EMPATHY_SASL_MECHANISM_GOOGLE, MECH_GOOGLE },
};
static void
@@ -254,6 +256,42 @@ empathy_sasl_auth_wlm_async (TpChannel *channel,
g_object_unref (result);
}
+void
+empathy_sasl_auth_google_async (TpChannel *channel,
+ const gchar *username,
+ const gchar *access_token,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+ GArray *credential;
+
+ result = empathy_sasl_auth_common_async (channel, callback, user_data);
+
+ g_return_if_fail (result != NULL);
+ g_return_if_fail (empathy_sasl_channel_supports_mechanism (channel,
+ MECH_GOOGLE));
+ g_return_if_fail (!tp_str_empty (username));
+ g_return_if_fail (!tp_str_empty (access_token));
+
+ DEBUG ("Start %s mechanism", MECH_GOOGLE);
+
+ credential = g_array_sized_new (FALSE, FALSE, sizeof (gchar),
+ strlen (access_token) + strlen (username) + 2);
+
+ g_array_append_val (credential, "\0");
+ g_array_append_vals (credential, username, strlen (username));
+ g_array_append_val (credential, "\0");
+ g_array_append_vals (credential, access_token, strlen (access_token));
+
+ tp_cli_channel_interface_sasl_authentication_call_start_mechanism_with_data (
+ channel, -1, MECH_GOOGLE, credential,
+ generic_cb, g_object_ref (result), g_object_unref, NULL);
+
+ g_array_unref (credential);
+ g_object_unref (result);
+}
+
gboolean
empathy_sasl_auth_finish (TpChannel *channel,
GAsyncResult *result,
diff --git a/libempathy/empathy-sasl-mechanisms.h b/libempathy/empathy-sasl-mechanisms.h
index 84165ac70..f0ac12343 100644
--- a/libempathy/empathy-sasl-mechanisms.h
+++ b/libempathy/empathy-sasl-mechanisms.h
@@ -30,6 +30,7 @@ typedef enum
EMPATHY_SASL_MECHANISM_UNSUPPORTED,
EMPATHY_SASL_MECHANISM_FACEBOOK,
EMPATHY_SASL_MECHANISM_WLM,
+ EMPATHY_SASL_MECHANISM_GOOGLE,
} EmpathySaslMechanism;
void empathy_sasl_auth_facebook_async (TpChannel *channel,
@@ -43,6 +44,12 @@ void empathy_sasl_auth_wlm_async (TpChannel *channel,
GAsyncReadyCallback callback,
gpointer user_data);
+void empathy_sasl_auth_google_async (TpChannel *channel,
+ const gchar *username,
+ const gchar *access_token,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
gboolean empathy_sasl_auth_finish (TpChannel *channel,
GAsyncResult *result,
GError **error);