From fa7744f11f110ed4ed24a6270cc963abfa99a2b0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 19 Jan 2016 16:25:04 +0100 Subject: Add support for locations query --- src/command_line_options.cpp | 4 ++++ src/httpxmldownloader.cpp | 8 ++++++-- src/httpxmldownloader.h | 2 +- src/main.cpp | 8 +++++++- 4 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp index 3a9cbc5..fd72641 100644 --- a/src/command_line_options.cpp +++ b/src/command_line_options.cpp @@ -13,6 +13,7 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { {"fullscreen", no_argument, NULL, 'F'}, {"file", required_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, + {"locations", required_argument, NULL, 'l'}, {"pool", required_argument, NULL, 'P'}, {"pvs", no_argument, NULL, 'p'}, {"runscript", no_argument, NULL, 'S'}, @@ -55,6 +56,9 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { case 'P': options.insert("pool", optarg); break; + case 'l': + options.insert("locations", optarg); + break; case 'p': options.insert("pvs", "pvs"); break; diff --git a/src/httpxmldownloader.cpp b/src/httpxmldownloader.cpp index 208caf0..bebcfd0 100644 --- a/src/httpxmldownloader.cpp +++ b/src/httpxmldownloader.cpp @@ -6,8 +6,12 @@ HttpXmlDownloader::HttpXmlDownloader() { nam = new QNetworkAccessManager(this); } -QNetworkReply* HttpXmlDownloader::makeRequest(const QString& xmlurl) { - return nam->get(QNetworkRequest(QUrl(xmlurl))); +QNetworkReply* HttpXmlDownloader::makeRequest(const QString& xmlurl, const QString& locationIds) { + QUrl url(xmlurl); + if (!locationIds.isEmpty()) { + url.addQueryItem("locations", locationIds); + } + return nam->get(QNetworkRequest(url)); } void HttpXmlDownloader::connectSlot(QObject* obj, const char* slot) { diff --git a/src/httpxmldownloader.h b/src/httpxmldownloader.h index ef6444f..068a733 100644 --- a/src/httpxmldownloader.h +++ b/src/httpxmldownloader.h @@ -12,7 +12,7 @@ class HttpXmlDownloader : public QObject { QNetworkAccessManager* nam; public: HttpXmlDownloader(); - QNetworkReply* makeRequest(const QString& xmlurl); + QNetworkReply* makeRequest(const QString& xmlurl, const QString& locationIds = QString()); void connectSlot(QObject* obj, const char* slot); }; diff --git a/src/main.cpp b/src/main.cpp index 83c93de..4d0053e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,7 @@ int main(int argc, char *argv[]) { " -b --base base directory where VM images are accessible\n" " -d, --default name of default session\n" " -c, --config alternative config file\n" + " -l, --location location id(s), space separated\n" " -P, --pool one or more pool names to display (comma separated)\n" " -f, --file direct boot .desktop file\n" " -x, --xpath path of X Session .desktop files\n" @@ -204,6 +205,11 @@ int main(int argc, char *argv[]) { defaultTab = cmdOptions.value("tab").toInt(); } + QString locationIds; + if (cmdOptions.contains("locations")) { + locationIds = cmdOptions.value("locations"); + } + /* read session files */ QList xsessions(XSession::readSessions(xSessionPath)); @@ -215,7 +221,7 @@ int main(int argc, char *argv[]) { SLOT(addSessionsAfterDownload(QNetworkReply*))); // read xml and add items later - httpxmldownloader.makeRequest(urlBase + "list.php"); + httpxmldownloader.makeRequest(urlBase + "list.php", locationIds); /* DOWNLOAD NEWS */ HttpXmlDownloader news_downloader; -- cgit v1.2.3-55-g7522