1 /* 2 * Copyright 2010, Stephan Aßmus <superstippi@gmx.de> 3 * Copyright 2020, Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 7 8 #include "BootPrompt.h" 9 10 #include <stdlib.h> 11 12 #include <Catalog.h> 13 #include <LaunchRoster.h> 14 #include <Locale.h> 15 16 #include <syscalls.h> 17 18 19 static int sExitValue; 20 21 22 int 23 main(int, char **) 24 { 25 BootPromptApp app; 26 app.Run(); 27 return sExitValue; 28 } 29 30 31 // #pragma mark - 32 33 34 const char* kAppSignature = "application/x-vnd.Haiku-FirstBootPrompt"; 35 const char* kDeskbarSignature = "application/x-vnd.Be-TSKB"; 36 37 38 BootPromptApp::BootPromptApp() 39 : 40 BApplication(kAppSignature) 41 { 42 } 43 44 45 void 46 BootPromptApp::MessageReceived(BMessage* message) 47 { 48 switch (message->what) { 49 // Booting the desktop or running the installer both result 50 // in sending a B_QUIT_REQUESTED message that ultimately 51 // closes the FirstBootPrompt window. However, according to 52 // BootPromptWindow::QuitRequested(), if the BootPromptWindow 53 // is not running on a desktop and the user decides to close 54 // the window using the button, the user will be asked if 55 // they wish to reboot their system. 56 // 57 // Asking that in the former scenarios would not make much 58 // sense. "dont_reboot" explicitly states that the user does 59 // not wish to reboot their system, which suppresses the 60 // confirm box. 61 case MSG_BOOT_DESKTOP: 62 { 63 BLaunchRoster().Target("desktop"); 64 sExitValue = 1; 65 66 PostMessage(B_QUIT_REQUESTED); 67 break; 68 } 69 case MSG_RUN_INSTALLER: 70 { 71 BLaunchRoster().Target("installer"); 72 sExitValue = 0; 73 74 PostMessage(B_QUIT_REQUESTED); 75 break; 76 } 77 case MSG_REBOOT_REQUESTED: 78 { 79 _kern_shutdown(true); 80 sExitValue = -1; 81 break; 82 } 83 84 default: 85 BApplication::MessageReceived(message); 86 } 87 } 88 89 90 void 91 BootPromptApp::ReadyToRun() 92 { 93 // Prompt the user to select his preferred language. 94 new BootPromptWindow(); 95 } 96 97 98 bool 99 BootPromptApp::QuitRequested() 100 { 101 // Override the default QuitRequested because we don't want to ask the 102 // window. The window QuitRequested is used when closing the window, and 103 // offers to reboot the system. When we get here, it means we got the 104 // message from one of the Desktop/Installer buttons and we should just 105 // exit. 106 return true; 107 } 108