[X2Go-Commits] [x2goclient] 01/01: Client can synchronize sessions with broker. Broker need to send syncinterval value in the client config section.
git-admin at x2go.org
git-admin at x2go.org
Tue May 12 20:21:45 CEST 2020
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2goclient.
commit 15f7c78fc28e93223024e2f4c308589a4b5214fd
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date: Tue May 12 13:21:25 2020 -0500
Client can synchronize sessions with broker. Broker need to send syncinterval value in the client config section.
---
debian/changelog | 2 ++
src/httpbrokerclient.cpp | 13 +++++---
src/onmainwindow.cpp | 51 ++++++++++++++++++----------
src/onmainwindow.h | 8 +++--
src/sessionbutton.cpp | 6 +++-
src/sessionbutton.h | 9 +++++
src/sessionexplorer.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++-----
src/sessionexplorer.h | 3 ++
8 files changed, 146 insertions(+), 33 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 9625ac9..85b363b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium
- Download alternative resource files from http server.
- Support for PNG background images.
- Display state of broker connection in status bar.
+ - Client can synchronize sessions with broker. Broker need to send syncinterval
+ value in the client config section.
[ Ryan Schmidt ]
* New upstream version (4.1.2.3):
diff --git a/src/httpbrokerclient.cpp b/src/httpbrokerclient.cpp
index da08fed..f61bfce 100644
--- a/src/httpbrokerclient.cpp
+++ b/src/httpbrokerclient.cpp
@@ -501,7 +501,8 @@ void HttpBrokerClient::processClientConfig(const QString& raw_content)
{
X2goSettings st(raw_content, QSettings::IniFormat);
mainWindow->config.brokerEvents=st.setting()->value("events",false).toBool();
- mainWindow->config.brokerLiveEventsTimeout=st.setting()->value("liveevent",false).toUInt();
+ mainWindow->config.brokerLiveEventsTimeout=st.setting()->value("liveevent",0).toUInt();
+ mainWindow->config.brokerSyncTimeout=st.setting()->value("syncinterval",0).toUInt();
if(mainWindow->config.brokerEvents)
{
x2goDebug<<"sending client events to broker";
@@ -510,6 +511,10 @@ void HttpBrokerClient::processClientConfig(const QString& raw_content)
x2goDebug<<"sending alive events to broker every "<<mainWindow->config.brokerLiveEventsTimeout<<" seconds";
}
}
+ if(mainWindow->config.brokerSyncTimeout)
+ {
+ x2goDebug<<"synchronizing with broker every "<<mainWindow->config.brokerSyncTimeout<<" seconds";
+ }
}
@@ -518,7 +523,7 @@ void HttpBrokerClient::createIniFile(const QString& raw_content)
QString content;
content = raw_content;
content.replace("<br>","\n");
- x2goDebug<<"Inifile content: "<<content<<endl;
+// x2goDebug<<"Inifile content: "<<content<<endl;
QString cont;
QStringList lines=content.split("START_USER_SESSIONS\n");
if (lines.count()>1)
@@ -543,7 +548,7 @@ void HttpBrokerClient::createIniFile(const QString& raw_content)
bool HttpBrokerClient::checkAccess(QString answer )
{
- x2goDebug<<"Called checkAccess - answer was: "<<answer;
+// x2goDebug<<"Called checkAccess - answer was: "<<answer;
if (answer.indexOf("Access granted")==-1)
{
QMessageBox::critical (
@@ -653,7 +658,7 @@ void HttpBrokerClient::slotRequestFinished ( QNetworkReply* reply )
}
QString answer ( reply->readAll() );
- x2goDebug<<"A http request returned. Result was: "<<answer;
+// x2goDebug<<"A http request returned. Result was: "<<answer;
if (reply == testConRequest)
{
testConRequest=0l;
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index e61a631..f570967 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -209,6 +209,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
readExportsFrom=QString::null;
spoolTimer=0l;
brokerAliveTimer=0l;
+ brokerSyncTimer=0l;
#ifdef Q_OS_DARWIN
modMapTimer = NULL;
kbMap = QString ();
@@ -607,6 +608,8 @@ void ONMainWindow::initUI()
brokerAliveTimer=new QTimer(this);
connect ( brokerAliveTimer, SIGNAL ( timeout() ), this,
SLOT ( slotSendBrokerAlive() ) );
+ brokerSyncTimer=new QTimer(this);
+ connect ( brokerSyncTimer, SIGNAL( timeout()), broker , SLOT(getUserSessions()));
}
initSelectSessDlg();
@@ -1002,6 +1005,7 @@ void ONMainWindow::initWidgetsNormal()
QTimer::singleShot ( 1, this, SLOT ( slotReadSessions() ) );
else
{
+ bgLay->insertStretch(3);
QTimer::singleShot(1, this,SLOT(slotGetBrokerAuth()));
}
}
@@ -1092,7 +1096,6 @@ void ONMainWindow::slotGetBrokerAuth()
users->hide();
ln->hide();
- bgLay->insertStretch(3);
QString text=tr("<b>Authentication</b>");
/* if(config.brokerName.length()>0)
@@ -1852,6 +1855,17 @@ void ONMainWindow::slotSelectedFromList ( UserButton* user )
showPass ( user );
}
+
+bool ONMainWindow::isPassFormHidden()
+{
+ return passForm->isHidden();
+}
+
+bool ONMainWindow::isSelectFormHidden()
+{
+ return selectSessionDlg->isHidden();
+}
+
void ONMainWindow::slotClosePass()
{
if (brokerMode)
@@ -1882,6 +1896,7 @@ void ONMainWindow::slotClosePass()
sessionExplorer->getLastSession()->show();
uname->setText ( sessionExplorer->getLastSession()->name() );
}
+ sessionExplorer->setLastSession(0);
}
uname->setEnabled ( true );
u->setEnabled ( true );
@@ -2296,13 +2311,11 @@ void ONMainWindow::slotReadSessions()
if(brokerMode)
{
- bgLay->removeItem(bgLay->itemAt(3));
+// bgLay->removeItem(bgLay->itemAt(3));
slotResize(QSize(width(), height()));
}
X2goSettings *st;
- sessionExplorer->cleanSessions();
- sessionExplorer->setLastSession(0);
if (brokerMode)
{
@@ -2311,18 +2324,22 @@ void ONMainWindow::slotReadSessions()
config.key=QString::null;
config.user=QString::null;
config.sessiondata=QString::null;
- for (int i=sessionExplorer->getSessionsList()->count()-1; i>=0; --i)
- {
- SessionButton* but=sessionExplorer->getSessionsList()->takeAt(i);
- if (but)
- delete but;
- }
st=new X2goSettings(config.iniFile,QSettings::IniFormat);
sessionStatusDlg->hide();
- selectSessionDlg->hide();
setEnabled ( true );
- slotClosePass();
+ if(config.brokerSyncTimeout*1000!=brokerSyncTimer->interval())
+ {
+ brokerSyncTimer->setInterval(config.brokerSyncTimeout*1000);
+ }
+ if(config.brokerSyncTimeout && !(brokerSyncTimer->isActive()))
+ {
+ brokerSyncTimer->start();
+ }
+ if(!config.brokerSyncTimeout)
+ {
+ brokerSyncTimer->stop();
+ }
}
else
st= new X2goSettings( "sessions" );
@@ -2341,12 +2358,7 @@ void ONMainWindow::slotReadSessions()
close();
return;
}
- for ( int i=0; i<slst.size(); ++i )
- {
- if ( slst[i]!="embedded" )
- sessionExplorer->createBut ( slst[i] );
- }
- sessionExplorer->placeButtons();
+ sessionExplorer->updateSessions(slst);
if ( slst.size() ==0 )
slotNewSession();
uname->setText ( "" );
@@ -3731,6 +3743,9 @@ bool ONMainWindow::startSession ( const QString& sid, CONTYPE conType )
bool proxyAutologin=false;
bool proxyKrbLogin=false;
+ if(brokerMode)
+ brokerSyncTimer->stop();
+
user=getCurrentUname();
runRemoteCommand=true;
if(!embedMode)
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index b2ebae6..bf47328 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -173,6 +173,7 @@ struct ConfigFile
bool brokerKrbLogin;
bool brokerEvents; //Send events to broker and get control commands
uint brokerLiveEventsTimeout; //(seconds)How often send alive events, 0 - do not send
+ uint brokerSyncTimeout; //(seconds)How often synchronize with broker, 0 - not synchronize
QString brokerSshKey;
QString brokerCaCertFile;
QString iniFile;
@@ -571,6 +572,8 @@ public:
bool startSshd (key_types key_type = RSA_KEY_TYPE);
QSize getEmbedAreaSize();
void setBrokerStatus(const QString& text, bool error=false);
+ bool isPassFormHidden();
+ bool isSelectFormHidden();
#ifdef Q_OS_WIN
static QString cygwinPath ( const QString& winPath );
void startXOrg(std::size_t start_offset = 0);
@@ -738,6 +741,7 @@ private:
QTimer *proxyWinTimer;
QTimer *xineramaTimer;
QTimer *brokerAliveTimer;
+ QTimer *brokerSyncTimer;
short xinSizeInc;
QRect lastDisplayGeometry;
QList <QRect> xineramaScreens;
@@ -1049,7 +1053,6 @@ private slots:
void readUsers();
void slotSelectedFromList ( UserButton* user );
void slotUnameEntered();
- void slotClosePass();
void slotReadSessions();
void slotManage();
void displayToolBar ( bool );
@@ -1080,6 +1083,8 @@ public slots:
void slotActivateWindow();
void setFocus();
void slotEnableBrokerLogoutButton ();
+ void slotClosePass();
+ void slotCloseSelectDlg();
private slots:
void slotSendBrokerAlive();
@@ -1087,7 +1092,6 @@ private slots:
void slotSnameChanged ( const QString& );
void slotSelectedFromList ( SessionButton* session );
void slotSessEnter();
- void slotCloseSelectDlg();
void slotActivated ( const QModelIndex& index );
void slotResumeSess();
void slotSuspendSess();
diff --git a/src/sessionbutton.cpp b/src/sessionbutton.cpp
index 15bf74e..6467fe9 100644
--- a/src/sessionbutton.cpp
+++ b/src/sessionbutton.cpp
@@ -58,6 +58,7 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id )
setPalette(pal);
+ updated=false;
QFont fnt=font();
if ( mw->retMiniMode() )
@@ -293,6 +294,8 @@ void SessionButton::slotRemove()
void SessionButton::redraw()
{
+
+ updated=true;
bool snd;
@@ -322,6 +325,7 @@ void SessionButton::redraw()
sessName->setText (elName);
sessName->setToolTip(nameofSession);
+ sessStatus->setText("");
QString status=st->setting()->value ( sid+"/status",
( QVariant ) QString::null ).toString();
if (status == "R")
@@ -362,7 +366,7 @@ void SessionButton::redraw()
{
sessIcon=par->iconsPath("/128x128/x2gosession.png");
}
- x2goDebug << "Creating QPixmap with session icon: " << sessIcon.toLatin1 () << ".";
+// x2goDebug << "Creating QPixmap with session icon: " << sessIcon.toLatin1 () << ".";
if (!par->brokerMode || sessIcon == par->iconsPath("/128x128/x2gosession.png"))
pix=new QPixmap( sessIcon );
else
diff --git a/src/sessionbutton.h b/src/sessionbutton.h
index 78115b0..d831e61 100644
--- a/src/sessionbutton.h
+++ b/src/sessionbutton.h
@@ -52,6 +52,14 @@ public:
{
this->path=path;
}
+ void setNotUpdated()
+ {
+ updated=false;
+ }
+ bool isUpdated()
+ {
+ return updated;
+ }
private:
QString nameofSession;
@@ -79,6 +87,7 @@ private:
bool rootless;
bool published;
bool editable;
+ bool updated;
private slots:
void slotClicked();
diff --git a/src/sessionexplorer.cpp b/src/sessionexplorer.cpp
index a6e33c6..d163aa6 100644
--- a/src/sessionexplorer.cpp
+++ b/src/sessionexplorer.cpp
@@ -67,6 +67,55 @@ SessionExplorer::~SessionExplorer()
{
}
+SessionButton * SessionExplorer::findSession(const QString& id)
+{
+ foreach (SessionButton* s, sessions)
+ {
+ if(s->id()==id)
+ return s;
+ }
+ return 0;
+}
+
+
+void SessionExplorer::updateSessions(QStringList slst)
+{
+ foreach (SessionButton* s, sessions)
+ {
+ s->setNotUpdated();
+ }
+ for ( int i=0; i<slst.size(); ++i )
+ {
+ if ( slst[i]=="embedded" )
+ continue;
+ SessionButton* s=findSession(slst[i]);
+ if(!s)
+ {
+ s=createBut ( slst[i] );
+ }
+ else
+ checkPath(s);
+ s->redraw();
+ }
+ foreach (SessionButton* s, sessions)
+ {
+ if(!s->isUpdated())
+ {
+ sessions.removeOne(s);
+ if(s==lastSession)
+ {
+ lastSession=0;
+ parent->slotCloseSelectDlg();
+ parent->slotClosePass();
+ }
+ delete s;
+ }
+ }
+
+ placeButtons();
+}
+
+
void SessionExplorer::resize()
{
pathLabel->setMaximumWidth(parent->getUsersArea()->width()-backButton->width());
@@ -242,6 +291,17 @@ void SessionExplorer::slotCreateDesktopIcon ( SessionButton* bt )
#endif
}
+void SessionExplorer::checkPath(SessionButton* s)
+{
+ if(s->getPath()!="")
+ {
+ if(findFolder(s->getPath())==-1)
+ {
+ createFolder(s->getPath());
+ }
+ }
+}
+
SessionButton* SessionExplorer::createBut ( const QString& id )
{
@@ -257,13 +317,7 @@ SessionButton* SessionExplorer::createBut ( const QString& id )
connect ( l,SIGNAL ( sessionSelected ( SessionButton* ) ),parent,
SLOT ( slotSelectedFromList ( SessionButton* ) ) );
- if(l->getPath()!="")
- {
- if(findFolder(l->getPath())==-1)
- {
- createFolder(l->getPath());
- }
- }
+ checkPath(l);
return l;
}
@@ -281,7 +335,7 @@ void SessionExplorer::placeButtons()
for ( int i=0; i<folders.size(); ++i )
{
- if(folders[i]->getPath() != currentPath)
+ if((folders[i]->getPath() != currentPath)||(getFolderChildren(folders[i]).length()<=0))
{
folders[i]->hide();
continue;
@@ -304,6 +358,12 @@ void SessionExplorer::placeButtons()
folders[i]->setChildrenList(getFolderChildren(folders[i]));
}
+ if(parent->isPassFormHidden() && parent->isSelectFormHidden())
+ {
+ lastSession=0;
+ parent->slotClosePass();
+ }
+
for ( int i=0; i<sessions.size(); ++i )
{
if(sessions[i]->getPath() != currentPath)
@@ -332,7 +392,12 @@ void SessionExplorer::placeButtons()
currentVerticalPosition+=230;
}
}
+// x2goDebug<<"last session"<<(void*)lastSession<<"current"<<(void*)sessions[i];
sessions[i]->show();
+ if(lastSession == sessions[i])
+ {
+ sessions[i]->hide();
+ }
}
if ( currentVerticalPosition )
@@ -340,6 +405,11 @@ void SessionExplorer::placeButtons()
parent->getUsersFrame()->setFixedHeight (
currentVerticalPosition);
}
+ int id=findFolder(currentPath);
+ if(id<0)
+ return;
+ if(getFolderChildren(folders[id]).length()<=0)
+ slotLevelUp();
}
QStringList SessionExplorer::getFolderChildren(FolderButton* folder)
@@ -388,6 +458,7 @@ void SessionExplorer::setNavigationVisible(bool value)
void SessionExplorer::createFolder(QString path)
{
+ x2goDebug<<"Create Folder:"<<path;
QStringList tails=path.split("/");
QStringList currentPath;
for(int i=0; i<tails.count()-1; ++i)
diff --git a/src/sessionexplorer.h b/src/sessionexplorer.h
index 09f7c79..a1ec64e 100644
--- a/src/sessionexplorer.h
+++ b/src/sessionexplorer.h
@@ -63,6 +63,7 @@ public:
void createNewFolder(QString path);
void renameFolder(QString oldPath, QString currentPath);
void deleteFolder(QString path);
+ void updateSessions(QStringList slst);
QString getCurrentPath()
{
@@ -94,6 +95,8 @@ private:
int findFolder(QString path);
void createFolder(QString path);
void getFoldersFromConfig();
+ SessionButton* findSession( const QString& id);
+ void checkPath(SessionButton* s);
public slots:
void slotDeleteButton ( SessionButton * bt );
--
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