plugin badness

Koos Vriezen koos.vriezen at xs4all.nl
Wed Mar 17 17:05:50 GMT 2004


On Tue, Mar 16, 2004 at 05:29:40PM -0500, George Staikos wrote:
> On Tuesday 16 March 2004 15:15, Koos Vriezen wrote:
> > > Now how could a kpart present itself as more then one plugin more
> > > generally? Also using properies in .desktop files.. doesn't sound that
> > > dynamic... Hmm, what if we add a pluginsinfo property that points to this
> > > file. So if a part has this property, try open this file and register
> > > plugin as it used to be.
> >
> > Attached this propery points to plugin info filename idea. Needs also a
> > small change in nspluginscan to add to
> > ~/.kde/share/services/nsplugin.desktop
> > X-KDE-BrowserView-PluginsInfo=nsplugins/pluginsinfo
> 
>    I really can't test or properly review right now, sorry.  I have to leave 
> it up to you to patch as you see fit.  In any case, KHTML generally gets 
> fully backported so you can expect that these things will end up in the 
> branch.  Please backport the fixes, though, in case they get lost somehow.

Ok, for others to comment a final version. It should be backwards compatable
with pre 'this stuff' plugin scans. Also changes for kjavaappletviewer
to participate in this plugin array.

Koos
-------------- next part --------------
Index: khtml/ecma/kjs_navigator.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/ecma/kjs_navigator.cpp,v
retrieving revision 1.67
diff -u -3 -p -r1.67 kjs_navigator.cpp
--- khtml/ecma/kjs_navigator.cpp	13 Feb 2004 15:22:40 -0000	1.67
+++ khtml/ecma/kjs_navigator.cpp	17 Mar 2004 16:59:17 -0000
@@ -244,38 +244,57 @@ PluginBase::PluginBase(ExecState *exec)
         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 = (**it).name();
-            plugin->file = (**it).library();
-            plugin->desc = (**it).comment();
-
-            plugins->append( plugin );
-
-            // get mime types from string
-            QStringList types = (**it).serviceTypes();
-            QStringList::Iterator type;
-            for ( type=types.begin(); type!=types.end(); ++type ) {
-
-                // get mime information
-                QStringList tokens = QStringList::split(':', *type, true);
-                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 );
-                    }
-               }
+            QVariant pluginsinfo = (**it).property( "X-KDE-BrowserView-PluginsInfo" );
+            if ( !pluginsinfo.isValid() ) {
+                // <backwards compatible>
+                if ((**it).library() == QString("libnsplugin"))
+                    pluginsinfo = QVariant("nsplugins/pluginsinfo");
+                else
+                // </backwards compatible>
+                    continue;
+            }
+            // read configuration
+            KConfig kc( locate ("data", pluginsinfo.toString()) );
+            unsigned num = (unsigned int) kc.readNumEntry("number");
+            for ( unsigned n = 0; n < num; n++ ) {
+                kc.setGroup( QString::number(n) );
+                PluginInfo *plugin = new PluginInfo;
+
+                plugin->name = kc.readEntry("name");
+                plugin->file = kc.readPathEntry("file");
+                plugin->desc = kc.readEntry("description");
+
+                plugins->append( plugin );
+
+                // get mime types from string
+                QStringList types = QStringList::split( ';', kc.readEntry("mime") );
+                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 );
+
+                }
             }
         }
     }
Index: khtml/java/Makefile.am
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/Makefile.am,v
retrieving revision 1.36
diff -u -3 -p -r1.36 Makefile.am
--- khtml/java/Makefile.am	15 Mar 2004 16:31:37 -0000	1.36
+++ khtml/java/Makefile.am	17 Mar 2004 16:59:17 -0000
@@ -18,7 +18,7 @@ INCLUDES = -I$(top_srcdir) -I$(top_srcdi
 	-I$(top_srcdir)/kio/kssl -I$(top_builddir)/kio/kssl \
 	$(all_includes) 
 
-kjavadata_DATA = kjava.jar kjava.policy
+kjavadata_DATA = kjava.jar kjava.policy pluginsinfo
 kjavadatadir = $(kde_datadir)/kjava/
 
 SUBDIRS = . tests dummy
Index: khtml/java/kjavaappletviewer.desktop
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletviewer.desktop,v
retrieving revision 1.48
diff -u -3 -p -r1.48 kjavaappletviewer.desktop
--- khtml/java/kjavaappletviewer.desktop	16 Mar 2004 07:13:00 -0000	1.48
+++ khtml/java/kjavaappletviewer.desktop	17 Mar 2004 16:59:17 -0000
@@ -57,3 +57,4 @@ MimeType=application/x-java-applet;
 ServiceTypes=KParts/ReadOnlyPart,Browser/View
 Type=Service
 InitialPreference=2
+X-KDE-BrowserView-PluginsInfo=kjava/pluginsinfo
Index: kparts/browserview.desktop
===================================================================
RCS file: /home/kde/kdelibs/kparts/browserview.desktop,v
retrieving revision 1.162
diff -u -3 -p -r1.162 browserview.desktop
--- kparts/browserview.desktop	14 Jan 2004 07:51:06 -0000	1.162
+++ kparts/browserview.desktop	17 Mar 2004 16:59:17 -0000
@@ -132,3 +132,10 @@ Type=bool
 # (famous bug).
 [PropertyDef::X-KDE-BrowserView-Built-Into]
 Type=QString
+
+# If the part has a plugin for KHTML Javascript's window.navigator.plugins
+# array, it should create a plugin info file and set this propery to the
+# file path here. The path should be relative to KDE's data dir
+# ($KDEDIR/share/apps)
+[PropertyDef::X-KDE-BrowserView-PluginsInfo]
+Type=QString
Index: nsplugins/pluginscan.cpp
===================================================================
RCS file: /home/kde/kdebase/nsplugins/pluginscan.cpp,v
retrieving revision 1.51
diff -u -3 -p -r1.51 pluginscan.cpp
--- nsplugins/pluginscan.cpp	28 Oct 2003 10:33:29 -0000	1.51
+++ nsplugins/pluginscan.cpp	17 Mar 2004 16:59:26 -0000
@@ -494,6 +494,7 @@ void writeServicesFile( QStringList mime
         ts << "X-KDE-Library=libnsplugin" << endl;
         ts << "InitialPreference=0" << endl;
         ts << "ServiceTypes=KParts/ReadOnlyPart,Browser/View" << endl;
+        ts << "X-KDE-BrowserView-PluginsInfo=nsplugins/pluginsinfo" << endl;
 
         if (mimeTypes.count() > 0)
             ts << "MimeType=" << mimeTypes.join(";") << endl;
-------------- next part --------------
number=1

[0]
description=Java Plug-in KJAS for Konqueror
file=kjavaappletviewer.so
mime=application/x-java-applet:class:Java Applet;application/x-java-bean:jar:JavaBeans
name=Java Plug-in


More information about the kfm-devel mailing list