summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]CMakeLists.txt100
-rw-r--r--i18n/pvs_ar_JO.ts8
-rw-r--r--i18n/pvs_de_DE.ts8
-rw-r--r--i18n/pvs_es_MX.ts8
-rw-r--r--i18n/pvs_fr_FR.ts8
-rw-r--r--i18n/pvs_pl_PL.ts8
-rwxr-xr-x[-rw-r--r--]src/pvs.cpp27
-rwxr-xr-x[-rw-r--r--]src/pvs.h11
-rwxr-xr-x[-rw-r--r--]src/pvsDaemon.cpp22
-rw-r--r--src/pvsgui.cpp2
-rwxr-xr-x[-rw-r--r--]src/util/clientGUIUtils.h25
-rwxr-xr-xsrc/util/clientGUIUtils_Win32.cpp46
-rwxr-xr-xsrc/util/clientGUIUtils_X11.cpp168
-rwxr-xr-x[-rw-r--r--]src/util/consoleLogger.cpp2
-rwxr-xr-x[-rw-r--r--]src/util/util.cpp62
-rwxr-xr-x[-rw-r--r--]src/util/util.h6
16 files changed, 411 insertions, 100 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9570774..d2eae17 100644..100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,8 +11,8 @@ CMAKE_MINIMUM_REQUIRED( VERSION 2.6.2 )
# set compiler optimizations for debug and release
SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall")
-SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-# -march=native -DQT_NO_DEBUG_OUTPUT")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native")
+# -DQT_NO_DEBUG_OUTPUT")
# local cmake modules
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
@@ -31,6 +31,15 @@ INCLUDE_DIRECTORIES(
${CMAKE_BINARY_DIR}
)
+IF(WIN32)
+ SET(sysdep_suffix _Win32)
+ INCLUDE_DIRECTORIES(
+ /c/KDE4/tmp/LibVNCServer-0.9.7/
+ )
+ELSEIF(UNIX)
+ SET(sysdep_suffix _X11)
+ENDIF(WIN32)
+
################################################################################
# Variables
################################################################################
@@ -78,7 +87,7 @@ SET( PVS_SRCS
src/net/pvsLocalhostCommunicator.cpp
src/util/util.cpp
src/util/consoleLogger.cpp
- src/util/clientGUIUtils.cpp
+ src/util/clientGUIUtils${sysdep_suffix}.cpp
src/util/pvsSettingsManager.cpp
src/core/pvsChatClient.cpp
src/net/pvsServiceDiscovery.cpp
@@ -262,6 +271,7 @@ QT4_CREATE_TRANSLATION( PVSGUI_QMS ${PVSGUI_SRCS} ${PVSGUI_UI_HDRS} ${PVSGUI_TSS
################################################################################
## here we instruct CMake to build our executable from all of the source files
+if(UNIX)
ADD_EXECUTABLE( pvsmgr
${PVSMGR_SRCS}
${PVSMGR_MOC_SRCS}
@@ -277,6 +287,7 @@ ADD_EXECUTABLE( pvsmgrtouch
${PVSMGR_RC_SRCS}
${PVSMGR_QMS}
)
+ENDIF(UNIX)
ADD_EXECUTABLE( pvs
${PVS_SRCS}
@@ -295,35 +306,72 @@ ADD_EXECUTABLE( pvsgui
# last thing we have to do is to tell CMake what libraries our executable needs,
# luckily FIND_PACKAGE prepared variables for us:
-TARGET_LINK_LIBRARIES( pvsmgr
- ${QT_LIBRARIES}
- ${VNC_LIBRARIES}
- ${X11_LIBRARIES}
-)
-
-TARGET_LINK_LIBRARIES( pvsmgrtouch
- ${QT_LIBRARIES}
- ${VNC_LIBRARIES}
- ${X11_LIBRARIES}
-)
-
-TARGET_LINK_LIBRARIES( pvs
- ${QT_LIBRARIES}
- ${VNC_LIBRARIES}
- ${X11_LIBRARIES}
-)
-
-TARGET_LINK_LIBRARIES( pvsgui
- ${QT_LIBRARIES}
- ${VNC_LIBRARIES}
-)
+IF(WIN32)
+ TARGET_LINK_LIBRARIES( pvsmgr
+
+ )
+ELSEIF(UNIX)
+TARGET_LINK_LIBRARIES( pvsmgr
+ ${QT_LIBRARIES}
+ ${VNC_LIBRARIES}
+ ${X11_LIBRARIES}
+ )
+ENDIF(WIN32)
+
+IF(WIN32)
+ TARGET_LINK_LIBRARIES( pvsmgrtouch
+
+ )
+ELSEIF(UNIX)
+ TARGET_LINK_LIBRARIES( pvsmgrtouch
+ ${QT_LIBRARIES}
+ ${VNC_LIBRARIES}
+ ${X11_LIBRARIES}
+ )
+ENDIF(WIN32)
+
+IF(WIN32)
+ TARGET_LINK_LIBRARIES( pvs
+ ${QT_LIBRARIES}
+ ${VNC_LIBRARIES}
+ advapi32
+ ws2_32
+ )
+ELSEIF(UNIX)
+ TARGET_LINK_LIBRARIES( pvs
+ ${QT_LIBRARIES}
+ ${VNC_LIBRARIES}
+ ${X11_LIBRARIES}
+ )
+ENDIF(WIN32)
+
+IF(WIN32)
+ TARGET_LINK_LIBRARIES( pvsgui
+ ${QT_LIBRARIES}
+ ${VNC_LIBRARIES}
+ #advapi32
+ ws2_32
+ )
+ELSEIF(UNIX)
+ TARGET_LINK_LIBRARIES( pvsgui
+ ${QT_LIBRARIES}
+ ${VNC_LIBRARIES}
+ )
+ENDIF(WIN32)
+
+IF(UNIX)
SET_PROPERTY(TARGET pvsmgrtouch PROPERTY COMPILE_DEFINITIONS MAINWINDOW_USE_TOUCHGUI)
SET_PROPERTY(TARGET pvsmgr PROPERTY COMPILE_DEFINITIONS MAINWINDOW_USE_NORMALGUI)
+ENDIF(UNIX)
# add install target to our makefile
CONFIGURE_FILE( org.openslx.pvs.service ${CMAKE_BINARY_DIR}/org.openslx.pvs.service )
-INSTALL( TARGETS pvsmgr pvs pvsgui pvsmgrtouch RUNTIME DESTINATION bin )
+IF(WIN32)
+ INSTALL( TARGETS pvs pvsgui RUNTIME DESTINATION bin )
+ELSEIF(UNIX)
+ INSTALL( TARGETS pvsmgr pvs pvsgui pvsmgrtouch RUNTIME DESTINATION bin )
+ENDIF(WIN32)
INSTALL( PROGRAMS misc/pvs-vncsrv DESTINATION bin)
INSTALL( FILES ${CMAKE_BINARY_DIR}/org.openslx.pvs.service DESTINATION share/dbus-1/services )
diff --git a/i18n/pvs_ar_JO.ts b/i18n/pvs_ar_JO.ts
index c1b19cb..38bf578 100644
--- a/i18n/pvs_ar_JO.ts
+++ b/i18n/pvs_ar_JO.ts
@@ -4,22 +4,22 @@
<context>
<name>PVS</name>
<message>
- <location filename="../src/pvs.cpp" line="272"/>
+ <location filename="../src/pvs.cpp" line="275"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>VNC connection</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>The host </source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="352"/>
+ <location filename="../src/pvs.cpp" line="355"/>
<source> requested your screen!</source>
<translation type="unfinished"></translation>
</message>
diff --git a/i18n/pvs_de_DE.ts b/i18n/pvs_de_DE.ts
index c1b19cb..38bf578 100644
--- a/i18n/pvs_de_DE.ts
+++ b/i18n/pvs_de_DE.ts
@@ -4,22 +4,22 @@
<context>
<name>PVS</name>
<message>
- <location filename="../src/pvs.cpp" line="272"/>
+ <location filename="../src/pvs.cpp" line="275"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>VNC connection</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>The host </source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="352"/>
+ <location filename="../src/pvs.cpp" line="355"/>
<source> requested your screen!</source>
<translation type="unfinished"></translation>
</message>
diff --git a/i18n/pvs_es_MX.ts b/i18n/pvs_es_MX.ts
index c1b19cb..38bf578 100644
--- a/i18n/pvs_es_MX.ts
+++ b/i18n/pvs_es_MX.ts
@@ -4,22 +4,22 @@
<context>
<name>PVS</name>
<message>
- <location filename="../src/pvs.cpp" line="272"/>
+ <location filename="../src/pvs.cpp" line="275"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>VNC connection</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>The host </source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="352"/>
+ <location filename="../src/pvs.cpp" line="355"/>
<source> requested your screen!</source>
<translation type="unfinished"></translation>
</message>
diff --git a/i18n/pvs_fr_FR.ts b/i18n/pvs_fr_FR.ts
index c1b19cb..38bf578 100644
--- a/i18n/pvs_fr_FR.ts
+++ b/i18n/pvs_fr_FR.ts
@@ -4,22 +4,22 @@
<context>
<name>PVS</name>
<message>
- <location filename="../src/pvs.cpp" line="272"/>
+ <location filename="../src/pvs.cpp" line="275"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>VNC connection</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>The host </source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="352"/>
+ <location filename="../src/pvs.cpp" line="355"/>
<source> requested your screen!</source>
<translation type="unfinished"></translation>
</message>
diff --git a/i18n/pvs_pl_PL.ts b/i18n/pvs_pl_PL.ts
index c1b19cb..38bf578 100644
--- a/i18n/pvs_pl_PL.ts
+++ b/i18n/pvs_pl_PL.ts
@@ -4,22 +4,22 @@
<context>
<name>PVS</name>
<message>
- <location filename="../src/pvs.cpp" line="272"/>
+ <location filename="../src/pvs.cpp" line="275"/>
<source>Message</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>VNC connection</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="350"/>
+ <location filename="../src/pvs.cpp" line="353"/>
<source>The host </source>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../src/pvs.cpp" line="352"/>
+ <location filename="../src/pvs.cpp" line="355"/>
<source> requested your screen!</source>
<translation type="unfinished"></translation>
</message>
diff --git a/src/pvs.cpp b/src/pvs.cpp
index d09d407..1c08be5 100644..100755
--- a/src/pvs.cpp
+++ b/src/pvs.cpp
@@ -36,12 +36,14 @@ PVS::PVS() :
_vncRequested = false;
readPolicyFiles();
loadCommands();
- _blankScreen = NULL;
+ /*#ifndef __WIN32__*/
+ _blankScreen = NULL;
+ /*#endif*/
_vncPort = -1;
// 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()));
@@ -64,6 +66,7 @@ PVS::PVS() :
_timerLockTest = 0;
_timerLockDelay = 0;
+ #ifndef __WIN32__
//add signalhandling for sigterm signals
struct sigaction act;
act.sa_handler = &PVS::signalHandler;
@@ -75,7 +78,7 @@ PVS::PVS() :
sigaction(SIGHUP, &act, 0);
sigaction(SIGINT, &act, 0);
sigaction(SIGQUIT, &act, 0);
-
+ #endif /*__WIN32__*/
}
PVS::~PVS()
@@ -498,14 +501,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
{
@@ -521,6 +529,7 @@ int PVS::stopVNCScript()
{
if (gotVNCScript())
{
+ #ifndef __WIN32__
ConsoleLog writeLine("Stopping VNC-Script");
QString commandLine(_vncScriptPath);
commandLine.append(" ");
@@ -532,6 +541,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
{
@@ -608,6 +621,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();
@@ -622,6 +636,9 @@ void PVS::signalHandler(int signal)
mainClient->quit();
break;
}
+ #else
+ ConsoleLog writeLine("Abfang nicht definiert fuer Windows");
+ #endif /*__WIN32__*/
}
diff --git a/src/pvs.h b/src/pvs.h
index ba696d8..b6b5e65 100644..100755
--- a/src/pvs.h
+++ b/src/pvs.h
@@ -13,8 +13,10 @@
#define PVSCLIENT_H_
#include <QtCore>
-#include <X11/Xlib.h>
-#include <X11/cursorfont.h>
+#ifndef __WIN32__
+ #include <X11/Xlib.h>
+ #include <X11/cursorfont.h>
+#endif
#include <signal.h>
#include "setup.h"
@@ -25,7 +27,6 @@
#include "src/util/consoleLogger.h"
#include "src/util/clientGUIUtils.h"
-
class PVSServiceDiscovery;
class PVSDiscoveredServer;
@@ -116,7 +117,9 @@ private:
bool _locked; ///< are we locked?
QString _lockMsg; ///< message to display while we're locked
bool _vncAllowed; ///< whether vncConnections to this client are allowed (dup?)
- BlankScreen *_blankScreen;///< obhject to blank the screen
+ /*#ifndef __WIN32__*/
+ BlankScreen *_blankScreen;///< object to blank the screen
+ /*#endif*/
QFileSystemWatcher* _notify; ///< used to get notifies about file changes
//vnc-server
diff --git a/src/pvsDaemon.cpp b/src/pvsDaemon.cpp
index e87bfe7..e9479df 100644..100755
--- a/src/pvsDaemon.cpp
+++ b/src/pvsDaemon.cpp
@@ -68,11 +68,17 @@ int main(int argc, char** argv)
int port = -1;
QFileInfo script;
- script.setFile("/usr/bin/pvs-vncsrv");
- if (!script.exists())
- script.setFile("/usr/local/bin/pvs-vncsrv");
- if (!script.exists())
- script.setFile("/home/" + getUserName() + "/.pvs/pvs-vncsrv");
+ #ifdef __WIN32__
+ //TODO Win32
+ if (!script.exists())
+ script.setFile(getHomeDir() + "/.pvs/pvs-vncsrv_win32.bat");
+ #else
+ script.setFile("/usr/bin/pvs-vncsrv");
+ if (!script.exists())
+ script.setFile("/usr/local/bin/pvs-vncsrv");
+ if (!script.exists())
+ script.setFile(getHomeDir() + "/.pvs/pvs-vncsrv");
+ #endif //__WIN32__
QCoreApplication app(argc, argv);
app.setOrganizationName("openslx");
@@ -293,6 +299,8 @@ int main(int argc, char** argv)
#ifdef as_daemon
+ /*Alex: neu schreiben als pvsdaemon_win32.cpp und minimieren in Task-Leiste*/
+ #ifndef __WIN32__
/* Our process ID and Session ID */
pid_t pid, sid;
@@ -331,10 +339,10 @@ int main(int argc, char** argv)
/* Close out the standard file descriptors */
close(STDIN_FILENO);
- freopen ((QString("/home/").append(getUserName().append(QString("/.pvs/dump")))).toUtf8().data(),"w",stdout);
+ freopen ((QString(getHomeDir()).append(QString("/.pvs/dump"))).toUtf8().data(),"w",stdout);
//close(STDOUT_FILENO);
close(STDERR_FILENO);
-
+ #endif /*__WIN32__*/
/* Daemon-specific initialization goes here */
/* The Big Loop */
diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp
index 6fdd673..b2f0a8f 100644
--- a/src/pvsgui.cpp
+++ b/src/pvsgui.cpp
@@ -107,7 +107,7 @@ PVSGUI::PVSGUI(QWidget *parent) :
connect(_ifaceDBus, SIGNAL(delHost(QString)), this, SLOT(delHost(QString)));
// show toolbar
- setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
+ setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint);
setAttribute(Qt::WA_AlwaysShowToolTips);
updateConfig();
setVisible(true);
diff --git a/src/util/clientGUIUtils.h b/src/util/clientGUIUtils.h
index 28b05cc..b04d3fe 100644..100755
--- a/src/util/clientGUIUtils.h
+++ b/src/util/clientGUIUtils.h
@@ -1,21 +1,20 @@
+#ifndef _BLANKSCREEN_H_
+#define _BLANKSCREEN_H_
+
#include "src/util/consoleLogger.h"
-#include <X11/Xlib.h> // Every Xlib program must include this
-#include <X11/cursorfont.h>
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
-
#define REFRESH_RATE 0.15
-
-#ifndef _BLANKSCREEN_H_
-#define _BLANKSCREEN_H_
+class BlankScreen_Sysdep;
class BlankScreen
{
public:
BlankScreen();
+ virtual ~BlankScreen();
void draw(bool force = false);
bool lock();
bool unlock();
@@ -23,17 +22,7 @@ public:
bool lock_inputs();
private:
- Display *dpy;
- Window win;
- XEvent ev;
- int scr;
-
- bool locked;
-
-
- QString lockMsg;
- int blackColor, whiteColor;
- int offX, offY;
+ BlankScreen_Sysdep* _sysdep;
};
-#endif
+#endif \ No newline at end of file
diff --git a/src/util/clientGUIUtils_Win32.cpp b/src/util/clientGUIUtils_Win32.cpp
new file mode 100755
index 0000000..1b4d2ae
--- /dev/null
+++ b/src/util/clientGUIUtils_Win32.cpp
@@ -0,0 +1,46 @@
+
+#include "clientGUIUtils.h"
+#include <qwidget.h>
+
+struct BlankScreen_Sysdep {
+
+ bool locked;
+ QWidget* blankwin;
+
+ QString lockMsg;
+ int blackColor, whiteColor;
+ int offX, offY;
+};
+
+BlankScreen::BlankScreen()
+{
+ _sysdep = new BlankScreen_Sysdep;
+ _sysdep->blankwin = new QWidget(0, Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
+ _sysdep->blankwin->setWindowState(Qt::WindowFullScreen);
+ _sysdep->blankwin->show();
+}
+
+BlankScreen::~BlankScreen()
+{
+ delete _sysdep;
+}
+
+void BlankScreen::draw(bool force)
+{
+
+}
+
+bool BlankScreen::lock()
+{
+ return true;
+}
+
+bool BlankScreen::lock_inputs()
+{
+ return true;
+}
+
+bool BlankScreen::unlock()
+{
+ return true;
+}
diff --git a/src/util/clientGUIUtils_X11.cpp b/src/util/clientGUIUtils_X11.cpp
new file mode 100755
index 0000000..29c96f0
--- /dev/null
+++ b/src/util/clientGUIUtils_X11.cpp
@@ -0,0 +1,168 @@
+#include "clientGUIUtils.h"
+#include <X11/Xlib.h>
+#include <X11/cursorfont.h>
+
+
+struct BlankScreen_Sysdep {
+
+ Display *dpy;
+ Window win;
+ XEvent ev;
+ int scr;
+
+ bool locked;
+
+
+ QString lockMsg;
+ int blackColor, whiteColor;
+ int offX, offY;
+};
+
+BlankScreen::BlankScreen()
+{
+ _sysdep = new BlankScreen_Sysdep;
+ _sysdep->dpy = XOpenDisplay(NULL);
+ _sysdep->scr = DefaultScreen(_sysdep->dpy);
+ assert(_sysdep->dpy);
+ _sysdep->blackColor = BlackPixel(_sysdep->dpy, DefaultScreen(_sysdep->dpy));
+ _sysdep->whiteColor = WhitePixel(_sysdep->dpy, DefaultScreen(_sysdep->dpy));
+// win = XCreateSimpleWindow(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), 0, 0, 200, 100, 0, blackColor, whiteColor);
+ _sysdep->win = XCreateSimpleWindow(_sysdep->dpy, RootWindow(_sysdep->dpy, _sysdep->scr), 10, 10, 200, 200, 1, WhitePixel(_sysdep->dpy, _sysdep->scr), BlackPixel(_sysdep->dpy, _sysdep->scr));
+
+ XSelectInput(_sysdep->dpy, _sysdep->win, ExposureMask | KeyPressMask);
+ _sysdep->locked = false;
+ _sysdep->offX = _sysdep->offY = 0;
+}
+
+BlankScreen::~BlankScreen()
+{
+ delete _sysdep;
+}
+
+void BlankScreen::draw(bool force)
+{
+ if (_sysdep->locked)// no need to draw if we're not showing the window
+ {
+ XWindowAttributes xwa;
+ XGetWindowAttributes(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), &xwa);
+ int hx = (xwa.width)>>2, hy = (xwa.height)>>2;
+
+ if (XCheckTypedEvent(_sysdep->dpy, Expose, &_sysdep->ev) || force )
+ {
+ hx += _sysdep->offX;
+ hy += _sysdep->offY;
+
+ GC gcc = XCreateGC(_sysdep->dpy, _sysdep->win, 0, NULL);
+ XSetForeground(_sysdep->dpy, gcc, _sysdep->whiteColor);
+// XClearArea(_sysdep->dpy, _sysdep->win, 0, 0, xwa.width, xwa.height, false);
+ if (_sysdep->lockMsg.size() > 0)
+ {
+ char *msg = const_cast<char*>(_sysdep->lockMsg.toUtf8().data());
+ XDrawString(_sysdep->dpy, _sysdep->win, gcc/*DefaultGC(dpy, scr)*/, hx, hy, msg, strlen(msg));
+ }
+ else
+ {
+ }
+ }
+ }
+}
+
+bool BlankScreen::lock()
+{
+#define lock_test
+
+ if (_sysdep->locked)
+ return _sysdep->locked;
+
+ // We want to get MapNotify events
+ XSelectInput(_sysdep->dpy, _sysdep->win, StructureNotifyMask);
+
+ // "Map" the window (that is, make it appear on the screen)
+ XMapWindow(_sysdep->dpy, _sysdep->win);
+
+ // Create a "Graphics Context"
+ //GC gc = XCreateGC(dpy, win, 0, NULL);
+
+ XEvent xev;
+ Atom wm_state = XInternAtom(_sysdep->dpy, "_NET_WM_STATE", False);
+ Atom fullscreen = XInternAtom(_sysdep->dpy, "_NET_WM_STATE_FULLSCREEN", False);
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = _sysdep->win;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = fullscreen;
+ xev.xclient.data.l[2] = 0;
+
+ XSendEvent(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), False,
+ SubstructureNotifyMask, &xev);
+
+
+
+
+ // Wait for the MapNotify event
+ for (;;)
+ {
+ XEvent e;
+ XNextEvent(_sysdep->dpy, &e);
+ if (e.type == MapNotify)
+ break;
+ }
+ //Flush it!
+ //XFlush(_sysdep->dpy);
+
+#ifndef lock_test
+ // load the locked cursor, so people dont think they can click anything
+ // TODO: Use some kind of invisible cursor instead of the wait-cursor
+ Cursor _sysdep->locked_cur = XCreateFontCursor(_sysdep->dpy, XC_watch);
+ XDefineCursor(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy),_sysdep->locked_cur);
+#endif
+
+ // grabbing of keyboard and mouse and hide the cursor
+ XGrabKeyboard(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), false, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XGrabPointer(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), false, 0, GrabModeAsync, GrabModeAsync, None, NULL, CurrentTime);
+
+ if (!_sysdep->locked)
+ ConsoleLog writeLine(QString("Locked"));
+
+ // see header for more information on this switch
+ return _sysdep->locked = true;
+}
+
+bool BlankScreen::lock_inputs()
+{
+ // grabbing of keyboard and mouse and hide the cursor
+ XGrabKeyboard(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), false, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XGrabPointer(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), false, 0, GrabModeAsync, GrabModeAsync, None, NULL, CurrentTime);
+ return true;
+}
+
+bool BlankScreen::unlock()
+{
+
+ if (_sysdep->dpy)
+ {
+
+ int retval = -1;
+
+ //reset cursor to arrow (no *real* default here...)
+ Cursor normal_cur = XCreateFontCursor(_sysdep->dpy, XC_arrow);
+ XDefineCursor(_sysdep->dpy, DefaultRootWindow(_sysdep->dpy), normal_cur);
+
+ // ungrabbing of keyboard and mouse
+ XUngrabPointer(_sysdep->dpy, CurrentTime);
+ XUngrabKeyboard(_sysdep->dpy, CurrentTime);
+
+
+ retval = XUnmapWindow(_sysdep->dpy,_sysdep->win);
+ if (retval == BadWindow)
+ ConsoleLog writeError(QString("Bad window while unmapping. Badwindow: ").append(int2String(retval)));
+ XFlush(_sysdep->dpy);
+ }
+ if (_sysdep->locked)
+ ConsoleLog writeLine(QString("Unlocked"));
+
+ _sysdep->lockMsg.clear();
+ return !(_sysdep->locked = false);
+}
diff --git a/src/util/consoleLogger.cpp b/src/util/consoleLogger.cpp
index b523b40..ae29989 100644..100755
--- a/src/util/consoleLogger.cpp
+++ b/src/util/consoleLogger.cpp
@@ -226,7 +226,7 @@ void ConsoleLogger::_prepareLog()
_logFileGood = false;
_readLog();
- mkdir(getPolicyFilePath(QString()).toUtf8().data(), 0777);
+ createPolicyDir();
QString fullpath;
fullpath.append(_logPath);
//TODO: handle wether path/ or path were entered?
diff --git a/src/util/util.cpp b/src/util/util.cpp
index 946168e..7463ae0 100644..100755
--- a/src/util/util.cpp
+++ b/src/util/util.cpp
@@ -6,7 +6,11 @@
#include <cstdlib>
#include <QStringList>
#include <iostream>
-
+#include <QDir>
+#ifdef __WIN32__
+ #include <windows.h>
+ #include <Lmcons.h>
+#endif //__WIN32__
PVSServerEntry::PVSServerEntry(QString name)
{
@@ -45,7 +49,11 @@ int getRandom(int min, int max)
if (init)
{
init = false;
+ #ifndef __WIN32__
srand ( time(NULL) + getpid() );
+ #else
+ srand ( time(NULL) ); /*might be solved by another random factor*/
+ #endif
}
if (min >= max) return rand();
return rand() % (max-min+1) + min;
@@ -184,12 +192,29 @@ QString colonSplitter(QString line, bool first)
QString getUserName()
{
- struct passwd* passUser = getpwuid(getuid());
QString username;
- if (passUser)
- {
- username = QString(passUser->pw_name);
- }
+ #ifdef __WIN32__
+ WCHAR* lpszSystemInfo; // pointer to system information
+ DWORD cchBuff = 256; // size of user name
+ WCHAR tchBuffer[UNLEN + 1]; // buffer for expanded string
+
+ lpszSystemInfo = tchBuffer;
+
+ // Get and display the user name.
+ GetUserNameW(lpszSystemInfo, &cchBuff);
+
+ //Unicode string needs to be converted
+ username = QString::fromWCharArray(lpszSystemInfo);
+ #elif defined __WIN32__
+ struct passwd* passUser = getpwuid(getuid());
+
+ if (passwd)
+ username = passwd->pw_name;
+ if (passUser)
+ {
+ username = QString(passUser->pw_name);
+ }
+ #endif //#ifdef __WIN32__
if (username.isEmpty())
{
printf("USERNAME COULDNT BE RETRIEVED!\n");
@@ -202,19 +227,21 @@ QString getUserName()
QString getFullUsername()
{
QString fullname = getUserName();
- struct passwd *pd;
+ #ifndef __WIN32__
+ struct passwd *pd;
- if (NULL == (pd = getpwuid(getuid())))
- {ConsoleLog writeError("getpwuid() error.");}
- else
- {
- QString tmp = pd->pw_gecos;
- QStringList userData = tmp.split(",");
- if(userData[0].length() > 0 )
+ if (NULL == (pd = getpwuid(getuid())))
+ {ConsoleLog writeError("getpwuid() error.");}
+ else
{
- fullname = userData[0];
+ QString tmp = pd->pw_gecos;
+ QStringList userData = tmp.split(",");
+ if(userData[0].length() > 0 )
+ {
+ fullname = userData[0];
+ }
}
- }
+ #endif //__WIN32__ //might be completed some time to a full solution for WIN32
return fullname;
}
@@ -266,7 +293,8 @@ bool policyFileExists(QString fileName)
void createPolicyDir()
{
- mkdir(getPolicyDir().toUtf8().data(), 0777);
+ QDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)).mkdir(".pvs");
+ //assuming PolicyDir is defined like in getPolicyDir()
}
void createPolicyFiles()
diff --git a/src/util/util.h b/src/util/util.h
index 6ddefc6..4f2d0ee 100644..100755
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -4,7 +4,11 @@
#include <list>
#include <fstream>
#include <iostream>
-#include <pwd.h>
+#ifndef __WIN32__
+ #include <pwd.h>
+#else
+ /*#include "pwd_win32.h"*/
+#endif /*__WIN32*/
#include <sys/types.h>
#include <sys/stat.h>