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 CallErrorMsgPopup.cpp
19 * @brief Error message pop class
21 #include <FGraphics.h>
22 #include "CallAppUtility.h"
23 #include "CallErrorMsgPopup.h"
24 #include "CallTypes.h"
26 using namespace Tizen::Base;
27 using namespace Tizen::Ui;
28 using namespace Tizen::Ui::Controls;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Base::Utility;
31 using namespace Tizen::Base::Runtime;
33 const int IDI_VERTICAL_LINE_SPACING = 20;
34 const int W_ERROR_MSG_POPUP = 720;
35 const int IDI_VERTICAL_MARGIN = 39;
36 static const wchar_t* IDL_ERROR_MSG_POPUP = L"IDL_ERROR_MSG_POPUP";
37 static const wchar_t* IDC_MSG_TEXTBOX = L"IDC_MSG_TEXTBOX";
38 static const wchar_t* IDS_DIAL_ERROR_MSG = L"IDS_DIAL_ERROR_MSG";
39 static const wchar_t* IDS_JOIN_FAILED_ERROR_MSG = L"IDS_JOIN_FAILED_ERROR_MSG";
40 static const wchar_t* IDS_REJECT_FAILED_ERROR_MSG = L"IDS_REJECT_FAILED_ERROR_MSG";
41 static const wchar_t* IDS_CALL_SWAP_ERROR_MSG = L"IDS_CALL_SWAP_ERROR_MSG";
42 static const wchar_t* IDS_END_PARTICIPANT_ERROR_MSG = L"IDS_END_PARTICIPANT_ERROR_MSG";
43 static const wchar_t* IDS_SPLIT_PARTICIPANT_ERROR_MSG = L"IDS_SPLIT_PARTICIPANT_ERROR_MSG";
44 static const wchar_t* IDS_SIM_INIT_ERROR_MSG = L"IDS_SIM_INIT_ERROR_MSG";
45 static const wchar_t* IDS_EMERGENCY_CALLS_ONLY_ERROR_MSG = L"IDS_EMERGENCY_CALLS_ONLY_ERROR_MSG";
46 static const wchar_t* IDS_INVALID_ARGS_ERROR_MSG = L"IDS_INVALID_ARGS_ERROR_MSG";
47 static const wchar_t* IDS_TAPI_INIT_ERROR_MSG = L"IDS_TAPI_INIT_ERROR_MSG";
48 static const wchar_t* IDS_GENERAL_TAPI_ERROR_MSG = L"IDS_GENERAL_TAPI_ERROR_MSG";
49 static const wchar_t* IDS_LONG_BARRING_PWD_ERROR_MSG = L"IDS_LONG_BARRING_PWD_ERROR_MSG";
50 static const wchar_t* IDS_INVALID_NUMBER_ERROR_MSG = L"IDS_INVALID_NUMBER_ERROR_MSG";
51 static const wchar_t* IDS_GENERAL_ERROR_MSG = L"IDS_GENERAL_ERROR_MSG";
53 ErrorMsgPopup::ErrorMsgPopup(IPopupClosedEventListener* pEventListener)
54 : __pEventListener(pEventListener)
59 ErrorMsgPopup::~ErrorMsgPopup(void)
70 ErrorMsgPopup::ConstructPopup(int errorCode)
72 Construct(IDL_ERROR_MSG_POPUP);
74 String msg = FetchErrorMessage(errorCode);
76 //Set text to Message box
77 TextBox* pMsgTxtBox = static_cast<TextBox*>(GetControl(IDC_MSG_TEXTBOX));
78 pMsgTxtBox->SetLineSpacing(1,1);
79 pMsgTxtBox->SetText(msg);
80 pMsgTxtBox->SetEnabled(false);
81 pMsgTxtBox->SetTextAlignment(ALIGNMENT_CENTER);
83 Rectangle msgTxtBoxRect = pMsgTxtBox->GetBounds();
84 //get no. of lines to show message
85 int noOfLines = pMsgTxtBox->GetLineCount();
86 pMsgTxtBox->SetSize(msgTxtBoxRect.width,((noOfLines * msgTxtBoxRect.height) + IDI_VERTICAL_LINE_SPACING));
88 Dimension popUpDimen = pMsgTxtBox->GetSize();
89 popUpDimen.width = W_ERROR_MSG_POPUP;
90 popUpDimen.height += (2 * IDI_VERTICAL_MARGIN);
93 SetControlAlwaysOnTop(*pMsgTxtBox,true);
94 RelativeLayout* relPopUpLayout = static_cast<RelativeLayout*>(GetLayoutN());
95 if(relPopUpLayout != null)
97 // Set Relations between msgtextbox and Popup
98 relPopUpLayout->SetCenterAligned(*pMsgTxtBox, CENTER_ALIGN_HORIZONTAL);
99 relPopUpLayout->SetCenterAligned(*pMsgTxtBox, CENTER_ALIGN_VERTICAL);
102 __pTimer = new (std::nothrow) Timer();
103 __pTimer->Construct(*this);
107 ErrorMsgPopup::ShowErrorMsgPopupN(int errorCode)
109 //Construct the message popup
110 ConstructPopup(errorCode);
116 ErrorMsgPopup::ShowPopup(void)
118 __popupModalResult = 0;
119 //start timer to show popup
120 __pTimer->Start(2000);
126 ErrorMsgPopup::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
128 //Call default implementation of "Object.Equals()"
129 //returns true, if they are pointing to same address.
130 if (__pTimer->Equals(timer))
133 //notify the listener
134 __pEventListener->HandlePopupClosed();
139 ErrorMsgPopup::FetchErrorMessage(int errorCode)
147 case ERROR_DIAL_FAILED:
149 msg.Append(AppUtility::GetResourceString(IDS_DIAL_ERROR_MSG));
153 case ERROR_JOIN_FAILED:
155 msg.Append(AppUtility::GetResourceString(IDS_JOIN_FAILED_ERROR_MSG));
159 case ERROR_REJECT_FAILED:
161 msg.Append(AppUtility::GetResourceString(IDS_REJECT_FAILED_ERROR_MSG));
165 case ERROR_SWAP_FAILED:
167 msg.Append(AppUtility::GetResourceString(IDS_CALL_SWAP_ERROR_MSG));
171 case ERROR_END_FROM_CONFERENCE_FAILED:
173 msg.Append(AppUtility::GetResourceString(IDS_END_PARTICIPANT_ERROR_MSG));
177 case ERROR_SPLIT_FROM_CONFERENCE_FAILED:
179 msg.Append(AppUtility::GetResourceString(IDS_SPLIT_PARTICIPANT_ERROR_MSG));
183 case ERROR_CODE_SIM_INITIALIZATION_FAILED:
185 msg.Append(AppUtility::GetResourceString(IDS_SIM_INIT_ERROR_MSG));
189 case ERROR_NOT_EMERGENCY_NUM:
191 msg.Append(AppUtility::GetResourceString(IDS_EMERGENCY_CALLS_ONLY_ERROR_MSG));
195 case ERROR_INVALID_INPUT:
197 msg.Append(AppUtility::GetResourceString(IDS_INVALID_ARGS_ERROR_MSG));
201 case ERROR_TAPI_INIT_FAILED:
203 msg.Append(AppUtility::GetResourceString(IDS_TAPI_INIT_ERROR_MSG));
207 case ERROR_TAPI_ERROR:
209 msg.Append(AppUtility::GetResourceString(IDS_GENERAL_TAPI_ERROR_MSG));
213 case ERROR_BARRING_PWD_TOO_LONG:
215 msg.Append(AppUtility::GetResourceString(IDS_LONG_BARRING_PWD_ERROR_MSG));
219 case ERROR_INVALID_NUMBER:
221 msg.Append(AppUtility::GetResourceString(IDS_INVALID_NUMBER_ERROR_MSG));
225 case ERROR_FLIGHT_MODE_SET:
227 msg.Append(AppUtility::GetResourceString(IDS_FLIGHT_MODE_ON));
234 msg.Append(AppUtility::GetResourceString(IDS_GENERAL_ERROR_MSG));