[X2Go-Commits] [x2goclient] 02/02: Fix resuming sessions on multiply servers.
git-admin at x2go.org
git-admin at x2go.org
Wed Apr 3 17:38:57 CEST 2019
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch feature/kdrive_support
in repository x2goclient.
commit 7131865a7597e2306c6399451d98c8e0501cfc7b
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date: Wed Apr 3 17:37:46 2019 +0200
Fix resuming sessions on multiply servers.
---
src/httpbrokerclient.cpp | 27 +++++++++++++++++++++---
src/httpbrokerclient.h | 2 ++
src/onmainwindow.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++------
src/onmainwindow.h | 1 +
4 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/src/httpbrokerclient.cpp b/src/httpbrokerclient.cpp
index b9c0337..fc2cee3 100644
--- a/src/httpbrokerclient.cpp
+++ b/src/httpbrokerclient.cpp
@@ -663,6 +663,7 @@ void HttpBrokerClient::slotRequestFinished ( QNetworkReply* reply )
void HttpBrokerClient::parseSession(QString sinfo)
{
config->sessiondata="";
+ suspendedSession.clear();
x2goDebug<<"Starting parser.";
QStringList lst=sinfo.split("SERVER:",QString::SkipEmptyParts);
int keyStartPos=sinfo.indexOf("-----BEGIN DSA PRIVATE KEY-----");
@@ -687,11 +688,31 @@ void HttpBrokerClient::parseSession(QString sinfo)
if (sinfo.indexOf("SESSION_INFO")!=-1)
{
QStringList lst=sinfo.split("SESSION_INFO:",QString::SkipEmptyParts);
- config->sessiondata=lst[1];
- x2goDebug<<"Session data: "<<config->sessiondata<<"\n";
+ //config->sessiondata=lst[1];
+ x2goDebug<<"Session data: "<<lst[1]<<"\n";
+ suspendedSession=lst[1].trimmed().split ( '\n', QString::SkipEmptyParts );
+ mainWindow->selectSession(suspendedSession);
+ }
+ else
+ {
+ emit sessionSelected();
}
x2goDebug<<"Parsing has finished.";
- emit sessionSelected();
+}
+
+void HttpBrokerClient::resumeSession(const QString& id, const QString& server)
+{
+ x2goDebug<<"Resuming session with id:"<<id<<"on:"<<server;
+ foreach (QString sline, suspendedSession)
+ {
+ if(sline.indexOf(id)!=-1)
+ {
+ config->sessiondata=sline;
+ config->serverIp=server;
+ emit sessionSelected();
+ break;
+ }
+ }
}
diff --git a/src/httpbrokerclient.h b/src/httpbrokerclient.h
index 73ae2ef..d01c734 100644
--- a/src/httpbrokerclient.h
+++ b/src/httpbrokerclient.h
@@ -47,6 +47,7 @@ public:
void closeSSHInteractionDialog();
void sendEvent(const QString& ev, const QString& id, const QString& server, const QString& client,
const QString& login, const QString& cmd, const QString& display, const QString& start, uint connectionTime);
+ void resumeSession(const QString& id, const QString& server);
private:
QNetworkAccessManager* http;
QNetworkRequest* netRequest;
@@ -63,6 +64,7 @@ private:
QTime requestTime;
bool sshBroker;
SshMasterConnection* sshConnection;
+ QStringList suspendedSession;
private:
void createIniFile(const QString& raw_content);
void processClientConfig(const QString& raw_content);
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index ec3623c..b696188 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -462,7 +462,6 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
saveCygnusSettings();
#endif
initPassDlg();
- initSelectSessDlg();
initStatusDlg();
interDlg=new InteractionDialog(bgFrame);
connect(interDlg, SIGNAL(closeInterractionDialog()), this, SLOT(slotCloseInteractionDialog()));
@@ -559,6 +558,8 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
SLOT ( slotSendBrokerAlive() ) );
}
+ initSelectSessDlg();
+
proxyWinTimer=new QTimer ( this );
connect ( proxyWinTimer, SIGNAL ( timeout() ), this,
SLOT ( slotFindProxyWin() ) );
@@ -3916,6 +3917,13 @@ void ONMainWindow::slotListSessions ( bool result,QString output,
QDesktopWidget wd;
+ //we already selected the session
+ if(brokerMode)
+ {
+ resumeSession(s);
+ return;
+ }
+
/* Check getSessionFromString for what this "invalid" string means. */
if ((s.agentPid != "invalid") && (s.status == "S")
&& (isColorDepthOk (wd.depth (), s.colorDepth))
@@ -3986,6 +3994,8 @@ x2goSession ONMainWindow::getSessionFromString ( const QString& string )
s.sndPort=lst[9];
if ( lst.count() >13 )
s.fsPort=lst[13];
+ if (brokerMode && lst.count()>14)
+ s.brokerUser=lst[14];
s.colorDepth=0;
if ( s.sessionId.indexOf ( "_dp" ) !=-1 )
{
@@ -4848,7 +4858,10 @@ void ONMainWindow::selectSession ( QStringList& sessions )
selectedSessions.append ( s );
QStandardItem *item;
- item= new QStandardItem ( s.display );
+ if(!brokerMode)
+ item= new QStandardItem ( s.display );
+ else
+ item= new QStandardItem ( s.brokerUser );
model->setItem ( row,S_DISPLAY,item );
if ( s.status=="R" )
@@ -4960,6 +4973,12 @@ void ONMainWindow::selectSession ( QStringList& sessions )
}
}
+ if(brokerMode)
+ {
+ bSusp->hide();
+ bTerm->hide();
+ }
+
sessTv->setCurrentIndex ( sessTv->model()->index ( 0, 0 ) );
sessTv->setFocus();
selectSessionDlg->show();
@@ -5019,6 +5038,11 @@ void ONMainWindow::slotActivated ( const QModelIndex& index )
void ONMainWindow::slotResumeSess()
{
x2goSession s=getSelectedSession();
+ if(brokerMode)
+ {
+ broker->resumeSession(s.sessionId, s.server);
+ return;
+ }
QDesktopWidget wd;
if ( isColorDepthOk ( wd.depth(),s.colorDepth ) )
{
@@ -12517,8 +12541,14 @@ void ONMainWindow::initSelectSessDlg()
sessTv->setRootIsDecorated ( false );
model=new QStandardItemModel ( sessionExplorer->getSessionsList()->size(), 8 );
- model->setHeaderData ( S_DISPLAY,Qt::Horizontal,
- QVariant ( ( QString ) tr ( "Display" ) ) );
+ if(!brokerMode)
+ model->setHeaderData ( S_DISPLAY,Qt::Horizontal,
+ QVariant ( ( QString ) tr ( "Display" ) ) );
+ else
+ {
+ model->setHeaderData ( S_DISPLAY,Qt::Horizontal,
+ QVariant ( ( QString ) tr ( "User" ) ) );
+ }
model->setHeaderData ( S_STATUS,Qt::Horizontal,
QVariant ( ( QString ) tr ( "Status" ) ) );
model->setHeaderData ( S_COMMAND,Qt::Horizontal,
@@ -12593,7 +12623,8 @@ void ONMainWindow::initSelectSessDlg()
alay->addWidget ( bShadowView );
alay->addWidget ( bShadow );
alay->addStretch();
- alay->addWidget ( bNew );
+ if(!brokerMode)
+ alay->addWidget ( bNew );
alay->addWidget ( bCancel );
tvlay->addWidget ( sessTv );
@@ -12601,6 +12632,8 @@ void ONMainWindow::initSelectSessDlg()
blay->addStretch();
blay->addWidget ( sOk );
+ if(brokerMode)
+ blay->addWidget ( bNew );
blay->addWidget ( sCancel );
blay->addStretch();
if ( !miniMode )
@@ -12619,13 +12652,21 @@ void ONMainWindow::initSelectSessDlg()
connect ( sessTv,SIGNAL ( selected ( const QModelIndex& ) ),
this,SLOT ( slotActivated ( const QModelIndex& ) ) );
+ connect ( sOk,SIGNAL ( clicked() ),this, SLOT ( slotResumeSess() ) );
connect ( sessTv,SIGNAL ( doubleClicked ( const QModelIndex& ) ),
this,SLOT ( slotResumeDoubleClick ( const QModelIndex& ) ) );
- connect ( sOk,SIGNAL ( clicked() ),this, SLOT ( slotResumeSess() ) );
+ if(!brokerMode)
+ {
+ connect ( bNew,SIGNAL ( clicked() ),this, SLOT ( slotNewSess() ) );
+ }
+ else
+ {
+ connect ( bNew,SIGNAL ( clicked() ),broker, SIGNAL ( sessionSelected() ) );
+ }
+
connect ( bSusp,SIGNAL ( clicked() ),this, SLOT ( slotSuspendSess() ) );
connect ( bTerm,SIGNAL ( clicked() ),this, SLOT ( slotTermSess() ) );
- connect ( bNew,SIGNAL ( clicked() ),this, SLOT ( slotNewSess() ) );
connect ( bShadow,SIGNAL ( clicked() ),this,
SLOT ( slotShadowSess() ) );
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index b8d04d7..6bcbf66 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -146,6 +146,7 @@ struct x2goSession
QString grPort;
QString sndPort;
QString fsPort;
+ QString brokerUser;
uint connectedSince;
bool published;
int colorDepth;
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list