summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-01-19 16:25:04 +0100
committerSimon Rettberg2016-01-19 16:25:04 +0100
commitfa7744f11f110ed4ed24a6270cc963abfa99a2b0 (patch)
tree715b458b24d0c673897bab07666fb12403105eb5
parentFix selection of last session if session was a VM (diff)
downloadvmchooser2-fa7744f11f110ed4ed24a6270cc963abfa99a2b0.tar.gz
vmchooser2-fa7744f11f110ed4ed24a6270cc963abfa99a2b0.tar.xz
vmchooser2-fa7744f11f110ed4ed24a6270cc963abfa99a2b0.zip
Add support for locations query
-rw-r--r--src/command_line_options.cpp4
-rw-r--r--src/httpxmldownloader.cpp8
-rw-r--r--src/httpxmldownloader.h2
-rw-r--r--src/main.cpp8
4 files changed, 18 insertions, 4 deletions
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<Session*> 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;