repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / installer / InstallerApp.cpp
blob41581a0677a281e909f48624e5808b12aa049469
1 /*
2 * Copyright 2015, Axel Dörfler <axeld@pinc-software.de>
3 * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
4 * Copyright 2005, Jérôme DUVAL.
5 * All rights reserved. Distributed under the terms of the MIT License.
6 */
8 #include "InstallerApp.h"
10 #include <unistd.h>
12 #include <Alert.h>
13 #include <Roster.h>
14 #include <TextView.h>
16 #include <syscalls.h>
18 #include "tracker_private.h"
19 #include "Utility.h"
22 static const uint32 kMsgAgree = 'agre';
23 static const uint32 kMsgNext = 'next';
25 //static const char* kEULAText =
26 //"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n"
28 //"Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights "
29 //"reserved. The copyright to the Haiku code is property of Haiku, Inc. or of "
30 //"the respective authors where expressly noted in the source.\n\n"
32 //"Permission is hereby granted, free of charge, to any person obtaining a "
33 //"copy of this software and associated documentation files (the \"Software\"), "
34 //"to deal in the Software without restriction, including without limitation "
35 //"the rights to use, copy, modify, merge, publish, distribute, sublicense, "
36 //"and/or sell copies of the Software, and to permit persons to whom the "
37 //"Software is furnished to do so, subject to the following conditions:\n\n"
38 //"The above copyright notice and this permission notice shall be included in "
39 //"all copies or substantial portions of the Software.\n\n"
41 //"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS "
42 //"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, "
43 //"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE "
44 //"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER "
45 //"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING "
46 //"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS "
47 //"IN THE SOFTWARE.";
50 #undef B_TRANSLATION_CONTEXT
51 #define B_TRANSLATION_CONTEXT "InstallerApp"
54 int main(int, char **)
56 InstallerApp theApp;
57 theApp.Run();
58 return 0;
62 InstallerApp::InstallerApp()
64 BApplication("application/x-vnd.Haiku-Installer")
69 void
70 InstallerApp::MessageReceived(BMessage* message)
72 switch (message->what) {
73 case kMsgAgree:
74 fEULAWindow->Lock();
75 fEULAWindow->Quit();
76 case kMsgNext:
77 new InstallerWindow();
78 break;
80 default:
81 BApplication::MessageReceived(message);
86 void
87 InstallerApp::AboutRequested()
89 BAlert *alert = new BAlert("about", B_TRANSLATE("Installer\n"
90 "\twritten by Jérôme Duval and Stephan Aßmus\n"
91 "\tCopyright 2005-2010, Haiku.\n\n"), B_TRANSLATE("OK"));
92 alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
93 BTextView *view = alert->TextView();
94 BFont font;
96 view->SetStylable(true);
98 view->GetFont(&font);
99 font.SetSize(18);
100 font.SetFace(B_BOLD_FACE);
101 view->SetFontAndColor(0, 9, &font);
103 alert->Go();
107 void
108 InstallerApp::ReadyToRun()
110 #if 1
111 // Show the EULA first.
112 fEULAWindow = new EULAWindow();
113 #else
114 // Show the installer window without EULA.
115 new InstallerWindow();
116 #endif
120 void
121 InstallerApp::Quit()
123 BApplication::Quit();
125 if (!be_roster->IsRunning(kDeskbarSignature)) {
126 // Synchronize disks, and reboot the system
127 sync();
129 if (Utility::IsReadOnlyVolume("/boot")) {
130 // Unblock CD tray, and eject the CD
131 Utility::BlockMedia("/boot", false);
132 Utility::EjectMedia("/boot");
135 // Quickly reboot without possibly touching anything on disk
136 // (which we might just have ejected)
137 _kern_shutdown(true);