This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit d3e1f850d6cde233d94e24b0ce6c59f77a848c60 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Tue Oct 29 13:51:10 2019 +0100 Add possibility to suspend and terminate sessions from session selection dialog in broker mode. --- debian/changelog | 1 + src/onmainwindow.cpp | 126 ++++++++++++++++++++++++++++++++++++--------------- src/onmainwindow.h | 15 +++++- 3 files changed, 105 insertions(+), 37 deletions(-) diff --git a/debian/changelog b/debian/changelog index 490b0b6..6272987 100644 --- a/debian/changelog +++ b/debian/changelog @@ -39,6 +39,7 @@ x2goclient (4.1.2.2-0x2go1) UNRELEASED; urgency=medium format. Supporting both Windows and Linux path in automount format. Check if path exists before mounting. - Do not show Pulseaudio warning on Windows, if Pulseaudio is disabled in settings or by command line. - Improve request handling in HTTP broker. + - Add possibility to suspend and terminate sessions from session selection dialog in broker mode. [ Mihai Moldovan ] * New upstream version (4.1.2.2): diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp index 13c69cd..823fd81 100644 --- a/src/onmainwindow.cpp +++ b/src/onmainwindow.cpp @@ -221,6 +221,8 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent ) #endif /* defined (Q_OS_DARWIN) || defined (Q_OS_WIN) */ + connectionType=DEFAULT; + hide(); kdeIconsPath=getKdeIconsPath(); @@ -2943,7 +2945,21 @@ void ONMainWindow::slotSshConnectionOk() continueLDAPSession(); } else - continueNormalSession(); + { + if(brokerMode && (connectionType != DEFAULT)) + { + if(connectionType==SUSPEND) + { + suspendSession(suspendTerminateSessionFromBroker); + } + else + { + termSession(suspendTerminateSessionFromBroker, false); + } + } + else + continueNormalSession(); + } } void ONMainWindow::cleanServerSshConnections() @@ -3619,8 +3635,9 @@ QString ONMainWindow::findSshKeyForServer(QString user, QString server, QString } -bool ONMainWindow::startSession ( const QString& sid ) +bool ONMainWindow::startSession ( const QString& sid, CONTYPE conType ) { + connectionType=conType; setEnabled ( false ); #ifdef Q_OS_LINUX directRDP=false; @@ -3664,7 +3681,10 @@ bool ONMainWindow::startSession ( const QString& sid ) passForm->setEnabled ( false ); if(brokerMode) { - host=config.serverIp; + if(connectionType==DEFAULT) + host=config.serverIp; + else + host=suspendTerminateHostFromBroker; sshPort=config.sshport; x2goDebug<<"Server: "<<host; } @@ -4990,11 +5010,6 @@ void ONMainWindow::selectSession ( QStringList& sessions ) } } - if(brokerMode) - { - bSusp->hide(); - bTerm->hide(); - } sessTv->setCurrentIndex ( sessTv->model()->index ( 0, 0 ) ); sessTv->setFocus(); @@ -5145,28 +5160,29 @@ void ONMainWindow::slotSuspendSess() QString host=sessTv->model()->index ( sessTv->currentIndex().row(), S_SERVER ).data().toString(); + + if ( !useLdap ) { - if ( brokerMode ) - { - host=config.serverIp; - } - if ( embedMode ) - { - host=config.server; - } - else + if ( !brokerMode ) { - X2goSettings st ( "sessions" ); - - if (!(sessionExplorer->getLastSession())) { - x2goDebug << "No session selected, returning without suspending a session."; - return; + if ( embedMode ) + { + host=config.server; } + else + { + X2goSettings st ( "sessions" ); - QString sid=sessionExplorer->getLastSession()->id(); - host=st.setting()->value ( sid+"/host", - ( QVariant ) host ).toString(); + if (!(sessionExplorer->getLastSession())) { + x2goDebug << "No session selected, returning without suspending a session."; + return; + } + + QString sid=sessionExplorer->getLastSession()->id(); + host=st.setting()->value ( sid+"/host", + ( QVariant ) host ).toString(); + } } } else @@ -5182,8 +5198,14 @@ void ONMainWindow::slotSuspendSess() } } - - suspendSession ( sessId ); + if(brokerMode) + { + suspendBrokerSession(sessId, host); + } + else + { + suspendSession ( sessId ); + } } @@ -5262,6 +5284,7 @@ void ONMainWindow::slotTermSessFromSt() void ONMainWindow::slotRetSuspSess ( bool result, QString output, int ) { + setEnabled ( true ); if ( result==false ) { QString message=tr ( "<b>Connection failed.</b>\n" ) +output; @@ -5317,6 +5340,9 @@ void ONMainWindow::slotTermSess() QString sessId=sessTv->model()->index ( sessTv->currentIndex().row(), S_ID ).data().toString(); + QString host=sessTv->model()->index ( + sessTv->currentIndex().row(), + S_SERVER ).data().toString(); if ( !useLdap ) { @@ -5334,9 +5360,6 @@ void ONMainWindow::slotTermSess() } else { - QString host=sessTv->model()->index ( sessTv->currentIndex().row(), - S_SERVER ).data().toString(); - sshConnection=findServerSshConnection(host); if (!sshConnection) { @@ -5347,8 +5370,14 @@ void ONMainWindow::slotTermSess() return; } } - - termSession ( sessId ); + if(brokerMode) + { + termBrokerSession(sessId, host); + } + else + { + termSession ( sessId ); + } } @@ -5361,6 +5390,7 @@ void ONMainWindow::slotNewSess() void ONMainWindow::slotRetTermSess ( bool result, QString output, int ) { + setEnabled ( true ); if ( result==false ) { QString message=tr ( "<b>Connection failed.</b>\n" ) +output; @@ -6844,6 +6874,33 @@ void ONMainWindow::slotResumeDoubleClick ( const QModelIndex& ) slotResumeSess(); } +void ONMainWindow::suspendBrokerSession(const QString& sessId, const QString& host) +{ + suspendTerminateHostFromBroker=host; + suspendTerminateSessionFromBroker=sessId; + startSession(config.session, SUSPEND); +} + +void ONMainWindow::termBrokerSession(const QString& sessId, const QString& host) +{ + if(QMessageBox::warning ( + this,tr ( "Warning" ), + tr ( + "Are you sure you want to terminate " + "this session?\n" + "Unsaved documents will be lost." ), + QMessageBox::Yes,QMessageBox::No )!= QMessageBox::Yes) + { + setEnabled(true); + selectSessionDlg->setEnabled ( true ); + return; + } + + suspendTerminateHostFromBroker=host; + suspendTerminateSessionFromBroker=sessId; + startSession(config.session, TERMINATE); +} + void ONMainWindow::suspendSession ( QString sessId ) { @@ -12678,8 +12735,7 @@ void ONMainWindow::initSelectSessDlg() alay->addWidget ( bShadowView ); alay->addWidget ( bShadow ); alay->addStretch(); - if(!brokerMode) - alay->addWidget ( bNew ); + alay->addWidget ( bNew ); alay->addWidget ( bCancel ); tvlay->addWidget ( sessTv ); @@ -12687,8 +12743,6 @@ void ONMainWindow::initSelectSessDlg() blay->addStretch(); blay->addWidget ( sOk ); - if(brokerMode) - blay->addWidget ( bNew ); blay->addWidget ( sCancel ); blay->addStretch(); if ( !miniMode ) diff --git a/src/onmainwindow.h b/src/onmainwindow.h index 2761c64..7909593 100644 --- a/src/onmainwindow.h +++ b/src/onmainwindow.h @@ -325,8 +325,10 @@ public: static bool isServerRunning ( int port ); void startNewSession(); void suspendSession ( QString sessId ); + void suspendBrokerSession ( const QString& sessId, const QString& host ); bool termSession ( QString sessId, bool warn=true ); + void termBrokerSession ( const QString& sessId, const QString& host ); InteractionDialog* getInteractionDialog() { return interDlg; @@ -915,6 +917,17 @@ private: bool trayMinCon; bool trayMaxDiscon; bool trayAutoHidden; + + //server connection type + // DEFAULT - start X2GO session + // SUSPEND - open connection to suspend broker session + // TERMINATE - open connection to terminate broker session + typedef enum {DEFAULT, SUSPEND, TERMINATE} CONTYPE; + + CONTYPE connectionType; + QString suspendTerminateHostFromBroker; + QString suspendTerminateSessionFromBroker; + void sendEventToBroker(client_events ev); void suspendFromBroker(const QString& sid); void terminateFromBroker(const QString& sid); @@ -930,7 +943,7 @@ private: QString getKdeIconsPath(); QString findTheme ( QString theme ); bool initLdapSession ( bool showBox=true ); - bool startSession ( const QString& id ); + bool startSession ( const QString& id, CONTYPE conType=DEFAULT); x2goSession getSessionFromString ( const QString& string ); void resumeSession ( const x2goSession& s ); void selectSession ( QStringList& sessions ); -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git