eca1c1c3c7b2c76830b24bc871efd94fd6731902
[presencevnc] / src / main.cpp
1 /*
2     Presence VNC
3     Copyright (C) 2010 Christian Pulvermacher
4
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.
9
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.
14
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.
18 */
19 #include "mainwindow.h"
20
21 #include <QApplication>
22 #include <QString>
23
24 #include <iostream>
25
26
27 const QString APPNAME("Presence VNC");
28
29 int main(int argc, char *argv[])
30 {
31         QCoreApplication::setOrganizationName(APPNAME);
32         QCoreApplication::setApplicationName(APPNAME);
33
34         QApplication app(argc, argv);
35
36         QString url;
37         int quality = 2;
38         bool view_only = false;
39
40         QStringList arguments = QCoreApplication::arguments();
41         for(int i = 1; i < arguments.count(); i++) {
42                 if(arguments.at(i) == "--help") {
43                         std::cout << "Usage: " << qPrintable(arguments.at(0)) << " [options] [URL [quality]]\n"
44
45                                 << "\nOptions:\n"
46                                 << " --help\t\t Print this text and exit.\n"
47                                 << " --viewonly\t Don't send mouse/keyboard input to remote desktop. This is only useful if you also supply a URL.\n"
48
49                                 << "\nURLs:\n"
50                                 << " vnc://:password@server:display\n\n"
51                                 << " Password and display can be omitted, e.g. vnc://server is a valid URL.\n"
52                                 << " Optionally, you can define the quality as a second argument (1-3, where 1 is the best). Default is 2.\n";
53
54                         return 0;
55                 } else if(arguments.at(i) == "--viewonly") {
56                         view_only = true;
57                 } else { //not a valid command line option, should be the url
58                         url = arguments.at(i);
59
60                         if(arguments.count() > i+1) { //having a --quality option would make more sense.
61                                 quality = arguments.at(i+1).toInt();
62                                 i++;
63                         }
64                 }
65         }
66
67         MainWindow main(url, quality, view_only);
68         main.show();
69         return app.exec();
70 }