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 */ 7 8 #include "InstallerApp.h" 9 10 #include <unistd.h> 11 12 #include <Alert.h> 13 #include <Roster.h> 14 #include <TextView.h> 15 16 #include <syscalls.h> 17 18 #include "tracker_private.h" 19 #include "Utility.h" 20 21 22 static const uint32 kMsgAgree = 'agre'; 23 static const uint32 kMsgNext = 'next'; 24 25 //static const char* kEULAText = 26 //"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n" 27 // 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" 31 // 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" 40 // 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."; 48 49 50 #undef B_TRANSLATION_CONTEXT 51 #define B_TRANSLATION_CONTEXT "InstallerApp" 52 53 54 int main(int, char **) 55 { 56 InstallerApp theApp; 57 theApp.Run(); 58 return 0; 59 } 60 61 62 InstallerApp::InstallerApp() 63 : 64 BApplication("application/x-vnd.Haiku-Installer") 65 { 66 } 67 68 69 void 70 InstallerApp::MessageReceived(BMessage* message) 71 { 72 switch (message->what) { 73 case kMsgAgree: 74 fEULAWindow->Lock(); 75 fEULAWindow->Quit(); 76 case kMsgNext: 77 new InstallerWindow(); 78 break; 79 80 default: 81 BApplication::MessageReceived(message); 82 } 83 } 84 85 86 void 87 InstallerApp::AboutRequested() 88 { 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; 95 96 view->SetStylable(true); 97 98 view->GetFont(&font); 99 font.SetSize(18); 100 font.SetFace(B_BOLD_FACE); 101 view->SetFontAndColor(0, 9, &font); 102 103 alert->Go(); 104 } 105 106 107 void 108 InstallerApp::ReadyToRun() 109 { 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 117 } 118 119 120 void 121 InstallerApp::Quit() 122 { 123 BApplication::Quit(); 124 125 if (!be_roster->IsRunning(kDeskbarSignature)) { 126 // Synchronize disks, and reboot the system 127 sync(); 128 129 if (Utility::IsReadOnlyVolume("/boot")) { 130 // Unblock CD tray, and eject the CD 131 Utility::BlockMedia("/boot", false); 132 Utility::EjectMedia("/boot"); 133 } 134 135 // Quickly reboot without possibly touching anything on disk 136 // (which we might just have ejected) 137 _kern_shutdown(true); 138 } 139 } 140