2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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 CallBaseForm.cpp
19 * @brief Base class for all Call forms
21 #include "CallActiveCallForm.h"
22 #include "CallIncomingCallForm.h"
23 #include "CallBaseForm.h"
25 #include "CallPresentationModel.h"
26 #include "CallConfCallerListForm.h"
27 #include "CallPhoneFormFactory.h"
28 #include "CallSceneRegister.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Scenes;
37 using namespace Tizen::Ui::Controls;
39 BaseForm::BaseForm(FormType formType)
40 : __formType(formType)
42 __pCallPresentor = null;
43 __pErrorMsgPopup = null;
46 BaseForm::~BaseForm(void)
51 BaseForm::OnInitializing(void)
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<AppCallInfo>& pCallList)
69 if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
71 //This scenario will come, if 1 call is disconnected from conf. call having 2 participants.
72 //In this case, if there is any dialing call exists, then ignore.
73 //Else, if there is any incoming call exists, then update call option popup.
76 case FORMTYPE_INCOMINGCALL:
78 IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
79 if (pIncomingCallForm != null)
81 pIncomingCallForm->CallDisconnected();
92 SceneManager* pSceneManager = SceneManager::GetInstance();
96 case FORMTYPE_OUTGOINGCALL:
97 case FORMTYPE_INCOMINGCALL:
98 case FORMTYPE_CONFCALLLIST:
99 case FORMTYPE_ACTIVECALL:
100 case FORMTYPE_ACTIVECONFCALL:
102 int noOfCalls = pCallList.GetCount();
103 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
104 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
105 pCallInfoList->Construct(noOfCalls);
107 for (int index = 0; index < noOfCalls; index++)
109 //fetch call info and add to list
110 AppCallInfo callInfo;
111 result r = pCallList.GetAt(index, callInfo);
114 //copy call information to new instance
115 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
117 pCallInfoList->Add(pCaller);
123 //Check if active call is conference call
124 AppCallInfo* pActiveCallInfo = static_cast<AppCallInfo*>(pCallInfoList->GetAt(0));
125 if(pActiveCallInfo->IsConferenceCall() == true)
127 //single Conference call - goto active Conf. call form
128 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
129 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
133 //single active call - goto active call form
134 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL,
135 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
138 else if(noOfCalls == 2)
140 //goto multiple active call form
141 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL,
142 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
147 case FORMTYPE_MULTIPLECALLS:
149 //This case can come on Multiple Calls screen, when one of the calls is conference call with 2 participants
150 //and one of the participants exits himself from ConfCall.
151 int noOfCalls = pCallList.GetCount();
152 AppLogDebug("Active Call Count = %d", noOfCalls);
153 //this is just a safety check, call count will aleays be 2 here.
154 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
155 if(noOfCalls == IDI_MAX_ACTIVE_CALLS && pActiveCallForm != null)
158 pActiveCallForm->UpdateMultipleCallScreen(pCallList);
163 case FORMTYPE_EMERGENCYOUTGOINGCALL:
165 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
166 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
167 pCallInfoList->Construct(1);
169 //fetch call info and add to list
170 AppCallInfo callInfo;
171 result r = pCallList.GetAt(0, callInfo);
174 //copy call information to new instance
175 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
177 pCallInfoList->Add(pCaller);
178 //single active call - goto active call form
179 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVE_EMERGENCYCALL,
180 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
191 BaseForm::HandleCallDisconnected(bool isLastCall, IListT<AppCallInfo>& pCurrentActiveCallList)
193 AppLogDebug("Enter");
194 if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
196 //This scenario will come, if this disconnected call is neither incoming nor dialing call.
197 //In this case, if there is any dialing call exists, then ignore.
198 //Else, if there is any incoming call exists, then update call option popup.
199 AppLogDebug("IsIncomingorDialingCallPresent %d",__formType);
202 case FORMTYPE_INCOMINGCALL:
204 IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
205 if (pIncomingCallForm != null)
207 pIncomingCallForm->CallDisconnected();
218 SceneManager* pSceneManager = SceneManager::GetInstance();
219 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
221 int callCount = pCurrentActiveCallList.GetCount();
224 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
225 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
226 pCallInfoList->Construct(callCount);
227 for (int index = 0; index < callCount; index++)
229 //fetch call info and add to list
230 AppCallInfo callInfo;
231 result r = pCurrentActiveCallList.GetAt(index, callInfo);
234 //copy call information to new instance
235 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
237 pCallInfoList->Add(pCaller);
243 //fetch call info and add to list
244 AppCallInfo callInfo;
245 result r = pCurrentActiveCallList.GetAt(0, callInfo);
248 //copy call information to new instance
249 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
251 pCallInfoList->Add(pCaller);
254 if (isLastCall == true)
256 //list contains 1 last ended call to show EndCall screen.
257 //goto End Call form if single call was ended else terminate
258 // if (callInfo.IsConferenceCall() == false)
261 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL,
262 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
266 pPhoneApp->Terminate();
271 //list contains 1 active call
272 if (pCurrentActiveCallList.GetCount() == 1)
274 if (callInfo.IsConferenceCall() == true)
276 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
277 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
281 //goto Single Active Call form
282 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL,
283 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
290 //multiple active calls are present.
291 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL,
292 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
297 //This is done to show end call form in missed call case also
298 //this was done on request received from HQ to solve a bug in
299 //camera application. In which if a call comes when camera is
300 //running and user disconnects before the ui is shown the camera
302 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
303 pCallInfoList->Construct(1);
304 AppCallInfo callInfo;
305 result r = pCurrentActiveCallList.GetAt(0, callInfo);
308 //copy call information to new instance
309 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
311 pCallInfoList->Add(pCaller);
312 //multiple active calls are present.
313 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL,
314 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
319 pPhoneApp->Terminate();
327 BaseForm::HandleConferenceCall(AppCallInfo& pCallInfo)
329 SceneManager* pSceneManager = SceneManager::GetInstance();
331 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
332 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
333 pCallInfoList->Construct(1);
335 //update list to be passed
336 AppCallInfo* pConfInfo = new (std::nothrow) AppCallInfo();
337 *pConfInfo = pCallInfo;
338 pCallInfoList->Add(pConfInfo);
340 //Todo: create screens for single conf call and conf call with another held call
341 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL,
342 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
346 BaseForm::HandleIncomingCall(AppCallInfo& pCallInfo)
348 SceneManager* pSceneManager = SceneManager::GetInstance();
350 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
351 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
352 pCallInfoList->Construct(1);
354 //update list to be passed
355 AppCallInfo* pIncomingCall = new (std::nothrow) AppCallInfo();
356 *pIncomingCall = pCallInfo;
357 pCallInfoList->Add(pIncomingCall);
359 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL,
360 SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_NO_HISTORY,SCENE_DESTROY_OPTION_KEEP), pCallInfoList);
364 BaseForm::HandleCallSwapOccured(IListT<AppCallInfo>& pCallList)
366 int noOfCalls = pCallList.GetCount();
367 if(noOfCalls != IDI_MAX_ACTIVE_CALLS && __formType != FORMTYPE_MULTIPLECALLS)
371 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
372 if(pActiveCallForm != null)
375 pActiveCallForm->UpdateMultipleCallScreen(pCallList);
376 pActiveCallForm->SetSwapInProgress(false);
382 BaseForm::HandleConferenceChange(void)
384 if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
386 //This scenario will come, if 1 call is disconnected from conf. call having more than 2 participants.
387 //In this case, if there is any dialing call exists, then ignore.
388 //Else, if there is any incoming call exists, then update call option popup.
391 case FORMTYPE_INCOMINGCALL:
393 IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
394 if (pIncomingCallForm != null)
396 pIncomingCallForm->CallDisconnected();
409 case FORMTYPE_CONFCALLLIST:
411 ConfCallerListForm* pConfCallerListForm = dynamic_cast<ConfCallerListForm*>(this);
412 if(pConfCallerListForm != null)
414 pConfCallerListForm->HandleParticipantsChanged();
419 case FORMTYPE_ACTIVECONFCALL:
420 case FORMTYPE_MULTIPLECALLS:
422 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
423 if(pActiveCallForm != null)
425 pActiveCallForm->HandleConfCallChanged();
435 BaseForm::HandleTelephonyError(int errorCode)
437 //show error msg Popup
438 if (__pErrorMsgPopup == null)
440 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
441 __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
446 BaseForm::HandlePopupClosed(void)
449 delete __pErrorMsgPopup;
450 __pErrorMsgPopup = null;
454 case FORMTYPE_OUTGOINGCALL:
456 //fetch no of calls from telephony
457 CallPresentationModel* pPresentor = CallPresentationModel::GetInstance();
458 if(pPresentor != null)
460 //check if any call is present
461 if(pPresentor->GetCurrentCallCount() > 0)
463 //fetch current call list
464 IListT<AppCallInfo>* pCurrentCallList = pPresentor->GetCallListN();
465 HandleCallDisconnected(false,*pCurrentCallList);
466 delete pCurrentCallList;
467 pCurrentCallList = null;
471 //No more calls are active
472 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
473 pPhoneApp->Terminate();
480 case FORMTYPE_ENDCALL:
482 //It comes here, only when we make voice call for Last call from EndCallForm
483 //and some TAPI error is encountered.
484 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
485 pPhoneApp->Terminate();