delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / nepomuk / services / strigi / strigiservice.cpp
blobfe240c8fe18b31b1d40c67daad726e9d5abdc4f0
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.
19 #include "strigiservice.h"
20 #include "strigiserviceadaptor.h"
21 #include "priority.h"
22 #include "indexscheduler.h"
23 #include "eventmonitor.h"
24 #include "systray.h"
25 #include "config.h"
26 #include "statuswidget.h"
27 #include "nepomukstorageinterface.h"
29 #include <KDebug>
31 #include <strigi/indexpluginloader.h>
32 #include <strigi/indexmanager.h>
34 #include <nepomuk/resourcemanager.h>
37 Nepomuk::StrigiService::StrigiService( QObject* parent, const QList<QVariant>& )
38 : Service( parent, true )
40 // only so ResourceManager won't open yet another connection to the nepomuk server
41 ResourceManager::instance()->setOverrideMainModel( mainModel() );
43 // lower process priority - we do not want to spoil KDE usage
44 // ==============================================================
45 if ( !lowerPriority() )
46 kDebug() << "Failed to lower priority.";
47 if ( !lowerSchedulingPriority() )
48 kDebug() << "Failed to lower scheduling priority.";
49 if ( !lowerIOPriority() )
50 kDebug() << "Failed to lower io priority.";
52 // Using Strigi with the redland backend is torture.
53 // Thus we simply fail initialization if it is used
54 // ==============================================================
55 if ( org::kde::nepomuk::Storage( "org.kde.NepomukStorage",
56 "/nepomukstorage",
57 QDBusConnection::sessionBus() )
58 .usedSopranoBackend().value() != QString::fromLatin1( "redland" ) ) {
59 // setup the actual index scheduler including strigi stuff
60 // ==============================================================
61 if ( ( m_indexManager = Strigi::IndexPluginLoader::createIndexManager( "sopranobackend", 0 ) ) ) {
62 m_indexScheduler = new IndexScheduler( m_indexManager, this );
64 ( void )new EventMonitor( m_indexScheduler, this );
65 ( void )new StrigiServiceAdaptor( m_indexScheduler, this );
66 StatusWidget* sw = new StatusWidget( mainModel(), m_indexScheduler );
67 ( new SystemTray( m_indexScheduler, sw ) )->show();
69 m_indexScheduler->start();
71 else {
72 kDebug() << "Failed to load sopranobackend Strigi index manager.";
76 // service initialization done if creating a strigi index manager was successful
77 // ==============================================================
78 setServiceInitialized( m_indexManager != 0 );
80 else {
81 kDebug() << "Will not start when using redland Soprano backend due to horrible performance.";
82 setServiceInitialized( false );
87 Nepomuk::StrigiService::~StrigiService()
89 if ( m_indexManager ) {
90 m_indexScheduler->stop();
91 m_indexScheduler->wait();
92 Strigi::IndexPluginLoader::deleteIndexManager( m_indexManager );
97 #include <kpluginfactory.h>
98 #include <kpluginloader.h>
100 NEPOMUK_EXPORT_SERVICE( Nepomuk::StrigiService, "nepomukstrigiservice" )
102 #include "strigiservice.moc"