3 Copyright (C) 2010 Christian Pulvermacher
5 This program 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 2 of the License, or
8 (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 along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "mainwindow.h"
21 #include <QApplication>
27 const QString APPNAME("Presence VNC");
30 std::cout << "Usage: " << qPrintable(QCoreApplication::arguments().at(0)) << " [options] [URL [quality]]\n"
33 << " --help\t\t Print this text and exit.\n"
34 << " --viewonly\t Don't send mouse/keyboard input to remote desktop. This is only useful if you also supply a URL.\n"
37 << " vnc://:password@server:display\n\n"
38 << " Password and display can be omitted, e.g. vnc://server is a valid URL.\n"
39 << " Optionally, you can define the quality as a second argument (1-3, where 1 is the best). Default is 2.\n";
42 int main(int argc, char *argv[])
44 QCoreApplication::setOrganizationName(APPNAME);
45 QCoreApplication::setApplicationName(APPNAME);
47 QApplication app(argc, argv);
51 bool view_only = false;
53 QStringList arguments = QCoreApplication::arguments();
54 for(int i = 1; i < arguments.count(); i++) {
55 if(arguments.at(i) == "--help") {
59 } else if(arguments.at(i) == "--viewonly") {
61 } else { //not a valid command line option, should be the url
62 url = arguments.at(i);
65 if(!url.startsWith("vnc://")) {
66 std::cerr << "\"" << qPrintable(url) << "\" is not a valid command line option!\n\n";
72 if(arguments.count() > i+1) { //having a --quality option would make more sense.
73 int arg = arguments.at(i+1).toInt();
74 if(1 <= arg and arg <= 3) { //check if arg is valid, might also be another option
82 MainWindow main(url, quality, view_only);