/[rdesktop]/sourceforge.net/trunk/rdesktop/cliprdr.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/cliprdr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 391 by forsberg, Fri Jun 6 09:29:01 2003 UTC revision 392 by forsberg, Fri Jun 6 09:30:06 2003 UTC
# Line 505  cliprdr_handle_first_handshake(STREAM s) Line 505  cliprdr_handle_first_handshake(STREAM s)
505          cliprdr_send_format_announce();          cliprdr_send_format_announce();
506  }  }
507    
508  void cliprdr_handle_server_data(uint32 length, STREAM s)  void cliprdr_handle_server_data(uint32 length, uint32 flags, STREAM s)
509  {  {
510          uint32 remaining_length;          static uint32 remaining_length;
511          char *data;          static char *data, *datap;
512          in_uint32_le(s, remaining_length);          static uint32 bytes_left_to_read;
513          data = s->p;          DEBUG_CLIPBOARD(("In cliprdr_handle_server_data, flags is %d\n",
514                             flags));
515            if (3 == flags)  /* One-op write, no packets follows */
516            {
517                    in_uint32_le(s, remaining_length);
518                    data = s->p;
519            } else if (1 == flags) /* First of several packets */
520            {      
521                    in_uint32_le(s, remaining_length);
522                    DEBUG_CLIPBOARD(("Remaining length is %d\n",
523                                     remaining_length));
524                    data = xmalloc(remaining_length);
525                    datap = data;
526                    DEBUG_CLIPBOARD(("Copying first %d bytes\n",
527                                     MAX_CLIPRDR_STANDALONE_DATASIZE));
528                    memcpy(datap, s->p, MAX_CLIPRDR_STANDALONE_DATASIZE);
529    
530                    datap+=MAX_CLIPRDR_STANDALONE_DATASIZE;
531                    bytes_left_to_read = remaining_length-MAX_CLIPRDR_STANDALONE_DATASIZE;
532                    return;
533            } else if (0 == flags)
534            {
535                    DEBUG_CLIPBOARD(("Copying %d middle bytes",
536                                     MAX_CLIPRDR_CONTINUATION_DATASIZE));
537                    memcpy(datap, s->p, MAX_CLIPRDR_CONTINUATION_DATASIZE);
538    
539                    datap+=MAX_CLIPRDR_CONTINUATION_DATASIZE;
540                    bytes_left_to_read-=MAX_CLIPRDR_CONTINUATION_DATASIZE;
541                    return;
542            } else if (2 == flags)
543            {
544                    DEBUG_CLIPBOARD(("Copying last %d bytes\n",
545                                     bytes_left_to_read));
546                    memcpy(datap, s->p, bytes_left_to_read);
547            }
548          XChangeProperty(display,          XChangeProperty(display,
549                          selection_event.requestor,                          selection_event.requestor,
550                          selection_event.property,                          selection_event.property,
# Line 518  void cliprdr_handle_server_data(uint32 l Line 552  void cliprdr_handle_server_data(uint32 l
552                          8,                          8,
553                          PropModeAppend,                          PropModeAppend,
554                          data,                          data,
555                          remaining_length);                          remaining_length-1);
556    
557          XSendEvent(display,          XSendEvent(display,
558                     selection_event.requestor,                     selection_event.requestor,
559                     False,                     False,
560                     NoEventMask,                     NoEventMask,
561                     (XEvent *)&selection_event);                     (XEvent *)&selection_event);
562            
563            if (flags & 0x12)
564                    xfree(data);
565    
566  }  }
567    
# Line 579  void cliprdr_callback(STREAM s, uint16 c Line 615  void cliprdr_callback(STREAM s, uint16 c
615          clipboard_channelno = channelno;          clipboard_channelno = channelno;
616          DEBUG_CLIPBOARD(("cliprdr_callback called with channelno %d, clipboard data:\n", channelno));          DEBUG_CLIPBOARD(("cliprdr_callback called with channelno %d, clipboard data:\n", channelno));
617  #ifdef WITH_DEBUG_CLIPBOARD  #ifdef WITH_DEBUG_CLIPBOARD
618          hexdump(s->p, s->end - s->p);          //      hexdump(s->p, s->end - s->p);
619  #endif  #endif
620          in_uint32_le(s, length);          in_uint32_le(s, length);
621          in_uint32_le(s, flags);          in_uint32_le(s, flags);
622    
623          DEBUG_CLIPBOARD(("length is %d, flags are %d\n", length, flags));          DEBUG_CLIPBOARD(("length is %d, flags are %d\n", length, flags));
624    
625          if (flags & 0x03 || flags & 0x01) /* Single-write op or first-packet-of-several op */          if (3 == flags || 1 == flags) /* Single-write op or first-packet-of-several op */
626          {          {
627                  in_uint16_le(s, ptype0);                  in_uint16_le(s, ptype0);
628                  in_uint16_le(s, ptype1);                  in_uint16_le(s, ptype1);
# Line 631  void cliprdr_callback(STREAM s, uint16 c Line 667  void cliprdr_callback(STREAM s, uint16 c
667                          return;                          return;
668                  } else if (5 == ptype0 && 1 == ptype1)                  } else if (5 == ptype0 && 1 == ptype1)
669                  {                  {
670                          cliprdr_handle_server_data(length, s);                          cliprdr_handle_server_data(length, flags, s);
671                  } else if (4 == ptype0 && 0 == ptype1)                  } else if (4 == ptype0 && 0 == ptype1)
672                  {                  {
673                          cliprdr_handle_server_data_request(s);                          cliprdr_handle_server_data_request(s);
674                  }                  }
675    
676                                    
677            }
678            else
679            {
680                    DEBUG_CLIPBOARD(("Handling middle or last packet\n"));
681                    cliprdr_handle_server_data(length, flags, s);
682          }          }
683  }  }
684    

Legend:
Removed from v.391  
changed lines
  Added in v.392

  ViewVC Help
Powered by ViewVC 1.1.26