2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
18 * @file PhnSettingsPresentationModel.cpp
19 * @brief Setting Presentation model
21 #include "PhnSettingsConstants.h"
22 #include "PhnSettingsManager.h"
23 #include "PhnSettingsPresentationModel.h"
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Social;
29 SettingsPresentationModel* SettingsPresentationModel::__pInstance = null;
31 SettingsPresentationModel::SettingsPresentationModel()
33 __pSettingsMgr = null;
34 __pSettingsEventListener = null;
37 SettingsPresentationModel::~SettingsPresentationModel()
42 SettingsPresentationModel::CreateInstance(void)
44 __pInstance = new (std::nothrow) SettingsPresentationModel();
45 result r = __pInstance->Construct();
52 atexit(&(SettingsPresentationModel::DestroyInstance));
55 SettingsPresentationModel*
56 SettingsPresentationModel::GetInstance(void)
58 if (__pInstance == null)
66 SettingsPresentationModel::DestroyInstance(void)
68 if (__pInstance->__pSettingsMgr != null)
70 __pInstance->__pSettingsMgr->RemoveSettingEventListener(__pInstance);
71 __pInstance->__pSettingsMgr = null;
77 SettingsPresentationModel::Construct(void)
79 //Construct Settings Manager
80 __pSettingsMgr = SettingsManager::GetInstance();
81 __pSettingsMgr->AddSettingEventListener(this);
86 SettingsPresentationModel::AddSettingEventListener(ISettingsEventListener* pSettingsEventListener)
89 if (__pSettingsEventListener == null && pSettingsEventListener != null)
91 __pSettingsEventListener = pSettingsEventListener;
98 SettingsPresentationModel::RemoveSettingEventListener(void)
100 __pSettingsEventListener = null;
104 SettingsPresentationModel::GetRejectMessageListN(void)
106 return __pSettingsMgr->GetRejectMessageListN();
110 SettingsPresentationModel::AddToCallRejectList(const String& phoneNumber, CallRejectMatchCondition rejectCondition)
112 return __pSettingsMgr->AddToCallRejectList(phoneNumber, rejectCondition);
115 IListT<CallRejectInfo>*
116 SettingsPresentationModel::GetCallRejectList(void)
118 return __pSettingsMgr->GetCallRejectList();
122 SettingsPresentationModel::SetPrefixDialNumber(int phoneNumberIndex, const String& phoneNumber)
124 return __pSettingsMgr->SetPrefixDialNumber(phoneNumberIndex, phoneNumber);
128 SettingsPresentationModel::SetActivePrefixDialingValue(int prefixDialIndex)
130 return __pSettingsMgr->SetActivePrefixDialingValue(prefixDialIndex);
134 SettingsPresentationModel::SetPrefixDialingStatus(bool enablePrefixDialing)
136 return __pSettingsMgr->SetPrefixDialingStatus(enablePrefixDialing);
140 SettingsPresentationModel::GetActivePrefixDialNumber(Tizen::Base::String& phoneNumber)
142 result r = E_FAILURE;
143 if(__pSettingsMgr->GetPrefixDialingStatus() == true)
145 int activePrefixIndex = -1;
146 //fetch active prefix index
147 r = __pSettingsMgr->GetActivePrefixDialingValue(activePrefixIndex);
148 TryReturn(r == E_SUCCESS, r, "Error while fetching Active Prefix Dialing Index");
150 //fetch phone number mapped to fetched index
151 r = __pSettingsMgr->GetPrefixDialNumberAtIndex(activePrefixIndex, phoneNumber);
157 SettingsPresentationModel::SetCallBarringStatus(const String& password, CallBarringType callBarringType, bool activateBarring)
159 return __pSettingsMgr->SetCallBarringStatus(password, callBarringType, activateBarring);
163 SettingsPresentationModel::GetCallForwardStatus(CallForwardCondition callFwdCondition)
165 return __pSettingsMgr->GetCallForwardStatus(callFwdCondition);
169 SettingsPresentationModel::SetCallForwardStatus(const String& phoneNumber, CallForwardCondition callFwdCondition, bool activateFwding, int noReplyTime)
171 return __pSettingsMgr->SetCallForwardStatus(phoneNumber, callFwdCondition, activateFwding, noReplyTime);
175 SettingsPresentationModel::GetCallBarringStatus(CallBarringType callBarringType)
177 return __pSettingsMgr->GetCallBarringStatus(callBarringType);
181 SettingsPresentationModel::SetCallWaitingStatus(bool activateWaiting)
183 return __pSettingsMgr->SetCallWaitingStatus(activateWaiting);
187 SettingsPresentationModel::GetCallWaitingStatus(void)
189 return __pSettingsMgr->GetCallWaitingStatus();
193 SettingsPresentationModel::SetCallConnectToneStatus(bool activate)
195 return __pSettingsMgr->SetCallConnectToneStatus(activate);
198 SettingsPresentationModel::GetCallConnectToneStatus(void)
200 return __pSettingsMgr->GetCallConnectToneStatus();
204 SettingsPresentationModel::SetMinuteMinderToneStatus(bool activate)
206 return __pSettingsMgr->SetMinuteMinderToneStatus(activate);
210 SettingsPresentationModel::GetMinuteMinderToneStatus(void)
212 return __pSettingsMgr->GetMinuteMinderToneStatus();
216 SettingsPresentationModel::SetCallEndToneStatus(bool activate)
218 return __pSettingsMgr->SetCallEndToneStatus(activate);
222 SettingsPresentationModel::GetCallEndToneStatus(void)
224 return __pSettingsMgr->GetCallEndToneStatus();
228 SettingsPresentationModel::UpdateCallRejectRow(int rowId, const String& phoneNumber, bool activate, CallRejectMatchCondition rejectCondition)
230 return __pSettingsMgr->UpdateCallRejectRow(rowId, phoneNumber, activate, rejectCondition);
234 SettingsPresentationModel::RemoveCallRejectRow(int rowId)
236 return __pSettingsMgr->RemoveCallRejectRow(rowId);
240 SettingsPresentationModel::SetRejectMessage(int messageIndex, const String& rejectMessage)
242 return __pSettingsMgr->SetRejectMessage(messageIndex, rejectMessage);
246 SettingsPresentationModel::RemoveRejectMessage(const Tizen::Base::Collection::IListT<int>& deleteKeyList)
248 return __pSettingsMgr->RemoveRejectMessage(deleteKeyList);
252 SettingsPresentationModel::SetSpeedDialMapping(const String& contactId, int numberToMap)
254 return __pSettingsMgr->SetSpeedDialMapping(contactId,numberToMap);
257 IMapT<int,SpeedDialInfo>*
258 SettingsPresentationModel::GetSpeedDialMappingN(void)
260 return __pSettingsMgr->GetSpeedDialMappingN();
264 SettingsPresentationModel::IsCallToBeRejected(Tizen::Base::String& phoneNumber)
266 return __pSettingsMgr->IsCallToBeRejected(phoneNumber);
270 SettingsPresentationModel::RemoveSpeedDialMapping(int rowId)
272 return __pSettingsMgr->RemoveSpeedDialMapping(rowId);
276 SettingsPresentationModel::UpdateSpeedDialMapping(int rowId, const String& contactId, int numberToMap)
278 return __pSettingsMgr->UpdateSpeedDialMapping(rowId, contactId, numberToMap);
282 SettingsPresentationModel::SetCallLineIdentity(CallLineIdentity identity)
284 return __pSettingsMgr->SetCallLineIdentity(identity);
288 SettingsPresentationModel::GetCallLineIdentity(CallLineIdentity& identity)
290 return __pSettingsMgr->GetCallLineIdentity(identity);
294 SettingsPresentationModel::SetCallAlertStatus(CallAlertStatus callAlertStatus)
296 return __pSettingsMgr->SetCallAlertStatus(callAlertStatus);
300 SettingsPresentationModel::GetCallAlertStatus(CallAlertStatus& callAlertStatus)
302 return __pSettingsMgr->GetCallAlertStatus(callAlertStatus);
306 SettingsPresentationModel::SetUnknownRejectStatus(bool activate)
308 return __pSettingsMgr->SetUnknownRejectStatus(activate);
312 SettingsPresentationModel::GetUnknownRejectStatus(void)
314 return __pSettingsMgr->GetUnknownRejectStatus();
318 SettingsPresentationModel::FetchContactDetailsN(const String& contactId)
320 return __pSettingsMgr->FetchContactDetailsN(contactId);
323 //////////////////////////////////////////////////
324 // Settings Event Listener Methods //
325 //////////////////////////////////////////////////
328 SettingsPresentationModel::HandleGetCallWaitingResponse(bool isCallSuccessful, bool callWaitingActivated)
330 if (__pSettingsEventListener != null)
332 __pSettingsEventListener->HandleGetCallWaitingResponse(isCallSuccessful, callWaitingActivated);
337 SettingsPresentationModel::HandleSetCallWaitingResponse(bool isCallSuccessful, bool isCallWaitingEnabled)
339 if (__pSettingsEventListener != null)
341 __pSettingsEventListener->HandleSetCallWaitingResponse(isCallSuccessful, isCallWaitingEnabled);
346 SettingsPresentationModel::HandleGetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool callForwardActivated, int noReplyWaitTime)
348 if (__pSettingsEventListener != null)
350 __pSettingsEventListener->HandleGetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, callForwardActivated, noReplyWaitTime);
355 SettingsPresentationModel::HandleSetCallForwardResponse(bool isCallSuccessful, CallForwardCondition callFwdCondition, const String& callFwdNumber, bool isCallForwardActivated, int noReplyWaitTime)
357 if (__pSettingsEventListener != null)
359 __pSettingsEventListener->HandleSetCallForwardResponse(isCallSuccessful, callFwdCondition, callFwdNumber, isCallForwardActivated, noReplyWaitTime);
364 SettingsPresentationModel::HandleGetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated)
366 if (__pSettingsEventListener != null)
368 __pSettingsEventListener->HandleGetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated);
373 SettingsPresentationModel::HandleSetCallBarringResponse(bool isCallSuccessful, CallBarringType callBarringType, bool isBarringActivated)
375 if (__pSettingsEventListener != null)
377 __pSettingsEventListener->HandleSetCallBarringResponse(isCallSuccessful, callBarringType, isBarringActivated);
382 SettingsPresentationModel::SetCallState(CallState callState)
384 return __pSettingsMgr->SetCallState(callState);