summaryrefslogtreecommitdiffstats
path: root/main/remmina/remmina-1.0.0-some-more-clipboard-fixes.patch
blob: ad31d512b5e16aa3c877b20a45dfccecfe4315ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
From 84327f81995b4efe56503b94216e35eb9e99f243 Mon Sep 17 00:00:00 2001
From: Jean-Louis Dupond <jean-louis@dupond.be>
Date: Thu, 3 May 2012 15:25:02 +0200
Subject: [PATCH] Some more clipboard fixes

---
 remmina-plugins/rdp/rdp_cliprdr.c |   68 ++++++++++++++++++++++---------------
 remmina-plugins/rdp/rdp_plugin.c  |    9 +++--
 remmina-plugins/rdp/rdp_plugin.h  |    2 +-
 3 files changed, 48 insertions(+), 31 deletions(-)

diff --git a/remmina-plugins/rdp/rdp_cliprdr.c b/remmina-plugins/rdp/rdp_cliprdr.c
index b9b37ad..1424ac9 100644
--- a/remmina-plugins/rdp/rdp_cliprdr.c
+++ b/remmina-plugins/rdp/rdp_cliprdr.c
@@ -204,7 +204,7 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 	g_printf("GetData: Requested Format: %#X\n", format);
 	rfContext* rfi = GET_DATA(gp);
 	GtkClipboard* clipboard;
-	uint8* inbuf = NULL;
+	uint8* inbuf = (uint8*)"";
 	uint8* outbuf = NULL;
 	GdkPixbuf *image = NULL;
 	
@@ -225,6 +225,8 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 
 	if (format == CB_FORMAT_TEXT || format == CB_FORMAT_HTML || format == CB_FORMAT_UNICODETEXT)
 	{
+		if (inbuf == NULL)
+			inbuf = (uint8*)"";
 		inbuf = lf2crlf(inbuf, size);
 		if (format == CB_FORMAT_TEXT)
 		{
@@ -243,6 +245,7 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 			uniconv = freerdp_uniconv_new();
 			outbuf = (uint8*) freerdp_uniconv_out(uniconv, (char*) inbuf, &out_size);
 			freerdp_uniconv_free(uniconv);
+			g_free(inbuf);
 			*size = out_size + 2;
 		}
 	}
@@ -253,11 +256,13 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 		if (format == CB_FORMAT_PNG)
 		{
 			gdk_pixbuf_save_to_buffer(image, &data, &buffersize, "png", NULL, NULL);
+			outbuf = (uint8*) xmalloc(buffersize);
 			memcpy(outbuf, data, buffersize);
 		}
 		if (format == CB_FORMAT_JPEG)
 		{
 			gdk_pixbuf_save_to_buffer(image, &data, &buffersize, "jpeg", NULL, NULL);
+			outbuf = (uint8*) xmalloc(buffersize);
 			memcpy(outbuf, data, buffersize);
 		}
 		if (format == CB_FORMAT_DIB)
@@ -268,13 +273,9 @@ uint8* remmina_rdp_cliprdr_get_data(RemminaProtocolWidget* gp, uint32 format, in
 			outbuf = (uint8*) xmalloc(*size);
 			memcpy(outbuf, data + 14, *size);
 		}
+		g_object_unref(image);
 	}
 
-	if (inbuf)
-		g_free(inbuf);
-	if (G_IS_OBJECT(image))
-		g_object_unref(image);
-	
 	if (!outbuf)
 		outbuf = (uint8*)"";
 
@@ -357,7 +358,10 @@ void remmina_rdp_cliprdr_parse_response_event(RemminaProtocolWidget* gp, RDP_EVE
 	if (clipboard)
 	{
 		if (text || img)
-			rfi->clipboard_wait = TRUE;
+		{
+			rfi->clipboard_wait = 2;
+			g_printf("Setting Clipboard Wait\n");
+		}
 		if (text)
 		{
 			gtk_clipboard_set_text(clipboard, (gchar*)data, size);
@@ -404,31 +408,39 @@ void remmina_handle_channel_event(RemminaProtocolWidget* gp, RDP_EVENT* event)
 				for (i = 0; i < format_list_event->num_formats; i++)
 				{
 					g_printf("Format: 0x%X\n", format_list_event->formats[i]);
-					if (format_list_event->formats[i] == CB_FORMAT_UNICODETEXT)
-					{
-						format = CB_FORMAT_UNICODETEXT;
-						break;
-					}
-					if (format_list_event->formats[i] == CB_FORMAT_DIB)
-					{
-						format = CB_FORMAT_DIB;
-						break;
-					}
-					if (format_list_event->formats[i] == CB_FORMAT_JPEG)
+				}
+
+				for (i = 0; i < format_list_event->num_formats; i++)
+				{
+					g_printf("Format: 0x%X\n", format_list_event->formats[i]);
+					if (format_list_event->formats[i] > format)
 					{
-						format = CB_FORMAT_JPEG;
-						break;
+						g_printf("Format 0x%X is bigger!\n", format_list_event->formats[i]);
+						if (format_list_event->formats[i] == CB_FORMAT_UNICODETEXT)
+						{
+							format = CB_FORMAT_UNICODETEXT;
+						}
+						if (format_list_event->formats[i] == CB_FORMAT_DIB)
+						{
+							format = CB_FORMAT_DIB;
+						}
+						if (format_list_event->formats[i] == CB_FORMAT_JPEG)
+						{
+							format = CB_FORMAT_JPEG;
+						}
+						if (format_list_event->formats[i] == CB_FORMAT_PNG)
+						{
+							format = CB_FORMAT_PNG;
+						}
+						if (format_list_event->formats[i] == CB_FORMAT_TEXT)
+						{
+							format = CB_FORMAT_TEXT;
+						}
 					}
-					if (format_list_event->formats[i] == CB_FORMAT_PNG)
+					else
 					{
-						format = CB_FORMAT_PNG;
-						break;
+						g_printf("Format 0x%X is smaller!\n", format_list_event->formats[i]);
 					}
-					if (format_list_event->formats[i] == CB_FORMAT_TEXT)
-					{
-						format = CB_FORMAT_TEXT;
-						break;
-					}				
 				}
 				rfi->requested_format = format;
 				
diff --git a/remmina-plugins/rdp/rdp_plugin.c b/remmina-plugins/rdp/rdp_plugin.c
index fd0fe08..3c7fc0a 100644
--- a/remmina-plugins/rdp/rdp_plugin.c
+++ b/remmina-plugins/rdp/rdp_plugin.c
@@ -131,9 +131,14 @@ boolean rf_check_fds(RemminaProtocolWidget* gp)
 						event->mouse_event.x, event->mouse_event.y);
 				break;
 			case REMMINA_RDP_EVENT_TYPE_CLIPBOARD:
-				if (!rfi->clipboard_wait)
+				if (rfi->clipboard_wait <= 0)
+				{
 					remmina_rdp_cliprdr_send_format_list_event(gp);
-				rfi->clipboard_wait = FALSE;
+					g_printf("Clipboard Wait ON\n");
+					rfi->clipboard_wait = 0;
+				}
+				g_printf("Setting Clipboard Wait To FALSE\n");
+				rfi->clipboard_wait--;
 				break;
 		}
 
diff --git a/remmina-plugins/rdp/rdp_plugin.h b/remmina-plugins/rdp/rdp_plugin.h
index 1931384..ff66906 100644
--- a/remmina-plugins/rdp/rdp_plugin.h
+++ b/remmina-plugins/rdp/rdp_plugin.h
@@ -134,7 +134,7 @@ struct rf_context
 	GAsyncQueue* event_queue;
 	gint event_pipe[2];
 
-	gboolean clipboard_wait;
+	gint clipboard_wait;
 	uint32 requested_format;
 };
 
-- 
1.7.10