introduce a CoreBackendManager class.

convert the plugins into true KDE plugins with desktop file and all.

let the user pick a backend in the config dialog and load backends on the fly.

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1105758
This commit is contained in:
Volker Lanz 2010-03-21 10:50:44 +00:00
parent 389fc52e0e
commit 5ca58c6c1c
36 changed files with 403 additions and 87 deletions

3
TODO
View File

@ -20,7 +20,8 @@ Plans and ideas for 1.1:
* offer a) no alignment of partition boundaries at all or b) legacy cylinder
alignment or c) sector based alignment (the name is misleading, though)
* align partitions while changing size and position in the size dialog base
* don't hardcode any support for libparted-related stuff like shrinking fat16
in the file system classes.
===============================================================================

View File

@ -24,11 +24,8 @@
#include "util/globallog.h"
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <kdebug.h>
#include <klocale.h>
#include <kaboutdata.h>
#include <config.h>
@ -52,29 +49,6 @@ CoreBackend::~CoreBackend()
delete d;
}
CoreBackend* CoreBackend::self()
{
static CoreBackend* instance = NULL;
if (instance == NULL)
{
KPluginLoader loader(Config::backend());
KPluginFactory* factory = loader.factory();
if (factory != NULL)
{
instance = factory->create<CoreBackend>(NULL);
instance->setAboutData(factory->componentData().aboutData());
kDebug() << "Loaded backend plugin: " << instance->about().programName() << ", " << instance->about().version();
}
else
kWarning() << "Could not load instance plugin for core backend: " << loader.errorString();
}
return instance;
}
void CoreBackend::emitProgress(int i)
{
emit progress(i);

View File

@ -26,6 +26,7 @@
#include <QObject>
#include <QList>
class CoreBackendManager;
class CoreBackendDevice;
class Device;
class PartitionTable;
@ -39,6 +40,8 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend : public QObject
Q_OBJECT
Q_DISABLE_COPY(CoreBackend)
friend class CoreBackendManager;
protected:
CoreBackend();
virtual ~CoreBackend();
@ -48,7 +51,6 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend : public QObject
void scanProgress(const QString&,int);
public:
static CoreBackend* self();
virtual const KAboutData& about() const { return *m_AboutData; }
virtual QList<Device*> scanDevices() = 0;

View File

@ -0,0 +1,81 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "backend/corebackendmanager.h"
#include "backend/corebackend.h"
#include <QStringList>
#include <QString>
#include <kpluginfactory.h>
#include <kpluginloader.h>
#include <kdebug.h>
#include <klocale.h>
#include <kaboutdata.h>
#include <kservice.h>
#include <kservicetypetrader.h>
#include <config.h>
CoreBackendManager::CoreBackendManager() :
m_Backend(NULL)
{
}
CoreBackendManager* CoreBackendManager::self()
{
static CoreBackendManager* instance = NULL;
if (instance == NULL)
instance = new CoreBackendManager;
return instance;
}
KService::List CoreBackendManager::list() const
{
return KServiceTypeTrader::self()->query("PartitionManager/Plugin", "[X-KDE-PluginInfo-Category] == 'BackendPlugin'");
}
bool CoreBackendManager::load(const QString& name)
{
if (backend())
unload();
KPluginLoader loader(name);
KPluginFactory* factory = loader.factory();
if (factory != NULL)
{
m_Backend = factory->create<CoreBackend>(NULL);
backend()->setAboutData(factory->componentData().aboutData());
kDebug() << "Loaded backend plugin: " << backend()->about().programName() << ", " << backend()->about().version();
return true;
}
kWarning() << "Could not load plugin for core backend " << name << ": " << loader.errorString();
return false;
}
void CoreBackendManager::unload()
{
delete m_Backend;
m_Backend = NULL;
}

View File

@ -0,0 +1,50 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#if !defined(COREBACKENDMANAGER__H)
#define COREBACKENDMANAGER__H
#include "util/libpartitionmanagerexport.h"
#include <kservice.h>
class QString;
class QStringList;
class CoreBackend;
class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackendManager
{
private:
CoreBackendManager();
public:
static CoreBackendManager* self();
static QString defaultBackendName() { return "pmlibpartedbackendplugin"; }
KService::List list() const;
bool load(const QString& name);
void unload();
CoreBackend* backend() { return m_Backend; }
private:
CoreBackend* m_Backend;
};
#endif

View File

@ -80,7 +80,7 @@
</entry>
<entry key="backend" type="String">
<label context="@label">Backend Plugin</label>
<default>pluginpmlibparted</default>
<default>pmlibpartedbackendplugin</default>
</entry>
<entry key="defaultFileSystem" type="Int">
<default>FileSystem::Ext3</default>

View File

@ -20,6 +20,7 @@
#include "core/copysourcedevice.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "core/copytarget.h"
@ -53,7 +54,7 @@ CopySourceDevice::~CopySourceDevice()
*/
bool CopySourceDevice::open()
{
m_BackendDevice = CoreBackend::self()->openDeviceExclusive(device().deviceNode());
m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode());
return m_BackendDevice != NULL;
}

View File

@ -20,6 +20,7 @@
#include "core/copytargetdevice.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "core/device.h"
@ -50,7 +51,7 @@ CopyTargetDevice::~CopyTargetDevice()
*/
bool CopyTargetDevice::open()
{
m_BackendDevice = CoreBackend::self()->openDeviceExclusive(device().deviceNode());
m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode());
return m_BackendDevice != NULL;
}

View File

@ -20,6 +20,7 @@
#include "core/devicescanner.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "core/operationstack.h"
#include "core/device.h"
@ -34,7 +35,12 @@ DeviceScanner::DeviceScanner(QObject* parent, OperationStack& ostack) :
QThread(parent),
m_OperationStack(ostack)
{
connect(CoreBackend::self(), SIGNAL(scanProgress(QString,int)), SIGNAL(progress(QString,int)));
setupConnections();
}
void DeviceScanner::setupConnections()
{
connect(CoreBackendManager::self()->backend(), SIGNAL(scanProgress(QString,int)), SIGNAL(progress(QString,int)));
}
void DeviceScanner::clear()
@ -54,7 +60,7 @@ void DeviceScanner::scan()
clear();
QList<Device*> deviceList = CoreBackend::self()->scanDevices();
QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
foreach(Device* d, deviceList)
operationStack().addDevice(d);

View File

@ -40,6 +40,7 @@ class DeviceScanner : public QThread
public:
void clear(); /**< clear Devices and the OperationStack */
void scan(); /**< do the actual scanning; blocks if called directly */
void setupConnections();
signals:
void progress(const QString& device_node, int progress);

View File

@ -19,6 +19,8 @@
#include "gui/configureoptionsdialog.h"
#include "backend/corebackendmanager.h"
#include "fs/filesystem.h"
#include "fs/filesystemfactory.h"
@ -28,6 +30,7 @@
#include "ui_configurepagefilesystemcolors.h"
#include <kiconloader.h>
#include <kservice.h>
#include <config.h>
@ -37,8 +40,11 @@ class GeneralPageWidget : public QWidget, public Ui::ConfigurePageGeneral
GeneralPageWidget(QWidget* parent) : QWidget(parent) { setupUi(this); setupDialog(); }
public:
QComboBox& comboDefaultFileSystem() { return *m_ComboDefaultFileSystem; }
const QComboBox& comboDefaultFileSystem() const { return *m_ComboDefaultFileSystem; }
KComboBox& comboDefaultFileSystem() { return *m_ComboDefaultFileSystem; }
const KComboBox& comboDefaultFileSystem() const { return *m_ComboDefaultFileSystem; }
KComboBox& comboBackend() { return *m_ComboBackend; }
const KComboBox& comboBackend() const { return *m_ComboBackend; }
FileSystem::Type defaultFileSystem() const
{
@ -50,6 +56,26 @@ class GeneralPageWidget : public QWidget, public Ui::ConfigurePageGeneral
comboDefaultFileSystem().setCurrentIndex(comboDefaultFileSystem().findText(FileSystem::nameForType(t)));
}
QString backend() const
{
KService::List services = CoreBackendManager::self()->list();
foreach(KService::Ptr p, services)
if (p->name() == comboBackend().currentText())
return p->library();
return QString();
}
void setBackend(const QString& name)
{
KService::List services = CoreBackendManager::self()->list();
foreach(KService::Ptr p, services)
if (p->library() == name)
comboBackend().setCurrentIndex(comboBackend().findText(p->name()));
}
private:
void setupDialog()
{
@ -64,6 +90,12 @@ class GeneralPageWidget : public QWidget, public Ui::ConfigurePageGeneral
comboDefaultFileSystem().addItem(createFileSystemColor(FileSystem::typeForName(fsName), 8), fsName);
setDefaultFileSystem(FileSystem::defaultFileSystem());
KService::List services = CoreBackendManager::self()->list();
foreach(KService::Ptr p, services)
comboBackend().addItem(p->name());
setBackend(Config::backend());
}
};
@ -86,6 +118,8 @@ ConfigureOptionsDialog::ConfigureOptionsDialog(QWidget* parent, const QString& n
item->setIcon(KIcon(DesktopIcon("configure")));
connect(&generalPageWidget().comboDefaultFileSystem(), SIGNAL(activated(int)), SLOT(onComboDefaultFileSystemActivated(int)));
connect(&generalPageWidget().comboBackend(), SIGNAL(activated(int)), SLOT(onComboBackendActivated(int)));
item = addPage(&fileSystemColorsPageWidget(), i18nc("@title:tab", "File System Colors"), QString(), i18n("File System Color Settings"));
item->setIcon(KIcon(DesktopIcon("format-fill-color")));
@ -101,22 +135,47 @@ ConfigureOptionsDialog::~ConfigureOptionsDialog()
void ConfigureOptionsDialog::updateSettings()
{
Config::setDefaultFileSystem(generalPageWidget().defaultFileSystem());
KConfigDialog::updateSettings();
bool changed = false;
if (generalPageWidget().defaultFileSystem() != Config::defaultFileSystem())
{
Config::setDefaultFileSystem(generalPageWidget().defaultFileSystem());
changed = true;
}
if (generalPageWidget().backend() != Config::backend())
{
Config::setBackend(generalPageWidget().backend());
changed = true;
}
if (changed)
emit KConfigDialog::settingsChanged(i18n("General Settings"));
}
bool ConfigureOptionsDialog::hasChanged()
{
bool result = KConfigDialog::hasChanged();
KConfigSkeletonItem* kcItem = Config::self()->findItem("defaultFileSystem");
result = result || !kcItem->isEqual(generalPageWidget().defaultFileSystem());
kcItem = Config::self()->findItem("backend");
result = result || !kcItem->isEqual(generalPageWidget().backend());
return result;
}
bool ConfigureOptionsDialog::isDefault()
{
bool result = !hasChanged();
bool result = KConfigDialog::isDefault();
if (result)
{
const bool useDefaults = Config::self()->useDefaults(true);
KConfigSkeletonItem* kcItem = Config::self()->findItem("defaultFileSystem");
if (kcItem != NULL)
result = kcItem->isEqual(generalPageWidget().defaultFileSystem());
else
kWarning() << "the kcitem for defaultFileSytstem is gone.";
result = !hasChanged();
Config::self()->useDefaults(useDefaults);
}
@ -127,6 +186,6 @@ void ConfigureOptionsDialog::updateWidgetsDefault()
{
bool useDefaults = Config::self()->useDefaults(true);
generalPageWidget().setDefaultFileSystem(FileSystem::defaultFileSystem());
generalPageWidget().setBackend(CoreBackendManager::defaultBackendName());
Config::self()->useDefaults(useDefaults);
}

View File

@ -38,8 +38,10 @@ class ConfigureOptionsDialog : public KConfigDialog
protected slots:
virtual void updateSettings();
virtual void updateWidgetsDefault();
virtual bool hasChanged();
virtual bool isDefault();
void onComboDefaultFileSystemActivated(int) { settingsChangedSlot(); }
void onComboBackendActivated(int) { settingsChangedSlot(); }
protected:
GeneralPageWidget& generalPageWidget() { Q_ASSERT(m_GeneralPageWidget); return *m_GeneralPageWidget; }

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>459</width>
<height>633</height>
<height>389</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -32,7 +32,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Allow Applying Operations Without Administrator Privileges</string>
<string>Allow applying operations without administrator privileges</string>
</property>
</widget>
</item>
@ -54,7 +54,7 @@
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_useCylinderAlignment">
<property name="text">
<string>Use Cylinder Based MS-Dos Partition Alignment (Windows XP compatible)</string>
<string>Use cylinder based MS-Dos partition alignment (Windows XP compatible)</string>
</property>
<property name="checked">
<bool>true</bool>
@ -67,7 +67,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>Partition Sector Alignment:</string>
<string>Partition sector alignment:</string>
</property>
<property name="buddy">
<cstring>kcfg_sectorAlignment</cstring>
@ -108,7 +108,7 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Hide Messages Below:</string>
<string>Hide messages below:</string>
</property>
<property name="buddy">
<cstring>kcfg_minLogLevel</cstring>
@ -116,7 +116,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="kcfg_minLogLevel">
<widget class="KComboBox" name="kcfg_minLogLevel">
<item>
<property name="text">
<string>Debug</string>
@ -157,21 +157,56 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default File System:</string>
<string>Default file system:</string>
</property>
<property name="buddy">
<cstring>kcfg_minLogLevel</cstring>
<cstring>m_ComboDefaultFileSystem</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_ComboDefaultFileSystem"/>
<widget class="KComboBox" name="m_ComboDefaultFileSystem"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Backend</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Active backend:</string>
</property>
<property name="buddy">
<cstring>m_ComboBackend</cstring>
</property>
</widget>
</item>
<item>
<widget class="KComboBox" name="m_ComboBackend"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -26,6 +26,9 @@
#include "gui/configureoptionsdialog.h"
#include "gui/devicepropsdialog.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackend.h"
#include "core/device.h"
#include "core/partition.h"
@ -42,6 +45,8 @@
#include "fs/filesystem.h"
#include "fs/filesystemfactory.h"
#include "util/helpers.h"
#include <kstandardaction.h>
#include <kactioncollection.h>
#include <ktoolbar.h>
@ -903,8 +908,23 @@ void MainWindow::onFileSystemSupport()
dlg.exec();
}
void MainWindow::onSettingsChanged(const QString&)
void MainWindow::onSettingsChanged()
{
if (CoreBackendManager::self()->backend()->about().appName() != Config::backend())
{
CoreBackendManager::self()->unload();
// FIXME: if loadBackend() fails to load the configured backend and loads the default
// one instead it also sets the default backend in the config; the config dialog will
// overwrite that again, however, after we're done here.
if (loadBackend())
{
deviceScanner().setupConnections();
scanDevices();
}
else
close();
}
enableActions();
pmWidget().updatePartitions();
}
@ -916,7 +936,11 @@ void MainWindow::onConfigureOptions()
QPointer<ConfigureOptionsDialog> dlg = new ConfigureOptionsDialog(this, "Settings");
connect(dlg, SIGNAL(settingsChanged(const QString&)), SLOT(onSettingsChanged(const QString&)));
// FIXME: we'd normally use settingsChanged(), according to the kde api docs. however, this
// is emitted each time the user changes any of our own settings (backend, default file system), without
// applying or clicking ok. so the below is the workaround for that.
connect(dlg, SIGNAL(applyClicked()), SLOT(onSettingsChanged()));
connect(dlg, SIGNAL(okClicked()), SLOT(onSettingsChanged()));
dlg->show();
}
@ -943,4 +967,3 @@ void MainWindow::onPropertiesDevice(const QString&)
delete dlg;
}
}

View File

@ -159,7 +159,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
void onClearAllOperations();
void onConfigureOptions();
void onSettingsChanged(const QString&);
void onSettingsChanged();
void onFileSystemSupport();

View File

@ -20,6 +20,7 @@
#include "jobs/createpartitionjob.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackendpartitiontable.h"
@ -49,7 +50,7 @@ bool CreatePartitionJob::run(Report& parent)
Report* report = jobStarted(parent);
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(device().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice)
{

View File

@ -19,6 +19,7 @@
#include "jobs/createpartitiontablejob.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackend.h"
@ -44,7 +45,7 @@ bool CreatePartitionTableJob::run(Report& parent)
Report* report = jobStarted(parent);
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(device().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice != NULL)
{

View File

@ -20,6 +20,7 @@
#include "jobs/deletefilesystemjob.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackendpartitiontable.h"
@ -60,7 +61,7 @@ bool DeleteFileSystemJob::run(Report& parent)
rval = true;
else
{
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(device().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice)
{

View File

@ -20,6 +20,7 @@
#include "jobs/deletepartitionjob.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackendpartitiontable.h"
@ -56,7 +57,7 @@ bool DeletePartitionJob::run(Report& parent)
Report* report = jobStarted(parent);
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(device().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice)
{

View File

@ -23,6 +23,7 @@
#include "core/device.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackendpartitiontable.h"
@ -115,7 +116,7 @@ bool ResizeFileSystemJob::resizeFileSystemInternal(Report& report)
{
bool rval = false;
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(device().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice)
{
@ -123,9 +124,9 @@ bool ResizeFileSystemJob::resizeFileSystemInternal(Report& report)
if (backendPartitionTable)
{
connect(CoreBackend::self(), SIGNAL(progress(int)), this, SIGNAL(progress(int)));
connect(CoreBackendManager::self()->backend(), SIGNAL(progress(int)), this, SIGNAL(progress(int)));
rval = backendPartitionTable->resizeFileSystem(report, partition(), newLength());
disconnect(CoreBackend::self(), SIGNAL(progress(int)), this, SIGNAL(progress(int)));
disconnect(CoreBackendManager::self()->backend(), SIGNAL(progress(int)), this, SIGNAL(progress(int)));
if (rval)
{

View File

@ -20,6 +20,7 @@
#include "jobs/restorefilesystemjob.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackendpartitiontable.h"
@ -83,7 +84,7 @@ bool RestoreFileSystemJob::run(Report& parent)
// create a new file system for what was restored with the length of the image file
const qint64 newLastSector = targetPartition().firstSector() + copySource.length() - 1;
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(targetDevice().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(targetDevice().deviceNode());
FileSystem::Type t = FileSystem::Unknown;

View File

@ -20,6 +20,7 @@
#include "jobs/setpartflagsjob.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackendpartition.h"
#include "backend/corebackendpartitiontable.h"
@ -57,7 +58,7 @@ bool SetPartFlagsJob::run(Report& parent)
Report* report = jobStarted(parent);
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(device().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice)
{

View File

@ -20,6 +20,7 @@
#include "jobs/setpartgeometryjob.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackenddevice.h"
#include "backend/corebackendpartitiontable.h"
@ -55,7 +56,7 @@ bool SetPartGeometryJob::run(Report& parent)
Report* report = jobStarted(parent);
CoreBackendDevice* backendDevice = CoreBackend::self()->openDevice(device().deviceNode());
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice)
{

View File

@ -20,12 +20,14 @@
#include "gui/mainwindow.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "util/helpers.h"
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kmessagebox.h>
#include <kaboutdata.h>
#include <config.h>
@ -47,11 +49,8 @@ int main(int argc, char* argv[])
Config::instance("partitionmanagerrc");
if (CoreBackend::self() == NULL)
{
KMessageBox::error(NULL, i18nc("@info", "The core backend plugin could not be loaded. Please check your installation."), i18nc("@title:window", "Fatal Error: Could Not Load Backend Plugin"));
if (!loadBackend())
return 0;
}
MainWindow* mainWindow = new MainWindow();
mainWindow->show();

View File

@ -17,5 +17,8 @@
############################################
install(FILES pmcorebackendplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
add_subdirectory(libparted)
add_subdirectory(dummy)

View File

@ -15,12 +15,12 @@
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
file (GLOB pluginpmdummy_SRCS *.cpp)
file (GLOB pmdummybackendplugin_SRCS *.cpp)
kde4_add_library(pluginpmdummy SHARED ${pluginpmdummy_SRCS})
kde4_add_plugin(pmdummybackendplugin ${pmdummybackendplugin_SRCS})
target_link_libraries(pluginpmdummy partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} ${KDE4_SOLID_LIBS})
target_link_libraries(pmdummybackendplugin partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} ${KDE4_SOLID_LIBS})
set_target_properties(pluginpmdummy PROPERTIES PREFIX "")
install(TARGETS pmdummybackendplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES pmdummybackendplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(TARGETS pluginpmdummy DESTINATION ${PLUGIN_INSTALL_DIR})

View File

@ -42,7 +42,7 @@ K_PLUGIN_FACTORY(DummyBackendFactory, registerPlugin<DummyBackend>(); )
static KAboutData createPluginAboutData()
{
KAboutData about(
"dummypmplugin",
"pmdummybackendplugin",
NULL,
ki18nc("@title", "Dummy Backend Plugin"),
QString(VERSION).toUtf8(),

View File

@ -0,0 +1,16 @@
[Desktop Entry]
Encoding=UTF-8
Name=KDE Partition Manager Dummy Backend
Comment=A KDE Partition Manager dummy backend for testing purposes.
Type=Service
ServiceTypes=PartitionManager/Plugin
Icon=preferences-plugin
X-KDE-PluginInfo-Name=pmdummybackendplugin
X-KDE-PluginInfo-Author=Volker Lanz
X-KDE-PluginInfo-Email=vl@fidra.de
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-Category=BackendPlugin
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-PluginInfo-Version=1
X-KDE-PluginInfo-Website=http://www.partitionmanager.org

View File

@ -15,12 +15,11 @@
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
file (GLOB pluginpmlibparted_SRCS *.cpp)
file (GLOB pmlibpartedbackendplugin_SRCS *.cpp)
kde4_add_library(pluginpmlibparted SHARED ${pluginpmlibparted_SRCS})
kde4_add_plugin(pmlibpartedbackendplugin ${pmlibpartedbackendplugin_SRCS})
target_link_libraries(pluginpmlibparted partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} ${KDE4_SOLID_LIBS})
target_link_libraries(pmlibpartedbackendplugin partitionmanagerprivate ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} ${KDE4_SOLID_LIBS})
set_target_properties(pluginpmlibparted PROPERTIES PREFIX "")
install(TARGETS pluginpmlibparted DESTINATION ${PLUGIN_INSTALL_DIR})
install(TARGETS pmlibpartedbackendplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES pmlibpartedbackendplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})

View File

@ -56,7 +56,7 @@ K_PLUGIN_FACTORY(LibPartedBackendFactory, registerPlugin<LibPartedBackend>(); )
static KAboutData createPluginAboutData()
{
KAboutData about(
"libpartedpmplugin",
"pmlibpartedbackendplugin",
NULL,
ki18nc("@title", "LibParted Backend Plugin"),
QString("%1, libparted version: %2").arg(VERSION).arg(ped_get_version()).toUtf8(),
@ -425,7 +425,7 @@ QList<Device*> LibPartedBackend::scanDevices()
const Solid::Block* solidBlock = solidDevice.as<Solid::Block>();
Device* d = CoreBackend::self()->scanDevice(solidBlock->device());
Device* d = scanDevice(solidBlock->device());
if (d != NULL)
{

View File

@ -21,6 +21,9 @@
#include "plugins/libparted/libpartedpartition.h"
#include "plugins/libparted/libpartedbackend.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include "core/partition.h"
#include "core/device.h"
@ -291,7 +294,7 @@ bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition&
static void pedTimerHandler(PedTimer* pedTimer, void*)
{
CoreBackend::self()->emitProgress(pedTimer->frac * 100);
CoreBackendManager::self()->backend()->emitProgress(pedTimer->frac * 100);
}
bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength)

View File

@ -0,0 +1,16 @@
[Desktop Entry]
Encoding=UTF-8
Name=KDE Partition Manager LibParted Backend
Comment=The LibParted backend for KDE Partition Manager
Type=Service
ServiceTypes=PartitionManager/Plugin
Icon=preferences-plugin
X-KDE-PluginInfo-Name=pmlibpartedbackendplugin
X-KDE-PluginInfo-Author=Volker Lanz
X-KDE-PluginInfo-Email=vl@fidra.de
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-Category=BackendPlugin
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-PluginInfo-Version=1
X-KDE-PluginInfo-Website=http://www.partitionmanager.org

View File

@ -0,0 +1,5 @@
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=PartitionManager/Plugin
Name=KDE Partition Manager Plugin

View File

@ -20,6 +20,8 @@
#include "util/helpers.h"
#include "util/globallog.h"
#include "backend/corebackendmanager.h"
#include "ops/operation.h"
#include <klocale.h>
@ -179,3 +181,29 @@ void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree)
}
}
bool loadBackend()
{
if (CoreBackendManager::self()->load(Config::backend()) == false)
{
if (CoreBackendManager::self()->load(CoreBackendManager::defaultBackendName()))
{
KMessageBox::sorry(NULL,
i18nc("@info", "<para>The configured backend plugin \"%1\" could not be loaded.</para>"
"<para>Loading the default backend plugin \"%2\" instead.</para>",
Config::backend(), CoreBackendManager::defaultBackendName()),
i18nc("@title:window", "Error: Could Not Load Backend Plugin"));
Config::setBackend(CoreBackendManager::defaultBackendName());
}
else
{
KMessageBox::error(NULL,
i18nc("@info", "<para>Neither the configured (\"%1\") nor the default (\"%2\") backend "
"plugin could be loaded.</para><para>Please check your installation.</para>",
Config::backend(), CoreBackendManager::defaultBackendName()),
i18nc("@title:window", "Error: Could Not Load Backend Plugin"));
return false;
}
}
return true;
}

View File

@ -43,4 +43,6 @@ LIBPARTITIONMANAGERPRIVATE_EXPORT QIcon createFileSystemColor(FileSystem::Type t
LIBPARTITIONMANAGERPRIVATE_EXPORT void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree);
LIBPARTITIONMANAGERPRIVATE_EXPORT bool loadBackend();
#endif

View File

@ -20,6 +20,7 @@
#include "util/report.h"
#include "backend/corebackend.h"
#include "backend/corebackendmanager.h"
#include <QTextDocument>
@ -98,7 +99,7 @@ QString Report::htmlHeader()
s += "<table>\n";
s += tableLine(i18n("Date:"), KGlobal::locale()->formatDateTime(KDateTime::currentLocalDateTime()));
s += tableLine(i18n("Program version:"), KGlobal::mainComponent().aboutData()->version());
s += tableLine(i18n("Backend:"), QString("%1 (%2)").arg(CoreBackend::self()->about().programName()).arg(CoreBackend::self()->about().version()));
s += tableLine(i18n("Backend:"), QString("%1 (%2)").arg(CoreBackendManager::self()->backend()->about().programName()).arg(CoreBackendManager::self()->backend()->about().version()));
s += tableLine(i18n("KDE version:"), KDE_VERSION_STRING);
s += tableLine(i18n("Machine:"), unameString);
s += tableLine(i18n("User ID:"), QString::number(geteuid()));