Intergrating mht file to konqueror

David Faure faure at kde.org
Thu Nov 4 19:29:41 GMT 2004


On Thursday 04 November 2004 20:08, Spiros Georgaras wrote:
> David Faure wrote:
> > Ah yeah I'm still behind with that.
> > How about adding support for X-KDE-LocalProtocol instead? Query the
> > mimetype for it, and if it's set, redirect to <protocol>://path.
> 
> Sorry David I don't understand what you mean.... :(
> Where does X-KDE-LocalProtocol refer to?
> Do you mean to change the mht.protocol file?
> 
> I see in konq_mainwindow.cc file:
>   //////////// Tar/zip files support
>   // The hack-ish and hardcoded way.
>   // Possible cleaner solution: 2 properties in the mimetype definition,
>   // e.g. X-Konq-Redirect-URL set to tar:%f/
>   //  and X-Konq-Redirect-Mimetype set to inode/directory
> 
> This is something different right?
It was the initial idea long ago, but after discussion with Jowenn he added
X-KDE-LocalProtocol to the mimetypes instead.

For instance the mimetype application/x-tar has a property X-KDE-LocalProtocol
set to "tar" (see kdelibs/mimetypes/application/x-tar.desktop)

So the konq_mainwindow code would be like 

if ( url.isLocalFile() )
{
  KServiceType::Ptr ptr = KServiceType::serviceType( serviceType );
  if ( ptr ) 
  {
     const QString protocol = ptr->property("X-KDE-LocalProtocol").toString();
     if ( !protocol.isEmpty() )
     {
         url.setProtocol( protocol );
         url.setPath( url.path() + '/' );        // TODO: for *.war files we want "/index.html". New property?
         serviceType = "inode/directory"; // would be text/html for *.war files...
     }
   }
}

Please test, it should work :)
Don't forget to add this to your mimetype .desktop file:

[Property::X-KDE-LocalProtocol]
Type=QString
Value=mht

Hmm, it looks like x-zip.desktop is missing it...

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kfm-devel mailing list