From d0cab16b9f138d94bb3d6b57d8e4aa6efa73383e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Wed, 12 Aug 2009 13:54:28 +0000 Subject: [PATCH] Make mountvolume a BApplication and set it as the preferred one for opening BFS and (for now) ISO images. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32275 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/Jamfile | 1 + src/bin/mountvolume.cpp | 91 ++++++++++++++++++++-- src/bin/mountvolume.rdef | 10 +++ src/data/beos_mime/application/x-bfs-image | 4 +- src/data/beos_mime/application/x-cd-image | 4 +- 5 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 src/bin/mountvolume.rdef diff --git a/src/bin/Jamfile b/src/bin/Jamfile index d6b93cbf0a..e3827ec79c 100644 --- a/src/bin/Jamfile +++ b/src/bin/Jamfile @@ -14,6 +14,7 @@ ResComp $(haiku-utils_rsrc) : [ FGristFiles haiku-utils.rdef ] ; AddResources fortune : fortune.rdef ; AddResources hey : hey.rdef ; AddResources mimeset : mimeset.rdef ; +AddResources mountvolume : mountvolume.rdef ; AddResources urlwrapper : urlwrapper.rdef ; # standard commands that don't need any additional library diff --git a/src/bin/mountvolume.cpp b/src/bin/mountvolume.cpp index 16ba9fa392..53094ce590 100644 --- a/src/bin/mountvolume.cpp +++ b/src/bin/mountvolume.cpp @@ -1,8 +1,9 @@ /* - * Copyright 2005-2007, Ingo Weinhold, bonefish@users.sf.net. All rights reserved. - * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2005-2007 Ingo Weinhold, bonefish@users.sf.net + * Copyright 2005-2009 Axel Dörfler, axeld@pinc-software.de + * Copyright 2009 Jonas Sundström, jonas@kirilla.se * - * Distributed under the terms of the MIT License. + * All rights reserved. Distributed under the terms of the MIT License. */ @@ -14,6 +15,7 @@ #include #include +#include #include #include #include @@ -288,8 +290,67 @@ struct PrintPartitionsVisitor : public BDiskDeviceVisitor { // #pragma mark - -int -main(int argc, char** argv) +class MountVolume : public BApplication { +public: + MountVolume(); + virtual ~MountVolume(); + + virtual void RefsReceived(BMessage* message); + virtual void ArgvReceived(int32 argc, char** argv); + virtual void ReadyToRun(); +}; + + +MountVolume::MountVolume() + : + BApplication("application/x-vnd.haiku-mountvolume") +{ +} + + +MountVolume::~MountVolume() +{ +} + + +void +MountVolume::RefsReceived(BMessage* message) +{ + status_t status; + int32 refCount; + type_code typeFound; + + status = message->GetInfo("refs", &typeFound, &refCount); + if (status != B_OK || refCount < 1) { + fprintf(stderr, "Failed to get info from entry_refs BMessage: %s\n", + strerror(status)); + exit(1); + } + + entry_ref ref; + BPath path; + + int32 argc = refCount + 1; + char** argv = new char*[argc + 1]; + argv[0] = strdup(kAppName); + + for (int32 i = 0; i < refCount; i++) { + message->FindRef("refs", i, &ref); + status = path.SetTo(&ref); + if (status != B_OK) { + fprintf(stderr, "Failed to get a path (%s) from entry (%s): %s\n", + path.Path(), ref.name, strerror(status)); + } + argv[1 + i] = strdup(path.Path()); + } + argv[argc] = NULL; + + ArgvReceived(argc, argv); +} + + +void +MountVolume::ArgvReceived(int32 argc, char** argv) { MountVisitor mountVisitor; PrintPartitionsVisitor printPartitionsVisitor; @@ -460,5 +521,25 @@ main(int argc, char** argv) deviceList.VisitEachMountablePartition(&printPartitionsVisitor); } + exit(0); +} + + +void +MountVolume::ReadyToRun() +{ + Quit(); +} + + +// #pragma mark - + + +int +main() +{ + MountVolume mountVolume; + mountVolume.Run(); return 0; } + diff --git a/src/bin/mountvolume.rdef b/src/bin/mountvolume.rdef new file mode 100644 index 0000000000..629b2c94b4 --- /dev/null +++ b/src/bin/mountvolume.rdef @@ -0,0 +1,10 @@ +resource app_signature "application/x-vnd.haiku-mountvolume"; + +resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP; + +resource(1, "BEOS:FILE_TYPES") message +{ + "types" = "application/x-bfs-image", + "types" = "application/x-cd-image" +}; + diff --git a/src/data/beos_mime/application/x-bfs-image b/src/data/beos_mime/application/x-bfs-image index b323413047..d9bc2de0ab 100644 --- a/src/data/beos_mime/application/x-bfs-image +++ b/src/data/beos_mime/application/x-bfs-image @@ -14,7 +14,9 @@ resource(5, "META:EXTENS") message(234) { "type" = "application/x-bfs-image" }; -resource(6, "META:ICON") #'VICN' array { +resource(6, "META:PREF_APP") #'MSIG' "application/x-vnd.haiku-mountvolume"; + +resource(7, "META:ICON") #'VICN' array { $"6E636966080500040054020006023B019B3AA235BC243E3C71D248D17C498491" $"00E7BB8FFFC99867020006023BA71138D0C8BBF4B83E90E64AED7C485BD7008A" $"561DFFB57A3A02000602BB6FCBB8D4C839AA71BC3992492FF148D96A00FFC790" diff --git a/src/data/beos_mime/application/x-cd-image b/src/data/beos_mime/application/x-cd-image index a606ebd261..a7794a9411 100644 --- a/src/data/beos_mime/application/x-cd-image +++ b/src/data/beos_mime/application/x-cd-image @@ -11,7 +11,9 @@ resource(3, "META:EXTENS") message(234) { "type" = "application/x-cd-image" }; -resource(4, "META:ICON") #'VICN' array { +resource(4, "META:PREF_APP") #'MSIG' "application/x-vnd.haiku-mountvolume"; + +resource(5, "META:ICON") #'VICN' array { $"6E63696605050002030605B812A5BE03E13DE784B8021049F79F4A16EC00F1F1" $"F136D9DDF48A9996B9B4B8BEDBFFF4F4F404EBD0020006023C92C0388F5FB854" $"503C576348D8DF48C95B004137A9FFB9B9B904017E0402043F2E4E2E302E2242"