navigator.plugins and kparts for konqueror
Koos Vriezen
koos.vriezen at xs4all.nl
Fri Feb 13 15:09:41 GMT 2004
On Fri, Feb 13, 2004 at 03:58:39PM +0100, David Faure wrote:
> On Friday 13 February 2004 15:52, Koos Vriezen wrote:
> > On Fri, Feb 13, 2004 at 11:31:21AM +0100, Koos Vriezen wrote:
> > > A bug was entered for kmplayer http://bugs.kde.org/show_bug.cgi?id=75108
> > > and it's about a page
> > > http://www-306.ibm.com/e-business/doc/content/ondemand/tvspot.html
> > > that uses navigator.plugins to determine if a certain movie player is
> > > installed (see http://www-306.ibm.com/e-business/doc/content/ondemand/popups.js)
> > > Currently ecma/kjs_navigator.cpp only looks in
> > > .kde/share/apps/nsplugins/pluginsinfo for that array, not including
> > > plugins like kjas and kmplayer (unacceptable of course :-).
> > > So what we could do is assign a rc or directory for it in share/apps/khtml,
> > > or return an array of all registered mime types that have an embedded app
> > > assigned...actually I like the last option.
> >
> > Rob Buis pointed me to a patch he posted in Oct last year and it does
> > pretty much the above. I changed it a little bit, less kdebug, strip original
> > nsplugin config stuff and no special case for inode.
>
> I like this patch - but I think the config stuff should remain. The idea was that if you disable
> plugins in "Configure Konqueror" (assuming this really means all plugins, not just nsplugins),
> then navigator.plugins shouldn't return anything, otherwise the site will think you have plugins.
Ah, yes there a two configs, the 'enable plugins' and the reading of nsplugins/pluginsinfo
Indeed only the second can be stripped.
Thanks,
Koos
-------------- next part --------------
Index: kjs_navigator.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/ecma/kjs_navigator.cpp,v
retrieving revision 1.66
diff -u -3 -p -r1.66 kjs_navigator.cpp
--- kjs_navigator.cpp 16 Oct 2003 22:50:03 -0000 1.66
+++ kjs_navigator.cpp 13 Feb 2004 15:08:23 -0000
@@ -28,6 +28,9 @@
#include <kdebug.h>
#include <kio/kprotocolmanager.h>
+#include <kio/kmimetype.h>
+#include <kio/kservice.h>
+#include <kio/ktrader.h>
#include "kjs_navigator.h"
#include "kjs/lookup.h"
#include "kjs_binding.h"
@@ -232,51 +235,46 @@ PluginBase::PluginBase(ExecState *exec)
plugins->setAutoDelete( true );
mimes->setAutoDelete( true );
- // read configuration
- KConfig c(KGlobal::dirs()->saveLocation("data","nsplugins")+"/pluginsinfo");
- unsigned num = (unsigned int)c.readNumEntry("number");
- // FIXME: add domain support here
KConfig kc("konquerorrc", true);
- bool enabled = KConfigGroup(&kc, "Java/JavaScript Settings").readBoolEntry("EnablePlugins", true);
- for ( unsigned n = 0; enabled && n < num; n++ ) {
+ if (!KConfigGroup(&kc, "Java/JavaScript Settings").readBoolEntry("EnablePlugins", true))
+ return; // plugins disabled
- c.setGroup( QString::number(n) );
+ // read in using KTrader
+ KTrader::OfferList offers = KTrader::self()->query("Browser/View");
+ KTrader::OfferList::iterator it;
+ for ( it = offers.begin(); it != offers.end(); ++it ) {
PluginInfo *plugin = new PluginInfo;
- plugin->name = c.readEntry("name");
- plugin->file = c.readPathEntry("file");
- plugin->desc = c.readEntry("description");
-
- //kdDebug(6070) << "plugin : " << plugin->name << " - " << plugin->desc << endl;
+ plugin->name = (**it).name();
+ plugin->file = (**it).library();
+ plugin->desc = (**it).comment();
plugins->append( plugin );
// get mime types from string
- QStringList types = QStringList::split( ';', c.readEntry("mime") );
+ QStringList types = (**it).serviceTypes();
QStringList::Iterator type;
for ( type=types.begin(); type!=types.end(); ++type ) {
// get mime information
QStringList tokens = QStringList::split(':', *type, true);
- if ( tokens.count() < 3 ) // we need 3 items
- continue;
-
- MimeClassInfo *mime = new MimeClassInfo;
- QStringList::Iterator token = tokens.begin();
- mime->type = (*token).lower();
- //kdDebug(6070) << "mime->type=" << mime->type << endl;
- ++token;
-
- mime->suffixes = *token;
- ++token;
-
- mime->desc = *token;
- ++token;
-
- mime->plugin = plugin;
-
- mimes->append( mime );
- plugin->mimes.append( mime );
+ QStringList::Iterator token;
+ for ( token=tokens.begin(); token!=tokens.end(); ++token ) {
+ KMimeType::Ptr mimePtr = KMimeType::mimeType(*token);
+ QString name = (*mimePtr).name();
+ if ( name != KMimeType::defaultMimeType() )
+ {
+ MimeClassInfo *mime = new MimeClassInfo;
+ mime->type = name;
+ mime->suffixes = (*mimePtr).patterns().join(", ");
+ mime->desc = (*mimePtr).comment();
+
+ mime->plugin = plugin;
+
+ mimes->append( mime );
+ plugin->mimes.append( mime );
+ }
+ }
}
}
}
More information about the kfm-devel
mailing list