summaryrefslogtreecommitdiffstats
path: root/src/pvs.cpp
diff options
context:
space:
mode:
authorJohann Latocha2011-04-19 00:33:11 +0200
committerJohann Latocha2011-04-19 00:33:11 +0200
commit63bcd293e78ceacab40451b595b3ed2556fea9ab (patch)
tree256de619ea9b7553f161f5c39466347d5a364adc /src/pvs.cpp
parentAutoconnect bug fixed (2) (diff)
downloadpvs-63bcd293e78ceacab40451b595b3ed2556fea9ab.tar.gz
pvs-63bcd293e78ceacab40451b595b3ed2556fea9ab.tar.xz
pvs-63bcd293e78ceacab40451b595b3ed2556fea9ab.zip
[PVS]
* System/User scope configuration (/etc/xdg/openslx/ and ~/.config/openslx/) * Restricted mode available
Diffstat (limited to 'src/pvs.cpp')
-rw-r--r--src/pvs.cpp61
1 files changed, 25 insertions, 36 deletions
diff --git a/src/pvs.cpp b/src/pvs.cpp
index 39bacb0..5621c64 100644
--- a/src/pvs.cpp
+++ b/src/pvs.cpp
@@ -44,22 +44,20 @@ PVS::PVS() :
_locked = false;
_vncAllowed = false;
_vncRequested = false;
- readPolicyFiles();
- loadCommands();
_blankScreen = NULL;
_vncPort = -1;
- _masterMcastConfig = new McastConfiguration(this);
- _masterMcastConfig->loadFrom(&_settings, "multicast");
+ QSettings tmp(QSettings::SystemScope, "openslx", "pvs");
+ if (tmp.value("restricted").toBool())
+ _settings = new QSettings(QSettings::SystemScope, "openslx", "pvs", this);
+ else
+ _settings = new QSettings(QSettings::UserScope, "openslx", "pvs", this);
- // add a notify to the allow file, so we get informed when the file is changed
- QString watchPath(getPolicyDir());
- watchPath.append(QString(".allow"));
- _notify = new QFileSystemWatcher(this);
- _notify->addPath(QString(watchPath.toUtf8().data()));
+ readPolicyFiles();
+ loadCommands();
- connect(_notify, SIGNAL(fileChanged(const QString &)), this,
- SLOT(fileChanged(const QString &)));
+ _masterMcastConfig = new McastConfiguration(this);
+ _masterMcastConfig->loadFrom(_settings, "multicast");
// connect to D-Bus
new PvsAdaptor(this);
@@ -94,10 +92,10 @@ PVS::PVS() :
initializeInputEventHandling();
// Read Config and try to autoconnect to given host
- QHostAddress host(_settings.value("Connection/host").toString());
- int port = _settings.value("Connection/port").toInt();
- QByteArray fingerprint = QByteArray::fromHex(_settings.value("Connection/fingerprint").toByteArray());
- QString name = _settings.value("Connection/sessionname").toString();
+ QHostAddress host(_settings->value("Connection/host").toString());
+ int port = _settings->value("Connection/port").toInt();
+ QByteArray fingerprint = QByteArray::fromHex(_settings->value("Connection/fingerprint").toByteArray());
+ QString name = _settings->value("Connection/sessionname").toString();
if (!host.isNull() && port > 0 && fingerprint != "" && name != "")
{
qDebug() << "Autoconnecting to " << host.toString();
@@ -110,10 +108,6 @@ PVS::PVS() :
PVS::~PVS()
{
- // make sure we dont leave a locked computer
- if (_notify)
- disconnect(_notify, SIGNAL(fileChanged(const QString &)), this,
- SLOT(fileChanged(const QString &)));
unlock();
delete _sdClient;
}
@@ -423,11 +417,6 @@ void PVS::timerEvent(QTimerEvent *event)
killTimer(event->timerId());
}
-bool PVS::allowExists()
-{
- return policyFileExists(QString(".allow"));
-}
-
/**
* check whether we want to allow vnc connections to this client
*/
@@ -475,14 +464,6 @@ void PVS::readPolicyFiles()
}
/**
- * callback which gets invoked when the watched file is changed
- */
-void PVS::fileChanged(const QString& path)
-{
- getVNCAllow();
-}
-
-/**
* lock the client
*/
bool PVS::lock()
@@ -665,6 +646,11 @@ QString PVS::isConnected()
return _pvsServerConnection->getServerName();
}
+bool PVS::isRestricted()
+{
+ return (_settings->scope() == QSettings::SystemScope);
+}
+
QString PVS::chat_getNickname()
{
return _chat->getSource();
@@ -922,14 +908,17 @@ void PVS::loadMcastConfig(QString const& message)
void PVS::setConfigValue(QString key, QString value)
{
- _settings.setValue(key, value);
- _settings.sync();
- getVNCAllow();
+ if (!isRestricted())
+ {
+ _settings->setValue(key, value);
+ _settings->sync();
+ getVNCAllow();
+ }
}
QString PVS::getConfigValue(QString key)
{
- return _settings.value(key).toString();
+ return _settings->value(key).toString();
}
void PVS::showProc(QString filter)