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 PhnBaseForm.cpp
19 * @brief Base class for all Call forms
21 #include "PhnActiveCallForm.h"
22 #include "PhnBaseForm.h"
23 #include "PhnCallInfo.h"
24 #include "PhnCallPresentationModel.h"
25 #include "PhnConfCallerListForm.h"
26 #include "PhnPhoneFormFactory.h"
27 #include "PhnSceneRegister.h"
28 #include "PhnPhoneApp.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Scenes;
36 using namespace Tizen::Ui::Controls;
38 BaseForm::BaseForm(FormType formType)
39 : __formType(formType)
41 __pCallPresentor = null;
42 __pErrorMsgPopup = null;
45 BaseForm::~BaseForm(void)
50 BaseForm::OnInitializing(void)
52 AddOrientationEventListener(*this);
53 //To be implemented in sub classes
58 BaseForm::OnActionPerformed(const Control& source, int actionId)
62 /////////////////////////////////////////////////////////////////
63 ///// Event Listener methods from ITelephonyEventListener /////
64 /////////////////////////////////////////////////////////////////
67 BaseForm::HandleCallConnected(IListT<CallInfo>& pCallList)
69 SceneManager* pSceneManager = SceneManager::GetInstance();
73 case FORMTYPE_OUTGOINGCALL:
74 case FORMTYPE_INCOMINGCALL:
75 case FORMTYPE_CONFCALLLIST:
76 case FORMTYPE_ACTIVECALL:
77 case FORMTYPE_ACTIVECONFCALL:
79 int noOfCalls = pCallList.GetCount();
80 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
81 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
82 pCallInfoList->Construct(noOfCalls);
84 for (int index = 0; index < noOfCalls; index++)
86 //fetch call info and add to list
88 result r = pCallList.GetAt(index, callInfo);
91 //copy call information to new instance
92 CallInfo* pCaller = new (std::nothrow) CallInfo();
94 pCallInfoList->Add(pCaller);
100 //Check if active call is conference call
101 CallInfo* pActiveCallInfo = static_cast<CallInfo*>(pCallInfoList->GetAt(0));
102 if(pActiveCallInfo->IsConferenceCall() == true)
104 //single Conference call - goto active Conf. call form
105 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
109 //single active call - goto active call form
110 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
113 else if(noOfCalls == 2)
115 //goto multiple active call form
116 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
121 case FORMTYPE_EMERGENCYOUTGOINGCALL:
123 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
124 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
125 pCallInfoList->Construct(1);
127 //fetch call info and add to list
129 result r = pCallList.GetAt(0, callInfo);
132 //copy call information to new instance
133 CallInfo* pCaller = new (std::nothrow) CallInfo();
135 pCallInfoList->Add(pCaller);
136 //single active call - goto active call form
137 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVE_EMERGENCYCALL), pCallInfoList);
148 BaseForm::HandleCallDisconnected(bool isLastCall, IListT<CallInfo>& pCallList)
150 SceneManager* pSceneManager = SceneManager::GetInstance();
151 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
153 int callCount = pCallList.GetCount();
156 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
157 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
158 pCallInfoList->Construct(callCount);
159 for (int index = 0; index < callCount; index++)
161 //fetch call info and add to list
163 result r = pCallList.GetAt(index, callInfo);
166 //copy call information to new instance
167 CallInfo* pCaller = new (std::nothrow) CallInfo();
169 pCallInfoList->Add(pCaller);
174 //fetch call info and add to list
176 result r = pCallList.GetAt(0, callInfo);
179 //copy call information to new instance
180 CallInfo* pCaller = new (std::nothrow) CallInfo();
182 pCallInfoList->Add(pCaller);
185 if (isLastCall == true)
187 //goto End Call form if single call. else go to dialer
188 SceneId nextSceneId = pPhoneApp->GetInitialScene();
189 if (callInfo.IsConferenceCall() == false)
191 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL), pCallInfoList);
193 else if (nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG)
195 pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
196 SCENE_HISTORY_OPTION_NO_HISTORY));
197 pCallInfoList->RemoveAll();
198 delete pCallInfoList;
199 pCallInfoList = null;
203 pPhoneApp->Terminate();
208 if (pCallList.GetCount() == 1)
210 if (callInfo.IsConferenceCall() == true)
212 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
216 //goto Single Active Call form
217 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
224 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
229 SceneId nextSceneId = pPhoneApp->GetInitialScene();
230 //No more calls are active
231 if (nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG)
233 pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
234 SCENE_HISTORY_OPTION_NO_HISTORY));
238 pPhoneApp->Terminate();
245 BaseForm::HandleConferenceCall(CallInfo& pCallInfo)
247 SceneManager* pSceneManager = SceneManager::GetInstance();
249 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
250 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
251 pCallInfoList->Construct(1);
253 //update list to be passed
254 CallInfo* pConfInfo = new (std::nothrow) CallInfo();
255 *pConfInfo = pCallInfo;
256 pCallInfoList->Add(pConfInfo);
258 //Todo: create screens for single conf call and conf call with another held call
259 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
263 BaseForm::HandleIncomingCall(CallInfo& pCallInfo)
265 SceneManager* pSceneManager = SceneManager::GetInstance();
267 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
268 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
269 pCallInfoList->Construct(1);
271 //update list to be passed
272 CallInfo* pIncomingCall = new (std::nothrow) CallInfo();
273 *pIncomingCall = pCallInfo;
274 pCallInfoList->Add(pIncomingCall);
276 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL), pCallInfoList);
280 BaseForm::HandleCallSwapOccured(IListT<CallInfo>& pCallList)
282 int noOfCalls = pCallList.GetCount();
283 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
284 pCallInfoList->Construct(noOfCalls);
286 for (int index = 0; index < noOfCalls; index++)
288 //fetch call info and add to list
290 result r = pCallList.GetAt(index, callInfo);
293 //copy call information to new instance
294 CallInfo* pCallInfo = new (std::nothrow) CallInfo();
295 *pCallInfo = callInfo;
296 pCallInfoList->Add(pCallInfo);
300 SceneManager* pSceneManager = SceneManager::GetInstance();
301 if (pSceneManager != null)
303 Scene* pActiveScene = pSceneManager->GetCurrentScene();
304 if (pActiveScene != null)
306 String formString = pActiveScene->GetFormId();
307 if (formString == IDL_FORM_MULTIPLEACTIVECALL)
309 ActiveCallForm* pActiveForm = (ActiveCallForm*) pActiveScene->GetForm();
310 pActiveForm->HandleCallSwapN(pCallInfoList);
317 BaseForm::HandleConferenceChange(void)
319 SceneManager* pSceneManager = SceneManager::GetInstance();
320 if (pSceneManager != null)
322 Scene* pActiveScene = pSceneManager->GetCurrentScene();
323 if (pActiveScene != null)
325 String formString = pActiveScene->GetFormId();
326 if (formString == IDL_FORM_CONFCALLLIST)
328 ConfCallerListForm* pConfListForm = (ConfCallerListForm*) pActiveScene->GetForm();
329 pConfListForm->HandleCallChange();
336 BaseForm::HandleTelephonyError(int errorCode)
338 //show error msg Popup
339 if (__pErrorMsgPopup == null)
341 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
343 __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
347 BaseForm::HandlePopupClosed(void)
350 delete __pErrorMsgPopup;
351 __pErrorMsgPopup = null;
353 SceneManager* pSceneManager = SceneManager::GetInstance();
356 case FORMTYPE_OUTGOINGCALL:
358 //fetch no of calls from telephony
359 CallPresentationModel* pPresentor = CallPresentationModel::GetInstance();
360 if(pPresentor != null)
362 //check if any call is present
363 if(pPresentor->GetCurrentCallCount() > 0)
365 //fetch current call list
366 IListT<CallInfo>* pCurrentCallList = pPresentor->GetCallListN();
367 HandleCallDisconnected(false,*pCurrentCallList);
368 delete pCurrentCallList;
369 pCurrentCallList = null;
373 //No more calls are active
374 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
375 SceneId nextSceneId = pPhoneApp->GetInitialScene();
376 if (nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG)
378 pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
379 SCENE_HISTORY_OPTION_NO_HISTORY));
383 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
384 pPhoneApp->Terminate();
391 case FORMTYPE_ENDCALL:
393 //It comes here, only when we make voice call for Last call from EndCallForm
394 //and some TAPI error is encountered.
395 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
396 pPhoneApp->Terminate();
406 BaseForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
408 SetOrientation(ORIENTATION_PORTRAIT);