From 8dd71c2b234ae80d37330c7721062a667816c3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 4 Apr 2009 16:31:33 +0000 Subject: [PATCH] Implemented UnurlString() and used it. Now you can fully use query: as in query://%28%28MAIL:to==%22%2ahaiku%2a%22%29%26%26%28BEOS:TYPE==%22text/x-email%22%29%29 :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29903 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/urlwrapper.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/bin/urlwrapper.cpp b/src/bin/urlwrapper.cpp index ae09be5aa7..ea4c045ef7 100644 --- a/src/bin/urlwrapper.cpp +++ b/src/bin/urlwrapper.cpp @@ -15,14 +15,16 @@ #include #include #include +#include #include #include #include #include #include + +#include #include #include -#include /* compile-time configuration */ #include "urlwrapper.h" @@ -206,7 +208,19 @@ UrlWrapperApp::~UrlWrapperApp() status_t UrlWrapperApp::UnurlString(BString &s) { - // TODO:WRITEME + // TODO: check for %00 and bail out! + int32 length = s.Length(); + int i; + for (i = 0; s[i] && i < length - 2; i++) { + if (s[i] == '%' && isxdigit(s[i+1]) && isxdigit(s[i+2])) { + int c; + sscanf(s.String() + i + 1, "%02x", &c); + s.Remove(i, 3); + s.Insert((char)c, 1, i); + length -= 2; + } + } + return B_OK; } @@ -423,7 +437,7 @@ void UrlWrapperApp::ArgvReceived(int32 argc, char **argv) if (u.proto == "file") { BMessage m(B_REFS_RECEIVED); entry_ref ref; - // UnurlString(path); + UnurlString(u.path); if (get_ref_for_path(u.path.String(), &ref) < B_OK) return; m.AddRef("refs", &ref); @@ -433,7 +447,7 @@ void UrlWrapperApp::ArgvReceived(int32 argc, char **argv) #endif #ifdef HANDLE_QUERY - // XXX:TODO: unencode the formula + split options + // XXX:TODO: split options if (u.proto == "query") { // mktemp ? BString qname("/tmp/query-url-temp-"); @@ -444,8 +458,7 @@ void UrlWrapperApp::ArgvReceived(int32 argc, char **argv) BString s; int32 v; - // TODO: - // UnurlString(full); + UnurlString(u.full); // TODO: handle options (list of attrs in the column, ...) v = 'qybF'; // QuerY By Formula XXX: any #define for that ? @@ -453,6 +466,7 @@ void UrlWrapperApp::ArgvReceived(int32 argc, char **argv) s = "TextControl"; query.WriteAttr("_trk/focusedView", B_STRING_TYPE, 0LL, s.String(), s.Length()+1); s = u.full; + PRINT(("QUERY='%s'\n", s.String())); query.WriteAttr("_trk/qryinitstr", B_STRING_TYPE, 0LL, s.String(), s.Length()+1); query.WriteAttr("_trk/qrystr", B_STRING_TYPE, 0LL, s.String(), s.Length()+1); s = "application/x-vnd.Be-query";