/soc/2015/nakulgulati/main: be8db9efb38f: hangouts: channel - ge...

Nakul at rock.pidgin.im Nakul at rock.pidgin.im
Mon Aug 10 12:50:19 EDT 2015


Changeset: be8db9efb38f90acc47bf4be7403f06d53553e8c
Author:	 Nakul Gulati
Date:	 2015-08-11 00:50 +0800
Branch:	 hangouts
URL: https://hg.pidgin.im/soc/2015/nakulgulati/main/rev/be8db9efb38f

Description:

hangouts: channel - get sid

diffstat:

 libpurple/protocols/hangouts/channel.c |  49 ++++++++++++++++++++++++++++++++-
 libpurple/protocols/hangouts/channel.h |   3 ++
 2 files changed, 50 insertions(+), 2 deletions(-)

diffs (84 lines):

diff --git a/libpurple/protocols/hangouts/channel.c b/libpurple/protocols/hangouts/channel.c
--- a/libpurple/protocols/hangouts/channel.c
+++ b/libpurple/protocols/hangouts/channel.c
@@ -82,8 +82,50 @@ hangouts_channel_set_access_token (Hango
 }
 
 static void
+hangouts_channel_get_sid_cb (PurpleHttpConnection *http_conn,
+			     PurpleHttpResponse *response, gpointer *user_data)
+{
+  HangoutsChannel *channel;
+  gchar *res;
+  JsonNode *node;
+
+  channel = user_data;
+  res = purple_http_response_get_data (response, NULL);
+
+  node = hangouts_json_node_new (res, -1, FALSE);
+
+  purple_debug_misc ("hangouts-channel", "sid res: %s", res);
+}
+
+void
+hangouts_channel_get_sid (HangoutsChannel *channel)
+{
+  HangoutsChannelPrivate *priv;
+  PurpleHttpRequest *request;
+  gchar *params;
+
+  priv = channel->priv;
+
+  params = g_strdup_printf ("?ctype=hangouts"
+			    "&RID=81187"
+			    "&VER=8"
+			    "&gessionid=%s",
+			    priv->gession_id);
+  request = purple_http_request_new (
+      g_strdup_printf ("%s%s%s", HANGOUTS_CHANNEL_URL, "channel/bind", params));
+
+  purple_http_request_set_method (request, "POST");
+  purple_http_request_set_max_len (request, -1);
+  purple_http_request_set_cookie_jar (request, priv->cj);
+  purple_http_request_header_add (
+      request, "Authorization",
+      g_strdup_printf ("Bearer %s", priv->access_token));
+  purple_http_request (priv->gc, request, hangouts_channel_get_sid_cb, channel);
+}
+
+static void
 hangouts_channel_get_gsid_cb (PurpleHttpConnection *http_conn,
-			      PurpleHttpResponse *response, gpointer *data)
+			      PurpleHttpResponse *response, gpointer *user_data)
 {
   /*[
    * 12880, expires_in
@@ -95,11 +137,14 @@ hangouts_channel_get_gsid_cb (PurpleHttp
   JsonNode *node;
   HangoutsChannel *channel;
 
-  channel = data;
+  channel = user_data;
   res_raw = purple_http_response_get_data (response, NULL);
   node = hangouts_json_node_new (res_raw, -1, FALSE);
   channel->priv->gession_id = hangouts_json_node_get_str (node, "$[1]", NULL);
+  purple_debug_misc ("hangouts-channel", "gsid: %s", channel->priv->gession_id);
+  hangouts_channel_get_sid (channel);
 
+  json_node_free (node);
 }
 
 void
diff --git a/libpurple/protocols/hangouts/channel.h b/libpurple/protocols/hangouts/channel.h
--- a/libpurple/protocols/hangouts/channel.h
+++ b/libpurple/protocols/hangouts/channel.h
@@ -39,6 +39,9 @@ HangoutsChannel *
 hangouts_channel_new (PurpleConnection *gc);
 
 void
+hangouts_channel_get_sid (HangoutsChannel *channel);
+
+void
 hangouts_channel_get_gsid (HangoutsChannel *channel);
 
 #endif /* _HANGOUTS_CHANNEL_H_ */



More information about the Commits mailing list