1 /**************************************************************************
2 * Copyright (C) 2005-2020 by Oleksandr Shneyder *
3 * <o.shneyder@phoca-gmbh.de> *
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 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17
18 #ifdef HAVE_CONFIG_H
19 #include <config.h>
20 #endif
21
22 #include "ongetpass.h"
23
24 #include "x2goclientconfig.h"
25
26 #include <QApplication>
27 #include <QLocale>
28
29 #ifdef CFGCLIENT
30 #include <onmainwindow.h>
31 #endif
32
33 #ifndef Q_OS_WIN
34 #include <sys/types.h>
35 #include <signal.h>
36 #endif
37
38 #if QT_VERSION < 0x050000
39 #include <QPlastiqueStyle>
40 #endif
41 #include <QMessageBox>
42 #include <iostream>
43 #include <QFile>
44 #include <QProcess>
45 #include <QLocalSocket>
46 #include "x2gologdebug.h"
47
48
49
x2goMain(int argc,char * argv[])50 int x2goMain ( int argc, char *argv[] )
51 {
52 QApplication app ( argc,argv );
53
54 #ifndef Q_WS_HILDON
55 #ifdef Q_OS_UNIX
56 #if QT_VERSION < 0x050000
57 app.setStyle ( new QPlastiqueStyle() );
58 #else
59 app.setStyle ("fusion");
60 #endif
61 #endif
62 #endif
63 QStringList args;
64 if ( argc > 1 )
65 args=app.arguments();
66 if ( args.count() >1 && args[1]=="--dialog" )
67 {
68 #ifdef CFGCLIENT
69 ONMainWindow::installTranslator();
70 #endif
71 QString type=args[2];
72 QString caption=args[4];
73 caption=caption.replace ( "NX","X2Go" );
74 QString text=args[6];
75 if ( type=="error" || type=="panic" )
76 return QMessageBox::critical ( 0, caption,text );
77 if ( type=="ok" )
78 return QMessageBox::information ( 0, caption,text );
79 if ( type=="yesno" )
80 {
81 if(text.indexOf("No response received from the remote server")!=-1 &&
82 text.indexOf("Do you want to terminate the current session")!=-1)
83 {
84 text=QObject::tr("No response received from the remote server. Do you want to terminate the current session?");
85 int rez=QMessageBox::question ( 0, caption,text,
86 QMessageBox::Yes,
87 QMessageBox::No );
88 if(rez==QMessageBox::Yes && args.count()>9)
89 {
90 #ifndef Q_OS_WIN
91 int pid=args[9].toUInt();
92 kill(pid, SIGKILL);
93 #else
94 QProcess::execute("bash -c \"kill -9 "+args[9]+"\"");
95 #endif
96 }
97 return rez;
98 }
99 else
100 return QMessageBox::question ( 0, caption,text,
101 QMessageBox::Yes,
102 QMessageBox::No );
103 }
104 return -1;
105 }
106
107 #ifdef CFGCLIENT
108 else
109 {
110 ONMainWindow* mw = new ONMainWindow;
111 mw->show();
112 int retval;
113 app.setQuitOnLastWindowClosed(false);
114 retval = app.exec();
115 delete mw;
116 return retval;
117 }
118 #endif
119 return 0;
120 }
121
122
123
124
125
126
127