Registered Member
|
Hi all,
I'm trying to implement a kioslave and I've got a doubt about its design: for almost every operation I have to check the incoming URL to see if it is a special one, otherwise I have to rewrite it and manage as a local filesystem URL. Therefore in my copy method, for instance, I've got something like:
Now, what is the recommended way to achieve this? Should I inherit also from the file slave and call super when required an action of the file slave or should I forward the call to the file slave (and I don't know exactly how to do that)? Can anybody give me an hint? |
KDE Developer
|
You can't inherit from kio_file, it's a plugin, not a public shared library. However you should use ForwardingSlaveBase, for easy "forwarding to the file slave". I'm surprised by the statement that you need to check incoming URLs in all methods. get(), put(), listDir(), and many other basic methods will only ever be called with URLs of your own protocol. copy() however is a special case, it's an optional optimization for copying from local files to your-own-protocol, or for copying from your-own-protocol to local files, or both, depending on the flags you set in the .protocol file. So yes, in that method you need to check which protocols the URLs use. But only in that method. |
Registered Member
|
Thanks, can you please point to some piece of code and/or other slaves that use ForwardingSlaveBase, so that I can use it as an example?
You are right, the URLs are always related to my protocol, of course. However I'm implementing a slave that is going to present to the user some virtual information along with some real (i.e., coming from the local filesystem) information. Therefore I could have an URL that points to a virtual folder, and so I need to display only virtual content, or to a real folder, and therefore I have to display real content from the local filesystem. That is why I cannot simply forward a whole URL but I have to check it to understand which content has to be presented to the user. If you have any suggestion about how to solve or can spend some time discussing with me the architecture of this slave I will be very happy! Thanks |
KDE Developer
|
Look for ForwardingSlaveBase on http://lxr.kde.org.
> I have to check it to understand which content has to be presented to the user. Well, yes, obviously, by design You'll see that most ForwardingSlaveBase-based ioslaves do pretty much the same. |
Registered Member
|
Thanks, I'm having a look at the recent documents implementation http://lxr.kde.org/source/kde/kde-runtime/kioslave/recentdocuments/recentdocuments.cpp#42, if you think there is a better one to study on please advice. |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft