1 // Copyright 2010 Jochen Becher
3 // This file is part of MovieSchedule.
5 // MovieSchedule is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // MovieSchedule 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
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with MovieSchedule. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef ABSTRACTSEARCHCLIENT_H
19 #define ABSTRACTSEARCHCLIENT_H
22 #include <QNetworkAccessManager>
23 #include <QNetworkReply>
26 class AbstractSearchClient : public QObject
30 static const int INVALID_SEARCH_TASK_ID = -1;
33 explicit AbstractSearchClient(QObject *parent = 0);
34 virtual ~AbstractSearchClient();
36 int GetSearchTaskId() const { return _search_task_id; }
39 int GetStartIndex() { return _start; }
41 virtual void Search(const QUrl &url, int start);
44 Q_SIGNAL void SearchStarted(int search_task_id);
45 Q_SIGNAL void Progress(int search_task_id, qint64, qint64);
46 Q_SIGNAL void Reply(int search_task_id, bool intermediate);
47 Q_SIGNAL void Error(int search_task_id);
48 Q_SIGNAL void Cancelled(int search_task_id);
49 Q_SIGNAL void SearchFinished(int search_task_id, bool success);
52 Q_SLOT virtual void ReplyFinished(QNetworkReply *) = 0;
53 Q_SLOT virtual void DownloadProgress(qint64, qint64);
54 Q_SLOT virtual void NetworkError(QNetworkReply::NetworkError);
57 void FixLocation(QUrl *url);
60 QNetworkAccessManager *_network;
61 static QMutex _next_search_task_id_mutex;
62 static int _next_search_task_id;
68 #endif // ABSTRACTSEARCHCLIENT_H