1.Call on lock screen support added 2.Missed calls SEEN and UNSEEN support added...
[apps/osp/Call.git] / src / CallSettingsPresentationModel.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
18  * @file    CallSettingsPresentationModel.cpp
19  * @brief   Setting Presentation model
20  */
21 #include "CallSettingsConstants.h"
22 #include "CallSettingsManager.h"
23 #include "CallSettingsPresentationModel.h"
24 #include "CallPresentationModel.h"
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Social;
29
30 SettingsPresentationModel* SettingsPresentationModel::__pInstance = null;
31
32 SettingsPresentationModel::SettingsPresentationModel()
33 {
34         __pSettingsMgr = null;
35         __pSettingsEventListener = null;
36 }
37
38 SettingsPresentationModel::~SettingsPresentationModel()
39 {
40 }
41
42 void
43 SettingsPresentationModel::CreateInstance(void)
44 {
45         __pInstance = new (std::nothrow) SettingsPresentationModel();
46         result r = __pInstance->Construct();
47         if(IsFailed(r))
48         {
49                 delete __pInstance;
50                 __pInstance = null;
51                 return;
52         }
53         atexit(&(SettingsPresentationModel::DestroyInstance));
54 }
55
56 SettingsPresentationModel*
57 SettingsPresentationModel::GetInstance(void)
58 {
59         if (__pInstance == null)
60         {
61                 CreateInstance();
62         }
63         return __pInstance;
64 }
65
66 void
67 SettingsPresentationModel::DestroyInstance(void)
68 {
69         if (__pInstance->__pSettingsMgr != null)
70         {
71                 __pInstance->__pSettingsMgr->RemoveSettingEventListener(__pInstance);
72                 __pInstance->__pSettingsMgr = null;
73         }
74         delete __pInstance;
75 }
76
77 result
78 SettingsPresentationModel::Construct(void)
79 {
80         //Construct Settings Manager
81         __pSettingsMgr = SettingsManager::GetInstance();
82         __pSettingsMgr->AddSettingEventListener(this);
83         return E_SUCCESS;
84 }
85
86 result
87 SettingsPresentationModel::AddSettingEventListener(ISettingsEventListener* pSettingsEventListener)
88 {
89         result r = E_FAILURE;
90         if (__pSettingsEventListener == null && pSettingsEventListener != null)
91         {
92                 __pSettingsEventListener = pSettingsEventListener;
93                 r = E_SUCCESS;
94         }
95         return r;
96 }
97
98 void
99 SettingsPresentationModel::RemoveSettingEventListener(void)
100 {
101         __pSettingsEventListener = null;
102 }
103
104 IMapT<int,String>*
105 SettingsPresentationModel::GetRejectMessageListN(void)
106 {
107         return __pSettingsMgr->GetRejectMessageListN();
108 }
109
110
111 bool
112 SettingsPresentationModel::IsCallToBeRejected(Tizen::Base::String& phoneNumber)
113 {
114         return __pSettingsMgr->IsCallToBeRejected(phoneNumber);
115 }
116
117
118 //////////////////////////////////////////////////
119 //               Settings Event Listener Methods                //
120 //////////////////////////////////////////////////
121
122 void
123 SettingsPresentationModel::HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated)
124 {
125         if (__pSettingsEventListener != null)
126         {
127                 __pSettingsEventListener->HandleGetCallWaitingResponse(isCallSuccessful, callWaitingActivated);
128         }
129 }
130
131 void
132 SettingsPresentationModel::HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled)
133 {
134         if (__pSettingsEventListener != null)
135                 {
136                         __pSettingsEventListener->HandleSetCallWaitingResponse(isCallSuccessful, isCallWaitingEnabled);
137                 }
138 }
139
140 void
141 SettingsPresentationModel::HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime)
142 {
143         if (__pSettingsEventListener != null)
144                 {
145                         __pSettingsEventListener->HandleGetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, callForwardActivated, noReplyWaitTime);
146                 }
147 }
148
149 void
150 SettingsPresentationModel::HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime)
151 {
152         if (__pSettingsEventListener != null)
153                 {
154                         __pSettingsEventListener->HandleSetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, isCallForwardActivated, noReplyWaitTime);
155                 }
156 }
157
158 void
159 SettingsPresentationModel::HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated)
160 {
161         if (__pSettingsEventListener != null)
162         {
163                 __pSettingsEventListener->HandleGetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated);
164         }
165 }
166
167 void
168 SettingsPresentationModel::HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated)
169 {
170         if (__pSettingsEventListener != null)
171         {
172                 __pSettingsEventListener->HandleSetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated);
173         }
174 }
175
176 void
177 SettingsPresentationModel::HandleFlightMode(bool isFlightModeActivated)
178 {
179         CallPresentationModel::GetInstance()->EndAllCall();
180 }
181
182 result
183 SettingsPresentationModel::SetCallState(CallState callState)
184 {
185         return __pSettingsMgr->SetCallState(callState);
186 }
187
188 bool
189 SettingsPresentationModel::GetFlightModeStatus(void)
190 {
191         return __pSettingsMgr->GetFlightModeStatus();
192 }