1
/* This file is part of Strigi Desktop Search
3
* Copyright (C) 2008 Jos van den Oever <jos@vandenoever.info>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public License
16
* along with this library; see the file COPYING.LIB. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
20
#include "xesamlistener.h"
21
#include "xesam/xesamdbus.h"
22
#include <QtCore/QDebug>
23
#include <QtCore/QTimer>
24
#include <QtCore/QTime>
26
XesamListener::XesamListener(OrgFreedesktopXesamSearchInterface* xesam)
28
connect(xesam, SIGNAL(HitsAdded(const QString&, uint)),
29
this, SLOT(slotHitsAdded(const QString&, uint)));
30
connect(xesam, SIGNAL(HitsRemoved(const QString &, const QList<uint> &)),
31
this, SLOT(slotHitsRemoved(const QString &, const QList<uint> &)));
32
connect(xesam, SIGNAL(SearchDone(const QString&)),
33
this, SLOT(slotSearchDone(const QString&)));
34
connect(xesam, SIGNAL(StateChanged(const QStringList&)),
35
this, SLOT(slotStateChanged(const QStringList&)));
38
XesamListener::waitForSearchToFinish(const QString& searchid,
39
int millisecondtimeout) {
42
int left = millisecondtimeout;
43
bool finished = finishedSearches.contains(searchid);
44
while (left > 0 && !finished) {
45
QTimer::singleShot(left, &eventloop, SLOT(quit()));
47
left = millisecondtimeout - time.elapsed();
48
finished = finishedSearches.contains(searchid);
53
XesamListener::getNumberOfReportedHits(const QString& searchid) const {
54
return hitsReported.value(searchid);
57
XesamListener::slotHitsAdded(const QString &search, uint count) {
58
hitsReported[search] += count;
62
XesamListener::slotHitsModified(const QString &search,
63
const QList<uint> &hit_ids) {
67
XesamListener::slotHitsRemoved(const QString &search,
68
const QList<uint> &hit_ids) {
72
XesamListener::slotSearchDone(const QString &search) {
73
finishedSearches.append(search);
77
XesamListener::slotStateChanged(const QStringList &state_info) {