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 "CallBaseForm.h"
24 #include "CallPresentationModel.h"
25 #include "CallConfCallerListForm.h"
26 #include "CallPhoneFormFactory.h"
27 #include "CallSceneRegister.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 //To be implemented in sub classes
57 BaseForm::OnActionPerformed(const Control& source, int actionId)
61 /////////////////////////////////////////////////////////////////
62 ///// Event Listener methods from ITelephonyEventListener /////
63 /////////////////////////////////////////////////////////////////
66 BaseForm::HandleCallConnected(IListT<AppCallInfo>& pCallList)
68 SceneManager* pSceneManager = SceneManager::GetInstance();
72 case FORMTYPE_OUTGOINGCALL:
73 case FORMTYPE_INCOMINGCALL:
74 case FORMTYPE_CONFCALLLIST:
75 case FORMTYPE_ACTIVECALL:
76 case FORMTYPE_ACTIVECONFCALL:
78 int noOfCalls = pCallList.GetCount();
79 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
80 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
81 pCallInfoList->Construct(noOfCalls);
83 for (int index = 0; index < noOfCalls; index++)
85 //fetch call info and add to list
87 result r = pCallList.GetAt(index, callInfo);
90 //copy call information to new instance
91 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
93 pCallInfoList->Add(pCaller);
99 //Check if active call is conference call
100 AppCallInfo* pActiveCallInfo = static_cast<AppCallInfo*>(pCallInfoList->GetAt(0));
101 if(pActiveCallInfo->IsConferenceCall() == true)
103 //single Conference call - goto active Conf. call form
104 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
108 //single active call - goto active call form
109 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
112 else if(noOfCalls == 2)
114 //goto multiple active call form
115 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
120 case FORMTYPE_MULTIPLECALLS:
122 //This case can come on Multiple Calls screen, when one of the calls is conference call with 2 participants
123 //and one of the participants exits himself from ConfCall.
124 int noOfCalls = pCallList.GetCount();
125 AppLogDebug("Active Call Count = %d", noOfCalls);
126 //this is just a safety check, call count will aleays be 2 here.
127 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
128 if(noOfCalls == IDI_MAX_ACTIVE_CALLS && pActiveCallForm != null)
131 pActiveCallForm->UpdateMultipleCallScreen(pCallList);
136 case FORMTYPE_EMERGENCYOUTGOINGCALL:
138 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
139 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
140 pCallInfoList->Construct(1);
142 //fetch call info and add to list
143 AppCallInfo callInfo;
144 result r = pCallList.GetAt(0, callInfo);
147 //copy call information to new instance
148 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
150 pCallInfoList->Add(pCaller);
151 //single active call - goto active call form
152 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVE_EMERGENCYCALL), pCallInfoList);
163 BaseForm::HandleCallDisconnected(bool isLastCall, IListT<AppCallInfo>& pCallList)
165 SceneManager* pSceneManager = SceneManager::GetInstance();
166 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
168 int callCount = pCallList.GetCount();
171 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
172 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
173 pCallInfoList->Construct(callCount);
174 for (int index = 0; index < callCount; index++)
176 //fetch call info and add to list
177 AppCallInfo callInfo;
178 result r = pCallList.GetAt(index, callInfo);
181 //copy call information to new instance
182 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
184 pCallInfoList->Add(pCaller);
189 //fetch call info and add to list
190 AppCallInfo callInfo;
191 result r = pCallList.GetAt(0, callInfo);
194 //copy call information to new instance
195 AppCallInfo* pCaller = new (std::nothrow) AppCallInfo();
197 pCallInfoList->Add(pCaller);
200 if (isLastCall == true)
202 //goto End Call form if single call. else terminate
203 if (callInfo.IsConferenceCall() == false)
205 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ENDCALL), pCallInfoList);
209 pPhoneApp->Terminate();
214 if (pCallList.GetCount() == 1)
216 if (callInfo.IsConferenceCall() == true)
218 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
222 //goto Single Active Call form
223 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_ACTIVECALL), pCallInfoList);
230 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MULTIPLEACTIVECALL), pCallInfoList);
235 pPhoneApp->Terminate();
241 BaseForm::HandleConferenceCall(AppCallInfo& pCallInfo)
243 SceneManager* pSceneManager = SceneManager::GetInstance();
245 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
246 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
247 pCallInfoList->Construct(1);
249 //update list to be passed
250 AppCallInfo* pConfInfo = new (std::nothrow) AppCallInfo();
251 *pConfInfo = pCallInfo;
252 pCallInfoList->Add(pConfInfo);
254 //Todo: create screens for single conf call and conf call with another held call
255 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CONFCALL), pCallInfoList);
259 BaseForm::HandleIncomingCall(AppCallInfo& pCallInfo)
261 SceneManager* pSceneManager = SceneManager::GetInstance();
263 //Ownership - To be deleted in 'OnSceneActivatedN' of next form
264 ArrayList* pCallInfoList = new (std::nothrow) ArrayList(SingleObjectDeleter);
265 pCallInfoList->Construct(1);
267 //update list to be passed
268 AppCallInfo* pIncomingCall = new (std::nothrow) AppCallInfo();
269 *pIncomingCall = pCallInfo;
270 pCallInfoList->Add(pIncomingCall);
272 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_INCOMINGCALL), pCallInfoList);
276 BaseForm::HandleCallSwapOccured(IListT<AppCallInfo>& pCallList)
278 int noOfCalls = pCallList.GetCount();
279 if(noOfCalls != IDI_MAX_ACTIVE_CALLS && __formType != FORMTYPE_MULTIPLECALLS)
283 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
284 if(pActiveCallForm != null)
287 pActiveCallForm->UpdateMultipleCallScreen(pCallList);
292 BaseForm::HandleConferenceChange(void)
296 case FORMTYPE_CONFCALLLIST:
298 ConfCallerListForm* pConfCallerListForm = dynamic_cast<ConfCallerListForm*>(this);
299 if(pConfCallerListForm != null)
301 pConfCallerListForm->HandleParticipantsChanged();
306 case FORMTYPE_ACTIVECONFCALL:
307 case FORMTYPE_MULTIPLECALLS:
309 ActiveCallForm* pActiveCallForm = dynamic_cast<ActiveCallForm*>(this);
310 if(pActiveCallForm != null)
312 pActiveCallForm->HandleConfCallChanged();
322 BaseForm::HandleTelephonyError(int errorCode)
324 //show error msg Popup
325 if (__pErrorMsgPopup == null)
327 __pErrorMsgPopup = new (std::nothrow) ErrorMsgPopup(this);
329 __pErrorMsgPopup->ShowErrorMsgPopupN(errorCode);
333 BaseForm::HandlePopupClosed(void)
336 delete __pErrorMsgPopup;
337 __pErrorMsgPopup = null;
341 case FORMTYPE_OUTGOINGCALL:
343 //fetch no of calls from telephony
344 CallPresentationModel* pPresentor = CallPresentationModel::GetInstance();
345 if(pPresentor != null)
347 //check if any call is present
348 if(pPresentor->GetCurrentCallCount() > 0)
350 //fetch current call list
351 IListT<AppCallInfo>* pCurrentCallList = pPresentor->GetCallListN();
352 HandleCallDisconnected(false,*pCurrentCallList);
353 delete pCurrentCallList;
354 pCurrentCallList = null;
358 //No more calls are active
359 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
360 pPhoneApp->Terminate();
367 case FORMTYPE_ENDCALL:
369 //It comes here, only when we make voice call for Last call from EndCallForm
370 //and some TAPI error is encountered.
371 CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
372 pPhoneApp->Terminate();