summaryrefslogtreecommitdiffstats
path: root/kommander/pluginmanager/pluginmanager.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kommander/pluginmanager/pluginmanager.cpp
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kommander/pluginmanager/pluginmanager.cpp')
-rw-r--r--kommander/pluginmanager/pluginmanager.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/kommander/pluginmanager/pluginmanager.cpp b/kommander/pluginmanager/pluginmanager.cpp
new file mode 100644
index 00000000..e9301b26
--- /dev/null
+++ b/kommander/pluginmanager/pluginmanager.cpp
@@ -0,0 +1,89 @@
+/***************************************************************************
+ pluginmanager.cpp - Plugin manager class
+ -------------------
+ copyright : (C) 2005 Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+
+#include <kconfig.h>
+#include <klibloader.h>
+
+#include "pluginmanager.h"
+
+PluginManager::PluginManager()
+{
+ m_cfg = new KConfig("kommanderrc");
+ m_list = new QStringList(m_cfg->readListEntry("plugins"));
+}
+
+PluginManager::~PluginManager()
+{
+ m_cfg->writeEntry("plugins", *m_list);
+ delete m_cfg;
+ delete m_list;
+}
+
+int PluginManager::count() const
+{
+ return m_list->count();
+}
+
+QString PluginManager::item(int i) const
+{
+ return (*m_list)[i];
+}
+
+bool PluginManager::add(const QString& plugin, bool)
+{
+ QString plugName= libraryName(plugin);
+ if (plugName.isNull())
+ return false;
+ if (m_list->contains(plugName))
+ return false;
+ m_list->append(plugName);
+ return true;
+}
+
+bool PluginManager::remove(const QString& plugin)
+{
+ if (!m_list->contains(plugin))
+ return false;
+ m_list->remove(plugin);
+ return true;
+}
+
+int PluginManager::verify()
+{
+ QStringList verified;
+ for (QStringList::ConstIterator it = m_list->begin(); it != m_list->end(); ++it)
+ if (!libraryName(*it).isNull())
+ verified.append(*it);
+ int removed = count() - verified.count();
+ m_list->clear();
+ (*m_list) += verified;
+ return removed;
+}
+
+QString PluginManager::libraryName(const QString& plugin) const
+{
+ KLibrary *l = KLibLoader::self()->library(plugin.latin1());
+ QString libname;
+ if (l && l->hasSymbol("kommander_plugin"))
+ libname = l->fileName();
+ return libname;
+}
+
+QStringList PluginManager::items() const
+{
+ return (*m_list);
+}
+