/soc/2015/nakulgulati/main: 77c0f8039ec6: hangouts: util parser ...

Nakul at rock.pidgin.im Nakul at rock.pidgin.im
Wed Jul 15 03:09:36 EDT 2015


Changeset: 77c0f8039ec69fcf542ef83be99ab9f0d4e24df3
Author:	 Nakul Gulati
Date:	 2015-07-14 16:10 +0800
Branch:	 hangouts
URL: https://hg.pidgin.im/soc/2015/nakulgulati/main/rev/77c0f8039ec6

Description:

hangouts: util parser returns hashtable

diffstat:

 libpurple/protocols/hangouts/util.c |  14 +++++++++++---
 libpurple/protocols/hangouts/util.h |   2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diffs (52 lines):

diff --git a/libpurple/protocols/hangouts/util.c b/libpurple/protocols/hangouts/util.c
--- a/libpurple/protocols/hangouts/util.c
+++ b/libpurple/protocols/hangouts/util.c
@@ -27,12 +27,15 @@ hangouts_util_escape_string(gchar *strin
 	return g_strescape(string,NULL);
 }
 
-void
+GHashTable *
 hangouts_util_parse(gchar *raw_data)
 {
 	GRegex *regex_script_data,*regex_key_data;
 	GMatchInfo *match_info;
 	gchar *escaped_data;
+	GHashTable *chat_init_data;
+
+	chat_init_data = g_hash_table_new(g_str_hash, g_str_equal);
 
 	escaped_data = hangouts_util_escape_string(raw_data);
 
@@ -45,13 +48,18 @@ hangouts_util_parse(gchar *raw_data)
 		gchar *script_data = g_match_info_fetch (match_info, 0);
 		gchar **key_data = g_regex_split(regex_key_data, script_data, 0);
 
-		/*key_data[1] - key
-		key_data[2] - data*/
+		g_hash_table_insert(chat_init_data, key_data[1], key_data[2]);
 
 		g_match_info_next (match_info, NULL);
 		g_free(script_data);
 		g_free(key_data);
 	}
 
+	g_match_info_free (match_info);
+	g_regex_unref (regex_key_data);
+	g_regex_unref (regex_script_data);
+
+	return chat_init_data;
+
 }
 
diff --git a/libpurple/protocols/hangouts/util.h b/libpurple/protocols/hangouts/util.h
--- a/libpurple/protocols/hangouts/util.h
+++ b/libpurple/protocols/hangouts/util.h
@@ -26,6 +26,6 @@ static const gchar *HANGOUTS_CHAT_INIT_R
 static const gchar *HANGOUTS_CHAT_KEY_DATA_REGEX = "(?:key: \'(ds:.{1,2})\')(?:.*?)(?:data:function..{return (.*?)}}.;<\/script>)";
 
 gchar *hangouts_util_escape_string(gchar *string);
-void hangouts_util_parse(gchar *raw_data);
+GHashTable *hangouts_util_parse(gchar *raw_data);
 
 #endif _UTIL_H



More information about the Commits mailing list