/soc/2015/nakulgulati/main: 9e75338f6aec: hangouts: api request
Nakul at rock.pidgin.im
Nakul at rock.pidgin.im
Thu Jul 23 01:06:31 EDT 2015
Changeset: 9e75338f6aec6f7270df9fdf3b370ba21a1874fc
Author: Nakul Gulati
Date: 2015-07-21 03:46 +0800
Branch: hangouts
URL: https://hg.pidgin.im/soc/2015/nakulgulati/main/rev/9e75338f6aec
Description:
hangouts: api request
diffstat:
libpurple/protocols/hangouts/api.c | 44 ++++++++++++++++++++++++++++++++++++-
libpurple/protocols/hangouts/api.h | 11 ++++++++-
2 files changed, 52 insertions(+), 3 deletions(-)
diffs (92 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
@@ -22,16 +22,56 @@
#include "api.h"
#include "auth.h"
+//TODO get data api ready
+
G_DEFINE_TYPE(HangoutsApi, hangouts_api, G_TYPE_OBJECT);
-typedef struct
-{
+typedef struct {
hangouts_oauth_cookies *cookies;
gchar *api_key;
+ gchar *access_token;
gchar *header_date;
+ gchar *header_version;
gchar *header_id;
gchar *client_id;
gchar *email;
GTimeVal *sync_timestamp;
} _hangouts_api_data;
+
+void hangouts_api_request(HangoutsApi *hangoutsApi, gchar *url_endpoint, gchar *content_type, gchar *request_body) {
+
+ HangoutsApiData *data = hangoutsApi->api_data;
+ gchar *url = g_strconcat(HANGOUTS_API_BASE_URL, url_endpoint,"?alt=json");
+ PurpleHttpRequest *request = purple_http_request_new(url);
+ PurpleHttpConnection *ret;
+
+ purple_http_request_header_add(request, "content-type", content_type);
+ purple_http_request_header_add(request, "Authorization", hangouts_auth_get_authorization_header(data->access_token));
+ purple_http_request_set_method(request, "POST");
+ purple_http_request_set_contents(request, request_body);
+ //purple_http_request()
+}
+
+gchar *
+hangouts_api_get_request_header(HangoutsApi *hangoutsApi) {
+
+ HangoutsApiData *data = hangoutsApi->api_data;
+
+ gchar *header = g_strdup_printf("["
+ "[6, 3, %s, %s],"
+ "[%s, %s],"
+ "None,"
+ "\"en\""
+ "]",
+ data->header_version,
+ data->header_date,
+ data->client_id,
+ data->header_id);
+
+ return header;
+}
+
+void hangouts_api_getselfinfo() {
+
+}
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
@@ -26,6 +26,7 @@
#define HANGOUTS_IMAGE_UPLOAD_URL "http://docs.google.com/upload/photos/resumable"
#define HANGOUTS_PVT_TOKEN_URL "https://talkgadget.google.com/talkgadget/_/extension-start"
#define HANGOUTS_CHAT_INIT_URL "https://talkgadget.google.com/u/0/talkgadget/_/chat"
+#define HANGOUTS_API_BASE_URL "https://www.googleapis.com/chat/v1ios/"
#define HANGOUTS_PROP "aChromeExtension"
#define HANGOUTS_FID "gtn-roster-iframe-id"
@@ -41,9 +42,17 @@
#define HANGOUTS_IS_API_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), HANGOUTS_TYPE_API))
#define HANGOUTS_API_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), HANGOUTS_TYPE_API, HangoutsApiClass))
+typedef struct _HangoutsApi HangoutsApi;
+typedef struct _hangouts_api_data HangoutsApiData;
+
+struct _HangoutsApi{
+ GObject parent;
+ HangoutsApiData *api_data;
+};
+
GType
hangouts_api_get_type(void);
-typedef struct _hangouts_api_data hangouts_api_data;
+
#endif /* _API_H */
More information about the Commits
mailing list