1
/**************************************************************************
2
* Copyright (C) 2005-2015 by Oleksandr Shneyder *
3
* o.shneyder@phoca-gmbh.de *
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. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
16
***************************************************************************/
18
#ifndef ONMAINWINDOW_H
19
#define ONMAINWINDOW_H
22
#include <QMetaClassInfo>
23
#include <qtbrowserplugin.h>
26
#include <ActiveQt/QAxBindable>
27
#include <ActiveQt/QAxFactory>
28
#include <qt_windows.h>
33
#include "x2goclientconfig.h"
34
//#include "CallbackInterface.h"
35
#include <QMainWindow>
37
#include <QPushButton>
41
#include "LDAPSession.h"
43
#include <QSystemTrayIcon>
44
#include "sshmasterconnection.h"
53
@author Oleksandr Shneyder
56
#if defined(CFGPLUGIN) && defined(Q_OS_LINUX)
57
class QX11EmbedContainer;
77
class SshMasterConnection;
79
class QStandardItemModel;
80
class HttpBrokerClient;
84
class SessionExplorer;
91
static bool lessThen ( user u1,user u2 )
93
return u1.uid < u2.uid;
112
bool operator < ( const struct serv it )
114
return ( it.sess < sess );
116
static bool lt ( const struct serv it, const struct serv it1 )
118
return it.sess<it1.sess;
129
enum {MULTIMEDIA, DEVELOPMENT, EDUCATION, GAME,
130
GRAPHICS, NETWORK, OFFICE,
131
SETTINGS, SYSTEM, UTILITY, OTHER, TOP
133
static bool lessThen(Application t1, Application t2)
135
return (t1.name.compare(t2.name,Qt::CaseInsensitive)<0);
155
enum {DESKTOP,ROOTLESS,SHADOW} sessionType;
157
void operator = ( const x2goSession& s );
166
QString brokerUserId;
168
QString sshBrokerBin;
169
bool brokerAuthenticated;
171
bool brokerAutologin;
172
bool brokerAutologoff;
174
QString brokerSshKey;
175
QString brokerCaCertFile;
178
QString serverIp;//Can be different from server (use for loadballancing)
184
QString connectionts;
187
bool checkexitstatus;
195
//if true - use cfg values, else default or client settings
215
SshMasterConnection::ProxyType proxyType;
219
QString proxypassword;
236
//wrapper to send mouse events under windows in embedded mode
238
class WWrapper : public QPushButton
240
friend class ONMainWindow;
245
class WinServerStarter: public QThread
248
enum daemon {X,SSH,PULSE};
249
WinServerStarter ( daemon server, ONMainWindow * par );
253
ONMainWindow* parent;
258
class SessTreeView : public QTreeView
263
SessTreeView ( QWidget* parent = 0 ) : QTreeView ( parent ) {}
265
virtual void selectionChanged ( const QItemSelection& selected,
266
const QItemSelection& deselected ) {
267
emit this->selected ( currentIndex() );
268
QTreeView::selectionChanged ( selected, deselected );
272
void selected ( const QModelIndex& index );
277
class ONMainWindow : public QMainWindow
279
, public QtNPBindable
286
friend class HttpBrokerClient;
287
friend class SessionButton;
289
Q_PROPERTY ( QString x2goconfig READ x2goconfig WRITE setX2goconfig )
290
Q_CLASSINFO ( "ClassID", "{5a20006d-118f-4185-9653-9f98958a0008}" )
291
Q_CLASSINFO ( "InterfaceID", "{2df000ba-da4f-4fb7-8f35-b8dfbf80009a}" )
292
Q_CLASSINFO ( "EventsID", "{44900013-f8bd-4d2e-a2cf-eab407c03005}" )
293
Q_CLASSINFO ( "MIME",
294
"application/x2go:x2go:Configuration File "
296
Q_CLASSINFO ( "ToSuperClass", "ONMainWindow" )
297
Q_CLASSINFO ( "DefaultProperty","x2goconfig" )
337
static bool debugging;
339
static bool portable;
340
ONMainWindow ( QWidget *parent = 0 );
342
static void installTranslator();
343
QString iconsPath ( QString fname );
344
static bool isServerRunning ( int port );
345
void startNewSession();
346
void suspendSession ( QString sessId );
347
bool termSession ( QString sessId,
349
void setStatStatus ( QString status=QString::null );
350
x2goSession getNewSessionFromString ( const QString& string );
352
long findWindow ( QString text );
361
QString retLdapServer()
373
QString retLdapServer1()
381
QString retLdapServer2()
389
QHBoxLayout* mainLayout()
393
QWidget* mainWidget()
395
return ( QWidget* ) fr;
398
static bool getPortable()
402
static QString getHomeDirectory()
406
bool getShowAdvOption()
408
return config.showextconfig;
414
QString getCardLogin()
418
QString getDefaultCmd()
422
QString getDefaultSshPort()
424
return defaultSshPort;
426
QString getDefaultClipboardMode()
428
return defaultClipboardMode;
430
QString getDefaultKbdType()
432
return defaultKbdType;
434
QStringList getDefaultLayout()
436
return defaultLayout;
438
QString getDefaultPack()
442
int getDefaultQuality()
444
return defaultQuality;
452
bool getDefaultSetDPI()
454
return defaultSetDPI;
466
int getDefaultWidth()
470
int getDefaultHeight()
472
return defaultHeight;
474
bool getDefaultSetKbd()
476
return defaultSetKbd;
478
bool getDefaultUseSound()
480
return defaultUseSound;
482
bool getDefaultFullscreen()
484
return defaultFullscreen;
486
bool sessionEditEnabled()
488
return !noSessionEdit;
490
const QList<Application>& getApplications()
494
static QString getSessionConf()
498
bool getHideFolderSharing()
500
return hideFolderSharing;
503
SessionExplorer* getSessionExplorer()
505
return sessionExplorer;
518
QScrollArea* getUsersArea()
523
QFrame* getUsersFrame()
528
IMGFrame* getCentralFrame()
533
ConfigFile* getConfig()
538
void runApplication(QString exec);
541
SshMasterConnection* findServerSshConnection(QString host);
545
void showTextFile(QString file, QString title);
547
void showChangelog();
549
void exportDirs ( QString exports,bool removable=false );
551
void setWidgetStyle ( QWidget* widget );
552
QStringList internApplicationsNames()
554
return _internApplicationsNames;
556
QStringList transApplicationsNames()
558
return _transApplicationsNames;
560
QString transAppName ( const QString& internAppName,
562
QString internAppName ( const QString& transAppName,
564
void setEmbedSessionActionsEnabled ( bool enable );
566
QSize getEmbedAreaSize();
568
static QString cygwinPath ( const QString& winPath );
571
static bool haveCygwinEntry();
572
static void removeCygwinEntry();
573
static QString U3DevicePath()
581
QString m_x2goconfig;
582
QStringList _internApplicationsNames;
583
QStringList _transApplicationsNames;
584
QString portableDataPath;
585
QString proxyErrString;
591
bool closeDisconnect;
594
bool hideFolderSharing;
595
bool brokerNoauthWithSessionUsername;
596
bool defaultUseSound;
597
bool defaultXinerama;
605
bool changeBrokerPass;
609
QString statusString;
610
QString autostartApp;
616
bool defaultFullscreen;
625
bool resumeAfterSuspending;
627
QString clientSshPort;
628
QString defaultSshPort;
629
QVBoxLayout* selectSesDlgLayout;
630
SshMasterConnection* sshConnection;
631
QList<SshMasterConnection*> serverSshConnections;
635
QString shadowDisplay;
637
QStringList defaultLayout;
638
QString selectedLayout;
639
QString defaultKbdType;
640
QString defaultClipboardMode;
644
QStringList listedSessions;
646
QString localGraphicPort;
647
static QString homeDir;
649
QList<serv> x2goServers;
650
QList<Application> applications;
651
QList<sshKey> cmdSshKeys;
652
bool forceToShowTrayicon; //true if --tray-icon passed in command line
657
QPushButton* bShadow;
658
QPushButton* bShadowView;
659
QPushButton* bCancel;
662
QLabel* selectSessionLabel;
663
SessTreeView* sessTv;
665
QLineEdit* desktopFilter;
666
QCheckBox* desktopFilterCb;
668
SessionExplorer* sessionExplorer;
674
ClickLineEdit* login;
680
SVGFrame *selectSessionDlg;
681
SVGFrame *sessionStatusDlg;
687
QLabel* layoutPrompt;
693
QString readExportsFrom;
694
QString readLoginsFrom;
701
QPushButton* sCancel;
703
QString kdeIconsPath;
708
QList<UserButton*> names;
709
UserButton* lastUser;
713
QString selectedCommand;
717
QTimer *agentCheckTimer;
719
QTimer *proxyWinTimer;
720
QTimer *xineramaTimer;
722
QRect lastDisplayGeometry;
723
QList <QRect> xineramaScreens;
724
QStyle* widgetExtraStyle;
728
bool embedControlChanged;
732
QStandardItemModel* model;
733
QStandardItemModel* modelDesktop;
736
QAction *act_abclient;
737
QAction *act_support;
738
QAction *act_shareFolder;
739
QAction *act_showApps;
740
QAction *act_suspend;
741
QAction *act_terminate;
742
QAction *act_reconnect;
743
QAction *act_embedContol;
744
QAction *act_embedToolBar;
745
QAction *act_changeBrokerPass;
746
QAction *act_testCon;
747
QList <QAction*> topActions;
751
QString sessionStatus;
754
QHBoxLayout* username;
755
QList <user> userList;
756
QList <directory> exportDir;
760
static QString sessionCfg;
762
QProcess* soundServer;
769
bool proxyWinEmbedded;
783
int startSessSndSystem;
789
bool fsExportKeyReady;
800
QString supportMenuFile;
806
bool LDAPSndStartServer;
808
bool LDAPPrintSupport;
812
QAction *act_sessicon;
819
PROCESS_INFORMATION sshd;
821
static QString u3Device;
824
QString pulseVersionTestOutput;
825
QProcess* pulseVersionTest;
826
bool pulseVersionIsLegacy;
827
QProcess* pulseServer;
828
QStringList pulseArgs;
832
bool winServersReady;
840
QString pulseBaseDir;
841
QString pulseRuntimeDir;
842
QString pulseCookieArg;
845
bool maximizeProxyWin;
848
QTimer* xorgLogTimer;
852
QString lastFreeServer;
855
int localDisplayNumber;
861
QList<x2goSession> selectedSessions;
862
QStringList selectedDesktops;
863
x2goSession resumingSession;
866
bool runRemoteCommand;
873
HttpBrokerClient* broker;
876
#if defined ( Q_OS_WIN) //&& defined (CFGCLIENT )
878
bool startXorgOnStart;
880
enum {VCXSRV, XMING} internalX;
883
QString xorgWinOptions;
884
QString xorgFSOptions;
885
QString xorgSAppOptions;
886
enum {WIN,FS,SAPP} xorgMode;
897
// Tray icon stuff based on patch from Joachim Langenbach <joachim@falaba.de>
898
QSystemTrayIcon *trayIcon;
900
QMenu *trayIconActiveConnectionMenu;
902
QAction* appSeparator;
903
QMenu* appMenu[Application::OTHER+1];
912
QString findSshKeyForServer(QString user, QString server, QString port);
914
void showPass ( UserButton* user );
917
QString defaultSessionName;
918
QString defaultSessionId;
919
QString defaultUserName;
921
QString getKdeIconsPath();
922
QString findTheme ( QString theme );
923
bool initLdapSession ( bool showBox=true );
924
bool startSession ( const QString& id );
925
x2goSession getSessionFromString ( const QString& string );
926
void resumeSession ( const x2goSession& s );
927
void selectSession ( QStringList& sessions );
928
x2goSession getSelectedSession();
929
bool parseParameter ( QString param );
930
bool linkParameter ( QString value );
931
bool clipboardParameter ( QString value );
932
bool geometry_par ( QString value );
933
bool setKbd_par ( QString value );
934
bool ldapParameter ( QString value );
935
bool ldap1Parameter ( QString value );
936
bool ldap2Parameter ( QString value );
937
bool packParameter ( QString value );
938
bool soundParameter ( QString val );
939
void printError ( QString param );
940
void exportDefaultDirs();
941
QString createRSAKey();
942
directory* getExpDir ( QString key );
943
bool findInList ( const QString& uid );
944
void setUsersEnabled ( bool enable );
945
void externalLogout ( const QString& logoutDir );
946
void externalLogin ( const QString& loginDir );
947
void startGPGAgent ( const QString& login,
948
const QString& appId );
950
void continueNormalSession();
951
void continueLDAPSession();
952
SshMasterConnection* startSshConnection ( QString host, QString port,
953
bool acceptUnknownHosts, QString login,
954
QString password, bool autologin, bool krbLogin, bool getSrv=false, bool useproxy=false,
955
SshMasterConnection::ProxyType type=SshMasterConnection::PROXYSSH,
956
QString proxyserver=QString::null, quint16 proxyport=0,
957
QString proxylogin=QString::null, QString proxypassword=QString::null, QString proxyKey=QString::null,
958
bool proxyAutologin=false, bool proxyKrbLogin=false );
959
void setProxyWinTitle();
960
QRect proxyWinGeometry();
961
void readApplications();
962
void removeAppsFromTray();
963
void plugAppsInTray();
964
QMenu* initTrayAppMenu(QString text, QPixmap icon);
965
void setTrayIconToSessionIcon(QString info);
969
virtual void closeEvent ( QCloseEvent* event );
970
virtual void hideEvent ( QHideEvent* event);
973
virtual void mouseReleaseEvent ( QMouseEvent * event );
976
void slotSetWinServersReady();
977
void startWinServers();
978
void slotCheckXOrgLog();
979
void slotCheckXOrgConnection();
980
void slotCheckPulse();
981
void slotStartParec ();
984
void slotAppDialog();
985
void slotShowPassForm();
987
void slotAppMenuTriggered ( QAction * action );
988
void slotPassChanged(const QString& result);
989
void slotResize ( const QSize sz );
990
void slotUnameChanged ( const QString& text );
991
void slotPassEnter();
992
void slotChangeBrokerPass();
993
void slotTestConnection();
994
void slotCheckPortableDir();
996
void slotSelectedFromList ( UserButton* user );
997
void slotUnameEntered();
998
void slotClosePass();
999
void slotReadSessions();
1001
void displayToolBar ( bool );
1002
void showSessionStatus();
1003
void slotSshConnectionError ( QString message, QString lastSessionError );
1004
void slotSshServerAuthError ( int error, QString sshMessage, SshMasterConnection* connection );
1005
void slotSshServerAuthPassphrase ( SshMasterConnection* connection, bool verificationCode );
1006
void slotSshUserAuthError ( QString error );
1007
void slotSshConnectionOk();
1008
void slotServSshConnectionOk(QString server);
1009
void slotChangeKbdLayout(const QString& layout);
1011
void slotShutdownThinClient();
1012
void slotReadApplications(bool result, QString output, int pid );
1016
void slotNewSession();
1017
void slotEmbedControlAction();
1018
void slotDetachProxyWindow();
1019
void slotActivateWindow();
1023
void slotSnameChanged ( const QString& );
1024
void slotSelectedFromList ( SessionButton* session );
1025
void slotSessEnter();
1026
void slotCloseSelectDlg();
1027
void slotActivated ( const QModelIndex& index );
1028
void slotResumeSess();
1029
void slotSuspendSess();
1030
void slotTermSessFromSt();
1031
void slotSuspendSessFromSt();
1032
void slotTermSess();
1034
void slotGetBrokerAuth();
1035
void slotGetBrokerSession();
1036
void slotCmdMessage ( bool result,QString output,
1038
void slotListSessions ( bool result,QString output,
1040
void slotRetSuspSess ( bool value,QString message,
1042
void slotRetTermSess ( bool result,QString output,
1044
void slotRetResumeSess ( bool result,QString output,
1046
void slotTunnelFailed ( bool result,QString output,
1048
void slotFsTunnelFailed ( bool result,QString output,
1050
void slotSndTunnelFailed ( bool result,QString output,
1052
void slotCopyKey ( bool result,QString output,int );
1053
void slotTunnelOk(int );
1054
void slotFsTunnelOk(int );
1055
void slotProxyError ( QProcess::ProcessError err );
1056
void slotProxyFinished ( int result,QProcess::ExitStatus st );
1057
void slotProxyStderr();
1058
void slotProxyStdout();
1059
void slotResumeDoubleClick ( const QModelIndex& );
1060
void slotShowAdvancedStat();
1061
void slotRestartProxy();
1062
void slotTestSessionStatus();
1063
void slotRetRunCommand ( bool result, QString output,
1065
void slotGetServers ( bool result, QString output,
1067
void slotListAllSessions ( bool result,QString output,
1069
void slotRetExportDir ( bool result,QString output,
1072
void slotExportDirectory();
1073
void slotExportTimer();
1079
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
1080
void trayMessageClicked();
1082
void trayIconInit();
1086
void slotSetProxyWinFullscreen();
1087
void slotCheckPrintSpool();
1088
void slotRereadUsers();
1089
void slotExtTimer();
1090
void slotStartPGPAuth();
1091
void slotScDaemonOut();
1092
void slotScDaemonError();
1093
void slotGpgFinished ( int exitCode,
1094
QProcess::ExitStatus exitStatus );
1095
void slotScDaemonFinished ( int exitCode,
1096
QProcess::ExitStatus exitStatus );
1097
void slotGpgError();
1098
void slotCheckScDaemon();
1099
void slotGpgAgentFinished ( int exitCode,
1100
QProcess::ExitStatus exitStatus );
1101
void slotCheckAgentProcess();
1102
void slotExecXmodmap();
1103
void slotCreateSessionIcon();
1104
void slotFindProxyWin();
1105
void slotConfigXinerama();
1106
void slotXineramaConfigured();
1107
void slotAttachProxyWindow();
1108
void slotEmbedIntoParentWindow();
1109
void slotEmbedWindow();
1110
void slotSndTunOk();
1111
void slotPCookieReady ( bool result,QString output,
1113
void slotEmbedToolBar();
1114
void slotEmbedToolBarToolTip();
1115
void slotHideEmbedToolBarToolTip();
1116
void slotDesktopFilterChanged ( const QString& text ) ;
1117
void slotDesktopFilterCb ( int state ) ;
1118
void slotShadowViewSess();
1119
void slotShadowSess();
1120
void slotReconnectSession();
1121
void slotStartBroker();
1122
void slotStartNewBrokerSession ();
1124
void slotSetModMap();
1126
QTimer* modMapTimer;
1131
void resizeProxyWinOnDisplay(int display);
1133
long X11FindWindow ( QString text, long rootWin=0 );
1135
void addToAppNames ( QString intName, QString transName );
1136
bool checkAgentProcess();
1137
bool isColorDepthOk ( int disp, int sess );
1138
void check_cmd_status();
1139
int startSshFsTunnel();
1140
void startX2goMount();
1141
void cleanPrintSpool();
1142
void cleanAskPass();
1143
void initWidgetsEmbed();
1144
void initWidgetsNormal();
1145
QString getCurrentUname();
1146
QString getCurrentPass();
1147
void processSessionConfig();
1148
void processCfgLine ( QString line );
1149
void initSelectSessDlg();
1150
void initStatusDlg();
1152
void printSshDError_startupFailure();
1153
void printSshDError_noHostPubKey();
1154
void printSshDError_noExportPubKey();
1155
void printSshDError_noAuthorizedKeysFile();
1156
void loadPulseModuleNativeProtocol();
1157
void initEmbedToolBar();
1159
void startDirectRDP();
1161
void filterDesktops ( const QString& filter,
1162
bool strict=false );
1163
void generateHostDsaKey();
1164
void generateEtcFiles();
1165
QString u3DataPath();
1166
void cleanPortable();
1167
void removeDir ( QString path );
1169
void saveCygnusSettings();
1170
void restoreCygnusSettings();
1172
#if defined (Q_OS_WIN) || defined (Q_OS_DARWIN)
1173
QString getXDisplay();
1176
////////////////plugin stuff////////////////////
1179
void setX2goconfig ( const QString& text );
1181
QString x2goconfig() const
1183
return m_x2goconfig;
1188
void embedWindow ( long wndId );
1189
void detachClient();
1193
QSize oldParentSize;
1196
QX11EmbedContainer* embedContainer;
1199
QWidget* embedContainer;
1200
QPoint oldParentPos;
1202
QSize oldContainerSize;
1203
QTimer *updateTimer;
1208
QSize getWindowSize ( long winId );
1209
void doPluginInit();
1213
void slotUpdateEmbedWindow();
1216
#endif //(Q_OS_DARWIN)
1218
////////////////end of plugin stuff////////////////////