Beispiel #1
0
void rfbNewFramebuffer(rfbScreenInfoPtr screen, char *framebuffer,
                       int width, int height,
                       int bitsPerSample, int samplesPerPixel,
                       int bytesPerPixel)
{
  rfbPixelFormat old_format;
  rfbBool format_changed = FALSE;
  rfbClientIteratorPtr iterator;
  rfbClientPtr cl;

  /* Update information in the screenInfo structure */

  old_format = screen->serverFormat;

  if (width & 3)
    rfbErr("WARNING: New width (%d) is not a multiple of 4.\n", width);

  screen->width = width;
  screen->height = height;
  screen->bitsPerPixel = screen->depth = 8*bytesPerPixel;
  screen->paddedWidthInBytes = width*bytesPerPixel;

  rfbInitServerFormat(screen, bitsPerSample);

  if (memcmp(&screen->serverFormat, &old_format,
             sizeof(rfbPixelFormat)) != 0) {
    format_changed = TRUE;
  }

  screen->frameBuffer = framebuffer;

  /* Adjust pointer position if necessary */

  if (screen->cursorX >= width)
    screen->cursorX = width - 1;
  if (screen->cursorY >= height)
    screen->cursorY = height - 1;

  /* For each client: */
  iterator = rfbGetClientIterator(screen);
  while ((cl = rfbClientIteratorNext(iterator)) != NULL) {

    /* Re-install color translation tables if necessary */

    if (format_changed)
      screen->setTranslateFunction(cl);

    /* Mark the screen contents as changed, and schedule sending
       NewFBSize message if supported by this client. */

    LOCK(cl->updateMutex);
    sraRgnDestroy(cl->modifiedRegion);
    cl->modifiedRegion = sraRgnCreateRect(0, 0, width, height);
    sraRgnMakeEmpty(cl->copyRegion);
    cl->copyDX = 0;
    cl->copyDY = 0;

    if (cl->useNewFBSize)
      cl->newFBSizePending = TRUE;

    TSIGNAL(cl->updateCond);
    UNLOCK(cl->updateMutex);
  }
  rfbReleaseClientIterator(iterator);
}
Beispiel #2
0
VNCServer::VNCServer()
{
	//NO editor or private viewer
	editorId = 0;
	viewerId = 0;

	//NO listener yet
	listener = NULL;

	//No height
	int width=0;
	int height=0;
	int bytesPerPixel = 4;
	int bitsPerSample  = 8;

	//Alocate screen info
	screen = (rfbScreenInfo*)calloc(sizeof(rfbScreenInfo),1);

	//Set private data to use object to allow locking in static objects
	screen->screenData = (void*)&use;

	//Set default vaules
	screen->autoPort=FALSE;
	screen->clientHead=NULL;
	screen->pointerClient=NULL;
	screen->port=5900;
	screen->ipv6port=5900;
	screen->socketState=RFB_SOCKET_INIT;

	screen->inetdInitDone = FALSE;
	screen->inetdSock=-1;

	screen->udpSock=-1;
	screen->udpSockConnected=FALSE;
	screen->udpPort=0;
	screen->udpClient=NULL;

	screen->maxFd=0;
	screen->listenSock=-1;
	screen->listen6Sock=-1;

	screen->httpInitDone=FALSE;
	screen->httpEnableProxyConnect=FALSE;
	screen->httpPort=0;
	screen->http6Port=0;
	screen->httpDir=NULL;
	screen->httpListenSock=-1;
	screen->httpListen6Sock=-1;
	screen->httpSock=-1;

	screen->desktopName = "MCU";
	screen->alwaysShared = TRUE;
	screen->neverShared = FALSE;
	screen->dontDisconnect = TRUE;

	screen->authPasswdData = NULL;
	screen->authPasswdFirstViewOnly = 1;

	screen->width = width;
	screen->height = height;
	screen->bitsPerPixel = screen->depth = 8*bytesPerPixel;
	screen->paddedWidthInBytes = width*bytesPerPixel;

	//Allocate memory for max usage
	screen->frameBuffer = (char*) malloc32(width*height*4);

	screen->passwordCheck = rfbDefaultPasswordCheck;

	screen->ignoreSIGPIPE = TRUE;

	/* disable progressive updating per default */
	screen->progressiveSliceHeight = 0;

	screen->listenInterface = htonl(INADDR_ANY);

	screen->deferUpdateTime=0;
	screen->maxRectsPerUpdate=50;

	screen->handleEventsEagerly = FALSE;

	screen->protocolMajorVersion = rfbProtocolMajorVersion;
	screen->protocolMinorVersion = rfbProtocolMinorVersion;

	screen->permitFileTransfer = FALSE;

	screen->paddedWidthInBytes = width*bytesPerPixel;

	/* format */

	rfbInitServerFormat(screen, bitsPerSample);

	/* cursor */

	screen->cursorX=screen->cursorY=screen->underCursorBufferLen=0;
	screen->underCursorBuffer=NULL;
	screen->dontConvertRichCursorToXCursor = FALSE;
	screen->cursor = &myCursor;
	INIT_MUTEX(screen->cursorMutex);

	IF_PTHREADS(screen->backgroundLoop = FALSE);

	/* proc's and hook's */

	screen->kbdAddEvent = onKeyboardEvent;
	screen->kbdReleaseAllKeys = rfbDoNothingWithClient;
	screen->ptrAddEvent = onMouseEvent;
	screen->setXCutText = rfbDefaultSetXCutText;
	screen->getCursorPtr = rfbDefaultGetCursorPtr;
	screen->setTranslateFunction = rfbSetTranslateFunction;
	screen->newClientHook = NULL;
	screen->displayHook = onDisplay;
	screen->displayFinishedHook = onDisplayFinished;
	screen->getKeyboardLedStateHook = NULL;
	screen->xvpHook = NULL;

	/* initialize client list and iterator mutex */
	rfbClientListInit(screen);
}
Beispiel #3
0
rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
 int width,int height,int bitsPerSample,int samplesPerPixel,
 int bytesPerPixel)
{
   rfbScreenInfoPtr screen=calloc(sizeof(rfbScreenInfo),1);

   if (! logMutex_initialized) {
     INIT_MUTEX(logMutex);
     logMutex_initialized = 1;
   }


   if(width&3)
     rfbErr("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width);

   screen->autoPort=FALSE;
   screen->clientHead=NULL;
   screen->pointerClient=NULL;
   screen->port=5900;
   screen->ipv6port=5900;
   screen->socketState=RFB_SOCKET_INIT;

   screen->inetdInitDone = FALSE;
   screen->inetdSock=-1;

   screen->udpSock=-1;
   screen->udpSockConnected=FALSE;
   screen->udpPort=0;
   screen->udpClient=NULL;

   screen->maxFd=0;
   screen->listenSock=-1;
   screen->listen6Sock=-1;

   screen->httpInitDone=FALSE;
   screen->httpEnableProxyConnect=FALSE;
   screen->httpPort=0;
   screen->http6Port=0;
   screen->httpDir=NULL;
   screen->httpListenSock=-1;
   screen->httpListen6Sock=-1;
   screen->httpSock=-1;

   screen->desktopName = "LibVNCServer";
   screen->alwaysShared = FALSE;
   screen->neverShared = FALSE;
   screen->dontDisconnect = FALSE;
   screen->authPasswdData = NULL;
   screen->authPasswdFirstViewOnly = 1;
   
   screen->width = width;
   screen->height = height;
   screen->bitsPerPixel = screen->depth = 8*bytesPerPixel;

   screen->passwordCheck = rfbDefaultPasswordCheck;

   screen->ignoreSIGPIPE = TRUE;

   /* disable progressive updating per default */
   screen->progressiveSliceHeight = 0;

   screen->listenInterface = htonl(INADDR_ANY);

   screen->deferUpdateTime=5;
   screen->maxRectsPerUpdate=50;

   screen->handleEventsEagerly = FALSE;

   screen->protocolMajorVersion = rfbProtocolMajorVersion;
   screen->protocolMinorVersion = rfbProtocolMinorVersion;

   screen->permitFileTransfer = FALSE;

   if(!rfbProcessArguments(screen,argc,argv)) {
     free(screen);
     return NULL;
   }

#ifdef WIN32
   {
	   DWORD dummy=255;
	   GetComputerName(screen->thisHost,&dummy);
   }
#else
   gethostname(screen->thisHost, 255);
#endif

   screen->paddedWidthInBytes = width*bytesPerPixel;

   /* format */

   rfbInitServerFormat(screen, bitsPerSample);

   /* cursor */

   screen->cursorX=screen->cursorY=screen->underCursorBufferLen=0;
   screen->underCursorBuffer=NULL;
   screen->dontConvertRichCursorToXCursor = FALSE;
   screen->cursor = &myCursor;
   INIT_MUTEX(screen->cursorMutex);

   IF_PTHREADS(screen->backgroundLoop = FALSE);

   /* proc's and hook's */

   screen->kbdAddEvent = rfbDefaultKbdAddEvent;
   screen->kbdReleaseAllKeys = rfbDoNothingWithClient;
   screen->ptrAddEvent = rfbDefaultPtrAddEvent;
   screen->setXCutText = rfbDefaultSetXCutText;
   screen->getCursorPtr = rfbDefaultGetCursorPtr;
   screen->setTranslateFunction = rfbSetTranslateFunction;
   screen->newClientHook = rfbDefaultNewClientHook;
   screen->displayHook = NULL;
   screen->displayFinishedHook = NULL;
   screen->getKeyboardLedStateHook = NULL;
   screen->xvpHook = NULL;

   /* initialize client list and iterator mutex */
   rfbClientListInit(screen);

   return(screen);
}
Beispiel #4
0
rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
 int width,int height,int bitsPerSample,int samplesPerPixel,
 int bytesPerPixel)
{
   rfbScreenInfoPtr rfbScreen=malloc(sizeof(rfbScreenInfo));

   if(width&3)
     rfbErr("WARNING: Width (%d) is not a multiple of 4. VncViewer has problems with that.\n",width);

   rfbScreen->autoPort=FALSE;
   rfbScreen->localOnly=FALSE;
   rfbScreen->rfbClientHead=0;
   rfbScreen->rfbPort=5900;
   rfbScreen->socketInitDone=FALSE;

   rfbScreen->inetdInitDone = FALSE;
   rfbScreen->inetdSock=-1;

   rfbScreen->maxFd=0;

   rfbScreen->rfbListenSock[0] = -1;
   rfbScreen->rfbListenSockTotal = 0;
   rfbScreen->netIface = NULL;

   rfbScreen->desktopName = strdup("LibVNCServer");
   rfbScreen->rfbAlwaysShared = FALSE;
   rfbScreen->rfbNeverShared = FALSE;
   rfbScreen->rfbDontDisconnect = FALSE;
   
   rfbScreen->width = width;
   rfbScreen->height = height;
   rfbScreen->bitsPerPixel = rfbScreen->depth = 8*bytesPerPixel;

   rfbScreen->securityTypes[0] = rfbNoAuth;
   rfbScreen->nSecurityTypes = 0;
   rfbScreen->authTypes[0] = rfbNoAuth;
   rfbScreen->nAuthTypes = 0;
   rfbScreen->passwordCheck = NULL;

#ifdef WIN32
   {
	   DWORD dummy=255;
	   GetComputerName(rfbScreen->rfbThisHost,&dummy);
   }
#else
   gethostname(rfbScreen->rfbThisHost, 255);
#endif

   rfbScreen->paddedWidthInBytes = width*bytesPerPixel;

   /* format */

   rfbInitServerFormat(rfbScreen, bitsPerSample);

   /* cursor */

   rfbScreen->cursorX=rfbScreen->cursorY=rfbScreen->underCursorBufferLen=0;
   rfbScreen->underCursorBuffer=NULL;
   rfbScreen->cursor = &myCursor;

   rfbScreen->rfbDeferUpdateTime=5;
   rfbScreen->maxRectsPerUpdate=50;

   /* proc's and hook's */

   rfbScreen->kbdAddEvent = NULL;
   rfbScreen->ptrAddEvent = defaultPtrAddEvent;
   rfbScreen->setXCutText = NULL;
   rfbScreen->newClientHook = NULL;
   rfbScreen->authenticatedClientHook = NULL;

   /* initialize client list and iterator mutex */
   rfbClientListInit(rfbScreen);

   rfbAuthInitScreen(rfbScreen);

   return(rfbScreen);
}