add more spacing
[personal-kdebase.git] / runtime / nepomuk / services / strigi / strigiserviceadaptor.cpp
blob4d5d08dd199108a3e4f5a6b803d0ea7f6a50199e
1 /* This file is part of the KDE Project
2 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
4 Based on code generated by dbusxml2cpp version 0.6
5 dbusxml2cpp is Copyright (C) 2006 Trolltech ASA. All rights reserved.
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #include "strigiserviceadaptor.h"
23 #include "strigiservice.h"
24 #include "indexscheduler.h"
26 #include <QtCore/QUrl>
27 #include <QtCore/QDateTime>
28 #include <QtCore/QFile>
29 #include <QtCore/QDataStream>
31 #include <KDebug>
34 Nepomuk::StrigiServiceAdaptor::StrigiServiceAdaptor( IndexScheduler* scheduler, StrigiService* parent )
35 : QDBusAbstractAdaptor(parent),
36 m_indexScheduler( scheduler )
38 connect( m_indexScheduler, SIGNAL( indexingStarted() ),
39 this, SIGNAL( indexingStarted() ) );
40 connect( m_indexScheduler, SIGNAL( indexingStopped() ),
41 this, SIGNAL( indexingStopped() ) );
42 connect( m_indexScheduler, SIGNAL( indexingFolder(QString) ),
43 this, SIGNAL( indexingFolder(QString) ) );
47 Nepomuk::StrigiServiceAdaptor::~StrigiServiceAdaptor()
52 bool Nepomuk::StrigiServiceAdaptor::isIndexing()
54 // handle method call org.kde.nepomuk.Strigi.isIndexing
55 return m_indexScheduler->isIndexing();
59 bool Nepomuk::StrigiServiceAdaptor::isSuspended()
61 // handle method call org.kde.nepomuk.Strigi.isSuspended
62 return m_indexScheduler->isSuspended();
66 QString Nepomuk::StrigiServiceAdaptor::currentFolder()
68 return m_indexScheduler->currentFolder();
72 void Nepomuk::StrigiServiceAdaptor::resume()
74 // handle method call org.kde.nepomuk.Strigi.resume
75 m_indexScheduler->resume();
79 void Nepomuk::StrigiServiceAdaptor::suspend()
81 // handle method call org.kde.nepomuk.Strigi.suspend
82 m_indexScheduler->suspend();
86 void Nepomuk::StrigiServiceAdaptor::updateFolder( const QString& path )
88 m_indexScheduler->updateDir( path );
92 void Nepomuk::StrigiServiceAdaptor::updateAllFolders()
94 m_indexScheduler->updateAll();
98 void Nepomuk::StrigiServiceAdaptor::analyzeResource( const QString& uri, uint mTime, const QByteArray& data )
100 QDataStream stream( data );
101 m_indexScheduler->analyzeResource( QUrl::fromEncoded( uri.toAscii() ), QDateTime::fromTime_t( mTime ), stream );
105 void Nepomuk::StrigiServiceAdaptor::analyzeResourceFromTempFileAndDeleteTempFile( const QString& uri, uint mTime, const QString& tmpFile )
107 QFile file( tmpFile );
108 if ( file.open( QIODevice::ReadOnly ) ) {
109 QDataStream stream( &file );
110 m_indexScheduler->analyzeResource( QUrl::fromEncoded( uri.toAscii() ), QDateTime::fromTime_t( mTime ), stream );
111 file.remove();
113 else {
114 kDebug() << "Failed to open" << tmpFile;