turn the libparted backend into a plugin
svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1097425
This commit is contained in:
parent
60e6c1b109
commit
c7bc3368e4
|
@ -17,9 +17,12 @@
|
|||
|
||||
############################################
|
||||
|
||||
add_subdirectory(backend/libparted)
|
||||
|
||||
############################################
|
||||
|
||||
file(GLOB partitionmanagerprivate_SRCS
|
||||
backend/*.cpp
|
||||
backend/libparted/*.cpp
|
||||
core/*.cpp
|
||||
util/*.cpp
|
||||
ops/*.cpp
|
||||
|
@ -36,7 +39,7 @@ kde4_add_kcfg_files(partitionmanagerprivate_SRCS config.kcfgc)
|
|||
|
||||
kde4_add_library(partitionmanagerprivate SHARED ${partitionmanagerprivate_SRCS})
|
||||
|
||||
target_link_libraries(partitionmanagerprivate libfatlabel ${KDE4_KDECORE_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${LIBPARTED_LIBS} ${UUID_LIBRARIES} ${BLKID_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS})
|
||||
target_link_libraries(partitionmanagerprivate libfatlabel ${KDE4_KDECORE_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${UUID_LIBRARIES} ${BLKID_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS})
|
||||
|
||||
install(TARGETS partitionmanagerprivate ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
|
|
|
@ -18,14 +18,31 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include "backend/corebackend.h"
|
||||
#include "backend/libparted/libpartedbackend.h"
|
||||
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
static const char pluginName[] = "pluginpmlibparted";
|
||||
|
||||
CoreBackend* CoreBackend::self()
|
||||
{
|
||||
// This could be used to load any kind of backend if there were more than one
|
||||
// to choose from. So right now it's just loading the parted plugin and returning
|
||||
// it.
|
||||
static CoreBackend* instance = NULL;
|
||||
|
||||
if (instance == NULL)
|
||||
instance = new LibPartedBackend();
|
||||
{
|
||||
KPluginLoader loader(pluginName);
|
||||
|
||||
KPluginFactory* factory = loader.factory();
|
||||
|
||||
if (factory != NULL)
|
||||
instance = factory->create<CoreBackend>(NULL);
|
||||
else
|
||||
kWarning() << "Could not load instance plugin for core backend: " << loader.errorString();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -23,12 +23,15 @@
|
|||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class CoreBackendDevice;
|
||||
class Device;
|
||||
class QString;
|
||||
|
||||
class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend
|
||||
class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(CoreBackend)
|
||||
|
||||
protected:
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# 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
|
||||
|
||||
file (GLOB pluginpmlibparted_SRCS *.cpp)
|
||||
|
||||
kde4_add_library(pluginpmlibparted SHARED ${pluginpmlibparted_SRCS})
|
||||
|
||||
target_link_libraries(pluginpmlibparted 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})
|
|
@ -41,11 +41,15 @@
|
|||
#include <klocale.h>
|
||||
#include <kmountpoint.h>
|
||||
#include <kdiskfreespaceinfo.h>
|
||||
#include <kpluginfactory.h>
|
||||
|
||||
#include <parted/parted.h>
|
||||
#include <unistd.h>
|
||||
#include <blkid/blkid.h>
|
||||
|
||||
K_PLUGIN_FACTORY(LibPartedBackendFactory, registerPlugin<LibPartedBackend>(); )
|
||||
K_EXPORT_PLUGIN(LibPartedBackendFactory("pluginpmlibparted"))
|
||||
|
||||
static const LibPartedBackend::FlagMap flagmap[] =
|
||||
{
|
||||
{ PED_PARTITION_BOOT, PartitionTable::FlagBoot },
|
||||
|
@ -328,7 +332,7 @@ static void scanDevicePartitions(PedDevice* pedDevice, Device& d, PedDisk* pedDi
|
|||
}
|
||||
|
||||
/** Constructs a LibParted object. */
|
||||
LibPartedBackend::LibPartedBackend() :
|
||||
LibPartedBackend::LibPartedBackend(QObject*, const QList<QVariant>&) :
|
||||
CoreBackend()
|
||||
{
|
||||
ped_exception_set_handler(pedExceptionHandler);
|
||||
|
|
|
@ -29,10 +29,12 @@
|
|||
|
||||
#include <parted/parted.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
#include <qglobal.h>
|
||||
|
||||
class Device;
|
||||
|
||||
class KPluginFactory;
|
||||
class QString;
|
||||
|
||||
/** @brief Device scanning done by libparted.
|
||||
|
@ -43,7 +45,7 @@ class QString;
|
|||
*/
|
||||
class LibPartedBackend : public CoreBackend
|
||||
{
|
||||
friend class CoreBackend;
|
||||
friend class KPluginFactory;
|
||||
|
||||
Q_DISABLE_COPY(LibPartedBackend)
|
||||
|
||||
|
@ -55,7 +57,7 @@ class LibPartedBackend : public CoreBackend
|
|||
} FlagMap;
|
||||
|
||||
private:
|
||||
LibPartedBackend();
|
||||
LibPartedBackend(QObject* parent, const QList<QVariant>& args);
|
||||
|
||||
public:
|
||||
static const FlagMap* flagMap();
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -19,10 +19,13 @@
|
|||
|
||||
#include "gui/mainwindow.h"
|
||||
|
||||
#include "backend/corebackend.h"
|
||||
|
||||
#include "util/helpers.h"
|
||||
|
||||
#include <kapplication.h>
|
||||
#include <kcmdlineargs.h>
|
||||
#include <kmessagebox.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -40,6 +43,13 @@ int main(int argc, char* argv[])
|
|||
if (!checkPermissions())
|
||||
return 0;
|
||||
|
||||
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"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
MainWindow* mainWindow = new MainWindow();
|
||||
mainWindow->show();
|
||||
|
||||
|
|
Loading…
Reference in New Issue