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();
288 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
289 pCallInfoList->Construct(noOfCalls);
291 for (int index = 0; index < noOfCalls; index++)
293 //fetch call info and add to list
295 result r = pCallList.GetAt(index, callInfo);
298 //copy call information to new instance
299 CallInfo* pCallInfo = new (std::nothrow) CallInfo();
300 *pCallInfo = callInfo;
301 pCallInfoList->Add(pCallInfo);
305 if (__formType == FORMTYPE_MULTIPLECALLS)
307 ActiveCallForm* pActiveForm = dynamic_cast<ActiveCallForm*>(this);
308 if(pActiveForm != null)
310 pActiveForm->HandleCallSwapN(pCallInfoList);
316 BaseForm::HandleConferenceChange(void)
318 if (__formType == FORMTYPE_CONFCALLLIST)
320 ConfCallerListForm* pConfCallerListForm = dynamic_cast<ConfCallerListForm*>(this);
321 if(pConfCallerListForm != null)
323 pConfCallerListForm->HandleCallChange();
330 BaseForm::HandleTelephonyError(int errorCode)
332 //show error msg Popup
333 if (__pErrorMsgPopup == null)
335 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
337 __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
341 BaseForm::HandlePopupClosed(void)
344 delete __pErrorMsgPopup;
345 __pErrorMsgPopup = null;
347 SceneManager* pSceneManager = SceneManager::GetInstance();
350 case FORMTYPE_OUTGOINGCALL:
352 //fetch no of calls from telephony
353 CallPresentationModel* pPresentor = CallPresentationModel::GetInstance();
354 if(pPresentor != null)
356 //check if any call is present
357 if(pPresentor->GetCurrentCallCount() > 0)
359 //fetch current call list
360 IListT<CallInfo>* pCurrentCallList = pPresentor->GetCallListN();
361 HandleCallDisconnected(false,*pCurrentCallList);
362 delete pCurrentCallList;
363 pCurrentCallList = null;
367 //No more calls are active
368 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
369 SceneId nextSceneId = pPhoneApp->GetInitialScene();
370 if (nextSceneId == IDSCN_DIALER || nextSceneId == IDSCN_CALL_LOG)
372 pSceneManager->GoForward( ForwardSceneTransition(nextSceneId, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
373 SCENE_HISTORY_OPTION_NO_HISTORY));
377 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
378 pPhoneApp->Terminate();
385 case FORMTYPE_ENDCALL:
387 //It comes here, only when we make voice call for Last call from EndCallForm
388 //and some TAPI error is encountered.
389 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
390 pPhoneApp->Terminate();
400 BaseForm::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
402 SetOrientation(ORIENTATION_PORTRAIT);