1 |
dev-zero 11/01/05 13:14:18 |
2 |
|
3 |
Added: |
4 |
0001-Added-initial-connection-url-handling-using-the-urip.patch |
5 |
Log: |
6 |
Added uri handling patch. |
7 |
|
8 |
(Portage version: 2.1.9.26/cvs/Linux x86_64) |
9 |
|
10 |
Revision Changes Path |
11 |
1.1 app-emulation/spice/files/0001-Added-initial-connection-url-handling-using-the-urip.patch |
12 |
|
13 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/spice/files/0001-Added-initial-connection-url-handling-using-the-urip.patch?rev=1.1&view=markup |
14 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/spice/files/0001-Added-initial-connection-url-handling-using-the-urip.patch?rev=1.1&content-type=text/plain |
15 |
|
16 |
Index: 0001-Added-initial-connection-url-handling-using-the-urip.patch |
17 |
=================================================================== |
18 |
From d885244f70bff899b58f81eb4be76d7da3869706 Mon Sep 17 00:00:00 2001 |
19 |
From: Tiziano Mueller <dev-zero@g.o> |
20 |
Date: Fri, 24 Dec 2010 13:23:23 +0100 |
21 |
Subject: [PATCH] Added initial connection url handling using the uriparser library for |
22 |
proper URI parsing and handling. Can handle port, tls-port and password |
23 |
for now. |
24 |
|
25 |
--- |
26 |
client/application.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ |
27 |
client/application.h | 1 + |
28 |
configure.ac | 19 +++++++++++++++ |
29 |
3 files changed, 81 insertions(+), 0 deletions(-) |
30 |
|
31 |
diff --git a/client/application.cpp b/client/application.cpp |
32 |
index d865e84..a9e86d1 100644 |
33 |
--- a/client/application.cpp |
34 |
+++ b/client/application.cpp |
35 |
@@ -53,6 +53,8 @@ |
36 |
#include <smartcard_channel.h> |
37 |
#endif |
38 |
|
39 |
+#include <uriparser/Uri.h> |
40 |
+ |
41 |
#define STICKY_KEY_PIXMAP ALT_IMAGE_RES_ID |
42 |
#define STICKY_KEY_TIMEOUT 750 |
43 |
|
44 |
@@ -2130,6 +2132,56 @@ bool Application::set_disabled_display_effects(CmdLineParser& parser, char *val, |
45 |
return true; |
46 |
} |
47 |
|
48 |
+bool Application::parse_connection_uri(const char* uri, std::string& host, int& port, int& sport, std::string& password) |
49 |
+{ |
50 |
+ UriParserStateA state; |
51 |
+ UriUriA uri_object; |
52 |
+ |
53 |
+ state.uri = &uri_object; |
54 |
+ |
55 |
+ if (uriParseUriA(&state, uri) != URI_SUCCESS) { |
56 |
+ uriFreeUriMembersA(&uri_object); |
57 |
+ return false; |
58 |
+ } |
59 |
+ |
60 |
+ if ((uri_object.scheme.afterLast != uri_object.scheme.first + 5) || |
61 |
+ (strncmp(uri_object.scheme.first, "spice", 5) != 0)) { |
62 |
+ uriFreeUriMembersA(&uri_object); |
63 |
+ return false; |
64 |
+ } |
65 |
+ |
66 |
+ host.assign(uri_object.hostText.first, uri_object.hostText.afterLast); |
67 |
+ |
68 |
+ UriQueryListA* queryList; |
69 |
+ int itemCount; |
70 |
+ |
71 |
+ if (uriDissectQueryMallocA(&queryList, &itemCount, |
72 |
+ uri_object.query.first, uri_object.query.afterLast) != URI_SUCCESS) { |
73 |
+ uriFreeUriMembersA(&uri_object); |
74 |
+ return false; |
75 |
+ } |
76 |
+ |
77 |
+ for (UriQueryListA* i(queryList); i != NULL; i = i->next) { |
78 |
+ if ((strcmp(i->key, "port") == 0) && (i->value != NULL)) { |
79 |
+ port = str_to_port(i->value); |
80 |
+ continue; |
81 |
+ } |
82 |
+ if ((strcmp(i->key, "tls-port") == 0) && (i->value != NULL)) { |
83 |
+ sport = str_to_port(i->value); |
84 |
+ continue; |
85 |
+ } |
86 |
+ if ((strcmp(i->key, "password") == 0) && (i->value != NULL)) { |
87 |
+ password = i->value; |
88 |
+ continue; |
89 |
+ } |
90 |
+ /* ignore all other parameters for now */ |
91 |
+ } |
92 |
+ |
93 |
+ uriFreeQueryListA(queryList); |
94 |
+ uriFreeUriMembersA(&uri_object); |
95 |
+ return true; |
96 |
+} |
97 |
+ |
98 |
void Application::on_cmd_line_invalid_arg(const char* arg0, const char* what, const char* val) |
99 |
{ |
100 |
Platform::term_printf("%s: invalid %s value %s\n", arg0, what, val); |
101 |
@@ -2185,6 +2237,7 @@ bool Application::process_cmd_line(int argc, char** argv) |
102 |
SPICE_OPT_HOST = CmdLineParser::OPTION_FIRST_AVILABLE, |
103 |
SPICE_OPT_PORT, |
104 |
SPICE_OPT_SPORT, |
105 |
+ SPICE_OPT_URI, |
106 |
SPICE_OPT_PASSWORD, |
107 |
SPICE_OPT_FULL_SCREEN, |
108 |
SPICE_OPT_SECURE_CHANNELS, |
109 |
@@ -2225,6 +2278,7 @@ bool Application::process_cmd_line(int argc, char** argv) |
110 |
parser.add(SPICE_OPT_HOST, "host", "spice server address", "host", true, 'h'); |
111 |
parser.add(SPICE_OPT_PORT, "port", "spice server port", "port", true, 'p'); |
112 |
parser.add(SPICE_OPT_SPORT, "secure-port", "spice server secure port", "port", true, 's'); |
113 |
+ parser.add(SPICE_OPT_URI, "uri", "spice uri", "uri", true); |
114 |
parser.add(SPICE_OPT_SECURE_CHANNELS, "secure-channels", |
115 |
"force secure connection on the specified channels", "channel", |
116 |
true); |
117 |
@@ -2301,6 +2355,13 @@ bool Application::process_cmd_line(int argc, char** argv) |
118 |
} |
119 |
break; |
120 |
} |
121 |
+ case SPICE_OPT_URI: { |
122 |
+ if (parse_connection_uri(val, host, port, sport, password) == false) { |
123 |
+ on_cmd_line_invalid_arg(argv[0], "uri", val); |
124 |
+ return false; |
125 |
+ } |
126 |
+ break; |
127 |
+ } |
128 |
case SPICE_OPT_FULL_SCREEN: |
129 |
if (val) { |
130 |
if (strcmp(val, "auto-conf")) { |
131 |
diff --git a/client/application.h b/client/application.h |
132 |
index f9bbd53..f6ec524 100644 |
133 |
--- a/client/application.h |
134 |
+++ b/client/application.h |
135 |
@@ -289,6 +289,7 @@ private: |
136 |
bool set_canvas_option(CmdLineParser& parser, char *val, const char* arg0); |
137 |
bool set_disabled_display_effects(CmdLineParser& parser, char *val, const char* arg0, |
138 |
DisplaySetting& disp_setting); |
139 |
+ bool parse_connection_uri(const char* uri, std::string& host, int& port, int& sport, std::string& password); |
140 |
void on_cmd_line_invalid_arg(const char* arg0, const char* what, const char* val); |
141 |
bool process_cmd_line(int argc, char** argv); |
142 |
void register_channels(); |
143 |
diff --git a/configure.ac b/configure.ac |
144 |
index 511d94e..ef4d68e 100644 |
145 |
--- a/configure.ac |
146 |
+++ b/configure.ac |
147 |
@@ -297,6 +297,25 @@ AC_SUBST(JPEG_LIBS) |
148 |
AC_CHECK_LIB(z, deflate, Z_LIBS='-lz', AC_MSG_ERROR([zlib not found])) |
149 |
AC_SUBST(Z_LIBS) |
150 |
|
151 |
+URIPARSER_MISSING="Please install uriparser 0.7.5 or later. |
152 |
+ On a Debian-based system enter 'sudo apt-get install liburiparser-dev'." |
153 |
+AC_CHECK_LIB(uriparser, uriParseUriA,, AC_MSG_ERROR(${URIPARSER_MISSING})) |
154 |
+AC_CHECK_HEADER(uriparser/Uri.h,, AC_MSG_ERROR(${URIPARSER_MISSING})) |
155 |
+ |
156 |
+URIPARSER_TOO_OLD="uriparser 0.7.5 or later is required, your copy is too old." |
157 |
+AC_COMPILE_IFELSE([ |
158 |
+#include <uriparser/Uri.h> |
159 |
+#if (defined(URI_VER_MAJOR) && defined(URI_VER_MINOR) && defined(URI_VER_RELEASE) \ |
160 |
+&& ((URI_VER_MAJOR > 0) \ |
161 |
+|| ((URI_VER_MAJOR == 0) && (URI_VER_MINOR > 7)) \ |
162 |
+|| ((URI_VER_MAJOR == 0) && (URI_VER_MINOR == 7) && (URI_VER_RELEASE >= 5)) \ |
163 |
+)) |
164 |
+/* FINE */ |
165 |
+#else |
166 |
+# error uriparser not recent enough |
167 |
+#endif |
168 |
+],,AC_MSG_ERROR(${URIPARSER_TOO_OLD})) |
169 |
+ |
170 |
dnl =========================================================================== |
171 |
dnl check compiler flags |
172 |
|
173 |
-- |
174 |
1.7.3.4 |