Trash kded module

David Faure faure at
Wed Aug 19 19:10:32 BST 2009

On Wednesday 12 August 2009, Sebastian TrĂ¼g wrote:
> In the trash kio slave's trashimpl.h David writes that it could be
> converted into a kded module.

Yeah, the idea was to prevent races when multiple kioslaves do concurrent 
operations. In practice it doesn't seem to be a big deal (except that now we 
have a size cache so concurrency becomes a bit more of a problem). However 
Tobias Koenig and I came up with the idea of inter-process locking (using 
DBUS) instead of a kded module. Well, Tobias' current implementation of that 
locking is a kded module, but Thiago had a better idea, simply using the dbus 
service-name registration mechanism as a locking mechanism.

In conclusion, this kind of removes the need for a trash kded module.

In any case, if there had been one, it would have been an implementation 
detail, with internal API, not with public API. KIO has the public API for 
handling the trash (moving files into it, out of it, etc.), I don't see the 
point in two public APIs for the same thing. (But I agree, trashPaths() isn't 
provided anywhere right now, more on that below).

> The Nepomuk search kio slave does also return results from the trash and I
> need a way to filter them. One way would be to check the path and see if
> they are children of one of the trash paths.

I'm not sure what you mean. You want to look into trash:/ URLs, or you want
to exclude ~/.local/share/Trash local files from nepomuk searches?

> So it means that I would have to copy code from trashimpl or rely on a new
> kded module to answer the question for me.
> /// @returns the new path of the file
> QString moveToTrash(QString path)

KIO::move(path, "trash:/") does the same.

> bool restoreFromLocalPath( QString localPath );
> bool restoreFromTrashPath( QString path );

KIO::move(trash url, localpath)?
or ktrash --restore trashurl, which in kio terms is a bit more convoluted 

> bool restoreFromTrashName( QString name );
Hmm? name?

> /// @return all trash folders in the system including removable storages
> QStringList allTrashFolders();

OK that's the one you really need I guess. 
If you and kio_trash are the only two users for this, I don't really feel like
moving it to kdelibs, or indeed making a kded module just for it.... How about
a KIO::special job that would return this information out of kio_trash?

> /// @return the trash folders for the storage with solid id @p uuid
> QStringList trashFoldersForStorage( QString uuid );

Is it needed if you have allTrashFolders()?

> void emptyTrash();

`ktrash --empty` or its implementation (KIO::special), in code.

David Faure, faure at, sponsored by Qt Software @ Nokia to work on KDE,
Konqueror (, and KOffice (

More information about the kde-core-devel mailing list