diff options
author | Johann Latocha | 2011-04-19 00:33:11 +0200 |
---|---|---|
committer | Johann Latocha | 2011-04-19 00:33:11 +0200 |
commit | 63bcd293e78ceacab40451b595b3ed2556fea9ab (patch) | |
tree | 256de619ea9b7553f161f5c39466347d5a364adc | |
parent | Autoconnect bug fixed (2) (diff) | |
download | pvs-63bcd293e78ceacab40451b595b3ed2556fea9ab.tar.gz pvs-63bcd293e78ceacab40451b595b3ed2556fea9ab.tar.xz pvs-63bcd293e78ceacab40451b595b3ed2556fea9ab.zip |
[PVS]
* System/User scope configuration (/etc/xdg/openslx/ and ~/.config/openslx/)
* Restricted mode available
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | misc/pvs.conf | 12 | ||||
-rw-r--r-- | src/gui/mainWindow.cpp | 6 | ||||
-rw-r--r-- | src/pvs.cpp | 61 | ||||
-rw-r--r-- | src/pvs.h | 6 | ||||
-rw-r--r-- | src/pvsDaemon.cpp | 7 | ||||
-rw-r--r-- | src/pvsgui.cpp | 39 | ||||
-rw-r--r-- | src/pvsgui.h | 1 |
8 files changed, 59 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index fccfb8b..0cf2065 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -364,7 +364,7 @@ CONFIGURE_FILE(org.openslx.pvs.service ${CMAKE_BINARY_DIR}/org.openslx.pvs.servi INSTALL(TARGETS pvsmgr pvs pvsgui pvsmgrtouch RUNTIME DESTINATION bin) INSTALL(PROGRAMS misc/pvs-vncsrv DESTINATION bin) INSTALL(FILES ${CMAKE_BINARY_DIR}/org.openslx.pvs.service DESTINATION share/dbus-1/services) -INSTALL(FILES misc/pvs.conf misc/pvsgui.conf misc/pvsmgr.conf DESTINATION /etc/openslx) +INSTALL(FILES misc/pvs.conf misc/pvsgui.conf misc/pvsmgr.conf DESTINATION /etc/xdg/openslx) INSTALL(FILES misc/pvsgui.desktop DESTINATION /etc/xdg/autostart) # uninstall diff --git a/misc/pvs.conf b/misc/pvs.conf index 7e3d78c..5f2a528 100644 --- a/misc/pvs.conf +++ b/misc/pvs.conf @@ -1,6 +1,14 @@ +restricted=false + [VNC] -script=/usr/local/bin/pvs-vncsrv +script=/usr/local/bin/pvs-vncsrv [Permissions] -vnc_lecturer=ro +vnc_lecturer=rw vnc_other=no + +[Connection] +host= +port=3490 +fingerprint= +sessionname= diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 4eae44e..7e2efc3 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -46,12 +46,6 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) : { ui->setupUi(this); - - if (!QFile::exists(_settings.fileName())) - { - QDir::root().mkpath(QFileInfo(_settings.fileName()).path()); - QFile::copy("/etc/openslx/pvsmgr.conf", _settings.fileName()); - } myself = this; #ifdef MAINWINDOW_USE_NORMALGUI 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) @@ -80,10 +80,10 @@ public Q_SLOTS: void chat_send(QString nick_to, QString nick_from, QString msg); QString chat_getNickname(); QStringList chat_getNicknames(); - void fileChanged(const QString& path); void pvsConnect(QString host, QString passwd); void pvsDisconnect(); QString isConnected(); + bool isRestricted(); QStringList getAvailableHosts(); QString getIpByNick(QString nick); @@ -126,7 +126,6 @@ protected: private: // own - bool allowExists(); ///< whether the .allow file exists bool getVNCAllow(); ///< whether vnc-connections to this client are allowed void readPolicyFiles(); ///< pars the policy files @@ -141,7 +140,6 @@ private: bool _vncAllowed; ///< whether vncConnections to this client are allowed (dup?) BlankScreen *_blankScreen;///< object to blank the screen - QFileSystemWatcher* _notify; ///< used to get notifies about file changes //vnc-server QString _vncScriptPath; ///< path to the vnc script file QString _vncScriptName; ///< name of the vnc script file @@ -193,6 +191,6 @@ private Q_SLOTS: void processStopErrorOccured(QProcess::ProcessError error); private: - QSettings _settings; + QSettings *_settings; }; #endif /* PVSCLIENT_H_ */ diff --git a/src/pvsDaemon.cpp b/src/pvsDaemon.cpp index 9f2572c..6dd30ec 100644 --- a/src/pvsDaemon.cpp +++ b/src/pvsDaemon.cpp @@ -75,12 +75,7 @@ int main(int argc, char** argv) app.installTranslator(&translator); QFileInfo script; - QSettings settings; - if (!QFile::exists(settings.fileName())) - { - QDir::root().mkpath(QFileInfo(settings.fileName()).path()); - QFile::copy("/etc/openslx/pvs.conf", settings.fileName()); - } + QSettings settings(QSettings::SystemScope, "openslx", "pvs"); QString s = settings.value("VNC/script").toString(); script.setFile(s); if (!script.exists()) diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp index 4294206..5359449 100644 --- a/src/pvsgui.cpp +++ b/src/pvsgui.cpp @@ -26,12 +26,6 @@ PVSGUI::PVSGUI(QWidget *parent) : { setupUi(this); - if (!QFile::exists(_settings.fileName())) - { - QDir::root().mkpath(QFileInfo(_settings.fileName()).path()); - QFile::copy("/etc/openslx/pvsgui.conf", _settings.fileName()); - } - // stop running pvs qDebug("[%s] Stopping pvs daemon.", metaObject()->className()); QProcess::execute("pvs -c stop"); @@ -48,8 +42,6 @@ PVSGUI::PVSGUI(QWidget *parent) : _hostMenu->setEnabled(false); hostButton->setEnabled(false); - setupMenu(); - _trayIcon = new QSystemTrayIcon(QIcon(":cam_off32.svg"), this); _trayIcon->setContextMenu(_menu); _trayIcon->setVisible(true); @@ -72,19 +64,26 @@ PVSGUI::PVSGUI(QWidget *parent) : else qDebug("[%s] ERROR: Could not connect to PVS daemon!", metaObject()->className()); - // get available hosts - QDBusPendingReply<QStringList> reply1 = _ifaceDBus->getAvailableHosts(); + // ask if restricted mode is on + QDBusPendingReply<bool> reply1 = _ifaceDBus->isRestricted(); reply1.waitForFinished(); - QStringList hosts = reply1.value(); - if (reply1.isValid() && !hosts.isEmpty()) + _restricted = reply1.value(); + + setupMenu(); + + // get available hosts + QDBusPendingReply<QStringList> reply2 = _ifaceDBus->getAvailableHosts(); + reply2.waitForFinished(); + QStringList hosts = reply2.value(); + if (reply2.isValid() && !hosts.isEmpty()) foreach (QString host, hosts) addHost(host); // already connected? - QDBusPendingReply<QString> reply2 = _ifaceDBus->isConnected(); - reply2.waitForFinished(); - QString host = reply2.value(); - if (reply2.isValid() && host != "") + QDBusPendingReply<QString> reply3 = _ifaceDBus->isConnected(); + reply3.waitForFinished(); + QString host = reply3.value(); + if (reply3.isValid() && host != "") connected(host); else disconnected(); @@ -239,17 +238,17 @@ void PVSGUI::setupMenu() // setup menu _menu->addAction(_showAction); - _menu->addMenu(_hostMenu); - _menu->addAction(_disconnectAction); + if (!_restricted) _menu->addMenu(_hostMenu); + if (!_restricted) _menu->addAction(_disconnectAction); _menu->addAction(_showInfoAction); _menu->addSeparator(); _menu->addAction(_startChatAction); _menu->addAction(_sendFileAction); _menu->addSeparator(); - _menu->addAction(_configAction); + if (!_restricted) _menu->addAction(_configAction); _menu->addAction(_aboutAction); _menu->addSeparator(); - _menu->addAction(_quitAction); + if (!_restricted) _menu->addAction(_quitAction); pvsButton->setMenu(_menu); hostButton->setMenu(_hostMenu); diff --git a/src/pvsgui.h b/src/pvsgui.h index b96d73c..f87b328 100644 --- a/src/pvsgui.h +++ b/src/pvsgui.h @@ -93,6 +93,7 @@ private: QAction *_quitAction; int _position; + bool _restricted; QPoint _clickPoint; QString _passwd; |