Make coding style more consistent
authorChristian Pulvermacher <pulvermacher@gmx.de>
Tue, 1 May 2012 11:28:23 +0000 (13:28 +0200)
committerChristian Pulvermacher <pulvermacher@gmx.de>
Tue, 1 May 2012 11:28:23 +0000 (13:28 +0200)
src/connectdialog.h
src/vncclientthread.cpp
src/vncclientthread.h
src/vncview.cpp
src/vncview.h

index b5b35fc..6242875 100644 (file)
 
 #include <QtGui>
 
 
 #include <QtGui>
 
-class QMaemo5ListPickSelector;
-
 class ConnectDialog : public QDialog
 {
     Q_OBJECT
 public:
 class ConnectDialog : public QDialog
 {
     Q_OBJECT
 public:
-    ConnectDialog(QWidget *parent);
+    explicit ConnectDialog(QWidget *parent);
 public slots:
     virtual void accept();
 signals:
 public slots:
     virtual void accept();
 signals:
index d35f71d..9f80c6f 100644 (file)
@@ -38,7 +38,7 @@ const int MAX_COLOR_DEPTH = 32;
 
 rfbBool VncClientThread::newclient(rfbClient *cl)
 {
 
 rfbBool VncClientThread::newclient(rfbClient *cl)
 {
-    VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
+    VncClientThread *t = static_cast<VncClientThread*>(rfbClientGetClientData(cl, 0));
     Q_ASSERT(t);
 
     switch (t->quality()) {
     Q_ASSERT(t);
 
     switch (t->quality()) {
@@ -83,11 +83,10 @@ rfbBool VncClientThread::newclient(rfbClient *cl)
         cl->format.blueMax = 0xff;
     }
 
         cl->format.blueMax = 0xff;
     }
 
-    if (t->frameBuffer)
-        delete [] t->frameBuffer; // do not leak if we get a new framebuffer size
+    delete [] t->m_frameBuffer; // do not leak if we get a new framebuffer size
     const int size = cl->width * cl->height * (cl->format.bitsPerPixel / 8);
     const int size = cl->width * cl->height * (cl->format.bitsPerPixel / 8);
-    t->frameBuffer = new uint8_t[size];
-    cl->frameBuffer = t->frameBuffer;
+    t->m_frameBuffer = new uint8_t[size];
+    cl->frameBuffer = t->m_frameBuffer;
     memset(cl->frameBuffer, '\0', size);
 
 
     memset(cl->frameBuffer, '\0', size);
 
 
@@ -111,7 +110,7 @@ void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h)
         kDebug(5011) << "image not loaded";
     }
 
         kDebug(5011) << "image not loaded";
     }
 
-    VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
+    VncClientThread *t = static_cast<VncClientThread*>(rfbClientGetClientData(cl, 0));
     Q_ASSERT(t);
 
     t->setImage(img);
     Q_ASSERT(t);
 
     t->setImage(img);
@@ -125,7 +124,7 @@ void VncClientThread::cuttext(rfbClient* cl, const char *text, int textlen)
     kDebug(5011) << "cuttext: " << cutText;
 
     if (!cutText.isEmpty()) {
     kDebug(5011) << "cuttext: " << cutText;
 
     if (!cutText.isEmpty()) {
-        VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
+        VncClientThread *t = static_cast<VncClientThread*>(rfbClientGetClientData(cl, 0));
         Q_ASSERT(t);
 
         t->emitGotCut(cutText);
         Q_ASSERT(t);
 
         t->emitGotCut(cutText);
@@ -136,7 +135,7 @@ char *VncClientThread::passwdHandler(rfbClient *cl)
 {
     kDebug(5011) << "password request" << kBacktrace();
 
 {
     kDebug(5011) << "password request" << kBacktrace();
 
-    VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0);
+    VncClientThread *t = static_cast<VncClientThread*>(rfbClientGetClientData(cl, 0));
     Q_ASSERT(t);
 
     t->m_passwordError = true;
     Q_ASSERT(t);
 
     t->m_passwordError = true;
@@ -183,9 +182,9 @@ void VncClientThread::outputHandler(const char *format, ...)
 
 VncClientThread::VncClientThread(QObject *parent)
     : QThread(parent)
 
 VncClientThread::VncClientThread(QObject *parent)
     : QThread(parent)
-    , frameBuffer(0)
+    , m_frameBuffer(0)
 {
 {
-    QMutexLocker locker(&mutex);
+    QMutexLocker locker(&m_mutex);
     m_stopped = false;
 
     QTimer *outputErrorMessagesCheckTimer = new QTimer(this);
     m_stopped = false;
 
     QTimer *outputErrorMessagesCheckTimer = new QTimer(this);
@@ -203,8 +202,8 @@ VncClientThread::~VncClientThread()
     if(!quitSuccess)
         kDebug(5011) << "~VncClientThread(): Quit failed";
 
     if(!quitSuccess)
         kDebug(5011) << "~VncClientThread(): Quit failed";
 
-    delete [] frameBuffer;
-    //cl is free()d when event loop exits.
+    delete [] m_frameBuffer;
+    //m_cl is free()d when event loop exits.
 }
 
 void VncClientThread::checkOutputErrorMessage()
 }
 
 void VncClientThread::checkOutputErrorMessage()
@@ -220,13 +219,13 @@ void VncClientThread::checkOutputErrorMessage()
 
 void VncClientThread::setHost(const QString &host)
 {
 
 void VncClientThread::setHost(const QString &host)
 {
-    QMutexLocker locker(&mutex);
+    QMutexLocker locker(&m_mutex);
     m_host = host;
 }
 
 void VncClientThread::setPort(int port)
 {
     m_host = host;
 }
 
 void VncClientThread::setPort(int port)
 {
-    QMutexLocker locker(&mutex);
+    QMutexLocker locker(&m_mutex);
     m_port = port;
 }
 
     m_port = port;
 }
 
@@ -242,13 +241,13 @@ RemoteView::Quality VncClientThread::quality() const
 
 void VncClientThread::setImage(const QImage &img)
 {
 
 void VncClientThread::setImage(const QImage &img)
 {
-    QMutexLocker locker(&mutex);
+    QMutexLocker locker(&m_mutex);
     m_image = img;
 }
 
 const QImage VncClientThread::image(int x, int y, int w, int h)
 {
     m_image = img;
 }
 
 const QImage VncClientThread::image(int x, int y, int w, int h)
 {
-    QMutexLocker locker(&mutex);
+    QMutexLocker locker(&m_mutex);
 
     if (w == 0) // full image requested
         return m_image;
 
     if (w == 0) // full image requested
         return m_image;
@@ -272,16 +271,16 @@ void VncClientThread::stop()
         return;
 
     //also abort listening for connections, should be safe without locking
         return;
 
     //also abort listening for connections, should be safe without locking
-    if(listen_port)
-        cl->listenSpecified = false;
+    if(m_listen_port)
+        m_cl->listenSpecified = false;
 
 
-    QMutexLocker locker(&mutex);
+    QMutexLocker locker(&m_mutex);
     m_stopped = true;
 }
 
 void VncClientThread::run()
 {
     m_stopped = true;
 }
 
 void VncClientThread::run()
 {
-    QMutexLocker locker(&mutex);
+    QMutexLocker locker(&m_mutex);
 
     int passwd_failures = 0;
     while (!m_stopped) { // try to connect as long as the server allows
 
     int passwd_failures = 0;
     while (!m_stopped) { // try to connect as long as the server allows
@@ -290,29 +289,29 @@ void VncClientThread::run()
 
         rfbClientLog = outputHandler;
         rfbClientErr = outputHandler;
 
         rfbClientLog = outputHandler;
         rfbClientErr = outputHandler;
-        cl = rfbGetClient(8, 3, 4); // bitsPerSample, samplesPerPixel, bytesPerPixel
-        cl->MallocFrameBuffer = newclient;
-        cl->canHandleNewFBSize = true;
-        cl->GetPassword = passwdHandler;
-        cl->GotFrameBufferUpdate = updatefb;
-        cl->GotXCutText = cuttext;
-        rfbClientSetClientData(cl, 0, this);
+        m_cl = rfbGetClient(8, 3, 4); // bitsPerSample, samplesPerPixel, bytesPerPixel
+        m_cl->MallocFrameBuffer = newclient;
+        m_cl->canHandleNewFBSize = true;
+        m_cl->GetPassword = passwdHandler;
+        m_cl->GotFrameBufferUpdate = updatefb;
+        m_cl->GotXCutText = cuttext;
+        rfbClientSetClientData(m_cl, 0, this);
 
 
-        cl->serverHost = strdup(m_host.toUtf8().constData());
+        m_cl->serverHost = strdup(m_host.toUtf8().constData());
 
         if (m_port < 0 || !m_port) // port is invalid or empty...
             m_port = 5900; // fallback: try an often used VNC port
 
         if (m_port >= 0 && m_port < 100) // the user most likely used the short form (e.g. :1)
             m_port += 5900;
 
         if (m_port < 0 || !m_port) // port is invalid or empty...
             m_port = 5900; // fallback: try an often used VNC port
 
         if (m_port >= 0 && m_port < 100) // the user most likely used the short form (e.g. :1)
             m_port += 5900;
-        cl->serverPort = m_port;
+        m_cl->serverPort = m_port;
 
 
-        cl->listenSpecified = rfbBool(listen_port > 0);
-        cl->listenPort = listen_port;
+        m_cl->listenSpecified = rfbBool(m_listen_port > 0);
+        m_cl->listenPort = m_listen_port;
 
         kDebug(5011) << "--------------------- trying init ---------------------";
 
 
         kDebug(5011) << "--------------------- trying init ---------------------";
 
-        if (rfbInitClient(cl, 0, 0))
+        if (rfbInitClient(m_cl, 0, 0))
             break;
 
         //init failed...
             break;
 
         //init failed...
@@ -324,26 +323,26 @@ void VncClientThread::run()
 
         //stop connecting
         m_stopped = true;
 
         //stop connecting
         m_stopped = true;
-        return; //no cleanup necessary, cl was free()d by rfbInitClient()
+        return; //no cleanup necessary, m_cl was free()d by rfbInitClient()
     }
 
     locker.unlock();
 
     // Main VNC event loop
     while (!m_stopped) {
     }
 
     locker.unlock();
 
     // Main VNC event loop
     while (!m_stopped) {
-        const int i = WaitForMessage(cl, 500);
+        const int i = WaitForMessage(m_cl, 500);
         if(m_stopped or i < 0)
             break;
 
         if (i)
         if(m_stopped or i < 0)
             break;
 
         if (i)
-            if (!HandleRFBServerMessage(cl))
+            if (!HandleRFBServerMessage(m_cl))
                 break;
 
         locker.relock();
 
         while (!m_eventQueue.isEmpty()) {
             ClientEvent* clientEvent = m_eventQueue.dequeue();
                 break;
 
         locker.relock();
 
         while (!m_eventQueue.isEmpty()) {
             ClientEvent* clientEvent = m_eventQueue.dequeue();
-            clientEvent->fire(cl);
+            clientEvent->fire(m_cl);
             delete clientEvent;
         }
 
             delete clientEvent;
         }
 
@@ -352,7 +351,7 @@ void VncClientThread::run()
 
     // Cleanup allocated resources
     locker.relock();
 
     // Cleanup allocated resources
     locker.relock();
-    rfbClientCleanup(cl);
+    rfbClientCleanup(m_cl);
     m_stopped = true;
 }
 
     m_stopped = true;
 }
 
@@ -377,7 +376,7 @@ void ClientCutEvent::fire(rfbClient* cl)
 
 void VncClientThread::mouseEvent(int x, int y, int buttonMask)
 {
 
 void VncClientThread::mouseEvent(int x, int y, int buttonMask)
 {
-    QMutexLocker lock(&mutex);
+    QMutexLocker lock(&m_mutex);
     if (m_stopped)
         return;
 
     if (m_stopped)
         return;
 
@@ -386,7 +385,7 @@ void VncClientThread::mouseEvent(int x, int y, int buttonMask)
 
 void VncClientThread::keyEvent(int key, bool pressed)
 {
 
 void VncClientThread::keyEvent(int key, bool pressed)
 {
-    QMutexLocker lock(&mutex);
+    QMutexLocker lock(&m_mutex);
     if (m_stopped)
         return;
 
     if (m_stopped)
         return;
 
@@ -395,7 +394,7 @@ void VncClientThread::keyEvent(int key, bool pressed)
 
 void VncClientThread::clientCut(const QString &text)
 {
 
 void VncClientThread::clientCut(const QString &text)
 {
-    QMutexLocker lock(&mutex);
+    QMutexLocker lock(&m_mutex);
     if (m_stopped)
         return;
 
     if (m_stopped)
         return;
 
index e3fc4c2..ad8ef8a 100644 (file)
@@ -106,13 +106,11 @@ public:
     void stop();
     void setHost(const QString &host);
     void setPort(int port);
     void stop();
     void setHost(const QString &host);
     void setPort(int port);
-    void setListenPort(int port) { listen_port = port; }
+    void setListenPort(int port) { m_listen_port = port; }
     void setQuality(RemoteView::Quality quality);
     void setPassword(const QString &password);
     const QString password() const { return m_password; }
     void setQuality(RemoteView::Quality quality);
     void setPassword(const QString &password);
     const QString password() const { return m_password; }
-
     RemoteView::Quality quality() const;
     RemoteView::Quality quality() const;
-    uint8_t *frameBuffer;
 
 signals:
     void imageUpdated(int x, int y, int w, int h);
 
 signals:
     void imageUpdated(int x, int y, int w, int h);
@@ -128,27 +126,29 @@ public slots:
 protected:
     void run();
 
 protected:
     void run();
 
+private slots:
+    void checkOutputErrorMessage();
+
 private:
 private:
+    //callbacks for libvncclient
     static rfbBool newclient(rfbClient *cl);
     static void updatefb(rfbClient *cl, int x, int y, int w, int h);
     static void cuttext(rfbClient *cl, const char *text, int textlen);
     static char* passwdHandler(rfbClient *cl);
     static void outputHandler(const char *format, ...);
 
     static rfbBool newclient(rfbClient *cl);
     static void updatefb(rfbClient *cl, int x, int y, int w, int h);
     static void cuttext(rfbClient *cl, const char *text, int textlen);
     static char* passwdHandler(rfbClient *cl);
     static void outputHandler(const char *format, ...);
 
+    uint8_t *m_frameBuffer;
     QImage m_image;
     QImage m_image;
-    rfbClient *cl;
+    rfbClient *m_cl;
     QString m_host;
     QString m_password;
     QString m_host;
     QString m_password;
-    int m_port, listen_port;
-    QMutex mutex;
+    int m_port, m_listen_port;
+    QMutex m_mutex;
     RemoteView::Quality m_quality;
     QQueue<ClientEvent* > m_eventQueue;
 
     volatile bool m_stopped;
     volatile bool m_passwordError;
     RemoteView::Quality m_quality;
     QQueue<ClientEvent* > m_eventQueue;
 
     volatile bool m_stopped;
     volatile bool m_passwordError;
-
-private slots:
-    void checkOutputErrorMessage();
 };
 
 #endif
 };
 
 #endif
index 3e3eb56..fd0400c 100644 (file)
@@ -22,6 +22,7 @@
 ****************************************************************************/
 
 #include "vncview.h"
 ****************************************************************************/
 
 #include "vncview.h"
+#include "vncclientthread.h"
 
 //for mouse button masks
 #include "rfb/rfbproto.h"
 
 //for mouse button masks
 #include "rfb/rfbproto.h"
@@ -46,33 +47,34 @@ const int DOUBLE_TAP_UP_TIME = 500;
 
 VncView::VncView(QWidget *parent, const KUrl &url, RemoteView::Quality quality, int listen_port)
     : RemoteView(parent),
 
 VncView::VncView(QWidget *parent, const KUrl &url, RemoteView::Quality quality, int listen_port)
     : RemoteView(parent),
+      m_vncThread(new VncClientThread()),
       m_initDone(false),
       m_buttonMask(0),
       m_initDone(false),
       m_buttonMask(0),
-      cursor_x(0),
-      cursor_y(0),
+      m_cursor_x(0),
+      m_cursor_y(0),
       m_quitFlag(false),
       m_firstPasswordTry(true),
       m_dontSendClipboard(false),
       m_horizontalFactor(1.0),
       m_verticalFactor(1.0),
       m_forceLocalCursor(false),
       m_quitFlag(false),
       m_firstPasswordTry(true),
       m_dontSendClipboard(false),
       m_horizontalFactor(1.0),
       m_verticalFactor(1.0),
       m_forceLocalCursor(false),
-      quality(quality),
-      listen_port(listen_port),
-      transformation_mode(Qt::FastTransformation),
-      display_off(false)
+      m_quality(quality),
+      m_listen_port(listen_port),
+      m_transformation_mode(Qt::FastTransformation),
+      m_display_off(false)
 {
     m_url = url;
     m_host = url.host();
     m_port = url.port();
 
     //BlockingQueuedConnection can cause deadlocks when exiting, handled in startQuitting()
 {
     m_url = url;
     m_host = url.host();
     m_port = url.port();
 
     //BlockingQueuedConnection can cause deadlocks when exiting, handled in startQuitting()
-    connect(&vncThread, SIGNAL(imageUpdated(int, int, int, int)), this, SLOT(updateImage(int, int, int, int)), Qt::BlockingQueuedConnection);
-    connect(&vncThread, SIGNAL(gotCut(const QString&)), this, SLOT(setCut(const QString&)), Qt::BlockingQueuedConnection);
-    connect(&vncThread, SIGNAL(passwordRequest()), this, SLOT(requestPassword()), Qt::BlockingQueuedConnection);
-    connect(&vncThread, SIGNAL(outputErrorMessage(QString)), this, SLOT(outputErrorMessage(QString)));
+    connect(m_vncThread, SIGNAL(imageUpdated(int, int, int, int)), this, SLOT(updateImage(int, int, int, int)), Qt::BlockingQueuedConnection);
+    connect(m_vncThread, SIGNAL(gotCut(const QString&)), this, SLOT(setCut(const QString&)), Qt::BlockingQueuedConnection);
+    connect(m_vncThread, SIGNAL(passwordRequest()), this, SLOT(requestPassword()), Qt::BlockingQueuedConnection);
+    connect(m_vncThread, SIGNAL(outputErrorMessage(QString)), this, SLOT(outputErrorMessage(QString)));
 
     //don't miss early connection failures
 
     //don't miss early connection failures
-    connect(&vncThread, SIGNAL(finished()), this, SLOT(startQuitting()));
+    connect(m_vncThread, SIGNAL(finished()), this, SLOT(startQuitting()));
 
     m_clipboard = QApplication::clipboard();
     connect(m_clipboard, SIGNAL(selectionChanged()), this, SLOT(clipboardSelectionChanged()));
 
     m_clipboard = QApplication::clipboard();
     connect(m_clipboard, SIGNAL(selectionChanged()), this, SLOT(clipboardSelectionChanged()));
@@ -86,9 +88,11 @@ VncView::~VncView()
     unpressModifiers();
 
     // Disconnect all signals so that we don't get any more callbacks from the client thread
     unpressModifiers();
 
     // Disconnect all signals so that we don't get any more callbacks from the client thread
-    vncThread.disconnect();
+    m_vncThread->disconnect();
 
     startQuitting();
 
     startQuitting();
+
+    delete m_vncThread;
 }
 
 bool VncView::eventFilter(QObject *obj, QEvent *event)
 }
 
 bool VncView::eventFilter(QObject *obj, QEvent *event)
@@ -136,16 +140,16 @@ void VncView::startQuitting()
 
     m_quitFlag = true;
 
 
     m_quitFlag = true;
 
-    vncThread.stop();
+    m_vncThread->stop();
 
 
-    const bool quitSuccess = vncThread.wait(700);
+    const bool quitSuccess = m_vncThread->wait(700);
     if(!quitSuccess) {
     if(!quitSuccess) {
-        //happens when vncThread wants to call a slot via BlockingQueuedConnection,
+        //happens when m_vncThread wants to call a slot via BlockingQueuedConnection,
         //needs an event loop in this thread so execution continues after 'emit'
         QEventLoop loop;
         if(!loop.processEvents())
             kDebug(5011) << "BUG: deadlocked, but no events to deliver?";
         //needs an event loop in this thread so execution continues after 'emit'
         QEventLoop loop;
         if(!loop.processEvents())
             kDebug(5011) << "BUG: deadlocked, but no events to deliver?";
-        vncThread.wait(700);
+        m_vncThread->wait(700);
     }
     setStatus(Disconnected);
 }
     }
     setStatus(Disconnected);
 }
@@ -157,19 +161,19 @@ bool VncView::isQuitting() const
 
 bool VncView::start()
 {
 
 bool VncView::start()
 {
-    vncThread.setHost(m_host);
-    vncThread.setPort(m_port);
-    vncThread.setListenPort(listen_port); //if port is != 0, thread will listen for connections
-    vncThread.setQuality(quality);
+    m_vncThread->setHost(m_host);
+    m_vncThread->setPort(m_port);
+    m_vncThread->setListenPort(m_listen_port); //if port is != 0, thread will listen for connections
+    m_vncThread->setQuality(m_quality);
 
     // set local cursor on by default because low quality mostly means slow internet connection
 
     // set local cursor on by default because low quality mostly means slow internet connection
-    if (quality == RemoteView::Low) {
+    if (m_quality == RemoteView::Low) {
         showDotCursor(RemoteView::CursorOn);
     }
 
     setStatus(Connecting);
 
         showDotCursor(RemoteView::CursorOn);
     }
 
     setStatus(Connecting);
 
-    vncThread.start();
+    m_vncThread->start();
     return true;
 }
 
     return true;
 }
 
@@ -190,7 +194,7 @@ void VncView::requestPassword()
     setStatus(Authenticating);
 
     if (!m_url.password().isNull()) {
     setStatus(Authenticating);
 
     if (!m_url.password().isNull()) {
-        vncThread.setPassword(m_url.password());
+        m_vncThread->setPassword(m_url.password());
         return;
     }
 
         return;
     }
 
@@ -202,7 +206,7 @@ void VncView::requestPassword()
     if(m_firstPasswordTry and !password.isEmpty()) {
         kDebug(5011) << "Trying saved password";
         m_firstPasswordTry = false;
     if(m_firstPasswordTry and !password.isEmpty()) {
         kDebug(5011) << "Trying saved password";
         m_firstPasswordTry = false;
-        vncThread.setPassword(password);
+        m_vncThread->setPassword(password);
         return;
     }
     m_firstPasswordTry = false;
         return;
     }
     m_firstPasswordTry = false;
@@ -240,9 +244,9 @@ void VncView::requestPassword()
             settings.sync();
         }
 
             settings.sync();
         }
 
-        vncThread.setPassword(password);
+        m_vncThread->setPassword(password);
     } else {
     } else {
-        vncThread.setPassword(QString()); //null string to exit
+        m_vncThread->setPassword(QString()); //null string to exit
     }
 }
 
     }
 }
 
@@ -286,7 +290,7 @@ void VncView::updateImage(int x, int y, int w, int h)
         m_h+=2*y_extrapixels;
     }
 
         m_h+=2*y_extrapixels;
     }
 
-    m_frame = vncThread.image();
+    m_frame = m_vncThread->image();
 
     if (!m_initDone) { //TODO this seems an odd place for initialization
         setAttribute(Qt::WA_NoSystemBackground);
 
     if (!m_initDone) { //TODO this seems an odd place for initialization
         setAttribute(Qt::WA_NoSystemBackground);
@@ -410,7 +414,7 @@ void VncView::paintEvent(QPaintEvent *event)
 
         painter.drawImage(update_rect,
                           m_frame.copy(sx, sy, sw, sh)
 
         painter.drawImage(update_rect,
                           m_frame.copy(sx, sy, sw, sh)
-                          .scaled(update_rect.size(), Qt::IgnoreAspectRatio, transformation_mode));
+                          .scaled(update_rect.size(), Qt::IgnoreAspectRatio, m_transformation_mode));
     }
 
     //draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
     }
 
     //draw local cursor ourselves, normal mouse pointer doesn't deal with scrolling
@@ -419,7 +423,7 @@ void VncView::paintEvent(QPaintEvent *event)
         painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
 #endif
         //rectangle size includes 1px pen width
         painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
 #endif
         //rectangle size includes 1px pen width
-        painter.drawRect(cursor_x*m_horizontalFactor - CURSOR_SIZE/2, cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE-1, CURSOR_SIZE-1);
+        painter.drawRect(m_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, m_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE-1, CURSOR_SIZE-1);
     }
 
     RemoteView::paintEvent(event);
     }
 
     RemoteView::paintEvent(event);
@@ -471,13 +475,13 @@ void VncView::mouseEventHandler(QMouseEvent *e)
     if(!e) { //flush held taps
         if(tap_detected) {
             m_buttonMask |= rfbButton1Mask;
     if(!e) { //flush held taps
         if(tap_detected) {
             m_buttonMask |= rfbButton1Mask;
-            vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+            m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
             m_buttonMask &= ~rfbButton1Mask;
             m_buttonMask &= ~rfbButton1Mask;
-            vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+            m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
             tap_detected = false;
         } else if(double_tap_detected and press_time.elapsed() > TAP_PRESS_TIME) { //got tap + another press -> tap & drag
             m_buttonMask |= rfbButton1Mask;
             tap_detected = false;
         } else if(double_tap_detected and press_time.elapsed() > TAP_PRESS_TIME) { //got tap + another press -> tap & drag
             m_buttonMask |= rfbButton1Mask;
-            vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+            m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
             double_tap_detected = false;
             tap_drag_detected = true;
         }
             double_tap_detected = false;
             tap_drag_detected = true;
         }
@@ -490,11 +494,11 @@ void VncView::mouseEventHandler(QMouseEvent *e)
         return;
     }
 
         return;
     }
 
-    cursor_x = qRound(e->x()/m_horizontalFactor);
-    cursor_y = qRound(e->y()/m_verticalFactor);
-    vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask); // plain move event
+    m_cursor_x = qRound(e->x()/m_horizontalFactor);
+    m_cursor_y = qRound(e->y()/m_verticalFactor);
+    m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask); // plain move event
 
 
-    if(!disable_tapping and e->button() == Qt::LeftButton) { //implement touchpad-like input for left button
+    if(!m_disable_tapping and e->button() == Qt::LeftButton) { //implement touchpad-like input for left button
         if(e->type() == QEvent::MouseButtonPress or e->type() == QEvent::MouseButtonDblClick) {
             press_time.start();
             if(tap_detected and up_time.elapsed() < DOUBLE_TAP_UP_TIME) {
         if(e->type() == QEvent::MouseButtonPress or e->type() == QEvent::MouseButtonDblClick) {
             press_time.start();
             if(tap_detected and up_time.elapsed() < DOUBLE_TAP_UP_TIME) {
@@ -506,19 +510,19 @@ void VncView::mouseEventHandler(QMouseEvent *e)
         } else if(e->type() == QEvent::MouseButtonRelease) {
             if(tap_drag_detected) { //end tap & drag
                 m_buttonMask &= ~rfbButton1Mask;
         } else if(e->type() == QEvent::MouseButtonRelease) {
             if(tap_drag_detected) { //end tap & drag
                 m_buttonMask &= ~rfbButton1Mask;
-                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+                m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
                 tap_drag_detected = false;
             } else if(double_tap_detected) { //double click
                 double_tap_detected = false;
 
                 m_buttonMask |= rfbButton1Mask;
                 tap_drag_detected = false;
             } else if(double_tap_detected) { //double click
                 double_tap_detected = false;
 
                 m_buttonMask |= rfbButton1Mask;
-                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+                m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
                 m_buttonMask &= ~rfbButton1Mask;
                 m_buttonMask &= ~rfbButton1Mask;
-                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+                m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
                 m_buttonMask |= rfbButton1Mask;
                 m_buttonMask |= rfbButton1Mask;
-                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+                m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
                 m_buttonMask &= ~rfbButton1Mask;
                 m_buttonMask &= ~rfbButton1Mask;
-                vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+                m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
             } else if(press_time.elapsed() < TAP_PRESS_TIME) { //tap
                 up_time.start();
                 tap_detected = true;
             } else if(press_time.elapsed() < TAP_PRESS_TIME) { //tap
                 up_time.start();
                 tap_detected = true;
@@ -538,21 +542,21 @@ void VncView::mouseEventHandler(QMouseEvent *e)
             if (e->button() & Qt::RightButton)
                 m_buttonMask &= ~rfbButton3Mask;
         }
             if (e->button() & Qt::RightButton)
                 m_buttonMask &= ~rfbButton3Mask;
         }
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
     }
 
     //prevent local cursor artifacts
     }
 
     //prevent local cursor artifacts
-    static int old_cursor_x = cursor_x;
-    static int old_cursor_y = cursor_y;
+    static int old_cursor_x = m_cursor_x;
+    static int old_cursor_y = m_cursor_y;
     if(((m_dotCursorState == CursorOn) || m_forceLocalCursor)
     if(((m_dotCursorState == CursorOn) || m_forceLocalCursor)
-            and (cursor_x != old_cursor_x or cursor_y != old_cursor_y)) {
+            and (m_cursor_x != old_cursor_x or m_cursor_y != old_cursor_y)) {
         //clear last position
         update(old_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, old_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
         //and refresh new one
         //clear last position
         update(old_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, old_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
         //and refresh new one
-        update(cursor_x*m_horizontalFactor - CURSOR_SIZE/2, cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
+        update(m_cursor_x*m_horizontalFactor - CURSOR_SIZE/2, m_cursor_y*m_verticalFactor - CURSOR_SIZE/2, CURSOR_SIZE, CURSOR_SIZE);
 
 
-        old_cursor_x = cursor_x;
-        old_cursor_y = cursor_y;
+        old_cursor_x = m_cursor_x;
+        old_cursor_y = m_cursor_y;
     }
 }
 
     }
 }
 
@@ -567,8 +571,8 @@ void VncView::wheelEventHandler(QWheelEvent *event)
     const int x = qRound(event->x() / m_horizontalFactor);
     const int y = qRound(event->y() / m_verticalFactor);
 
     const int x = qRound(event->x() / m_horizontalFactor);
     const int y = qRound(event->y() / m_verticalFactor);
 
-    vncThread.mouseEvent(x, y, m_buttonMask | eb);
-    vncThread.mouseEvent(x, y, m_buttonMask);
+    m_vncThread->mouseEvent(x, y, m_buttonMask | eb);
+    m_vncThread->mouseEvent(x, y, m_buttonMask);
 }
 
 void VncView::keyEventHandler(QKeyEvent *e)
 }
 
 void VncView::keyEventHandler(QKeyEvent *e)
@@ -614,12 +618,12 @@ void VncView::keyEventHandler(QKeyEvent *e)
 
     int current_zoom = -1;
     if(e->key() == Qt::Key_F8)
 
     int current_zoom = -1;
     if(e->key() == Qt::Key_F8)
-        current_zoom = left_zoom;
+        current_zoom = m_left_zoom;
     else if(e->key() == Qt::Key_F7)
     else if(e->key() == Qt::Key_F7)
-        current_zoom = right_zoom;
+        current_zoom = m_right_zoom;
     else if (k) {
         kDebug(5011) << "Key pressed: '" << e->text() << "', nativeVirtualKey: " << k;
     else if (k) {
         kDebug(5011) << "Key pressed: '" << e->text() << "', nativeVirtualKey: " << k;
-        vncThread.keyEvent(k, pressed);
+        m_vncThread->keyEvent(k, pressed);
     } else {
         kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed.";
         return;
     } else {
         kDebug(5011) << "nativeVirtualKey() for '" << e->text() << "' failed.";
         return;
@@ -634,29 +638,29 @@ void VncView::keyEventHandler(QKeyEvent *e)
             m_buttonMask |= rfbButton1Mask;
         else
             m_buttonMask &= ~rfbButton1Mask;
             m_buttonMask |= rfbButton1Mask;
         else
             m_buttonMask &= ~rfbButton1Mask;
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
     } else if(current_zoom == 1) { //right click
         if(pressed)
             m_buttonMask |= rfbButton3Mask;
         else
             m_buttonMask &= ~rfbButton3Mask;
     } else if(current_zoom == 1) { //right click
         if(pressed)
             m_buttonMask |= rfbButton3Mask;
         else
             m_buttonMask &= ~rfbButton3Mask;
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
     } else if(current_zoom == 2) { //middle click
         if(pressed)
             m_buttonMask |= rfbButton2Mask;
         else
             m_buttonMask &= ~rfbButton2Mask;
     } else if(current_zoom == 2) { //middle click
         if(pressed)
             m_buttonMask |= rfbButton2Mask;
         else
             m_buttonMask &= ~rfbButton2Mask;
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
     } else if(current_zoom == 3 and pressed) { //wheel up
     } else if(current_zoom == 3 and pressed) { //wheel up
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask | rfbWheelUpMask);
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask | rfbWheelUpMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
     } else if(current_zoom == 4 and pressed) { //wheel down
     } else if(current_zoom == 4 and pressed) { //wheel down
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask | rfbWheelDownMask);
-        vncThread.mouseEvent(cursor_x, cursor_y, m_buttonMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask | rfbWheelDownMask);
+        m_vncThread->mouseEvent(m_cursor_x, m_cursor_y, m_buttonMask);
     } else if(current_zoom == 5) { //page up
     } else if(current_zoom == 5) { //page up
-        vncThread.keyEvent(0xff55, pressed);
+        m_vncThread->keyEvent(0xff55, pressed);
     } else if(current_zoom == 6) { //page down
     } else if(current_zoom == 6) { //page down
-        vncThread.keyEvent(0xff56, pressed);
+        m_vncThread->keyEvent(0xff56, pressed);
     }
 }
 
     }
 }
 
@@ -665,8 +669,8 @@ void VncView::unpressModifiers()
     const QList<unsigned int> keys = m_mods.keys();
     QList<unsigned int>::const_iterator it = keys.constBegin();
     while (it != keys.end()) {
     const QList<unsigned int> keys = m_mods.keys();
     QList<unsigned int>::const_iterator it = keys.constBegin();
     while (it != keys.end()) {
-        vncThread.keyEvent(*it, false);
-        it++;
+        m_vncThread->keyEvent(*it, false);
+        ++it;
     }
     m_mods.clear();
 }
     }
     m_mods.clear();
 }
@@ -681,7 +685,7 @@ void VncView::clipboardSelectionChanged()
 
     const QString text = m_clipboard->text(QClipboard::Selection);
 
 
     const QString text = m_clipboard->text(QClipboard::Selection);
 
-    vncThread.clientCut(text);
+    m_vncThread->clientCut(text);
 }
 
 void VncView::clipboardDataChanged()
 }
 
 void VncView::clipboardDataChanged()
@@ -694,7 +698,7 @@ void VncView::clipboardDataChanged()
 
     const QString text = m_clipboard->text(QClipboard::Clipboard);
 
 
     const QString text = m_clipboard->text(QClipboard::Clipboard);
 
-    vncThread.clientCut(text);
+    m_vncThread->clientCut(text);
 }
 
 //fake key events
 }
 
 //fake key events
@@ -773,14 +777,14 @@ void VncView::sendKey(Qt::Key key)
     if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L || k == XK_Super_L) {
         if (m_mods.contains(k)) { //release
             m_mods.remove(k);
     if (k == XK_Shift_L || k == XK_Control_L || k == XK_Meta_L || k == XK_Alt_L || k == XK_Super_L) {
         if (m_mods.contains(k)) { //release
             m_mods.remove(k);
-            vncThread.keyEvent(k, false);
+            m_vncThread->keyEvent(k, false);
         } else { //press
             m_mods[k] = true;
         } else { //press
             m_mods[k] = true;
-            vncThread.keyEvent(k, true);
+            m_vncThread->keyEvent(k, true);
         }
     } else { //normal key
         }
     } else { //normal key
-        vncThread.keyEvent(k, true);
-        vncThread.keyEvent(k, false);
+        m_vncThread->keyEvent(k, true);
+        m_vncThread->keyEvent(k, false);
     }
 }
 
     }
 }
 
@@ -821,9 +825,9 @@ void VncView::sendKeySequence(QKeySequence keys)
 void VncView::reloadSettings()
 {
     QSettings settings;
 void VncView::reloadSettings()
 {
     QSettings settings;
-    left_zoom = settings.value("left_zoom", 0).toInt();
-    right_zoom = settings.value("right_zoom", 1).toInt();
-    disable_tapping = settings.value("disable_tapping", false).toBool();
+    m_left_zoom = settings.value("left_zoom", 0).toInt();
+    m_right_zoom = settings.value("right_zoom", 1).toInt();
+    m_disable_tapping = settings.value("disable_tapping", false).toBool();
 
     bool always_show_local_cursor = settings.value("always_show_local_cursor", false).toBool();
     showDotCursor(always_show_local_cursor?CursorOn:CursorOff);
 
     bool always_show_local_cursor = settings.value("always_show_local_cursor", false).toBool();
     showDotCursor(always_show_local_cursor?CursorOn:CursorOff);
@@ -845,17 +849,17 @@ void VncView::inputMethodEvent(QInputMethodEvent *event)
             kDebug(5011) << "unhandled key";
             continue;
         }
             kDebug(5011) << "unhandled key";
             continue;
         }
-        vncThread.keyEvent(k, true);
-        vncThread.keyEvent(k, false);
+        m_vncThread->keyEvent(k, true);
+        m_vncThread->keyEvent(k, false);
     }
 }
 
 void VncView::useFastTransformations(bool enabled)
 {
     if(enabled or zoomFactor() >= 1.0) {
     }
 }
 
 void VncView::useFastTransformations(bool enabled)
 {
     if(enabled or zoomFactor() >= 1.0) {
-        transformation_mode = Qt::FastTransformation;
+        m_transformation_mode = Qt::FastTransformation;
     } else {
     } else {
-        transformation_mode = Qt::SmoothTransformation;
+        m_transformation_mode = Qt::SmoothTransformation;
         update();
     }
 }
         update();
     }
 }
index 82de593..41be03b 100644 (file)
 #define VNCVIEW_H
 
 #include "remoteview.h"
 #define VNCVIEW_H
 
 #include "remoteview.h"
-#include "vncclientthread.h"
 
 
-class KConfigGroup {};
+#include <QMap>
 
 
-#include <QClipboard>
+class QClipboard;
+class KConfigGroup {};
+class VncClientThread;
 
 
-extern "C" {
-#include <rfb/rfbclient.h>
-}
 
 class VncView: public RemoteView
 {
 
 class VncView: public RemoteView
 {
@@ -57,8 +55,8 @@ public:
     void setViewOnly(bool viewOnly);
     void showDotCursor(DotCursorState state);
     void useFastTransformations(bool enabled);
     void setViewOnly(bool viewOnly);
     void showDotCursor(DotCursorState state);
     void useFastTransformations(bool enabled);
-    QPoint cursorPosition() const { return QPoint(cursor_x, cursor_y); }
-    void setDisplayOff(bool off) { display_off = off; }
+    QPoint cursorPosition() const { return QPoint(m_cursor_x, m_cursor_y); }
+    void setDisplayOff(bool off) { m_display_off = off; }
 
 public slots:
     void setZoomLevel(int level = -1); //'level' doesn't correspond to actual magnification, though mapping is done here
 
 public slots:
     void setZoomLevel(int level = -1); //'level' doesn't correspond to actual magnification, though mapping is done here
@@ -73,14 +71,24 @@ protected:
     bool eventFilter(QObject *obj, QEvent *event);
     void inputMethodEvent(QInputMethodEvent *event);
 
     bool eventFilter(QObject *obj, QEvent *event);
     void inputMethodEvent(QInputMethodEvent *event);
 
+private slots:
+    void mouseEventHandler(QMouseEvent *event = 0);
+
+    void updateImage(int x, int y, int w, int h);
+    void setCut(const QString &text);
+    void requestPassword();
+    void outputErrorMessage(const QString &message);
+    void clipboardSelectionChanged();
+    void clipboardDataChanged();
+
 private:
 private:
-    VncClientThread vncThread;
+    VncClientThread *m_vncThread;
     QClipboard *m_clipboard;
     bool m_initDone;
     int m_buttonMask;
     QMap<unsigned int, bool> m_mods;
     int m_x, m_y, m_w, m_h;
     QClipboard *m_clipboard;
     bool m_initDone;
     int m_buttonMask;
     QMap<unsigned int, bool> m_mods;
     int m_x, m_y, m_w, m_h;
-    int cursor_x, cursor_y;
+    int m_cursor_x, m_cursor_y;
     bool m_quitFlag;
     bool m_firstPasswordTry;
     bool m_dontSendClipboard;
     bool m_quitFlag;
     bool m_firstPasswordTry;
     bool m_dontSendClipboard;
@@ -88,26 +96,16 @@ private:
     qreal m_verticalFactor;
     QImage m_frame;
     bool m_forceLocalCursor;
     qreal m_verticalFactor;
     QImage m_frame;
     bool m_forceLocalCursor;
-    int left_zoom, right_zoom;
-    bool disable_tapping;
-    RemoteView::Quality quality;
-    int listen_port;
-    Qt::TransformationMode transformation_mode;
-    bool display_off;
+    int m_left_zoom, m_right_zoom;
+    bool m_disable_tapping;
+    RemoteView::Quality m_quality;
+    int m_listen_port;
+    Qt::TransformationMode m_transformation_mode;
+    bool m_display_off;
 
     void keyEventHandler(QKeyEvent *e);
     void unpressModifiers();
     void wheelEventHandler(QWheelEvent *event);
 
     void keyEventHandler(QKeyEvent *e);
     void unpressModifiers();
     void wheelEventHandler(QWheelEvent *event);
-
-private slots:
-    void mouseEventHandler(QMouseEvent *event = 0);
-
-    void updateImage(int x, int y, int w, int h);
-    void setCut(const QString &text);
-    void requestPassword();
-    void outputErrorMessage(const QString &message);
-    void clipboardSelectionChanged();
-    void clipboardDataChanged();
 };
 
 #endif
 };
 
 #endif