summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Darmochwal2010-10-05 12:45:20 +0200
committerJan Darmochwal2010-10-05 12:45:20 +0200
commit610840384ff2a04d640ca4d8fe100019bab0ba16 (patch)
treefaea71083d0c33f5389a9833f9576564cf0248eb /src
parentAllow sessions to be active for a given date range (diff)
downloadvmchooser-610840384ff2a04d640ca4d8fe100019bab0ba16.tar.gz
vmchooser-610840384ff2a04d640ca4d8fe100019bab0ba16.tar.xz
vmchooser-610840384ff2a04d640ca4d8fe100019bab0ba16.zip
simple PVS configuration in vmchooser
This patch adds a GroupBox with PVS access restriction options to vmchooser. Vmchooser checks if a PVS daemon is running and if so, displays some access configuration options. The options will be sent to the PVS daemon after a session has been started (just before vmchooser exits). All PVS configuration program logic is contained in the Dialog class. (It would probably be better to use a custom widget for the PVS options.) The file org.openslx.pvs.xml has been copied from a PVS build. This file has to be updated manually when the PVS D-Bus specification changes.
Diffstat (limited to 'src')
-rw-r--r--src/dialog.cpp104
-rw-r--r--src/dialog.h6
-rw-r--r--src/org.openslx.pvs.xml85
-rw-r--r--src/ui/dialog.ui101
4 files changed, 296 insertions, 0 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index a7b3a5e..37b6fb6 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -3,12 +3,29 @@
#include "save_restore_session.h"
#include "sessiontreeitem.h"
+
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
model_ = new SessionTreeModel(parent);
ui->setupUi(this);
+
+ QDBusConnection dbus = QDBusConnection::sessionBus();
+ ifaceDBus_ = new OrgOpenslxPvsInterface("org.openslx.pvs", "/", dbus, this);
+
+ if (ifaceDBus_->isValid()) {
+ // PVS is running
+ QStringList accessOptions;
+ accessOptions << "None" << "View Only" << "Full";
+ ui->comboBoxLecturer->insertItems(0, accessOptions);
+ ui->comboBoxOthers->insertItems(0, accessOptions);
+
+ readPVSSettings();
+ ui->PVSOptionsGroupBox->show();
+ } else {
+ ui->PVSOptionsGroupBox->hide();
+ }
}
Dialog::~Dialog()
@@ -44,6 +61,9 @@ void Dialog::on_treeView_activated(QModelIndex index)
return;
}
if (s->run()) {
+ if (ifaceDBus_->isValid()) {
+ writePVSSettings();
+ }
writeSessionName(s->shortDescription());
close();
} else {
@@ -79,3 +99,87 @@ void Dialog::on_pushButtonStart_clicked()
// TODO: check if a model is selected
this->on_treeView_activated(ui->treeView->selectionModel()->currentIndex());
}
+
+void Dialog::readPVSSettings()
+{
+ QDBusPendingReply<QString> reply;
+
+ reply = ifaceDBus_->getConfigValue("Permissions/vnc_lecturer");
+ reply.waitForFinished();
+ if (reply.isValid())
+ {
+ if (reply.value() == "rw") {
+ ui->comboBoxLecturer->setCurrentIndex(2);
+ } else if (reply.value() == "ro") {
+ ui->comboBoxLecturer->setCurrentIndex(1);
+ } else {
+ ui->comboBoxLecturer->setCurrentIndex(0);
+ }
+ }
+
+ reply = ifaceDBus_->getConfigValue("Permissions/vnc_other");
+ reply.waitForFinished();
+ if (reply.isValid())
+ {
+ if (reply.value() == "rw") {
+ ui->comboBoxOthers->setCurrentIndex(2);
+ } else if (reply.value() == "ro") {
+ ui->comboBoxOthers->setCurrentIndex(1);
+ } else {
+ ui->comboBoxOthers->setCurrentIndex(0);
+ }
+ }
+
+ reply = ifaceDBus_->getConfigValue("Permissions/allow_chat");
+ reply.waitForFinished();
+ if (reply.isValid())
+ ui->checkBoxChat->setChecked(reply.value() == "T");
+
+ reply = ifaceDBus_->getConfigValue("Permissions/allow_filetransfer");
+ reply.waitForFinished();
+ if (reply.isValid())
+ ui->checkBoxFileTransfer->setChecked(reply.value() == "T");
+}
+
+void Dialog::writePVSSettings()
+{
+ int accessLecturer = ui->comboBoxLecturer->currentIndex();
+ if (accessLecturer == 2) {
+ ifaceDBus_->setConfigValue("Permissions/vnc_lecturer", "rw");
+ } else if (accessLecturer == 1) {
+ ifaceDBus_->setConfigValue("Permissions/vnc_lecturer", "ro");
+ } else {
+ ifaceDBus_->setConfigValue("Permissions/vnc_lecturer", "no");
+ }
+
+ int accessOthers = ui->comboBoxOthers->currentIndex();
+ if (accessOthers == 2) {
+ ifaceDBus_->setConfigValue("Permissions/vnc_other", "rw");
+ } else if (accessOthers == 1) {
+ ifaceDBus_->setConfigValue("Permissions/vnc_other", "ro");
+ } else {
+ ifaceDBus_->setConfigValue("Permissions/vnc_other", "no");
+ }
+
+ ifaceDBus_->setConfigValue("Permissions/allow_chat",
+ QString(ui->checkBoxChat->isChecked() ? "T" : "F"));
+ ifaceDBus_->setConfigValue("Permissions/allow_filetransfer",
+ QString(ui->checkBoxFileTransfer->isChecked() ? "T" : "F"));
+}
+
+void Dialog::on_comboBoxLecturer_currentIndexChanged(int index)
+{
+ // TODO: may others have more access than lecturer?
+ if (index < ui->comboBoxOthers->currentIndex()) {
+ ui->comboBoxOthers->setCurrentIndex(index);
+ }
+}
+
+void Dialog::on_comboBoxOthers_currentIndexChanged(int index)
+{
+ // TODO: may others have more access than lecturer?
+ if (index > ui->comboBoxLecturer->currentIndex()) {
+ ui->comboBoxLecturer->setCurrentIndex(index);
+ }
+
+}
diff --git a/src/dialog.h b/src/dialog.h
index f452c61..e4d87e9 100644
--- a/src/dialog.h
+++ b/src/dialog.h
@@ -6,6 +6,7 @@
#include <QList>
#include "session.h"
#include "sessiontreemodel.h"
+#include "pvsinterface.h"
namespace Ui {
class Dialog;
@@ -24,8 +25,13 @@ protected:
private:
Ui::Dialog *ui;
SessionTreeModel *model_;
+ OrgOpenslxPvsInterface *ifaceDBus_;
+ void readPVSSettings();
+ void writePVSSettings();
private slots:
+ void on_comboBoxOthers_currentIndexChanged(int index);
+ void on_comboBoxLecturer_currentIndexChanged(int index);
void on_pushButtonStart_clicked();
void on_pushButtonAbort_clicked();
void on_treeView_activated(QModelIndex index);
diff --git a/src/org.openslx.pvs.xml b/src/org.openslx.pvs.xml
new file mode 100644
index 0000000..382e825
--- /dev/null
+++ b/src/org.openslx.pvs.xml
@@ -0,0 +1,85 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.openslx.pvs">
+ <signal name="project">
+ <arg name="host" type="s" direction="out"/>
+ <arg name="port" type="i" direction="out"/>
+ <arg name="passwd" type="s" direction="out"/>
+ <arg name="fullscreen" type="b" direction="out"/>
+ <arg name="smoothTransformation" type="b" direction="out"/>
+ <arg name="quality" type="i" direction="out"/>
+ </signal>
+ <signal name="unproject">
+ </signal>
+ <signal name="chat_receive">
+ <arg name="nick_from" type="s" direction="out"/>
+ <arg name="nick_to" type="s" direction="out"/>
+ <arg name="msg" type="s" direction="out"/>
+ </signal>
+ <signal name="chat_client_add">
+ <arg name="nick" type="s" direction="out"/>
+ </signal>
+ <signal name="chat_client_remove">
+ <arg name="nick" type="s" direction="out"/>
+ </signal>
+ <signal name="showMessage">
+ <arg name="title" type="s" direction="out"/>
+ <arg name="msg" type="s" direction="out"/>
+ <arg name="useDialog" type="b" direction="out"/>
+ </signal>
+ <signal name="connected">
+ <arg name="host" type="s" direction="out"/>
+ </signal>
+ <signal name="disconnected">
+ </signal>
+ <signal name="addHost">
+ <arg name="host" type="s" direction="out"/>
+ </signal>
+ <signal name="delHost">
+ <arg name="host" type="s" direction="out"/>
+ </signal>
+ <method name="start">
+ <arg type="b" direction="out"/>
+ </method>
+ <method name="quit">
+ </method>
+ <method name="chat_send">
+ <arg name="nick_to" type="s" direction="in"/>
+ <arg name="nick_from" type="s" direction="in"/>
+ <arg name="msg" type="s" direction="in"/>
+ </method>
+ <method name="chat_getNickname">
+ <arg type="s" direction="out"/>
+ </method>
+ <method name="chat_getNicknames">
+ <arg type="as" direction="out"/>
+ </method>
+ <method name="fileChanged">
+ <arg name="path" type="s" direction="in"/>
+ </method>
+ <method name="pvsConnect">
+ <arg name="host" type="s" direction="in"/>
+ <arg name="passwd" type="s" direction="in"/>
+ </method>
+ <method name="pvsDisconnect">
+ </method>
+ <method name="isConnected">
+ <arg type="s" direction="out"/>
+ </method>
+ <method name="getAvailableHosts">
+ <arg type="as" direction="out"/>
+ </method>
+ <method name="getIpByNick">
+ <arg type="s" direction="out"/>
+ <arg name="nick" type="s" direction="in"/>
+ </method>
+ <method name="setConfigValue">
+ <arg name="key" type="s" direction="in"/>
+ <arg name="value" type="s" direction="in"/>
+ </method>
+ <method name="getConfigValue">
+ <arg type="s" direction="out"/>
+ <arg name="key" type="s" direction="in"/>
+ </method>
+ </interface>
+</node>
diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui
index 522ae55..fe03b5d 100644
--- a/src/ui/dialog.ui
+++ b/src/ui/dialog.ui
@@ -28,6 +28,107 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="PVSOptionsGroupBox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string>PVS Options</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelLecturer">
+ <property name="text">
+ <string>VNC access by lecturer:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="comboBoxLecturer">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelOthers">
+ <property name="text">
+ <string>VNC access by others:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="comboBoxOthers">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <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="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="checkBoxChat">
+ <property name="text">
+ <string>Accept chat messages</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxFileTransfer">
+ <property name="text">
+ <string>Accept file transfers</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <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>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">