summaryrefslogtreecommitdiffstats
path: root/src/pvs.cpp
diff options
context:
space:
mode:
authorSebastien Braun2010-10-05 22:57:48 +0200
committerSebastien Braun2010-10-05 22:57:48 +0200
commit0cb19c0a597bfb7a6cac416fb5c0b0a89043081e (patch)
tree1c076c798ae6ce960bccde2e0aea675143d961d8 /src/pvs.cpp
parentFix SIGSEGV-generating lookup bug when incoming multicast transfers are retried (diff)
parent[PVSGUI] parsing cmdargs fixed (diff)
downloadpvs-0cb19c0a597bfb7a6cac416fb5c0b0a89043081e.tar.gz
pvs-0cb19c0a597bfb7a6cac416fb5c0b0a89043081e.tar.xz
pvs-0cb19c0a597bfb7a6cac416fb5c0b0a89043081e.zip
Merge remote branch 'openslx/master' into mcastft
Conflicts: CMakeLists.txt pvsmgr.qrc src/gui/clientConfigDialog.cpp src/gui/mainWindow.cpp src/gui/ui/mainwindow.ui src/gui/ui/mainwindowtouch.ui src/pvs.cpp src/pvs.h src/pvsDaemon.cpp src/pvsgui.cpp
Diffstat (limited to 'src/pvs.cpp')
-rwxr-xr-x[-rw-r--r--]src/pvs.cpp100
1 files changed, 61 insertions, 39 deletions
diff --git a/src/pvs.cpp b/src/pvs.cpp
index 1c389df..cd9ed2d 100644..100755
--- a/src/pvs.cpp
+++ b/src/pvs.cpp
@@ -43,16 +43,17 @@ PVS::PVS() :
_vncRequested = false;
readPolicyFiles();
loadCommands();
- _blankScreen = NULL;
+ /*#ifndef __WIN32__*/
+ _blankScreen = NULL;
+ /*#endif*/
_vncPort = -1;
- QSettings settings;
_masterMcastConfig = new McastConfiguration(this);
- _masterMcastConfig->loadFrom(&settings);
+ _masterMcastConfig->loadFrom(&_settings, "multicast");
// add a notify to the allow file, so we get informed when the file is changed
- QString watchPath("/home/");
- watchPath.append(getUserName().append(QString("/.pvs/.allow")));
+ QString watchPath(getPolicyDir());
+ watchPath.append(QString(".allow"));
_notify = new QFileSystemWatcher(this);
_notify->addPath(QString(watchPath.toUtf8().data()));
@@ -62,8 +63,10 @@ PVS::PVS() :
// connect to D-Bus
new PvsAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
- dbus.registerObject("/", this);
- dbus.registerService("org.openslx.pvs");
+ if (!dbus.registerObject("/", this))
+ qDebug("[ERROR] DBus: Could not register object");
+ if (!dbus.registerService("org.openslx.pvs"))
+ qDebug("[ERROR] DBus: Could not register service");
_sdClient = new PVSServiceDiscovery(this);
@@ -75,6 +78,7 @@ PVS::PVS() :
_timerLockTest = 0;
_timerLockDelay = 0;
+ #ifndef __WIN32__
//add signalhandling for sigterm signals
struct sigaction act;
act.sa_handler = &PVS::signalHandler;
@@ -86,7 +90,7 @@ PVS::PVS() :
sigaction(SIGHUP, &act, 0);
sigaction(SIGINT, &act, 0);
sigaction(SIGQUIT, &act, 0);
-
+ #endif /*__WIN32__*/
}
PVS::~PVS()
@@ -242,6 +246,19 @@ void PVS::onCommand(PVSMsg cmdMessage)
loadMcastConfig(message);
return;
}
+ if (ident.compare("SHOWPROCESSES") == 0)
+ {
+ // do stuff to show processes
+ // to test if SHOWPROCESSES command is submitted correct uncomment following lines
+ // a messagebox will appear on the client
+ // emit showMessage("Show Processes", "", true);
+ return;
+ }
+ if (ident.compare("KILLPROCESS") == 0)
+ {
+ // do stuff to kill a process
+ return;
+ }
#ifdef never
// prototype
@@ -383,24 +400,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)
{
@@ -515,12 +517,13 @@ void PVS::setScriptPath(QString path)
bool PVS::gotVNCScript()
{
- if (fileExists(_vncScriptPath))
+ if (!_vncScriptPath.isEmpty() && fileExists(_vncScriptPath))
return true;
- if (policyFileExists(_vncScriptName))
+
+ if (!_vncScriptName.isEmpty() && policyFileExists(_vncScriptName))
return true;
- return false;
+ return false;
}
/**
* setup password and port
@@ -566,14 +569,19 @@ int PVS::startVNCScript(int port, QString pass, QString rwpass)
commandLine.append(rwpass);
if (!system(NULL))
ConsoleLog writeError("No Command processor available");
-
int result = system(commandLine.toUtf8().data());
+ #ifndef __WIN32__
+//TODO Win32
result = WEXITSTATUS(result);
if (result != 0)
ConsoleLog writeError(QString("VNC-Server is not running, code: ") + int2String(result));
else
ConsoleLog writeLine("VNC-Server should be running");
return result;
+ #else
+ /*Code fuer VNC-Aufruf unter Windows einfuegen*/
+ return 0;
+ #endif /*__WIN32__*/
}
else
{
@@ -589,6 +597,7 @@ int PVS::stopVNCScript()
{
if (gotVNCScript())
{
+ #ifndef __WIN32__
ConsoleLog writeLine("Stopping VNC-Script");
QString commandLine(_vncScriptPath);
commandLine.append(" ");
@@ -600,6 +609,10 @@ int PVS::stopVNCScript()
ConsoleLog writeLine("VNC-Server should be stopped");
int result = system(commandLine.toUtf8().data());
return WEXITSTATUS(result);
+ #else
+ /*Code fuer VNC-Server stoppen unter Windows einfuegen*/
+ return 0;
+ #endif /*__WIN32__*/
}
else
{
@@ -607,9 +620,10 @@ int PVS::stopVNCScript()
}
}
-void PVS::start()
+bool PVS::start()
{
_pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROJECTING", "YES"));
+ return true;
}
void PVS::onConnected(QString name)
@@ -676,6 +690,7 @@ QString PVS::getIpByNick(QString nick)
void PVS::signalHandler(int signal)
{
ConsoleLog writeLine(QString("Received Signal ").append (int2String(signal)));
+ #ifndef __WIN32__
switch (signal) {
case SIGHUP:
mainClient->quit();
@@ -690,6 +705,9 @@ void PVS::signalHandler(int signal)
mainClient->quit();
break;
}
+ #else
+ ConsoleLog writeLine("Abfang nicht definiert fuer Windows");
+ #endif /*__WIN32__*/
}
@@ -740,14 +758,6 @@ void PVS::cancelIncomingMulticastTransfer(qulonglong transferID)
}
}
-void PVS::setMulticastInterface(QString const& interfaceName)
-{
- QSettings settings;
- _masterMcastConfig->multicastInterface(interfaceName);
- _masterMcastConfig->writeTo(&settings, "multicast");
- settings.sync();
-}
-
void PVS::onIncomingMulticastTransfer(QString const& sender, qulonglong transferID,
QString const& basename, qulonglong size, ushort port)
{
@@ -870,3 +880,15 @@ void PVS::loadMcastConfig(QString const& message)
ConsoleLog writeLine(QString("Reconfigured multicast filetransfer to IP %1, UDP port base %2, destination port %3, source port %4, MTU %5, Window Size %6, rate %7, %8using UDP")
.arg(addr).arg(udpp).arg(dp).arg(sp).arg(mtu).arg(wsz).arg(rate).arg(useudp ? "" : "not "));
}
+
+void PVS::setConfigValue(QString key, QString value)
+{
+ _settings.setValue(key, value);
+ _settings.sync();
+ getVNCAllow();
+}
+
+QString PVS::getConfigValue(QString key)
+{
+ return _settings.value(key).toString();
+}