16ffb6a6eSJérôme Duval /* 27ff74a7bSStephan Aßmus * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 37ff74a7bSStephan Aßmus * Copyright 2005, Jérôme DUVAL. 47ff74a7bSStephan Aßmus * All rights reserved. Distributed under the terms of the MIT License. 56ffb6a6eSJérôme Duval */ 66ffb6a6eSJérôme Duval 77ff74a7bSStephan Aßmus #include "InstallerApp.h" 87ff74a7bSStephan Aßmus 96ffb6a6eSJérôme Duval #include <Alert.h> 107ff74a7bSStephan Aßmus #include <Button.h> 117ff74a7bSStephan Aßmus #include <GroupLayoutBuilder.h> 128b7c3f78SJérôme Duval #include <Screen.h> 1335d3acb2SJérôme Duval #include <ScrollView.h> 146ffb6a6eSJérôme Duval #include <TextView.h> 156ffb6a6eSJérôme Duval 166ffb6a6eSJérôme Duval 177ff74a7bSStephan Aßmus static const uint32 kMsgAgree = 'agre'; 187ff74a7bSStephan Aßmus 19*3ac4a739SStephan Aßmus //static const char* kEULAText = 20*3ac4a739SStephan Aßmus //"NOTICE: READ THIS BEFORE INSTALLING OR USING HAIKU\n\n" 21*3ac4a739SStephan Aßmus // 22*3ac4a739SStephan Aßmus //"Copyright " B_UTF8_COPYRIGHT " 2001-2009 The Haiku Project. All rights " 23*3ac4a739SStephan Aßmus //"reserved. The copyright to the Haiku code is property of Haiku, Inc. or of " 24*3ac4a739SStephan Aßmus //"the respective authors where expressly noted in the source.\n\n" 25*3ac4a739SStephan Aßmus // 26*3ac4a739SStephan Aßmus //"Permission is hereby granted, free of charge, to any person obtaining a " 27*3ac4a739SStephan Aßmus //"copy of this software and associated documentation files (the \"Software\"), " 28*3ac4a739SStephan Aßmus //"to deal in the Software without restriction, including without limitation " 29*3ac4a739SStephan Aßmus //"the rights to use, copy, modify, merge, publish, distribute, sublicense, " 30*3ac4a739SStephan Aßmus //"and/or sell copies of the Software, and to permit persons to whom the " 31*3ac4a739SStephan Aßmus //"Software is furnished to do so, subject to the following conditions:\n\n" 32*3ac4a739SStephan Aßmus //"The above copyright notice and this permission notice shall be included in " 33*3ac4a739SStephan Aßmus //"all copies or substantial portions of the Software.\n\n" 34*3ac4a739SStephan Aßmus // 35*3ac4a739SStephan Aßmus //"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS " 36*3ac4a739SStephan Aßmus //"OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " 37*3ac4a739SStephan Aßmus //"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " 38*3ac4a739SStephan Aßmus //"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " 39*3ac4a739SStephan Aßmus //"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING " 40*3ac4a739SStephan Aßmus //"FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS " 41*3ac4a739SStephan Aßmus //"IN THE SOFTWARE."; 427ff74a7bSStephan Aßmus 437ff74a7bSStephan Aßmus 44*3ac4a739SStephan Aßmus static const char* kInfoText = 45*3ac4a739SStephan Aßmus "IMPORTANT INFORMATION BEFORE INSTALLING HAIKU\n\n" 467ff74a7bSStephan Aßmus 47*3ac4a739SStephan Aßmus "This is alpha-quality software! It means there is a high risk of loosing " 48*3ac4a739SStephan Aßmus "important data. Make frequent backups! You have been warned.\n\n" 49*3ac4a739SStephan Aßmus 50*3ac4a739SStephan Aßmus "1) If you are installing Haiku onto real hardware (not inside an emulation) " 51*3ac4a739SStephan Aßmus "you need to have prepared a harddisk partition. The Installer and the " 52*3ac4a739SStephan Aßmus "DriveSetup tool will only offer to initialize existing partitions with the " 53*3ac4a739SStephan Aßmus "Haiku native filesystem. We recommend using the GParted Live-CD, it can also " 54*3ac4a739SStephan Aßmus "resize partitions to make room. We do not feel confident in enabling our own " 55*3ac4a739SStephan Aßmus "code to mess with your harddisk partition table. If you have not created a " 56*3ac4a739SStephan Aßmus "partition yet, simply reboot, create the partition using whatever tool you " 57*3ac4a739SStephan Aßmus "feel most comfortable with, and reboot into Haiku to continue with the " 58*3ac4a739SStephan Aßmus "installation.\n\n" 59*3ac4a739SStephan Aßmus 60*3ac4a739SStephan Aßmus "2) The Installer will take no steps to integrate Haiku into an existig boot " 61*3ac4a739SStephan Aßmus "menu. The Haiku partition itself will be made bootable. If you have GRUB " 62*3ac4a739SStephan Aßmus "already installed, edit your /boot/grub/menu.1st by launching your favorite " 63*3ac4a739SStephan Aßmus "editor from a Terminal like this:\n\n" 64*3ac4a739SStephan Aßmus 65*3ac4a739SStephan Aßmus "\tsudo <your favorite text editor> /boot/grub/menu.lst\n\n" 66*3ac4a739SStephan Aßmus 67*3ac4a739SStephan Aßmus "You'll note that GRUB uses a different naming strategy for hard drives than " 68*3ac4a739SStephan Aßmus "Linux.\n\n" 69*3ac4a739SStephan Aßmus 70*3ac4a739SStephan Aßmus "With GRUB it's: (hdN,n)\n\n" 71*3ac4a739SStephan Aßmus 72*3ac4a739SStephan Aßmus "All harddisks start with \"hd\"\n" 73*3ac4a739SStephan Aßmus "\"N\" is the hard disk number, starting with \"0\".\n" 74*3ac4a739SStephan Aßmus "\"n\" is the partition number, also starting with \"0\".\n" 75*3ac4a739SStephan Aßmus "The first logical partition always has the number 4, regardless of the " 76*3ac4a739SStephan Aßmus "number of primary partitions.\n\n" 77*3ac4a739SStephan Aßmus 78*3ac4a739SStephan Aßmus "So behind the other menu entries towards the bottom of the file, add " 79*3ac4a739SStephan Aßmus "something similar to these lines:\n\n" 80*3ac4a739SStephan Aßmus 81*3ac4a739SStephan Aßmus "\t# Haiku on /dev/sda7\n" 82*3ac4a739SStephan Aßmus "\ttitle\t\t\t\tHaiku\n" 83*3ac4a739SStephan Aßmus "\trootnoverify\t\t(hd0,6)\n" 84*3ac4a739SStephan Aßmus "\tchainloader\t\t+1\n\n" 85*3ac4a739SStephan Aßmus 86*3ac4a739SStephan Aßmus "You can see the correct partition in gparted for example.\n\n" 87*3ac4a739SStephan Aßmus 88*3ac4a739SStephan Aßmus "3) When you successfully boot into Haiku for the first time, make sure to read " 89*3ac4a739SStephan Aßmus "our \"Welcome\" documentation, there is a link on the Desktop.\n\n" 90*3ac4a739SStephan Aßmus 91*3ac4a739SStephan Aßmus "Have fun and thanks a lot for trying out Haiku! We hope you like it!" 92*3ac4a739SStephan Aßmus ; 937ff74a7bSStephan Aßmus 9435d3acb2SJérôme Duval 956ffb6a6eSJérôme Duval int main(int, char **) 966ffb6a6eSJérôme Duval { 976ffb6a6eSJérôme Duval InstallerApp theApp; 986ffb6a6eSJérôme Duval theApp.Run(); 996ffb6a6eSJérôme Duval return 0; 1006ffb6a6eSJérôme Duval } 1016ffb6a6eSJérôme Duval 1027ff74a7bSStephan Aßmus 1036ffb6a6eSJérôme Duval InstallerApp::InstallerApp() 1047ff74a7bSStephan Aßmus : BApplication("application/x-vnd.Haiku-Installer") 1056ffb6a6eSJérôme Duval { 10653ad1814SJérôme Duval } 10753ad1814SJérôme Duval 1087ff74a7bSStephan Aßmus 1097ff74a7bSStephan Aßmus void 1107ff74a7bSStephan Aßmus InstallerApp::MessageReceived(BMessage* message) 1117ff74a7bSStephan Aßmus { 1127ff74a7bSStephan Aßmus switch (message->what) { 1137ff74a7bSStephan Aßmus case kMsgAgree: 1147ff74a7bSStephan Aßmus fEULAWindow->Lock(); 1157ff74a7bSStephan Aßmus fEULAWindow->Quit(); 1167ff74a7bSStephan Aßmus new InstallerWindow(); 1177ff74a7bSStephan Aßmus break; 1187ff74a7bSStephan Aßmus 1197ff74a7bSStephan Aßmus default: 1207ff74a7bSStephan Aßmus BApplication::MessageReceived(message); 1216ffb6a6eSJérôme Duval } 1227ff74a7bSStephan Aßmus } 1237ff74a7bSStephan Aßmus 1246ffb6a6eSJérôme Duval 1256ffb6a6eSJérôme Duval void 1266ffb6a6eSJérôme Duval InstallerApp::AboutRequested() 1276ffb6a6eSJérôme Duval { 1286ffb6a6eSJérôme Duval BAlert *alert = new BAlert("about", "Installer\n" 1296ffb6a6eSJérôme Duval "\twritten by Jérôme Duval\n" 1306ffb6a6eSJérôme Duval "\tCopyright 2005, Haiku.\n\n", "Ok"); 1316ffb6a6eSJérôme Duval BTextView *view = alert->TextView(); 1326ffb6a6eSJérôme Duval BFont font; 1336ffb6a6eSJérôme Duval 1346ffb6a6eSJérôme Duval view->SetStylable(true); 1356ffb6a6eSJérôme Duval 1366ffb6a6eSJérôme Duval view->GetFont(&font); 1376ffb6a6eSJérôme Duval font.SetSize(18); 1386ffb6a6eSJérôme Duval font.SetFace(B_BOLD_FACE); 1396ffb6a6eSJérôme Duval view->SetFontAndColor(0, 14, &font); 1406ffb6a6eSJérôme Duval 1416ffb6a6eSJérôme Duval alert->Go(); 1426ffb6a6eSJérôme Duval } 1436ffb6a6eSJérôme Duval 1446ffb6a6eSJérôme Duval 1456ffb6a6eSJérôme Duval void 1466ffb6a6eSJérôme Duval InstallerApp::ReadyToRun() 1476ffb6a6eSJérôme Duval { 1487ff74a7bSStephan Aßmus #if 1 1497ff74a7bSStephan Aßmus // Show the EULA first. 1507ff74a7bSStephan Aßmus BTextView* textView = new BTextView("eula", be_plain_font, NULL, 1517ff74a7bSStephan Aßmus B_WILL_DRAW); 1527ff74a7bSStephan Aßmus textView->SetInsets(10, 10, 10, 10); 1537ff74a7bSStephan Aßmus textView->MakeEditable(false); 1547ff74a7bSStephan Aßmus textView->MakeSelectable(false); 155*3ac4a739SStephan Aßmus textView->SetText(kInfoText); 1566ffb6a6eSJérôme Duval 1577ff74a7bSStephan Aßmus BScrollView* scrollView = new BScrollView("eulaScroll", 1587ff74a7bSStephan Aßmus textView, B_WILL_DRAW, false, true); 1597ff74a7bSStephan Aßmus 160*3ac4a739SStephan Aßmus BButton* cancelButton = new BButton("Quit", 1617ff74a7bSStephan Aßmus new BMessage(B_QUIT_REQUESTED)); 162*3ac4a739SStephan Aßmus cancelButton->SetTarget(this); 1637ff74a7bSStephan Aßmus 164*3ac4a739SStephan Aßmus BButton* continueButton = new BButton("Continue", 1657ff74a7bSStephan Aßmus new BMessage(kMsgAgree)); 166*3ac4a739SStephan Aßmus continueButton->SetTarget(this); 167*3ac4a739SStephan Aßmus continueButton->MakeDefault(true); 1687ff74a7bSStephan Aßmus 1697ff74a7bSStephan Aßmus BRect eulaFrame = BRect(0, 0, 600, 450); 170*3ac4a739SStephan Aßmus fEULAWindow = new BWindow(eulaFrame, "README", 1717ff74a7bSStephan Aßmus B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE 1727ff74a7bSStephan Aßmus | B_AUTO_UPDATE_SIZE_LIMITS); 1737ff74a7bSStephan Aßmus 1747ff74a7bSStephan Aßmus fEULAWindow->SetLayout(new BGroupLayout(B_HORIZONTAL)); 1757ff74a7bSStephan Aßmus fEULAWindow->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) 1767ff74a7bSStephan Aßmus .Add(scrollView) 1777ff74a7bSStephan Aßmus .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) 1787ff74a7bSStephan Aßmus .AddGlue() 179*3ac4a739SStephan Aßmus .Add(cancelButton) 180*3ac4a739SStephan Aßmus .Add(continueButton) 1817ff74a7bSStephan Aßmus ) 1827ff74a7bSStephan Aßmus .SetInsets(10, 10, 10, 10) 1837ff74a7bSStephan Aßmus ); 1847ff74a7bSStephan Aßmus 1857ff74a7bSStephan Aßmus BRect frame = BScreen().Frame(); 1867ff74a7bSStephan Aßmus fEULAWindow->MoveTo(frame.left + (frame.Width() - eulaFrame.Width()) / 2, 1877ff74a7bSStephan Aßmus frame.top + (frame.Height() - eulaFrame.Height()) / 2); 1887ff74a7bSStephan Aßmus 1897ff74a7bSStephan Aßmus fEULAWindow->Show(); 1907ff74a7bSStephan Aßmus #else 1917ff74a7bSStephan Aßmus // Show the installer window without EULA. 1927ff74a7bSStephan Aßmus new InstallerWindow(); 1937ff74a7bSStephan Aßmus #endif 1946ffb6a6eSJérôme Duval } 1956ffb6a6eSJérôme Duval 196