drivesetup is a preference. since identical files were already in src/prefs/drivesetup, I am removing these.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1226 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty 2002-09-28 02:29:20 +00:00
parent 75c2064c1a
commit 78dadb1b39
9 changed files with 0 additions and 735 deletions

View File

@ -1,208 +0,0 @@
/*! \file MainWindow.cpp
* \brief Code for the MainWindow class.
*
* Displays the main window, the essence of the app.
*
*/
#ifndef MAIN_WINDOW_H
#include "MainWindow.h"
#endif
/**
* Constructor.
* @param frame The size to make the window.
*/
MainWindow::MainWindow(BRect frame, PosSettings *Settings)
:BWindow(frame, "DriveSetup", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE){
BRect bRect;
BMenu *menu;
BMenu *tmpMenu;
BMenuItem *emptyItem;
fSettings = Settings;
bRect = Bounds();
bRect.bottom = 18.0;
rootMenu = new BMenuBar(bRect, "root menu");
//Setup Mount menu
menu = new BMenu("Mount");
menu->AddItem(new BMenuItem("Mount All Partitions", new BMessage(MOUNT_MOUNT_ALL_MSG), 'M'));
menu->AddSeparatorItem();
rootMenu->AddItem(menu);
//Setup Unmount menu
menu = new BMenu("Unmount");
emptyItem = new BMenuItem("<empty>", NULL);
emptyItem->SetEnabled(false);
menu->AddItem(emptyItem);
rootMenu->AddItem(menu);
//Setup Setup menu
menu = new BMenu("Setup");
menu->AddItem(new BMenuItem("Format", new BMessage(SETUP_FORMAT_MSG), 'F'));
tmpMenu = new BMenu("Partition");
tmpMenu->AddItem(new BMenuItem("apple...", new BMessage(SETUP_PARTITION_APPLE_MSG)));
tmpMenu->AddItem(new BMenuItem("intel...", new BMessage(SETUP_PARTITION_INTEL_MSG)));
menu->AddItem(tmpMenu);
tmpMenu = new BMenu("Initialize");
//add menu for formats
menu->AddItem(tmpMenu);
rootMenu->AddItem(menu);
//Setup Options menu
menu = new BMenu("Options");
menu->AddItem(new BMenuItem("Eject", new BMessage(OPTIONS_EJECT_MSG), 'E'));
menu->AddItem(new BMenuItem("Surface Test", new BMessage(OPTIONS_SURFACE_TEST_MSG), 'T'));
rootMenu->AddItem(menu);
//Setup Rescan menu
menu = new BMenu("Rescan");
menu->AddItem(new BMenuItem("IDE", new BMessage(RESCAN_IDE_MSG)));
menu->AddItem(new BMenuItem("SCSI", new BMessage(RESCAN_SCSI_MSG)));
rootMenu->AddItem(menu);
AddChild(rootMenu);
}
/**
* Handles messages.
* @param message The message recieved by the window.
*/
void MainWindow::MessageReceived(BMessage *message){
switch(message->what){
case MOUNT_MOUNT_ALL_MSG:
printf("MOUNT_MOUNT_ALL_MSG\n");
break;
case MOUNT_MOUNT_SELECTED_MSG:
printf("MOUNT_MOUNT_SELECTED_MSG\n");
break;
case UNMOUNT_UNMOUNT_SELECTED_MSG:
printf("UNMOUNT_UNMOUNT_SELECTED_MSG\n");
break;
case SETUP_FORMAT_MSG:
printf("SETUP_FORMAT_MSG\n");
break;
case SETUP_PARTITION_APPLE_MSG:
printf("SETUP_PARTITION_APPLE_MSG\n");
break;
case SETUP_PARTITION_INTEL_MSG:
printf("SETUP_PARTITION_INTEL_MSG\n");
break;
case SETUP_INITIALIZE_MSG:
printf("SETUP_INITIALIZE_MSG\n");
break;
case OPTIONS_EJECT_MSG:
printf("OPTIONS_EJECT_MSG\n");
break;
case OPTIONS_SURFACE_TEST_MSG:
printf("OPTIONS_SURFACE_TEST_MSG\n");
break;
case RESCAN_IDE_MSG:
printf("RESCAN_IDE_MSG\n");
break;
case RESCAN_SCSI_MSG:
printf("RESCAN_SCSI_MSG\n");
break;
default:
BWindow::MessageReceived(message);
}//switch
}
/**
* Quits and Saves.
* Sets the swap size and turns the virtual memory on by writing to the
* /boot/home/config/settings/kernel/drivers/virtual_memory file.
*/
bool MainWindow::QuitRequested(){
be_app->PostMessage(B_QUIT_REQUESTED);
return(true);
}
void MainWindow::FrameMoved(BPoint origin)
{//MainWindow::FrameMoved
fSettings->SetWindowPosition(Frame());
}//MainWindow::FrameMoved
void MainWindow::AddDeviceInfo(dev_info d){
BMenuItem *tmp;
int cnt;
printf("Got %s\n", d.device);
cnt = 0;
while(cnt < d.numParts){
if(d.parts[cnt].mounted){
//Check to see if we have to get rid of the <empty> item
if(strcmp(rootMenu->SubmenuAt(1)->ItemAt(0)->Label(), "<empty>") == 0){
rootMenu->SubmenuAt(1)->RemoveItem((int32) 0);
}//if
//add to Unmount menu
tmp = new BMenuItem(d.parts[cnt].mount_pt, new BMessage(UNMOUNT_UNMOUNT_SELECTED_MSG));
if(strcmp(d.parts[cnt].mount_pt, "/boot") == 0){
tmp->SetEnabled(false);
}//if
rootMenu->SubmenuAt(1)->AddItem(tmp);
}//if
//add to Mount menu
//This label comes from the type mapping
tmp = new BMenuItem(d.parts[cnt].fs, new BMessage(MOUNT_MOUNT_SELECTED_MSG));
if(d.parts[cnt].mounted){
tmp->SetEnabled(false);
}//if
rootMenu->SubmenuAt(0)->AddItem(tmp);
cnt++;
}//while
//send to view
}//SetDeviceInfo

View File

@ -1,85 +0,0 @@
/*! \file MainWindow.h
\brief Header for the MainWindow class.
*/
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#define MOUNT_MOUNT_ALL_MSG 'mall'
#define MOUNT_MOUNT_SELECTED_MSG 'msel'
#define UNMOUNT_UNMOUNT_SELECTED_MSG 'usel'
#define SETUP_FORMAT_MSG 'sfor'
#define SETUP_PARTITION_APPLE_MSG 'spaa'
#define SETUP_PARTITION_INTEL_MSG 'spai'
#define SETUP_INITIALIZE_MSG 'sini'
#define OPTIONS_EJECT_MSG 'oeje'
#define OPTIONS_SURFACE_TEST_MSG 'osut'
#define RESCAN_IDE_MSG 'ride'
#define RESCAN_SCSI_MSG 'rscs'
#ifndef _APPLICATION_H
#include <Application.h>
#endif
#ifndef _WINDOW_H
#include <Window.h>
#endif
#ifndef _MENU_BAR_H
#include <MenuBar.h>
#endif
#ifndef _MENU_ITEM_H
#include <MenuItem.h>
#endif
#ifndef _RECT_H
#include <Rect.h>
#endif
#ifndef _STDIO_H
#include <stdio.h>
#endif
#ifndef POS_SETTINGS_H
#include "PosSettings.h"
#endif
#ifndef STRUCTS_H
#include "structs.h"
#endif
/**
* The main window of the app.
*
* Sets up and displays everything you need for the app.
*/
class MainWindow : public BWindow{
private:
PosSettings *fSettings;
BMenuBar *rootMenu;
public:
MainWindow(BRect frame, PosSettings *fSettings);
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
virtual void FrameMoved(BPoint origin);
void AddDeviceInfo(dev_info d);
};
#endif

View File

@ -1,94 +0,0 @@
#ifndef POS_SETTINGS_H
#include "PosSettings.h"
#endif
#ifndef _APPLICATION_H
#include <Application.h>
#endif
#ifndef _FILE_H
#include <File.h>
#endif
#ifndef _PATH_H
#include <Path.h>
#endif
#ifndef _FINDDIRECTORY_H
#include <FindDirectory.h>
#endif
#include <stdio.h>
const char PosSettings::kVMSettingsFile[] = "DriveSetup_prefs";
PosSettings::PosSettings()
{//VMSettings::VMSettings
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) == B_OK)
{
path.Append(kVMSettingsFile);
BFile file(path.Path(), B_READ_ONLY);
if (file.InitCheck() != B_OK)
be_app->PostMessage(B_QUIT_REQUESTED);
// Now read in the data
if (file.Read(&fcorner, sizeof(BPoint)) != sizeof(BPoint))
be_app->PostMessage(B_QUIT_REQUESTED);
if (file.Read(&brCorner, sizeof(BPoint)) != sizeof(BPoint))
be_app->PostMessage(B_QUIT_REQUESTED);
}
printf("VM settings file read.\n");
printf("=========================\n");
printf("fcorner read in as ");
fcorner.PrintToStream();
printf("brCorner read in as ");
brCorner.PrintToStream();
fWindowFrame.left=fcorner.x;
fWindowFrame.top=fcorner.y;
fWindowFrame.right=brCorner.x;
fWindowFrame.bottom=brCorner.y;
//Check to see if the co-ords of the window are in the range of the Screen
BScreen screen;
if (screen.Frame().right >= fWindowFrame.right
&& screen.Frame().bottom >= fWindowFrame.bottom)
return;
// If they are not, lets just stick the window in the middle
// of the screen.
//I don't want to deal with this now - MSM
/*fWindowFrame = screen.Frame();
fWindowFrame.left = (fWindowFrame.right-269)/2;
fWindowFrame.right = fWindowFrame.left + 269;
fWindowFrame.top = (fWindowFrame.bottom-172)/2;
fWindowFrame.bottom = fWindowFrame.top + 172;
*/
}//VMSettings::VMSettings
PosSettings::~PosSettings()
{//VMSettings::~VMSettings
//printf("enter\n");
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) < B_OK)
return;
//printf("find_directory\n");
path.Append(kVMSettingsFile);
//printf("path.Append\n");
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
//printf("create file\n");
if (file.InitCheck() == B_OK)
{
//printf("in if statement\n");
file.Write(&fcorner, sizeof(BPoint));
file.Write(&brCorner, sizeof(BPoint));
}
//printf("exit\n");
}//MouseSettings::~MouseSettings
void PosSettings::SetWindowPosition(BRect f)
{//VMSettings::SetWindowFrame
fcorner.x=f.left;
fcorner.y=f.top;
brCorner.x=f.right;
brCorner.y=f.bottom;
brCorner.PrintToStream();
}//VMSettings::SetWindowFrame

View File

@ -1,21 +0,0 @@
#ifndef POS_SETTINGS_H_
#define POS_SETTINGS_H_
#include <SupportDefs.h>
#include <Screen.h>
class PosSettings{
public :
PosSettings();
virtual ~PosSettings();
BRect WindowPosition() const { return fWindowFrame; }
void SetWindowPosition(BRect);
private:
static const char kVMSettingsFile[];
BRect fWindowFrame;
BPoint fcorner;
BPoint brCorner;
};
#endif

View File

@ -1,117 +0,0 @@
/*! \file main.cpp
* \brief Code for the main class.
*
* This file contains the code for the main class. This class sets up all
* of the initial conditions for the app.
*
*/
#ifndef MAIN_WINDOW_H
#include "MainWindow.h"
#endif
#ifndef MAIN_H
#include "main.h"
#endif
/**
* Main method.
*
* Starts the whole thing.
*/
int main(int, char**){
/**
* An instance of the application.
*/
DriveSetup dsApp;
dsApp.Run();
return(0);
}
/*
* Constructor.
*
* Provides a contstructor for the application.
*/
DriveSetup::DriveSetup()
:BApplication("application/x-vnd.MSM-DriveSetupPrefPanel"){
fSettings = new PosSettings();
/*
* The main interface window.
*/
MainWindow *Main;
dev_info devs;
partition_info partitions[4];
Main = new MainWindow(fSettings->WindowPosition(), fSettings);
//This section is to set up defaults that I can use for testing.
//set up floppy drive
partitions[0].type = 11;
partitions[0].fs = "dos";
partitions[0].name = "";
partitions[0].mount_pt = "";
partitions[0].size = 1.4;
partitions[0].mounted = FALSE;
devs.device = "/dev/disk/floppy";
devs.map = 1;
devs.numParts = 1;
devs.parts = partitions;
Main->AddDeviceInfo(devs);
partitions[0].type = 11;
partitions[0].fs = "dos";
partitions[0].name = "winxp";
partitions[0].mount_pt = "/winxp";
partitions[0].size = 5600.0;
partitions[0].mounted = TRUE;
partitions[1].type = 12;
partitions[1].fs = "dos";
partitions[1].name = "windata";
partitions[1].mount_pt = "/windata";
partitions[1].size = 3600.0;
partitions[1].mounted = TRUE;
partitions[2].type = 235;
partitions[2].fs = "Be File System";
partitions[2].name = "BeOS";
partitions[2].mount_pt = "/boot";
partitions[2].size = 4900.0;
partitions[2].mounted = TRUE;
devs.device = "/dev/disk/ide/ata/0/master/0";
devs.map = 1;
devs.numParts = 3;
devs.parts = partitions;
Main->AddDeviceInfo(devs);
partitions[0].type = 11;
partitions[0].fs = "iso9660";
partitions[0].name = "";
partitions[0].mount_pt = "/OUTLAWSTAR_D1";
partitions[0].size = 2200.0;
partitions[0].mounted = TRUE;
devs.device = "/dev/disk/ide/atapi/1/master/0";
devs.map = 2;
devs.numParts = 1;
devs.parts = partitions;
Main->AddDeviceInfo(devs);
//End set up of defaults
Main->Show();
}
DriveSetup::~DriveSetup()
{
delete fSettings;
}

View File

@ -1,53 +0,0 @@
/*! \file main.h
\brief Header file for the main class.
*/
#ifndef MAIN_H
#define MAIN_H
#ifndef _APPLICATION_H
#include <Application.h>
#endif
#ifndef _STDIO_H
#include <stdio.h>
#endif
#ifndef POS_SETTINGS_H
#include "PosSettings.h"
#endif
#ifndef STRUCTS_H
#include "structs.h"
#endif
/**
* Main class.
*
* Gets everything going.
*/
class DriveSetup : public BApplication{
public:
/**
* Constructor.
*/
DriveSetup();
virtual ~DriveSetup();
private:
PosSettings *fSettings;
};
#endif

View File

@ -1,125 +0,0 @@
## BeOS Generic Makefile v2.2 ##
## Fill in this file to specify the project being created, and the referenced
## makefile-engine will do all of the hard work for you. This handles both
## Intel and PowerPC builds of the BeOS.
## Application Specific Settings ---------------------------------------------
# specify the name of the binary
NAME= DriveSetup
# specify the type of binary
# APP: Application
# SHARED: Shared library or add-on
# STATIC: Static library archive
# DRIVER: Kernel Driver
TYPE= APP
# add support for new Pe and Eddie features
# to fill in generic makefile
#%{
# @src->@
# specify the source files to use
# full paths or paths relative to the makefile can be included
# all files, regardless of directory, will have their object
# files created in the common object directory.
# Note that this means this makefile will not work correctly
# if two source files with the same name (source.c or source.cpp)
# are included from different directories. Also note that spaces
# in folder names do not work well with this makefile.
SRCS= main.cpp \
MainWindow.cpp \
PosSettings.cpp
# specify the resource files to use
# full path or a relative path to the resource file can be used.
RSRCS= Resource.rsrc
# @<-src@
#%}
# end support for Pe and Eddie
# specify additional libraries to link against
# there are two acceptable forms of library specifications
# - if your library follows the naming pattern of:
# libXXX.so or libXXX.a you can simply specify XXX
# library: libbe.so entry: be
#
# - if your library does not follow the standard library
# naming scheme you need to specify the path to the library
# and it's name
# library: my_lib.a entry: my_lib.a or path/my_lib.a
LIBS= be
# specify additional paths to directories following the standard
# libXXX.so or libXXX.a naming scheme. You can specify full paths
# or paths relative to the makefile. The paths included may not
# be recursive, so include all of the paths where libraries can
# be found. Directories where source files are found are
# automatically included.
LIBPATHS=
# additional paths to look for system headers
# thes use the form: #include <header>
# source file directories are NOT auto-included here
SYSTEM_INCLUDE_PATHS =
# additional paths to look for local headers
# thes use the form: #include "header"
# source file directories are automatically included
LOCAL_INCLUDE_PATHS =
# specify the level of optimization that you desire
# NONE, SOME, FULL
OPTIMIZE= FULL
# specify any preprocessor symbols to be defined. The symbols will not
# have their values set automatically; you must supply the value (if any)
# to use. For example, setting DEFINES to "DEBUG=1" will cause the
# compiler option "-DDEBUG=1" to be used. Setting DEFINES to "DEBUG"
# would pass "-DDEBUG" on the compiler's command line.
DEFINES=
# specify special warning levels
# if unspecified default warnings will be used
# NONE = supress all warnings
# ALL = enable all warnings
WARNINGS =
# specify whether image symbols will be created
# so that stack crawls in the debugger are meaningful
# if TRUE symbols will be created
SYMBOLS =
# specify debug settings
# if TRUE will allow application to be run from a source-level
# debugger. Note that this will disable all optimzation.
DEBUGGER =
# specify additional compiler flags for all files
COMPILER_FLAGS =
# specify additional linker flags
LINKER_FLAGS =
# specify the version of this particular item
# (for example, -app 3 4 0 d 0 -short 340 -long "340 "`echo -n -e '\302\251'`"1999 GNU GPL")
# This may also be specified in a resource.
APP_VERSION =
# (for TYPE == DRIVER only) Specify desired location of driver in the /dev
# hierarchy. Used by the driverinstall rule. E.g., DRIVER_PATH = video/usb will
# instruct the driverinstall rule to place a symlink to your driver's binary in
# ~/add-ons/kernel/drivers/dev/video/usb, so that your driver will appear at
# /dev/video/usb when loaded. Default is "misc".
DRIVER_PATH =
## include the makefile-engine
include /boot/develop/etc/makefile-engine
zip tar backup:
@zip -y `basename $(NAME)`-`date +%Y-%m-%d`.zip *.[ch]* *.rsrc makefile

View File

@ -1,32 +0,0 @@
/*! \file structs.h
\brief Holds the structs used.
*/
#ifndef STRUCTS_H
#define STRUCTS_H
struct partition_info{
int32 type; /* partition type */
/* Maybe get this from the type mapping? */
char *fs; /* file system */
char *name; /* volume name */
char *mount_pt; /* mounted at */
double size; /* size (in MB) */
bool mounted; /* TRUE if mounted, FALSE if not */
};
struct dev_info{
char *device; /* the path to the device */
int map; /* 0 for none, 1 for intel, 2 for apple */
int numParts; /* number of partitions */
partition_info parts[4]; /* information on the partitions on the device */
};
#endif