1 /* 2 * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 3 * Copyright 2005, Jérôme DUVAL. 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 7 #include "InstallerApp.h" 8 9 #include <Alert.h> 10 #include <Button.h> 11 #include <GroupLayoutBuilder.h> 12 #include <Screen.h> 13 #include <ScrollView.h> 14 #include <TextView.h> 15 16 17 static const uint32 kMsgAgree = 'agre'; 18 19 //static const char* kEULAText = 20 //"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n" 21 // 22 //"Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights " 23 //"reserved. The copyright to the Haiku code is property of Haiku, Inc. or of " 24 //"the respective authors where expressly noted in the source.\n\n" 25 // 26 //"Permission is hereby granted, free of charge, to any person obtaining a " 27 //"copy of this software and associated documentation files (the \"Software\"), " 28 //"to deal in the Software without restriction, including without limitation " 29 //"the rights to use, copy, modify, merge, publish, distribute, sublicense, " 30 //"and/or sell copies of the Software, and to permit persons to whom the " 31 //"Software is furnished to do so, subject to the following conditions:\n\n" 32 //"The above copyright notice and this permission notice shall be included in " 33 //"all copies or substantial portions of the Software.\n\n" 34 // 35 //"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS " 36 //"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " 37 //"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " 38 //"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " 39 //"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING " 40 //"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS " 41 //"IN THE SOFTWARE."; 42 43 44 static const char* kInfoText = 45 "Welcome to the Haiku Installer!\n\n" 46 47 "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n" 48 49 "This is alpha-quality software! It means there is a high risk of losing " 50 "important data. Make frequent backups! You have been warned.\n\n" 51 52 "1) If you are installing Haiku onto real hardware (not inside an emulator) " 53 "it is recommended that you have already prepared a hard disk partition. The " 54 "Installer and the DriveSetup tool offer to initialize existing partitions " 55 "with the Haiku native filesystem, but the options to change the actual " 56 "partition layout may not have been tested on a sufficiently great variety of " 57 "computer installations so we do not recommend using it.\n" 58 "If you have not created a partition yet, simply reboot, create the partition " 59 "using whatever tool you feel most comfortable with, and reboot into Haiku to " 60 "continue with the installation. You could for example use the GParted " 61 "Live-CD, it can also resize existing partitions to make room.\n\n" 62 63 "2) The Installer will take no steps to integrate Haiku into an existing boot " 64 "menu. The Haiku partition itself will be made bootable. If you have GRUB " 65 "already installed, edit your /boot/grub/menu.lst by launching your favorite " 66 "editor from a Terminal like this:\n\n" 67 68 "\tsudo <your favorite text editor> /boot/grub/menu.lst\n\n" 69 70 "You'll note that GRUB uses a different naming strategy for hard drives than " 71 "Linux.\n\n" 72 73 "With GRUB it's: (hdN,n)\n\n" 74 75 "All harddisks start with \"hd\"\n" 76 "\"N\" is the hard disk number, starting with \"0\".\n" 77 "\"n\" is the partition number, also starting with \"0\".\n" 78 "The first logical partition always has the number 4, regardless of the " 79 "number of primary partitions.\n\n" 80 81 "So behind the other menu entries towards the bottom of the file, add " 82 "something similar to these lines:\n\n" 83 84 "\t# Haiku on /dev/sda7\n" 85 "\ttitle\t\t\t\tHaiku\n" 86 "\trootnoverify\t\t(hd0,6)\n" 87 "\tchainloader\t\t+1\n\n" 88 89 "You can see the correct partition in GParted for example.\n\n" 90 91 "3) When you successfully boot into Haiku for the first time, make sure to read " 92 "our \"Welcome\" documentation, there is a link on the Desktop.\n\n" 93 94 "Have fun and thanks a lot for trying out Haiku! We hope you like it!" 95 ; 96 97 98 int main(int, char **) 99 { 100 InstallerApp theApp; 101 theApp.Run(); 102 return 0; 103 } 104 105 106 InstallerApp::InstallerApp() 107 : BApplication("application/x-vnd.Haiku-Installer") 108 { 109 } 110 111 112 void 113 InstallerApp::MessageReceived(BMessage* message) 114 { 115 switch (message->what) { 116 case kMsgAgree: 117 fEULAWindow->Lock(); 118 fEULAWindow->Quit(); 119 new InstallerWindow(); 120 break; 121 122 default: 123 BApplication::MessageReceived(message); 124 } 125 } 126 127 128 void 129 InstallerApp::AboutRequested() 130 { 131 BAlert *alert = new BAlert("about", "Installer\n" 132 "\twritten by Jérôme Duval\n" 133 "\tCopyright 2005, Haiku.\n\n", "Ok"); 134 BTextView *view = alert->TextView(); 135 BFont font; 136 137 view->SetStylable(true); 138 139 view->GetFont(&font); 140 font.SetSize(18); 141 font.SetFace(B_BOLD_FACE); 142 view->SetFontAndColor(0, 14, &font); 143 144 alert->Go(); 145 } 146 147 148 void 149 InstallerApp::ReadyToRun() 150 { 151 #if 1 152 // Show the EULA first. 153 BTextView* textView = new BTextView("eula", be_plain_font, NULL, 154 B_WILL_DRAW); 155 textView->SetInsets(10, 10, 10, 10); 156 textView->MakeEditable(false); 157 textView->MakeSelectable(false); 158 textView->SetText(kInfoText); 159 160 BScrollView* scrollView = new BScrollView("eulaScroll", 161 textView, B_WILL_DRAW, false, true); 162 163 BButton* cancelButton = new BButton("Quit", 164 new BMessage(B_QUIT_REQUESTED)); 165 cancelButton->SetTarget(this); 166 167 BButton* continueButton = new BButton("Continue", 168 new BMessage(kMsgAgree)); 169 continueButton->SetTarget(this); 170 continueButton->MakeDefault(true); 171 172 BRect eulaFrame = BRect(0, 0, 600, 450); 173 fEULAWindow = new BWindow(eulaFrame, "README", 174 B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE 175 | B_AUTO_UPDATE_SIZE_LIMITS); 176 177 fEULAWindow->SetLayout(new BGroupLayout(B_HORIZONTAL)); 178 fEULAWindow->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 179 .Add(scrollView) 180 .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 181 .AddGlue() 182 .Add(cancelButton) 183 .Add(continueButton) 184 ) 185 .SetInsets(10, 10, 10, 10) 186 ); 187 188 fEULAWindow->CenterOnScreen(); 189 fEULAWindow->Show(); 190 #else 191 // Show the installer window without EULA. 192 new InstallerWindow(); 193 #endif 194 } 195 196