From 610840384ff2a04d640ca4d8fe100019bab0ba16 Mon Sep 17 00:00:00 2001 From: Jan Darmochwal Date: Tue, 5 Oct 2010 12:45:20 +0200 Subject: 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. --- src/dialog.cpp | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'src/dialog.cpp') 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 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); + } + +} -- cgit v1.2.3-55-g7522