vfs: check userland buffers before reading them.
[haiku.git] / src / apps / bootmanager / WizardController.cpp
blobc7e5e5571e45af376e555aec128310f1d0d79553
1 /*
2 * Copyright 2008-2010, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
7 */
10 #include "WizardController.h"
12 #include "WizardView.h"
13 #include "WizardPageView.h"
16 void
17 WizardController::StateStack::MakeEmpty()
19 StateStack* stack = this;
20 StateStack* next;
21 do {
22 next = stack->Next();
23 delete stack;
24 stack = next;
25 } while (next != NULL);
29 WizardController::WizardController()
31 fStack(NULL)
36 WizardController::~WizardController()
38 if (fStack != NULL) {
39 fStack->MakeEmpty();
40 fStack = NULL;
45 void
46 WizardController::Initialize(WizardView* view)
48 if (fStack == NULL)
49 _PushState(InitialState());
50 _ShowPage(view);
54 void
55 WizardController::Next(WizardView* wizard)
57 wizard->PageCompleted();
59 if (fStack == NULL)
60 return;
62 int state = NextState(fStack->State());
63 if (state < 0)
64 return;
66 _PushState(state);
67 _ShowPage(wizard);
71 void
72 WizardController::Previous(WizardView* wizard)
74 wizard->PageCompleted();
76 if (fStack != NULL) {
77 StateStack* stack = fStack;
78 fStack = fStack->Next();
79 delete stack;
81 _ShowPage(wizard);
85 int32
86 WizardController::CurrentState() const
88 if (fStack == NULL)
89 return -1;
91 return fStack->State();
95 void
96 WizardController::_PushState(int32 state)
98 fStack = new StateStack(state, fStack);
102 void
103 WizardController::_ShowPage(WizardView* wizard)
105 if (fStack == NULL)
106 return;
108 WizardPageView* page = CreatePage(fStack->State(), wizard);
109 wizard->SetPage(page);