The branch, master has been updated via 34f39898b958bc37bd93c24f5605e0c90c0ac78e (commit) via e73a88d9f7f53e102ddac38122b52c4a089514e6 (commit) via 7377e0ea98f56cdf97fff63d3ea69d7a20c8eb1f (commit) from 23cc0c462239bc27076a475fb541bf5c3c6767ec (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 34f39898b958bc37bd93c24f5605e0c90c0ac78e Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Jul 14 09:46:07 2011 +0200 bundle commit, worked in unreleased non-Git versions 3.01-19, 3.01-20, 3.01-21, bumping towards version 3.0.99.0. commit e73a88d9f7f53e102ddac38122b52c4a089514e6 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Jul 14 09:17:04 2011 +0200 re-refer to NoMachine as NXv3 source (as they became active again...) commit 7377e0ea98f56cdf97fff63d3ea69d7a20c8eb1f Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Jul 14 09:16:51 2011 +0200 remove build files ----------------------------------------------------------------------- Summary of changes: .DS_Store | Bin 6148 -> 0 bytes .kdev4/x2goclient-3.01-libssh.kdev4 | 20 - INSTALL | 2 +- VERSION | 2 +- brokerpassdialog.ui | 182 ++++++++ brokerpassdlg.cpp | 71 +++ xsettingswidget.h => brokerpassdlg.h | 26 +- build_win_plugin.bat | 7 + config_linux_static.sh | 2 +- config_linux_static_plugin.sh | 1 + debian/changelog | 31 ++- desktop/x2goclient.desktop | 2 +- httpbrokerclient.cpp | 824 +++++++++++++++++++--------------- httpbrokerclient.h | 63 ++- icons/32x32/auth.png | Bin 0 -> 1686 bytes object_script.x2goclient.Debug | 2 + object_script.x2goclient.Release | 2 + onmainwindow.cpp | 252 ++++++++++- onmainwindow.h | 33 ++- onmainwindow_part2.cpp | 143 ++++-- onmainwindow_part3.cpp | 130 +++++- onmainwindow_part4.cpp | 152 +++++-- onmainwindow_privat.h | 1 + resources.rcc | 1 + sessionbutton.cpp | 111 ++++-- sessionbutton.h | 1 + sshmasterconnection.cpp | 26 +- sshmasterconnection.h | 7 +- sshprocess.cpp | 2 +- version.h | 2 +- wapi.cpp | 32 ++ wapi.h | 2 + x2goclient.pro | 17 +- x2goclientconfig.h | 2 +- x2goplugin.rc | 10 +- x2gosettings.cpp | 50 ++- x2gosettings.h | 4 +- xsettingsui.ui | 29 +-- xsettingswidget.cpp | 14 +- 39 files changed, 1626 insertions(+), 632 deletions(-) delete mode 100644 .DS_Store delete mode 100644 .kdev4/x2goclient-3.01-libssh.kdev4 create mode 100644 brokerpassdialog.ui create mode 100644 brokerpassdlg.cpp copy xsettingswidget.h => brokerpassdlg.h (63%) create mode 100755 build_win_plugin.bat create mode 100644 icons/32x32/auth.png The diff of changes is: diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.kdev4/x2goclient-3.01-libssh.kdev4 b/.kdev4/x2goclient-3.01-libssh.kdev4 deleted file mode 100644 index 4e0da72..0000000 --- a/.kdev4/x2goclient-3.01-libssh.kdev4 +++ /dev/null @@ -1,20 +0,0 @@ -[Buildset] -BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00,\x00x\x002\x00g\x00o\x00c\x00l\x00i\x00e\x00n\x00t\x00-\x003\x00.\x000\x001\x00-\x00l\x00i\x00b\x00s\x00s\x00h) - -[Launch] -Launch Configurations=Launch Configuration 0 - -[Launch][Launch Configuration 0] -Configured Launch Modes=execute -Configured Launchers=nativeAppLauncher -Name=New Native Application Configuration -Type=Native Application - -[Launch][Launch Configuration 0][Data] -Arguments= -Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00) -Dependency Action=Nothing -EnvironmentGroup=default -Executable=file:///usr/src.cur/db-builds/x2goclient/x2goclient-3.01/x2goclient -Working Directory= -isExecutable=true diff --git a/INSTALL b/INSTALL index 6bef37b..05d9730 100644 --- a/INSTALL +++ b/INSTALL @@ -7,7 +7,7 @@ Qt4: http://www.trolltech.com nxcomp+nxproxy: -http://code.x2go.org/releases +http://www.nomachine.com/sources.php You may want also install pulseaudio sound server to enable sound support http://www.pulseaudio.org/wiki/DownloadPulseAudio diff --git a/VERSION b/VERSION index df46582..14e681e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.1.18 +3.0.99.0 diff --git a/brokerpassdialog.ui b/brokerpassdialog.ui new file mode 100644 index 0000000..333a577 --- /dev/null +++ b/brokerpassdialog.ui @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>BrokerPassDialogUi</class> + <widget class="QDialog" name="BrokerPassDialogUi"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>311</width> + <height>160</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Old password:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="leOldPas"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>New password:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="lePass1"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Confirm password:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="lePass2"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="statusLabel"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>BrokerPassDialogUi</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>292</x> + <y>143</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>153</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>BrokerPassDialogUi</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>286</x> + <y>143</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>153</y> + </hint> + </hints> + </connection> + <connection> + <sender>lePass1</sender> + <signal>textChanged(QString)</signal> + <receiver>BrokerPassDialogUi</receiver> + <slot>slotPassChanged()</slot> + <hints> + <hint type="sourcelabel"> + <x>167</x> + <y>46</y> + </hint> + <hint type="destinationlabel"> + <x>103</x> + <y>113</y> + </hint> + </hints> + </connection> + <connection> + <sender>lePass2</sender> + <signal>textChanged(QString)</signal> + <receiver>BrokerPassDialogUi</receiver> + <slot>slotPassChanged()</slot> + <hints> + <hint type="sourcelabel"> + <x>215</x> + <y>79</y> + </hint> + <hint type="destinationlabel"> + <x>208</x> + <y>105</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <slot>slotPassChanged()</slot> + </slots> +</ui> diff --git a/brokerpassdlg.cpp b/brokerpassdlg.cpp new file mode 100644 index 0000000..b3a7571 --- /dev/null +++ b/brokerpassdlg.cpp @@ -0,0 +1,71 @@ +/* + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 2011 Oleksandr Shneyder + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "brokerpassdlg.h" +#include <QPushButton> + +BrokerPassDlg::BrokerPassDlg(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f) +{ + setupUi(this); + statusLabel->setText(QString::null); + buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); +} + +BrokerPassDlg::~BrokerPassDlg() +{ + +} + +void BrokerPassDlg::slotPassChanged() +{ + bool passEq=false; + if (lePass1->text()!=lePass2->text()) + { + passEq=false; + statusLabel->setText(tr("Passwords do not match")); + } + else + { + passEq=true; + statusLabel->setText(QString::null); + } + buttonBox->button(QDialogButtonBox::Ok)->setEnabled(passEq && + lePass1->text().size()>0 && + leOldPas->text().size()>0); +} + +void BrokerPassDlg::accept() +{ + QDialog::accept(); +} + +void BrokerPassDlg::reject() +{ + QDialog::reject(); +} + +QString BrokerPassDlg::newPass() +{ + return lePass1->text(); +} + +QString BrokerPassDlg::oldPass() +{ + return leOldPas->text(); +} diff --git a/xsettingswidget.h b/brokerpassdlg.h similarity index 63% copy from xsettingswidget.h copy to brokerpassdlg.h index 0a441cf..90b3ba2 100644 --- a/xsettingswidget.h +++ b/brokerpassdlg.h @@ -1,6 +1,6 @@ /* <one line to give the program's name and a brief idea of what it does.> - Copyright (C) 2011 Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> + Copyright (C) 2011 Oleksandr Shneyder This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,23 +17,25 @@ */ -#ifndef XSETTINGSWIDGET_H -#define XSETTINGSWIDGET_H +#ifndef BROKERPASSDLG_H +#define BROKERPASSDLG_H -#include <QWidget> -#include "ui_xsettingsui.h" +#include <QDialog> +#include "ui_brokerpassdialog.h" -class XSettingsWidget : public QWidget, private Ui_XSettingsWidgetUI +class BrokerPassDlg: public QDialog, private Ui_BrokerPassDialogUi { Q_OBJECT public: - XSettingsWidget(QWidget* parent = 0); - virtual ~XSettingsWidget(); - void setDefaults(); - void saveSettings(); + BrokerPassDlg(QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~BrokerPassDlg(); + virtual void accept(); + virtual void reject(); + QString oldPass(); + QString newPass(); private slots: - void slotSetExecutable(); + void slotPassChanged(); }; -#endif // XSETTINGSWIDGET_H +#endif // BROKERPASSDLG_H diff --git a/build_win_plugin.bat b/build_win_plugin.bat new file mode 100755 index 0000000..61989d0 --- /dev/null +++ b/build_win_plugin.bat @@ -0,0 +1,7 @@ +mingw32-make +copy release\npx2goplugin.dll d:\share\plugin\x2goplugin\ +d: +cd \share\plugin\x2goplugin\ +idc.exe npx2goplugin.dll /idl npx2goplugin.idl -version 1.0 +midl npx2goplugin.idl /nologo /tlb npx2goplugin.tlb +idc.exe npx2goplugin.dll /tlb npx2goplugin.tlb diff --git a/config_linux_static.sh b/config_linux_static.sh index 294b1d3..a51bac9 100755 --- a/config_linux_static.sh +++ b/config_linux_static.sh @@ -1,5 +1,5 @@ #!/bin/bash make distclean -/usr/local/Trolltech/Qt-4.7.1/bin/qmake -config release -spec linux-g++ +X2GO_LINUX_STATIC=x2go_linux_static /usr/local/Trolltech/Qt-4.7.1/bin/qmake -config release -spec linux-g++ diff --git a/config_linux_static_plugin.sh b/config_linux_static_plugin.sh index b3ad0d9..4776a3c 100755 --- a/config_linux_static_plugin.sh +++ b/config_linux_static_plugin.sh @@ -2,4 +2,5 @@ make distclean +export X2GO_LINUX_STATIC=x2go_linux_static X2GO_CLIENT_TARGET=plugin /usr/local/Trolltech/Qt-4.7.1/bin/qmake -config release -spec linux-g++ diff --git a/debian/changelog b/debian/changelog index 16cf113..ac2dd58 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,37 @@ -x2goclient (3.0.1.18-0~x2go3) UNRELEASED; urgency=low +x2goclient (3.0.99.0-0~x2go1) UNRELEASED; urgency=low + + * nothing yet. + + -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Thu, 14 Jul 2011 09:08:10 +0200 + +x2goclient (3.0.1.21-0~x2go1) unstable; urgency=low + + * changes in windows plugin + + -- Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> Thu, 30 Jun 2011 18:45:25 +0200 + +x2goclient (3.0.1.20-0~x2go1) unstable; urgency=low + + * support menu + * custom background + * custom icon on broker auth dialog + * fixed creation of desktop icons on windows + + -- Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> Fri, 08 Apr 2011 19:18:30 +0200 + +x2goclient (3.0.1.19-0~x2go1) unstable; urgency=low + + * Support to get sessions from for web broker + + -- Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> Thu, 29 Mar 2011 18:34:08 +0200 + +x2goclient (3.0.1.18-0~x2go3) unstable; urgency=low * Add ssh (server) as runtime dependency * React to bug #627990, prefer man2html-base over man2html. * Use x2goumount-session instead of old x2goumount_session command. - -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Thu, 16 Jun 2011 17:13:57 +0200 + -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Thu, 14 Jul 2011 09:07:59 +0200 x2goclient (3.0.1.18-0~x2go2) unstable; urgency=low diff --git a/desktop/x2goclient.desktop b/desktop/x2goclient.desktop index 29283c1..58f2ce0 100644 --- a/desktop/x2goclient.desktop +++ b/desktop/x2goclient.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Encoding=UTF-8 -Version=3.0.1.18 +Version=3.0.99.0 Type=Application Name=X2Go Client Exec=/usr/bin/x2goclient diff --git a/httpbrokerclient.cpp b/httpbrokerclient.cpp index 2d7fcc4..0e0a6ab 100644 --- a/httpbrokerclient.cpp +++ b/httpbrokerclient.cpp @@ -24,195 +24,263 @@ #include <QTimer> #include "SVGFrame.h" #include "onmainwindow.h" +#include <QTemporaryFile> HttpBrokerClient::HttpBrokerClient ( ONMainWindow* wnd, ConfigFile* cfg ) { - config=cfg; - mainWindow=wnd; - cmdRequest=sinfoKeyRequest=sinfoRequest=-1; - QUrl lurl ( config->brokerurl ); - http=new QHttp ( this ); - - if ( config->brokerurl.indexOf ( "https://" ) !=-1 ) - http->setHost ( lurl.host(),QHttp::ConnectionModeHttps, - lurl.port ( 443 ) ); - else - http->setHost ( lurl.host(),QHttp::ConnectionModeHttp, - lurl.port ( 80 ) ); - - connect ( http,SIGNAL ( requestFinished ( int,bool ) ),this, - SLOT ( slotRequestFinished ( int,bool ) ) ); - connect ( http,SIGNAL ( sslErrors ( const QList<QSslError>& ) ),this, - SLOT ( slotSslErrors ( const QList<QSslError>& ) ) ); - getSInfoFromBroker ( true ); + config=cfg; + mainWindow=wnd; + cmdRequest=sinfoKeyRequest=sinfoRequest=-1; + QUrl lurl ( config->brokerurl ); + http=new QHttp ( this ); + + if ( config->brokerurl.indexOf ( "https://" ) !=-1 ) + http->setHost ( lurl.host(),QHttp::ConnectionModeHttps, + lurl.port ( 443 ) ); + else + http->setHost ( lurl.host(),QHttp::ConnectionModeHttp, + lurl.port ( 80 ) ); + + connect ( http,SIGNAL ( requestFinished ( int,bool ) ),this, + SLOT ( slotRequestFinished ( int,bool ) ) ); + connect ( http,SIGNAL ( sslErrors ( const QList<QSslError>& ) ),this, + SLOT ( slotSslErrors ( const QList<QSslError>& ) ) ); + if (!wnd->brokerMode) + getSInfoFromBroker ( true ); } HttpBrokerClient::~HttpBrokerClient() { + +} + +void HttpBrokerClient::getUserSessions() +{ + QString req; + QTextStream ( &req ) << + "task=listsessions&"<< + "user="<<config->brokerUser<<"&"<< + "password="<<config->brokerPass<<"&"<< + "authid="<<config->brokerUserId; + QUrl lurl ( config->brokerurl ); + httpSessionAnswer.close(); + httpSessionAnswer.setData ( 0,0 ); + sessionsRequest=http->post ( lurl.path(),req.toUtf8(),&httpSessionAnswer ); + config->sessiondata=QString::null; + +} + +void HttpBrokerClient::selectUserSession(const QString& session) +{ +// x2goDebug<<"selected sid: "<<session; + QString req; + QTextStream ( &req ) << + "task=selectsession&"<< + "sid="<<session<<"&"<< + "user="<<config->brokerUser<<"&"<< + "password="<<config->brokerPass<<"&"<< + "authid="<<config->brokerUserId; + QUrl lurl ( config->brokerurl ); + httpSessionAnswer.close(); + httpSessionAnswer.setData ( 0,0 ); + selSessRequest=http->post ( lurl.path(),req.toUtf8(),&httpSessionAnswer ); + +} + +void HttpBrokerClient::changePassword(QString newPass) +{ + newBrokerPass=newPass; + QString req; + QTextStream ( &req ) << + "task=setpass&"<< + "newpass="<<newPass<<"&"<< + "user="<<config->brokerUser<<"&"<< + "password="<<config->brokerPass<<"&"<< + "authid="<<config->brokerUserId; + QUrl lurl ( config->brokerurl ); + httpSessionAnswer.close(); + httpSessionAnswer.setData ( 0,0 ); + chPassRequest=http->post ( lurl.path(),req.toUtf8(),&httpSessionAnswer ); + +} + + +void HttpBrokerClient::createIniFile(const QString& content) +{ + QString cont; + QStringList lines=content.split("START_USER_SESSIONS<br>"); + if (lines.count()>1) + { + cont=lines[1]; + cont=cont.split("END_USER_SESSIONS")[0]; + cont.replace("\n",""); + cont.replace("<br>","\n"); + } + mainWindow->config.iniFile=cont; } QString HttpBrokerClient::getSInfoFromBroker ( bool getKey ) { - QString pack; - bool fullscreen; - int height; - int width; - int quality; - int speed; - bool usekbd; - bool setDPI=false; - uint dpi=96; - QString layout; - QString type; - QString homeDir=QDir::homePath(); - X2goSettings st( "sessions" ); - - QString sid; - sid="embedded"; - pack=st.setting()->value ( sid+"/pack", - ( QVariant ) "16m-jpeg" ).toString(); - fullscreen=st.setting()->value ( sid+"/fullscreen", - ( QVariant ) - false ).toBool(); - height=st.setting()->value ( sid+"/height", - ( QVariant ) 600 ).toInt(); - width=st.setting()->value ( sid+"/width", - ( QVariant ) 800 ).toInt(); - setDPI=st.setting()->value ( sid+"/setdpi", - ( QVariant ) false ).toBool(); - dpi=st.setting()->value ( sid+"/dpi", - ( QVariant ) 96 ).toUInt(); - quality=st.setting()->value ( - sid+"/quality", - ( QVariant ) 9 ).toInt(); - speed=st.setting()->value ( sid+"/speed", - ( QVariant ) 2 ).toInt(); - usekbd=st.setting()->value ( sid+"/usekbd", - ( QVariant ) true ).toBool(); - layout=st.setting()->value ( sid+"/layout", - ( QVariant ) - tr ( "us" ) ).toString(); - type=st.setting()->value ( sid+"/type", - ( QVariant ) - tr ( "pc105/us" ) ).toString(); - bool startEmbedded=false; - if ( st.setting()->value ( sid+"/startembed", - ( QVariant ) true ).toBool() ) - { - startEmbedded=true; - fullscreen=false; - QSize sz=mainWindow->getEmbedAreaSize(); - height=sz.height(); - width=sz.width(); - - } - - QString geometry; - if ( fullscreen ) - { - geometry="fullscreen"; + QString pack; + bool fullscreen; + int height; + int width; + int quality; + int speed; + bool usekbd; + bool setDPI=false; + uint dpi=96; + QString layout; + QString type; + QString homeDir=mainWindow->getHomeDirectory(); + X2goSettings st( "sessions" ); + + QString sid; + sid="embedded"; + pack=st.setting()->value ( sid+"/pack", + ( QVariant ) "16m-jpeg" ).toString(); + fullscreen=st.setting()->value ( sid+"/fullscreen", + ( QVariant ) + false ).toBool(); + height=st.setting()->value ( sid+"/height", + ( QVariant ) 600 ).toInt(); + width=st.setting()->value ( sid+"/width", + ( QVariant ) 800 ).toInt(); + setDPI=st.setting()->value ( sid+"/setdpi", + ( QVariant ) false ).toBool(); + dpi=st.setting()->value ( sid+"/dpi", + ( QVariant ) 96 ).toUInt(); + quality=st.setting()->value ( + sid+"/quality", + ( QVariant ) 9 ).toInt(); + speed=st.setting()->value ( sid+"/speed", + ( QVariant ) 2 ).toInt(); + usekbd=st.setting()->value ( sid+"/usekbd", + ( QVariant ) true ).toBool(); + layout=st.setting()->value ( sid+"/layout", + ( QVariant ) + tr ( "us" ) ).toString(); + type=st.setting()->value ( sid+"/type", + ( QVariant ) + tr ( "pc105/us" ) ).toString(); + bool startEmbedded=false; + if ( st.setting()->value ( sid+"/startembed", + ( QVariant ) true ).toBool() ) + { + startEmbedded=true; + fullscreen=false; + QSize sz=mainWindow->getEmbedAreaSize(); + height=sz.height(); + width=sz.width(); + + } + + QString geometry; + if ( fullscreen ) + { + geometry="fullscreen"; #ifdef Q_OS_WIN - fullscreen=false; + fullscreen=false; #endif - } - if ( ! fullscreen ) - { - geometry=QString::number ( width ) +"x"+ - QString::number ( height ); - - } - QString link; - switch ( speed ) - { - case 0: - link="modem"; - break; - case 1: - link="isdn"; - break; - case 2: - link="adsl"; - break; - case 3: - link="wan"; - break; - case 4: - link="lan"; - break; - } - - QFile file ( ":/txt/packs" ); - file.open ( QIODevice::ReadOnly | QIODevice::Text ); - QTextStream in ( &file ); - while ( !in.atEnd() ) - { - QString pc=in.readLine(); - if ( pc.indexOf ( "-%" ) !=-1 ) - { - pc=pc.left ( pc.indexOf ( "-%" ) ); - if ( pc==pack ) - { - pack+="-"+QString::number ( quality ); - break; - } - } - } - file.close(); - - QDesktopWidget wd; - QString depth=QString::number ( wd.depth() ); + } + if ( ! fullscreen ) + { + geometry=QString::number ( width ) +"x"+ + QString::number ( height ); + + } + QString link; + switch ( speed ) + { + case 0: + link="modem"; + break; + case 1: + link="isdn"; + break; + case 2: + link="adsl"; + break; + case 3: + link="wan"; + break; + case 4: + link="lan"; + break; + } + + QFile file ( ":/txt/packs" ); + file.open ( QIODevice::ReadOnly | QIODevice::Text ); + QTextStream in ( &file ); + while ( !in.atEnd() ) + { + QString pc=in.readLine(); + if ( pc.indexOf ( "-%" ) !=-1 ) + { + pc=pc.left ( pc.indexOf ( "-%" ) ); + if ( pc==pack ) + { + pack+="-"+QString::number ( quality ); + break; + } + } + } + file.close(); + + QDesktopWidget wd; + QString depth=QString::number ( wd.depth() ); #ifdef Q_OS_DARWIN - usekbd=0; - type="query"; + usekbd=0; + type="query"; #endif - QString dpiS; - if ( setDPI ) - { - dpiS=QString::number ( dpi ); - } - else - dpiS="noset"; - QString useKbdS; - if ( usekbd ) - useKbdS="1"; - else - useKbdS="0"; - - - QString req; - QTextStream ( &req ) << - "mode=getsinfo&"<< - "geometry="<<geometry<<"&" - "link="<<link<<"&" - "pack="<<pack<<"&" - "depth="<<depth<<"&" - "layout="<<layout<<"&" - "type="<<type<<"&" - "usekbd="<<useKbdS<<"&" - "dpi="<<dpiS<<"&" - "user="<<config->user<<"&"<< - "connectionts="<<config->connectionts<<"&"<< - "cookie="<<config->cookie; - QUrl lurl ( config->brokerurl ); - httpSIAnswer.close(); - httpSIAnswer.setData ( 0,0 ); - if ( getKey ) - { - QTextStream ( &req ) <<"&" - "getkey=true"; - sinfoKeyRequest=http->post ( lurl.path(), - req.toUtf8(),&httpSIAnswer ); - x2goDebug<<"requested key :"<<sinfoKeyRequest; - } - else - { - sinfoRequest=http->post ( lurl.path(), - req.toUtf8(),&httpSIAnswer ); - x2goDebug<<"requested session :"<<sinfoRequest; - } - return QString::null; + QString dpiS; + if ( setDPI ) + { + dpiS=QString::number ( dpi ); + } + else + dpiS="noset"; + QString useKbdS; + if ( usekbd ) + useKbdS="1"; + else + useKbdS="0"; + + + QString req; + QTextStream ( &req ) << + "mode=getsinfo&"<< + "geometry="<<geometry<<"&" + "link="<<link<<"&" + "pack="<<pack<<"&" + "depth="<<depth<<"&" + "layout="<<layout<<"&" + "type="<<type<<"&" + "usekbd="<<useKbdS<<"&" + "dpi="<<dpiS<<"&" + "user="<<config->user<<"&"<< + "connectionts="<<config->connectionts<<"&"<< + "cookie="<<config->cookie; + QUrl lurl ( config->brokerurl ); + httpSIAnswer.close(); + httpSIAnswer.setData ( 0,0 ); + if ( getKey ) + { + QTextStream ( &req ) <<"&" + "getkey=true"; + sinfoKeyRequest=http->post ( lurl.path(), + req.toUtf8(),&httpSIAnswer ); + x2goDebug<<"requested key :"<<sinfoKeyRequest; + } + else + { + sinfoRequest=http->post ( lurl.path(), + req.toUtf8(),&httpSIAnswer ); + x2goDebug<<"requested session :"<<sinfoRequest; + } + return QString::null; } @@ -220,206 +288,250 @@ void HttpBrokerClient::slotRequestFinished ( int id, bool error ) { // x2goDebug<<"http request "<<id<<", finished with: "<<error; - if ( error ) - x2goDebug<<http->errorString(); - -// QString answer ( httpCmdAnswer.data() ); -// x2goDebug<<"cmd request answer: "<<answer; - - if ( id==sinfoKeyRequest || id==sinfoRequest ) - { + if ( error ) + { + x2goDebug<<http->errorString(); + QMessageBox::critical(0,tr("Error"),http->errorString()); + emit fatalHttpError(); + return; + } + +// QString answer ( httpSiAnswer.data() ); +// x2goDebug<<"cmd request answer: "<<answer; + if ( id== sessionsRequest || id == selSessRequest || id==chPassRequest) + { + QString answer ( httpSessionAnswer.data() ); + x2goDebug<<"cmd request answer: "<<answer; + if (answer.indexOf("Access granted")==-1) + { + QMessageBox::critical ( + 0,tr ( "Error" ), + tr ( "Login failed!<br>" + "Please try again" ) ); + emit authFailed(); + return; + } + config->brokerAuthenticated=true; + if (id == sessionsRequest) + { + createIniFile(answer); + emit sessionsLoaded(); + } + if (id == selSessRequest) + { + emit getSession(answer); + } + if ( id == chPassRequest) + { + if (answer.indexOf("CHANGING PASS OK")!=-1) + { + emit passwordChanged(newBrokerPass); + } + else + { + emit passwordChanged(QString::null); + } + + } + } + + if ( id==sinfoKeyRequest || id==sinfoRequest ) + { // x2goDebug<<"Answer:"<<httpSIAnswer.data(); - QString key ( httpSIAnswer.data() ); - if ( key.indexOf ( "X2GO_BROKER_ERRORR-ACESS DENIED" ) !=-1 ) - { - QMessageBox::critical ( - 0,tr ( "Error" ), - tr ( "Your session was disconnected. " - "To get access to your running " - "session, please return to the login page " - "or use the \"reload\" function of " - "your browser." ) ); - emit fatalHttpError(); - return; - } - QStringList strings=key.split ( "\n" ); - for ( int i=0;i<strings.count();++i ) - { - if ( strings[i].indexOf ( "x2gosession=" ) !=-1 ) - { - QStringList vals=strings[i].split ( "=" ); - config->sessiondata=vals[1]; - } - if ( strings[i]=="rootless=false" ) - { - config->rootless=false; - } - if ( strings[i]=="rootless=true" ) - { - config->rootless=true; - } - } - if ( id==sinfoKeyRequest ) - { - emit haveSshKey ( key ); - QTimer::singleShot ( 5000, this, - SLOT ( slotGetConnectionCmd() ) ); - } - else - emit haveAgentInfo(); - } - if ( id==cmdRequest ) - { - QString answer ( httpCmdAnswer.data() ); + QString key ( httpSIAnswer.data() ); + if ( key.indexOf ( "X2GO_BROKER_ERRORR-ACESS DENIED" ) !=-1 ) + { + QMessageBox::critical ( + 0,tr ( "Error" ), + tr ( "Your session was disconnected. " + "To get access to your running " + "session, please return to the login page " + "or use the \"reload\" function of " + "your browser." ) ); + emit fatalHttpError(); + return; + } + QStringList strings=key.split ( "\n" ); + for ( int i=0;i<strings.count();++i ) + { + if ( strings[i].indexOf ( "x2gosession=" ) !=-1 ) + { + QStringList vals=strings[i].split ( "=" ); + config->sessiondata=vals[1]; + } + if ( strings[i]=="rootless=false" ) + { + config->rootless=false; + } + if ( strings[i]=="rootless=true" ) + { + config->rootless=true; + } + } + if ( id==sinfoKeyRequest ) + { + emit haveSshKey ( key ); + QTimer::singleShot ( 5000, this, + SLOT ( slotGetConnectionCmd() ) ); + } + else + emit haveAgentInfo(); + } + if ( id==cmdRequest ) + { + QString answer ( httpCmdAnswer.data() ); // x2goDebug<<"cmd request answer: "<<answer; - if ( !error ) - { - answer=answer.split ( - "<body onload=\"checkPlugin()\">" ) [1]; - answer=answer.split ( "</body>" ) [0]; - if ( answer.indexOf ( "CMD:0:" ) !=-1 ) - { - x2goDebug<<"brocker sent reconnect cmd"; - emit cmdReconnect(); - } - } - QTimer::singleShot ( 3000, this, - SLOT ( slotGetConnectionCmd() ) ); - } + if ( !error ) + { + answer=answer.split ( + "<body onload=\"checkPlugin()\">" ) [1]; + answer=answer.split ( "</body>" ) [0]; + if ( answer.indexOf ( "CMD:0:" ) !=-1 ) + { + x2goDebug<<"brocker sent reconnect cmd"; + emit cmdReconnect(); + } + } + QTimer::singleShot ( 3000, this, + SLOT ( slotGetConnectionCmd() ) ); + } } void HttpBrokerClient::slotSslErrors ( const QList<QSslError> & errors ) { - QStringList err; - QSslCertificate cert; - for ( int i=0;i<errors.count();++i ) - { - x2goDebug<<"sslError ,code:"<<errors[i].error() <<":"; - err<<errors[i].errorString(); - if ( !errors[i].certificate().isNull() ) - cert=errors[i].certificate(); - } - - - QString md5=getHexVal ( cert.digest() ); - QString fname=md5; - fname=fname.replace(":","_"); - QUrl lurl ( config->brokerurl ); - QString homeDir=QDir::homePath(); - if ( QFile::exists ( homeDir+"/.x2go/ssl/exceptions/"+ - lurl.host() +"/"+fname ) ) - { - QFile fl ( homeDir+"/.x2go/ssl/exceptions/"+ - lurl.host() +"/"+fname ); - fl.open ( QIODevice::ReadOnly | QIODevice::Text ); - QSslCertificate mcert ( &fl ); - if ( mcert==cert ) - { - http->ignoreSslErrors(); - return; - } - } - - QString text=tr ( "<br><b>Server uses an invalid " - "security certificate.</b><br><br>" ); - text+=err.join ( "<br>" ); - text+=tr ( "<p style='background:#FFFFDC;'>" - "You should not add an exception " - "if you are using an internet connection " - "that you do not trust completely or if you are " - "not used to seeing a warning for this server.</p>" ); - QMessageBox mb ( QMessageBox::Warning,tr ( "Secure connection failed" ), - text ); - text=QString::null; - QTextStream ( &text ) <<err.join ( "\n" ) <<"\n"<< - "------------\n"<< - tr ( "Issued to:\n" ) << - tr ( "Common Name(CN)\t" ) << - cert.issuerInfo ( QSslCertificate::CommonName ) - <<endl<< - tr ( "Organization(O)\t" ) << - cert.issuerInfo ( QSslCertificate::Organization ) - <<endl<< - tr ( "Organizational Unit(OU)\t" ) << - cert.issuerInfo ( QSslCertificate::OrganizationalUnitName ) - <<endl<< - tr ( "Serial Number\t" ) <<getHexVal ( cert.serialNumber() ) - <<endl<<endl<< - tr ( "Issued by:\n" ) << - tr ( "Common Name(CN)\t" ) << - cert.subjectInfo ( QSslCertificate::CommonName ) - <<endl<< - tr ( "Organization(O)\t" ) << - cert.subjectInfo ( QSslCertificate::Organization ) - <<endl<< - tr ( "Organizational Unit(OU)\t" ) << - cert.subjectInfo ( QSslCertificate::OrganizationalUnitName ) - <<endl<<endl<< - - tr ( "Validity:\n" ) << - tr ( "Issued on\t" ) <<cert.effectiveDate().toString() <<endl<< - tr ( "expires on\t" ) <<cert.expiryDate().toString() <<endl<<endl<< - tr ( "Fingerprints:\n" ) << - tr ( "SHA1\t" ) << - getHexVal ( cert.digest ( QCryptographicHash::Sha1 ) ) <<endl<< - tr ( "MD5\t" ) <<md5; - - - - mb.setDetailedText ( text ); - mb.setEscapeButton ( - ( QAbstractButton* ) mb.addButton ( tr ( "Exit X2Go Client" ), - QMessageBox::RejectRole ) ); - QPushButton *okButton=mb.addButton ( tr ( "Add exception" ), - QMessageBox::AcceptRole ); - mb.setDefaultButton ( okButton ); - - mb.exec(); - if ( mb.clickedButton() == ( QAbstractButton* ) okButton ) - { - x2goDebug<<"accept certificate"; - QDir dr; - dr.mkpath ( homeDir+"/.x2go/ssl/exceptions/"+lurl.host() +"/" ); - QFile fl ( homeDir+"/.x2go/ssl/exceptions/"+ - lurl.host() +"/"+fname ); - fl.open ( QIODevice::WriteOnly | QIODevice::Text ); - QTextStream ( &fl ) <<cert.toPem(); - fl.close(); - http->ignoreSslErrors(); - } - else - emit fatalHttpError(); + QStringList err; + QSslCertificate cert; + for ( int i=0;i<errors.count();++i ) + { + x2goDebug<<"sslError ,code:"<<errors[i].error() <<":"; + err<<errors[i].errorString(); + if ( !errors[i].certificate().isNull() ) + cert=errors[i].certificate(); + } + + + QString md5=getHexVal ( cert.digest() ); + QString fname=md5; + fname=fname.replace(":","_"); + QUrl lurl ( config->brokerurl ); + QString homeDir=mainWindow->getHomeDirectory(); + if ( QFile::exists ( homeDir+"/ssl/exceptions/"+ + lurl.host() +"/"+fname ) ) + { + QFile fl ( homeDir+"/ssl/exceptions/"+ + lurl.host() +"/"+fname ); + fl.open ( QIODevice::ReadOnly | QIODevice::Text ); + QSslCertificate mcert ( &fl ); + if ( mcert==cert ) + { + http->ignoreSslErrors(); + return; + } + } + + QString text=tr ( "<br><b>Server uses an invalid " + "security certificate.</b><br><br>" ); + text+=err.join ( "<br>" ); + text+=tr ( "<p style='background:#FFFFDC;'>" + "You should not add an exception " + "if you are using an internet connection " + "that you do not trust completely or if you are " + "not used to seeing a warning for this server.</p>" ); + QMessageBox mb ( QMessageBox::Warning,tr ( "Secure connection failed" ), + text ); + text=QString::null; + QTextStream ( &text ) <<err.join ( "\n" ) <<"\n"<< + "------------\n"<< + tr ( "Issued to:\n" ) << + tr ( "Common Name(CN)\t" ) << + cert.issuerInfo ( QSslCertificate::CommonName ) + <<endl<< + tr ( "Organization(O)\t" ) << + cert.issuerInfo ( QSslCertificate::Organization ) + <<endl<< + tr ( "Organizational Unit(OU)\t" ) << + cert.issuerInfo ( QSslCertificate::OrganizationalUnitName ) + <<endl<< + tr ( "Serial Number\t" ) <<getHexVal ( cert.serialNumber() ) + <<endl<<endl<< + tr ( "Issued by:\n" ) << + tr ( "Common Name(CN)\t" ) << + cert.subjectInfo ( QSslCertificate::CommonName ) + <<endl<< + tr ( "Organization(O)\t" ) << + cert.subjectInfo ( QSslCertificate::Organization ) + <<endl<< + tr ( "Organizational Unit(OU)\t" ) << + cert.subjectInfo ( QSslCertificate::OrganizationalUnitName ) + <<endl<<endl<< + + tr ( "Validity:\n" ) << + tr ( "Issued on\t" ) <<cert.effectiveDate().toString() <<endl<< + tr ( "expires on\t" ) <<cert.expiryDate().toString() <<endl<<endl<< + tr ( "Fingerprints:\n" ) << + tr ( "SHA1\t" ) << + getHexVal ( cert.digest ( QCryptographicHash::Sha1 ) ) <<endl<< + tr ( "MD5\t" ) <<md5; + + + + mb.setDetailedText ( text ); + mb.setEscapeButton ( + ( QAbstractButton* ) mb.addButton ( tr ( "Exit X2Go Client" ), + QMessageBox::RejectRole ) ); + QPushButton *okButton=mb.addButton ( tr ( "Add exception" ), + QMessageBox::AcceptRole ); + mb.setDefaultButton ( okButton ); + + mb.exec(); + if ( mb.clickedButton() == ( QAbstractButton* ) okButton ) + { + x2goDebug<<"accept certificate"; + QDir dr; + dr.mkpath ( homeDir+"/ssl/exceptions/"+lurl.host() +"/" ); + QFile fl ( homeDir+"/ssl/exceptions/"+ + lurl.host() +"/"+fname ); + fl.open ( QIODevice::WriteOnly | QIODevice::Text ); + QTextStream ( &fl ) <<cert.toPem(); + fl.close(); + http->ignoreSslErrors(); + x2goDebug<<"store certificate in "<<homeDir+"/ssl/exceptions/"+ + lurl.host() +"/"+fname; + + } + else + emit fatalHttpError(); } QString HttpBrokerClient::getHexVal ( const QByteArray& ba ) { - QStringList val; - for ( int i=0;i<ba.size();++i ) - { - QString bt; - bt.sprintf ( "%02X", ( unsigned char ) ba[i] ); - val<<bt; - } - return val.join ( ":" ); + QStringList val; + for ( int i=0;i<ba.size();++i ) + { + QString bt; + bt.sprintf ( "%02X", ( unsigned char ) ba[i] ); + val<<bt; + } + return val.join ( ":" ); } void HttpBrokerClient::slotGetConnectionCmd() { - QString req; - QTextStream ( &req ) << - "mode=getcmd&"<< - "user="<<config->user<<"&"<< - "connectionts="<<config->connectionts<<"&"<< - "cookie="<<config->cookie; - - QUrl lurl ( config->brokerurl ); - httpCmdAnswer.close(); - httpCmdAnswer.setData ( 0,0 ); - - cmdRequest=http->post ( lurl.path(), - req.toUtf8(),&httpCmdAnswer ); + QString req; + QTextStream ( &req ) << + "mode=getcmd&"<< + "user="<<config->user<<"&"<< + "connectionts="<<config->connectionts<<"&"<< + "cookie="<<config->cookie; + + QUrl lurl ( config->brokerurl ); + httpCmdAnswer.close(); + httpCmdAnswer.setData ( 0,0 ); + + cmdRequest=http->post ( lurl.path(), + req.toUtf8(),&httpCmdAnswer ); // x2goDebug<<"requested brocker cmd :"<<cmdRequest; } diff --git a/httpbrokerclient.h b/httpbrokerclient.h index 628817b..43d65e5 100644 --- a/httpbrokerclient.h +++ b/httpbrokerclient.h @@ -24,31 +24,46 @@ class ONMainWindow; class HttpBrokerClient: public QObject { - Q_OBJECT - public: - HttpBrokerClient ( ONMainWindow* wnd, ConfigFile* cfg ); - ~HttpBrokerClient(); - QString getSInfoFromBroker ( bool getKey=false ); - private: - QBuffer httpSIAnswer; - QBuffer httpCmdAnswer; - QHttp* http; - int sinfoRequest; - int sinfoKeyRequest; - int cmdRequest; - ConfigFile* config; - ONMainWindow* mainWindow; + Q_OBJECT +public: + HttpBrokerClient ( ONMainWindow* wnd, ConfigFile* cfg ); + ~HttpBrokerClient(); + QString getSInfoFromBroker ( bool getKey=false ); + void selectUserSession(const QString& session ); + void changePassword(QString newPass); +private: + QBuffer httpSIAnswer; + QBuffer httpCmdAnswer; + QBuffer httpSessionAnswer; + QHttp* http; + int sinfoRequest; + int sinfoKeyRequest; + int sessionsRequest; + int selSessRequest; + int cmdRequest; + int chPassRequest; + QString newBrokerPass; + ConfigFile* config; + ONMainWindow* mainWindow; + void createIniFile(const QString& content); - private slots: - void slotRequestFinished ( int id, bool error ); - void slotSslErrors ( const QList<QSslError> & errors ) ; - QString getHexVal ( const QByteArray& ba ); - void slotGetConnectionCmd(); - signals: - void haveSshKey ( QString ); - void fatalHttpError(); - void haveAgentInfo (); - void cmdReconnect (); +private slots: + void slotRequestFinished ( int id, bool error ); + void slotSslErrors ( const QList<QSslError> & errors ) ; + QString getHexVal ( const QByteArray& ba ); + void slotGetConnectionCmd(); +public slots: + void getUserSessions(); + +signals: + void haveSshKey ( QString ); + void fatalHttpError(); + void haveAgentInfo (); + void cmdReconnect (); + void authFailed(); + void sessionsLoaded(); + void getSession( QString ); + void passwordChanged( QString ); }; #endif diff --git a/icons/32x32/auth.png b/icons/32x32/auth.png new file mode 100644 index 0000000..e334fb6 Binary files /dev/null and b/icons/32x32/auth.png differ diff --git a/object_script.x2goclient.Debug b/object_script.x2goclient.Debug index 6a32207..8c972be 100644 --- a/object_script.x2goclient.Debug +++ b/object_script.x2goclient.Debug @@ -32,6 +32,7 @@ INPUT( ./debug\httpbrokerclient.o ./debug\ongetpass.o ./debug\x2gosettings.o +./debug\brokerpassdlg.o ./debug\xsettingswidget.o ./debug\x2goclient.o ./debug\moc_configdialog.o @@ -57,6 +58,7 @@ INPUT( ./debug\moc_sharewidget.o ./debug\moc_clicklineedit.o ./debug\moc_httpbrokerclient.o +./debug\moc_brokerpassdlg.o ./debug\moc_xsettingswidget.o ./debug\qrc_resources.o ); diff --git a/object_script.x2goclient.Release b/object_script.x2goclient.Release index 0b6487e..74e0753 100644 --- a/object_script.x2goclient.Release +++ b/object_script.x2goclient.Release @@ -32,6 +32,7 @@ INPUT( ./release\httpbrokerclient.o ./release\ongetpass.o ./release\x2gosettings.o +./release\brokerpassdlg.o ./release\xsettingswidget.o ./release\x2goclient.o ./release\moc_configdialog.o @@ -57,6 +58,7 @@ INPUT( ./release\moc_sharewidget.o ./release\moc_clicklineedit.o ./release\moc_httpbrokerclient.o +./release\moc_brokerpassdlg.o ./release\moc_xsettingswidget.o ./release\qrc_resources.o ); diff --git a/onmainwindow.cpp b/onmainwindow.cpp index 7b08939..033aacc 100644 --- a/onmainwindow.cpp +++ b/onmainwindow.cpp @@ -48,6 +48,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) x2goDebug<<"ONMainWindow constructor"<<endl; setFocusPolicy ( Qt::StrongFocus ); installTranslator(); + cleanAllFiles=false; drawMenu=true; usePGPCard=false; extLogin=false; @@ -82,11 +83,14 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) defaultSshPort=sshPort=clientSshPort="22"; LDAPPrintSupport=false; managedMode=false; + brokerMode=false; sshProxy.use=false; startEmbedded=false; sshConnection=0; sessionStatusDlg=0; noSessionEdit=false; + lastSession=0l; + changeBrokerPass=false; #ifdef Q_OS_WIN clientSshPort="7022"; @@ -183,11 +187,17 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) embedMode=true; #endif + + +//set homedir as portable,etc + + #ifdef Q_OS_WIN - portableDataPath=u3DataPath(); + QString u3Path=u3DataPath(); //we have U3 System - if ( portableDataPath.length() >0 ) + if ( u3Path.length() >0 ) { + portableDataPath=u3Path; ONMainWindow::portable=true; setWindowTitle ( "X2Go client - U3" ); } @@ -201,6 +211,9 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) homeDir=portableDataPath; x2goDebug<<"running in \"portable\" mode\n"<< "Data Dir is "<<portableDataPath; + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(slotCheckPortableDir())); + timer->start(1000); } loadSettings(); @@ -252,7 +265,10 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) #ifndef Q_WS_HILDON - bgFrame=new SVGFrame ( ( QString ) ":/svg/bg.svg",true,fr ); + if(BGFile.size()) + bgFrame=new SVGFrame ( ( QString ) BGFile,true,fr ); + else + bgFrame=new SVGFrame ( ( QString ) ":/svg/bg.svg",true,fr ); #else bgFrame=new SVGFrame ( ( QString ) ":/svg/bg_hildon.svg",true,fr ); #endif @@ -291,7 +307,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) x2golay->addWidget ( x2g ); - QHBoxLayout* bgLay=new QHBoxLayout ( bgFrame ); + bgLay=new QHBoxLayout ( bgFrame ); bgLay->setSpacing ( 0 ); bgLay->setMargin ( 0 ); bgLay->addLayout ( onlay ); @@ -307,9 +323,19 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) act_set=new QAction ( QIcon ( iconsPath ( "/32x32/edit_settings.png" ) ), tr ( "&Settings ..." ),this ); - + + if(supportMenuFile!=QString::null) + { + act_support=new QAction ( tr ( "Support ..." ),this ); + connect ( act_support,SIGNAL ( triggered ( bool ) ),this, + SLOT ( slotSupport() ) ); + + } + act_abclient=new QAction ( QIcon ( ":icons/32x32/x2goclient.png" ), tr ( "About X2GO client" ),this ); + + @@ -324,7 +350,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) #endif -#if defined (Q_OS_WIN) && defined (CFGCLIENT ) +#if defined (Q_OS_WIN) //&& defined (CFGCLIENT ) xorgSettings(); #endif @@ -359,7 +385,27 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) connect ( fr,SIGNAL ( resized ( const QSize ) ),this, SLOT ( slotResize ( const QSize ) ) ); slotResize ( fr->size() ); - x2goDebug<<"ONMainWindows constructor finished"<<endl; + + if(brokerMode) + { + broker=new HttpBrokerClient ( this, &config ); + connect ( broker,SIGNAL ( haveSshKey ( QString ) ),this, + SLOT ( slotStartSshAgent ( QString ) ) ); + connect ( broker,SIGNAL ( haveAgentInfo () ),this, + SLOT ( slotStartNewBrokerSession () ) ); + connect ( broker,SIGNAL ( fatalHttpError() ),this, + SLOT ( close() ) ); + connect ( broker,SIGNAL ( cmdReconnect() ),this, + SLOT ( slotReconnectSession() ) ); + connect ( broker, SIGNAL ( authFailed()), this ,SLOT ( slotGetBrokerAuth())); + connect ( broker, SIGNAL( sessionsLoaded()), this, SLOT (slotReadSessions())); + connect ( broker, SIGNAL ( getSession(QString)), this, SLOT (slotGetBrokerSession(QString))); + connect ( broker, SIGNAL ( passwordChanged(QString)), this, SLOT ( slotPassChanged(QString))); + + + } + + x2goDebug<<"ONMainWindows constructor finished, home Directory is:"<<homeDir<<endl; } @@ -375,8 +421,6 @@ ONMainWindow::~ONMainWindow() - - void ONMainWindow::installTranslator() { QTranslator* x2goclientTranslator=new QTranslator(); @@ -630,6 +674,19 @@ void ONMainWindow::initWidgetsNormal() QIcon ( iconsPath ( "/32x32/create_file.png" ) ), tr ( "&Create session icon on desktop..." ), this ); + if(brokerMode) + act_sessicon->setEnabled(false); + + if(changeBrokerPass) + { + act_changeBrokerPass=new QAction ( + QIcon ( iconsPath ( "/32x32/auth.png" ) ), + tr ( "&Set broker password..." ), + this ); + connect ( act_changeBrokerPass,SIGNAL ( triggered(bool)),this, + SLOT ( slotChangeBrokerPass()) ); + act_changeBrokerPass->setEnabled(false); + } QAction *act_tb=new QAction ( tr ( "Show toolbar" ),this ); @@ -652,6 +709,7 @@ void ONMainWindow::initWidgetsNormal() SLOT ( trayQuit()) ) ; connect ( act_tb,SIGNAL ( toggled ( bool ) ),this, SLOT ( displayToolBar ( bool ) ) ); + stb=addToolBar ( tr ( "Show toolbar" ) ); QShortcut* ex=new QShortcut ( QKeySequence ( tr ( "Ctrl+Q","exit" ) ), @@ -662,7 +720,8 @@ void ONMainWindow::initWidgetsNormal() { QMenu* menu_sess=menuBar()->addMenu ( tr ( "&Session" ) ); QMenu* menu_opts=menuBar()->addMenu ( tr ( "&Options" ) ); - + if(!brokerMode) + { menu_sess->addAction ( act_new ); menu_sess->addAction ( act_edit ); #if (!defined Q_WS_HILDON) && (!defined Q_OS_DARWIN) @@ -670,14 +729,21 @@ void ONMainWindow::initWidgetsNormal() menu_sess->addAction ( act_sessicon ); #endif menu_sess->addSeparator(); + } menu_sess->addAction ( act_exit ); menu_opts->addAction ( act_set ); menu_opts->addAction ( act_tb ); + if(changeBrokerPass) + menu_opts->addAction(act_changeBrokerPass); QMenu* menu_help=menuBar()->addMenu ( tr ( "&Help" ) ); + if(supportMenuFile!=QString::null) + menu_help->addAction ( act_support ); menu_help->addAction ( act_abclient ); menu_help->addAction ( act_abqt ); + if(!brokerMode) + { stb->addAction ( act_new ); stb->addAction ( act_edit ); #if (!defined Q_WS_HILDON) && (!defined Q_OS_DARWIN) @@ -685,7 +751,10 @@ void ONMainWindow::initWidgetsNormal() stb->addAction ( act_sessicon ); #endif stb->addSeparator(); + } stb->addAction ( act_set ); + if(changeBrokerPass) + stb->addAction(act_changeBrokerPass); if ( !showToolBar ) stb->hide(); @@ -708,7 +777,14 @@ void ONMainWindow::initWidgetsNormal() QTimer::singleShot ( 1500, this, SLOT ( readUsers() ) ); } else + { + if(!brokerMode) QTimer::singleShot ( 1, this, SLOT ( slotReadSessions() ) ); + else + { + QTimer::singleShot(1, this,SLOT(slotGetBrokerAuth())); + } + } QTimer* t=new QTimer ( this ); connect ( t,SIGNAL ( timeout() ),this,SLOT ( slotRereadUsers() ) ); t->start ( 20000 ); @@ -721,6 +797,95 @@ void ONMainWindow::initWidgetsNormal() } + +void ONMainWindow::slotPassChanged(const QString& result) +{ + + if(result==QString::null) + { + QMessageBox::critical(this, tr("Error"),tr("Operation failed")); + } + else + { + QMessageBox::information(this, tr("Password changed"),tr("Password changed")); + config.brokerPass=result; + } + setEnabled(true); + + slotClosePass(); + sessionStatusDlg->hide(); + +} + + +void ONMainWindow::slotChangeBrokerPass() +{ + x2goDebug<<"change broker pass"; + BrokerPassDlg passDlg; + if(passDlg.exec()!=QDialog::Accepted) + return; + if(passDlg.oldPass()!=config.brokerPass) + { + QMessageBox::critical(this,tr("Error"),tr("Wrong password!")); + return; + } + broker->changePassword(passDlg.newPass()); + setStatStatus ( tr ( "Connecting to broker" ) ); + stInfo->insertPlainText ( "broker url: "+config.brokerurl ); + setEnabled ( false ); + uname->hide(); + u->hide(); + return; +} + + +void ONMainWindow::slotCheckPortableDir() +{ + if(!QFile::exists(homeDir)) + { + x2goDebug<<"portable dir not exists, close"; + close(); + } +} + +void ONMainWindow::slotGetBrokerAuth() +{ + pass->clear(); + login->clear(); + QString pixFile=":icons/128x128/x2gosession.png"; + if(SPixFile!=QString::null) + pixFile=SPixFile; + QPixmap pix(pixFile); + if ( !miniMode ) + { + fotoLabel->setPixmap ( + pix.scaled ( 64,64, + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation ) ); + fotoLabel->setFixedSize ( 64,64 ); + } + else + { + fotoLabel->setPixmap ( + pix.scaled ( 48,48, + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation ) ); + fotoLabel->setFixedSize ( 48,48 ); + } + users->hide(); + ln->hide(); + bgLay->insertStretch(3); + QString text=tr("<b>Authentication</b>"); + /* if(config.brokerName.length()>0) + text+=config.brokerName; + else + text+=config.brokerurl;*/ + nameLabel->setText ( text ); + slotShowPassForm(); + config.brokerAuthenticated=false; +} + + void ONMainWindow::trayIconInit() { @@ -1241,6 +1406,11 @@ void ONMainWindow::slotSelectedFromList ( UserButton* user ) void ONMainWindow::slotClosePass() { + if(brokerMode) + { + if(!config.brokerAuthenticated) + close(); + } passForm->hide(); if ( !embedMode ) { @@ -1256,8 +1426,11 @@ void ONMainWindow::slotClosePass() } else { + if(lastSession) + { lastSession->show(); uname->setText ( lastSession->name() ); + } } uname->setEnabled ( true ); u->setEnabled ( true ); @@ -1270,6 +1443,7 @@ void ONMainWindow::slotClosePass() void ONMainWindow::slotPassEnter() { + shadowSession=false; #if defined ( Q_OS_WIN ) || defined (Q_OS_DARWIN ) QString disp=getXDisplay(); @@ -1664,7 +1838,6 @@ void ONMainWindow::slotCreateDesktopIcon ( SessionButton* bt ) QSettings xst ( "HKEY_LOCAL_MACHINE\\SOFTWARE\\x2goclient", QSettings::NativeFormat ); QString workDir=xst.value ( "Default" ).toString(); - workDir+="\\bin"; QString progname=workDir+"\\x2goclient.exe"; QString args="--sessionid="+bt->id(); if ( crHidden ) @@ -1691,11 +1864,45 @@ void ONMainWindow::slotCreateDesktopIcon ( SessionButton* bt ) void ONMainWindow::slotReadSessions() { - X2goSettings st ( "sessions" ); + + users->show(); + ln->show(); - QStringList slst=st.setting()->childGroups(); - for ( int i=0;i<slst.size();++i ) + X2goSettings *st; + lastSession=0; + + if(brokerMode) + { + if(changeBrokerPass) + act_changeBrokerPass->setEnabled(true); + config.key=QString::null; + config.user=QString::null; + config.sessiondata=QString::null; + for (int i=sessions.count()-1;i>=0;--i) + { + SessionButton* but=sessions.takeAt(i); + if(but) + delete but; + } + + st=new X2goSettings(config.iniFile,QSettings::IniFormat); + sessionStatusDlg->hide(); + selectSessionDlg->hide(); + setEnabled ( true ); + slotClosePass(); + } + else + st= new X2goSettings( "sessions" ); + + QStringList slst=st->setting()->childGroups(); + x2goDebug<<"read "<<slst.size()<<" sessions from config file"; + if(brokerMode && (slst.size()==0)) { + QMessageBox::critical(this,tr("Error"),tr("X2Go sessions not found")); + close(); + } + for ( int i=0;i<slst.size();++i ) + { if ( slst[i]!="embedded" ) createBut ( slst[i] ); } @@ -1757,6 +1964,7 @@ void ONMainWindow::slotReadSessions() raise(); } } + delete st; } @@ -1814,6 +2022,9 @@ void ONMainWindow::placeButtons() else sessions[i]->move ( ( users->width()-260 ) /2, i*155+i*20+5 ); + if(brokerMode) + sessions[i]->move ( ( users->width()-360 ) /2, + i*150+i*25+5 ); sessions[i]->show(); } if ( sessions.size() ) @@ -1824,6 +2035,9 @@ void ONMainWindow::placeButtons() else uframe->setFixedHeight ( sessions.size() *155+ ( sessions.size()-1 ) *20 ); + if(brokerMode) + uframe->setFixedHeight ( + sessions.size() *150+ ( sessions.size()-1 ) *25 ); } } @@ -2118,6 +2332,16 @@ void ONMainWindow::slotSelectedFromList ( SessionButton* session ) sessionName=session->name(); QString sid=session->id(); + if(brokerMode) + { + broker->selectUserSession(session->id()); + setStatStatus ( tr ( "Connecting to broker" ) ); + stInfo->insertPlainText ( "broker url: "+config.brokerurl ); + setEnabled ( false ); + uname->hide(); + u->hide(); + return; + } X2goSettings st ( "sessions" ); diff --git a/onmainwindow.h b/onmainwindow.h index a1ea247..0f7d892 100644 --- a/onmainwindow.h +++ b/onmainwindow.h @@ -1,3 +1,4 @@ + /*************************************************************************** * Copyright (C) 2005-2011 by Oleksandr Shneyder * * oleksandr.shneyder@obviously-nice.de * @@ -54,6 +55,7 @@ #if defined(CFGPLUGIN) && defined(Q_OS_LINUX) class QX11EmbedContainer; #endif +class QTemporaryFile; class QLineEdit; class QFrame; class QVBoxLayout; @@ -138,6 +140,12 @@ struct ConfigFile { QString session; QString user; + QString brokerUser; + QString brokerPass; + QString brokerUserId; + QString brokerName; + bool brokerAuthenticated; + QString iniFile; QString server; QString sshport; QString proxy; @@ -215,6 +223,7 @@ class ONMainWindow : public QMainWindow #endif { friend class HttpBrokerClient; + friend class SessionButton; #ifdef CFGPLUGIN Q_PROPERTY ( QString x2goconfig READ x2goconfig WRITE setX2goconfig ) Q_CLASSINFO ( "ClassID", "{5a20006d-118f-4185-9653-9f98958a0008}" ) @@ -455,6 +464,8 @@ private: bool usePGPCard; bool miniMode; bool managedMode; + bool brokerMode; + bool changeBrokerPass; bool embedMode; QString statusString; int defaultLink; @@ -468,6 +479,7 @@ private: bool printSupport; bool showTbTooltip; bool noSessionEdit; + bool cleanAllFiles; struct SshProxy sshProxy; QString sshPort; QString clientSshPort; @@ -542,6 +554,7 @@ private: QScrollArea* users; QVBoxLayout* userl; QHBoxLayout* mainL; + QHBoxLayout* bgLay; QList<UserButton*> names; QList<SessionButton*> sessions; UserButton* lastUser; @@ -569,12 +582,14 @@ private: QAction *act_set; QAction *act_abclient; + QAction *act_support; QAction *act_shareFolder; QAction *act_suspend; QAction *act_terminate; QAction *act_reconnect; QAction *act_embedContol; QAction *act_embedToolBar; + QAction *act_changeBrokerPass; QToolBar *stb; @@ -620,6 +635,10 @@ private: int ldapPort2; QString ldapDn; QString sessionCmd; + + QString supportMenuFile; + QString BGFile; + QString SPixFile; QString LDAPSndSys; QString LDAPSndPort; @@ -684,11 +703,11 @@ private: HttpBrokerClient* broker; -#if defined ( Q_OS_WIN) && defined (CFGCLIENT ) +#if defined ( Q_OS_WIN) //&& defined (CFGCLIENT ) void xorgSettings(); bool startXorgOnStart; - bool useXming; - int xorgDelay; + bool useInternalX; + enum {VCXSRV, XMING} internalX; QString xorgExe; QString xorgOptions; QString xorgWinOptions; @@ -697,6 +716,7 @@ private: enum {WIN,FS,SAPP} xorgMode; QString xorgWidth; QString xorgHeight; + int waitingForX; #endif // Tray icon stuff based on patch from Joachim Langenbach <joachim@falaba.de> @@ -764,13 +784,17 @@ private slots: void slotSetWinServersReady(); void startWinServers(); void slotCheckXOrgLog(); + void slotCheckXOrgConnection(); #endif private slots: void slotShowPassForm(); void displayUsers(); + void slotPassChanged(const QString& result); void slotResize ( const QSize sz ); void slotUnameChanged ( const QString& text ); void slotPassEnter(); + void slotChangeBrokerPass(); + void slotCheckPortableDir(); void readUsers(); void slotSelectedFromList ( UserButton* user ); @@ -809,6 +833,8 @@ private slots: void slotSuspendSessFromSt(); void slotTermSess(); void slotNewSess(); + void slotGetBrokerAuth(); + void slotGetBrokerSession(const QString& sinfo); void slotCmdMessage ( bool result,QString output, SshProcess* ); void slotListSessions ( bool result,QString output, @@ -849,6 +875,7 @@ private slots: void slotExportTimer(); void slotAboutQt(); void slotAbout(); + void slotSupport(); //trayIcon stuff void trayIconActivated(QSystemTrayIcon::ActivationReason reason); diff --git a/onmainwindow_part2.cpp b/onmainwindow_part2.cpp index d45bd6f..2826f87 100644 --- a/onmainwindow_part2.cpp +++ b/onmainwindow_part2.cpp @@ -136,6 +136,16 @@ void ONMainWindow::slotSessEnter() slotPassEnter(); return; } + if(brokerMode) + { + if(!config.brokerAuthenticated) + { + x2goDebug<<"starting broker request"; + slotStartBroker(); + return; + } + } + resumingSession.sessionId=QString::null; resumingSession.server=QString::null; resumingSession.display=QString::null; @@ -150,11 +160,16 @@ void ONMainWindow::slotSessEnter() void ONMainWindow::continueNormalSession() { x2goDebug<<"continue normal x2go session"<<endl; + if(brokerMode) + { + slotListSessions(true,QString::null,0); + return; + } SshProcess* proc=new SshProcess ( sshConnection, this ); connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ), this,SLOT ( slotListSessions ( bool, QString, SshProcess* ) ) ); - if ( !shadowSession ) + if ( !shadowSession ) proc->startNormal ( "export HOSTNAME && x2golistsessions" ); else proc->startNormal ( "export HOSTNAME && x2golistdesktops" ); @@ -189,7 +204,7 @@ bool ONMainWindow::startSession ( const QString& sid ) return true; } - if ( !embedMode ) + if ( !embedMode && !brokerMode ) { X2goSettings st ( "sessions" ); @@ -210,8 +225,20 @@ bool ONMainWindow::startSession ( const QString& sid ) sshPort=config.sshport; selectedCommand=config.command; } - - passwd=getCurrentPass(); + if(!brokerMode) + passwd=getCurrentPass(); + else + { + currentKey=config.key; + host=config.server; + X2goSettings st ( config.iniFile, QSettings::IniFormat ); + passForm->setEnabled ( false ); + user=st.setting()->value ( sid+"/user", + ( QVariant ) QString::null ).toString(); + login->setText(user); + sshPort=st.setting()->value ( sid+"/sshport", + ( QVariant ) "22" ).toString(); + } startSshConnection ( host,sshPort,acceptRsa,user,passwd,autologin ); return true; @@ -253,7 +280,7 @@ void ONMainWindow::slotListSessions ( bool result,QString output, uname->setEnabled ( false ); u->setEnabled ( false ); } - if ( managedMode ) + if ( managedMode || brokerMode ) { x2goDebug<<"sess data:"<<config.sessiondata; if ( config.sessiondata.indexOf ( "|S|" ) ==-1 ) @@ -419,51 +446,57 @@ void ONMainWindow::startNewSession() } else { - X2goSettings st ( "sessions" ); - QString sid; + X2goSettings* st; + + if(!brokerMode) + st=new X2goSettings( "sessions" ); + else + st= new X2goSettings(config.iniFile,QSettings::IniFormat); + + QString sid; if ( !embedMode ) sid=lastSession->id(); else sid="embedded"; - pack=st.setting()->value ( sid+"/pack", + pack=st->setting()->value ( sid+"/pack", ( QVariant ) defaultPack ).toString(); - fullscreen=st.setting()->value ( sid+"/fullscreen", + fullscreen=st->setting()->value ( sid+"/fullscreen", ( QVariant ) defaultFullscreen ).toBool(); - height=st.setting()->value ( sid+"/height", + height=st->setting()->value ( sid+"/height", ( QVariant ) defaultHeight ).toInt(); - width=st.setting()->value ( sid+"/width", + width=st->setting()->value ( sid+"/width", ( QVariant ) defaultWidth ).toInt(); - setDPI=st.setting()->value ( sid+"/setdpi", + setDPI=st->setting()->value ( sid+"/setdpi", ( QVariant ) defaultSetDPI ).toBool(); - dpi=st.setting()->value ( sid+"/dpi", + dpi=st->setting()->value ( sid+"/dpi", ( QVariant ) defaultDPI ).toUInt(); - quality=st.setting()->value ( + quality=st->setting()->value ( sid+"/quality", ( QVariant ) defaultQuality ).toInt(); - speed=st.setting()->value ( sid+"/speed", + speed=st->setting()->value ( sid+"/speed", ( QVariant ) defaultLink ).toInt(); - usekbd=st.setting()->value ( sid+"/usekbd", + usekbd=st->setting()->value ( sid+"/usekbd", ( QVariant ) defaultSetKbd ).toBool(); - layout=st.setting()->value ( sid+"/layout", + layout=st->setting()->value ( sid+"/layout", ( QVariant ) defaultLayout[0] ).toString(); - type=st.setting()->value ( sid+"/type", + type=st->setting()->value ( sid+"/type", ( QVariant ) defaultKbdType ).toString(); if ( !embedMode ) { - command=st.setting()->value ( sid+"/command", + command=st->setting()->value ( sid+"/command", ( QVariant ) defaultCmd ).toString(); - host=st.setting()->value ( + host=st->setting()->value ( sid+"/host", ( QVariant ) ( QString ) "localhost" ).toString(); - rootless=st.setting()->value ( sid+"/rootless", + rootless=st->setting()->value ( sid+"/rootless", ( QVariant ) false ).toBool(); - xdmcpServer=st.setting()->value ( sid+"/xdmcpserver", + xdmcpServer=st->setting()->value ( sid+"/xdmcpserver", ( QVariant ) "localhost" ).toString(); } @@ -473,7 +506,7 @@ void ONMainWindow::startNewSession() rootless= config.rootless; host=config.server; startEmbedded=false; - if ( st.setting()->value ( sid+"/startembed", + if ( st->setting()->value ( sid+"/startembed", ( QVariant ) true ).toBool() ) { startEmbedded=true; @@ -511,6 +544,7 @@ void ONMainWindow::startNewSession() { runRemoteCommand=false; } + delete st; } @@ -531,7 +565,7 @@ void ONMainWindow::startNewSession() maximizeProxyWin=false; proxyWinWidth=width; proxyWinHeight=height; -#ifdef CFGCLIENT +//#ifdef CFGCLIENT xorgMode=WIN; if(fullscreen) xorgMode=FS; @@ -539,9 +573,9 @@ void ONMainWindow::startNewSession() xorgMode=SAPP; xorgWidth=QString::number(width); xorgHeight=QString::number(height); - if(!useXming && ! startXorgOnStart) + if(! startXorgOnStart) startXOrg(); -#endif +//#endif #endif if ( fullscreen ) { @@ -709,43 +743,47 @@ void ONMainWindow::resumeSession ( const x2goSession& s ) sid=lastSession->id(); else sid="embedded"; - X2goSettings st ( "sessions" ); + X2goSettings* st; + if(!brokerMode) + st=new X2goSettings( "sessions" ); + else + st=new X2goSettings(config.iniFile,QSettings::IniFormat); - pack=st.setting()->value ( sid+"/pack", + pack=st->setting()->value ( sid+"/pack", ( QVariant ) defaultPack ).toString(); - fullscreen=st.setting()->value ( sid+"/fullscreen", + fullscreen=st->setting()->value ( sid+"/fullscreen", ( QVariant ) defaultFullscreen ).toBool(); - height=st.setting()->value ( sid+"/height", + height=st->setting()->value ( sid+"/height", ( QVariant ) defaultHeight ).toInt(); - width=st.setting()->value ( sid+"/width", + width=st->setting()->value ( sid+"/width", ( QVariant ) defaultWidth ).toInt(); - quality=st.setting()->value ( sid+"/quality", + quality=st->setting()->value ( sid+"/quality", ( QVariant ) defaultQuality ).toInt(); - speed=st.setting()->value ( sid+"/speed", + speed=st->setting()->value ( sid+"/speed", ( QVariant ) defaultLink ).toInt(); - usekbd=st.setting()->value ( sid+"/usekbd", + usekbd=st->setting()->value ( sid+"/usekbd", ( QVariant ) defaultSetKbd ).toBool(); - layout=st.setting()->value ( sid+"/layout", + layout=st->setting()->value ( sid+"/layout", ( QVariant ) defaultLayout[0] ).toString(); - type=st.setting()->value ( sid+"/type", + type=st->setting()->value ( sid+"/type", ( QVariant ) defaultKbdType ).toString(); - rootless=st.setting()->value ( sid+"/rootless", + rootless=st->setting()->value ( sid+"/rootless", ( QVariant ) false ).toBool(); if ( !embedMode ) { - host=st.setting()->value ( sid+"/host", + host=st->setting()->value ( sid+"/host", ( QVariant ) s.server ).toString(); } else { startEmbedded=false; - if ( st.setting()->value ( sid+"/startembed", + if ( st->setting()->value ( sid+"/startembed", ( QVariant ) true ).toBool() ) { fullscreen=false; @@ -773,6 +811,7 @@ void ONMainWindow::resumeSession ( const x2goSession& s ) usekbd=true; } } + delete st; } if(defaultLayout.size()>0) @@ -783,7 +822,7 @@ void ONMainWindow::resumeSession ( const x2goSession& s ) maximizeProxyWin=false; proxyWinWidth=width; proxyWinHeight=height; -#ifdef CFGCLIENT +// #ifdef CFGCLIENT xorgMode=WIN; if(fullscreen) xorgMode=FS; @@ -791,9 +830,9 @@ void ONMainWindow::resumeSession ( const x2goSession& s ) xorgMode=SAPP; xorgWidth=QString::number(width); xorgHeight=QString::number(height); - if(!useXming && ! startXorgOnStart) + if(! startXorgOnStart) startXOrg(); -#endif +// #endif #endif if ( fullscreen ) @@ -1815,9 +1854,10 @@ void ONMainWindow::slotTunnelOk() #ifdef Q_OS_WIN else { -#ifdef CFGCLIENT - if(useXming) -#endif +// #ifdef CFGCLIENT + // if using XMing, we must find proxy win for case, that we should make it fullscreen + if(useInternalX&& (internalX==XMING)) +// #endif proxyWinTimer->start ( 300 ); } #endif @@ -1899,8 +1939,8 @@ void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus ) #ifdef Q_OS_WIN else proxyWinTimer->stop(); -#ifdef CFGCLIENT - if(!useXming && ! startXorgOnStart) +// #ifdef CFGCLIENT + if(! startXorgOnStart) { if(xorg) { @@ -1912,7 +1952,7 @@ void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus ) } } } -#endif +// #endif #endif if ( closeEventSent ) return; @@ -1993,9 +2033,16 @@ void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus ) { if ( !embedMode ) { + if(!brokerMode) + { pass->setText ( "" ); QTimer::singleShot ( 2000,this, SLOT ( slotShowPassForm() ) ); + } + else + QTimer::singleShot ( 2000,broker, + SLOT ( getUserSessions() ) ); + } } else diff --git a/onmainwindow_part3.cpp b/onmainwindow_part3.cpp index acb533e..a2d10b8 100644 --- a/onmainwindow_part3.cpp +++ b/onmainwindow_part3.cpp @@ -51,7 +51,11 @@ void ONMainWindow::runCommand() bool rootless=false; if ( !embedMode ) { - X2goSettings st ( "sessions" ); + X2goSettings* st; + if(!brokerMode) + st=new X2goSettings( "sessions" ); + else + st=new X2goSettings(config.iniFile, QSettings::IniFormat); if ( useLdap ) @@ -59,29 +63,30 @@ void ONMainWindow::runCommand() else { QString sid=lastSession->id(); - command=st.setting()->value ( + command=st->setting()->value ( sid+"/command", ( QVariant ) tr ( "KDE" ) ).toString(); - rdpOpts=st.setting()->value ( + rdpOpts=st->setting()->value ( sid+"/rdpoptions", ( QVariant ) "" ).toString(); - rdpServer=st.setting()->value ( + rdpServer=st->setting()->value ( sid+"/rdpserver", ( QVariant ) "" ).toString(); - rootless=st.setting()->value ( sid+"/rootless", + rootless=st->setting()->value ( sid+"/rootless", ( QVariant ) false ).toBool(); - rdpFS=st.setting()->value ( + rdpFS=st->setting()->value ( sid+"/fullscreen", ( QVariant ) defaultFullscreen ).toBool(); - rdpHeight=st.setting()->value ( + rdpHeight=st->setting()->value ( sid+"/height", ( QVariant ) defaultHeight ).toString(); - rdpWidth=st.setting()->value ( + rdpWidth=st->setting()->value ( sid+"/width", ( QVariant ) defaultWidth ).toString(); } + delete st; } else { @@ -220,6 +225,11 @@ bool ONMainWindow::parseParameter ( QString param ) ONMainWindow::portable=true; return true; } + if ( param == "--clean-all-files" ) + { + cleanAllFiles=true; + return true; + } if ( param=="--no-menu" ) { @@ -257,6 +267,12 @@ bool ONMainWindow::parseParameter ( QString param ) noSessionEdit=true; return true; } + if( param=="--change-broker-pass") + { + changeBrokerPass=true; + return true; + } + QString setting,value; QStringList vals=param.split ( "=" ); @@ -368,6 +384,86 @@ bool ONMainWindow::parseParameter ( QString param ) embedParent=value.toLong(); return true; } + if( setting == "--broker-url") + { + brokerMode=true; + noSessionEdit=true; + config.brokerurl=value; + return true; + } + if( setting == "--broker-name") + { + config.brokerName=value; + return true; + } + if( setting == "--auth-id") + { + QFile file(value); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + printError ( param + tr(" (can't open file)")); + return false; + } + QTextStream in(&file); + config.brokerUserId = in.readLine(); + return true; + } + if(setting == "--support-menu") + { + if(! QFile::exists(value)) + { + printError( param + tr(" (file not exists)")); + return false; + } + supportMenuFile=value; + return true; + } + if(setting == "--background") + { + if(! QFile::exists(value)) + { + printError( param + tr(" (file not exists)")); + return false; + } + BGFile=value; + return true; + } + if(setting == "--session-icon") + { + if(! QFile::exists(value)) + { + printError( param + tr(" (file not exists)")); + return false; + } + SPixFile=value; + return true; + } + if(setting == "--home") + { + QDir dr; + +#ifdef Q_OS_WIN + int find=value.indexOf("("); + int lind=value.indexOf(")"); + if(find!=-1 && lind !=-1) + { + QString label=value.mid(find+1,lind-find-1); + x2goDebug<< "searching for drive with label: "<<label; + QString drive=wapiGetDriveByLabel(label); + value.replace("("+label+")",drive); + x2goDebug<<"new path: "<<value; + } +#endif + if(! dr.exists(value)) + { + printError( param + tr(" (directory not exists)")); + return false; + } + homeDir=value; + portableDataPath=value; + return true; + } + printError ( param ); return false; } @@ -617,6 +713,7 @@ void ONMainWindow::showHelp() "--kbd-layout=<layout>\t\t set default keyboard layout or layouts\n" "comma separated\n" "--kbd-type=<typed>\t\t set default keyboard type\n" + "--home=<dir>\t\t set users home directory\n" "--set-kbd=<0|1>\t\t\t overwrite current keyboard settings\n" ; qCritical ( "%s",helpMsg.toLocal8Bit().data() ); QMessageBox::information ( this,tr ( "Options" ),helpMsg ); @@ -1388,7 +1485,7 @@ void ONMainWindow::slotExportTimer() { SshProcess* sproc=new SshProcess ( sshConnection, this ); - sproc->startNormal ( "export HOSTNAME && x2goumount-session "+ + sproc->startNormal ( "export HOSTNAME && x2goumount_session "+ sessionId+" "+args[i] ); } } @@ -1398,6 +1495,21 @@ void ONMainWindow::slotAboutQt() QMessageBox::aboutQt ( this ); } +void ONMainWindow::slotSupport() +{ + QFile file(supportMenuFile); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return; + + QTextStream in(&file); + QString sup; + while (!in.atEnd()) + { + sup+=in.readLine(); + } + QMessageBox::information (this,tr ( "Support" ),sup); +} + void ONMainWindow::slotAbout() { QString aboutStr=tr ( diff --git a/onmainwindow_part4.cpp b/onmainwindow_part4.cpp index 451c421..a6102d6 100644 --- a/onmainwindow_part4.cpp +++ b/onmainwindow_part4.cpp @@ -282,14 +282,18 @@ void ONMainWindow::startXOrg () QTextStream ( &dispString ) <<":"<<xDisplay; QStringList args; - QString exec=appDir+"\\xming\\Xming.exe"; - bool xming=true; + QString exec; + if(internalX==XMING) + exec=appDir+"\\xming\\Xming.exe"; + if(internalX==VCXSRV) + exec=appDir+"\\vcxsrv\\vcxsrv.exe"; winServersReady=false; -#ifdef CFGCLIENT - xming=useXming; - if (!xming) + x2goDebug<<"using internal X: "<<useInternalX; +//#ifdef CFGCLIENT + if (!useInternalX || internalX!=XMING) { - exec=xorgExe; + if(!useInternalX) + exec=xorgExe; QString cmdLine; if (startXorgOnStart) cmdLine=xorgOptions; @@ -320,9 +324,9 @@ void ONMainWindow::startXOrg () } args<<dispString; } -#endif +//#endif xorg=new QProcess ( 0 ); - if (xming) + if (useInternalX && (internalX==XMING)) { QString workingDir=appDir+"\\xming"; @@ -344,7 +348,7 @@ void ONMainWindow::startXOrg () xorg-> setWorkingDirectory ( workingDir); } - x2goDebug<<"running"<<exec; + x2goDebug<<"running"<<exec<<" "<<args.join(" "); xorg->start ( exec, args ); @@ -356,15 +360,41 @@ void ONMainWindow::startXOrg () "Please check your installation" ) ); close(); } -#ifdef CFGCLIENT - if (!xming) +// #ifdef CFGCLIENT + if ( !useInternalX || internalX!= XMING) { - x2goDebug<<"servers ready after"<<xorgDelay<<endl; - QTimer::singleShot(xorgDelay*1000, this, SLOT(slotSetWinServersReady())); + //check connection in slot and launch setWinServerReady + waitingForX=0; + QTimer::singleShot(1000, this, SLOT(slotCheckXOrgConnection())); } -#endif +// #endif } +void ONMainWindow::slotCheckXOrgConnection() +{ + ++waitingForX; + if(isServerRunning(6000+xDisplay)) + { + x2goDebug<<"X is started"; + slotSetWinServersReady(); + } + else + { + if(waitingForX > 10) + { + QMessageBox::critical ( + 0,QString::null, + tr ( "Can't start X Server\n" + "Please check your installation" ) ); + close(); + } + else + { + x2goDebug<<"waiting for X"; + QTimer::singleShot(1000, this, SLOT(slotCheckXOrgConnection())); + } + } +} WinServerStarter::WinServerStarter ( daemon server, ONMainWindow * par ) : QThread ( 0 ) @@ -421,17 +451,17 @@ void ONMainWindow::startWinServers() { pulseStarter->start(); } -#ifdef CFGCLIENT - x2goDebug<<"xorg settings: "<<startXorgOnStart <<" "<< useXming<<endl; - if (useXming) +// #ifdef CFGCLIENT +// x2goDebug<<"xorg settings: "<<startXorgOnStart <<" "<< useXming<<endl; + if ( useInternalX && (internalX== XMING)) { -#endif +// #endif xStarter->start(); xorgLogTimer=new QTimer ( this ); connect ( xorgLogTimer,SIGNAL ( timeout() ),this, SLOT ( slotCheckXOrgLog() ) ); xorgLogTimer->start ( 500 ); -#ifdef CFGCLIENT +// #ifdef CFGCLIENT } else { @@ -440,7 +470,7 @@ void ONMainWindow::startWinServers() startXOrg(); } } -#endif +// #endif } @@ -678,26 +708,45 @@ void ONMainWindow::startPulsed() } -#ifdef CFGCLIENT +// #ifdef CFGCLIENT void ONMainWindow::xorgSettings() { x2goDebug<<"getting xorg settings"<<endl; X2goSettings st ( "settings" ); - useXming=(st.setting()->value("usexming",true).toBool()); + + useInternalX=(st.setting()->value("useintx",true).toBool()); + xorgExe=(st.setting()->value("xexec","C:\\program files\\vcxsrv\\vcxsrv.exe").toString()); xorgOptions=(st.setting()->value("options","-multiwindow -notrayicon -clipboard").toString()); startXorgOnStart=(st.setting()->value("onstart",true).toBool()); xorgWinOptions=(st.setting()->value("optionswin","-screen 0 %wx%h -notrayicon -clipboard").toString()); xorgFSOptions=(st.setting()->value("optionsfs","-fullscreen -notrayicon -clipboard").toString()); xorgSAppOptions=(st.setting()->value("optionssingle","-multiwindow -notrayicon -clipboard").toString()); - xorgDelay=(st.setting()->value("delay",3).toInt()); + + if(QFile::exists(appDir+"\\vcxsrv")) + internalX=VCXSRV; + if(QFile::exists(appDir+"\\xming")) + internalX=XMING; + if(useInternalX) + { + startXorgOnStart=(internalX==XMING); + xorgOptions="-multiwindow -notrayicon -clipboard"; + if(internalX==VCXSRV) + { +// xorgWinOptions="-screen 0 %wx%h -notrayicon -clipboard"; + xorgWinOptions="-multiwindow -notrayicon -clipboard"; + xorgFSOptions="-fullscreen -notrayicon -clipboard"; + xorgSAppOptions="-multiwindow -notrayicon -clipboard"; + } + } } -#endif +// #endif void ONMainWindow::slotSetWinServersReady() { + x2goDebug<<"all winservers are started\n"; winServersReady=true; restoreCygnusSettings(); } @@ -906,7 +955,7 @@ QString ONMainWindow::getCurrentUname() QString ONMainWindow::getCurrentPass() { - return pass->text(); + return pass->text(); } void ONMainWindow::slotDetachProxyWindow() @@ -2117,22 +2166,43 @@ QSize ONMainWindow::getEmbedAreaSize() void ONMainWindow::slotStartBroker() { - broker=new HttpBrokerClient ( this, &config ); - connect ( broker,SIGNAL ( haveSshKey ( QString ) ),this, - SLOT ( slotStartSshAgent ( QString ) ) ); - connect ( broker,SIGNAL ( haveAgentInfo () ),this, - SLOT ( slotStartNewBrokerSession () ) ); - connect ( broker,SIGNAL ( fatalHttpError() ),this, - SLOT ( close() ) ); - connect ( broker,SIGNAL ( cmdReconnect() ),this, - SLOT ( slotReconnectSession() ) ); + config.brokerPass=pass->text(); + config.brokerUser=login->text(); setStatStatus ( tr ( "Connecting to broker" ) ); stInfo->insertPlainText ( "broker url: "+config.brokerurl ); setEnabled ( false ); - + broker->getUserSessions(); +} + +void ONMainWindow::slotGetBrokerSession(const QString& sinfo) +{ + //x2goDebug<<"broker session: "<<sinfo; + QStringList lst=sinfo.split("SERVER:",QString::SkipEmptyParts); + int keyStartPos=sinfo.indexOf("-----BEGIN DSA PRIVATE KEY-----"); + QString endStr="-----END DSA PRIVATE KEY-----"; + int keyEndPos=sinfo.indexOf(endStr); + if(keyEndPos == -1 || keyStartPos == -1 || lst.size()==0) + { + //throw error + QMessageBox::critical ( + 0,tr ( "Error" ), + tr ("Invalid reply from broker") +"<br>"+sinfo); + + close(); + return; + } + config.server=(lst[1].split("\n"))[0]; + config.key=sinfo.mid(keyStartPos, keyEndPos+endStr.length()-keyStartPos); +// x2goDebug<<"server: "<<config.server<<endl<<" key: "<<config.key; + if(sinfo.indexOf("SESSION_INFO")!=-1) + { + QStringList lst=sinfo.split("SESSION_INFO:",QString::SkipEmptyParts); + config.sessiondata=(lst[1].split("\n"))[0]; +// x2goDebug<<"data: "<<config.sessiondata; + } + slotSessEnter(); } - void ONMainWindow::slotStartNewBrokerSession ( ) { if ( managedMode ) @@ -2176,19 +2246,21 @@ QString ONMainWindow::u3DataPath() void ONMainWindow::cleanPortable() { - QDir dr; - dr.rmdir ( QDir::homePath() +"/.ssh" ); - removeDir ( homeDir+"/.x2go/" ); + removeDir ( homeDir +"/.ssh" ); + removeDir ( homeDir +"/ssh" ); + removeDir ( homeDir+"/.x2go" ); + if(cleanAllFiles) + removeDir(homeDir+"/.x2goclient"); } void ONMainWindow::removeDir ( QString path ) { - x2goDebug<<"entering path"; + x2goDebug<<"entering " <<path; QDir dr ( path ); QStringList files=dr.entryList ( QDir::Files ); for ( int i=0;i<files.size();++i ) { - if ( files[i]!="known_hosts" ) + if ( files[i]!="known_hosts" || cleanAllFiles) { x2goDebug<<"cleaning file:"<<path+"/"+files[i]; dr.remove ( path+"/"+files[i] ); diff --git a/onmainwindow_privat.h b/onmainwindow_privat.h index 60d623e..a2d54aa 100644 --- a/onmainwindow_privat.h +++ b/onmainwindow_privat.h @@ -74,6 +74,7 @@ #include "clicklineedit.h" #include <QThread> +#include "brokerpassdlg.h" #include "sshmasterconnection.h" diff --git a/resources.rcc b/resources.rcc index 931afc1..a22aaa9 100644 --- a/resources.rcc +++ b/resources.rcc @@ -40,6 +40,7 @@ <file>icons/32x32/detach.png</file> <file>icons/32x32/suspend.png</file> <file>icons/32x32/stop.png</file> + <file>icons/32x32/auth.png</file> <file>icons/32x32/x2goclient.png</file> <file>icons/32x32/resolution.png</file> <file>icons/16x16/audio.png</file> diff --git a/sessionbutton.cpp b/sessionbutton.cpp index 197ad11..c5ec122 100644 --- a/sessionbutton.cpp +++ b/sessionbutton.cpp @@ -30,7 +30,7 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id ) : SVGFrame ( ":/svg/sessionbut.svg",false,parent ) { editable=mw->sessionEditEnabled(); - + QFont fnt=font(); if ( mw->retMiniMode() ) #ifdef Q_WS_HILDON @@ -71,6 +71,7 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id ) geomBox->setPalette ( cpal ); sessName=new QLabel ( this ); + sessStatus=new QLabel ( this ); fnt=sessName->font(); fnt.setBold ( true ); sessName->setFont ( fnt ); @@ -142,6 +143,7 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id ) if ( !miniMode ) { sessName->move ( 80,34 ); + sessStatus->move(80,50); editBut->move ( 307,156 ); serverIcon->move ( 58,84 ); server->move ( 80,84 ); @@ -158,6 +160,7 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id ) { editBut->move ( 218,113 ); sessName->move ( 64,11 ); + sessStatus->hide(); serverIcon->move ( 66,44 ); server->move ( 88,44 ); cmdIcon->move ( 66,68 ); @@ -169,6 +172,14 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id ) soundIcon->move ( 66,116 ); sound->move ( 86,116 ); } + + if(mw->brokerMode) + { + icon->move(10,30); + sessName->move(90,50); + sessStatus->move(90,70); + setFixedHeight(120); + } cmdBox->hide(); @@ -206,7 +217,18 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id ) cmdBox->hide(); geomBox->hide(); sessMenu->hide(); - sound->setEnabled(false); + sound->setEnabled(false); + } + if(mw->brokerMode) + { + cmd->hide(); + cmdIcon->hide(); + server->hide(); + serverIcon->hide(); + geom->hide(); + geomIcon->hide(); + sound->hide(); + soundIcon->hide(); } } @@ -232,36 +254,66 @@ void SessionButton::slotRemove() void SessionButton::redraw() { bool snd; - X2goSettings st ( "sessions" ); + + + X2goSettings *st; + + if (par->brokerMode) + st=new X2goSettings(par->config.iniFile,QSettings::IniFormat); + else + st= new X2goSettings( "sessions" ); + + + sessName->setText ( - st.setting()->value ( sid+"/name", - ( QVariant ) tr ( "New Session" ) ).toString() ); - QString sessIcon=st.setting()->value ( + st->setting()->value ( sid+"/name", + ( QVariant ) tr ( "New Session" ) ).toString()); + QString status=st->setting()->value ( sid+"/status", + ( QVariant ) QString::null ).toString(); + if (status == "R") + { + sessStatus->setText("("+tr("running")+")"); + } + if (status == "S") + { + sessStatus->setText("("+tr("suspended")+")"); + } + + QString sessIcon=st->setting()->value ( sid+"/icon", ( QVariant ) ":icons/128x128/x2gosession.png" ).toString(); - QPixmap pix ( sessIcon ); + QPixmap* pix; + + if (!par->brokerMode || sessIcon == ":icons/128x128/x2gosession.png") + pix=new QPixmap( sessIcon ); + else + { + pix=new QPixmap; + pix->loadFromData(QByteArray::fromBase64(sessIcon.toAscii())); + } if ( !par->retMiniMode() ) - icon->setPixmap ( pix.scaled ( 64,64,Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ) ); + icon->setPixmap ( pix->scaled ( 64,64,Qt::IgnoreAspectRatio, + Qt::SmoothTransformation ) ); else - icon->setPixmap ( pix.scaled ( 48,48,Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ) ); - - QString sv=st.setting()->value ( sid+"/host", ( QVariant ) - QString::null ).toString(); - QString uname=st.setting()->value ( sid+"/user", ( QVariant ) - QString::null ).toString(); + icon->setPixmap ( pix->scaled ( 48,48,Qt::IgnoreAspectRatio, + Qt::SmoothTransformation ) ); + + delete pix; + QString sv=st->setting()->value ( sid+"/host", ( QVariant ) + QString::null ).toString(); + QString uname=st->setting()->value ( sid+"/user", ( QVariant ) + QString::null ).toString(); server->setText ( uname+"@"+sv ); - QString command=st.setting()->value ( sid+"/command", - ( QVariant ) - tr ( - "KDE" ) ). + QString command=st->setting()->value ( sid+"/command", + ( QVariant ) + tr ( + "KDE" ) ). toString(); - rootless=st.setting()->value ( sid+"/rootless", - false ).toBool(); + rootless=st->setting()->value ( sid+"/rootless", + false ).toBool(); cmdBox->clear(); @@ -337,17 +389,17 @@ void SessionButton::redraw() #else geomBox->addItem ( tr ( "window" ) ); #endif - if ( st.setting()->value ( sid+"/fullscreen", - ( QVariant ) false ).toBool() ) + if ( st->setting()->value ( sid+"/fullscreen", + ( QVariant ) false ).toBool() ) { geom->setText ( tr ( "fullscreen" ) ); } else { #ifndef Q_WS_HILDON - QString g=QString::number ( st.setting()->value ( + QString g=QString::number ( st->setting()->value ( sid+"/width" ).toInt() ); - g+="x"+QString::number ( st.setting()->value ( + g+="x"+QString::number ( st->setting()->value ( sid+"/height" ).toInt() ); geom->setText ( g ); if ( geomBox->findText ( g ) ==-1 ) @@ -360,7 +412,7 @@ void SessionButton::redraw() } - snd=st.setting()->value ( sid+"/sound", ( QVariant ) true ).toBool(); + snd=st->setting()->value ( sid+"/sound", ( QVariant ) true ).toBool(); if ( snd ) sound->setText ( tr ( "Enabled" ) ); else @@ -374,6 +426,7 @@ void SessionButton::redraw() geom->setMinimumSize ( geom->sizeHint() ); cmd->setMinimumSize ( cmd->sizeHint() ); server->setMinimumSize ( server->sizeHint() ); + delete st; } void SessionButton::mousePressEvent ( QMouseEvent * event ) @@ -396,8 +449,8 @@ void SessionButton::mouseMoveEvent ( QMouseEvent * event ) { SVGFrame::mouseMoveEvent ( event ); - if(!editable) - return; + if (!editable) + return; if ( cmd->isVisible() ) if ( event->x() > cmd->x() && event->x() < cmd->x() + cmd->width() && diff --git a/sessionbutton.h b/sessionbutton.h index 8efaad4..b39bdb5 100644 --- a/sessionbutton.h +++ b/sessionbutton.h @@ -36,6 +36,7 @@ class SessionButton : public SVGFrame private: QString sid; QLabel* sessName; + QLabel* sessStatus; QLabel* icon; QComboBox* cmdBox; QLabel* cmd; diff --git a/sshmasterconnection.cpp b/sshmasterconnection.cpp index d36d675..224b7bf 100644 --- a/sshmasterconnection.cpp +++ b/sshmasterconnection.cpp @@ -28,8 +28,10 @@ #include <arpa/inet.h> #endif +#include "onmainwindow.h" + #undef DEBUG -#define DEBUG +// #define DEBUG static bool isLibSshInited=false; @@ -44,11 +46,13 @@ SshMasterConnection::SshMasterConnection ( QString host, int port, bool acceptUn this->autologin=autologin; this->acceptUnknownServers=acceptUnknownServers; reverseTunnel=false; + mainWnd=(ONMainWindow*) parent; } SshMasterConnection::SshMasterConnection ( QString host, int port, bool acceptUnknownServers, QString user, QString pass, QString key, bool autologin, - int remotePort, QString localHost, int localPort, SshProcess* creator, QObject* parent ) : QThread ( parent ) + int remotePort, QString localHost, int localPort, SshProcess* creator, + QObject* parent, ONMainWindow* mwd ) : QThread ( parent ) { this->host=host; @@ -63,6 +67,7 @@ SshMasterConnection::SshMasterConnection ( QString host, int port, bool acceptUn reverseTunnelCreator=creator; reverseTunnel=true; reverseTunnelRemotePort=remotePort; + mainWnd=mwd; } SshMasterConnection* SshMasterConnection::reverseTunnelConnection ( SshProcess* creator, @@ -70,7 +75,7 @@ SshMasterConnection* SshMasterConnection::reverseTunnelConnection ( SshProcess* { SshMasterConnection* con=new SshMasterConnection ( host,port,acceptUnknownServers,user,pass, key,autologin, remotePort,localHost, - localPort,creator,this ); + localPort,creator,this, mainWnd); connect ( con,SIGNAL ( ioErr ( SshProcess*,QString,QString ) ),this,SIGNAL ( ioErr ( SshProcess*,QString,QString ) ) ); connect ( con,SIGNAL ( stdErr ( SshProcess*,QByteArray ) ),this,SIGNAL ( stdErr ( SshProcess*,QByteArray ) ) ); @@ -120,7 +125,9 @@ void SshMasterConnection::run() quit(); return; } - +#ifdef Q_OS_WIN + ssh_options_set ( my_ssh_session, SSH_OPTIONS_SSH_DIR, (mainWnd->getHomeDirectory()+"/ssh").toAscii()); +#endif // ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); if ( !sshConnect() ) { @@ -146,9 +153,18 @@ void SshMasterConnection::run() } ssh_options_set ( my_ssh_session, SSH_OPTIONS_USER, user.toAscii() ); +#ifdef Q_OS_WIN + ssh_options_set ( my_ssh_session, SSH_OPTIONS_SSH_DIR, (mainWnd->getHomeDirectory()+"/ssh").toAscii()); +#endif + x2goDebug<<"setting SSH DIR to "<<mainWnd->getHomeDirectory()+"/ssh"; if ( userAuth() ) + { + #ifdef DEBUG + x2goDebug<<"user auth OK\n"; + #endif emit connectionOk(); + } else { QString err=ssh_get_error ( my_ssh_session ); @@ -317,7 +333,7 @@ bool SshMasterConnection::userAuthWithKey() if ( key.indexOf ( "PRIVATE KEY" ) !=-1 ) { QDir dr; - QString keyPath=QDir::homePath() +"/.x2go/ssh/gen"; + QString keyPath=mainWnd->getHomeDirectory() +"/.x2go/ssh/gen"; dr.mkpath ( keyPath ); QTemporaryFile fl ( keyPath+"/key" ); fl.open(); diff --git a/sshmasterconnection.h b/sshmasterconnection.h index a68c0b4..15d9235 100644 --- a/sshmasterconnection.h +++ b/sshmasterconnection.h @@ -24,6 +24,7 @@ #include <QThread> #include <QStringList> +class ONMainWindow; class SshProcess; struct ChannelConnection { @@ -72,7 +73,8 @@ public: private: SshMasterConnection(QString host, int port, bool acceptUnknownServers, QString user, QString pass, QString key, bool autologin, - int remotePort, QString localHost, int localPort, SshProcess* creator, QObject* parent = 0); + int remotePort, QString localHost, int localPort, SshProcess* creator, + QObject* parent, ONMainWindow* parWnd); bool sshConnect(); bool userAuthWithPass(); bool userAuthAuto(); @@ -105,7 +107,8 @@ private: int reverseTunnelLocalPort; bool acceptUnknownServers; QString reverseTunnelLocalHost; - SshProcess* reverseTunnelCreator; + SshProcess* reverseTunnelCreator; + ONMainWindow* mainWnd; signals: void stdErr(SshProcess* caller, QByteArray data); diff --git a/sshprocess.cpp b/sshprocess.cpp index 83d1ce4..9e72e8f 100644 --- a/sshprocess.cpp +++ b/sshprocess.cpp @@ -25,7 +25,7 @@ #endif #undef DEBUG -#define DEBUG +// #define DEBUG SshProcess::SshProcess(SshMasterConnection* master, QObject* parent): QObject(parent) { diff --git a/version.h b/version.h index 119983c..b49a660 100644 --- a/version.h +++ b/version.h @@ -1 +1 @@ -#define VERSION "3.0.1.18" +#define VERSION "3.0.99.0" diff --git a/wapi.cpp b/wapi.cpp index 297ead3..e565cc6 100644 --- a/wapi.cpp +++ b/wapi.cpp @@ -177,6 +177,38 @@ QString wapiShortFileName ( const QString& longName ) } +QString wapiGetDriveByLabel(const QString& label) +{ + int len=GetLogicalDriveStrings(0,0); + if(len>0) + { + TCHAR* buf=new TCHAR[len+1]; + len=GetLogicalDriveStrings(len,buf); + for(int i=0;i<len;i+=4) + { + QString drive=QString::fromUtf16 ( ( const ushort* ) buf+i ); + x2goDebug<<"drive:"<<drive; + TCHAR vol[MAX_PATH+1]; + TCHAR fs[MAX_PATH+1]; + GetVolumeInformation(buf+i,vol,MAX_PATH,0,0,0,fs,MAX_PATH); + QString volume=QString::fromUtf16 ( ( const ushort* ) vol ); + x2goDebug<<"vol:"<<volume<< + "fs:"<<QString::fromUtf16 ( ( const ushort* ) fs ); + if(!volume.compare(label,Qt::CaseInsensitive)) + { + x2goDebug<<"matched! "; + + delete []buf; + return drive.replace(":\\",""); + } + } + delete []buf; + } + + return label; +} + + QString getNameFromSid ( PSID psid, QString* systemName ) { DWORD length=0; diff --git a/wapi.h b/wapi.h index e5e59d2..ffdd392 100644 --- a/wapi.h +++ b/wapi.h @@ -51,6 +51,8 @@ QString wapiGetDefaultPrinter(); QStringList wapiGetLocalPrinters(); long wapiSetFSWindow ( HWND hWnd, const QRect& desktopGeometry ); void wapiRestoreWindow ( HWND hWnd, long style, const QRect& desktopGeometry ); +QString wapiGetDriveByLabel(const QString& label); + #endif diff --git a/x2goclient.pro b/x2goclient.pro index 6e6eb9f..6393fcf 100644 --- a/x2goclient.pro +++ b/x2goclient.pro @@ -7,9 +7,10 @@ CONFIG += $$(X2GO_CLIENT_TARGET) +CONFIG += $$(X2GO_LINUX_STATIC) +#CONFIG += console - -FORMS += cupsprintsettingsdialog.ui cupsprintwidget.ui printdialog.ui printercmddialog.ui printwidget.ui xsettingsui.ui +FORMS += cupsprintsettingsdialog.ui cupsprintwidget.ui printdialog.ui printercmddialog.ui printwidget.ui xsettingsui.ui brokerpassdialog.ui TRANSLATIONS += x2goclient_de.ts TRANSLATIONS += x2goclient_ru.ts @@ -46,6 +47,7 @@ HEADERS += configdialog.h \ ongetpass.h \ onmainwindow_privat.h \ x2gosettings.h \ + brokerpassdlg.h \ xsettingswidget.h SOURCES += sharewidget.cpp \ @@ -81,8 +83,11 @@ SOURCES += sharewidget.cpp \ httpbrokerclient.cpp \ ongetpass.cpp \ x2gosettings.cpp \ + brokerpassdlg.cpp \ xsettingswidget.cpp +LIBS += -lssh + plugin { TARGET = x2goplugin } @@ -107,6 +112,13 @@ linux-g++-64 { message(building $$TARGET with ldap and cups) LIBS += -lldap -lcups -lX11 } +x2go_linux_static { + message (linking all libs statically) + LIBS -= -lssh + LIBS += -lssh_static -lssl + QMAKE_LFLAGS = -Bstatic $$QMAKE_LFLAGS +} + macx { message(building $$TARGET with ldap and cups) LIBS += -lldap -lcups @@ -116,7 +128,6 @@ win32-* { LIBS += -lwinspool CONFIG += static } -LIBS += -lssh QT += svg network ICON =icons/x2go-mac.icns QMAKE_MAC_SDK =/Developer/SDKs/MacOSX10.6.sdk diff --git a/x2goclientconfig.h b/x2goclientconfig.h index 0e4983a..48a8992 100644 --- a/x2goclientconfig.h +++ b/x2goclientconfig.h @@ -6,7 +6,7 @@ #include <qglobal.h> -//#define LOGFILE QDir::homePath()+"/x2goclient.log" +// #define LOGFILE QDir::homePath()+"/x2goclient.log" #if !defined Q_OS_WIN #define USELDAP diff --git a/x2goplugin.rc b/x2goplugin.rc index 7f5aa21..2db7f67 100644 --- a/x2goplugin.rc +++ b/x2goplugin.rc @@ -1,8 +1,8 @@ 1 TYPELIB "x2goplugin.rc" 1 VERSIONINFO - FILEVERSION 3,0,1,18 - PRODUCTVERSION 3,0,1,18 + FILEVERSION 3,0,99,0 + PRODUCTVERSION 3,0,99,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -21,13 +21,13 @@ BEGIN VALUE "FileDescription", "Allows you to start X2Go session in a webbrowser\0" VALUE "FileExtents", "x2go\0" VALUE "FileOpenName", "Configuration File for X2Go Session (*.x2go)\0" - VALUE "FileVersion", "3, 0, 1, 18\0" + VALUE "FileVersion", "3, 0, 99, 0\0" VALUE "InternalName", "x2goplugin\0" VALUE "LegalCopyright", "Copyright � 2010 Obviously Nice\0" VALUE "MIMEType", "application/x2go\0" VALUE "OriginalFilename", "npx2goplugin.dll\0" - VALUE "ProductName", "X2GoClient Plug-in 3.0.1.18\0" - VALUE "ProductVersion", "3, 0, 1, 18\0" + VALUE "ProductName", "X2GoClient Plug-in 3.0.99.0\0" + VALUE "ProductVersion", "3, 0, 99, 0\0" END END BLOCK "VarFileInfo" diff --git a/x2gosettings.cpp b/x2gosettings.cpp index 9a5f59b..57fbc4a 100644 --- a/x2gosettings.cpp +++ b/x2gosettings.cpp @@ -13,30 +13,44 @@ #include "x2goclientconfig.h" #include "x2gologdebug.h" #include "onmainwindow.h" +#include <QTemporaryFile> + +X2goSettings::X2goSettings(QString fileContent, QSettings::Format format) +{ + cfgFile=new QTemporaryFile(); + cfgFile->open(); + QTextStream out(cfgFile); + out<<fileContent; + cfgFile->close(); + set=new QSettings ( cfgFile->fileName(), + format ); +} + X2goSettings::X2goSettings ( QString group ) { + cfgFile=0l; #ifndef Q_OS_WIN - set=new QSettings ( ONMainWindow::getHomeDirectory() + - "/.x2goclient/"+group, - QSettings::NativeFormat ); + set=new QSettings ( ONMainWindow::getHomeDirectory() + + "/.x2goclient/"+group, + QSettings::NativeFormat ); #else - if ( !ONMainWindow::getPortable() ) - { - set=new QSettings ( "Obviously Nice","x2goclient" ); - set->beginGroup ( group ); + if ( !ONMainWindow::getPortable() ) + { + set=new QSettings ( "Obviously Nice","x2goclient" ); + set->beginGroup ( group ); // x2goDebug<<"settings in reg"; - } - else - { - set=new QSettings ( ONMainWindow::getHomeDirectory() + - "/.x2goclient/"+group, - QSettings::IniFormat ); + } + else + { + set=new QSettings ( ONMainWindow::getHomeDirectory() + + "/.x2goclient/"+group, + QSettings::IniFormat ); // x2goDebug<<"settings in ini:"<< - ONMainWindow::getHomeDirectory() + - "/.x2goclient/"+group; + ONMainWindow::getHomeDirectory() + + "/.x2goclient/"+group; - } + } #endif } @@ -44,7 +58,9 @@ X2goSettings::X2goSettings ( QString group ) X2goSettings::~X2goSettings() { - delete set; + delete set; + if (cfgFile) + delete cfgFile; } diff --git a/x2gosettings.h b/x2gosettings.h index c59ecd1..fffd350 100644 --- a/x2gosettings.h +++ b/x2gosettings.h @@ -16,7 +16,7 @@ #include <QSettings> - +class QTemporaryFile; /** @author Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> */ @@ -24,6 +24,7 @@ class X2goSettings { public: X2goSettings ( QString group ); + X2goSettings ( QString fileContent, QSettings::Format format); ~X2goSettings(); QSettings* setting() @@ -33,6 +34,7 @@ public: private: QSettings* set; + QTemporaryFile* cfgFile; }; diff --git a/xsettingsui.ui b/xsettingsui.ui index 43d6d61..fa06cbf 100644 --- a/xsettingsui.ui +++ b/xsettingsui.ui @@ -47,7 +47,7 @@ <item> <widget class="QRadioButton" name="rbXming"> <property name="text"> - <string>use integrated XMing</string> + <string>use integrated X-Server</string> </property> <property name="checked"> <bool>true</bool> @@ -158,33 +158,6 @@ </layout> </widget> </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>delay after X-Server start (s):</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spDelay"/> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> </layout> </widget> </item> diff --git a/xsettingswidget.cpp b/xsettingswidget.cpp index 3991552..7cd117b 100644 --- a/xsettingswidget.cpp +++ b/xsettingswidget.cpp @@ -26,8 +26,8 @@ XSettingsWidget::XSettingsWidget(QWidget* parent) setupUi(this); X2goSettings st ( "settings" ); - rbXming->setChecked(st.setting()->value("usexming",true).toBool()); - rbOther->setChecked(!(st.setting()->value("usexming",true).toBool())); + rbXming->setChecked(st.setting()->value("useintx",true).toBool()); + rbOther->setChecked(!(st.setting()->value("useintx",true).toBool())); leExec->setText(st.setting()->value("xexec","C:\\program files\\vcxsrv\\vcxsrv.exe").toString()); leCmdOptions->setText(st.setting()->value("options","-multiwindow -notrayicon -clipboard").toString()); @@ -37,7 +37,7 @@ XSettingsWidget::XSettingsWidget(QWidget* parent) leWinMod->setText(st.setting()->value("optionswin","-screen 0 %wx%h -notrayicon -clipboard").toString()); leFSMod->setText(st.setting()->value("optionsfs","-fullscreen -notrayicon -clipboard").toString()); leSingApp->setText(st.setting()->value("optionssingle","-multiwindow -notrayicon -clipboard").toString()); - spDelay->setValue(st.setting()->value("delay",3).toInt()); +// spDelay->setValue(st.setting()->value("delay",3).toInt()); pbExec->setIcon( QPixmap ( ":/icons/16x16/file-open.png" ) ); } @@ -58,21 +58,21 @@ void XSettingsWidget::slotSetExecutable() void XSettingsWidget::setDefaults() { - rbXming->setChecked("usexming"); + rbXming->setChecked(true); leExec->setText("C:\\program files\\vcxsrv\\vcxsrv.exe"); leCmdOptions->setText("-multiwindow -notrayicon -clipboard"); cbOnstart->setChecked(true); leWinMod->setText("-screen 0 %wx%h -notrayicon -clipboard"); leFSMod->setText("-fullscreen -notrayicon -clipboard"); leSingApp->setText("-multiwindow -notrayicon -clipboard"); - spDelay->setValue(3); +// spDelay->setValue(3); } void XSettingsWidget::saveSettings() { X2goSettings st ( "settings" ); - st.setting()->setValue("usexming",rbXming->isChecked()); + st.setting()->setValue("useintx",rbXming->isChecked()); st.setting()->setValue("xexec",leExec->text()); st.setting()->setValue("options",leCmdOptions->text()); st.setting()->setValue("onstart",cbOnstart->isChecked()); @@ -80,7 +80,7 @@ void XSettingsWidget::saveSettings() st.setting()->setValue("optionswin",leWinMod->text()); st.setting()->setValue("optionsfs",leFSMod->text()); st.setting()->setValue("optionssingle",leSingApp->text()); - st.setting()->setValue("delay",spDelay->value()); +// st.setting()->setValue("delay",spDelay->value()); st.setting()->sync(); } hooks/post-receive -- x2goclient.git (X2go Client) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "x2goclient.git" (X2go Client).