/[rdesktop]/sourceforge.net/trunk/rdesktop/xclip.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/xclip.c

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

revision 1213 by ossman_, Tue Mar 28 13:24:48 2006 UTC revision 1234 by ossman_, Mon May 15 11:38:49 2006 UTC
# Line 157  utf16_lf2crlf(uint8 * data, uint32 * siz Line 157  utf16_lf2crlf(uint8 * data, uint32 * siz
157  {  {
158          uint8 *result;          uint8 *result;
159          uint16 *inptr, *outptr;          uint16 *inptr, *outptr;
160            Bool swap_endianess;
161    
162          /* Worst case: Every char is LF */          /* Worst case: Every char is LF */
163          result = xmalloc((*size * 2) + 2);          result = xmalloc((*size * 2) + 2);
# Line 167  utf16_lf2crlf(uint8 * data, uint32 * siz Line 168  utf16_lf2crlf(uint8 * data, uint32 * siz
168          outptr = (uint16 *) result;          outptr = (uint16 *) result;
169    
170          /* Check for a reversed BOM */          /* Check for a reversed BOM */
171          Bool swap_endianess = (*inptr == 0xfffe);          swap_endianess = (*inptr == 0xfffe);
172    
173          while ((uint8 *) inptr < data + *size)          while ((uint8 *) inptr < data + *size)
174          {          {
# Line 292  xclip_send_data_with_convert(uint8 * sou Line 293  xclip_send_data_with_convert(uint8 * sou
293          if (target == format_string_atom ||          if (target == format_string_atom ||
294              target == format_unicode_atom || target == format_utf8_string_atom)              target == format_unicode_atom || target == format_utf8_string_atom)
295          {          {
296                    size_t unicode_buffer_size;
297                    char *unicode_buffer;
298                    iconv_t cd;
299                    size_t unicode_buffer_size_remaining;
300                    char *unicode_buffer_remaining;
301                    char *data_remaining;
302                    size_t data_size_remaining;
303                    uint32 translated_data_size;
304                    uint8 *translated_data;
305    
306                  if (rdp_clipboard_request_format != RDP_CF_TEXT)                  if (rdp_clipboard_request_format != RDP_CF_TEXT)
307                          return False;                          return False;
308    
# Line 300  xclip_send_data_with_convert(uint8 * sou Line 311  xclip_send_data_with_convert(uint8 * sou
311                     to it, so using CF_TEXT is not safe (and is unnecessary, since all                     to it, so using CF_TEXT is not safe (and is unnecessary, since all
312                     WinNT versions are Unicode-minded).                     WinNT versions are Unicode-minded).
313                   */                   */
                 size_t unicode_buffer_size;  
                 char *unicode_buffer;  
                 iconv_t cd;  
   
314                  if (target == format_string_atom)                  if (target == format_string_atom)
315                  {                  {
316                          char *locale_charset = nl_langinfo(CODESET);                          char *locale_charset = nl_langinfo(CODESET);
# Line 342  xclip_send_data_with_convert(uint8 * sou Line 349  xclip_send_data_with_convert(uint8 * sou
349                  }                  }
350    
351                  unicode_buffer = xmalloc(unicode_buffer_size);                  unicode_buffer = xmalloc(unicode_buffer_size);
352                  size_t unicode_buffer_size_remaining = unicode_buffer_size;                  unicode_buffer_size_remaining = unicode_buffer_size;
353                  char *unicode_buffer_remaining = unicode_buffer;                  unicode_buffer_remaining = unicode_buffer;
354                  char *data_remaining = (char *) source;                  data_remaining = (char *) source;
355                  size_t data_size_remaining = source_size;                  data_size_remaining = source_size;
356                  iconv(cd, (ICONV_CONST char **) &data_remaining, &data_size_remaining,                  iconv(cd, (ICONV_CONST char **) &data_remaining, &data_size_remaining,
357                        &unicode_buffer_remaining, &unicode_buffer_size_remaining);                        &unicode_buffer_remaining, &unicode_buffer_size_remaining);
358                  iconv_close(cd);                  iconv_close(cd);
359    
360                  /* translate linebreaks */                  /* translate linebreaks */
361                  uint32 translated_data_size = unicode_buffer_size - unicode_buffer_size_remaining;                  translated_data_size = unicode_buffer_size - unicode_buffer_size_remaining;
362                  uint8 *translated_data =                  translated_data = utf16_lf2crlf((uint8 *) unicode_buffer, &translated_data_size);
                         utf16_lf2crlf((uint8 *) unicode_buffer, &translated_data_size);  
363                  if (translated_data != NULL)                  if (translated_data != NULL)
364                  {                  {
365                          DEBUG_CLIPBOARD(("Sending Unicode string of %d bytes\n",                          DEBUG_CLIPBOARD(("Sending Unicode string of %d bytes\n",
# Line 512  xclip_handle_SelectionNotify(XSelectionE Line 518  xclip_handle_SelectionNotify(XSelectionE
518                  {                  {
519                          res = XGetWindowProperty(g_display, g_wnd,                          res = XGetWindowProperty(g_display, g_wnd,
520                                                   rdesktop_primary_timestamp_target_atom, 0,                                                   rdesktop_primary_timestamp_target_atom, 0,
521                                                   XMaxRequestSize(g_display), False, XA_INTEGER,                                                   XMaxRequestSize(g_display), False, AnyPropertyType,
522                                                   &type, &format, &nitems, &bytes_left, &data);                                                   &type, &format, &nitems, &bytes_left, &data);
523                  }                  }
524                  else                  else
525                  {                  {
526                          res = XGetWindowProperty(g_display, g_wnd,                          res = XGetWindowProperty(g_display, g_wnd,
527                                                   rdesktop_clipboard_timestamp_target_atom, 0,                                                   rdesktop_clipboard_timestamp_target_atom, 0,
528                                                   XMaxRequestSize(g_display), False, XA_INTEGER,                                                   XMaxRequestSize(g_display), False, AnyPropertyType,
529                                                   &type, &format, &nitems, &bytes_left, &data);                                                   &type, &format, &nitems, &bytes_left, &data);
530                  }                  }
531    
532    
533                  if ((res != Success) || (nitems != 1))                  if ((res != Success) || (nitems != 1) || (format != 32))
534                  {                  {
535                          DEBUG_CLIPBOARD(("XGetWindowProperty failed!\n"));                          DEBUG_CLIPBOARD(("XGetWindowProperty failed!\n"));
536                          goto fail;                          goto fail;
# Line 1112  ui_clip_set_mode(const char *optarg) Line 1118  ui_clip_set_mode(const char *optarg)
1118  {  {
1119          g_rdpclip = True;          g_rdpclip = True;
1120    
1121          if (str_startswith(optarg, "auto") || str_startswith(optarg, "on")          if (str_startswith(optarg, "PRIMARYCLIPBOARD"))
             || str_startswith(optarg, "PRIMARYCLIPBOARD"))  
1122                  auto_mode = True;                  auto_mode = True;
1123          else if (str_startswith(optarg, "CLIPBOARD"))          else if (str_startswith(optarg, "CLIPBOARD"))
1124                  auto_mode = False;                  auto_mode = False;
# Line 1173  xclip_init(void) Line 1178  xclip_init(void)
1178          targets[num_targets++] = format_string_atom;          targets[num_targets++] = format_string_atom;
1179          targets[num_targets++] = XA_STRING;          targets[num_targets++] = XA_STRING;
1180  }  }
1181    
1182    void
1183    xclip_deinit(void)
1184    {
1185            if (XGetSelectionOwner(g_display, primary_atom) == g_wnd)
1186                    XSetSelectionOwner(g_display, primary_atom, None, acquire_time);
1187            if (XGetSelectionOwner(g_display, clipboard_atom) == g_wnd)
1188                    XSetSelectionOwner(g_display, clipboard_atom, None, acquire_time);
1189            xclip_notify_change();
1190    }

Legend:
Removed from v.1213  
changed lines
  Added in v.1234

  ViewVC Help
Powered by ViewVC 1.1.26