summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohann Latocha2010-07-10 01:54:35 +0200
committerJohann Latocha2010-07-10 01:54:35 +0200
commit25305a6ef01120bf3b0d929bae0ba7693f41c46b (patch)
tree4e02673cd14fcc9db4477309f5fa1ff295a06c04 /src
parentRevoke Fabians changes. (diff)
downloadpvs-25305a6ef01120bf3b0d929bae0ba7693f41c46b.tar.gz
pvs-25305a6ef01120bf3b0d929bae0ba7693f41c46b.tar.xz
pvs-25305a6ef01120bf3b0d929bae0ba7693f41c46b.zip
Configuration by pvs via D-Bus. Old .allow ist now deprecated, config file: .config/openslx/pvs.conf
Diffstat (limited to 'src')
-rw-r--r--src/gui/clientConfigDialog.cpp84
-rw-r--r--src/gui/clientConfigDialog.h2
-rw-r--r--src/gui/ui/clientToolbar.ui31
-rw-r--r--src/pvs.cpp33
-rw-r--r--src/pvs.h7
-rw-r--r--src/pvsgui.cpp30
-rw-r--r--src/pvsgui.h1
7 files changed, 76 insertions, 112 deletions
diff --git a/src/gui/clientConfigDialog.cpp b/src/gui/clientConfigDialog.cpp
index 76b4f5e..3e1ee50 100644
--- a/src/gui/clientConfigDialog.cpp
+++ b/src/gui/clientConfigDialog.cpp
@@ -26,6 +26,12 @@ ClientConfigDialog::ClientConfigDialog(QWidget *parent) :
connect(radioButtonOtherRO, SIGNAL(clicked()), this,
SLOT(checkPermissions()));
+ // connect to D-Bus and get interface
+ QDBusConnection dbus = QDBusConnection::sessionBus();
+ dbus.registerObject("/config", this);
+ dbus.registerService("org.openslx.pvsgui");
+ _ifaceDBus = new OrgOpenslxPvsInterface("org.openslx.pvs", "/", dbus, this);
+
}
ClientConfigDialog::~ClientConfigDialog()
@@ -49,50 +55,66 @@ void ClientConfigDialog::readSettings()
else
comboBox->setCurrentIndex(_settings.value("Display/location").toInt());
- if (_settings.value("Permissions/vnc_lecturer").toString() == "rw")
- radioButtonLecturerRW->setChecked(true);
- else if (_settings.value("Permissions/vnc_lecturer").toString() == "ro")
- radioButtonLecturerRO->setChecked(true);
- else
- radioButtonLecturerNO->setChecked(true);
- if (_settings.value("Permissions/vnc_other").toString() == "rw")
- radioButtonOtherRW->setChecked(true);
- else if (_settings.value("Permissions/vnc_other").toString() == "ro")
- radioButtonOtherRO->setChecked(true);
- else
- radioButtonOtherNO->setChecked(true);
- checkBoxAllowChat->setChecked(
- _settings.value("Permissions/allow_chat").toBool());
- checkBoxAllowFiletransfer->setChecked(_settings.value(
- "Permissions/allow_filetransfer").toBool());
-
- qDebug("[%s] Setting read from: '%s'", metaObject()->className(),
- qPrintable(_settings.fileName()));
+ QDBusPendingReply<QString> reply = _ifaceDBus->getConfigValue("Permissions/vnc_lecturer");
+ reply.waitForFinished();
+ if (reply.isValid())
+ {
+ if (reply.value() == "rw")
+ radioButtonLecturerRW->setChecked(true);
+ else if (reply.value() == "ro")
+ radioButtonLecturerRO->setChecked(true);
+ else
+ radioButtonLecturerNO->setChecked(true);
+ }
+
+ reply = _ifaceDBus->getConfigValue("Permissions/vnc_other");
+ reply.waitForFinished();
+ if (reply.isValid())
+ {
+ if (reply.value() == "rw")
+ radioButtonOtherRW->setChecked(true);
+ else if (reply.value() == "ro")
+ radioButtonOtherRO->setChecked(true);
+ else
+ radioButtonOtherNO->setChecked(true);
+ }
+
+ reply = _ifaceDBus->getConfigValue("Permissions/allow_chat");
+ reply.waitForFinished();
+ if (reply.isValid())
+ checkBoxAllowChat->setChecked(reply.value() == "T");
+
+ reply = _ifaceDBus->getConfigValue("Permissions/allow_filetransfer");
+ reply.waitForFinished();
+ if (reply.isValid())
+ checkBoxAllowFiletransfer->setChecked(reply.value() == "T");
+
}
void ClientConfigDialog::writeSettings()
{
_settings.setValue("Display/location", comboBox->currentIndex());
+
if (radioButtonLecturerRW->isChecked())
- _settings.setValue("Permissions/vnc_lecturer", "rw");
+ _ifaceDBus->setConfigValue("Permissions/vnc_lecturer", "rw");
else if (radioButtonLecturerRO->isChecked())
- _settings.setValue("Permissions/vnc_lecturer", "ro");
+ _ifaceDBus->setConfigValue("Permissions/vnc_lecturer", "ro");
else
- _settings.setValue("Permissions/vnc_lecturer", "no");
+ _ifaceDBus->setConfigValue("Permissions/vnc_lecturer", "no");
if (radioButtonOtherRW->isChecked())
- _settings.setValue("Permissions/vnc_other", "rw");
+ _ifaceDBus->setConfigValue("Permissions/vnc_other", "rw");
else if (radioButtonOtherRO->isChecked())
- _settings.setValue("Permissions/vnc_other", "ro");
+ _ifaceDBus->setConfigValue("Permissions/vnc_other", "ro");
else
- _settings.setValue("Permissions/vnc_other", "no");
- _settings.setValue("Permissions/allow_chat", checkBoxAllowChat->isChecked());
- _settings.setValue("Permissions/allow_filetransfer",
- checkBoxAllowFiletransfer->isChecked());
+ _ifaceDBus->setConfigValue("Permissions/vnc_other", "no");
+
+ _ifaceDBus->setConfigValue("Permissions/allow_chat",
+ QString(checkBoxAllowChat->isChecked() ? "T" : "F"));
+ _ifaceDBus->setConfigValue("Permissions/allow_filetransfer",
+ QString(checkBoxAllowFiletransfer->isChecked() ? "T" : "F"));
+
_settings.sync();
emit configChanged();
-
- qDebug("[%s] Settings written to: '%s'.", metaObject()->className(),
- qPrintable(_settings.fileName()));
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gui/clientConfigDialog.h b/src/gui/clientConfigDialog.h
index 706bd8a..98da54f 100644
--- a/src/gui/clientConfigDialog.h
+++ b/src/gui/clientConfigDialog.h
@@ -15,6 +15,7 @@
#define CLIENTCONFIGDIALOG_H_
#include <QtGui>
+#include "pvsinterface.h"
#include "ui_clientConfigDialog.h"
class ClientConfigDialog: public QDialog, private Ui::ClientConfigDialogClass
@@ -37,6 +38,7 @@ private Q_SLOTS:
void checkPermissions();
private:
+ OrgOpenslxPvsInterface *_ifaceDBus;
QSettings _settings;
};
diff --git a/src/gui/ui/clientToolbar.ui b/src/gui/ui/clientToolbar.ui
index 5a59c5f..51cb62e 100644
--- a/src/gui/ui/clientToolbar.ui
+++ b/src/gui/ui/clientToolbar.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>577</width>
+ <width>463</width>
<height>28</height>
</rect>
</property>
@@ -144,35 +144,6 @@ p, li { white-space: pre-wrap; }
</spacer>
</item>
<item>
- <widget class="QCheckBox" name="vncCheckBox">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Enable/Disable VNC only for this session</string>
- </property>
- <property name="text">
- <string>Allow VNC</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
diff --git a/src/pvs.cpp b/src/pvs.cpp
index 2069e36..124b257 100644
--- a/src/pvs.cpp
+++ b/src/pvs.cpp
@@ -317,24 +317,9 @@ bool PVS::allowExists()
*/
bool PVS::getVNCAllow()
{
- if (allowExists())
- {
- if (getAllowed())
- {
- _vncAllowed = true;
- }
- else
- {
- _vncAllowed = false;
- }
- }
- else
- {
- ConsoleLog writeError("No .allow file found.");
- _vncAllowed = false;
- //make sure the vncsever is off
- ConsoleLog writeError("Shutting down vnc-server because we have no .allow file.");
- }
+
+ QString value = getConfigValue("Permissions/vnc_lecturer");
+ _vncAllowed = (value == "rw" || value == "ro");
if (_vncAllowed && _vncRequested)
{
@@ -627,3 +612,15 @@ void PVS::signalHandler(int signal)
}
+void PVS::setConfigValue(QString key, QString value)
+{
+ _settings.setValue(key, value);
+ _settings.sync();
+ getVNCAllow();
+}
+
+QString PVS::getConfigValue(QString key)
+{
+ return _settings.value(key).toString();
+}
+
diff --git a/src/pvs.h b/src/pvs.h
index 4b1e29e..ba696d8 100644
--- a/src/pvs.h
+++ b/src/pvs.h
@@ -80,6 +80,9 @@ public Q_SLOTS:
QStringList getAvailableHosts();
QString getIpByNick(QString nick);
+ void setConfigValue(QString key, QString value);
+ QString getConfigValue(QString key);
+
Q_SIGNALS:
void project(QString host, int port, QString passwd, bool fullscreen,
bool smoothTransformation, int quality);
@@ -131,8 +134,6 @@ private:
PVSServerConnection* _pvsServerConnection; ///< our tcp connection object to the pvsserver
- QSettings _settings;
-
PVSServiceDiscovery *_sdClient;
PVSChatClient *_chat;
@@ -142,5 +143,7 @@ private:
int _timerLockTest;
int _timerLockDelay;
+ QSettings _settings;
+
};
#endif /* PVSCLIENT_H_ */
diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp
index 25f1cd6..6fdd673 100644
--- a/src/pvsgui.cpp
+++ b/src/pvsgui.cpp
@@ -76,18 +76,6 @@ PVSGUI::PVSGUI(QWidget *parent) :
if (dbus.isConnected())
qDebug("[%s] Connection to DBus successful!", metaObject()->className());
- // TODO: perhaps this can go if fadi does his work
- // check if vnc is allowed and setup checkbox
- QFile file(QDir::toNativeSeparators(QDir::homePath() + "/.pvs/.allow"));
- if (file.open(QIODevice::ReadOnly | QIODevice::Text))
- {
- QTextStream in(&file);
- QString line = in.readLine();
- if (line == "1")
- vncCheckBox->setChecked(true);
- file.close();
- }
-
// listen on port 29481 for incoming file transfers
_serverSocket = new QTcpServer();
_serverSocket->listen(QHostAddress::Any, 29481);
@@ -108,8 +96,6 @@ PVSGUI::PVSGUI(QWidget *parent) :
connect(_hostMenu, SIGNAL(aboutToHide()), this, SLOT(hide()));
connect(_hostMenu, SIGNAL(triggered(QAction*)), this,
SLOT(pvsConnect(QAction*)));
- connect(vncCheckBox, SIGNAL(stateChanged(int)), this,
- SLOT(setVncAllow(int)));
// signals & slots - dbus
connect(_ifaceDBus, SIGNAL(showMessage(QString, QString, bool)), this,
@@ -392,22 +378,6 @@ void PVSGUI::delHost(QString host)
}
}
-// TODO: perhaps this can go if fadi does his work
-void PVSGUI::setVncAllow(int i)
-{
- QFile file(QDir::toNativeSeparators(QDir::homePath() + "/.pvs/.allow"));
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
- return;
-
- QTextStream out(&file);
- if (i == 0)
- out << 0;
- else
- out << 1;
-
- file.close();
-}
-
void PVSGUI::sendFile()
{
ClientFileSendDialog *d = new ClientFileSendDialog();
diff --git a/src/pvsgui.h b/src/pvsgui.h
index f9a0ab8..90fe50e 100644
--- a/src/pvsgui.h
+++ b/src/pvsgui.h
@@ -62,7 +62,6 @@ private Q_SLOTS:
void delHost(QString host);
void pvsConnect(QAction *action);
void pvsDisconnect();
- void setVncAllow(int i);
void sendFile();
void receiveFile();