2 * Copyright (c) 2007-2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
6 * Ćukasz 'Sil2100' Zemczak <sil2100@vexillium.org>
11 #include "PackageWindow.h"
12 #include "UninstallWindow.h"
15 #include <Application.h>
27 #undef B_TRANSLATION_CONTEXT
28 #define B_TRANSLATION_CONTEXT "Packageinstaller main"
31 bool gVerbose
= false;
34 PackageInstaller::PackageInstaller()
36 BApplication("application/x-vnd.Haiku-PackageInstaller"),
42 PackageInstaller::~PackageInstaller()
48 PackageInstaller::ReadyToRun()
50 // We're ready to run - if no windows are yet visible, this means that
51 // we should show the UninstallWindow
52 if (fWindowCount
== 0) {
53 (new UninstallWindow
)->Show();
60 PackageInstaller::RefsReceived(BMessage
* message
)
63 for (int32 i
= 0; message
->FindRef("refs", i
, &ref
) == B_OK
; i
++)
69 PackageInstaller::ArgvReceived(int32 argc
, char** argv
)
71 for (int i
= 1; i
< argc
; i
++) {
72 if (strcmp("--verbose", argv
[i
]) == 0 || strcmp("-v", argv
[i
]) == 0) {
78 if (path
.SetTo(argv
[i
]) != B_OK
) {
79 fprintf(stderr
, B_TRANSLATE("Error! \"%s\" is not a valid path.\n"),
85 status_t ret
= get_ref_for_path(path
.Path(), &ref
);
87 fprintf(stderr
, B_TRANSLATE("Error (%s)! Could not open \"%s\".\n"),
88 strerror(ret
), argv
[i
]);
98 PackageInstaller::MessageReceived(BMessage
* message
)
100 switch (message
->what
) {
105 if (fWindowCount
== 0)
106 PostMessage(B_QUIT_REQUESTED
);
110 BApplication::MessageReceived(message
);
116 PackageInstaller::_NewWindow(const entry_ref
* ref
)
118 PackageWindow
* window
= new PackageWindow(ref
);
128 PackageInstaller app
;