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

List:       kde-core-devel
Subject:    [PATCH] Next try: plugin directories
From:       Martijn Klingens <mklingens () yahoo ! com>
Date:       2001-12-17 19:42:08
[Download RAW message or body]

And another attempt to get this right ;-)

This time I use the "modules" resource type, and add the proper plugin path 
to it. That is, if the patch is correct. I still highly doubt whether this 
patch works for plugins installed in the user's home dir.

Apart from that, I added a pluginApiVersion() method to KAboutData. I chose 
KAboutData because I had to choose something, and nobody came up with 
arguments for or against KLibLoader resp. KAboutData yet...

Is this better already? Or just as bad as the previous attempt? ;-)

Martijn

["kapplication.diff" (text/x-diff)]

? kapplication.diff
Index: kaboutdata.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kaboutdata.cpp,v
retrieving revision 1.15
diff -u -p -r1.15 kaboutdata.cpp
--- kaboutdata.cpp	2001/09/23 23:05:15	1.15
+++ kaboutdata.cpp	2001/12/17 19:30:02
@@ -81,6 +81,7 @@ public:
         {};
     const char *translatorName;
     const char *translatorEmail;
+    QString pluginApiVersion;
 };
 
 
@@ -176,6 +177,18 @@ QString
 KAboutData::version() const
 {
    return QString::fromLatin1(mVersion);
+}
+
+QString
+KAboutData::pluginApiVersion() const
+{
+   return d->pluginApiVersion;
+}
+
+void
+KAboutData::setPluginApiVersion( const QString &v )
+{
+   d->pluginApiVersion = v;
 }
 
 QString
Index: kaboutdata.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kaboutdata.h,v
retrieving revision 1.20
diff -u -p -r1.20 kaboutdata.h
--- kaboutdata.h	2001/12/06 13:03:57	1.20
+++ kaboutdata.h	2001/12/17 19:30:05
@@ -319,6 +319,22 @@ class KAboutData
     QString version() const;
 
     /**
+     * @return the version of the plugin API, if the app supports plugins.
+     * The version string should preferably not contain spaces and special
+     * characters, because the text is use in the path of the "modules"
+     * resource type. You should definitely stay away from i18n() for this
+     * string, or plugins would be locale-dependent... If they really are,
+     * you can specify that e.g. in a .desktop file for your plugin.
+     */
+    QString pluginApiVersion() const;
+
+    /**
+     * Set the plugin API version.
+     * See pluginApiVersion() for details.
+     */
+    void setPluginApiVersion( const QString &v );
+
+    /**
      * @return the short description (translated).
      */
     QString shortDescription() const;
Index: kapplication.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kapplication.cpp,v
retrieving revision 1.491
diff -u -p -r1.491 kapplication.cpp
--- kapplication.cpp	2001/12/13 04:01:35	1.491
+++ kapplication.cpp	2001/12/17 19:30:19
@@ -762,6 +762,19 @@ void KApplication::init(bool GUIenabled)
   // install appdata resource type
   KGlobal::dirs()->addResourceType("appdata", KStandardDirs::kde_default("data")
                                    + QString::fromLatin1(name()) + '/');
+                                   
+  // Application-specific plugins are part of the "modules" resource type,
+  // which defaults to $KDEDIRS/lib for compatibility. But we prefer the
+  // $KDEDIRS/lib/plugins/appname path, and if there is a pluginApiVersion in
+  // the KAboutData even $KDEDIRS/lib/plugins/appname-appversion.
+  QString pluginPath = KStandardDirs::kde_default( "modules" ) +
+                "plugins/" + pluginPath + '/' + QString::fromLatin1( name() );
+  const KAboutData *ad = KGlobal::instance()->aboutData();
+  if( ad && !ad->pluginApiVersion().isEmpty() )
+    pluginPath += '-' + ad->pluginApiVersion();
+  pluginPath += '/';
+  KGlobal::dirs()->addResourceDir( "appplugins", pluginPath );
+        
   pSessionConfig = 0L;
   bSessionManagement = true;
 


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

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