1/****************************************************************************
2**
3** Copyright (C) 2001-2003 Tim Jansen <tim@tjansen.de>
4** Copyright (C) 2007 - 2012 Urs Wolfer <uwolfer @ kde.org>
5**
6** This file is part of KDE.
7**
8** This program is free software; you can redistribute it and/or modify
9** it under the terms of the GNU General Public License as published by
10** the Free Software Foundation; either version 2 of the License, or
11** (at your option) any later version.
12**
13** This program is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** GNU General Public License for more details.
17**
18** You should have received a copy of the GNU General Public License
19** along with this program; see the file COPYING. If not, write to
20** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21** Boston, MA 02110-1301, USA.
22**
23****************************************************************************/
24
25#include "mainwindow.h"
26
27#include <KApplication>
28#include <KLocale>
29#include <KCmdLineArgs>
30#include <KAboutData>
31#include <KDebug>
32
33#include <QTime>
34
35int main(int argc, char **argv)
36{
37 QTime startupTimer;
38 startupTimer.start();
39 KAboutData aboutData("krdc", 0, ki18n("KRDC"), KDE_VERSION_STRING,
40 ki18n("KDE Remote Desktop Client"), KAboutData::License_GPL,
41 ki18n("(c) 2007-2013, Urs Wolfer\n"
42 "(c) 2001-2003, Tim Jansen\n"
43 "(c) 2002-2003, Arend van Beelen jr.\n"
44 "(c) 2000-2002, Const Kaplinsky\n"
45 "(c) 2000, Tridia Corporation\n"
46 "(c) 1999, AT&T Laboratories Boston\n"
47 "(c) 1999-2003, Matthew Chapman\n"
48 "(c) 2009, Collabora Ltd"));
49
50 aboutData.addAuthor(ki18n("Urs Wolfer"), ki18n("Developer, Maintainer"), "uwolfer@kde.org");
51 aboutData.addAuthor(ki18n("Tony Murray"), ki18n("Developer"), "murraytony@gmail.com");
52 aboutData.addAuthor(ki18n("Tim Jansen"), ki18n("Former Developer"), "tim@tjansen.de");
53 aboutData.addAuthor(ki18n("Arend van Beelen jr."), ki18n("Initial RDP backend"), "arend@auton.nl");
54 aboutData.addCredit(ki18n("Brad Hards"), ki18n("Google Summer of Code 2007 KRDC project mentor"),
55 "bradh@frogmouth.net");
56 aboutData.addCredit(ki18n("LibVNCServer / LibVNCClient developers"), ki18n("VNC client library"),
57 "libvncserver-common@lists.sf.net", "http://libvncserver.sourceforge.net/");
58 aboutData.addAuthor(ki18n("Abner Silva"), ki18n("Telepathy Tubes Integration"), "abner.silva@kdemail.net");
59
60 KCmdLineArgs::init(argc, argv, &aboutData);
61
62 KCmdLineOptions options;
63 options.add("fullscreen", ki18n("Start KRDC with the provided URL in fullscreen mode (works only with one URL)"));
64 options.add("!+[URL]", ki18n("URLs to connect after startup"));
65
66 KCmdLineArgs::addCmdLineOptions(options);
67
68 KApplication app;
69
70 MainWindow *mainwindow = new MainWindow;
71 mainwindow->show();
72
73 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
74
75 if (args->count() > 0) {
76 for (int i = 0; i < args->count(); ++i) {
77 KUrl u(args->url(i));
78
79 if (u.scheme().isEmpty() || u.host().isEmpty()) { // unusable url; try to recover it...
80 QString arg(args->url(i).url());
81
82 kDebug(5010) << "unusable url; try to recover it:" << arg;
83
84 if (arg.lastIndexOf('/') != 0)
85 arg = arg.right(arg.length() - arg.lastIndexOf('/') - 1);
86
87 if (!arg.contains("://"))
88 arg.prepend("vnc://"); // vnc was default in kde3 times...
89
90 kDebug(5010) << "recovered url:" << arg;
91
92 u = arg;
93 }
94
95 if (!u.isValid())
96 continue;
97
98 mainwindow->newConnection(u, ((args->isSet("fullscreen")) && (args->count() == 1)));
99 }
100 }
101
102 kDebug(5010) << "########## KRDC ready:" << startupTimer.elapsed() << "ms ##########";
103
104 return app.exec();
105}
106