summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-29 18:06:25 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-29 18:06:25 (EDT)
commitfeda98f9c3ecadeaf364f16c12d112e19ce7183f (patch)
tree78c71643bedbd32a81502219d6c40db3c6934da6 /src
parent85b5c16b09320d6da34dd552c79ad28a43e9debf (diff)
downloadmarquee-feda98f9c3ecadeaf364f16c12d112e19ce7183f.zip
marquee-feda98f9c3ecadeaf364f16c12d112e19ce7183f.tar.gz
marquee-feda98f9c3ecadeaf364f16c12d112e19ce7183f.tar.bz2
about: Make path handlers send responses to WK
Diffstat (limited to 'src')
-rw-r--r--src/about.c24
-rw-r--r--src/about.h3
-rw-r--r--src/about/marquee.c11
-rw-r--r--src/about/paths.h5
4 files changed, 27 insertions, 16 deletions
diff --git a/src/about.c b/src/about.c
index a4b4d39..c0ede12 100644
--- a/src/about.c
+++ b/src/about.c
@@ -53,12 +53,9 @@ parse_query_string(gchar *str)
void
mq_about_request(WebKitURISchemeRequest *request, MqApplication *application)
{
- const gchar *path;
- gchar *query_str;
- GHashTable *query;
- gchar *contents;
- gsize stream_length;
- GInputStream *stream;
+ const gchar *path;
+ gchar *query_str;
+ GHashTable *query;
path = webkit_uri_scheme_request_get_path(request);
query_str = strchr(webkit_uri_scheme_request_get_uri(request), '?');
@@ -70,16 +67,23 @@ mq_about_request(WebKitURISchemeRequest *request, MqApplication *application)
}
if (g_strcmp0(path, "marquee") == 0) {
- contents = mq_about_marquee_response(application, query);
- stream_length = strlen(contents);
- stream = g_memory_input_stream_new_from_data(contents,
- stream_length, g_free);
+ mq_about_marquee_response(application, query, request);
} else {
return;
}
g_free(query_str);
+}
+
+void
+mq_about_response(WebKitURISchemeRequest *request, gchar *contents)
+{
+ gsize stream_length;
+ GInputStream *stream;
+ stream_length = strlen(contents);
+ stream = g_memory_input_stream_new_from_data(contents,
+ stream_length, g_free);
webkit_uri_scheme_request_finish(request, stream, stream_length,
"text/html");
g_object_unref(stream);
diff --git a/src/about.h b/src/about.h
index a502cd9..f28d9fe 100644
--- a/src/about.h
+++ b/src/about.h
@@ -29,4 +29,7 @@
void
mq_about_request(WebKitURISchemeRequest *request, MqApplication *application);
+void
+mq_about_response(WebKitURISchemeRequest *request, gchar *contents);
+
#endif
diff --git a/src/about/marquee.c b/src/about/marquee.c
index 70413aa..c076e24 100644
--- a/src/about/marquee.c
+++ b/src/about/marquee.c
@@ -20,9 +20,11 @@
*/
#include <glib.h>
+#include <webkit2/webkit2.h>
#include "paths.h"
#include "../application.h"
+#include "../about.h"
const gchar *document =
"<!doctype html>"
@@ -38,8 +40,9 @@ const gchar *document =
"</body>"
"</html>";
-gchar *
-mq_about_marquee_response(MqApplication *application, GHashTable *query)
+void
+mq_about_marquee_response(MqApplication *application, GHashTable *query,
+ WebKitURISchemeRequest *request)
{
if (query && g_hash_table_lookup(query, "toggle")) {
if (mq_application_marquee_mode_on(application)) {
@@ -49,6 +52,6 @@ mq_about_marquee_response(MqApplication *application, GHashTable *query)
}
}
- return g_strdup_printf(document,
- "DANGER", "DO NOT PRESS");
+ mq_about_response(request, g_strdup_printf(document,
+ "DANGER", "DO NOT PRESS"));
}
diff --git a/src/about/paths.h b/src/about/paths.h
index ec365d1..e3c2434 100644
--- a/src/about/paths.h
+++ b/src/about/paths.h
@@ -26,7 +26,8 @@
#include "../application.h"
-gchar *
-mq_about_marquee_response(MqApplication *application, GHashTable *query);
+void
+mq_about_marquee_response(MqApplication *application, GHashTable *query,
+ WebKitURISchemeRequest *request);
#endif