Home | History | Annotate | Download | only in libvncclient

Lines Matching refs:client

44 static void Dummy(rfbClient* client) {
46 static rfbBool DummyPoint(rfbClient* client, int x, int y) {
49 static void DummyRect(rfbClient* client, int x, int y, int w, int h) {
53 static char* NoPassword(rfbClient* client) {
62 static char* ReadPassword(rfbClient* client) {
66 return NoPassword(client);
91 static rfbBool MallocFrameBuffer(rfbClient* client) {
94 if(client->frameBuffer)
95 free(client->frameBuffer);
101 allocSize = (uint64_t)client->width * client->height * client->format.bitsPerPixel/8;
108 client->frameBuffer=malloc( (size_t)allocSize );
110 if (client->frameBuffer == NULL)
113 return client->frameBuffer?TRUE:FALSE;
141 rfbClient* client=(rfbClient*)calloc(sizeof(rfbClient),1);
142 if(!client) {
143 rfbClientErr("Couldn't allocate client structure!\n");
146 initAppData(&client->appData);
147 client->endianTest = 1;
148 client->programName="";
149 client->serverHost=strdup("");
150 client->serverPort=5900;
152 client->destHost = NULL;
153 client->destPort = 5900;
155 client->CurrentKeyboardLedState = 0;
156 client->HandleKeyboardLedState = (HandleKeyboardLedStateProc)DummyPoint;
159 client->updateRect.x = -1;
161 client->frameBuffer = NULL;
162 client->outputWindow = 0;
164 client->format.bitsPerPixel = bytesPerPixel*8;
165 client->format.depth = bitsPerSample*samplesPerPixel;
166 client->appData.requestedDepth=client->format.depth;
167 client->format.bigEndian = *(char *)&client->endianTest?FALSE:TRUE;
168 client->format.trueColour = TRUE;
170 if (client->format.bitsPerPixel == 8) {
171 client->format.redMax = 7;
172 client->format.greenMax = 7;
173 client->format.blueMax = 3;
174 client->format.redShift = 0;
175 client->format.greenShift = 3;
176 client->format.blueShift = 6;
178 client->format.redMax = (1 << bitsPerSample) - 1;
179 client->format.greenMax = (1 << bitsPerSample) - 1;
180 client->format.blueMax = (1 << bitsPerSample) - 1;
181 if(!client->format.bigEndian) {
182 client->format.redShift = 0;
183 client->format.greenShift = bitsPerSample;
184 client->format.blueShift = bitsPerSample * 2;
186 if(client->format.bitsPerPixel==8*3) {
187 client->format.redShift = bitsPerSample*2;
188 client->format.greenShift = bitsPerSample*1;
189 client->format.blueShift = 0;
191 client->format.redShift = bitsPerSample*3;
192 client->format.greenShift = bitsPerSample*2;
193 client->format.blueShift = bitsPerSample;
198 client->bufoutptr=client->buf;
199 client->buffered=0;
202 client->raw_buffer_size = -1;
203 client->decompStreamInited = FALSE;
206 memset(client->zlibStreamActive,0,sizeof(rfbBool)*4);
207 client->jpegSrcManager = NULL;
211 client->HandleCursorPos = DummyPoint;
212 client->SoftCursorLockArea = DummyRect;
213 client->SoftCursorUnlockScreen = Dummy;
214 client->GotFrameBufferUpdate = DummyRect;
215 client->FinishedFrameBufferUpdate = NULL;
216 client->GetPassword = ReadPassword;
217 client->MallocFrameBuffer = MallocFrameBuffer;
218 client->Bell = Dummy;
219 client->CurrentKeyboardLedState = 0;
220 client->HandleKeyboardLedState = (HandleKeyboardLedStateProc)DummyPoint;
221 client->QoS_DSCP = 0;
223 client->authScheme = 0;
224 client->subAuthScheme = 0;
225 client->GetCredential = NULL;
226 client->tlsSession = NULL;
227 client->sock = -1;
228 client->listenSock = -1;
229 client->listenAddress = NULL;
230 client->listen6Sock = -1;
231 client->listen6Address = NULL;
232 client->clientAuthSchemes = NULL;
233 return client;
236 static rfbBool rfbInitConnection(rfbClient* client)
241 if (!client->listenSpecified) {
242 if (!client->serverHost)
244 if (client->destHost) {
245 if (!ConnectToRFBRepeater(client,client->serverHost,client->serverPort,client->destHost,client->destPort))
248 if (!ConnectToRFBServer(client,client->serverHost,client->serverPort))
255 if (!InitialiseRFBConnection(client))
258 client->width=client->si.framebufferWidth;
259 client->height=client->si.framebufferHeight;
260 if (!client->MallocFrameBuffer(client))
263 if (!SetFormatAndEncodings(client))
266 if (client->updateRect.x < 0) {
267 client->updateRect.x = client->updateRect.y = 0;
268 client->updateRect.w = client->width;
269 client->updateRect.h = client->height;
272 if (client->appData.scaleSetting>1)
274 if (!SendScaleSetting(client, client->appData.scaleSetting))
276 if (!SendFramebufferUpdateRequest(client,
277 client->updateRect.x / client->appData.scaleSetting,
278 client->updateRect.y / client->appData.scaleSetting,
279 client->updateRect.w / client->appData.scaleSetting,
280 client->updateRect.h / client->appData.scaleSetting,
286 if (!SendFramebufferUpdateRequest(client,
287 client->updateRect.x, client->updateRect.y,
288 client->updateRect.w, client->updateRect.h,
296 rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) {
300 if(client->programName==0)
301 client->programName=argv[0];
306 listenForIncomingConnections(client);
309 listenForIncomingConnectionsNoFork(client, -1);
312 client->serverPort = -1;
315 client->appData.encodingsString = argv[i+1];
318 client->appData.compressLevel = atoi(argv[i+1]);
321 client->appData.qualityLevel = atoi(argv[i+1]);
324 client->appData.scaleSetting = atoi(argv[i+1]);
327 client->QoS_DSCP = atoi(argv[i+1]);
332 if(client->destHost)
333 free(client->destHost);
334 client->destPort = 5900;
336 client->destHost = strdup(argv[i+1]);
338 client->destHost[(int)(colon-argv[i+1])] = '\0';
339 client->destPort = atoi(colon+1);
345 if(client->serverHost)
346 free(client->serverHost);
349 client->serverHost = strdup(argv[i]);
350 client->serverHost[(int)(colon-argv[i])] = '\0';
351 client->serverPort = atoi(colon+1);
353 client->serverHost = strdup(argv[i]);
355 if(client->serverPort >= 0 && client->serverPort < 5900)
356 client->serverPort += 5900;
367 if(!rfbInitConnection(client)) {
368 rfbClientCleanup(client);
375 void rfbClientCleanup(rfbClient* client) {
381 if (client->zlibStreamActive[i] == TRUE ) {
382 if (inflateEnd (&client->zlibStream[i]) != Z_OK &&
383 client->zlibStream[i].msg != NULL)
384 rfbClientLog("inflateEnd: %s\n", client->zlibStream[i].msg);
388 if ( client->decompStreamInited == TRUE ) {
389 if (inflateEnd (&client->decompStream) != Z_OK &&
390 client->decompStream.msg != NULL)
391 rfbClientLog("inflateEnd: %s\n", client->decompStream.msg );
394 if (client->jpegSrcManager)
395 free(client->jpegSrcManager);
399 FreeTLS(client);
401 while (client->clientData) {
402 rfbClientData* next = client->clientData->next;
403 free(client->clientData);
404 client->clientData = next;
407 if (client->sock >= 0)
408 close(client->sock);
409 if (client->listenSock >= 0)
410 close(client->listenSock);
411 free(client->desktopName);
412 free(client->serverHost);
413 if (client->destHost)
414 free(client->destHost);
415 if (client->clientAuthSchemes)
416 free(client->clientAuthSchemes);
417 free(client);