From 34e46ac3dfefbf0494d45c692bf2f625afc5e6ea Mon Sep 17 00:00:00 2001 From: Johann Latocha Date: Wed, 2 Mar 2011 19:03:03 +0100 Subject: * dbus interface removed * write pvs config directly * use "vmchooser --pvs" --- src/command_line_options.cpp | 4 ++ src/dialog.cpp | 103 ++++++++++++++++--------------------------- src/dialog.h | 5 ++- src/main.cpp | 5 +++ src/org.openslx.pvs.xml | 85 ----------------------------------- src/ui/dialog.ui | 94 +++++++++++++++++---------------------- src/vsession.h | 1 + src/xsession.h | 1 + 8 files changed, 94 insertions(+), 204 deletions(-) delete mode 100644 src/org.openslx.pvs.xml (limited to 'src') diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp index 2127c4f..6ace24a 100644 --- a/src/command_line_options.cpp +++ b/src/command_line_options.cpp @@ -11,6 +11,7 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { {"path", required_argument, NULL, 'p'}, {"xpath", required_argument, NULL, 'x'}, {"size", required_argument, NULL, 's'}, + {"pvs", no_argument, NULL, 'b'}, {"version", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} @@ -38,6 +39,9 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) { case 's': options.insert("size", optarg); break; + case 'b': + options.insert("pvs", "pvs"); + break; case 'v': options.insert("version", "version"); break; diff --git a/src/dialog.cpp b/src/dialog.cpp index 6100d8c..98a60e8 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -1,6 +1,7 @@ #include "dialog.h" #include +#include #include "ui_dialog.h" #include "save_restore_session.h" @@ -11,28 +12,13 @@ Dialog::Dialog(QWidget *parent) 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 <comboBoxLecturer->insertItems(0, accessOptions); - ui->comboBoxOthers->insertItems(0, accessOptions); - - readPVSSettings(); - ui->PVSOptionsGroupBox->show(); - } else { - ui->PVSOptionsGroupBox->hide(); - } + pvsSettings_ = NULL; + ui->PVSOptionsGroupBox->hide(); } Dialog::~Dialog() { delete ui; delete model_; - delete ifaceDBus_; } void Dialog::changeEvent(QEvent *e) { @@ -59,9 +45,7 @@ void Dialog::on_treeView_activated(QModelIndex index) { } if (s->run()) { - if (ifaceDBus_->isValid()) { - writePVSSettings(); - } + writePVSSettings(); writeSessionName(s->shortDescription()); setVisible(false); @@ -74,7 +58,6 @@ void Dialog::on_treeView_activated(QModelIndex index) { void Dialog::addItems(const QList& entries, const QString& section) { this->model_->addItems(entries, section); - ui->treeView->setModel(model_); ui->treeView->expandAll(); } @@ -88,66 +71,48 @@ void Dialog::on_pushButtonStart_clicked() { } 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); - } + if (!pvsSettings_) return; + QString value; + + value = pvsSettings_->value("Permissions/vnc_lecturer").toString(); + if (value == "rw") { + ui->comboBoxLecturer->setCurrentIndex(2); + } else if (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); - } + value = pvsSettings_->value("Permissions/vnc_other").toString(); + if (value == "rw") { + ui->comboBoxOthers->setCurrentIndex(2); + } else if (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() { + if (!pvsSettings_) return; int accessLecturer = ui->comboBoxLecturer->currentIndex(); if (accessLecturer == 2) { - ifaceDBus_->setConfigValue("Permissions/vnc_lecturer", "rw"); + pvsSettings_->setValue("Permissions/vnc_lecturer", "rw"); } else if (accessLecturer == 1) { - ifaceDBus_->setConfigValue("Permissions/vnc_lecturer", "ro"); + pvsSettings_->setValue("Permissions/vnc_lecturer", "ro"); } else { - ifaceDBus_->setConfigValue("Permissions/vnc_lecturer", "no"); + pvsSettings_->setValue("Permissions/vnc_lecturer", "no"); } int accessOthers = ui->comboBoxOthers->currentIndex(); if (accessOthers == 2) { - ifaceDBus_->setConfigValue("Permissions/vnc_other", "rw"); + pvsSettings_->setValue("Permissions/vnc_other", "rw"); } else if (accessOthers == 1) { - ifaceDBus_->setConfigValue("Permissions/vnc_other", "ro"); + pvsSettings_->setValue("Permissions/vnc_other", "ro"); } else { - ifaceDBus_->setConfigValue("Permissions/vnc_other", "no"); + pvsSettings_->setValue("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")); + pvsSettings_->sync(); } void Dialog::on_comboBoxLecturer_currentIndexChanged(int index) { @@ -190,3 +155,13 @@ void Dialog::selectSession(const QString& name) { void Dialog::selectPreviousSession() { selectSession(readSessionName()); } + +void Dialog::showSettingsPVS() { + pvsSettings_ = new QSettings("openslx", "pvs", this); + QStringList accessOptions; + accessOptions <comboBoxLecturer->insertItems(0, accessOptions); + ui->comboBoxOthers->insertItems(0, accessOptions); + readPVSSettings(); + ui->PVSOptionsGroupBox->show(); +} diff --git a/src/dialog.h b/src/dialog.h index 1b2e7c9..86896c7 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -4,9 +4,9 @@ #include #include #include +#include #include "session.h" #include "sessiontreemodel.h" -#include "pvsinterface.h" namespace Ui { class Dialog; @@ -20,6 +20,7 @@ class Dialog : public QDialog { void addItems(const QList&, const QString& section); void selectSession(const QString& name); void selectPreviousSession(); + void showSettingsPVS(); protected: void changeEvent(QEvent *e); @@ -27,7 +28,7 @@ class Dialog : public QDialog { private: Ui::Dialog *ui; SessionTreeModel *model_; - OrgOpenslxPvsInterface *ifaceDBus_; + QSettings *pvsSettings_; void readPVSSettings(); void writePVSSettings(); diff --git a/src/main.cpp b/src/main.cpp index 6264923..ff054fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,7 @@ int main(int argc, char *argv[]) { " -p, --path path to vmware .xml files\n" " -x, --xpath path of X Session .desktop files\n" " -s, --size window size x\n" + " -b, --pvs show pvs options\n" " -v, --version print version and exit\n" " -h, --help print usage information and exit\n" "\nFILE can be a vmware .xml or an X .desktop file\n") @@ -164,6 +166,9 @@ int main(int argc, char *argv[]) { QList vsessions(VSession::readXmlDir(vSessionPath)); Dialog w; + if (cmdOptions.contains("pvs")) + w.showSettingsPVS(); + w.resize(width, height); if (xsessions.empty() && vsessions.empty()) { std::cerr << a.translate( diff --git a/src/org.openslx.pvs.xml b/src/org.openslx.pvs.xml deleted file mode 100644 index 382e825..0000000 --- a/src/org.openslx.pvs.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui index e9e2920..9a49987 100644 --- a/src/ui/dialog.ui +++ b/src/ui/dialog.ui @@ -6,7 +6,7 @@ 0 0 - 842 + 542 655 @@ -142,15 +142,28 @@ border-bottom:1px solid #ccc; 9 - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + VNC access by lecturer: - + @@ -160,14 +173,27 @@ border-bottom:1px solid #ccc; - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + VNC access by others: - + @@ -177,59 +203,21 @@ border-bottom:1px solid #ccc; - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical - - - - - - - - Accept chat messages + + + Qt::Horizontal - - - - - - Accept file transfers + + + 40 + 20 + - + - - - - Qt::Horizontal - - - - 40 - 20 - - - - diff --git a/src/vsession.h b/src/vsession.h index 496e0a2..093ec2f 100644 --- a/src/vsession.h +++ b/src/vsession.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "session.h" enum ImgType { diff --git a/src/xsession.h b/src/xsession.h index 2e95a63..72c174c 100644 --- a/src/xsession.h +++ b/src/xsession.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "session.h" class XSession : public Session { -- cgit v1.2.3-55-g7522