[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [PATCH] kjs_navigator
From:       rwlbuis () xs4all ! nl
Date:       2003-10-12 10:34:00
[Download RAW message or body]

Hi,

I made a small patch to get the ecma navigator object to give more info
about the plugins konq is capable of supporting on a system. So far this
info is only given for netscape plugins, but I think it also makes sense
to include here things like kghostview, ksvg.
I'd like to get some feedback on this, as I dont know much about the exact
specs for this. I used "

http://selfhtml.teamone.de/javascript/objekte/mimetypes.htm and
http://selfhtml.teamone.de/javascript/objekte/plugins.htm as testcases.

The output using this patch looks reasonable, but I'd like to know what
plugins and mimetypes should be in the list and which not. I already
stripped out inode and default mimetype (octet) entries.
Comments?
Cheers,

Rob.
["kjs_navigator.patch" (text/x-diff)]

Index: kjs_navigator.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/ecma/kjs_navigator.cpp,v
retrieving revision 1.65
diff -u -3 -p -p -u -b -r1.65 kjs_navigator.cpp
--- kjs_navigator.cpp	10 Sep 2003 00:12:15 -0000	1.65
+++ kjs_navigator.cpp	12 Oct 2003 10:16:34 -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"
@@ -261,10 +264,11 @@ PluginBase::PluginBase(ExecState *exec)
                 MimeClassInfo *mime = new MimeClassInfo;
                 QStringList::Iterator token = tokens.begin();
                 mime->type = (*token).lower();
-                //kdDebug(6070) << "mime->type=" << mime->type << endl;
+                kdDebug(6070) << "mime->type=" << mime->type << endl;
                 ++token;
 
                 mime->suffixes = *token;
+                kdDebug(6070) << "mime->suffixes=" << mime->suffixes << endl;
                 ++token;
 
                 mime->desc = *token;
@@ -274,6 +278,50 @@ PluginBase::PluginBase(ExecState *exec)
 
                 mimes->append( mime );
                 plugin->mimes.append( mime );
+            }
+        }
+
+        // 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 = (**it).name();
+            plugin->file = (**it).library();
+            plugin->desc = (**it).comment();
+
+            kdDebug(6070) << "plugin : " << plugin->name << " - " << plugin->desc << endl;
+
+            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() && !name.startsWith("inode/") )
+                    {
+                        MimeClassInfo *mime = new MimeClassInfo;
+                        mime->type = name;
+                        kdDebug(6070) << "mime->type=" << mime->type << endl;
+                        mime->suffixes = (*mimePtr).patterns().join(", ");
+                        kdDebug(6070) << "mime->suffixes=" << mime->suffixes << endl;
+                        mime->desc = (*mimePtr).comment();
+                        kdDebug(6070) << "mime->desc=" << mime->desc << endl;
+
+                        mime->plugin = plugin;
+
+                        mimes->append( mime );
+                        plugin->mimes.append( mime );
+                    }
+               }
             }
         }
     }

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic