added start/stop browser feature

remotes/origin/HEAD
Tobias Weiss 9 years ago
parent f9f7e5f92f
commit adcfb722b9

@ -246,7 +246,7 @@ void lc::Client::Shutdown() {
GotStatusChanged( state_t::SHUTTING_DOWN );
}
void lc::Client::StartZLeaf( const QString * const argFakeName ) {
void lc::Client::StartZLeaf( const QString * argFakeName ) {
if ( state < state_t::RESPONDING || zLeafVersion.isEmpty() || GetSessionPort() < 7000 ) {
return;
}
@ -304,16 +304,49 @@ void lc::Client::StartZLeaf( const QString * const argFakeName ) {
}
}
void lc::Client::StartClientBrowser( const QString * const argURL ) {
void lc::Client::StartClientBrowser( const QString * const argURL, const bool * const argFullscreen ) {
//Declarations
QStringList arguments;
// Output message via the debug messages tab
qDebug() << settings->sshCmd << arguments.join( " " );
//Build arguments list for SSH command
arguments << "-i" << settings->pkeyPathUser
<< QString{ settings->userNameOnClients + "@" + ip }
<< "DISPLAY=:0.0"
<< settings->clientBrowserCmd
<< *argURL;
// Start the process
QProcess startClientBrowserProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
startClientBrowserProcess.setProcessEnvironment( env );
startClientBrowserProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab
qDebug() << settings->sshCmd << arguments.join( " " );
}
void lc::Client::StopClientBrowser() {
//Declarations
QStringList arguments;
//Build arguments list
arguments << "-i" << settings->pkeyPathUser
<< QString{ settings->userNameOnClients + "@" + ip }
<< "DISPLAY=:0.0"
<< "killall"
<< settings->clientBrowserCmd
<< "&& sleep 1"
<< "&& rm -R /home/ewfuser/.mozilla/firefox/*";
// Start the process
QProcess startClientBrowserProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
startClientBrowserProcess.setProcessEnvironment( env );
startClientBrowserProcess.startDetached( settings->clientBrowserCmd, arguments );
startClientBrowserProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab
qDebug() << settings->clientBrowserCmd << arguments.join( " " );
qDebug() << settings->sshCmd << arguments.join( " " );
}

@ -112,11 +112,16 @@ public:
/*!
@param argFakeName The name the zLeaf instance shall have (if not the default, which is the hostname of the client)
*/
void StartZLeaf( const QString * const argFakeName = nullptr );
void StartZLeaf(const QString *argFakeName = nullptr );
/*!
@param argURL URL to open in clients browser
* \brief Opens a browser window on the client
* @param argURL URL to open in clients browser
*/
void StartClientBrowser( const QString * const argURL = nullptr );
void StartClientBrowser( const QString *argURL = nullptr, const bool *argFullscreen = nullptr );
/*!
* \brief Closes all browser instances
*/
void StopClientBrowser();
private:
const QString &GetzLeafVersion() const { return zLeafVersion; }

@ -31,6 +31,9 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) :
browserCmd{ ReadSettingsItem( "browser_command",
"Opening ORSEE in a browser will not work.",
argSettings, true ) },
clientBrowserCmd{ ReadSettingsItem( "client_browser_command",
"Opening a browser window on clients will not work.",
argSettings, false ) },
dvipsCmd{ ReadSettingsItem( "dvips_command",
"Receipts creation will not work.",
argSettings, true ) },

@ -758,17 +758,37 @@ void lc::MainWindow::on_PBKillzTree_clicked()
// Output message via the debug messages tab
qDebug() << program << arguments;
} else {
qDebug() << "Canceled killing all z-Tree processes";
qDebug() << "Canceled stopping all z-Tree processes";
}
}
void lc::MainWindow::on_PBstartBrowser_clicked()
{
QString argURL = ui->LEURL->text();
bool argFullscreen = ui->CBFullscreen->checkState();
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->StartZLeaf( nullptr );
client->StartClientBrowser( &argURL, &argFullscreen );
}
}
}
void lc::MainWindow::on_PBstopBrowser_clicked()
{
// Confirmation dialog
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Confirm", "Really kill all selected browser instances?", QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->StopClientBrowser( );
}
}
} else {
qDebug() << "Canceled stopping all selected browser processes";
}
}

@ -116,6 +116,7 @@ private slots:
void on_PBrestartCrashedSession_clicked();
void on_PBKillzTree_clicked();
void on_PBstartBrowser_clicked();
void on_PBstopBrowser_clicked();
};
}

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>658</width>
<height>900</height>
</rect>
</property>
@ -163,6 +163,9 @@
<property name="editable">
<bool>true</bool>
</property>
<property name="currentText">
<string>Choose the name z-Leaf shall have</string>
</property>
<item>
<property name="text">
<string>Choose the name the z-Leaf shall have</string>
@ -201,7 +204,7 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<spacer name="verticalSpacer_ServerActions">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -383,10 +386,13 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<widget class="QCheckBox" name="CBFullscreen">
<property name="text">
<string>Fullscreen</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -399,7 +405,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="PBstopBrowser_2">
<widget class="QPushButton" name="PBstopBrowser">
<property name="text">
<string>Stop browser</string>
</property>
@ -408,7 +414,7 @@
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<spacer name="verticalSpacer_ClientActions">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -438,9 +444,9 @@
<property name="geometry">
<rect>
<x>9</x>
<y>79</y>
<width>371</width>
<height>381</height>
<y>69</y>
<width>311</width>
<height>391</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -458,6 +464,12 @@
</property>
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>New session</string>
</property>
@ -554,29 +566,24 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget_3">
<property name="geometry">
<rect>
<x>390</x>
<y>140</y>
<width>381</width>
<height>321</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4"/>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>761</width>
<height>57</height>
<width>621</width>
<height>55</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_15">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Cleanup / recover last session</string>
</property>
@ -612,10 +619,10 @@
<widget class="QWidget" name="verticalLayoutWidget_6">
<property name="geometry">
<rect>
<x>388</x>
<y>108</y>
<width>381</width>
<height>321</height>
<x>330</x>
<y>100</y>
<width>301</width>
<height>361</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">

Loading…
Cancel
Save