diff --git a/headers/private/support/Url.h b/headers/private/support/Url.h index be1cb32a7e..f7ba3e49a9 100644 --- a/headers/private/support/Url.h +++ b/headers/private/support/Url.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2009, Haiku Inc. All Rights Reserved. + * Copyright 2007-2009 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _URL_H @@ -7,19 +7,21 @@ #include + namespace BPrivate { namespace Support { class BUrl : public BString { public: - BUrl(const char *url); + BUrl(const char* url); ~BUrl(); status_t InitCheck() const; bool HasPreferredApplication() const; BString PreferredApplication() const; - status_t OpenWithPreferredApplication(bool onProblemAskUser = true) const; + status_t OpenWithPreferredApplication( + bool onProblemAskUser = true) const; bool HasHost() const; bool HasPort() const; @@ -27,32 +29,30 @@ public: bool HasPass() const; bool HasPath() const; - BString Proto() const; - BString Full() const; - BString Host() const; - BString Port() const; - BString User() const; - BString Pass() const; - BString Path() const; - - status_t UnurlString(BString &string); + const BString& Proto() const; + const BString& Full() const; + const BString& Host() const; + const BString& Port() const; + const BString& User() const; + const BString& Pass() const; + const BString& Path() const; private: status_t _ParseAndSplit(); BString _UrlMimeType() const; - BString proto; - BString full; - BString host; - BString port; - BString user; - BString pass; - BString path; + BString fProto; + BString fFull; + BString fHost; + BString fPort; + BString fUser; + BString fPass; + BString fPath; status_t fStatus; }; -}; // namespace Support -}; // namespace BPrivate +} // namespace Support +} // namespace BPrivate #endif // _URL_H diff --git a/src/bin/urlwrapper.cpp b/src/bin/urlwrapper.cpp index 7cc8220e35..d04f09e7d4 100644 --- a/src/bin/urlwrapper.cpp +++ b/src/bin/urlwrapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku. All rights reserved. + * Copyright 2007-2009 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -13,8 +13,11 @@ */ #define DEBUG 0 +#include +#include +#include + #include -#include #include #include #include @@ -23,41 +26,13 @@ #include "urlwrapper.h" -const char *kAppSig = APP_SIGNATURE; -const char *kTrackerSig = "application/x-vnd.Be-TRAK"; -#ifdef __HAIKU__ -const char *kTerminalSig = "application/x-vnd.Haiku-Terminal"; -#else -const char *kTerminalSig = "application/x-vnd.Be-SHEL"; -#endif - -#ifdef HANDLE_BESHARE -const char *kBeShareSig = "application/x-vnd.Sugoi-BeShare"; -#endif - -#ifdef HANDLE_IM -const char *kIMSig = "application/x-vnd.m_eiman.sample_im_client"; -#endif - -#ifdef HANDLE_VLC -const char *kVLCSig = "application/x-vnd.videolan-vlc"; -#endif - - -class UrlWrapper : public BApplication -{ -public: - UrlWrapper(); - ~UrlWrapper(); - - virtual void RefsReceived(BMessage *msg); - virtual void ArgvReceived(int32 argc, char **argv); - virtual void ReadyToRun(void); - -private: - status_t _Warn(const char *url); -}; +const char* kAppSig = "application/x-vnd.Haiku-urlwrapper"; +const char* kTrackerSig = "application/x-vnd.Be-TRAK"; +const char* kTerminalSig = "application/x-vnd.Haiku-Terminal"; +const char* kBeShareSig = "application/x-vnd.Sugoi-BeShare"; +const char* kIMSig = "application/x-vnd.m_eiman.sample_im_client"; +const char* kVLCSig = "application/x-vnd.videolan-vlc"; UrlWrapper::UrlWrapper() : BApplication(kAppSig) @@ -70,27 +45,32 @@ UrlWrapper::~UrlWrapper() } -status_t UrlWrapper::_Warn(const char *url) +status_t +UrlWrapper::_Warn(const char* url) { - BString message("An application has requested the system to open the following url: \n"); + BString message("An application has requested the system to open the " + "following url: \n"); message << "\n" << url << "\n\n"; - message << "This type of urls has a potential security risk.\n"; - message << "Proceed anyway ?"; - BAlert *alert = new BAlert("Warning", message.String(), "Ok", "No", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); - int32 v; - v = alert->Go(); - if (v == 0) + message << "This type of URL has a potential security risk.\n"; + message << "Proceed anyway?"; + BAlert* alert = new BAlert("Warning", message.String(), "Proceed", "Stop", NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT); + int32 button; + button = alert->Go(); + if (button == 0) return B_OK; + return B_ERROR; } -void UrlWrapper::RefsReceived(BMessage *msg) +void +UrlWrapper::RefsReceived(BMessage* msg) { char buff[B_PATH_NAME_LENGTH]; int32 index = 0; entry_ref ref; - char *args[] = { "urlwrapper", buff, NULL }; + char* args[] = { const_cast("urlwrapper"), buff, NULL }; status_t err; while (msg->FindRef("refs", index++, &ref) == B_OK) { @@ -100,14 +80,10 @@ void UrlWrapper::RefsReceived(BMessage *msg) if (f.InitCheck() == B_OK && ni.InitCheck() == B_OK) { ni.GetType(mimetype.LockBuffer(B_MIME_TYPE_LENGTH)); mimetype.UnlockBuffer(); -#ifdef HANDLE_URL_FILES - // http://filext.com/file-extension/URL - if (mimetype == "wwwserver/redirection" - || mimetype == "application/internet-shortcut" - || mimetype == "application/x-url" - || mimetype == "message/external-body" - || mimetype == "text/url" - || mimetype == "text/x-url") { + + // Internet Explorer Shortcut + if (mimetype == "text/x-url") { + // http://filext.com/file-extension/URL // http://www.cyanwerks.com/file-format-url.html off_t size; if (f.GetSize(&size) < B_OK) @@ -132,34 +108,34 @@ void UrlWrapper::RefsReceived(BMessage *msg) } } if (url.Length()) { - args[1] = (char *)url.String(); - //ArgvReceived(2, args); - err = be_roster->Launch("application/x-vnd.Be.URL.http", 1, args+1); + args[1] = (char*)url.String(); + err = be_roster->Launch("application/x-vnd.Be.URL.http", 1, + args+1); continue; } } -#endif - /* eat everything as bookmark files */ -#ifdef HANDLE_BOOKMARK_FILES - if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff, B_PATH_NAME_LENGTH) > 0) { - //ArgvReceived(2, args); - err = be_roster->Launch("application/x-vnd.Be.URL.http", 1, args+1); + + // NetPositive Bookmark or any file with a META:url attribute + if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff, + B_PATH_NAME_LENGTH) > 0) { + err = be_roster->Launch("application/x-vnd.Be.URL.http", 1, + args+1); continue; } -#endif } } } -void UrlWrapper::ArgvReceived(int32 argc, char **argv) +void +UrlWrapper::ArgvReceived(int32 argc, char** argv) { if (argc <= 1) return; - const char *failc = " || read -p 'Press any key'"; - const char *pausec = " ; read -p 'Press any key'"; - char *args[] = { "/bin/sh", "-c", NULL, NULL}; + const char* failc = " || read -p 'Press any key'"; + const char* pausec = " ; read -p 'Press any key'"; + char* args[] = { "/bin/sh", "-c", NULL, NULL}; BPrivate::Support::BUrl url(argv[1]); @@ -193,12 +169,13 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) cmd << " " << port; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; - args[2] = (char *)cmd.String(); + args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); return; } - // see draft: http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/ + // see draft: + // http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/ if (proto == "ssh") { BString cmd("ssh "); @@ -209,7 +186,7 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) cmd << host; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; - args[2] = (char *)cmd.String(); + args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; @@ -226,7 +203,7 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) cmd << full; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; - args[2] = (char *)cmd.String(); + args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; @@ -245,7 +222,7 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) cmd << ":" << path; PRINT(("CMD='%s'\n", cmd.String())); cmd << failc; - args[2] = (char *)cmd.String(); + args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; @@ -261,13 +238,12 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) cmd << "@" << host; PRINT(("CMD='%s'\n", cmd.String())); cmd << pausec; - args[2] = (char *)cmd.String(); + args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } -#ifdef HANDLE_HTTP_WGET if (proto == "http") { BString cmd("/bin/wget "); @@ -277,27 +253,23 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) cmd << full; PRINT(("CMD='%s'\n", cmd.String())); cmd << pausec; - args[2] = (char *)cmd.String(); + args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } -#endif -#ifdef HANDLE_FILE if (proto == "file") { BMessage m(B_REFS_RECEIVED); entry_ref ref; - url.UnurlString(path); + _DecodeUrlString(path); if (get_ref_for_path(path.String(), &ref) < B_OK) return; m.AddRef("refs", &ref); be_roster->Launch(kTrackerSig, &m); return; } -#endif -#ifdef HANDLE_QUERY // XXX:TODO: split options if (proto == "query") { // mktemp ? @@ -309,17 +281,20 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) BString s; int32 v; - url.UnurlString(full); + _DecodeUrlString(full); // TODO: handle options (list of attrs in the column, ...) v = 'qybF'; // QuerY By Formula XXX: any #define for that ? query.WriteAttr("_trk/qryinitmode", B_INT32_TYPE, 0LL, &v, sizeof(v)); s = "TextControl"; - query.WriteAttr("_trk/focusedView", B_STRING_TYPE, 0LL, s.String(), s.Length()+1); + query.WriteAttr("_trk/focusedView", B_STRING_TYPE, 0LL, s.String(), + s.Length()+1); s = 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); + 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"; query.WriteAttr("BEOS:TYPE", 'MIMS', 0LL, s.String(), s.Length()+1); @@ -330,29 +305,25 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) be_roster->Launch(&er); return; } -#endif -#ifdef HANDLE_SH if (proto == "sh") { BString cmd(full); if (_Warn(url.String()) != B_OK) return; PRINT(("CMD='%s'\n", cmd.String())); cmd << pausec; - args[2] = (char *)cmd.String(); + args[2] = (char*)cmd.String(); be_roster->Launch(kTerminalSig, 3, args); // TODO: handle errors return; } -#endif -#ifdef HANDLE_BESHARE if (proto == "beshare") { team_id team; BMessenger msgr(kBeShareSig); // if no instance is running, or we want a specific server, start it. if (!msgr.IsValid() || url.HasHost()) { - be_roster->Launch(kBeShareSig, (BMessage *)NULL, &team); + be_roster->Launch(kBeShareSig, (BMessage*)NULL, &team); msgr = BMessenger(NULL, team); } if (url.HasHost()) { @@ -369,36 +340,29 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) // TODO: handle errors return; } -#endif -#ifdef HANDLE_IM if (proto == "icq" || proto == "msn") { // TODO team_id team; - be_roster->Launch(kIMSig, (BMessage *)NULL, &team); + be_roster->Launch(kIMSig, (BMessage*)NULL, &team); BMessenger msgr(NULL, team); if (url.HasHost()) { BMessage mserver(B_REFS_RECEIVED); mserver.AddString("server", host); - msgr.SendMessage(&httpmserver); + msgr.SendMessage(&mserver); } // TODO: handle errors return; } -#endif -#ifdef HANDLE_VLC if (proto == "mms" || proto == "rtp" || proto == "rtsp") { - args[0] = (char *)url.String(); + args[0] = (char*)url.String(); be_roster->Launch(kVLCSig, 1, args); return; } -#endif -#ifdef HANDLE_AUDIO - // TODO -#endif + // Audio: ? // vnc: ? // irc: ? @@ -408,23 +372,52 @@ void UrlWrapper::ArgvReceived(int32 argc, char **argv) // smb: cifsmount ? // nfs: mount_nfs ? // - // mailto: ? but BeMail & Beam both handle it already (not fully though). + // mailto: ? Mail & Beam both handle it already (not fully though). + // + // mid: cid: as per RFC 2392 + // http://www.rfc-editor.org/rfc/rfc2392.txt query MAIL:cid // // itps: pcast: podcast: s//http/ + parse xml to get url to mp3 stream... - // audio: s//http:/ + default MediaPlayer -- see http://forums.winamp.com/showthread.php?threadid=233130 + // audio: s//http:/ + default MediaPlayer + // -- see http://forums.winamp.com/showthread.php?threadid=233130 // // gps: ? I should submit an RFC for that one :) } -void UrlWrapper::ReadyToRun(void) +status_t +UrlWrapper::_DecodeUrlString(BString& string) +{ + // TODO: check for %00 and bail out! + int32 length = string.Length(); + int i; + for (i = 0; string[i] && i < length - 2; i++) { + if (string[i] == '%' && isxdigit(string[i+1]) + && isxdigit(string[i+2])) { + int c; + sscanf(string.String() + i + 1, "%02x", &c); + string.Remove(i, 3); + string.Insert((char)c, 1, i); + length -= 2; + } + } + + return B_OK; +} + + +void +UrlWrapper::ReadyToRun(void) { Quit(); } -int main(int argc, char **argv) +// #pragma mark + + +int main(int argc, char** argv) { UrlWrapper app; if (be_app) diff --git a/src/bin/urlwrapper.h b/src/bin/urlwrapper.h index 49dc806575..30d57e991a 100644 --- a/src/bin/urlwrapper.h +++ b/src/bin/urlwrapper.h @@ -1,47 +1,28 @@ /* - * Copyright 2007, Haiku. All rights reserved. + * Copyright 2007-2009 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. - * - * Authors: - * François Revol, revol@free.fr */ +#ifndef _URL_WRAPPER_H +#define _URL_WRAPPER_H + +#include +#include -#define APP_SIGNATURE "application/x-vnd.Haiku-urlwrapper" -/* NetPositive Bookmark file type */ -#define HANDLE_BOOKMARK_FILES +class UrlWrapper : public BApplication +{ +public: + UrlWrapper(); + ~UrlWrapper(); -/* M$IE .url files */ -#define HANDLE_URL_FILES + virtual void RefsReceived(BMessage* msg); + virtual void ArgvReceived(int32 argc, char** argv); + virtual void ReadyToRun(void); -/* file: redirects to Tracker */ -#define HANDLE_FILE +private: + status_t _Warn(const char* url); + status_t _DecodeUrlString(BString& string); +}; -/* http: downloads with wget in a Terminal */ -#define HANDLE_HTTP_WGET - -/* query: BeOS/Haiku-specific: this should allow putting queries in web pages :) */ -#define HANDLE_QUERY - -/* mid: cid: as per RFC 2392 */ -/* http://www.rfc-editor.org/rfc/rfc2392.txt query MAIL:cid */ -/* UNIMPLEMENTED */ -//#define HANDLE_MID_CID - -/* sh: executes a shell command (before warning user of danger) */ -#define HANDLE_SH - -/* beshare: optionaly connect to a server and start a query */ -#define HANDLE_BESHARE - -/* icq: msn: ... should open im_client to this user */ -/* UNIMPLEMENTED */ -//#define HANDLE_IM - -/* mms: rtp: rtsp: opens the stream with VLC */ -#define HANDLE_VLC - -/* audio: redirects SoundPlay-urls for shoutcast streams */ -/* UNIMPLEMENTED */ -//#define HANDLE_AUDIO +#endif // _URL_WRAPPER_H diff --git a/src/bin/urlwrapper.rdef b/src/bin/urlwrapper.rdef index 10715d2bcb..f74f5b6e10 100644 --- a/src/bin/urlwrapper.rdef +++ b/src/bin/urlwrapper.rdef @@ -1,55 +1,22 @@ -#include "urlwrapper.h" +resource app_signature "application/x-vnd.Haiku-urlwrapper"; -resource app_signature APP_SIGNATURE; -/*resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP | B_ARGV_ONLY;*/ resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP; resource(1, "BEOS:FILE_TYPES") message { -#ifdef HANDLE_BOOKMARK_FILES "types" = "application/x-vnd.Be-bookmark", -#endif -#ifdef HANDLE_URL_FILES - /* setmime -set text/x-url -short "Internet Shortcut" -long "Internet Shortcut File" -sniffRule '0.80 ("[InternetShortcut]")' */ - "types" = "wwwserver/redirection", - "types" = "application/internet-shortcut", - "types" = "application/x-url", - "types" = "message/external-body", - "types" = "text/url", "types" = "text/x-url", -#endif -#ifdef HANDLE_FILE "types" = "application/x-vnd.Be.URL.file", -#endif -#ifdef HANDLE_HTTP_WGET "types" = "application/x-vnd.Be.URL.http", -#endif -#ifdef HANDLE_QUERY "types" = "application/x-vnd.Be.URL.query", -#endif -#ifdef HANDLE_MID_CID - "types" = "application/x-vnd.Be.URL.mid", - "types" = "application/x-vnd.Be.URL.cid", -#endif -#ifdef HANDLE_SH "types" = "application/x-vnd.Be.URL.sh", -#endif -#ifdef HANDLE_BESHARE "types" = "application/x-vnd.Be.URL.beshare", -#endif -#ifdef HANDLE_IM "types" = "application/x-vnd.Be.URL.icq", "types" = "application/x-vnd.Be.URL.msn", -#endif -#ifdef HANDLE_VLC "types" = "application/x-vnd.Be.URL.mms", "types" = "application/x-vnd.Be.URL.rtp", "types" = "application/x-vnd.Be.URL.rtsp", -#endif -#ifdef HANDLE_AUDIO - "types" = "application/x-vnd.Be.URL.audio", -#endif -/* default urls */ +// "types" = "application/x-vnd.Be.URL.audio", "types" = "application/x-vnd.Be.URL.telnet", "types" = "application/x-vnd.Be.URL.ssh", "types" = "application/x-vnd.Be.URL.ftp", diff --git a/src/kits/support/Url.cpp b/src/kits/support/Url.cpp index 96ca4cf090..5f088aa7c4 100644 --- a/src/kits/support/Url.cpp +++ b/src/kits/support/Url.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku. All rights reserved. + * Copyright 2007-2009 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -11,10 +11,6 @@ #define DEBUG 0 -#include -#include -#include - #include #include #include @@ -25,7 +21,7 @@ namespace BPrivate { namespace Support { -BUrl::BUrl(const char *url) +BUrl::BUrl(const char* url) : BString(url) { fStatus = _ParseAndSplit(); @@ -80,12 +76,12 @@ BUrl::OpenWithPreferredApplication(bool onProblemAskUser) const if (Length() > B_PATH_NAME_LENGTH) { // TODO: BAlert // if (onProblemAskUser) - // Balert ... Too long URL! + // BAlert ... Too long URL! fprintf(stderr, "URL too long"); return B_NAME_TOO_LONG; } - char *argv[] = { + char* argv[] = { const_cast("BUrlInvokedApplication"), const_cast(String()), NULL @@ -122,61 +118,62 @@ BUrl::_ParseAndSplit() // TODO: proto and host should be lowercased. // see http://en.wikipedia.org/wiki/URL_normalization - CopyInto(proto, 0, v); + CopyInto(fProto, 0, v); CopyInto(left, v + 1, Length() - v); - // TODO: RFC1738 says the // part should indicate the uri follows the u:p@h:p/path convention, so it should be used to check for special cases. + // TODO: RFC1738 says the // part should indicate the uri follows the + // u:p@h:p/path convention, so it should be used to check for special cases. if (left.FindFirst("//") == 0) left.RemoveFirst("//"); - full = left; + fFull = left; // path part // actually some apps handle file://[host]/path // but I have no idea what proto it implies... // or maybe it's just to emphasize on "localhost". v = left.FindFirst("/"); - if (v == 0 || proto == "file") { - path = left; - return 0; + if (v == 0 || fProto == "file") { + fPath = left; + return B_OK; } // some protos actually implies path if it's the only component - if ((v < 0) && (proto == "beshare" || proto == "irc")) { - path = left; - return 0; + if ((v < 0) && (fProto == "beshare" || fProto == "irc")) { + fPath = left; + return B_OK; } if (v > -1) { - left.MoveInto(path, v+1, left.Length()-v); + left.MoveInto(fPath, v+1, left.Length()-v); left.Remove(v, 1); } // user:pass@host v = left.FindFirst("@"); if (v > -1) { - left.MoveInto(user, 0, v); + left.MoveInto(fUser, 0, v); left.Remove(0, 1); - v = user.FindFirst(":"); + v = fUser.FindFirst(":"); if (v > -1) { - user.MoveInto(pass, v, user.Length() - v); - pass.Remove(0, 1); + fUser.MoveInto(fPass, v, fUser.Length() - v); + fPass.Remove(0, 1); } - } else if (proto == "finger") { + } else if (fProto == "finger") { // single component implies user // see also: http://www.subir.com/lynx/lynx_help/lynx_url_support.html - user = left; - return 0; + fUser = left; + return B_OK; } // host:port v = left.FindFirst(":"); if (v > -1) { - left.MoveInto(port, v + 1, left.Length() - v); + left.MoveInto(fPort, v + 1, left.Length() - v); left.Remove(v, 1); } // not much left... - host = left; + fHost = left; - return 0; + return B_OK; } @@ -184,7 +181,7 @@ BString BUrl::_UrlMimeType() const { BString mime; - mime << "application/x-vnd.Be.URL." << proto; + mime << "application/x-vnd.Be.URL." << fProto; return BString(mime); } @@ -193,107 +190,88 @@ BUrl::_UrlMimeType() const bool BUrl::HasHost() const { - return host.Length(); + return fHost.Length(); } bool BUrl::HasPort() const { - return port.Length(); + return fPort.Length(); } bool BUrl::HasUser() const { - return user.Length(); + return fUser.Length(); } bool BUrl::HasPass() const { - return pass.Length(); + return fPass.Length(); } bool BUrl::HasPath() const { - return path.Length(); + return fPath.Length(); } -BString +const BString& BUrl::Proto() const { - return BString(proto); + return fProto; } -BString +const BString& BUrl::Full() const { // RFC1738's "sheme-part" - return BString(full); + return fFull; } -BString +const BString& BUrl::Host() const { - return BString(host); + return fHost; } -BString +const BString& BUrl::Port() const { - return BString(port); + return fPort; } -BString +const BString& BUrl::User() const { - return BString(user); + return fUser; } -BString +const BString& BUrl::Pass() const { - return BString(pass); + return fPass; } -BString +const BString& BUrl::Path() const { - return BString(path); + return fPath; } -status_t -BUrl::UnurlString(BString &string) -{ - // TODO: check for %00 and bail out! - int32 length = string.Length(); - int i; - for (i = 0; string[i] && i < length - 2; i++) { - if (string[i] == '%' && isxdigit(string[i+1]) && isxdigit(string[i+2])) { - int c; - sscanf(string.String() + i + 1, "%02x", &c); - string.Remove(i, 3); - string.Insert((char)c, 1, i); - length -= 2; - } - } - - return B_OK; -} - -}; // namespace Support -}; // namespace BPrivate +} // namespace Support +} // namespace BPrivate