From 5f29df20b2dcda8f737c1456eac8aa47922131b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Wed, 25 Apr 2007 22:45:12 +0000 Subject: [PATCH] Fix app sig and put it at a single place. Add support for NetPositive bookmarks, so one can for ex place a bookmark on the desktop with an http: dl link for moz with pref app set to urlwrapper. *hint* Korli :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20831 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/urlwrapper.cpp | 21 ++++++++++++++++++++- src/bin/urlwrapper.h | 6 ++++++ src/bin/urlwrapper.rdef | 8 ++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/bin/urlwrapper.cpp b/src/bin/urlwrapper.cpp index 5630045678..2ab85d62bb 100644 --- a/src/bin/urlwrapper.cpp +++ b/src/bin/urlwrapper.cpp @@ -26,7 +26,7 @@ /* compile-time configuration */ #include "urlwrapper.h" -const char *kAppSig = "application/x-vnd.haiku.urlwrapper"; +const char *kAppSig = APP_SIGNATURE; const char *kTrackerSig = "application/x-vnd.Be-TRAK"; #ifdef __HAIKU__ @@ -86,6 +86,7 @@ public: status_t SplitUrl(const char *url, BString &host, BString &port, BString &user, BString &pass, BString &path); status_t UnurlString(BString &s); status_t Warn(const char *url); +virtual void RefsReceived(BMessage *msg); virtual void ArgvReceived(int32 argc, char **argv); virtual void ReadyToRun(void); private: @@ -222,6 +223,24 @@ status_t UrlWrapperApp::Warn(const char *url) return B_ERROR; } +void UrlWrapperApp::RefsReceived(BMessage *msg) +{ + char buff[B_PATH_NAME_LENGTH]; + int32 index = 0; + entry_ref ref; + char *args[] = { "urlwrapper", buff, NULL }; +#ifdef HANDLE_BOOKMARK_FILES + /* eat everything as bookmark files */ + while (msg->FindRef("refs", index++, &ref) == B_OK) { + BFile f(&ref, B_READ_ONLY); + if (f.InitCheck() == B_OK) { + if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff, B_PATH_NAME_LENGTH) > 0) { + ArgvReceived(2, args); + } + } + } +#endif +} void UrlWrapperApp::ArgvReceived(int32 argc, char **argv) { diff --git a/src/bin/urlwrapper.h b/src/bin/urlwrapper.h index f1249ab8d2..1f27e1de9d 100644 --- a/src/bin/urlwrapper.h +++ b/src/bin/urlwrapper.h @@ -10,10 +10,16 @@ * urlwrapper: compile-time configuration of supported protocols. */ +#define APP_SIGNATURE "application/x-vnd.Haiku-urlwrapper" + /* * comment out to disable handling a specific protocol */ + +/* NetPositive Bookmark file type */ +#define HANDLE_BOOKMARK_FILES + /* file: redirects to Tracker */ #define HANDLE_FILE diff --git a/src/bin/urlwrapper.rdef b/src/bin/urlwrapper.rdef index 0e40385fa6..cc1f478940 100644 --- a/src/bin/urlwrapper.rdef +++ b/src/bin/urlwrapper.rdef @@ -1,10 +1,14 @@ #include "urlwrapper.h" -resource app_signature "application/x-vnd.haiku.urlwrapper"; -resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP | B_ARGV_ONLY; +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_FILE "types" = "application/x-vnd.Be.URL.file", #endif