From 25305a6ef01120bf3b0d929bae0ba7693f41c46b Mon Sep 17 00:00:00 2001 From: Johann Latocha Date: Sat, 10 Jul 2010 01:54:35 +0200 Subject: Configuration by pvs via D-Bus. Old .allow ist now deprecated, config file: .config/openslx/pvs.conf --- src/pvsgui.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'src/pvsgui.cpp') 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(); -- cgit v1.2.3-55-g7522 From 19316e9142c5ab4a4e1603715fbbf555aac97826 Mon Sep 17 00:00:00 2001 From: Alexander Hoppe Date: Tue, 3 Aug 2010 18:23:24 +0200 Subject: Anpassungen fuer Win32-build. Aufspaltung der ClientGUIUtils in 2 Versionen Anpassungen des HomeDir Alle Aenderungen sollten unschaedlich fuer den Linux-build-Prozess sein. --- CMakeLists.txt | 100 +++++++++++++++++------ i18n/pvs_ar_JO.ts | 8 +- i18n/pvs_de_DE.ts | 8 +- i18n/pvs_es_MX.ts | 8 +- i18n/pvs_fr_FR.ts | 8 +- i18n/pvs_pl_PL.ts | 8 +- src/pvs.cpp | 27 ++++-- src/pvs.h | 11 ++- src/pvsDaemon.cpp | 22 +++-- src/pvsgui.cpp | 2 +- src/util/clientGUIUtils.h | 25 ++---- src/util/clientGUIUtils_Win32.cpp | 46 +++++++++++ src/util/clientGUIUtils_X11.cpp | 168 ++++++++++++++++++++++++++++++++++++++ src/util/consoleLogger.cpp | 2 +- src/util/util.cpp | 62 ++++++++++---- src/util/util.h | 6 +- 16 files changed, 411 insertions(+), 100 deletions(-) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 src/pvs.cpp mode change 100644 => 100755 src/pvs.h mode change 100644 => 100755 src/pvsDaemon.cpp mode change 100644 => 100755 src/util/clientGUIUtils.h create mode 100755 src/util/clientGUIUtils_Win32.cpp create mode 100755 src/util/clientGUIUtils_X11.cpp mode change 100644 => 100755 src/util/consoleLogger.cpp mode change 100644 => 100755 src/util/util.cpp mode change 100644 => 100755 src/util/util.h (limited to 'src/pvsgui.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 9570774..d2eae17 --- 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 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! 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 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! 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 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! 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 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! 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 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! diff --git a/src/pvs.cpp b/src/pvs.cpp old mode 100644 new mode 100755 index d09d407..1c08be5 --- 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 old mode 100644 new mode 100755 index ba696d8..b6b5e65 --- a/src/pvs.h +++ b/src/pvs.h @@ -13,8 +13,10 @@ #define PVSCLIENT_H_ #include -#include -#include +#ifndef __WIN32__ + #include + #include +#endif #include #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 old mode 100644 new mode 100755 index e87bfe7..e9479df --- 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 old mode 100644 new mode 100755 index 28b05cc..b04d3fe --- 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 // Every Xlib program must include this -#include #include #include #include - #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 + +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 +#include + + +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(_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 old mode 100644 new mode 100755 index b523b40..ae29989 --- 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 old mode 100644 new mode 100755 index 946168e..7463ae0 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -6,7 +6,11 @@ #include #include #include - +#include +#ifdef __WIN32__ + #include + #include +#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 old mode 100644 new mode 100755 index 6ddefc6..4f2d0ee --- a/src/util/util.h +++ b/src/util/util.h @@ -4,7 +4,11 @@ #include #include #include -#include +#ifndef __WIN32__ + #include +#else + /*#include "pwd_win32.h"*/ +#endif /*__WIN32*/ #include #include -- cgit v1.2.3-55-g7522 From 88dbb997a823ff77f752ac08105d12474345dfcb Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Wed, 4 Aug 2010 17:24:21 +0200 Subject: Implement GUI for receiving incoming multicast transfers --- src/gui/clientFileReceiveDialog.cpp | 83 +++++++++++++++++++++++++++++++- src/gui/clientFileReceiveDialog.h | 14 ++++++ src/gui/ui/clientFileReceiveDialog.ui | 11 ++++- src/net/pvsIncomingMulticastTransfer.cpp | 37 +++++++------- src/net/pvsIncomingMulticastTransfer.h | 6 +-- src/pvs.cpp | 19 +++++++- src/pvs.h | 5 +- src/pvsgui.cpp | 7 +++ src/pvsgui.h | 1 + 9 files changed, 154 insertions(+), 29 deletions(-) (limited to 'src/pvsgui.cpp') diff --git a/src/gui/clientFileReceiveDialog.cpp b/src/gui/clientFileReceiveDialog.cpp index 669ca81..ff3226a 100644 --- a/src/gui/clientFileReceiveDialog.cpp +++ b/src/gui/clientFileReceiveDialog.cpp @@ -16,6 +16,9 @@ */ #include "clientFileReceiveDialog.h" +#include +#include +#include ClientFileReceiveDialog::ClientFileReceiveDialog(QTcpSocket *socket, QWidget *parent) : QDialog(parent) @@ -37,9 +40,44 @@ ClientFileReceiveDialog::ClientFileReceiveDialog(QTcpSocket *socket, QWidget *pa connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater())); } +ClientFileReceiveDialog::ClientFileReceiveDialog(QString const& sender, qulonglong transferID, + QString const& filename, qulonglong size, OrgOpenslxPvsInterface* ifaceDBus, QWidget* parent) +{ + setupUi(this); + + _transferID = transferID; + _filename = filename; + _ifaceDBus = ifaceDBus; + _bytesToRead = size; + _socket = 0; + _file = 0; + div = 1; + while((size / div) > INT_MAX) + { + div <<= 1; + } + + connect(ifaceDBus, SIGNAL(incomingMulticastTransferStarted(qulonglong)), SLOT(mcastTransferStarted(qulonglong))); + connect(ifaceDBus, SIGNAL(incomingMulticastTransferProgress(qulonglong, qulonglong, qulonglong)), + SLOT(mcastTransferProgress(qulonglong, qulonglong, qulonglong))); + connect(ifaceDBus, SIGNAL(incomingMulticastTransferFinished(qulonglong)), SLOT(mcastTransferFinished(qulonglong))); + connect(ifaceDBus, SIGNAL(incomingMulticastTransferFailed(qulonglong, QString)), SLOT(mcastTransferFailed(qulonglong, QString))); + connect(cancelButton, SIGNAL(clicked()), SLOT(cancelTransfer())); + + qDebug("[%s] New multicast incoming transfer: %s from %s", metaObject()->className(), + filename.toLocal8Bit().constData(), sender.toLocal8Bit().constData()); + + + filenameLabel->setText(QFileInfo(filename).baseName()); + labelNick->setText(sender); + progressBar->setRange(0, 0); +} + + ClientFileReceiveDialog::~ClientFileReceiveDialog() { - _socket->deleteLater(); + if(_socket) + _socket->deleteLater(); qDebug("[%s] Deleted!", metaObject()->className()); } @@ -168,6 +206,49 @@ void ClientFileReceiveDialog::error(QAbstractSocket::SocketError error) close(); } +void ClientFileReceiveDialog::mcastTransferStarted(qulonglong transferID) +{ + if(transferID != _transferID) + return; +} + +void ClientFileReceiveDialog::mcastTransferProgress(qulonglong transferID, qulonglong bytes, qulonglong of) +{ + if(transferID != _transferID) + return; + + progressBar->setRange(0, of); + progressBar->setValue(bytes); +} + +void ClientFileReceiveDialog::mcastTransferFinished(qulonglong transferID) +{ + if(transferID != _transferID) + return; + + QString filename = QFileDialog::getSaveFileName(this, tr("Where should I save %1?").arg(_filename), _filename); + QFile* file = new QFile(_filename); + if(!file->rename(filename)) + { + QMessageBox::warning(this, tr("Could not rename file"), tr("Failed to rename %1 to %2").arg(_filename).arg(filename)); + } + accept(); +} + +void ClientFileReceiveDialog::mcastTransferFailed(qulonglong transferID, QString reason) +{ + if(transferID != _transferID) + return; + + QMessageBox::warning(this, tr("File transfer failed"), tr("File transfer failed for the following reason:\n%1").arg(reason)); + reject(); +} + +void ClientFileReceiveDialog::cancelTransfer() +{ + _ifaceDBus->cancelIncomingMulticastTransfer(_transferID); +} + QString ClientFileReceiveDialog::formatSize(qint64 size) { if (size >= 1000000000) // GB diff --git a/src/gui/clientFileReceiveDialog.h b/src/gui/clientFileReceiveDialog.h index c13d7b7..c9ed220 100644 --- a/src/gui/clientFileReceiveDialog.h +++ b/src/gui/clientFileReceiveDialog.h @@ -18,6 +18,8 @@ #include #include "ui_clientFileReceiveDialog.h" +class OrgOpenslxPvsInterface; + class ClientFileReceiveDialog: public QDialog, private Ui::ClientFileReceiveDialogClass { @@ -25,6 +27,7 @@ Q_OBJECT public: ClientFileReceiveDialog(QTcpSocket *socket, QWidget *parent = 0); + ClientFileReceiveDialog(QString const& sender, qulonglong transferID, QString const& basename, qulonglong size, OrgOpenslxPvsInterface* ifaceDBus, QWidget* parent = 0); ~ClientFileReceiveDialog(); private Q_SLOTS: @@ -33,6 +36,13 @@ private Q_SLOTS: void close(); void error(QAbstractSocket::SocketError error); + // multicast: + void mcastTransferStarted(qulonglong transferID); + void mcastTransferProgress(qulonglong transferID, qulonglong bytes, qulonglong of); + void mcastTransferFinished(qulonglong transferID); + void mcastTransferFailed(qulonglong transferID, QString reason); + void cancelTransfer(); + private: void sendAck(bool b); QString formatSize(qint64 size); @@ -42,6 +52,10 @@ private: qint64 _bytesToRead; int div; + // multicast: + OrgOpenslxPvsInterface* _ifaceDBus; + QString _filename; + qulonglong _transferID; }; #endif /* CLIENTFILERECEIVEDIALOG_H_ */ diff --git a/src/gui/ui/clientFileReceiveDialog.ui b/src/gui/ui/clientFileReceiveDialog.ui index af3a135..a137def 100644 --- a/src/gui/ui/clientFileReceiveDialog.ui +++ b/src/gui/ui/clientFileReceiveDialog.ui @@ -6,8 +6,8 @@ 0 0 - 208 - 108 + 528 + 117 @@ -61,6 +61,13 @@ + + + + + + + diff --git a/src/net/pvsIncomingMulticastTransfer.cpp b/src/net/pvsIncomingMulticastTransfer.cpp index 01507a9..10b5307 100644 --- a/src/net/pvsIncomingMulticastTransfer.cpp +++ b/src/net/pvsIncomingMulticastTransfer.cpp @@ -21,7 +21,7 @@ #include "pvsIncomingMulticastTransfer.h" #include -PVSIncomingMulticastTransfer::PVSIncomingMulticastTransfer(QString const& sender, qulonglong transferID, qulonglong size, +PVSIncomingMulticastTransfer::PVSIncomingMulticastTransfer(QString const& sender, qulonglong transferID, qulonglong size, QString const& filename, ushort port, McastConfiguration const* configTemplate, QObject* parent) : QObject(parent), _sender(sender), @@ -29,19 +29,21 @@ PVSIncomingMulticastTransfer::PVSIncomingMulticastTransfer(QString const& sender _bytes(0), _size(size), _port(port), - _temporaryFile(new QTemporaryFile(QFileInfo(QDir::homePath(), "incoming.mcastft.XXXXXX").absolutePath(), this)), - _finalFile(0), + _file(new QFile(filename, this)), _receiver(0), _config(configTemplate ? new McastConfiguration(*configTemplate) : new McastConfiguration()), _progressTimer(new QTimer(this)) { + _file->open(QIODevice::WriteOnly); + _config->multicastUDPPortBase(port); - _config->multicastDPort(port); - _config->multicastSPort(port); + // _config->multicastDPort(port+1); + // _config->multicastSPort(port+2); connect(_progressTimer, SIGNAL(timeout()), SLOT(updateProgress())); + connect(this, SIGNAL(failed(qulonglong, QString const&)), SLOT(removeFile())); } PVSIncomingMulticastTransfer::~PVSIncomingMulticastTransfer() @@ -51,10 +53,10 @@ PVSIncomingMulticastTransfer::~PVSIncomingMulticastTransfer() bool PVSIncomingMulticastTransfer::start() { - QFile *dest = _finalFile ? _finalFile : _temporaryFile; - _receiver = new McastReceiver(dest, new McastConfiguration(*_config), this); + _file->open(QIODevice::WriteOnly); + _receiver = new McastReceiver(_file, new McastConfiguration(*_config), this); connect(_receiver, SIGNAL(finished(int)), SLOT(receiverFinished(int))); - connect(_receiver, SIGNAL(progress(quint64)), SLOT(receiverProgress(quint64))); + connect(_receiver, SIGNAL(progress(quint64)), SLOT(receiverProgressed(quint64))); if (!_receiver->start()) { @@ -76,17 +78,8 @@ void PVSIncomingMulticastTransfer::abort() delete _progressTimer; _progressTimer = 0; - if (_temporaryFile) - { - _temporaryFile->remove(); - } - delete _temporaryFile; - - if (_finalFile) - { - _finalFile->remove(); - } - delete _finalFile; + if(_file) + delete _file; } void PVSIncomingMulticastTransfer::updatePort(ushort port) @@ -124,6 +117,12 @@ void PVSIncomingMulticastTransfer::receiverFinished(int how) } } +void PVSIncomingMulticastTransfer::removeFile() +{ + if(_file) + _file->remove(); +} + void PVSIncomingMulticastTransfer::updateProgress() { if (!_started) diff --git a/src/net/pvsIncomingMulticastTransfer.h b/src/net/pvsIncomingMulticastTransfer.h index 9a33348..f96e176 100644 --- a/src/net/pvsIncomingMulticastTransfer.h +++ b/src/net/pvsIncomingMulticastTransfer.h @@ -31,7 +31,7 @@ class PVSIncomingMulticastTransfer : public QObject { Q_OBJECT public: - PVSIncomingMulticastTransfer(QString const& sender, qulonglong transferID, qulonglong size, ushort port, + PVSIncomingMulticastTransfer(QString const& sender, qulonglong transferID, qulonglong size, QString const& filename, ushort port, McastConfiguration const* configTemplate, QObject* parent = 0); virtual ~PVSIncomingMulticastTransfer(); @@ -53,6 +53,7 @@ private slots: void receiverProgressed(quint64 bytes); void receiverFinished(int reason); void updateProgress(); + void removeFile(); private: QString _sender; @@ -60,8 +61,7 @@ private: qulonglong _bytes; qulonglong _size; ushort _port; - QFile* _temporaryFile; - QFile* _finalFile; + QFile* _file; McastReceiver* _receiver; McastConfiguration* _config; bool _started; diff --git a/src/pvs.cpp b/src/pvs.cpp index 0e5aaf5..852c9f4 100644 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -716,9 +716,23 @@ void PVS::cancelOutgoingMulticastTransfer(quint64 transferID) } } +void PVS::cancelIncomingMulticastTransfer(qulonglong transferID) +{ + PVSIncomingMulticastTransfer* transfer = _incomingTransfers.value(transferID, 0); + + if(transfer) + { + _incomingTransfers.remove(transferID); + delete transfer; + } +} + void PVS::onIncomingMulticastTransfer(QString const& sender, qulonglong transferID, QString const& basename, qulonglong size, ushort port) { + if (_outgoingTransfers.contains(transferID)) + return; + PVSIncomingMulticastTransfer* transfer; if (_incomingTransfers.value(transferID, 0)) { @@ -727,7 +741,8 @@ void PVS::onIncomingMulticastTransfer(QString const& sender, qulonglong transfer } else { - transfer = new PVSIncomingMulticastTransfer(sender, transferID, size, port, _masterMcastConfig, this); + QString filename = QFileInfo(QDir::home(), QString("%1.part.%2").arg(basename).arg(transferID, 0, 16)).absoluteFilePath(); + transfer = new PVSIncomingMulticastTransfer(sender, transferID, size, filename, port, _masterMcastConfig, this); _incomingTransfers.insert(transferID, transfer); connect(transfer, SIGNAL(retry(QString const&, qulonglong)), SLOT(onIncomingMulticastTransferRetry(QString const&, qulonglong))); @@ -738,7 +753,7 @@ void PVS::onIncomingMulticastTransfer(QString const& sender, qulonglong transfer connect(transfer, SIGNAL(finished(qulonglong)), SLOT(incomingMulticastTransferDelete(qulonglong))); connect(transfer, SIGNAL(failed(qulonglong, QString const&)), SLOT(incomingMulticastTransferDelete(qulonglong))); - emit incomingMulticastTransferNew(transferID, sender, basename, size); + emit incomingMulticastTransferNew(transferID, sender, filename, size); QTimer::singleShot(0, transfer, SLOT(start())); } } diff --git a/src/pvs.h b/src/pvs.h index dc272f0..ef6454e 100644 --- a/src/pvs.h +++ b/src/pvs.h @@ -86,6 +86,7 @@ public Q_SLOTS: // Multicast File Transfer bool createMulticastTransfer(QString const& objectPath, quint64& transferID, QString& errorReason); void cancelOutgoingMulticastTransfer(quint64 transferID); + void cancelIncomingMulticastTransfer(qulonglong transferID); Q_SIGNALS: @@ -106,7 +107,7 @@ Q_SIGNALS: void outgoingMulticastTransferProgress(qulonglong transferID, qulonglong bytes, qulonglong of); void outgoingMulticastTransferFinished(qulonglong transferID); void outgoingMulticastTransferFailed(qulonglong transferID, QString reason); - void incomingMulticastTransferNew(qulonglong transferID, QString sender, QString basename, qulonglong size); + void incomingMulticastTransferNew(qulonglong transferID, QString sender, QString filename, qulonglong size); void incomingMulticastTransferStarted(qulonglong transferID); void incomingMulticastTransferProgress(qulonglong transferID, qulonglong bytes, qulonglong of); void incomingMulticastTransferFinished(qulonglong transferID); @@ -166,12 +167,12 @@ private: QHash _incomingTransfers; void onIncomingMulticastTransfer(QString const& sender, qulonglong transferID, QString const& basename, qulonglong size, ushort port); - void onIncomingMulticastTransferRetry(QString const& sender, qulonglong transferID); static quint64 generateMcastTransferID(); private Q_SLOTS: // housekeeping void outgoingMulticastTransferDelete(qulonglong transferID); void incomingMulticastTransferDelete(qulonglong transferID); + void onIncomingMulticastTransferRetry(QString const& sender, qulonglong transferID); }; #endif /* PVSCLIENT_H_ */ diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp index 25f1cd6..e949d5b 100644 --- a/src/pvsgui.cpp +++ b/src/pvsgui.cpp @@ -119,6 +119,7 @@ PVSGUI::PVSGUI(QWidget *parent) : connect(_ifaceDBus, SIGNAL(disconnected()), this, SLOT(disconnected())); connect(_ifaceDBus, SIGNAL(addHost(QString)), this, SLOT(addHost(QString))); connect(_ifaceDBus, SIGNAL(delHost(QString)), this, SLOT(delHost(QString))); + connect(_ifaceDBus, SIGNAL(incomingMulticastTransferNew(qulonglong, QString, QString, qulonglong)), SLOT(incomingMulticastFile(qulonglong, QString, QString, qulonglong))); // show toolbar setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); @@ -421,6 +422,12 @@ void PVSGUI::receiveFile() d->open(); } +void PVSGUI::incomingMulticastFile(qulonglong transferID, QString sender, QString basename, qulonglong size) +{ + ClientFileReceiveDialog *d = new ClientFileReceiveDialog(sender, transferID, basename, size, _ifaceDBus, this); + d->open(); +} + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// diff --git a/src/pvsgui.h b/src/pvsgui.h index f9a0ab8..2883b60 100644 --- a/src/pvsgui.h +++ b/src/pvsgui.h @@ -65,6 +65,7 @@ private Q_SLOTS: void setVncAllow(int i); void sendFile(); void receiveFile(); + void incomingMulticastFile(qulonglong, QString sender, QString basename, qulonglong size); private: void setupMenu(); -- cgit v1.2.3-55-g7522 From f8e6e94b25a092d51acdec600465074b4eb32cb8 Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Wed, 4 Aug 2010 17:28:45 +0200 Subject: Make PGM interface configurable --- src/gui/clientConfigDialog.cpp | 61 +++++++++++++++++++++++++++++++++++++- src/gui/clientConfigDialog.h | 2 ++ src/gui/ui/clientConfigDialog.ui | 64 ++++++++++++++++++++++++++++++++++++++-- src/pvs.cpp | 7 +++++ src/pvs.h | 2 +- src/pvsgui.cpp | 3 ++ 6 files changed, 134 insertions(+), 5 deletions(-) (limited to 'src/pvsgui.cpp') diff --git a/src/gui/clientConfigDialog.cpp b/src/gui/clientConfigDialog.cpp index 76b4f5e..3867118 100644 --- a/src/gui/clientConfigDialog.cpp +++ b/src/gui/clientConfigDialog.cpp @@ -16,15 +16,32 @@ # ----------------------------------------------------------------------------- */ +#include #include "clientConfigDialog.h" +#include +#include +#include + +// For getting the network interface list: +#ifdef __linux +# include +# include +#endif + +using namespace std; ClientConfigDialog::ClientConfigDialog(QWidget *parent) : - QDialog(parent) + QDialog(parent), + _interfaceListModel(0) { setupUi(this); connect(this, SIGNAL(accepted()), this, SLOT(writeSettings())); connect(radioButtonOtherRO, SIGNAL(clicked()), this, SLOT(checkPermissions())); + connect(reloadInterfaceListButton, SIGNAL(clicked()), this, SLOT(reloadNetworkInterfaceList())); + reloadNetworkInterfaceList(); + interfaceList->setModel(_interfaceListModel); + interfaceList->setModelColumn(0); } @@ -66,6 +83,9 @@ void ClientConfigDialog::readSettings() checkBoxAllowFiletransfer->setChecked(_settings.value( "Permissions/allow_filetransfer").toBool()); + if(!_settings.value("Muticast/interface").isNull()) + interfaceList->setEditText(_settings.value("Multicast/interface").toString()); + qDebug("[%s] Setting read from: '%s'", metaObject()->className(), qPrintable(_settings.fileName())); } @@ -88,6 +108,7 @@ void ClientConfigDialog::writeSettings() _settings.setValue("Permissions/allow_chat", checkBoxAllowChat->isChecked()); _settings.setValue("Permissions/allow_filetransfer", checkBoxAllowFiletransfer->isChecked()); + _settings.setValue("Multicast/interface", interfaceList->currentText()); _settings.sync(); emit configChanged(); @@ -103,3 +124,41 @@ void ClientConfigDialog::checkPermissions() if (radioButtonLecturerNO->isChecked() && radioButtonOtherRO->isChecked()) radioButtonLecturerRO->setChecked(true); } + +void ClientConfigDialog::reloadNetworkInterfaceList() +{ +#ifdef __linux + static struct ifreq ifreqs[20]; + ifconf ifconfigs; + memset(&ifconfigs, 0, sizeof(ifconfigs)); + ifconfigs.ifc_len = sizeof(ifreqs); + ifconfigs.ifc_buf = (char*)&ifreqs; + + int nosock = socket(AF_INET, SOCK_STREAM, 0); + if (nosock < 0) + { + qWarning() << "Could not get a socket descriptor:" << strerror(errno); + } + int retval; + if ((retval = ioctl(nosock, SIOCGIFCONF, (char*)(&ifconfigs))) < 0) + { + qWarning() << "Could not get the list of interfaces:" << strerror(errno); + return; + } + + QStringList interfaces; + for(int i = 0; i < ifconfigs.ifc_len/sizeof(struct ifreq); i++) + { + char ifname[IFNAMSIZ + 1]; + strncpy(ifname, ifreqs[i].ifr_name, IFNAMSIZ); + ifname[IFNAMSIZ] = '\0'; + interfaces << QString::fromLocal8Bit(ifname); + } + if(!_interfaceListModel) + _interfaceListModel = new QStringListModel(interfaces, this); + else + _interfaceListModel->setStringList(interfaces); +#else +# warning "We have no way to get your system's network interface list. Some porting may be required." +#endif +} diff --git a/src/gui/clientConfigDialog.h b/src/gui/clientConfigDialog.h index 706bd8a..803f2c8 100644 --- a/src/gui/clientConfigDialog.h +++ b/src/gui/clientConfigDialog.h @@ -35,9 +35,11 @@ Q_SIGNALS: private Q_SLOTS: void checkPermissions(); + void reloadNetworkInterfaceList(); private: QSettings _settings; + QStringListModel* _interfaceListModel; }; diff --git a/src/gui/ui/clientConfigDialog.ui b/src/gui/ui/clientConfigDialog.ui index 3262b6b..bb4bdc9 100644 --- a/src/gui/ui/clientConfigDialog.ui +++ b/src/gui/ui/clientConfigDialog.ui @@ -6,8 +6,8 @@ 0 0 - 438 - 257 + 445 + 266 @@ -27,7 +27,7 @@ QTabWidget::North - 0 + 2 @@ -197,6 +197,64 @@ + + + + 0 + 0 + + + + false + + + Network + + + + + + + 0 + 0 + + + + true + + + QComboBox::NoInsert + + + true + + + + + + + + 0 + 0 + + + + Network Interface + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Reload List + + + + + diff --git a/src/pvs.cpp b/src/pvs.cpp index 202aa32..c217d52 100644 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -728,6 +728,13 @@ void PVS::cancelIncomingMulticastTransfer(qulonglong transferID) } } +void PVS::setMulticastInterface(QString const& interfaceName) +{ + QSettings settings; + settings.setValue("multicast/interface", interfaceName); + settings.sync(); +} + void PVS::onIncomingMulticastTransfer(QString const& sender, qulonglong transferID, QString const& basename, qulonglong size, ushort port) { diff --git a/src/pvs.h b/src/pvs.h index ef6454e..4c61ffd 100644 --- a/src/pvs.h +++ b/src/pvs.h @@ -87,7 +87,7 @@ public Q_SLOTS: bool createMulticastTransfer(QString const& objectPath, quint64& transferID, QString& errorReason); void cancelOutgoingMulticastTransfer(quint64 transferID); void cancelIncomingMulticastTransfer(qulonglong transferID); - + void setMulticastInterface(QString const& interfaceName); Q_SIGNALS: void project(QString host, int port, QString passwd, bool fullscreen, diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp index e949d5b..40112b4 100644 --- a/src/pvsgui.cpp +++ b/src/pvsgui.cpp @@ -143,6 +143,9 @@ void PVSGUI::updateConfig() setLocation(POSITION_TOP_CENTER); else setLocation(_settings.value("Display/location").toInt()); + + if (!_settings.value("Multicast/interface").isNull()) + _ifaceDBus->setMulticastInterface(_settings.value("Multicast/interface").toString()); } //////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3-55-g7522 From ca61d21c6defb9553234c1fa5b0979c46542c676 Mon Sep 17 00:00:00 2001 From: Johann Latocha Date: Sat, 28 Aug 2010 03:17:08 +0200 Subject: Enhancement #587 --- CMakeLists.txt | 2 +- i18n/pvs_ar_JO.ts | 139 ++++++++++++++++++++++++++++++++++++-- i18n/pvs_de_DE.ts | 141 +++++++++++++++++++++++++++++++++++++-- i18n/pvs_es_MX.ts | 139 ++++++++++++++++++++++++++++++++++++-- i18n/pvs_fr_FR.ts | 139 ++++++++++++++++++++++++++++++++++++-- i18n/pvs_pl_PL.ts | 139 ++++++++++++++++++++++++++++++++++++-- i18n/pvsgui_ar_JO.ts | 66 +++++++++--------- i18n/pvsgui_de_DE.ts | 66 +++++++++--------- i18n/pvsgui_es_MX.ts | 66 +++++++++--------- i18n/pvsgui_fr_FR.ts | 66 +++++++++--------- i18n/pvsgui_pl_PL.ts | 66 +++++++++--------- org.openslx.pvs.service | 2 +- src/gui/clientChatDialog.cpp | 2 - src/gui/clientConfigDialog.cpp | 2 - src/gui/clientFileSendDialog.cpp | 2 - src/gui/clientVNCViewer.cpp | 2 - src/pvs.cpp | 9 ++- src/pvs.h | 2 +- src/pvsDaemon.cpp | 132 ++++++++++++++++-------------------- src/pvsgui.cpp | 34 ++++++---- src/pvsgui.h | 1 - src/version.h | 4 +- 22 files changed, 931 insertions(+), 290 deletions(-) (limited to 'src/pvsgui.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ac01c9..e364528 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,7 +381,7 @@ SET( CPACK_SET_DESTDIR "ON" ) SET( CPACK_PACKAGE_NAME "pvs" ) SET( CPACK_PACKAGE_VERSION_MAJOR "2" ) SET( CPACK_PACKAGE_VERSION_MINOR "0" ) -SET( CPACK_PACKAGE_VERSION_PATCH "1" ) +SET( CPACK_PACKAGE_VERSION_PATCH "3" ) SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Pool Video Switch" ) SET( CPACK_PACKAGE_DESCRIPTION "") SET( CPACK_PACKAGE_CONTACT "Simon Wittenberg " ) diff --git a/i18n/pvs_ar_JO.ts b/i18n/pvs_ar_JO.ts index 38bf578..a57e4bd 100644 --- a/i18n/pvs_ar_JO.ts +++ b/i18n/pvs_ar_JO.ts @@ -4,24 +4,155 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! + + QObject + + + Version: + + + + + Usage: + + + + + <<option> <value>, ... > + + + + + Options: + + + + + -vncScriptFile <fullpath\filename> + + + + + Specifies a custom location for the vnc-start/stop-script. + + + + + If not specified, /usr/bin/pvs-vncsrv is expected. + + + + + -freq <seconds> + + + + + Specifies how long to wait until a reconnection attempt is made. + + + + + Default is 5. + + + + + -port <port> + + + + + Specifies on which port to run. + + + + + Default is + + + + + -h or --help + + + + + Shows this help text and exits. + + + + + -v or --version + + + + + Shows the current version and exits. + + + + + -d or --daemon + + + + + Start as daemon. + + + + + -c <string command>:<string value> + + + + + Sends the command and the optional value to a running PVS-Client. + + + + + Command and value may not contain spaces or colons. + + + + + The dividing colon is mandatory. + + + + + Prints out available commands to use with -c. + + + + + Use -h or --help to get a listing of all options. +-v or --version gives you the current version. + + + + + diff --git a/i18n/pvs_de_DE.ts b/i18n/pvs_de_DE.ts index 38bf578..a58199c 100644 --- a/i18n/pvs_de_DE.ts +++ b/i18n/pvs_de_DE.ts @@ -1,27 +1,158 @@ - + PVS - + Message - + VNC connection - + The host - + requested your screen! + + QObject + + + Version: + + + + + Usage: + + + + + <<option> <value>, ... > + + + + + Options: + + + + + -vncScriptFile <fullpath\filename> + + + + + Specifies a custom location for the vnc-start/stop-script. + + + + + If not specified, /usr/bin/pvs-vncsrv is expected. + + + + + -freq <seconds> + + + + + Specifies how long to wait until a reconnection attempt is made. + + + + + Default is 5. + + + + + -port <port> + + + + + Specifies on which port to run. + + + + + Default is + + + + + -h or --help + + + + + Shows this help text and exits. + + + + + -v or --version + + + + + Shows the current version and exits. + + + + + -d or --daemon + + + + + Start as daemon. + + + + + -c <string command>:<string value> + + + + + Sends the command and the optional value to a running PVS-Client. + + + + + Command and value may not contain spaces or colons. + + + + + The dividing colon is mandatory. + + + + + Prints out available commands to use with -c. + + + + + Use -h or --help to get a listing of all options. +-v or --version gives you the current version. + + + + + diff --git a/i18n/pvs_es_MX.ts b/i18n/pvs_es_MX.ts index 38bf578..a57e4bd 100644 --- a/i18n/pvs_es_MX.ts +++ b/i18n/pvs_es_MX.ts @@ -4,24 +4,155 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! + + QObject + + + Version: + + + + + Usage: + + + + + <<option> <value>, ... > + + + + + Options: + + + + + -vncScriptFile <fullpath\filename> + + + + + Specifies a custom location for the vnc-start/stop-script. + + + + + If not specified, /usr/bin/pvs-vncsrv is expected. + + + + + -freq <seconds> + + + + + Specifies how long to wait until a reconnection attempt is made. + + + + + Default is 5. + + + + + -port <port> + + + + + Specifies on which port to run. + + + + + Default is + + + + + -h or --help + + + + + Shows this help text and exits. + + + + + -v or --version + + + + + Shows the current version and exits. + + + + + -d or --daemon + + + + + Start as daemon. + + + + + -c <string command>:<string value> + + + + + Sends the command and the optional value to a running PVS-Client. + + + + + Command and value may not contain spaces or colons. + + + + + The dividing colon is mandatory. + + + + + Prints out available commands to use with -c. + + + + + Use -h or --help to get a listing of all options. +-v or --version gives you the current version. + + + + + diff --git a/i18n/pvs_fr_FR.ts b/i18n/pvs_fr_FR.ts index 38bf578..a57e4bd 100644 --- a/i18n/pvs_fr_FR.ts +++ b/i18n/pvs_fr_FR.ts @@ -4,24 +4,155 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! + + QObject + + + Version: + + + + + Usage: + + + + + <<option> <value>, ... > + + + + + Options: + + + + + -vncScriptFile <fullpath\filename> + + + + + Specifies a custom location for the vnc-start/stop-script. + + + + + If not specified, /usr/bin/pvs-vncsrv is expected. + + + + + -freq <seconds> + + + + + Specifies how long to wait until a reconnection attempt is made. + + + + + Default is 5. + + + + + -port <port> + + + + + Specifies on which port to run. + + + + + Default is + + + + + -h or --help + + + + + Shows this help text and exits. + + + + + -v or --version + + + + + Shows the current version and exits. + + + + + -d or --daemon + + + + + Start as daemon. + + + + + -c <string command>:<string value> + + + + + Sends the command and the optional value to a running PVS-Client. + + + + + Command and value may not contain spaces or colons. + + + + + The dividing colon is mandatory. + + + + + Prints out available commands to use with -c. + + + + + Use -h or --help to get a listing of all options. +-v or --version gives you the current version. + + + + + diff --git a/i18n/pvs_pl_PL.ts b/i18n/pvs_pl_PL.ts index 38bf578..a57e4bd 100644 --- a/i18n/pvs_pl_PL.ts +++ b/i18n/pvs_pl_PL.ts @@ -4,24 +4,155 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! + + QObject + + + Version: + + + + + Usage: + + + + + <<option> <value>, ... > + + + + + Options: + + + + + -vncScriptFile <fullpath\filename> + + + + + Specifies a custom location for the vnc-start/stop-script. + + + + + If not specified, /usr/bin/pvs-vncsrv is expected. + + + + + -freq <seconds> + + + + + Specifies how long to wait until a reconnection attempt is made. + + + + + Default is 5. + + + + + -port <port> + + + + + Specifies on which port to run. + + + + + Default is + + + + + -h or --help + + + + + Shows this help text and exits. + + + + + -v or --version + + + + + Shows the current version and exits. + + + + + -d or --daemon + + + + + Start as daemon. + + + + + -c <string command>:<string value> + + + + + Sends the command and the optional value to a running PVS-Client. + + + + + Command and value may not contain spaces or colons. + + + + + The dividing colon is mandatory. + + + + + Prints out available commands to use with -c. + + + + + Use -h or --help to get a listing of all options. +-v or --version gives you the current version. + + + + + diff --git a/i18n/pvsgui_ar_JO.ts b/i18n/pvsgui_ar_JO.ts index 04d9717..83560ba 100644 --- a/i18n/pvsgui_ar_JO.ts +++ b/i18n/pvsgui_ar_JO.ts @@ -40,47 +40,47 @@ ClientChatDialog - + &Send File... - + has joined the chat. - + has left the chat. - + PVS File Transfer - + Send file ' - + ' to - + Connected. - + Disconnected. - + Message from < @@ -260,23 +260,23 @@ ClientFileSendDialog - + Open File - - + + PVS - File Transfer - + File Transfer complete. - + File Transfer canceled! @@ -399,77 +399,77 @@ p, li { white-space: pre-wrap; } - + &Disconnect - + C&hat - + &Send File - + &Config - + &Information - + &About - + &Quit - - - + + + PVS Connection - + Please enter password (If not needed leave blank): - + Are you sure you want to disconnect? - - + + PVS connection - - + + Connected to - - + + Disconnected - + New host available: diff --git a/i18n/pvsgui_de_DE.ts b/i18n/pvsgui_de_DE.ts index 544ebff..d49306a 100644 --- a/i18n/pvsgui_de_DE.ts +++ b/i18n/pvsgui_de_DE.ts @@ -40,47 +40,47 @@ ClientChatDialog - + &Send File... Datei &Senden... - + has joined the chat. ist dem Chat beigetreten. - + has left the chat. hat den Chat verlassen. - + PVS File Transfer PVS Dateiübertragung - + Send file ' Datei senden ' - + ' to ' an - + Connected. Verbunden. - + Disconnected. Getrennt. - + Message from < Nachricht von < @@ -260,23 +260,23 @@ ClientFileSendDialog - + Open File Datei Öffnen - - + + PVS - File Transfer PBS -Dateiübertragung - + File Transfer complete. Dateiübertragung beendet. - + File Transfer canceled! Dateiübertragung abgebrochen! @@ -407,77 +407,77 @@ p, li { white-space: pre-wrap; } Verbinden - + &Disconnect &Trennen - + C&hat - + &Send File Datei &Senden - + &Config &Konfiguration - + &Information &Information - + &About &Über - + &Quit &Beenden - - - + + + PVS Connection PVS Verbindung - + Please enter password (If not needed leave blank): Bitte geben sie ein Passwor ein (Falls nicht erforderlich einfach leer lassen): - + Are you sure you want to disconnect? Sind sie sicher dass sie die Verbindung trennen möchten? - - + + PVS connection PVS Verbindung - - + + Connected to Verbunden mit - - + + Disconnected Getrennt - + New host available: Neuer Host verfügbar: diff --git a/i18n/pvsgui_es_MX.ts b/i18n/pvsgui_es_MX.ts index 855ee9b..92db9d7 100644 --- a/i18n/pvsgui_es_MX.ts +++ b/i18n/pvsgui_es_MX.ts @@ -40,47 +40,47 @@ ClientChatDialog - + &Send File... Enviar archivo... - + has joined the chat. ha ingresado al chat. - + has left the chat. ha abandonado el chat - + PVS File Transfer PVS Transferencia de datos - + Send file ' Enviar archivo ' - + ' to ' a - + Connected. Conectado. - + Disconnected. Desconectado. - + Message from < Mensaje de < @@ -260,23 +260,23 @@ ClientFileSendDialog - + Open File Abrir archivo - - + + PVS - File Transfer PVS - Transferencia de datos - + File Transfer complete. La transferencia de datos ha sido completada. - + File Transfer canceled! La transferencia de datos ha sido cancelada! @@ -419,77 +419,77 @@ p, li { white-space: pre-wrap; } Conectar - + &Disconnect &Desconectar - + C&hat ??? - + &Send File &Enviar archivo - + &Config &Configuración - + &Information &Información - + &About &Acerca de - + &Quit &Cerrar - - - + + + PVS Connection PVS Connección - + Please enter password (If not needed leave blank): Porfavor ingrese una contraseña (Deje la seccion vacia si no lo necesita): - + Are you sure you want to disconnect? Realmente desea desconectarse? - - + + PVS connection PVS Connección - - + + Connected to Connectar a - - + + Disconnected Desconectado - + New host available: Nuevo Host disponible: diff --git a/i18n/pvsgui_fr_FR.ts b/i18n/pvsgui_fr_FR.ts index 04d9717..83560ba 100644 --- a/i18n/pvsgui_fr_FR.ts +++ b/i18n/pvsgui_fr_FR.ts @@ -40,47 +40,47 @@ ClientChatDialog - + &Send File... - + has joined the chat. - + has left the chat. - + PVS File Transfer - + Send file ' - + ' to - + Connected. - + Disconnected. - + Message from < @@ -260,23 +260,23 @@ ClientFileSendDialog - + Open File - - + + PVS - File Transfer - + File Transfer complete. - + File Transfer canceled! @@ -399,77 +399,77 @@ p, li { white-space: pre-wrap; } - + &Disconnect - + C&hat - + &Send File - + &Config - + &Information - + &About - + &Quit - - - + + + PVS Connection - + Please enter password (If not needed leave blank): - + Are you sure you want to disconnect? - - + + PVS connection - - + + Connected to - - + + Disconnected - + New host available: diff --git a/i18n/pvsgui_pl_PL.ts b/i18n/pvsgui_pl_PL.ts index 04d9717..83560ba 100644 --- a/i18n/pvsgui_pl_PL.ts +++ b/i18n/pvsgui_pl_PL.ts @@ -40,47 +40,47 @@ ClientChatDialog - + &Send File... - + has joined the chat. - + has left the chat. - + PVS File Transfer - + Send file ' - + ' to - + Connected. - + Disconnected. - + Message from < @@ -260,23 +260,23 @@ ClientFileSendDialog - + Open File - - + + PVS - File Transfer - + File Transfer complete. - + File Transfer canceled! @@ -399,77 +399,77 @@ p, li { white-space: pre-wrap; } - + &Disconnect - + C&hat - + &Send File - + &Config - + &Information - + &About - + &Quit - - - + + + PVS Connection - + Please enter password (If not needed leave blank): - + Are you sure you want to disconnect? - - + + PVS connection - - + + Connected to - - + + Disconnected - + New host available: diff --git a/org.openslx.pvs.service b/org.openslx.pvs.service index 0398081..91a3e67 100644 --- a/org.openslx.pvs.service +++ b/org.openslx.pvs.service @@ -1,4 +1,4 @@ [D-BUS Service] Name=org.openslx.pvs -Exec=@CMAKE_INSTALL_PREFIX@/bin/pvs +Exec=@CMAKE_INSTALL_PREFIX@/bin/pvs -d diff --git a/src/gui/clientChatDialog.cpp b/src/gui/clientChatDialog.cpp index 7c32790..163ac92 100644 --- a/src/gui/clientChatDialog.cpp +++ b/src/gui/clientChatDialog.cpp @@ -29,8 +29,6 @@ ClientChatDialog::ClientChatDialog(QWidget *parent) : // connect to D-Bus and get interface QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/chat", this); - dbus.registerService("org.openslx.pvsgui"); _ifaceDBus = new OrgOpenslxPvsInterface("org.openslx.pvs", "/", dbus, this); connect(_ifaceDBus, SIGNAL(chat_receive(QString, QString, QString)), this, SLOT(receive(QString, QString, QString))); diff --git a/src/gui/clientConfigDialog.cpp b/src/gui/clientConfigDialog.cpp index 3e1ee50..0ee5908 100644 --- a/src/gui/clientConfigDialog.cpp +++ b/src/gui/clientConfigDialog.cpp @@ -28,8 +28,6 @@ ClientConfigDialog::ClientConfigDialog(QWidget *parent) : // 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); } diff --git a/src/gui/clientFileSendDialog.cpp b/src/gui/clientFileSendDialog.cpp index ccb44b3..b4512c0 100644 --- a/src/gui/clientFileSendDialog.cpp +++ b/src/gui/clientFileSendDialog.cpp @@ -28,8 +28,6 @@ ClientFileSendDialog::ClientFileSendDialog(QWidget *parent) : // connect to D-Bus and get interface QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/filesend", this); - dbus.registerService("org.openslx.pvsgui"); _ifaceDBus = new OrgOpenslxPvsInterface("org.openslx.pvs", "/", dbus, this); // get current users name from backend diff --git a/src/gui/clientVNCViewer.cpp b/src/gui/clientVNCViewer.cpp index d6a218b..d794b0b 100644 --- a/src/gui/clientVNCViewer.cpp +++ b/src/gui/clientVNCViewer.cpp @@ -22,8 +22,6 @@ ClientVNCViewer::ClientVNCViewer(QWidget *parent) : { // connect to D-Bus and get interface QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/vnc", this); - dbus.registerService("org.openslx.pvsgui"); _ifaceDBus = new OrgOpenslxPvsInterface("org.openslx.pvs", "/", dbus, this); connect(_ifaceDBus, SIGNAL(project(QString, int, QString, bool, bool, int)), this, SLOT(open(QString, int, QString, bool, bool, int))); diff --git a/src/pvs.cpp b/src/pvs.cpp index 1c08be5..21b7bdf 100755 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -53,8 +53,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); @@ -552,9 +554,10 @@ int PVS::stopVNCScript() } } -void PVS::start() +bool PVS::start() { _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROJECTING", "YES")); + return true; } void PVS::onConnected(QString name) diff --git a/src/pvs.h b/src/pvs.h index b6b5e65..1bb0747 100755 --- a/src/pvs.h +++ b/src/pvs.h @@ -69,7 +69,7 @@ public: void guiDelHost(QString host); public Q_SLOTS: - void start(); + bool start(); void quit(); void chat_send(QString nick_to, QString nick_from, QString msg); QString chat_getNickname(); diff --git a/src/pvsDaemon.cpp b/src/pvsDaemon.cpp index e9479df..b23bc57 100755 --- a/src/pvsDaemon.cpp +++ b/src/pvsDaemon.cpp @@ -9,14 +9,12 @@ #include "src/core/pvsChatClient.h" PVS *mainClient = NULL; - -// This define works as a switch whether to run as deamon or regular app -#define as_daemon +QTextStream qout(stdout); /// VERSION_STRING is defined in src/version.h void printVersion(bool doExit) { - + QTextStream qout(stdout); printf("Version:\t"VERSION_STRING"\n"); if (doExit) exit(0); @@ -25,30 +23,31 @@ void printVersion(bool doExit) /// outputs the full help text void printHelp() { - printf("**************************************************************\n"); - printf("\nPool Video Switch Client\n"); - printf("**************************************************************\n"); - printVersion(false); - printf("**************************************************************\n"); - printf("Usage:\tpoolVSClient <