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 PhnSettingsBarringPwdForm.cpp
19 * @brief Call Baring Password form
22 #include "PhnAppUtility.h"
23 #include "PhnSettingsBarringPwdForm.h"
24 #include "PhnSettingsConstants.h"
25 #include "PhnSettingsPresentationModel.h"
26 #include "PhnSceneRegister.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
37 static const wchar_t* IDL_SETTINGS_SET_BARRING_PWD__FORM = L"IDL_SETTINGS_SET_BARRING_PWD__FORM";
39 SettingsBarringPwdForm::SettingsBarringPwdForm(void)
40 : __pErrorMsgPopup(null)
44 SettingsBarringPwdForm::~SettingsBarringPwdForm(void)
49 SettingsBarringPwdForm::Initialize(void)
51 Construct(IDL_SETTINGS_SET_BARRING_PWD__FORM);
55 SettingsBarringPwdForm::OnInitializing(void)
61 //Initialize reject message editArea
62 EditField* pSetPwd = static_cast<EditField*>(GetControl(IDC_EDITFIELD));
65 pSetPwd->AddTextEventListener(*this);
67 pSetPwd->SetOverlayKeypadCommandButtonVisible(false);
68 pSetPwd->ShowKeypad();
74 SettingsBarringPwdForm::InitializeHeader(void)
76 Header* pHeader = GetHeader();
79 //TODO: get correct icons.
82 saveItemName.Append(AppUtility::GetResourceString(IDS_SETTING_SAVE_HEADER_ITEM));
83 ButtonItem saveHeaderItem;
84 saveHeaderItem.Construct(BUTTON_ITEM_STYLE_TEXT, IDA_SAVE_HEADER_ITEMID);
85 saveHeaderItem.SetText(saveItemName);
86 pHeader->SetButton(BUTTON_POSITION_LEFT, saveHeaderItem);
87 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
90 Bitmap* pNormalBmp = AppUtility::GetBitmapFromResourcesN(IDB_CANCEL_FOOTER_ITEM, W_HDR_FTR_ICON, H_HDR_FTR_ICON);
91 ButtonItem cancelHeaderItem;
92 cancelHeaderItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_CANCEL_HEADER_ITEMID);
93 cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pNormalBmp);
94 cancelHeaderItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pNormalBmp);
95 pHeader->SetButton(BUTTON_POSITION_RIGHT, cancelHeaderItem);
98 pHeader->AddActionEventListener(*this);
103 SettingsBarringPwdForm::OnTerminating(void)
105 result r = E_SUCCESS;
110 SettingsBarringPwdForm::OnActionPerformed(const Control& source, int actionId)
112 SceneManager* pSceneManager = SceneManager::GetInstance();
113 AppAssert(pSceneManager != null);
117 case IDA_CANCEL_HEADER_ITEMID:
122 case IDA_SAVE_HEADER_ITEMID:
124 //save call barring settings
125 EditField* pSetPwd = static_cast<EditField*>(GetControl(IDC_EDITFIELD));
128 SettingsPresentationModel* pPresentor = SettingsPresentationModel::GetInstance();
129 String password = pSetPwd->GetText();
130 //set call barring status
131 int errorCode = pPresentor->SetCallBarringStatus(password, __callBarringCondition, __conditionState);
132 if(errorCode != ERROR_NONE)
134 ShowErrorMessage(errorCode);
139 if(__conditionState == false)
141 if(__callBarringCondition == CALL_BARRING_ALL_OUTGOING)
143 pPresentor->SetCallBarringStatus(password, CALL_BARRING_INTERNATIONAL_OUTGOING, false);
144 pPresentor->SetCallBarringStatus(password, CALL_BARRING_INTERNATIONAL_EXCEPT_HOME, false);
146 if(__callBarringCondition == CALL_BARRING_ALL_INCOMING)
148 pPresentor->SetCallBarringStatus(password, CALL_BARRING_INCOMING_ROAMING, false);
161 //switch back to previous form
162 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_BARRING_OPTIONS), null);
166 SettingsBarringPwdForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
170 Integer* pIndexInt = static_cast<Integer*>(pArgs->GetAt(0));
171 switch (pIndexInt->ToInt())
175 __callBarringCondition = CALL_BARRING_ALL_OUTGOING;
181 __callBarringCondition = CALL_BARRING_INTERNATIONAL_OUTGOING;
187 __callBarringCondition = CALL_BARRING_INTERNATIONAL_EXCEPT_HOME;
193 __callBarringCondition = CALL_BARRING_ALL_INCOMING;
199 __callBarringCondition = CALL_BARRING_INCOMING_ROAMING;
207 Integer* pItemState = static_cast<Integer*>(pArgs->GetAt(1));
208 if (pItemState->ToInt() == LIST_ITEM_STATUS_CHECKED)
210 __conditionState = true;
214 __conditionState = false;
217 //Clear edit field and disable "save"
218 EditField* pSetPwd = static_cast<EditField*>(GetControl(IDC_EDITFIELD));
223 pSetPwd->Invalidate(true);
225 Header* pHeader = GetHeader();
228 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
229 pHeader->Invalidate(true);
239 SettingsBarringPwdForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
241 EditField* pSetPwd = static_cast<EditField*>(GetControl(IDC_EDITFIELD));
244 pSetPwd->HideKeypad();
249 SettingsBarringPwdForm::OnTextValueChanged(const Control& source)
252 EditField* pSetPwd = static_cast<EditField*>(GetControl(IDC_EDITFIELD));
253 Header* pHeader = GetHeader();
254 if (pSetPwd != null && pHeader != null)
256 textLen = pSetPwd->GetTextLength();
260 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
265 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
267 pHeader->Invalidate(true);
272 SettingsBarringPwdForm::OnTextValueChangeCanceled(const Control& source)
274 Header* pHeader = GetHeader();
277 pHeader->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
278 pHeader->Invalidate(true);
283 SettingsBarringPwdForm::ShowErrorMessage(int errorCode)
285 //show error msg Popup
286 if (__pErrorMsgPopup == null)
288 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
290 __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
294 SettingsBarringPwdForm::HandlePopupClosed(void)
297 delete __pErrorMsgPopup;
298 __pErrorMsgPopup = null;