/soc/2015/nakulgulati/main: ee7e4c1c684a: hangouts: hangouts prefix

Nakul at rock.pidgin.im Nakul at rock.pidgin.im
Mon Jun 29 01:54:34 EDT 2015


Changeset: ee7e4c1c684a88284f3264e617c87f0e7cfc0a0c
Author:	 Nakul Gulati
Date:	 2015-06-29 13:54 +0800
Branch:	 hangouts
URL: https://hg.pidgin.im/soc/2015/nakulgulati/main/rev/ee7e4c1c684a

Description:

hangouts: hangouts prefix

diffstat:

 libpurple/protocols/hangouts/api.c  |   2 ++
 libpurple/protocols/hangouts/api.h  |  25 +++++++++++++++++--------
 libpurple/protocols/hangouts/auth.c |  18 ++++++++++--------
 libpurple/protocols/hangouts/auth.h |  12 ++++++------
 4 files changed, 35 insertions(+), 22 deletions(-)

diffs (137 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
@@ -20,3 +20,5 @@
  */
 
 #include "api.h"
+
+G_DEFINE_TYPE(HangoutsApi, hangouts_api, G_TYPE_OBJECT);
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
@@ -22,17 +22,26 @@
 #ifndef _API_H
 #define _API_H
 
-#define ORIGIN_URL "https://talkgadget.google.com"
-#define IMAGE_UPLOAD_URL "http://docs.google.com/upload/photos/resumable"
-#define PVT_TOKEN_URL "https://talkgadget.google.com/talkgadget/_/extension-start"
-#define CHAT_INIT_URL "https://talkgadget.google.com/u/0/talkgadget/_/chat"
+#define HANGOUTS_ORIGIN_URL "https://talkgadget.google.com"
+#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 PROP "aChromeExtension"
-#define FID "gtn-roster-iframe-id"
-#define EC "[\"ci:ec\",true,true,false]"
+#define HANGOUTS_PROP "aChromeExtension"
+#define HANGOUTS_FID "gtn-roster-iframe-id"
+#define HANGOUTS_EC "[\"ci:ec\",true,true,false]"
 
-#define CHAT_INIT_PARAMS(pvt) g_strdup_printf("prop=%s&fid=%s&ec=%s&pvt=%s",PROP,FID,EC,pvt)
+#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_TYPE_API	(hangouts_api_get_type())
+#define HANGOUTS_API(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), HANGOUTS_TYPE_API, HangoutsApi))
+#define HANGOUTS_API(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), HANGOUTS_TYPE_API, HangoutsApi))
+#define HANGOUTS_API_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), HANGOUTS_TYPE_API, HangoutsApiClass))
+#define HANGOUTS_IS_API(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), HANGOUTS_TYPE_API))
+#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))
 
+GType
+hangouts_api_get_type(void);
 
 #endif /* _API_H */
diff --git a/libpurple/protocols/hangouts/auth.c b/libpurple/protocols/hangouts/auth.c
--- a/libpurple/protocols/hangouts/auth.c
+++ b/libpurple/protocols/hangouts/auth.c
@@ -94,11 +94,11 @@ hangouts_auth_with_authentication_code(P
 			"code=%s&"
 			"grant_type=%s&"
 			"redirect_uri=%s",
-			OAUTH2_CLIENT_ID,
-			OAUTH2_CLIENT_SECRET,
+			HANGOUTS_OAUTH2_CLIENT_ID,
+			HANGOUTS_OAUTH2_CLIENT_SECRET,
 			auth_code,
 			OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE,
-			OAUTH2_REDIRECT_URI);
+			HANGOUTS_OAUTH2_REDIRECT_URI);
 
 	PurpleHttpRequest *request;
 	const char *method = "POST";
@@ -154,8 +154,8 @@ hangouts_auth_with_refresh_token(PurpleC
 			"client_secret=%s&"
 			"grant_type=%s&"
 			"refresh_token=%s",
-			OAUTH2_CLIENT_ID,
-			OAUTH2_CLIENT_SECRET,
+			HANGOUTS_OAUTH2_CLIENT_ID,
+			HANGOUTS_OAUTH2_CLIENT_SECRET,
 			OAUTH2_GRANT_TYPE_REFRESH_CODE,
 			refresh_token);
 
@@ -177,15 +177,16 @@ hangouts_auth_get_session_cookies_got_cb
 {
 	purple_debug_misc("hangouts-prpl", "cookies_got");
 	gchar *raw = purple_http_response_get_data(response, NULL);
-	purple_debug_misc("hangouts-prpl", "cookies_got response: %s", raw);
+	/*purple_debug_misc("hangouts-prpl", "cookies_got response: %s", raw);*/
 
 	PurpleHttpCookieJar *cookie_jar;
 
 	cookie_jar = purple_http_conn_get_cookie_jar(gc);
 
 	gchar *cookies = purple_http_cookie_jar_dump(cookie_jar);
+	gchar *hsid = purple_http_cookie_jar_get(cookie_jar,"HSID");
 
-	purple_debug_misc("hangouts-prpl", "cookies: %s", cookies);
+	purple_debug_misc("hangouts-prpl", "cookies: %s \n HSID: %s", cookies, hsid);
 }
 
 void
@@ -195,7 +196,7 @@ hangouts_auth_get_session_cookies_uberau
 	purple_debug_misc("hangouts-prpl", "uberauth");
 	PurpleHttpRequest *request;
 	gchar *auth_data, *url, *uberauth;
-	//PurpleHttpCookieJar *cookie_jar;
+	PurpleHttpCookieJar *cookie_jar;
 
 	uberauth = purple_http_response_get_data(response, NULL);
 	purple_debug_misc("hangouts-prpl", "uberauth: %s", uberauth);
@@ -207,6 +208,7 @@ hangouts_auth_get_session_cookies_uberau
 	request = purple_http_request_new(url);
 	purple_http_request_set_method(request,"GET");
 	purple_http_request_header_set(request,"Authorization",auth_data);
+	purple_http_request_set_cookie_jar(request,cookie_jar);
 	purple_http_request(gc,request,hangouts_auth_get_session_cookies_got_cb,NULL);
 
 }
diff --git a/libpurple/protocols/hangouts/auth.h b/libpurple/protocols/hangouts/auth.h
--- a/libpurple/protocols/hangouts/auth.h
+++ b/libpurple/protocols/hangouts/auth.h
@@ -22,15 +22,15 @@
 #ifndef _AUTH_H_
 #define _AUTH_H_
 
-#define OAUTH2_SCOPE "https://www.google.com/accounts/OAuthLogin"
-#define OAUTH2_CLIENT_ID "936475272427.apps.googleusercontent.com"
-#define OAUTH2_CLIENT_SECRET "KWsJlkaMn1jGLxQpWxMnOox-"
-#define OAUTH2_REDIRECT_URI "urn:ietf:wg:oauth:2.0:oob"
+#define HANGOUTS_OAUTH2_SCOPE "https://www.google.com/accounts/OAuthLogin"
+#define HANGOUTS_OAUTH2_CLIENT_ID "936475272427.apps.googleusercontent.com"
+#define HANGOUTS_OAUTH2_CLIENT_SECRET "KWsJlkaMn1jGLxQpWxMnOox-"
+#define HANGOUTS_OAUTH2_REDIRECT_URI "urn:ietf:wg:oauth:2.0:oob"
 
 #define OAUTH2_LOGIN_URL "https://accounts.google.com/o/oauth2/auth?\
 response_type=code&\
-redirect_uri=" OAUTH2_REDIRECT_URI \
-"&client_id=" OAUTH2_CLIENT_ID "&scope=" OAUTH2_SCOPE
+redirect_uri=" HANGOUTS_OAUTH2_REDIRECT_URI \
+"&client_id=" HANGOUTS_OAUTH2_CLIENT_ID "&scope=" HANGOUTS_OAUTH2_SCOPE
 
 #define OAUTH2_TOKEN_REQUEST_URL "https://accounts.google.com/o/oauth2/token"
 



More information about the Commits mailing list