Hi, I just made a patch to add remote control for Dillo. 1. Summary: 1.1 Why? To be able to command Dillo from another process. E.g.: if Dillo is used as a help doc browser of a program, the program can implement context sensitive help and associate to each widget a help URL. The same Dillo instance can then be used to show the differents help docs. Other example, which also was the motivation of this patch: Sylpheed-Claws uses Dillo to render HTML mail, but currently it has to run a new instance each time the user views an HTML mail. Having only one instance is more efficient and improve responsiveness. 1.2. HowTo To be remote controlled, a Dillo instance must be explicitly started with a special command line option (-s, --server NAME), e.g.: dillo -s server A client instance sends commands to this server by referencing it and by using the -c, --command options, e.g.: a. dillo -s server -c "open(http://www.google.com)" -c "new-window(www.av.com)" b. dillo -s server http://www.google.com amounts to: dillo -s server -c "new-window(http://www.google.com)" Hence, running dillo -s server -c "open(URL)" mutliple times will launch only one instance of dillo at the first time, and the subsequent calls will just hand the arguments to the server. This is more practical than Mozilla's current behaviour where the user has to use two different commands to start and to control a server. The list of currently known commands is provided by the -H, --help-commands option: dillo -H Commands that can be used with the -c, --command option: open(URL) Open URL in current window. new-window(URL) Open URL in a new window. Exit() Terminate browsing session and exit. Command names are case insensitive. It is allowed to have more than one command option. New commands can be added, the syntax being: command(.*) 2. Ressources In dillorc: server_socket_path by default, it is "/tmp". It is used to create the socket name which is: $server_socket_path/dillo-$USER-$NAME. where $NAME is the server name from the -s, --server NAME option. E.g.: /tmp/dillo-john-help 3. Caveat If gtk specific command lines arguments are given, arguments are messed around, due to the fact that the patch delays gtk_init() after private arguments parsing, This will be fixed in the next version If a Dillo server does not quit cleanly, the socket corresponding to the server is not removed. Subsequent attempts to run a server with the same name will fail until the socket is removed (by default: /tmp/dillo-$USER-$SERVER_NAME). A solution is currently searched. The -c "exit()" works only when used from the client side The -c commands are currently ignored if no -s option is given. Any comments are welcome. Especially use cases for the remote control. 4. Details 4.1. Becoming a server Communication between server and client is done via UNIX domain socket. The advantage between this and FIFO being that a separate connection is made for each client, so communcation are guaranteed to not mixup. FIFO, on the other hand, can mixup communication of multiple clients if the messages are larger than some value (PIPE_BUF). This patch uses dynamic allocation for the messages received by the server. When the -s, --server NAME option is given, dillo checks wether a socket correspondig to that name is available and responding. If yes, it will hand any -c, --command CMD and any URL|FILE it finds in its command line options to that running server. URL|FILE are interpreted as "-c new-window(URL|FILE)". If no server socket is responding, it turns it self into a server by creating that socket. After that, it handles the -c, --command CMD and the URL|FILE options itself. 4.2. GUI initialisation The gtk_init() function is now called after dillo options parsing to speed up client execution. Indeed, a client instance does not need to initialise the GUI. This introduces the problem of messed up args if gtk args are given. This could affect the URL|FILE arguments. A solution would be to save them in a separate list for later processing. Another solution would be to interprete the URL|FILE arguments as -c open(URL|FILE) at an early stage. This will also help fixing the problem of the -c commands being ignored if no -s option is given. 4.3. Commands Commands are simple of the form: command(arg..). Arguments are parsed by the shell, so the user must take care that the command is interpreted as a single argument by the shell. Arguments should not contain unescaped parenthesis or spaces. Therefore, the following example is incorrect: dillo -s server -c open(file:///home/user/My documents) because: 1. the shell interprets the parenthesis, and 2. there is a space in the argument. This should be escaped in the following manner by using quotes: dillo -s server -c "open(file:///home/user/My documents)" It is easy to add new commands. -- Melvin Hadasht
On Sun, Aug 10, 2003 at 12:39:48AM +0200, Melvin Hadasht wrote:
Hi,
I just made a patch to add remote control for Dillo.
Terrific! Here are some comments for discussion. Take them with a grain of salt: - I'd prefer case sensitivity (the unixy environment is case sensitive, URIs are -- at least in part :-/ You know, principle of least surprise and that. - Implementation. Why not implement this as a wrapper which talks to the dpid? It would start Dillo if not already running. The advantages I see are: - the wrapper could clean up any mess Dillo might leave behind on a crash. This is one of the open issues you mention. (OK, Dillo doesn't crash, does it? but a simple wrapper is less complex and thus less likely to crash). - You could re-use the existing communication mechanism for dpi1, I think (I haven't looked deeply into this yet, though). The main disadvantage would be, of course, that you have to start dillo-wrapper instead of dillo, but may be we can convince folks in the list that this ie a Good Thing anyway (it would solve elegantly the `single dpid instance' issue, since it could look whether dpid is running before starting dillo). What do people think? Regards -- tomas
Hi Tomas, You wrote:
Here are some comments for discussion. Take them with a grain of salt:
- I'd prefer case sensitivity (the unixy environment is case sensitive, URIs are -- at least in part :-/ You know, principle of least surprise and that.
At first, I planned to implement mozilla-like options (which are documented as OpenURL but they are case insensitive: openurl works, too). Unix people are used to case sensitiveness, so I could switch to that, especially that there is no port to MSWindows or other case insensitive platform, yet (I have a doubt concerning VMS, though).
- Implementation. Why not implement this as a wrapper which talks to the dpid? It would start Dillo if not already running.
The advantages I see are:
- the wrapper could clean up any mess Dillo might leave behind on a crash. This is one of the open issues you mention. (OK, Dillo doesn't crash, does it? but a simple wrapper is less complex and thus less likely to crash).
nedit comes with a small "nc" nedit-client that does something similar: if no server exist, it forks one. So you can live with just the "nc" command. I'll read more about the dpi stuff and will think about how it could be used. Thanks for your comments! -- Melvin Hadasht
Melvin,
Hi,
I just made a patch to add remote control for Dillo.
1. Summary:
1.1 Why?
To be able to command Dillo from another process. E.g.: if Dillo is used as a help doc browser of a program, the program can implement context sensitive help and associate to each widget a help URL. The same Dillo instance can then be used to show the differents help docs. Other example, which also was the motivation of this patch: Sylpheed-Claws uses Dillo to render HTML mail, but currently it has to run a new instance each time the user views an HTML mail. Having only one instance is more efficient and improve responsiveness.
I agree.
1.2. HowTo [...]
I think this will be better handled with a dpi. It solves several problems and also add flexibility (you accurately mention some of them in:
3. Caveat [...]
So please give a study to the framework, isolate the needed commands (mostly done it seems) and I'll answer when time allows me. Sorry for the short answer. :( Best Jorge.-
Hi Jorge,
1.2. HowTo [...]
I think this will be better handled with a dpi. It solves several problems and also add flexibility (you accurately mention some of them in:
Yes, I already started to read the dpi/dpid docs and sources. As Tomas already suggested, PI infrastructure can be handy, at least on the server side. For a moment; I was even thinking about using Dillo itself as a plugin.
3. Caveat [...]
So please give a study to the framework, isolate the needed commands (mostly done it seems) and I'll answer when time allows me.
Sorry for the short answer. :(
Thanks for your comments. -- Melvin Hadasht
participants (3)
-
Jorge Arellano Cid
-
Melvin Hadasht
-
tomas@fabula.de