cleanup
authorChristian Pulvermacher <christian@hazel.(none)>
Fri, 15 Oct 2010 16:52:01 +0000 (18:52 +0200)
committerChristian Pulvermacher <christian@hazel.(none)>
Fri, 15 Oct 2010 16:52:01 +0000 (18:52 +0200)
libvnc/libvncclient/vncviewer.c
src/vncclientthread.cpp
src/vncview.cpp

index 553028f..a3c2603 100644 (file)
@@ -282,6 +282,8 @@ rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) {
        i--;
       }
     }
+  } else if(client->listenSpecified) {
+       listenForIncomingConnections(client);
   }
 
   if(!rfbInitConnection(client)) {
index ac71844..d115f6e 100644 (file)
@@ -265,7 +265,7 @@ void VncClientThread::run()
 
         rfbClientLog = outputHandler;
         rfbClientErr = outputHandler;
-        cl = rfbGetClient(8, 3, 4);
+        cl = rfbGetClient(8, 3, 4); // bitsPerSample, samplesPerPixel, bytesPerPixel
         cl->MallocFrameBuffer = newclient;
         cl->canHandleNewFBSize = true;
         cl->GetPassword = passwdHandler;
@@ -282,31 +282,24 @@ void VncClientThread::run()
             m_port += 5900;
         cl->serverPort = m_port;
 
+               cl->listenSpecified = rfbBool(listen_port > 0);
+               cl->listenPort = listen_port;
+
         kDebug(5011) << "--------------------- trying init ---------------------";
 
-               if(listen_port) { //listen for incoming connections
-                       int argc = 2;
-                       char* argv[2] = { "x", "-listen" }; //this isn't exactly elegant..
-                       cl->listenPort = listen_port;
-                       if (rfbInitClient(cl, &argc, argv))
-                               break;
-               } else { //connect to host
-                       if (rfbInitClient(cl, 0, 0))
-                               break;
-               }
+               if (rfbInitClient(cl, 0, 0))
+                       break;
 
+               //init failed...
         if (m_passwordError) {
                        passwd_failures++;
-                       if(passwd_failures > 2) {
-                               m_stopped = true;
-                               return;
-                       }
-                       continue;
+                       if(passwd_failures < 3)
+                               continue; //that's ok, try again
                }
 
-               //clean, just exit
+               //stop connecting
                m_stopped = true;
-        return;
+        return; //no cleanup necessary, cl was free()d by rfbInitClient()
     }
 
     locker.unlock();
index 5ba10fa..ccbae25 100644 (file)
@@ -816,10 +816,12 @@ void VncView::sendKeySequence(QKeySequence keys)
 
        //to get at individual key presses, we split 'keys' into its components
        QList<int> key_list;
-       for(int i = 0; ; i++) {
-               QString k = keys.toString().section('+', i, i);
+       int pos = 0;
+       while(true) {
+               QString k = keys.toString().section('+', pos, pos);
                if(k.isEmpty())
                        break;
+
                //kDebug(5011) << "found key: " << k;
                if(k == "Alt") {
                        key_list.append(Qt::Key_Alt);
@@ -830,6 +832,8 @@ void VncView::sendKeySequence(QKeySequence keys)
                } else {
                        key_list.append(QKeySequence(k)[0]);
                }
+               
+               pos++;
        }
        
        for(int i = 0; i < key_list.count(); i++)