1
/* This file is part of Clementine.
2
Copyright 2011, David Sansome <me@davidsansome.com>
4
Clementine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
9
Clementine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef CLEMENTINERUNNER_H
19
#define CLEMENTINERUNNER_H
21
#include "src/globalsearch/common.h"
25
#include <Plasma/AbstractRunner>
27
class OrgClementineplayerGlobalSearchInterface;
29
class ClementineRunner : public Plasma::AbstractRunner {
33
ClementineRunner(QObject* parent, const QVariantList& args);
35
static const char* kDbusService;
36
static const char* kDbusPath;
38
void match(Plasma::RunnerContext& context);
39
void run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& match);
42
void ResultsAvailable(int id, GlobalSearchServiceResultList results);
43
void SearchFinished(int id);
44
void ArtLoaded(int result_id, const QByteArray& image_data);
50
finished_signal_emitted_(false),
54
// The main thread is the only one to access these variables.
56
GlobalSearchServiceResultList results_waiting_for_art_;
57
bool finished_signal_emitted_;
59
// This list contains results that are finished and waiting to be processed
60
// by the match() thread. results_mutex_ locks results_ and
61
// results_semaphore_ is released once for each result.
62
GlobalSearchServiceResultList results_;
63
QMutex results_mutex_;
64
QSemaphore results_semaphore_;
67
typedef QMap<int, PendingQuery*> PendingMap;
69
qreal ResultRelevance(const GlobalSearchServiceResult& result) const;
70
void FillMatch(const GlobalSearchServiceResult& result,
71
Plasma::QueryMatch* match) const;
74
OrgClementineplayerGlobalSearchInterface* interface_;
78
// pending_mutex_ locks any access to the PendingMap.
79
QMutex pending_mutex_;
80
PendingMap pending_queries_;
83
#endif // CLEMENTINERUNNER_H