void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h) { // kDebug(5011) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h; VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0); Q_ASSERT(t); const int width = cl->width, height = cl->height; QImage img; switch(t->colorDepth()) { case bpp8: img = QImage(cl->frameBuffer, width, height, QImage::Format_Indexed8); img.setColorTable(m_colorTable); break; case bpp16: img = QImage(cl->frameBuffer, width, height, QImage::Format_RGB16); break; case bpp32: img = QImage(cl->frameBuffer, width, height, QImage::Format_RGB32); break; } if (img.isNull()) { kDebug(5011) << "image not loaded"; } if (t->m_stopped) { return; // sending data to a stopped thread is not a good idea } t->setImage(img); t->emitUpdated(x, y, w, h); }
rfbCredential *VncClientThread::credentialHandler(rfbClient *cl, int credentialType) { kDebug(5011) << "credential request" << credentialType; VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0); Q_ASSERT(t); rfbCredential *cred = 0; switch (credentialType) { case rfbCredentialTypeUser: t->passwordRequest(true); t->m_passwordError = true; cred = new rfbCredential; cred->userCredential.username = strdup(t->username().toUtf8()); cred->userCredential.password = strdup(t->password().toUtf8()); break; default: kError(5011) << "credential request failed, unspported credentialType:" << credentialType; t->outputErrorMessage(i18n("VNC authentication type is not supported.")); break; } return cred; }
rfbBool VncClientThread::newclient(rfbClient *cl) { VncClientThread *t = static_cast<VncClientThread*>(rfbClientGetClientData(cl, 0)); Q_ASSERT(t); switch (t->quality()) { case RemoteView::High: cl->format.bitsPerPixel = MAX_COLOR_DEPTH; cl->appData.useBGR233 = 0; cl->appData.encodingsString = "copyrect hextile raw"; cl->appData.compressLevel = 0; cl->appData.qualityLevel = 9; break; case RemoteView::Medium: cl->format.bitsPerPixel = 16; cl->appData.useBGR233 = 0; cl->appData.encodingsString = "tight zrle ultra copyrect hextile zlib corre rre raw"; cl->appData.compressLevel = 5; cl->appData.qualityLevel = 7; break; case RemoteView::Low: case RemoteView::Unknown: default: cl->format.bitsPerPixel = 16; //TODO: add support for 8bit (needs color map) cl->appData.encodingsString = "tight zrle ultra copyrect hextile zlib corre rre raw"; cl->appData.compressLevel = 9; cl->appData.qualityLevel = 1; } if(cl->format.bitsPerPixel == 16) { cl->format.depth = 16; //number of useful bits in the pixel value cl->format.redShift = 11; cl->format.greenShift = 5; cl->format.blueShift = 0; cl->format.redMax = 0x1f; cl->format.greenMax = 0x3f; cl->format.blueMax = 0x1f; } else { cl->format.depth = 24; //number of useful bits in the pixel value cl->format.redShift = 16; cl->format.greenShift = 8; cl->format.blueShift = 0; cl->format.redMax = 0xff; cl->format.greenMax = 0xff; cl->format.blueMax = 0xff; } 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); t->m_frameBuffer = new uint8_t[size]; cl->frameBuffer = t->m_frameBuffer; memset(cl->frameBuffer, '\0', size); SetFormatAndEncodings(cl); return true; }
char *VncClientThread::passwdHandler(rfbClient *cl) { kDebug(5011) << "password request"; VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0); Q_ASSERT(t); t->passwordRequest(); t->m_passwordError = true; return strdup(t->password().toUtf8()); }
void VncClientThread::cuttext(rfbClient* cl, const char *text, int textlen) { const QString cutText = QString::fromUtf8(text, textlen); kDebug(5011) << cutText; if (!cutText.isEmpty()) { VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0); Q_ASSERT(t); t->emitGotCut(cutText); } }
char *VncClientThread::passwdHandler(rfbClient *cl) { kDebug(5011) << "password request" << kBacktrace(); VncClientThread *t = static_cast<VncClientThread*>(rfbClientGetClientData(cl, 0)); Q_ASSERT(t); t->m_passwordError = true; t->passwordRequest(); return strdup(t->password().toLocal8Bit()); }
rfbBool VncClientThread::newclient(rfbClient *cl) { VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0); Q_ASSERT(t); const int width = cl->width, height = cl->height, depth = cl->format.bitsPerPixel; const int size = width * height * (depth / 8); if (t->frameBuffer) delete [] t->frameBuffer; // do not leak if we get a new framebuffer size t->frameBuffer = new uint8_t[size]; cl->frameBuffer = t->frameBuffer; memset(cl->frameBuffer, '\0', size); cl->format.bitsPerPixel = 32; cl->format.redShift = 16; cl->format.greenShift = 8; cl->format.blueShift = 0; cl->format.redMax = 0xff; cl->format.greenMax = 0xff; cl->format.blueMax = 0xff; switch (t->quality()) { case RemoteView::High: cl->appData.useBGR233 = 0; cl->appData.encodingsString = "copyrect hextile raw"; cl->appData.compressLevel = 0; cl->appData.qualityLevel = 9; break; case RemoteView::Medium: cl->appData.useBGR233 = 0; cl->appData.encodingsString = "tight zrle ultra copyrect hextile zlib corre rre raw"; cl->appData.compressLevel = 5; cl->appData.qualityLevel = 7; break; case RemoteView::Low: case RemoteView::Unknown: default: cl->appData.useBGR233 = 1; cl->appData.encodingsString = "tight zrle ultra copyrect hextile zlib corre rre raw"; cl->appData.compressLevel = 9; cl->appData.qualityLevel = 1; } SetFormatAndEncodings(cl); return true; }
void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h) { // kDebug(5011) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h; const int width = cl->width, height = cl->height; const QImage img(cl->frameBuffer, width, height, QImage::Format_RGB32); if (img.isNull()) kDebug(5011) << "image not loaded"; VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0); Q_ASSERT(t); t->setImage(img); t->emitUpdated(x, y, w, h); }
rfbBool VncClientThread::newclient(rfbClient *cl) { VncClientThread *t = (VncClientThread*)rfbClientGetClientData(cl, 0); Q_ASSERT(t); //8bit color hack for Intel(r) AMT KVM "classic vnc" = vnc server built in in Intel Vpro chipsets. if (INTEL_AMT_KVM_STRING == cl->desktopName) { kDebug(5011) << "Intel(R) AMT KVM: switching to 8 bit color depth (workaround, recent libvncserver needed)"; t->setColorDepth(bpp8); } setClientColorDepth(cl, t->colorDepth()); const int width = cl->width, height = cl->height, depth = cl->format.bitsPerPixel; const int size = width * height * (depth / 8); if (t->frameBuffer) delete [] t->frameBuffer; // do not leak if we get a new framebuffer size t->frameBuffer = new uint8_t[size]; cl->frameBuffer = t->frameBuffer; memset(cl->frameBuffer, '\0', size); switch (t->quality()) { case RemoteView::High: cl->appData.encodingsString = "copyrect zlib hextile raw"; cl->appData.compressLevel = 0; cl->appData.qualityLevel = 9; break; case RemoteView::Medium: cl->appData.encodingsString = "copyrect tight zrle ultra zlib hextile corre rre raw"; cl->appData.compressLevel = 5; cl->appData.qualityLevel = 7; break; case RemoteView::Low: case RemoteView::Unknown: default: cl->appData.encodingsString = "copyrect tight zrle ultra zlib hextile corre rre raw"; cl->appData.compressLevel = 9; cl->appData.qualityLevel = 1; } SetFormatAndEncodings(cl); kDebug(5011) << "Client created"; return true; }
void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h) { //kDebug(5011) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h; const QImage img( cl->frameBuffer, cl->width, cl->height, (cl->format.bitsPerPixel==16)?QImage::Format_RGB16:QImage::Format_RGB32 ); if (img.isNull()) { kDebug(5011) << "image not loaded"; } VncClientThread *t = static_cast<VncClientThread*>(rfbClientGetClientData(cl, 0)); Q_ASSERT(t); t->setImage(img); t->emitUpdated(x, y, w, h); }