Re: how to externally trigger konq-e to refresh view
Uli Luckas <[email protected]> Wed, 23 Sep 2009 18:02:09 +0200
| Newsgroups | gmane.comp.kde.devel.konq-e |
|---|---|
| Organization | Road GmbH |
| Message-ID | <[email protected]> |
On Wednesday, 23. September 2009, Stefan Strobl wrote: > Hi Uli > > thanks for your prompt answer. > > Uli Luckas wrote: > > On Wednesday, 23. September 2009, Stefan Strobl wrote: > >> What I would like to do is to somehow tell konq-e from another > >> application XY to reload its current URL. This is of use if application > >> XY generates and stors a html page locally and wants konqueror to > >> display/reload it. > >> > >> Now, this is how I tried to do it and the problems I ran into: > >> I thought I use the Unix system signal SIGUSR2 to do the signaling. In > >> the file view.cc in the BrowserView constructor I'm registering my > >> "protected: static void sigusr2_handler()" function for SIGUSR2 which is > >> generally working so far. From this handler I thought of calling the > >> public slot function reload() which is _not_ working because I cannot > >> call this non-static function reload() from my static function > >> sigusr2_handler(). From sigusr2_handler() I also cannot access "HTMLView > >> *m_doc" for the same reason. On the other hand I cannot make > >> sigusr2_handler() non-static because sigaction() would complain about > >> that. I'm lost here. Why can't I access the data even though I'm in the > >> same class? > >> > >> Any ideas what I'm doing wrong? Or maybe ideas about a better approach > >> to make my application XY cause konq-e to reload its page? > > > > Hi Stefan, > > there are a few problems here. > > First and most important, there are strict semantics of what is allowed > > to be done inside a signal handler. Keep in mind, that the signal handler > > could have interupted the main flow of code at any point and must make > > sure not to cause any unexpected modifications to the environment of the > > interrupted code. Please take a look at any unix book and what it tells > > you about signals. > > > > Second, non static methods need an object (an instance of the class) to > > operate on, static methods, also called "class methods", can be called on > > the class itself. Please take a look at any C++ book and what it tells > > you about classes and objects and the difference thereof. > > > > Qt/Embedded has a mechanism called qcop for inter process communication: > > http://doc.trolltech.com/3.3/qcopchannel.html > > You can extend konq-e to listen for a qcop message which could then > > trigger a reload. > > I now understand that I need an Object to access reload() from a static > function. I also understand that SIGUSR2 is asynchronous and may > interrupt the process at the wrong time. > > The other thing is that my application doing the signalling is not a > graphical QT application but a C program. Do you think using a Unix FIFO > could be an alternative or is it better to make my application XY a QT > application to be able to use QCopChannel? > Please keep the list CCed. If you don't want to make your programm a qapplication, you could also send qcop messages by calling the qcop command line application via ::system(). As you sugested you can also use a FIFO or a socket for communication. In the browser, just make sure to use the event loop (QSocket/QSocketNotifier) for asynchronus notification on fifo events. Regards, Uli -- ------- ROAD ...the handyPC Company - - - ) ) ) Uli Luckas Head of Software Development ROAD GmbH Bennigsenstr. 14 | 12159 Berlin | Germany fon: +49 (30) 230069 - 62 | fax: +49 (30) 230069 - 69 url: www.road.de Amtsgericht Charlottenburg: HRB 96688 B Managing director: Hans-Peter Constien