MMB opens in new tab

David Faure david at mandrakesoft.com
Mon Jul 15 18:10:40 BST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 15 July 2002 18:43, Doug Hanley wrote:
> On Monday 15 July 2002 04:01 am, David Faure wrote:
> > On Sunday 14 July 2002 18:22, Doug Hanley wrote:
> > >   KMimeType::Ptr mimeType = KMimeType::findByURL( url );
> >
> > Ouch. That's not good at all.
> > This function doesn't give reliable results, in particular over HTTP.
> > You work around that by assuming HTML, but there is more than HTML that
> > one can get over HTTP. Think images, for instance.
> 
> From what I've seen that function always returns application/octet-stream over 
> http, even for images, but I'd imagine that there are still times when it can 
> mess up, so I guess its not a good idea to use it.
There are other protocols than HTTP, who also have unreliable mimetypes - e.g. FTP
(by unreliable I mean: you can't find out the mimetype before you start downloading
the file)

> Also, in the case of 
> images, the htmlpart is only there in the beginning, it is replaced by an 
> image viewing part when KonqRun is called.
That's still a useless part creation that could/should be avoided.

> > Hmm, ok, I see you use a KonqRun if the mimetype was unknown, but....
> > the danger of the code that was posted here is more precisely in case
> > findByURL does a wrong assumption (as it does on some protocols).
> >
> > Why does addTab need to know the mimetype? Can't it create an empty
> > tab, and let openView (directly via openURL, or via KonqRun), take care
> > of creating the right part into it?
> 
> Well, as it is right now, add tab needs to have a mimetype so it can create a 
> part for the view.  Just looking at the KonqView constrution code, it doesn't 
> seem to be possible to create a KonqView without a part.  And all these 
> functions: openURL, openView, and KonqRun::KonqRun, require that a view 
> already exists for them to work on.

No, openURL creates a view if the view parameter is 0L.

The point is that:
* openURL might or might not know the mimetype. If it does, it calls openView.
If it doesn't, it creates a KonqRun which will call openView later too.
* openView *ALWAYS* knows the mimetype. It's been found out before, see above ;)

So it's fine if add tab needs to have the mimetype. Simply calls it from openView.

> All I can say is that I've been using this for 2 days or so, and it has worked 
> flawlessly for me.
But did you test all the existing kioslaves out there? ;)

> Also, looking at this snippet of code from 
> KMimeType::findByURL, it seems as though almost all non-local files would be 
> shown as application/octet-stream.

No, it really depends on the "default mimetype" of the protocol (which is a hack
in itself anyway. Konqueror needs to know better than that).

>       QString def = KProtocolInfo::defaultMimetype( _url );

> Better yet, perhaps we could simply do something like:
[....]

Better yet: let openURL find the mimetype first if necessary, and then, 
in openView, create the tab around the part.
I guess you simply need a flag that tells openView to create a tab
instead of a normal view.

All the logic for the mimetype determination is in place and works fine,
use it, don't work around it. Thanks ;)

- -- 
David FAURE, david at mandrakesoft.com, faure at kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
KOffice-1.2-beta2 is out! http://dot.kde.org/1025176121/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9MwIQ72KcVAmwbhARAtvjAJ9mqZIWWLT5bRax86ZuzwXITTX5DQCgtMgf
x+RQQsqjR5F4+T4v22oox/E=
=UDGh
-----END PGP SIGNATURE-----





More information about the kfm-devel mailing list