16ffb6a6eSJérôme Duval /* 276fb7c29SAxel Dörfler * Copyright 2015, Axel Dörfler <axeld@pinc-software.de> 37ff74a7bSStephan Aßmus * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 47ff74a7bSStephan Aßmus * Copyright 2005, Jérôme DUVAL. 57ff74a7bSStephan Aßmus * All rights reserved. Distributed under the terms of the MIT License. 66ffb6a6eSJérôme Duval */ 76ffb6a6eSJérôme Duval 87ff74a7bSStephan Aßmus #include "InstallerApp.h" 97ff74a7bSStephan Aßmus 1076fb7c29SAxel Dörfler #include <unistd.h> 1176fb7c29SAxel Dörfler 126ffb6a6eSJérôme Duval #include <Alert.h> 1376fb7c29SAxel Dörfler #include <Roster.h> 146ffb6a6eSJérôme Duval #include <TextView.h> 156ffb6a6eSJérôme Duval 1676fb7c29SAxel Dörfler #include <syscalls.h> 1776fb7c29SAxel Dörfler 181565964aSMatt Madia #include "tracker_private.h" 1976fb7c29SAxel Dörfler #include "Utility.h" 201565964aSMatt Madia 216ffb6a6eSJérôme Duval 227ff74a7bSStephan Aßmus static const uint32 kMsgAgree = 'agre'; 23e13de872SFreeman Lou static const uint32 kMsgNext = 'next'; 247ff74a7bSStephan Aßmus 253ac4a739SStephan Aßmus //static const char* kEULAText = 263ac4a739SStephan Aßmus //"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n" 273ac4a739SStephan Aßmus // 283ac4a739SStephan Aßmus //"Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights " 293ac4a739SStephan Aßmus //"reserved. The copyright to the Haiku code is property of Haiku, Inc. or of " 303ac4a739SStephan Aßmus //"the respective authors where expressly noted in the source.\n\n" 313ac4a739SStephan Aßmus // 323ac4a739SStephan Aßmus //"Permission is hereby granted, free of charge, to any person obtaining a " 333ac4a739SStephan Aßmus //"copy of this software and associated documentation files (the \"Software\"), " 343ac4a739SStephan Aßmus //"to deal in the Software without restriction, including without limitation " 353ac4a739SStephan Aßmus //"the rights to use, copy, modify, merge, publish, distribute, sublicense, " 363ac4a739SStephan Aßmus //"and/or sell copies of the Software, and to permit persons to whom the " 373ac4a739SStephan Aßmus //"Software is furnished to do so, subject to the following conditions:\n\n" 383ac4a739SStephan Aßmus //"The above copyright notice and this permission notice shall be included in " 393ac4a739SStephan Aßmus //"all copies or substantial portions of the Software.\n\n" 403ac4a739SStephan Aßmus // 413ac4a739SStephan Aßmus //"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS " 423ac4a739SStephan Aßmus //"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " 433ac4a739SStephan Aßmus //"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " 443ac4a739SStephan Aßmus //"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " 453ac4a739SStephan Aßmus //"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING " 463ac4a739SStephan Aßmus //"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS " 473ac4a739SStephan Aßmus //"IN THE SOFTWARE."; 487ff74a7bSStephan Aßmus 497ff74a7bSStephan Aßmus 50546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT 51546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "InstallerApp" 527ff74a7bSStephan Aßmus 5335d3acb2SJérôme Duval 546ffb6a6eSJérôme Duval int main(int, char **) 556ffb6a6eSJérôme Duval { 566ffb6a6eSJérôme Duval InstallerApp theApp; 576ffb6a6eSJérôme Duval theApp.Run(); 586ffb6a6eSJérôme Duval return 0; 596ffb6a6eSJérôme Duval } 606ffb6a6eSJérôme Duval 617ff74a7bSStephan Aßmus 626ffb6a6eSJérôme Duval InstallerApp::InstallerApp() 634a2da425SStephan Aßmus : 644a2da425SStephan Aßmus BApplication("application/x-vnd.Haiku-Installer") 656ffb6a6eSJérôme Duval { 6653ad1814SJérôme Duval } 6753ad1814SJérôme Duval 687ff74a7bSStephan Aßmus 697ff74a7bSStephan Aßmus void 707ff74a7bSStephan Aßmus InstallerApp::MessageReceived(BMessage* message) 717ff74a7bSStephan Aßmus { 727ff74a7bSStephan Aßmus switch (message->what) { 737ff74a7bSStephan Aßmus case kMsgAgree: 74dcee1c8cSAdrien Destugues fEULAWindow->PostMessage(B_QUIT_REQUESTED); 75*53db2fc8SAdrien Destugues break; 76e13de872SFreeman Lou case kMsgNext: 777ff74a7bSStephan Aßmus new InstallerWindow(); 787ff74a7bSStephan Aßmus break; 797ff74a7bSStephan Aßmus 807ff74a7bSStephan Aßmus default: 817ff74a7bSStephan Aßmus BApplication::MessageReceived(message); 826ffb6a6eSJérôme Duval } 837ff74a7bSStephan Aßmus } 847ff74a7bSStephan Aßmus 856ffb6a6eSJérôme Duval 866ffb6a6eSJérôme Duval void 876ffb6a6eSJérôme Duval InstallerApp::AboutRequested() 886ffb6a6eSJérôme Duval { 89e904ecc9SMatt Madia BAlert *alert = new BAlert("about", B_TRANSLATE("Installer\n" 904a2da425SStephan Aßmus "\twritten by Jérôme Duval and Stephan Aßmus\n" 91e904ecc9SMatt Madia "\tCopyright 2005-2010, Haiku.\n\n"), B_TRANSLATE("OK")); 92aed35104SHumdinger alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); 936ffb6a6eSJérôme Duval BTextView *view = alert->TextView(); 946ffb6a6eSJérôme Duval BFont font; 956ffb6a6eSJérôme Duval 966ffb6a6eSJérôme Duval view->SetStylable(true); 976ffb6a6eSJérôme Duval 986ffb6a6eSJérôme Duval view->GetFont(&font); 996ffb6a6eSJérôme Duval font.SetSize(18); 1006ffb6a6eSJérôme Duval font.SetFace(B_BOLD_FACE); 10137895b5dSJoachim Seemer view->SetFontAndColor(0, 9, &font); 1026ffb6a6eSJérôme Duval 1036ffb6a6eSJérôme Duval alert->Go(); 1046ffb6a6eSJérôme Duval } 1056ffb6a6eSJérôme Duval 1066ffb6a6eSJérôme Duval 1076ffb6a6eSJérôme Duval void 1086ffb6a6eSJérôme Duval InstallerApp::ReadyToRun() 1096ffb6a6eSJérôme Duval { 1107ff74a7bSStephan Aßmus #if 1 1117ff74a7bSStephan Aßmus // Show the EULA first. 112e13de872SFreeman Lou fEULAWindow = new EULAWindow(); 1137ff74a7bSStephan Aßmus #else 1147ff74a7bSStephan Aßmus // Show the installer window without EULA. 1157ff74a7bSStephan Aßmus new InstallerWindow(); 1167ff74a7bSStephan Aßmus #endif 1176ffb6a6eSJérôme Duval } 11876fb7c29SAxel Dörfler 11976fb7c29SAxel Dörfler 12076fb7c29SAxel Dörfler void 12176fb7c29SAxel Dörfler InstallerApp::Quit() 12276fb7c29SAxel Dörfler { 12376fb7c29SAxel Dörfler BApplication::Quit(); 12476fb7c29SAxel Dörfler 12576fb7c29SAxel Dörfler if (!be_roster->IsRunning(kDeskbarSignature)) { 12676fb7c29SAxel Dörfler // Synchronize disks, and reboot the system 12776fb7c29SAxel Dörfler sync(); 12876fb7c29SAxel Dörfler 12976fb7c29SAxel Dörfler if (Utility::IsReadOnlyVolume("/boot")) { 13076fb7c29SAxel Dörfler // Unblock CD tray, and eject the CD 13176fb7c29SAxel Dörfler Utility::BlockMedia("/boot", false); 13276fb7c29SAxel Dörfler Utility::EjectMedia("/boot"); 13376fb7c29SAxel Dörfler } 13476fb7c29SAxel Dörfler 135353af6bfSAxel Dörfler // Quickly reboot without possibly touching anything on disk 13676fb7c29SAxel Dörfler // (which we might just have ejected) 137353af6bfSAxel Dörfler _kern_shutdown(true); 13876fb7c29SAxel Dörfler } 13976fb7c29SAxel Dörfler } 140