Should CMD_MIMETYPE methods emit mimeType()?

David Faure faure at
Sat Sep 20 00:58:41 BST 2008

On Sunday 27 July 2008, Vlad wrote:

Wow, time flies...

> Am I correct to assume that the KIO slave methods called as a result of CMD_MIMETYPE (ie. sftpProtocol::mimetype(), Ftp::mimetype(), etc) should do an "emit mimeType()"? 

Yes. The docs for mimeType() say so.
("emit" isn't fully correct, it's not a signal, but doesn't matter, I see what you mean conceptually ;)
It's the whole point of that method.

Note, however, that mimetype() doesn't _have_ to be implemented by the slave;
if not implemented, a get will be issued, as it says in the apidox. This is what happens
for kio_file for instance. Hmm. We should probably implement it to avoid sending the whole data.

> Right now, sftpProtocol::mimetype() and Ftp::mimetype() don't do that, so I suspect they are broken. 

They are broken indeed, if they implement that method without calling mimeType in it.

> In fact, Ftp::mimetype() for sure doesn't work because it is #if 0'ed.

That's no problem, the default implementation is used instead.

> It seems that sftpProtocol::mimetype() and Ftp::mimetype() call data() instead of "emit mimeType()"
> and an 8-year-old comment in Ftp::mimetype() mentions KMimeMagic. Is calling data() and relying on KMimeMagic outdated? 

Yes, I don't see code doing this in the job. I think this comment makes no sense anymore.

> PS: The File KIO slave doesn't even have a FileProtocol::mimetype(), and nobody seems to miss it. 

Correct. See above and the default implementation in SlaveBase.

> Perhaps CMD_MIMETYPE isn't used at all

It is used by the KIO::mimetype() job. Indeed, this isn't widely used (it's not used by KRun anymore,
for which it was initially written), but it is used by code that wants to do a HTTP HEAD
playground/libs/webkitkde/kdenetwork/knetworkaccessmanager.cpp (for http head)
kdenetwork/kopete/protocols/yahoo/libkyahoo/receivefiletask.cpp (for http head)
playground/base/nepomuk-kde/linkwidget/linkwidget.cpp (seems to be the only real use of "I want the mimetype")

Ah. It's also used via NetAccess.
OK, that's a valid number of use cases, it's not completely useless ;)

Overall, I don't think it's a big problem if the mimetype method isn't implemented in the slaves.

David Faure, faure at, sponsored by Trolltech to work on KDE,
Konqueror (, and KOffice (

More information about the kde-core-devel mailing list