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 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), pCallInfoList);
132 //single active call - goto active call form
133 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
136 else if(noOfCalls == 2)
138 //goto multiple active call form
139 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
144 case FORMTYPE_MULTIPLECALLS:
146 //This case can come on Multiple Calls screen, when one of the calls is conference call with 2 participants
147 //and one of the participants exits himself from ConfCall.
148 int noOfCalls = pCallList.GetCount();
149 AppLogDebug("Active Call Count = %d", noOfCalls);
150 //this is just a safety check, call count will aleays be 2 here.
151 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
152 if(noOfCalls == IDI_MAX_ACTIVE_CALLS && pActiveCallForm != null)
155 pActiveCallForm->UpdateMultipleCallScreen(pCallList);
160 case FORMTYPE_EMERGENCYOUTGOINGCALL:
162 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
163 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
164 pCallInfoList->Construct(1);
166 //fetch call info and add to list
167 AppCallInfo callInfo;
168 result r = pCallList.GetAt(0, callInfo);
171 //copy call information to new instance
172 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
174 pCallInfoList->Add(pCaller);
175 //single active call - goto active call form
176 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVE_EMERGENCYCALL), pCallInfoList);
187 BaseForm::HandleCallDisconnected(bool isLastCall, IListT<AppCallInfo>& pCurrentActiveCallList)
189 if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
191 //This scenario will come, if this disconnected call is neither incoming nor dialing call.
192 //In this case, if there is any dialing call exists, then ignore.
193 //Else, if there is any incoming call exists, then update call option popup.
196 case FORMTYPE_INCOMINGCALL:
198 IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
199 if (pIncomingCallForm != null)
201 pIncomingCallForm->CallDisconnected();
212 SceneManager* pSceneManager = SceneManager::GetInstance();
213 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
215 int callCount = pCurrentActiveCallList.GetCount();
218 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
219 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
220 pCallInfoList->Construct(callCount);
221 for (int index = 0; index < callCount; index++)
223 //fetch call info and add to list
224 AppCallInfo callInfo;
225 result r = pCurrentActiveCallList.GetAt(index, callInfo);
228 //copy call information to new instance
229 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
231 pCallInfoList->Add(pCaller);
236 //fetch call info and add to list
237 AppCallInfo callInfo;
238 result r = pCurrentActiveCallList.GetAt(0, callInfo);
241 //copy call information to new instance
242 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
244 pCallInfoList->Add(pCaller);
247 if (isLastCall == true)
249 //goto End Call form if single call. else terminate
250 if (callInfo.IsConferenceCall() == false)
252 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL), pCallInfoList);
256 pPhoneApp->Terminate();
261 if (pCurrentActiveCallList.GetCount() == 1)
263 if (callInfo.IsConferenceCall() == true)
265 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
269 //goto Single Active Call form
270 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
277 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
282 pPhoneApp->Terminate();
288 BaseForm::HandleConferenceCall(AppCallInfo& pCallInfo)
290 SceneManager* pSceneManager = SceneManager::GetInstance();
292 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
293 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
294 pCallInfoList->Construct(1);
296 //update list to be passed
297 AppCallInfo* pConfInfo = new (std::nothrow) AppCallInfo();
298 *pConfInfo = pCallInfo;
299 pCallInfoList->Add(pConfInfo);
301 //Todo: create screens for single conf call and conf call with another held call
302 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
306 BaseForm::HandleIncomingCall(AppCallInfo& pCallInfo)
308 SceneManager* pSceneManager = SceneManager::GetInstance();
310 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
311 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
312 pCallInfoList->Construct(1);
314 //update list to be passed
315 AppCallInfo* pIncomingCall = new (std::nothrow) AppCallInfo();
316 *pIncomingCall = pCallInfo;
317 pCallInfoList->Add(pIncomingCall);
319 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL), pCallInfoList);
323 BaseForm::HandleCallSwapOccured(IListT<AppCallInfo>& pCallList)
325 int noOfCalls = pCallList.GetCount();
326 if(noOfCalls != IDI_MAX_ACTIVE_CALLS && __formType != FORMTYPE_MULTIPLECALLS)
330 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
331 if(pActiveCallForm != null)
334 pActiveCallForm->UpdateMultipleCallScreen(pCallList);
339 BaseForm::HandleConferenceChange(void)
341 if(__pCallPresentor->IsIncomingorDialingCallPresent() == true)
343 //This scenario will come, if 1 call is disconnected from conf. call having more than 2 participants.
344 //In this case, if there is any dialing call exists, then ignore.
345 //Else, if there is any incoming call exists, then update call option popup.
348 case FORMTYPE_INCOMINGCALL:
350 IncomingCallForm* pIncomingCallForm = dynamic_cast<IncomingCallForm*>(this);
351 if (pIncomingCallForm != null)
353 pIncomingCallForm->CallDisconnected();
366 case FORMTYPE_CONFCALLLIST:
368 ConfCallerListForm* pConfCallerListForm = dynamic_cast<ConfCallerListForm*>(this);
369 if(pConfCallerListForm != null)
371 pConfCallerListForm->HandleParticipantsChanged();
376 case FORMTYPE_ACTIVECONFCALL:
377 case FORMTYPE_MULTIPLECALLS:
379 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
380 if(pActiveCallForm != null)
382 pActiveCallForm->HandleConfCallChanged();
392 BaseForm::HandleTelephonyError(int errorCode)
394 //show error msg Popup
395 if (__pErrorMsgPopup == null)
397 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
398 __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
403 BaseForm::HandlePopupClosed(void)
406 delete __pErrorMsgPopup;
407 __pErrorMsgPopup = null;
411 case FORMTYPE_OUTGOINGCALL:
413 //fetch no of calls from telephony
414 CallPresentationModel* pPresentor = CallPresentationModel::GetInstance();
415 if(pPresentor != null)
417 //check if any call is present
418 if(pPresentor->GetCurrentCallCount() > 0)
420 //fetch current call list
421 IListT<AppCallInfo>* pCurrentCallList = pPresentor->GetCallListN();
422 HandleCallDisconnected(false,*pCurrentCallList);
423 delete pCurrentCallList;
424 pCurrentCallList = null;
428 //No more calls are active
429 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
430 pPhoneApp->Terminate();
437 case FORMTYPE_ENDCALL:
439 //It comes here, only when we make voice call for Last call from EndCallForm
440 //and some TAPI error is encountered.
441 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
442 pPhoneApp->Terminate();