Initial commit - from Precise source
[freerdp-ubuntu-pcb-backport.git] / channels / rdpdbg / rdpdbg_main.c
1 /**
2  * FreeRDP: A Remote Desktop Protocol client.
3  * Debugging Virtual Channel
4  *
5  * Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  * Copyright 2011 Vic Lee
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <freerdp/constants.h>
25 #include <freerdp/types.h>
26 #include <freerdp/utils/memory.h>
27 #include <freerdp/utils/svc_plugin.h>
28
29 typedef struct rdpdbg_plugin rdpdbgPlugin;
30 struct rdpdbg_plugin
31 {
32         rdpSvcPlugin plugin;
33 };
34
35 static void rdpdbg_process_connect(rdpSvcPlugin* plugin)
36 {
37         DEBUG_WARN("connecting");
38 }
39
40 static void rdpdbg_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
41 {
42         STREAM* data_out;
43
44         DEBUG_WARN("size %d", stream_get_size(data_in));
45         stream_free(data_in);
46
47         data_out = stream_new(8);
48         stream_write(data_out, "senddata", 8);
49         svc_plugin_send(plugin, data_out);
50 }
51
52 static void rdpdbg_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event)
53 {
54         DEBUG_WARN("event_type %d", event->event_type);
55         freerdp_event_free(event);
56
57         event = freerdp_event_new(RDP_EVENT_CLASS_DEBUG, 0, NULL, NULL);
58         svc_plugin_send_event(plugin, event);
59 }
60
61 static void rdpdbg_process_terminate(rdpSvcPlugin* plugin)
62 {
63         DEBUG_WARN("terminating");
64         xfree(plugin);
65 }
66
67 DEFINE_SVC_PLUGIN(rdpdbg, "rdpdbg",
68         CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP |
69         CHANNEL_OPTION_COMPRESS_RDP | CHANNEL_OPTION_SHOW_PROTOCOL)