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

List:       koffice-devel
Subject:    koffice
From:       Thomas Zander <zander () kde ! org>
Date:       2007-09-02 11:48:38
Message-ID: 1188733718.756528.16329.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 707597 by zander:

I realized the other day that our plugin versioning system is a bit weak; it doesn't \
scale well beyond the simple usage of 1 codebase. So I thought lets fix that :)

Specifically I made the following possible;
* allowing users to download a plugin that a 3rd party made and just install it \
without things breaking.  This specifically means that if the user is running KOffice \
2.2 and the plugin uses features in KOffice 2.3, we will not load the plugin.  But if \
the user is running KOffice 2.4 we will load it. The latter was impossible before.
* The user can install a plugin in his homedir that supersedes the same plugin \
installed on the system. I want to allow a user to download a new version and get it \
loaded without silly things like suddenly seeing 2 versions in his apps.

For this reason I made all registries (in the libs) use both a MinVersion and a \
PluginVersion variable. MinVersion basically is a 'minimum required application \
version for this plugin to run'.  So it won't be used if the plugin requires a higher \
number version of KOffice. PluginVersion means the version of the plugin.  If \
multiple are found, the highest number is used.

The version I put as the current one is '0', so any plugin that should have a minimum \
version of 0. This may sound a bit weird as we normally start counting at 1, but I \
did this on purpose due to 2 reasons. 1) it fits nicely with the KOffice minor \
version. So KOffice2.3 will have a minimum version of 3. 2) we won't freeze the APIs \
until KOffice2.1, so the first real version that external plugin implementers will \
actually see is version 1.

CCMAIL: koffice-devel@kde.org


 M  +2 -1      karbon/plugins/tools/karbontools.desktop  
 M  +2 -1      kchart/shape/chartshape.desktop  
 M  +2 -1      kformula/flake/formulashape.desktop  
 M  +2 -1      kspread/flake/tableshape.desktop  
 M  +1 -1      libs/flake/KoShapeBorderRegistry.cpp  
 M  +3 -3      libs/flake/KoShapeRegistry.cpp  
 M  +3 -3      libs/flake/KoToolRegistry.cpp  
 M  +3 -1      libs/flake/flake.desktop  
 M  +3 -1      libs/flake/flakeshape.desktop  
 M  +3 -1      libs/flake/flaketool.desktop  
 M  +1 -1      libs/kotext/KoInlineObjectRegistry.cpp  
 M  +1 -1      libs/kotext/KoTextEditingRegistry.cpp  
 M  +3 -1      libs/kotext/inlinetextobject.desktop  
 M  +3 -1      libs/kotext/texteditingplugin.desktop  
 M  +3 -1      libs/main/KoDockRegistry.cpp  
 M  +20 -5     libs/main/KoPluginLoader.cpp  
 M  +4 -0      libs/main/kofficedocker.desktop  
 M  +1 -1      libs/pigment/KoColorSpaceRegistry.cpp  
 M  +3 -1      libs/pigment/pigment.desktop  
 M  +2 -1      plugins/autocorrection/autocorrect.desktop  
 M  +2 -1      plugins/changecase/changecase.desktop  
 M  +2 -1      plugins/colorspaces/cmyk_u16/krita_cmyk_u16_plugin.desktop  
 M  +2 -2      plugins/colorspaces/cmyk_u8/kritacmykplugin.desktop  
 M  +2 -1      plugins/colorspaces/gray_u16/koffice_graya_u16_plugin.desktop  
 M  +2 -1      plugins/colorspaces/gray_u8/kofficegrayaplugin.desktop  
 M  +2 -1      plugins/colorspaces/rgb_u8/kritargbplugin.desktop  
 M  +2 -1      plugins/defaultTools/defaulttools.desktop  
 M  +2 -0      plugins/dockers/kofficedockers.desktop  
 M  +2 -1      plugins/spellcheck/spellcheck.desktop  
 M  +2 -1      plugins/variables/textvariables.desktop  
 M  +2 -1      shapes/divineProportion/divineproportionshape.desktop  
 M  +2 -1      shapes/musicshape/musicshape.desktop  
 M  +2 -1      shapes/pathshapes/pathshapes.desktop  
 M  +2 -1      shapes/pictureshape/pictureshape.desktop  
 M  +2 -1      shapes/text/textshape.desktop  
 M  +2 -1      shapes/videoshape/videoshape.desktop  
 M  +2 -1      tools/thesaurus/thesaurustool.desktop  


--- trunk/koffice/karbon/plugins/tools/karbontools.desktop #707596:707597
@@ -18,4 +18,5 @@
 ServiceTypes=KOffice/Tool
 Type=Service
 X-KDE-Library=karbontools
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/kchart/shape/chartshape.desktop #707596:707597
@@ -15,4 +15,5 @@
 ServiceTypes=KOffice/Shape
 Type=Service
 X-KDE-Library=chartshape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/kformula/flake/formulashape.desktop #707596:707597
@@ -16,4 +16,5 @@
 ServiceTypes=KOffice/Flake
 Type=Service
 X-KDE-Library=formulashape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/kspread/flake/tableshape.desktop #707596:707597
@@ -14,4 +14,5 @@
 ServiceTypes=KOffice/Shape
 Type=Service
 X-KDE-Library=tableshape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/libs/flake/KoShapeBorderRegistry.cpp #707596:707597
@@ -30,7 +30,7 @@
     config.whiteList = "FlakeBorderPlugins";
     config.blacklist = "FlakeBorderPluginsDisabled";
     KoPluginLoader::instance()->load(QString::fromLatin1("KOffice/Border"),
-                                     QString::fromLatin1("[X-Flake-Version] == 1"),
+                                     QString::fromLatin1("[X-Flake-MinVersion] <= \
0"),  config);
 
     // Also add our hard-coded basic border
--- trunk/koffice/libs/flake/KoShapeRegistry.cpp #707596:707597
@@ -1,6 +1,6 @@
 /* This file is part of the KDE project
  * Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org)
- * Copyright (C) 2006 Thomas Zander <zander@kde.org>
+ * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
  * Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
  * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
  *
@@ -61,12 +61,12 @@
     config.blacklist = "FlakePluginsDisabled";
     config.group = "koffice";
     KoPluginLoader::instance()->load( QString::fromLatin1("KOffice/Flake"),
-                                      QString::fromLatin1("[X-Flake-Version] == 1"),
+                                      QString::fromLatin1("[X-Flake-MinVersion] <= \
0"),  config);
     config.whiteList = "ShapePlugins";
     config.blacklist = "ShapePluginsDisabled";
     KoPluginLoader::instance()->load(QString::fromLatin1("KOffice/Shape"),
-                                     QString::fromLatin1("[X-Flake-Version] == 1"),
+                                     QString::fromLatin1("[X-Flake-MinVersion] <= \
0"),  config);
 
     // Also add our hard-coded basic shape
--- trunk/koffice/libs/flake/KoToolRegistry.cpp #707596:707597
@@ -1,5 +1,5 @@
 /* This file is part of the KDE project
- * Copyright (C) 2006 Thomas Zander <zander@kde.org>
+ * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
  * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
  *
  * This library is free software; you can redistribute it and/or
@@ -32,11 +32,11 @@
     config.blacklist = "FlakePluginsDisabled";
     config.group = "koffice";
     KoPluginLoader::instance()->load( QString::fromLatin1("KOffice/Flake"),
-                                      QString::fromLatin1("[X-Flake-Version] == \
1")); +                                      \
QString::fromLatin1("[X-Flake-MinVersion] <= 0"));  config.whiteList = "ToolPlugins";
     config.blacklist = "ToolPluginsDisabled";
     KoPluginLoader::instance()->load( QString::fromLatin1("KOffice/Tool"),
-                                      QString::fromLatin1("[X-Flake-Version] == \
1")); +                                      \
QString::fromLatin1("[X-Flake-MinVersion] <= 0"));  }
 
 KoToolRegistry::~KoToolRegistry()
--- trunk/koffice/libs/flake/flake.desktop #707596:707597
@@ -26,5 +26,7 @@
 Comment[sv]=Ett insticksprogram som innehåller en formmängd och ett verktyg
 Comment[x-test]=xxA plugin that contains a set of a shape and a toolxx
 Comment[zh_TW]=包含形狀與工具集的外掛程式
-[PropertyDef::X-Flake-Version]
+[PropertyDef::X-Flake-MinVersion]
 Type=int
+[PropertyDef::X-Flake-PluginVersion]
+Type=int
--- trunk/koffice/libs/flake/flakeshape.desktop #707596:707597
@@ -22,5 +22,7 @@
 Comment[sv]=Definition av ett formobjekt i Flake
 Comment[x-test]=xxDefinition of a flake shape objectxx
 Comment[zh_TW]=Flake 形狀物件定義
-[PropertyDef::X-Flake-Version]
+[PropertyDef::X-Flake-MinVersion]
 Type=int
+[PropertyDef::X-Flake-PluginVersion]
+Type=int
--- trunk/koffice/libs/flake/flaketool.desktop #707596:707597
@@ -23,5 +23,7 @@
 Comment[sv]=Definition av verktyg i Flake
 Comment[x-test]=xxDefinition of flake toolsxx
 Comment[zh_TW]=Flake 工具定義
-[PropertyDef::X-Flake-Version]
+[PropertyDef::X-Flake-MinVersion]
 Type=int
+[PropertyDef::X-Flake-PluginVersion]
+Type=int
--- trunk/koffice/libs/kotext/KoInlineObjectRegistry.cpp #707596:707597
@@ -33,7 +33,7 @@
     config.blacklist = "TextInlinePluginsDisabled";
     config.group = "koffice";
     KoPluginLoader::instance()->load( \
                QString::fromLatin1("KOffice/Text-InlineObject"),
-                                      QString::fromLatin1("[X-KoText-Version] == \
1"), config); +                                      \
QString::fromLatin1("[X-KoText-MinVersion] <= 0"), config);  }
 
 KoInlineObjectRegistry *KoInlineObjectRegistry::s_instance = 0;
--- trunk/koffice/libs/kotext/KoTextEditingRegistry.cpp #707596:707597
@@ -29,7 +29,7 @@
     config.blacklist = "TextEditingPluginsDisabled";
     config.group = "koffice";
     KoPluginLoader::instance()->load( \
                QString::fromLatin1("KOffice/Text-EditingPlugin"),
-                                      QString::fromLatin1("[X-KoText-Version] == \
1"), config); +                                      \
QString::fromLatin1("[X-KoText-MinVersion] <= 0"), config);  }
 
 KoTextEditingRegistry *KoTextEditingRegistry::s_instance = 0;
--- trunk/koffice/libs/kotext/inlinetextobject.desktop #707596:707597
@@ -22,5 +22,7 @@
 Comment[sv]=Definition av ett textobjekt
 Comment[x-test]=xxDefinition of a text objectxx
 Comment[zh_TW]=定義文字物件
-[PropertyDef::X-KoText-Version]
+[PropertyDef::X-KoText-MinVersion]
 Type=int
+[PropertyDef::X-Flake-PluginVersion]
+Type=int
--- trunk/koffice/libs/kotext/texteditingplugin.desktop #707596:707597
@@ -22,5 +22,7 @@
 Comment[sv]=Definition av ett Insticksprogram för textredigering
 Comment[x-test]=xxDefinition of a text-editing pluginxx
 Comment[zh_TW]=文字編輯外掛程式定義
-[PropertyDef::X-KoText-Version]
+[PropertyDef::X-KoText-MinVersion]
 Type=int
+[PropertyDef::X-Flake-PluginVersion]
+Type=int
--- trunk/koffice/libs/main/KoDockRegistry.cpp #707596:707597
@@ -30,7 +30,9 @@
     config.whiteList = "DockerPlugins";
     config.blacklist = "DockerPluginsDisabled";
     config.group = "koffice";
-    KoPluginLoader::instance()->load( QString::fromLatin1("KOffice/Dock"), \
QString(), config); +    KoPluginLoader::instance()->load( \
QString::fromLatin1("KOffice/Dock"), +                                     \
QString::fromLatin1("[X-Flake-MinVersion] <= 0"), +                                   \
config);  }
 
 KoDockRegistry::~KoDockRegistry()
--- trunk/koffice/libs/main/KoPluginLoader.cpp #707596:707597
@@ -1,5 +1,6 @@
 /* This file is part of the KDE project
- * Copyright (c) 2006 Boudewijn Rempt (boud@valdyas.org)
+ * Copyright (c) 2006 Boudewijn Rempt <boud@valdyas.org>
+ * Copyright (c) 2007 Thomas Zander <zander@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -73,7 +74,7 @@
     bool configChanged = false;
     QList<QString> blacklist; // what we will save out afterwards
     if(config.whiteList && config.blacklist && config.group) {
-        kDebug(30003) <<"Loading" << serviceType <<" with checking the config";
+        kDebug(30003) <<"Loading" << serviceType <<"with checking the config";
         KConfigGroup configGroup = KGlobal::config()->group(config.group);
         QList<QString> whiteList = configGroup.readEntry(config.whiteList, \
config.defaults);  QList<QString> knownList;
@@ -99,17 +100,31 @@
     else
         plugins = offers;
 
+    QMap<QString, KSharedPtr<KService> > serviceNames;
+    foreach(KSharedPtr<KService> service, plugins) {
+        if(serviceNames.contains(service->name())) { // duplicate
+            QVariant pluginVersion2 = service->property("X-Flake-PluginVersion");
+            if(pluginVersion2.isNull()) // just take the first one found...
+                continue;
+            KSharedPtr<KService> otherService = serviceNames.value(service->name());
+            QVariant pluginVersion = \
otherService->property("X-Flake-PluginVersion"); +            if(! \
(pluginVersion.isNull() || pluginVersion.toInt() < pluginVersion2.toInt()) ) +        \
continue; // replace the old one with this one, since its newer. +        }
+        serviceNames.insert(service->name(), service);
+    }
+
     QList<QString> whiteList;
-    foreach(KSharedPtr<KService> service, plugins) {
+    foreach(KSharedPtr<KService> service, serviceNames.values()) {
         int errCode = 0;
         QObject * plugin = KService::createInstance<QObject>(service, this, \
QStringList(), &errCode );  if ( plugin ) {
             whiteList << service->library();
-            kDebug(30003) <<"Loaded plugin" << service->name();
+            kDebug(30003) << "Loaded plugin" << service->name();
             delete plugin;
         }
         else {
-            kWarning(30003) <<"Loading plugin '" << service->name() << "' failed, \
"<< KLibLoader::errorString( errCode ) << " ("<< errCode << ")\n"; +            \
kWarning(30003) << "Loading plugin" << service->name() << "failed, "<< \
KLibLoader::errorString( errCode ) << "("<< errCode << ")";  }
     }
 
--- trunk/koffice/libs/main/kofficedocker.desktop #707596:707597
@@ -23,3 +23,7 @@
 Comment[sv]=Ett insticksprogram som innehåller en så kallad 'grafisk \
dockningskomponent'  Comment[x-test]=xxA plugin that contains a so called \
'dockwidget'xx  Comment[zh_TW]=包含「嵌入元件」的外掛程式
+[PropertyDef::X-Flake-MinVersion]
+Type=int
+[PropertyDef::X-Flake-PluginVersion]
+Type=int
--- trunk/koffice/libs/pigment/KoColorSpaceRegistry.cpp #707596:707597
@@ -141,7 +141,7 @@
     config.whiteList = "ColorSpacePlugins";
     config.blacklist = "ColorSpacePluginsDisabled";
     config.group = "koffice";
-    KoPluginLoader::instance()->load("KOffice/ColorSpace","[X-Pigment-Version] == \
1", config); +    KoPluginLoader::instance()->load("KOffice/ColorSpace","[X-Pigment-MinVersion] \
<= 0", config);  }
 
 KoColorSpaceRegistry::KoColorSpaceRegistry() : d(new Private())
--- trunk/koffice/libs/pigment/pigment.desktop #707596:707597
@@ -13,5 +13,7 @@
 Comment[sv]=En modul som implementerar en fullständig färgrymd för användning \
med libpigment  Comment[x-test]=xxA module implementing a complete colorspace for use \
with libpigmentxx  Comment[zh_TW]=實作完整色彩空間以使用 libpigment \
                的模組
-[PropertyDef::X-Pigment-Version]
+[PropertyDef::X-Pigment-MinVersion]
 Type=int
+[PropertyDef::X-Flake-PluginVersion]
+Type=int
--- trunk/koffice/plugins/autocorrection/autocorrect.desktop #707596:707597
@@ -15,5 +15,6 @@
 Name[zh_TW]=自動修正外掛程式
 ServiceTypes=KOffice/Text-EditingPlugin
 Type=Service
-X-KoText-Version=1
+X-KoText-MinVersion=0
+X-KoText-PluginVersion=1
 X-KDE-Library=autocorrect
--- trunk/koffice/plugins/changecase/changecase.desktop #707596:707597
@@ -11,5 +11,6 @@
 Name[zh_TW]=改變大小寫外掛程式
 ServiceTypes=KOffice/Text-EditingPlugin
 Type=Service
-X-KoText-Version=1
 X-KDE-Library=changecase
+X-KoText-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/colorspaces/cmyk_u16/krita_cmyk_u16_plugin.desktop \
#707596:707597 @@ -72,4 +72,5 @@
 ServiceTypes=KOffice/ColorSpace
 Type=Service
 X-KDE-Library=krita_cmyk_u16_plugin
-X-Pigment-Version=1
+X-Pigment-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/colorspaces/cmyk_u8/kritacmykplugin.desktop #707596:707597
@@ -84,5 +84,5 @@
 ServiceTypes=KOffice/ColorSpace
 Type=Service
 X-KDE-Library=kritacmykplugin
-X-Pigment-Version=1
-
+X-Pigment-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/colorspaces/gray_u16/koffice_graya_u16_plugin.desktop \
#707596:707597 @@ -48,5 +48,6 @@
 Comment[zh_TW]=每色 為 16-bit 的灰階圖片色彩模型
 ServiceTypes=KOffice/ColorSpace
 Type=Service
-X-Pigment-Version=1
 X-KDE-Library=koffice_graya_u16_plugin
+X-Pigment-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/colorspaces/gray_u8/kofficegrayaplugin.desktop \
#707596:707597 @@ -55,4 +55,5 @@
 ServiceTypes=KOffice/ColorSpace
 Type=Service
 X-KDE-Library=kofficegrayau8plugin
-X-Pigment-Version=1
+X-Pigment-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/colorspaces/rgb_u8/kritargbplugin.desktop #707596:707597
@@ -86,4 +86,5 @@
 ServiceTypes=KOffice/ColorSpace
 Type=Service
 X-KDE-Library=kritargbplugin
-X-Pigment-Version=1
+X-Pigment-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/defaultTools/defaulttools.desktop #707596:707597
@@ -15,4 +15,5 @@
 ServiceTypes=KOffice/Flake
 Type=Service
 X-KDE-Library=defaulttools
-X-Flake-Version=1
+X-KoText-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/dockers/kofficedockers.desktop #707596:707597
@@ -14,3 +14,5 @@
 ServiceTypes=KOffice/Dock
 Type=Service
 X-KDE-Library=kofficedockers
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/spellcheck/spellcheck.desktop #707596:707597
@@ -3,5 +3,6 @@
 Name=SpellCheck plugin
 ServiceTypes=KOffice/Text-EditingPlugin
 Type=Service
-X-KoText-Version=1
 X-KDE-Library=spellcheck
+X-KoText-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/plugins/variables/textvariables.desktop #707596:707597
@@ -14,5 +14,6 @@
 Name[zh_TW]=文字變數
 ServiceTypes=KOffice/Text-InlineObject
 Type=Service
-X-KoText-Version=1
 X-KDE-Library=textvariables
+X-KoText-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/shapes/divineProportion/divineproportionshape.desktop \
#707596:707597 @@ -12,4 +12,5 @@
 ServiceTypes=KOffice/Flake
 Type=Service
 X-KDE-Library=divineproportionshape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/shapes/musicshape/musicshape.desktop #707596:707597
@@ -14,4 +14,5 @@
 ServiceTypes=KOffice/Shape
 Type=Service
 X-KDE-Library=musicshape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/shapes/pathshapes/pathshapes.desktop #707596:707597
@@ -14,5 +14,6 @@
 Name[zh_TW]=路徑形狀
 ServiceTypes=KOffice/Shape
 Type=Service
-X-Flake-Version=1
 X-KDE-Library=pathshapes
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/shapes/pictureshape/pictureshape.desktop #707596:707597
@@ -13,4 +13,5 @@
 ServiceTypes=KOffice/Shape
 Type=Service
 X-KDE-Library=pictureshape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/shapes/text/textshape.desktop #707596:707597
@@ -14,4 +14,5 @@
 ServiceTypes=KOffice/Flake
 Type=Service
 X-KDE-Library=textshape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/shapes/videoshape/videoshape.desktop #707596:707597
@@ -14,4 +14,5 @@
 ServiceTypes=KOffice/Shape
 Type=Service
 X-KDE-Library=videoshape
-X-Flake-Version=1
+X-Flake-MinVersion=0
+X-Flake-PluginVersion=1
--- trunk/koffice/tools/thesaurus/thesaurustool.desktop #707596:707597
@@ -102,5 +102,6 @@
 Comment[x-test]=xxShow Related Wordsxx
 Comment[xh]=Bonisa Amagama Ahlobeneyo
 Comment[zh_TW]=顯示相關單字
-X-KoText-Version=1
+X-KoText-MinVersion=0
+X-Flake-PluginVersion=1
 ServiceTypes=KOffice/Text-EditingPlugin
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


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

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