# limitations under the License.
set(CLIPRDR_SRCS
+ cliprdr_constants.h
+ cliprdr_format.c
+ cliprdr_format.h
cliprdr_main.c
+ cliprdr_main.h
)
add_library(cliprdr SHARED ${CLIPRDR_SRCS})
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol client.
+ * Clipboard Virtual Channel
+ *
+ * Copyright 2009-2011 Jay Sorg
+ * Copyright 2010-2011 Vic Lee
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <freerdp/constants.h>
+#include <freerdp/types.h>
+#include <freerdp/utils/memory.h>
+#include <freerdp/utils/svc_plugin.h>
+
+#include "cliprdr_constants.h"
+#include "cliprdr_main.h"
+#include "cliprdr_format.h"
+
+#define CFSTR_HTML "HTML Format"
+#define CFSTR_PNG "PNG"
+#define CFSTR_JPEG "JFIF"
+#define CFSTR_GIF "GIF"
+
+static void cliprdr_copy_format_name(char* dest, const char* src)
+{
+ while (*src)
+ {
+ *dest = *src++;
+ dest += 2;
+ }
+}
+
+void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, FRDP_CB_FORMAT_LIST_EVENT* cb_event)
+{
+ STREAM* data_out;
+ int i;
+
+ data_out = cliprdr_packet_new(CB_FORMAT_LIST, 0, 36 * cb_event->num_formats);
+
+ for (i = 0; i < cb_event->num_formats; i++)
+ {
+ stream_write_uint32(data_out, cb_event->formats[i]);
+ switch (cb_event->formats[i])
+ {
+ case CB_FORMAT_HTML:
+ cliprdr_copy_format_name(stream_get_tail(data_out), CFSTR_HTML);
+ break;
+ case CB_FORMAT_PNG:
+ cliprdr_copy_format_name(stream_get_tail(data_out), CFSTR_PNG);
+ break;
+ case CB_FORMAT_JPEG:
+ cliprdr_copy_format_name(stream_get_tail(data_out), CFSTR_JPEG);
+ break;
+ case CB_FORMAT_GIF:
+ cliprdr_copy_format_name(stream_get_tail(data_out), CFSTR_GIF);
+ break;
+ }
+ stream_seek(data_out, 32);
+ }
+
+ cliprdr_packet_send(cliprdr, data_out);
+}
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol client.
+ * Clipboard Virtual Channel
+ *
+ * Copyright 2009-2011 Jay Sorg
+ * Copyright 2010-2011 Vic Lee
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CLIPRDR_FORMAT_H
+#define __CLIPRDR_FORMAT_H
+
+void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, FRDP_CB_FORMAT_LIST_EVENT* cb_event);
+
+#endif /* __CLIPRDR_FORMAT_H */
#include "cliprdr_constants.h"
#include "cliprdr_main.h"
+#include "cliprdr_format.h"
STREAM* cliprdr_packet_new(uint16 msgType, uint16 msgFlags, uint32 dataLen)
{
static void cliprdr_process_event(rdpSvcPlugin* plugin, FRDP_EVENT* event)
{
+ switch (event->event_type)
+ {
+ case FRDP_EVENT_TYPE_CB_FORMAT_LIST:
+ cliprdr_process_format_list_event((cliprdrPlugin*)plugin, (FRDP_CB_FORMAT_LIST_EVENT*)event);
+ break;
+
+ default:
+ DEBUG_WARN("unknown event type %d", event->event_type);
+ break;
+ }
+ freerdp_event_free(event);
}
static void cliprdr_process_terminate(rdpSvcPlugin* plugin)
#include <freerdp/constants.h>
#include <freerdp/chanman.h>
#include <freerdp/utils/event.h>
+#include <freerdp/utils/hexdump.h>
#include "test_cliprdr.h"
static int test_rdp_channel_data(rdpInst* inst, int chan_id, char* data, int data_size)
{
printf("chan_id %d data_size %d\n", chan_id, data_size);
+ freerdp_hexdump(data, data_size);
+}
+
+static int event_processed;
+
+static void event_process_callback(FRDP_EVENT* event)
+{
+ printf("Event %d processed.\n", event->event_type);
+ event_processed = 1;
}
void test_cliprdr(void)
rdpSettings settings = { 0 };
rdpInst inst = { 0 };
FRDP_EVENT* event;
+ FRDP_CB_FORMAT_LIST_EVENT* format_list_event;
settings.hostname = "testhost";
inst.settings = &settings;
CU_ASSERT(event->event_type == FRDP_EVENT_TYPE_CB_SYNC);
freerdp_event_free(event);
+ event = freerdp_event_new(FRDP_EVENT_TYPE_CB_FORMAT_LIST, event_process_callback, NULL);
+ format_list_event = (FRDP_CB_FORMAT_LIST_EVENT*)event;
+ format_list_event->num_formats = 2;
+ format_list_event->formats = (uint32*)xmalloc(sizeof(uint32) * 2);
+ format_list_event->formats[0] = CB_FORMAT_TEXT;
+ format_list_event->formats[1] = CB_FORMAT_HTML;
+
+ event_processed = 0;
+ freerdp_chanman_send_event(chan_man, "cliprdr", event);
+ while (!event_processed)
+ {
+ freerdp_chanman_check_fds(chan_man, &inst);
+ }
+
freerdp_chanman_close(chan_man, &inst);
freerdp_chanman_free(chan_man);
}