kioslave implementation help

3 views
Skip to first unread message

fluc...@infinito.it

unread,
Mar 14, 2012, 5:59:44 AM3/14/12
to kde-...@kde.org
Hi all,
I'm trying to implement a simple kioslave, but I don't understand well the lifecycle and therefore how the slave should behave.
If I get it right, the get() method is called each time a specific URL must be retrieved (e.g., a local file), while listDir and stat each time a folder content must be shown. Now, what I'd like to make into my slave is that when the root URL is called, a list of virtual folder is shown. Therefore I placed my simple implementation of listDir and stat as follows:

void RoleFS::listDir( const KUrl& url ){
  KIO::UDSEntry dirEntry;
  dirEntry.insert( KIO::UDSEntry::UDS_NAME, "TEST" );
  dirEntry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
 
  // emit a signal to list this entry
  listEntry( dirEntry, true );
  totalSize(1);
  finished();

}


void RoleFS::stat(const KUrl& url)
{
    KIO::UDSEntry dirEntry;
    dirEntry.insert( KIO::UDSEntry::UDS_NAME, "TEST" );
    dirEntry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
    statEntry( dirEntry );
    finished();
}


However I don't undestand how to force konqueror to list dirs when the root URL is placed into the address bar (e.g., rolefs:///), since the get method is the only one called. I've had a look at the audiocd slave implementation, that is similar to mine, but I don't understand how to instrument the get() method to force a directory listing instead of a single data retrieval. Can anybody point me to the solution?

Thanks,
Luca

Albert Astals Cid

unread,
Mar 17, 2012, 12:06:31 PM3/17/12
to kde-...@kde.org, fluc...@infinito.it
El Dimecres, 14 de març de 2012, a les 10:59:44, fluc...@infinito.it va
escriure:
> Hi all,

Hi

>
> I'm trying to implement a simple kioslave, but I don't understand well the
> lifecycle and therefore how the slave should behave.
>
> If I get it right, the get() method is called each time a specific URL must
> be retrieved (e.g., a local file), while listDir and stat each time a folder
> content must be shown. Now, what I'd like to make into my slave is that
> when the root URL is called, a list of virtual folder is shown. Therefore I
> placed my simple implementation of listDir and stat as follows:
>

> code snip

>
> However I don't undestand how to force konqueror to list dirs when the root
> URL is placed into the address bar (e.g., rolefs:///), since the get method
> is the only one called. I've had a look at the audiocd slave implementation,
> that is similar to mine, but I don't understand how to instrument the get()
> method to force a directory listing instead of a single data retrieval. Can
> anybody point me to the solution?

Do you have the listing entry in your .protocol file?

Albert

>
>
> Thanks,
>
> Luca

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

fluc...@infinito.it

unread,
Mar 22, 2012, 12:38:52 PM3/22/12
to Albert Astals Cid, kde-...@kde.org

> Do you have the listing entry in your .protocol file?

The following is my protocol file:

[Protocol]
DocPath=kioslave/kio_rolefs.html
exec=kio_rolefs
input=none
output=filesystem
protocol=rolefs
reading=true
Icon=folder
listing=Name,Type

so I guess the listing entry is right. I've tried to change the list method
to force emitting the folders (that I have saved into a QList):

void RoleFS::listDir( const KUrl& url ){

kDebug(7000) << "[Entering RoleFS::listDir] URL = " <<
url.toMimeDataString();

for( int i = 0; i < rootFolders.size(); i++ ){
KIO::UDSEntry& dirEntry = *(rootFolders.at( i ));


// emit a signal to list this entry
listEntry( dirEntry, true );
}

//totalSize( rootFolders.size() );
data( QByteArray() );
finished();
kDebug(7000) << "[Exiting RoleFS::listDir]";
}

However this still does not work. My get method is almost empty:

void RoleFS::get( const KUrl &url ){
kDebug(7000) << "[Entering RoleFS::get] URL = " <<
url.toMimeDataString();

finished(); // success


kDebug(7000) << "[Exiting RoleFS::get]";
}

Am I doing something wrong?

Albert Astals Cid

unread,
Mar 22, 2012, 6:42:48 PM3/22/12
to kde-...@kde.org, fluc...@infinito.it
El Dijous, 22 de març de 2012, a les 17:38:52, fluc...@infinito.it va
escriure:

Without looking at the code, don't know. But no, don't send me the code, you
said yourself that you wanted to do something similar to what audiocd:/ does,
so get the code of audiocd and start stripping it down and modifying it until
it does what you want. And then you'll find the difference with yours.

Cheers,
Albert

Reply all
Reply to author
Forward
0 new messages