… | |
… | |
312 | * the caching attribute. |
312 | * the caching attribute. |
313 | * |
313 | * |
314 | */ |
314 | */ |
315 | |
315 | |
316 | void |
316 | void |
317 | SetFaceMode (char *buf, int len, NewSocket * ns) |
317 | SetFaceMode (char *buf, int len, NewSocket *ns) |
318 | { |
318 | { |
319 | char tmp[256]; |
|
|
320 | |
|
|
321 | int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE); |
319 | int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE); |
322 | |
320 | |
323 | if (mode == CF_FACE_NONE) |
321 | if (mode == CF_FACE_NONE) |
324 | { |
|
|
325 | ns->facecache = 1; |
322 | ns->facecache = 1; |
326 | } |
|
|
327 | else if (mode != CF_FACE_PNG) |
323 | else if (mode != CF_FACE_PNG) |
328 | { |
324 | { |
|
|
325 | packet sl; |
329 | sprintf (tmp, "drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png"); |
326 | sl.printf ("drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png"); |
330 | Write_String_To_Socket (ns, tmp, strlen (tmp)); |
327 | ns->send_packet (sl); |
331 | #ifdef ESRV_DEBUG |
|
|
332 | LOG (llevDebug, "SetFaceMode: Invalid mode from client: %d\n", mode); |
|
|
333 | #endif |
|
|
334 | } |
328 | } |
|
|
329 | |
335 | if (mask) |
330 | if (mask) |
336 | { |
|
|
337 | ns->facecache = 1; |
331 | ns->facecache = 1; |
338 | } |
|
|
339 | } |
332 | } |
340 | |
333 | |
341 | /** |
334 | /** |
342 | * Client has requested pixmap that it somehow missed getting. |
335 | * Client has requested pixmap that it somehow missed getting. |
343 | * This will be called often if the client is |
336 | * This will be called often if the client is |
… | |
… | |
372 | { |
365 | { |
373 | LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num); |
366 | LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num); |
374 | return; |
367 | return; |
375 | } |
368 | } |
376 | |
369 | |
377 | SockList sl (MAXSOCKBUF); |
370 | packet sl; |
378 | fallback = get_face_fallback (ns->faceset, face_num); |
371 | fallback = get_face_fallback (ns->faceset, face_num); |
379 | |
372 | |
380 | if (facesets[fallback].faces[face_num].data == NULL) |
373 | if (facesets[fallback].faces[face_num].data == NULL) |
381 | { |
374 | { |
382 | LOG (llevError, "esrv_send_face: faces[%d].data == NULL\n", face_num); |
375 | LOG (llevError, "esrv_send_face: faces[%d].data == NULL\n", face_num); |
… | |
… | |
409 | |
402 | |
410 | Send_With_Handling (ns, &sl); |
403 | Send_With_Handling (ns, &sl); |
411 | } |
404 | } |
412 | |
405 | |
413 | ns->faces_sent[face_num] |= NS_FACESENT_FACE; |
406 | ns->faces_sent[face_num] |= NS_FACESENT_FACE; |
414 | sl.free (); |
|
|
415 | } |
407 | } |
416 | |
408 | |
417 | /** |
409 | /** |
418 | * Sends the number of images, checksum of the face file, |
410 | * Sends the number of images, checksum of the face file, |
419 | * and the image_info file information. See the doc/Developers/protocol |
411 | * and the image_info file information. See the doc/Developers/protocol |
… | |
… | |
421 | */ |
413 | */ |
422 | |
414 | |
423 | void |
415 | void |
424 | send_image_info (NewSocket * ns, char *params) |
416 | send_image_info (NewSocket * ns, char *params) |
425 | { |
417 | { |
426 | SockList sl (MAXSOCKBUF); |
418 | packet sl; |
427 | |
419 | |
428 | sl.printf ("replyinfo image_info\n%d\n%d\n", nrofpixmaps - 1, bmaps_checksum); |
420 | sl.printf ("replyinfo image_info\n%d\n%d\n", nrofpixmaps - 1, bmaps_checksum); |
429 | |
421 | |
430 | for (int i = 0; i < MAX_FACE_SETS; i++) |
422 | for (int i = 0; i < MAX_FACE_SETS; i++) |
431 | if (facesets[i].prefix) |
423 | if (facesets[i].prefix) |
432 | sl.printf ("%d:%s:%s:%d:%s:%s:%s", |
424 | sl.printf ("%d:%s:%s:%d:%s:%s:%s", |
433 | i, facesets[i].prefix, facesets[i].fullname, facesets[i].fallback, |
425 | i, facesets[i].prefix, facesets[i].fullname, facesets[i].fallback, |
434 | facesets[i].size, facesets[i].extension, facesets[i].comment); |
426 | facesets[i].size, facesets[i].extension, facesets[i].comment); |
435 | |
427 | |
436 | Send_With_Handling (ns, &sl); |
428 | Send_With_Handling (ns, &sl); |
437 | sl.free (); |
|
|
438 | } |
429 | } |
439 | |
430 | |
440 | /** |
431 | /** |
441 | * Sends requested face information. |
432 | * Sends requested face information. |
442 | * \param ns socket to send to |
433 | * \param ns socket to send to |
… | |
… | |
450 | send_image_sums (NewSocket * ns, char *params) |
441 | send_image_sums (NewSocket * ns, char *params) |
451 | { |
442 | { |
452 | int start, stop; |
443 | int start, stop; |
453 | char *cp, buf[MAX_BUF]; |
444 | char *cp, buf[MAX_BUF]; |
454 | |
445 | |
455 | SockList sl (MAXSOCKBUF); |
446 | packet sl; |
456 | |
447 | |
457 | start = atoi (params); |
448 | start = atoi (params); |
458 | for (cp = params; *cp != '\0'; cp++) |
449 | for (cp = params; *cp != '\0'; cp++) |
459 | if (*cp == ' ') |
450 | if (*cp == ' ') |
460 | break; |
451 | break; |
461 | |
452 | |
462 | stop = atoi (cp); |
453 | stop = atoi (cp); |
463 | if (stop < start || *cp == '\0' || (stop - start) > 1000 || stop >= nrofpixmaps) |
454 | if (stop < start || *cp == '\0' || (stop - start) > 1000 || stop >= nrofpixmaps) |
464 | { |
455 | { |
465 | sprintf (buf, "replyinfo image_sums %d %d", start, stop); |
456 | sl.printf ("replyinfo image_sums %d %d", start, stop); |
466 | cs_write_string (ns, buf, strlen (buf)); |
457 | ns->send_packet (sl); |
|
|
458 | sl.reset (); |
467 | return; |
459 | return; |
468 | } |
460 | } |
469 | |
461 | |
470 | sl.printf ("replyinfo image_sums %d %d ", start, stop); |
462 | sl.printf ("replyinfo image_sums %d %d ", start, stop); |
471 | |
463 | |
… | |
… | |
484 | /* It would make more sense to catch this pre-emptively in the code above. |
476 | /* It would make more sense to catch this pre-emptively in the code above. |
485 | * however, if this really happens, we probably just want to cut down the |
477 | * however, if this really happens, we probably just want to cut down the |
486 | * size to less than 1000, since that is what we claim the protocol would |
478 | * size to less than 1000, since that is what we claim the protocol would |
487 | * support. |
479 | * support. |
488 | */ |
480 | */ |
489 | if (sl.len >= MAXSOCKBUF) |
481 | if (sl.length () >= MAXSOCKBUF) |
490 | { |
482 | { |
491 | LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.len, MAXSOCKBUF); |
483 | LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.length (), MAXSOCKBUF); |
492 | abort (); |
484 | abort (); |
493 | } |
485 | } |
494 | |
486 | |
495 | Send_With_Handling (ns, &sl); |
487 | Send_With_Handling (ns, &sl); |
496 | sl.free (); |
|
|
497 | } |
488 | } |
498 | |
489 | |