[Dillo-dev]protocol handler dpi for mailto:, etc.
Hello again, I did up a proto-type bash shell dpi for handling unsupported protocols, like mailto:, with external applications. I called it xproto. It uses the config file $HOME/dillo/protorc to decide what to do. The plugin will make a default one you can edit when it's first run. I'm working on the C version, but I'm just learning C, so it'll take me a bit. One thing I can't seem to figure out is how to send a url from the plugin to dillo and have dillo display that page. For example I would like the url gg:water to send dillo http://www.google.com/search?q=water For now I just have it open up another dillo. I tried sending <dpi cmd="open_url" url="http://www.google.com/search?q=water"> but that didn't work, booo. Again, xproto.filter.dpi is just a shell script, so play away. If you have any hints on the gg: thing let me know, please... The patch, against dillo-0.8.2: -------------------------------------- diff -pruN dillo-0.8.2/dpi/Makefile.am dillo-0.8.2-xproto/dpi/Makefile.am --- dillo-0.8.2/dpi/Makefile.am 2004-01-29 17:04:05.000000000 -0330 +++ dillo-0.8.2-xproto/dpi/Makefile.am 2004-10-31 09:51:39.000000000 -0330 @@ -5,11 +5,13 @@ downloadsdir = $(libdir)/dillo/dpi/downl ftpdir = $(libdir)/dillo/dpi/ftp httpsdir = $(libdir)/dillo/dpi/https hellodir = $(libdir)/dillo/dpi/hello +xprotodir = $(libdir)/dillo/dpi/xproto bookmarks_PROGRAMS = bookmarks.dpi downloads_PROGRAMS = downloads.dpi ftp_PROGRAMS = ftp.filter.dpi https_PROGRAMS = https.filter.dpi hello_PROGRAMS = hello.filter.dpi +xproto_PROGRAMS = xproto.filter.dpi bookmarks_dpi_LDADD = @GLIB_LIBS@ downloads_dpi_LDADD = @GLIB_LIBS@ diff -pruN dillo-0.8.2/dpi/Makefile.in dillo-0.8.2-xproto/dpi/Makefile.in --- dillo-0.8.2/dpi/Makefile.in 2004-07-06 14:31:24.000000000 -0230 +++ dillo-0.8.2-xproto/dpi/Makefile.in 2004-10-31 10:18:28.000000000 -0330 @@ -44,6 +44,7 @@ downloads_PROGRAMS = downloads.dpi$(EXEE ftp_PROGRAMS = ftp.filter.dpi$(EXEEXT) https_PROGRAMS = https.filter.dpi$(EXEEXT) hello_PROGRAMS = hello.filter.dpi$(EXEEXT) +xproto_PROGRAMS = xproto.filter.dpi$(EXEEXT) subdir = dpi DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -53,14 +54,15 @@ am__configure_deps = $(am__aclocal_m4_de mkinstalldirs = $(mkdir_p) CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(bookmarksdir)" "$(DESTDIR)$(downloadsdir)" "$(DESTDIR)$(ftpdir)" "$(DESTDIR)$(hellodir)" "$(DESTDIR)$(httpsdir)" +am__installdirs = "$(DESTDIR)$(bookmarksdir)" "$(DESTDIR)$(downloadsdir)" "$(DESTDIR)$(ftpdir)" "$(DESTDIR)$(xprotodir)" "$(DESTDIR)$(hellodir)" "$(DESTDIR)$(httpsdir)" bookmarksPROGRAMS_INSTALL = $(INSTALL_PROGRAM) downloadsPROGRAMS_INSTALL = $(INSTALL_PROGRAM) ftpPROGRAMS_INSTALL = $(INSTALL_PROGRAM) helloPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +xprotoPROGRAMS_INSTALL = $(INSTALL_PROGRAM) httpsPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bookmarks_PROGRAMS) $(downloads_PROGRAMS) $(ftp_PROGRAMS) \ - $(hello_PROGRAMS) $(https_PROGRAMS) + $(xproto_PROGRAMS) $(hello_PROGRAMS) $(https_PROGRAMS) am_bookmarks_dpi_OBJECTS = bookmarks.$(OBJEXT) bookmarks_dpi_OBJECTS = $(am_bookmarks_dpi_OBJECTS) bookmarks_dpi_DEPENDENCIES = @@ -81,7 +83,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/bookmarks.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/downloads.Po ./$(DEPDIR)/ftp.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/hello.Po ./$(DEPDIR)/https.Po +@AMDEP_TRUE@ ./$(DEPDIR)/hello.Po ./$(DEPDIR)/https.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) @@ -198,6 +200,7 @@ downloadsdir = $(libdir)/dillo/dpi/downl ftpdir = $(libdir)/dillo/dpi/ftp httpsdir = $(libdir)/dillo/dpi/https hellodir = $(libdir)/dillo/dpi/hello +xprotodir = $(libdir)/dillo/dpi/xproto bookmarks_dpi_LDADD = @GLIB_LIBS@ downloads_dpi_LDADD = @GLIB_LIBS@ ftp_filter_dpi_LDADD = @GLIB_LIBS@ @@ -333,6 +336,28 @@ uninstall-helloPROGRAMS: clean-helloPROGRAMS: -test -z "$(hello_PROGRAMS)" || rm -f $(hello_PROGRAMS) + +install-xprotoPROGRAMS: $(xproto_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(xprotodir)" || $(mkdir_p) "$(DESTDIR)$(xprotodir)" + @list='$(xproto_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(xprotoPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(xprotodir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(xprotoPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(xprotodir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-xprotoPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(xproto_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(xprotodir)/$$f'"; \ + rm -f "$(DESTDIR)$(xprotodir)/$$f"; \ + done + install-httpsPROGRAMS: $(https_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(httpsdir)" || $(mkdir_p) "$(DESTDIR)$(httpsdir)" @@ -480,7 +505,7 @@ check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: - for dir in "$(DESTDIR)$(bookmarksdir)" "$(DESTDIR)$(downloadsdir)" "$(DESTDIR)$(ftpdir)" "$(DESTDIR)$(hellodir)" "$(DESTDIR)$(httpsdir)"; do \ + for dir in "$(DESTDIR)$(bookmarksdir)" "$(DESTDIR)$(downloadsdir)" "$(DESTDIR)$(ftpdir)" "$(DESTDIR)$(xprotodir)" "$(DESTDIR)$(hellodir)" "$(DESTDIR)$(httpsdir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am @@ -530,7 +555,7 @@ info: info-am info-am: install-data-am: install-bookmarksPROGRAMS install-downloadsPROGRAMS \ - install-ftpPROGRAMS install-helloPROGRAMS \ + install-ftpPROGRAMS install-helloPROGRAMS install-xprotoPROGRAMS \ install-httpsPROGRAMS install-exec-am: @@ -560,7 +585,7 @@ ps-am: uninstall-am: uninstall-bookmarksPROGRAMS uninstall-downloadsPROGRAMS \ uninstall-ftpPROGRAMS uninstall-helloPROGRAMS \ - uninstall-httpsPROGRAMS uninstall-info-am + uninstall-httpsPROGRAMS uninstall-xprotoPROGRAMS uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean \ clean-bookmarksPROGRAMS clean-downloadsPROGRAMS \ @@ -570,14 +595,14 @@ uninstall-am: uninstall-bookmarksPROGRAM html-am info info-am install install-am \ install-bookmarksPROGRAMS install-data install-data-am \ install-downloadsPROGRAMS install-exec install-exec-am \ - install-ftpPROGRAMS install-helloPROGRAMS \ + install-ftpPROGRAMS install-xprotoPROGRAMS install-helloPROGRAMS \ install-httpsPROGRAMS install-info install-info-am install-man \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-bookmarksPROGRAMS \ uninstall-downloadsPROGRAMS uninstall-ftpPROGRAMS \ - uninstall-helloPROGRAMS uninstall-httpsPROGRAMS \ + uninstall-xprotoPROGRAMS uninstall-helloPROGRAMS uninstall-httpsPROGRAMS \ uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. diff -pruN dillo-0.8.2/dpi/xproto.filter.dpi dillo-0.8.2-xproto/dpi/xproto.filter.dpi --- dillo-0.8.2/dpi/xproto.filter.dpi 1969-12-31 20:30:00.000000000 -0330 +++ dillo-0.8.2-xproto/dpi/xproto.filter.dpi 2004-10-31 09:44:40.000000000 -0330 @@ -0,0 +1,64 @@ +#!/bin/bash +read -d'>' dpip_tag + +url=${dpip_tag##*url=\'} +url=${url%\'} +dproto=${url%%:*} +ddata=${url#*:} + +confdir="$HOME/.dillo" +if [ ! -d "$confdir" ]; then + if ! mkdir $confdir; then + msg="Error, could not make directory $confdir" + fi +else + conffile="$confdir/xprotorc" +fi + +if [ "$conffile" ]; then + if [ ! -e "$conffile" ]; then + echo " +# %d is replaced with just the data after the : +# %s is replaced with the full url +ed2k; ed2k.sh %s +mailto; sylpheed --compose %d +rtsp; realplay %s +gg; dillo http://www.google.com/search?q=%d" > $conffile + fi + if [ -e "$conffile" ]; then + while read line; do + line=${line%%#*} + fproto=${line%%;*} + if [ x"$fproto" = x"$dproto" ]; then + handler=${line#*;} + break + fi + done < $conffile + else + msg="Error, could not create file $conffile" + fi +fi + +if [ "$handler" ]; then + handler=${handler//\\%s/"$url"} + handler=${handler//\\%d/"$ddata"} + msg="Using: $handler" + output=$($handler &) +else + msg="No handler registered for protocol: $dproto +Please edit the config file: $conffile" +fi + +cat <<EOF +<dpi cmd="start_send_page" url="dpi:/xproto/xproto.filter.dpi"> +Content-type: text/html + +<html> +<head><title>Xproto Feedback</title></head> +<body> +<hr><h1>Xproto Feedback</hq><hr> +<pre>$msg</pre> +<h3>Command Output, If Any:</h3> +<pre>$output</pre> +</body></html> +EOF diff -pruN dillo-0.8.2/src/capi.c dillo-0.8.2-xproto/src/capi.c --- dillo-0.8.2/src/capi.c 2004-05-21 19:43:07.000000000 -0230 +++ dillo-0.8.2-xproto/src/capi.c 2004-10-31 06:03:28.000000000 -0330 @@ -247,6 +247,9 @@ gint a_Capi_url_uses_dpi(gchar *url_str, } else if (g_strncasecmp(url_str, "https:/", 7) == 0) { server = g_strdup("https"); + + } else { + server = g_strdup("xproto"); } return ((*server_ptr = server) ? 1 : 0); diff -pruN dillo-0.8.2/src/IO/Url.c dillo-0.8.2-xproto/src/IO/Url.c --- dillo-0.8.2/src/IO/Url.c 2004-05-21 19:43:29.000000000 -0230 +++ dillo-0.8.2-xproto/src/IO/Url.c 2004-10-31 06:19:57.000000000 -0330 @@ -108,6 +108,6 @@ ChainFunction_t a_Url_get_ccc_funct(cons if ( j == KeyLen ) return cccList[i].cccFunction; } - return NULL; + return a_Dpi_ccc; } -- Lee Bigelow Blatch Enterprises <ligelowbee@yahoo.com>
On Sun, Oct 31, 2004 at 10:41:14AM -0330, Lee Bigelow wrote:
Hello again,
Hi!
I did up a proto-type bash shell dpi for handling unsupported protocols, like mailto:, with external applications. I called it xproto.
It uses the config file $HOME/dillo/protorc to decide what to do. The plugin will make a default one you can edit when it's first run.
I'm working on the C version, but I'm just learning C, so it'll take me a bit.
Good you made a prototype. Dpi isn't that hard to program and I hope your code will encourage more developers to try it.
One thing I can't seem to figure out is how to send a url from the plugin to dillo and have dillo display that page. For example I would like the url gg:water to send dillo http://www.google.com/search?q=water For now I just have it open up another dillo. I tried sending <dpi cmd="open_url" url="http://www.google.com/search?q=water"> but that didn't work, booo.
Try the small patch below. It's a no frills version to keep you going on... Beware that there's a safety test in the function: Capi_verify_dpi_url_request() (Safety test: only allow dpi-urls from dpi-generated pages.) To avoid the "permission denied" message, while testing the patch, I asked for bookmarks (dpi generated page) and then the hello dpi (that was modified to send 'open_url'). If this is too much trouble, just disable the safety test! :-)
Again, xproto.filter.dpi is just a shell script, so play away. If you have any hints on the gg: thing let me know, please...
Please post the next prototype as an URL. If you don't have access to a web server please ask Jörgen to put it on our downloads directory. Sometime ago someone asked about how to make a slide show with dpi. Another thing to have in mind is how to tell a running Dillo to display another URL (for instance for sylpheed, or slides, or help manual apps.). Please try the small patch. That's the basis, details need to be thought better. ... & tell us how it works for you! -- Cheers Jorge.-
participants (2)
-
Jorge Arellano Cid
-
Lee Bigelow