Add helpers for suggesting torrent paths
[qBittorrent.git] / src / webui / api / searchcontroller.h
blob78e70e759c3723451e74fadc06b44f83c17783be
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2018 Thomas Piccirello <thomas.piccirello@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program 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 this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
29 #pragma once
31 #include <memory>
33 #include <QtContainerFwd>
34 #include <QHash>
35 #include <QSet>
37 #include "base/search/searchpluginmanager.h"
38 #include "apicontroller.h"
40 class QJsonArray;
41 class QJsonObject;
43 struct SearchResult;
45 class SearchController : public APIController
47 Q_OBJECT
48 Q_DISABLE_COPY_MOVE(SearchController)
50 public:
51 using APIController::APIController;
53 private slots:
54 void startAction();
55 void stopAction();
56 void statusAction();
57 void resultsAction();
58 void deleteAction();
59 void pluginsAction();
60 void installPluginAction();
61 void uninstallPluginAction();
62 void enablePluginAction();
63 void updatePluginsAction();
65 private:
66 const int MAX_CONCURRENT_SEARCHES = 5;
68 void checkForUpdatesFinished(const QHash<QString, PluginVersion> &updateInfo);
69 void checkForUpdatesFailed(const QString &reason);
70 int generateSearchId() const;
71 QJsonObject getResults(const QList<SearchResult> &searchResults, bool isSearchActive, int totalResults) const;
72 QJsonArray getPluginsInfo(const QStringList &plugins) const;
74 QSet<int> m_activeSearches;
75 QHash<int, std::shared_ptr<SearchHandler>> m_searchHandlers;