summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/about.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/about.c b/src/about.c
index d130534..41338d3 100644
--- a/src/about.c
+++ b/src/about.c
@@ -19,20 +19,63 @@
* along with Marquee. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
+
#include <webkit2/webkit2.h>
#include "about.h"
#include "application.h"
+GHashTable *
+parse_query_string(gchar *str)
+{
+ GHashTable *hash_table;
+ gchar *key;
+ gchar *val;
+
+ hash_table = g_hash_table_new(g_str_hash, g_str_equal);
+
+ while (*str) {
+ key = str;
+ for (; *str && *str != '='; ++str);
+ if (!*str) {
+ g_hash_table_insert(hash_table, key, NULL);
+ break;
+ }
+ *str = '\0';
+ val = ++str;
+ for (; *str && *str != '&'; ++str);
+ if (!*str) {
+ g_hash_table_insert(hash_table, key, val);
+ break;
+ }
+ *str = '\0';
+ g_hash_table_insert(hash_table, key, val);
+ ++str;
+ }
+
+ return hash_table;
+}
+
void
mq_about_request(WebKitURISchemeRequest *request, MqApplication *application)
{
const gchar *path;
+ gchar *query_str;
+ GHashTable *query;
gchar *contents;
gsize stream_length;
GInputStream *stream;
path = webkit_uri_scheme_request_get_path(request);
+ query_str = strchr(webkit_uri_scheme_request_get_uri(request), '?');
+ if (query_str && query_str[1]) {
+ query_str = g_strdup(query_str + 1);
+ query = parse_query_string(query_str);
+ } else {
+ query = NULL;
+ }
+
if (g_strcmp0(path, "marquee") == 0) {
/* TODO: Respond with an HTML document with a toggle button. */
mq_application_marquee_mode_activate(application);