fe7907f3e8fc842b88425f3eeac559e130e2c74a
[platform/framework/web/web-provider.git] / src / Core / BoxState.cpp
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://floralicense.org/license/
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file    BoxState.cpp
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #include "IBoxContext.h"
21 #include "IBoxState.h"
22 #include "BoxState.h"
23
24 // BoxState
25 void BoxState::switchState()
26 {
27     // TODO this creation may be wrong..
28     m_context->setState(IBoxStatePtr(this));
29 }
30
31 void BoxState::setContext(IBoxContextPtr context)
32 {
33     m_context = context;
34 }
35
36 IBoxContextPtr BoxState::getContext()
37 {
38     return m_context;
39 }
40
41 // BoxReadyState
42 IBoxStatePtr BoxInitState::permitShow()
43 {
44     return IBoxStatePtr(BoxShowState::create(getContext()));
45 }
46
47 // BoxShowState
48 IBoxStatePtr BoxShowState::permitShow()
49 {
50     // In this case, existing state needn't to be changed
51     return IBoxStatePtr(this);
52 }
53
54 IBoxStatePtr BoxShowState::permitHide()
55 {
56     return IBoxStatePtr(BoxHideState::create(getContext()));
57 }
58
59 IBoxStatePtr BoxShowState::permitOpenPd()
60 {
61     return IBoxStatePtr(BoxOpenPdState::create(getContext()));
62 }
63
64 IBoxStatePtr BoxShowState::permitPause()
65 {
66     return IBoxStatePtr(BoxPauseState::create(getContext()));
67 }
68
69 // BoxHideState
70 IBoxStatePtr BoxHideState::permitShutdown()
71 {
72     // In this case, existing state needn't to be changed
73     // because there is no state to be changed from Hide State
74     return IBoxStatePtr(this);
75 }
76
77 // BoxOpenPdState
78 IBoxStatePtr BoxOpenPdState::permitClosePd()
79 {
80     return IBoxStatePtr(BoxClosePdState::create(getContext()));
81 }
82
83 // BoxClosePdState
84 IBoxStatePtr BoxClosePdState::permitShow()
85 {
86     return IBoxStatePtr(BoxShowState::create(getContext()));
87 }
88
89 // BoxPauseState
90 IBoxStatePtr BoxPauseState::permitResume()
91 {
92     return IBoxStatePtr(BoxResumeState::create(getContext()));
93 }
94
95 IBoxStatePtr BoxPauseState::permitHide()
96 {
97     return IBoxStatePtr(BoxHideState::create(getContext()));
98 }
99
100 // BoxResumeState
101 IBoxStatePtr BoxResumeState::permitShow()
102 {
103     return IBoxStatePtr(BoxShowState::create(getContext()));
104 }
105
106 IBoxStatePtr BoxResumeState::permitHide()
107 {
108     return IBoxStatePtr(BoxHideState::create(getContext()));
109 }