⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vncsconnectionst.cxx

📁 linux可以运行程序源码
💻 CXX
📖 第 1 页 / 共 2 页
字号:
void VNCSConnectionST::queryConnection(const char* userName){  // - Authentication succeeded - clear from blacklist  CharArray name; name.buf = sock->getPeerAddress();  server->blHosts->clearBlackmark(name.buf);  // - Special case to provide a more useful error message  if (rfb::Server::neverShared && !rfb::Server::disconnectClients &&    server->authClientCount() > 0) {    approveConnection(false, "The server is already in use");    return;  }  // - Does the client have the right to bypass the query?  if (reverseConnection ||      !(rfb::Server::queryConnect || sock->requiresQuery()) ||      (accessRights & AccessNoQuery))  {    approveConnection(true);    return;  }  // - Get the server to display an Accept/Reject dialog, if required  //   If a dialog is displayed, the result will be PENDING, and the  //   server will call approveConnection at a later time  CharArray reason;  VNCServerST::queryResult qr = server->queryConnection(sock, userName,                                                        &reason.buf);  if (qr == VNCServerST::PENDING)    return;  // - If server returns ACCEPT/REJECT then pass result to SConnection  approveConnection(qr == VNCServerST::ACCEPT, reason.buf);}void VNCSConnectionST::clientInit(bool shared){  lastEventTime = time(0);  if (rfb::Server::alwaysShared || reverseConnection) shared = true;  if (rfb::Server::neverShared) shared = false;  if (!shared) {    if (rfb::Server::disconnectClients) {      // - Close all the other connected clients      vlog.debug("non-shared connection - closing clients");      server->closeClients("Non-shared connection requested", getSock());    } else {      // - Refuse this connection if there are existing clients, in addition to      // this one      if (server->authClientCount() > 1) {        close("Server is already in use");        return;      }    }  }  SConnection::clientInit(shared);}void VNCSConnectionST::setPixelFormat(const PixelFormat& pf){  SConnection::setPixelFormat(pf);  char buffer[256];  pf.print(buffer, 256);  vlog.info("Client pixel format %s", buffer);  image_getter.init(server->pb, pf, writer());  setCursor();}void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask){  pointerEventTime = lastEventTime = time(0);  if (!(accessRights & AccessPtrEvents)) return;  if (!rfb::Server::acceptPointerEvents) return;  if (!server->pointerClient || server->pointerClient == this) {    pointerEventPos = pos;    if (buttonMask)      server->pointerClient = this;    else      server->pointerClient = 0;    server->desktop->pointerEvent(pointerEventPos, buttonMask);  }}class VNCSConnectionSTShiftPresser {public:  VNCSConnectionSTShiftPresser(SDesktop* desktop_)    : desktop(desktop_), pressed(false) {}  ~VNCSConnectionSTShiftPresser() {    if (pressed) { desktop->keyEvent(XK_Shift_L, false); }  }  void press() {    desktop->keyEvent(XK_Shift_L, true);    pressed = true;  }  SDesktop* desktop;  bool pressed;};// keyEvent() - record in the pressedKeys which keys were pressed.  Allow// multiple down events (for autorepeat), but only allow a single up event.void VNCSConnectionST::keyEvent(rdr::U32 key, bool down) {  lastEventTime = time(0);  if (!(accessRights & AccessKeyEvents)) return;  if (!rfb::Server::acceptKeyEvents) return;  // Remap the key if required  if (server->keyRemapper)    key = server->keyRemapper->remapKey(key);  // Turn ISO_Left_Tab into shifted Tab.  VNCSConnectionSTShiftPresser shiftPresser(server->desktop);  if (key == XK_ISO_Left_Tab) {    if (pressedKeys.find(XK_Shift_L) == pressedKeys.end() &&        pressedKeys.find(XK_Shift_R) == pressedKeys.end())      shiftPresser.press();    key = XK_Tab;  }  if (down) {    pressedKeys.insert(key);  } else {    if (!pressedKeys.erase(key)) return;  }  server->desktop->keyEvent(key, down);}void VNCSConnectionST::clientCutText(const char* str, int len){  if (!(accessRights & AccessCutText)) return;  if (!rfb::Server::acceptCutText) return;  server->desktop->clientCutText(str, len);}void VNCSConnectionST::framebufferUpdateRequest(const Rect& r,bool incremental){  if (!(accessRights & AccessView)) return;  SConnection::framebufferUpdateRequest(r, incremental);  Region reqRgn(r);  requested.assign_union(reqRgn);  if (!incremental) {    // Non-incremental update - treat as if area requested has changed    updates.add_changed(reqRgn);    server->comparer->add_changed(reqRgn);  }  writeFramebufferUpdate();}void VNCSConnectionST::setInitialColourMap(){  setColourMapEntries(0, 0);}// supportsLocalCursor() is called whenever the status of// cp.supportsLocalCursor has changed.  If the client does now support local// cursor, we make sure that the old server-side rendered cursor is cleaned up// and the cursor is sent to the client.void VNCSConnectionST::supportsLocalCursor(){  if (cp.supportsLocalCursor) {    removeRenderedCursor = true;    drawRenderedCursor = false;    setCursor();  }}void VNCSConnectionST::writeSetCursorCallback(){  rdr::U8* transData = writer()->getImageBuf(server->cursor.area());  image_getter.translatePixels(server->cursor.data, transData,                               server->cursor.area());  writer()->writeSetCursor(server->cursor.width(),                           server->cursor.height(),                           server->cursor.hotspot,                           transData, server->cursor.mask.buf);}void VNCSConnectionST::writeFramebufferUpdate(){  if (state() != RFBSTATE_NORMAL || requested.is_empty()) return;  server->checkUpdate();  // If the previous position of the rendered cursor overlaps the source of the  // copy, then when the copy happens the corresponding rectangle in the  // destination will be wrong, so add it to the changed region.  if (!updates.get_copied().is_empty() && !renderedCursorRect.is_empty()) {    Rect bogusCopiedCursor = (renderedCursorRect.translate(updates.get_delta())                              .intersect(server->pb->getRect()));    if (!updates.get_copied().intersect(bogusCopiedCursor).is_empty()) {      updates.add_changed(bogusCopiedCursor);    }  }  // If we need to remove the old rendered cursor, just add the rectangle to  // the changed region.  if (removeRenderedCursor) {    updates.add_changed(renderedCursorRect);    renderedCursorRect.clear();    removeRenderedCursor = false;  }  // Return if there is nothing to send the client.  if (updates.is_empty() && !writer()->needFakeUpdate() && !drawRenderedCursor)    return;  // If the client needs a server-side rendered cursor, work out the cursor  // rectangle.  If it's empty then don't bother drawing it, but if it overlaps  // with the update region, we need to draw the rendered cursor regardless of  // whether it has changed.  if (needRenderedCursor()) {    renderedCursorRect      = (server->renderedCursor.getRect(server->renderedCursorTL)         .intersect(requested.get_bounding_rect()));    if (renderedCursorRect.is_empty()) {      drawRenderedCursor = false;    } else if (!updates.get_changed().union_(updates.get_copied())               .intersect(renderedCursorRect).is_empty()) {      drawRenderedCursor = true;    }    // We could remove the new cursor rect from updates here.  It's not clear    // whether this is worth it.  If we do remove it, then we won't draw over    // the same bit of screen twice, but we have the overhead of a more complex    // region.    //if (drawRenderedCursor)    //  updates.subtract(renderedCursorRect);  }  UpdateInfo update;  updates.enable_copyrect(cp.useCopyRect);  updates.getUpdateInfo(&update, requested);  if (!update.is_empty() || writer()->needFakeUpdate() || drawRenderedCursor) {    int nRects = update.numRects() + (drawRenderedCursor ? 1 : 0);    writer()->writeFramebufferUpdateStart(nRects);    Region updatedRegion;    writer()->writeRects(update, &image_getter, &updatedRegion);    updates.subtract(updatedRegion);    if (drawRenderedCursor)      writeRenderedCursorRect();    writer()->writeFramebufferUpdateEnd();    requested.clear();  }}// writeRenderedCursorRect() writes a single rectangle drawing the rendered// cursor on the client.void VNCSConnectionST::writeRenderedCursorRect(){  image_getter.setPixelBuffer(&server->renderedCursor);  image_getter.setOffset(server->renderedCursorTL);  Rect actual;  writer()->writeRect(renderedCursorRect, &image_getter, &actual);  image_getter.setPixelBuffer(server->pb);  image_getter.setOffset(Point(0,0));  drawRenderedCursor = false;}void VNCSConnectionST::setColourMapEntries(int firstColour, int nColours){  if (!readyForSetColourMapEntries) return;  if (server->pb->getPF().trueColour) return;  image_getter.setColourMapEntries(firstColour, nColours, writer());  if (cp.pf().trueColour) {    updates.add_changed(server->pb->getRect());  }}// setCursor() is called whenever the cursor has changed shape or pixel format.// If the client supports local cursor then it will arrange for the cursor to// be sent to the client.void VNCSConnectionST::setCursor(){  if (state() != RFBSTATE_NORMAL || !cp.supportsLocalCursor) return;  writer()->cursorChange(this);  if (writer()->needFakeUpdate())    writeFramebufferUpdate();}void VNCSConnectionST::setSocketTimeouts(){  int timeoutms = rfb::Server::clientWaitTimeMillis;  soonestTimeout(&timeoutms, secsToMillis(rfb::Server::idleTimeout));  if (timeoutms == 0)    timeoutms = -1;  sock->inStream().setTimeout(timeoutms);  sock->outStream().setTimeout(timeoutms);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -