reset
authorRobert Manea <gotmor@gmail.com>
Tue, 16 Jun 2009 07:55:43 +0000 (09:55 +0200)
committerRobert Manea <gotmor@gmail.com>
Tue, 16 Jun 2009 07:55:43 +0000 (09:55 +0200)
Makefile
Makefile-new-test [deleted file]
uzbl.h
uzblctrl.c

index 5f4ba8f..b4a1298 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,37 +1,51 @@
-CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DG_ERRORCHECK_MUTEXES -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS)
-LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4) -pthread $(LDFLAGS)
+LIBS      := gtk+-2.0 webkit-1.0 gthread-2.0 libsoup-2.4
+ARCH      := $(shell uname -m)
+COMMIT    := $(shell git log | head -n1 | sed "s/.* //")
+DEBUG     := -ggdb -Wall -W -DG_ERRORCHECK_MUTEXES
+
+CFLAGS    := $(shell pkg-config --cflags $(LIBS)) $(DEBUG) -DARCH="\"$(ARCH)\"" -DCOMMIT="\"$(COMMIT)\"" -std=c99
+LDFLAGS   := $(shell pkg-config --libs $(LIBS)) $(LDFLAGS)
+
+PREFIX    ?= $(DESTDIR)/usr
+BINDIR    ?= $(PREFIX)/bin
+UZBLDATA  ?= $(PREFIX)/share/uzbl
+DOCSDIR   ?= $(PREFIX)/share/uzbl/docs
+EXMPLSDIR ?= $(PREFIX)/share/uzbl/examples
+
 all: uzbl uzblctrl
 
-PREFIX?=$(DESTDIR)/usr
+uzbl: uzbl.c uzbl.h config.h
 
-test: uzbl
-       ./uzbl --uri http://www.uzbl.org --verbose
+%: %.c
+       $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
 
-test-dev: uzbl
-       XDG_DATA_HOME=./examples/data               XDG_CONFIG_HOME=./examples/config               ./uzbl --uri http://www.uzbl.org --verbose
+test: uzbl
+       ./uzbl --uri http://www.uzbl.org
 
-test-share: uzbl
-       XDG_DATA_HOME=/usr/share/uzbl/examples/data XDG_CONFIG_HOME=/usr/share/uzbl/examples/config ./uzbl --uri http://www.uzbl.org --verbose
+test-config: uzbl
+       ./uzbl --uri http://www.uzbl.org < examples/configs/sampleconfig-dev
 
+test-config-real: uzbl
+       ./uzbl --uri http://www.uzbl.org < $(EXMPLSDIR)/configs/sampleconfig
        
 clean:
        rm -f uzbl
        rm -f uzblctrl
 
 install:
-       install -d $(PREFIX)/bin
-       install -d $(PREFIX)/share/uzbl/docs
-       install -d $(PREFIX)/share/uzbl/examples
-       install -D -m755 uzbl $(PREFIX)/bin/uzbl
-       install -D -m755 uzblctrl $(PREFIX)/bin/uzblctrl
-       cp -ax docs     $(PREFIX)/share/uzbl/
-       cp -ax config.h $(PREFIX)/share/uzbl/docs/
-       cp -ax examples $(PREFIX)/share/uzbl/
-       install -D -m644 AUTHORS $(PREFIX)/share/uzbl/docs
-       install -D -m644 README  $(PREFIX)/share/uzbl/docs
+       install -d $(BINDIR)
+       install -d $(DOCSDIR)
+       install -d $(EXMPLSDIR)
+       install -D -m755 uzbl $(BINDIR)/uzbl
+       install -D -m755 uzblctrl $(BINDIR)/uzblctrl
+       cp -ax docs/*   $(DOCSDIR)
+       cp -ax config.h $(DOCSDIR)
+       cp -ax examples/* $(EXMPLSDIR)
+       install -D -m644 AUTHORS $(DOCSDIR)
+       install -D -m644 README $(DOCSDIR)
 
 
 uninstall:
-       rm -rf $(PREFIX)/bin/uzbl
-       rm -rf $(PREFIX)/bin/uzblctrl
-       rm -rf $(PREFIX)/share/uzbl
+       rm -rf $(BINDIR)/uzbl
+       rm -rf $(BINDIR)/uzblctrl
+       rm -rf $(UZBLDATA)
diff --git a/Makefile-new-test b/Makefile-new-test
deleted file mode 100644 (file)
index 5985c90..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-LIBS      := gtk+-2.0 webkit-1.0
-ARCH      := $(shell uname -m)
-COMMIT    := $(shell git log | head -n1 | sed "s/.* //")
-DEBUG     := -ggdb -Wall -W -DG_ERRORCHECK_MUTEXES
-
-CFLAGS    := $(shell --cflags $(LIBS)) $(DEBUG) -DARCH="$(ARCH)" -DCOMMIT="\"$(COMMIT)\""
-LDFLAGS   := $(shell --libs $(LIBS)) $(LDFLAGS)
-
-PREFIX    ?= $(DESTDIR)/usr
-BINDIR    ?= $(PREFIX)/bin
-UZBLDATA  ?= $(PREFIX)/share/uzbl
-DOCSDIR   ?= $(PREFIX)/share/uzbl/docs
-EXMPLSDIR ?= $(PREFIX)/share/uzbl/examples
-
-all: uzbl uzblctrl
-
-uzbl: uzbl.c uzbl.h config.h
-
-%: %.c
-       $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIBS) -o $@ $<
-
-test: uzbl
-       ./uzbl --uri http://www.uzbl.org
-
-test-config: uzbl
-       ./uzbl --uri http://www.uzbl.org < examples/configs/sampleconfig-dev
-
-test-config-real: uzbl
-       ./uzbl --uri http://www.uzbl.org < $(EXMPLSDIR)/configs/sampleconfig
-       
-clean:
-       rm -f uzbl
-       rm -f uzblctrl
-
-install:
-       install -d $(BINDIR)
-       install -d $(DOCSDIR)
-       install -d $(EXMPLSDIR)
-       install -D -m755 uzbl $(BINDIR)/uzbl
-       install -D -m755 uzblctrl $(BINDIR)/uzblctrl
-       cp -ax docs/*   $(DOCSDIR)
-       cp -ax config.h $(DOCSDIR)
-       cp -ax examples/* $(EXMPLSDIR)
-       install -D -m644 AUTHORS $(DOCSDIR)
-       install -D -m644 README $(DOCSDIR)
-
-
-uninstall:
-       rm -rf $(BINDIR)/uzbl
-       rm -rf $(BINDIR)/uzblctrl
-       rm -rf $(UZBLDATA)
diff --git a/uzbl.h b/uzbl.h
index ee9e693..2cf0346 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -11,8 +11,6 @@
  *
  */
 
-#define NOSPLIT ((void*)1)
-
 enum {
   /* statusbar symbols */
   SYM_TITLE, SYM_URI, SYM_NAME,
@@ -178,6 +176,12 @@ typedef struct {
     GHashTable* commands;
 } Behaviour;
 
+/* javascript */
+typedef struct {
+    gboolean            initialized;
+    JSClassDefinition   classdef;
+    JSClassRef          classref;
+} Javascript;
 
 /* main uzbl data structure */
 typedef struct {
@@ -186,6 +190,7 @@ typedef struct {
     Network       net;
     Behaviour     behave;
     Communication comm;
+    Javascript    js;
 
     Window        xwin;
     GScanner      *scan;
@@ -218,6 +223,7 @@ XDG_Var XDG[] =
     { "XDG_DATA_DIRS",   "/usr/local/share/:/usr/share/" },
 };
 
+
 /* Functions */
 static void
 setup_scanner();
@@ -246,9 +252,6 @@ setup_signal(int signe, sigfunc *shandler);
 static gboolean
 set_var_value(gchar *name, gchar *val);
 
-static void
-print(WebKitWebView *page, GArray *argv);
-
 static gboolean
 new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
 
@@ -262,12 +265,6 @@ static gboolean
 download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
 
 static void
-toggle_zoom_type (WebKitWebView* page, GArray *argv);
-
-static void
-toggle_status_cb (WebKitWebView* page, GArray *argv);
-
-static void
 link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
 
 static void
@@ -304,50 +301,17 @@ static bool
 file_exists (const char * filename);
 
 static void
-toggle_insert_mode(WebKitWebView *page, GArray *argv);
-
-static void
-load_uri (WebKitWebView * web_view, GArray *argv);
-
-static void
 new_window_load_uri (const gchar * uri);
 
-static void
-chain (WebKitWebView *page, GArray *argv);
-
-static void
-keycmd (WebKitWebView *page, GArray *argv);
-
-static void
-keycmd_nl (WebKitWebView *page, GArray *argv);
-
-static void
-keycmd_bs (WebKitWebView *page, GArray *argv);
-
-static void
-close_uzbl (WebKitWebView *page, GArray *argv);
-
 static gboolean
 run_command(const gchar *command, const guint npre,
             const gchar **args, const gboolean sync, char **output_stdout);
 
 static void
-spawn(WebKitWebView *web_view, GArray *argv);
+parse_command(const char *cmd, const char *param, GString *result);
 
 static void
-spawn_sh(WebKitWebView *web_view, GArray *argv);
-
-static void
-spawn_sync(WebKitWebView *web_view, GArray *argv);
-
-static void
-spawn_sh_sync(WebKitWebView *web_view, GArray *argv);
-
-static void
-parse_command(const char *cmd, const char *param);
-
-static void
-parse_cmd_line(const char *ctl_line);
+parse_cmd_line(const char *ctl_line, GString *result);
 
 static gchar*
 build_stream_name(int type, const gchar *dir);
@@ -370,6 +334,9 @@ init_socket(gchar *dir);
 static gboolean
 control_socket(GIOChannel *chan);
 
+static gboolean
+control_client_socket(GIOChannel *chan);
+
 static void
 update_title (void);
 
@@ -412,51 +379,105 @@ settings_init ();
 static void
 search_text (WebKitWebView *page, GArray *argv, const gboolean forward);
 
+static void handle_cookies (SoupSession *session,
+                            SoupMessage *msg,
+                            gpointer     user_data);
 static void
-search_forward_text (WebKitWebView *page, GArray *argv);
+save_cookies (SoupMessage *msg,
+                gpointer     user_data);
 
 static void
-search_reverse_text (WebKitWebView *page, GArray *argv);
+act_dump_config();
 
 static void
-dehilight (WebKitWebView *page, GArray *argv);
+render_html();
 
 static void
-run_js (WebKitWebView * web_view, GArray *argv);
+set_timeout(int seconds);
 
 static void
-run_external_js (WebKitWebView * web_view, GArray *argv);
+dump_var_hash(gpointer k, gpointer v, gpointer ud);
 
-static void handle_cookies (SoupSession *session,
-                            SoupMessage *msg,
-                            gpointer     user_data);
 static void
-save_cookies (SoupMessage *msg,
-                gpointer     user_data);
+dump_key_hash(gpointer k, gpointer v, gpointer ud);
 
 static void
-set_var(WebKitWebView *page, GArray *argv);
+dump_config();
+
+
+/* Commands */
+
+typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result);
+typedef struct {
+    Command function;
+    gboolean no_split;
+} CommandInfo;
 
 static void
-act_bind(WebKitWebView *page, GArray *argv);
+print(WebKitWebView *page, GArray *argv, GString *result);
 
 static void
-act_dump_config();
+toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result);
 
 static void
-render_html();
+toggle_status_cb (WebKitWebView* page, GArray *argv, GString *result);
 
 static void
-set_timeout(int seconds);
+toggle_insert_mode(WebKitWebView *page, GArray *argv, GString *result);
 
 static void
-dump_var_hash(gpointer k, gpointer v, gpointer ud);
+load_uri (WebKitWebView * web_view, GArray *argv, GString *result);
 
 static void
-dump_key_hash(gpointer k, gpointer v, gpointer ud);
+chain (WebKitWebView *page, GArray *argv, GString *result);
 
 static void
-dump_config();
+keycmd (WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+keycmd_nl (WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+keycmd_bs (WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+close_uzbl (WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+spawn(WebKitWebView *web_view, GArray *argv, GString *result);
+
+static void
+spawn_sh(WebKitWebView *web_view, GArray *argv, GString *result);
+
+static void
+spawn_sync(WebKitWebView *web_view, GArray *argv, GString *result);
+
+static void
+spawn_sh_sync(WebKitWebView *web_view, GArray *argv, GString *result);
+
+static void
+search_forward_text (WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+search_reverse_text (WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+dehilight (WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+eval_js(WebKitWebView * web_view, gchar *script, GString *result);
+
+static void
+run_js (WebKitWebView * web_view, GArray *argv, GString *result);
+
+static void
+run_external_js (WebKitWebView * web_view, GArray *argv, GString *result);
+
+static void
+set_var(WebKitWebView *page, GArray *argv, GString *result);
+
+static void
+act_bind(WebKitWebView *page, GArray *argv, GString *result);
 
 
 /* Command callbacks */
index c8644c5..93584bc 100644 (file)
@@ -2,17 +2,9 @@
 /* Socket code more or less completely copied from here: http://www.ecst.csuchico.edu/~beej/guide/ipc/usock.html */
 
 #include <gtk/gtk.h>
-#include <gdk/gdkx.h>
-#include <gdk/gdkkeysyms.h>
-#include <webkit/webkit.h>
-#include <pthread.h>
 #include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -40,6 +32,7 @@ main(int argc, char* argv[]) {
     if (sockpath && command) {
         int s, len;
         struct sockaddr_un remote;
+        char tmp;
         
         if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1) {
             perror ("socket");
@@ -55,11 +48,18 @@ main(int argc, char* argv[]) {
             exit (1);
         }
         
-        if (send (s, command, strlen (command), 0) == -1) {
+        if ((send (s, command, strlen (command), 0) == -1) ||
+            (send (s, "\n", 1, 0) == -1)) {
             perror ("send");
             exit (1);
         }
         
+        while ((len = recv (s, &tmp, 1, 0))) {
+            putchar(tmp);
+            if (tmp == '\n')
+                break;
+        }
+
         close(s);
         
         return 0;