void received_text_from_clipboard (GtkClipboard *clipboard, const gchar *text, gpointer data) { if (text) SendClientCutText (cl, (char *) text, strlen (text)); }
int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; SendClientCutText(rfb_client, data, strlen(data)); return 0; }
static void SendCutBuffer() { char *str; int len; str = XFetchBytes(dpy, &len); if (!str) return; SendClientCutText(str, len); XFree(str); }
static void GetSelectionCallback(Widget w, XtPointer clientData, Atom* selection, Atom* type, XtPointer value, unsigned long* length, int* format) { int len = *length; char *str = (char *)value; if (str) SendClientCutText(str, len); else SendCutBuffer(); }
void ClientConnection::ProcessLocalClipboardChange() { vnclog.Print(2, _T("Clipboard changed\n")); HWND hOwner = GetClipboardOwner(); if (hOwner == m_hwnd) { vnclog.Print(2, _T("We changed it - ignore!\n")); } else if (!m_initialClipboardSeen) { vnclog.Print(2, _T("Don't send initial clipboard!\n")); m_initialClipboardSeen = true; } else if (!m_opts.m_DisableClipboard) { // The clipboard should not be modified by more than one thread at once omni_mutex_lock l(m_clipMutex); if (OpenClipboard(m_hwnd)) { HGLOBAL hglb = GetClipboardData(CF_TEXT); if (hglb == NULL) { CloseClipboard(); } else { LPSTR lpstr = (LPSTR) GlobalLock(hglb); char *contents = new char[strlen(lpstr) + 1]; char *unixcontents = new char[strlen(lpstr) + 1]; strcpy(contents,lpstr); GlobalUnlock(hglb); CloseClipboard(); // Translate to Unix-format lines before sending int j = 0; for (int i = 0; contents[i] != '\0'; i++) { if (contents[i] != '\x0d') { unixcontents[j++] = contents[i]; } } unixcontents[j] = '\0'; try { SendClientCutText(unixcontents, strlen(unixcontents)); } catch (WarningException &e) { vnclog.Print(0, _T("Exception while sending clipboard text : %s\n"), e.m_info); DestroyWindow(m_hwnd); } delete [] contents; delete [] unixcontents; } } } // Pass the message to the next window in clipboard viewer chain ::SendMessage(m_hwndNextViewer, WM_DRAWCLIPBOARD , 0,0); }
int guac_vnc_clipboard_end_handler(guac_user* user, guac_stream* stream) { guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data; rfbClient* rfb_client = vnc_client->rfb_client; char output_data[GUAC_VNC_CLIPBOARD_MAX_LENGTH]; const char* input = vnc_client->clipboard->buffer; char* output = output_data; guac_iconv_write* writer = vnc_client->clipboard_writer; /* Convert clipboard contents */ guac_iconv(GUAC_READ_UTF8, &input, vnc_client->clipboard->length, writer, &output, sizeof(output_data)); /* Send via VNC only if finished connecting */ if (rfb_client != NULL) SendClientCutText(rfb_client, output_data, output - output_data); return 0; }
void ClientCutEvent::fire(rfbClient* cl) { SendClientCutText(cl, text.toUtf8().data(), text.size()); }
virtual void fire( rfbClient *cl ) { SendClientCutText( cl, m_text, qstrlen( m_text ) ); }
// adzm - 2010-07 - Extended clipboard void ClientConnection::UpdateRemoteClipboard(CARD32 overrideFlags) { // The clipboard should not be modified by more than one thread at once omni_mutex_lock l(m_clipMutex); if (m_clipboard.settings.m_bSupportsEx) { ClipboardData newClipboard; if (newClipboard.Load(NULL)) { if (newClipboard.m_crc == m_clipboard.m_crc && overrideFlags == 0) { vnclog.Print(6, _T("Ignoring extended SendClientCutText due to identical data\n")); return; } m_clipboard.UpdateClipTextEx(newClipboard, overrideFlags); if (m_clipboard.m_bNeedToProvide) { m_clipboard.m_bNeedToProvide = false; int actualLen = m_clipboard.extendedClipboardDataMessage.GetDataLength(); rfbClientCutTextMsg message; memset(&message, 0, sizeof(rfbClientCutTextMsg)); message.type = rfbClientCutText; message.length = Swap32IfLE(-actualLen); //adzm 2010-09 WriteExactQueue((char*)&message, sz_rfbClientCutTextMsg, rfbClientCutText); WriteExact((char*)(m_clipboard.extendedClipboardDataMessage.GetData()), m_clipboard.extendedClipboardDataMessage.GetDataLength()); vnclog.Print(6, _T("Sent extended clipboard\n")); } m_clipboard.extendedClipboardDataMessage.Reset(); } else { vnclog.Print(6, _T("Failed to load local clipboard!\n")); } } else { vnclog.Print(6, _T("Checking clipboard...\n")); if (OpenClipboard(m_hwndcn)) { vnclog.Print(6, _T("Opened...\n")); HGLOBAL hglb = GetClipboardData(CF_TEXT); if (hglb == NULL) { vnclog.Print(6, _T("No CF_TEXT!\n")); CloseClipboard(); } else { vnclog.Print(6, _T("Got CF_TEXT!\n")); LPSTR lpstr = (LPSTR) GlobalLock(hglb); char *contents = new char[strlen(lpstr) + 1]; char *unixcontents = new char[strlen(lpstr) + 1]; strcpy(contents,lpstr); GlobalUnlock(hglb); CloseClipboard(); // Translate to Unix-format lines before sending int j = 0; for (int i = 0; contents[i] != '\0'; i++) { if (contents[i] != '\x0d') { unixcontents[j++] = contents[i]; } } unixcontents[j] = '\0'; try { SendClientCutText(unixcontents, strlen(unixcontents)); } catch (WarningException &e) { vnclog.Print(0, _T("Exception while sending clipboard text : %s\n"), e.m_info); DestroyWindow(m_hwndcn); } delete [] contents; delete [] unixcontents; } } else { vnclog.Print(1, _T("Failed to open clipboard! Last error 0x%08x\n"), GetLastError()); } } }