/soc/2015/nakulgulati/main: e350134de7ba: hangouts: api chat init
Nakul at rock.pidgin.im
Nakul at rock.pidgin.im
Sat Aug 1 16:20:29 EDT 2015
Changeset: e350134de7bad5428f0160439da7eb8627f0e3ed
Author: Nakul Gulati
Date: 2015-08-02 04:19 +0800
Branch: hangouts
URL: https://hg.pidgin.im/soc/2015/nakulgulati/main/rev/e350134de7ba
Description:
hangouts: api chat init
diffstat:
libpurple/protocols/hangouts/api.c | 53 ++++++++++++++++++++++++++++++++++++-
libpurple/protocols/hangouts/api.h | 5 ++-
2 files changed, 55 insertions(+), 3 deletions(-)
diffs (102 lines):
diff --git a/libpurple/protocols/hangouts/api.c b/libpurple/protocols/hangouts/api.c
--- a/libpurple/protocols/hangouts/api.c
+++ b/libpurple/protocols/hangouts/api.c
@@ -25,6 +25,7 @@
#include "http.h"
#include "api.h"
+#include "util.h"
//TODO api call backs
G_DEFINE_TYPE(HangoutsApi, hangouts_api, G_TYPE_OBJECT);
@@ -54,11 +55,12 @@ struct _HangoutsApiPrivate
gchar *api_key;
gchar *access_token;
+ gchar *client_id;
+ gchar *email;
gchar *header_date;
gchar *header_version;
gchar *header_id;
- gchar *client_id;
- gchar *email;
+ gchar *pvt_token;
GTimeVal *last_sync_timestamp;
};
@@ -308,6 +310,53 @@ hangouts_api_get_private_token (Hangouts
}
+static void
+hangouts_api_get_chat_init_cb (PurpleHttpConnection *http_conn,
+ PurpleHttpResponse *response, gpointer user_data)
+{
+ gchar *raw_res;
+ GHashTable *tab;
+
+ raw_res = purple_http_response_get_data (response, NULL);
+
+ tab = hangouts_util_parse (raw_res);
+}
+
+void
+hangouts_api_get_chat_init (HangoutsApi *api)
+{
+ HangoutsApiPrivate *priv;
+ HangoutsApiCookies *cookies;
+ PurpleConnection *gc;
+ PurpleHttpRequest *request;
+ const gchar *url_with_param;
+
+ priv = api->priv;
+ gc = priv->gc;
+ cookies = priv->cookies;
+
+ url_with_param = g_strconcat (HANGOUTS_API_CHAT_INIT_URL, "?",
+ HANGOUTS_API_CHAT_INIT_PARAMS(priv->pvt_token));
+ request = purple_http_request_new (url_with_param);
+
+ purple_http_request_set_method (request, "GET");
+ purple_http_request_set_max_len (request, -1);
+ purple_http_request_header_add (
+ request, "Cookie", g_strdup_printf ("APISID %s", cookies->APISID));
+ purple_http_request_header_add (request, "Cookie",
+ g_strdup_printf ("HSID %s", cookies->HSID));
+ purple_http_request_header_add (request, "Cookie",
+ g_strdup_printf ("NID %s", cookies->NID));
+ purple_http_request_header_add (
+ request, "Cookie", g_strdup_printf ("SAPISID %s", cookies->SAPISID));
+ purple_http_request_header_add (request, "Cookie",
+ g_strdup_printf ("SID %s", cookies->SID));
+ purple_http_request_header_add (request, "Cookie",
+ g_strdup_printf ("SSID %s", cookies->SSID));
+ purple_http_request (gc, request, hangouts_api_get_chat_init_cb, api);
+
+}
+
gchar *
hangouts_api_get_request_header (HangoutsApi *api)
{
diff --git a/libpurple/protocols/hangouts/api.h b/libpurple/protocols/hangouts/api.h
--- a/libpurple/protocols/hangouts/api.h
+++ b/libpurple/protocols/hangouts/api.h
@@ -37,7 +37,7 @@
#define HANGOUTS_API_FID "gtn-roster-iframe-id"
#define HANGOUTS_API_EC "[\"ci:ec\",true,true,false]"
-#define HANGOUTS_CHAT_INIT_PARAMS(pvt) g_strdup_printf("prop=%s&fid=%s&ec=%s&pvt=%s",HANGOUTS_PROP,HANGOUTS_FID,HANGOUTS_EC,pvt)
+#define HANGOUTS_API_CHAT_INIT_PARAMS(pvt) g_strdup_printf("prop=%s&fid=%s&ec=%s&pvt=%s",HANGOUTS_API_PROP,HANGOUTS_API_FID,HANGOUTS_API_EC,pvt)
#define HANGOUTS_TYPE_API (hangouts_api_get_type())
#define HANGOUTS_API(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), HANGOUTS_TYPE_API, HangoutsApi))
@@ -84,6 +84,9 @@ hangouts_api_fetch_login_cookies (Hangou
void
hangouts_api_get_private_token(HangoutsApi *api);
+void
+hangouts_api_get_chat_init (HangoutsApi *api);
+
gchar *
hangouts_api_get_request_header (HangoutsApi *api);
More information about the Commits
mailing list