1 /* This file is part of the KDE Project
2 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
20 #include "nepomukcore.h"
22 #include <QtDBus/QDBusConnection>
23 #include <QtCore/QFile>
27 #include <KStandardDirs>
29 #include <Soprano/Backend>
31 #include <kpluginfactory.h>
32 #include <kpluginloader.h>
34 NEPOMUK_EXPORT_SERVICE( Nepomuk::Storage
, "nepomukstorage" )
37 Nepomuk::Storage::Storage( QObject
* parent
, const QList
<QVariant
>& )
38 : Service( parent
, true /* delayed initialization */ )
40 QDBusConnection::sessionBus().registerService( "org.kde.NepomukStorage" );
42 m_core
= new Core( this );
43 connect( m_core
, SIGNAL( initializationDone(bool) ),
44 this, SLOT( slotNepomukCoreInitialized(bool) ) );
49 Nepomuk::Storage::~Storage()
54 void Nepomuk::Storage::slotNepomukCoreInitialized( bool success
)
57 kDebug() << "Successfully initialized nepomuk core";
59 // the core is initialized. Export it to the clients.
60 // the D-Bus interface
61 m_core
->registerAsDBusObject();
63 // the faster local socket interface
64 QString socketPath
= KGlobal::dirs()->locateLocal( "data", "nepomuk/socket" );
65 QFile::remove( socketPath
); // in case we crashed
66 m_core
->start( socketPath
);
69 kDebug() << "Failed to initialize nepomuk core";
72 setServiceInitialized( success
);
76 void Nepomuk::Storage::optimize( const QString
& repo
)
78 m_core
->optimize( repo
);
82 QString
Nepomuk::Storage::usedSopranoBackend() const
84 // FIXME: this is only partly true. It is perfectly possible to change the backend only
85 // for the main repo in the config file
86 return Repository::activeSopranoBackend()->pluginName();
89 #include "storage.moc"