[PATCH]: commands & auto-reload (was Re: dillo / time-controlled reloads)
[Henning, you may be interested: the patch implements a --reload option] Hi, To implement the server and remote commands feature in Dillo, I'm going to go step by step. First, I'll implement commands to control Dillo at startup time, then I'll implement the server mode (where a Dillo instance can send the aforementioned commands to another Dillo instance). This is because I may try two differents approaches for the server mode part and because the commands are just a generalization of the command line options and can be implemented separately. Here is my first step: implement commands (like -c "open(URL)"). Patch is attached and is against CVS version. This is a generalization of the command line interface, and in fact, most of the old command line options are translated to a Dillo -c command. The advantage of such approach is that the commands can take optional parameters, like in: dillo -c "open(URL newwindow reload=10 fullwindow=yes)" which is approximately equivalent to: dillo -f -r 10 URL The commands are passed to Dillo as arguments to the -c, --command command line option: dillo -c "open(http://www.google.com)" 1. Command Syntax The argument to the -c command line option is of the form: CMD([STRING][ PARAM=VALUE]...) CMD: command name STRING: first and generic argument: in general a URL or yes|no PARAM: name of optional parameter VALUE: value of optional parameter. Currently, only booleans (yes|no) and integer values are supported. Boolean value can be omitted, in which case the value is considered to be "yes". Integer value cannot be omitted. Parameters are separated with a single space (no commas, to simplify the parser) Commands can be divided into two groups: actions commands, and options commands 2. Action Commands: They do some action: currently implemented commands: open(URL [ fullwindow[=yes|no]] [ reload=SECONDS] [ spamsafe[=yes|no]] [ xid=XID]) parameters speak for themselves. The "reload" parameter is a new feature: it allows to reload the URL each SECONDS seconds. The reload is halted when the page is not viewed and restarted if the user comes back to it. exit() exit the instance. This will be useful when passed to another Dillo instance running as a server. Other commands can be added. The framework is quite flexible and extensible. 3. Options Commands These commands set some options that will affect the following commands. For example, the parameters used in the open() command act only on that particular URL. But it can be useful to be able to set some defaults values. The currently implemented commands that influence these defaults are: fullwindow([yes|no]) reload(SECONDS) spamsafe([yes|no]) xid(XID) all open() commands that come after these options commands will have these default values, unless explicitly overridden. 4. Examples: dillo -c "open(http://www.google.com)" -c "open(file:///home/mhadasht/test.html newwindow spamsafe)" will open two windows: the first with google, and the second with the local file opened in spamsafe mode. dillo -c "reload(10)" -c "open(http://www.freshmeat.net)" -c "open(http://news.google.com newwindow)" will open 2 windows and will reload both URLs each 10s. This is equivalent to: dillo --reload 10 http://www.freshmeat.net http://news.google.com 5. Implementation details: 5.1. Command Line Parsing Command line options other than the help/version options are translated into a -c command and stored in a list. The list of commands is then executed (or, when the server mode will is implemented, sent to another Dillo instance) 5.2. Reload Function a URL can be set to auto-reload itself if it is currently viewed. For that, a new member (reload_interval [milliseconds]) to DilloUrl is added and set with a_Url_set_reload(). Each BrowserWindow can trigger a timer function if the viewed URL (Nav_open_url()) has a non-zero reload_interval. (As soon as another URL is viewed, or when the BrowserWindow is destroyed, the eventually pending timeout function is removed.) The timer is of the one-shot type: when it is triggered, it requests its BrowserWindow to reload the URL, then it stops itself. There is currently no UI to start/stop an auto-reload of a URL, but it is just a matter of using a_Url_set_reload() to a non-zero or a zero reload interval. 6. Remark The -c command and the normal command line options can be seen as two ways of doing the same thing: passing commands to Dillo. But the -c command is more generic and flexible and has a more powerful syntax. 7. Future Plans I plan to implement the server mode. After reading the dpi doc and source, I found that it cannot be used to make Dillo act as a plugin unless we accept to have only one Dillo server. This is because the socket names are tightly linked to the service name. Each service has only one socket. Whereas Dillo servers must have a distinct socket. If the we add another argument to the "start_plugin" cmd: <dpi cmd="start_plugin" msg="dillo" param="SERVER_NAME"> and if we modify the socket naming scheme, then it could be possible. I have to think about that again. But I may still use the communication infrastructure of the dpi. If I find this overkill, I'll revert to the straightforward approach I used before, that is, I won't use the dpi framework. OK, it's late, I hope I managed to be somewhat clear... Cheers. -- Melvin Hadasht
Sorry, it looks the attachment was truncated. Here it is again, gzipped.
On Fri, Aug 22, 2003 at 11:30:47PM +0200, Melvin Hadasht wrote:
[Henning, you may be interested: the patch implements a --reload option]
guys, you rock. it's just two days ago that I asked for that. It works great on OpenBSD/i386 and OpenBSD/sparc, all OpenBSD -current (3.4-beta atm). there are two small problems: -if you specify a small reload time, and by that time is over before the page is actually loaded -> coredump -on sparc, using the "void" input drivers for keyboard and mouse -> coredump that must be the visibility check? both issues are unfortunaltely pretty much showstoppers in my application :-((
there are two small problems: -if you specify a small reload time, and by that time is over before the page is actually loaded -> coredump
Does not core dump for me. Where does it core dump? I tried "dillo -r 1 http://freshmeat.net" and it reloads the page before it is finished loading. Or by "actually loaded" you mean "did not *start* to load" ?
On Fri, Aug 22, 2003 at 11:30:47PM +0200, Melvin Hadasht wrote:
[Henning, you may be interested: the patch implements a --reload option]
hmm, I have one more issue. dillo caches the images too well. try looking at any mrtg-generated page. the mrtg graphs are usually rebuilt every N minutes, where N=5 in my case. tho, now, at 3:20h, it still shows the images from ~ 1:30h. old data is not relevant in this case :-(
Hi, I previously posted a "command" patch as a preliminary for the server mode patch for Dillo. It was about handling the list of commands to be sent to the server. The hereby attached patch already contains that patch slightly modified and adds the ability to eventually switch to server mode or to connect and send the commands to a server This patch does not solve the "reload" bugs. I have a web page (user oriented) at: http://melvin.hadasht.free.fr/home/dillo/server/index.html I finally chose the "straightforward" approach instead of the dpid approach. Two reasons for that: i) I felt it'd introduce more complexity, especially for a client instance that needs to connect to a server and ii) the current dpid allows only one socket per service while it would be needed to have more than one Dillo server. I already explained in another mail that the socket name would need to be parametrized (by the server name, for example). Of course, this patch of mine is just a suggestion, if others feels that the dpid approach is better and more efficient, I'd be happy to see how they implemented it. The "commands" patch could still be used. They just need to handle the server/client connection. The hereby attached patch has the following characteristics: - gtk_init() is never called by a client instance - if the XID option is given, and if the server already has an embedded window with that XID, it will reuse it. - an application can still directly access to the server socket and can keep the connection open until it really does not need it. It has to check whether /tmp/dillo-$USER-$SERVERNAME exists. If not, it should launch "dillo -s $SERVERNAME". Then it should open that Unix Domain Socket. Then it just need to send commands to it, the syntax of the commands being that of the -c options. The commands that are to be sent through the socket must be of the following format: ([COMMAND][NUL])*[CRLF] That is, each COMMAND string must be followed by the terminal NUL byte. The list of commands are buffered by the server command until a [CRLF] ("\r\n" without the terminal \NUL) is sent or until the socket is closed. Then, the list of buffered commands are executed. I'll provide a simple library that could be used by an application to directly use the socket, but for the moment, the most easy and straighforward approach is to set the browser command line to "dillo -s SERVERNAME URL". On a PII266Mhz, starting a dillo client with a single open() command needs only ~0.04 seconds (if gtk_init() were executed before command line parsing and thus if each dillo client had to init the display, it would have needed more than 0.1 seconds). My next plans are to provide a simple library to connect (and eventually start) a server and to sent it commands. Then I will try to fix the "reload" bug when the reload time is too short. -- Melvin Hadasht
participants (2)
-
Henning Brauer
-
Melvin Hadasht