7108c619fab01bd454250fa0acffc8db153e5fcb
[apps/osp/Call.git] / src / CallPresentationModel.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file        CallCallPresentationModel.cpp
19  * @brief       Call Presentation model class
20  */
21 #include <FApp.h>
22 #include <FUi.h>
23 #include <FMedia.h>
24 #include "CallApp.h"
25 #include "CallAppControlRequestMgr.h"
26 #include "CallActiveCallForm.h"
27 #include "CallInfo.h"
28 #include "CallPresentationModel.h"
29 #include "CallSettingsPresentationModel.h"
30 #include "CallConfCallerListForm.h"
31 #include "CallTelephonyManager.h"
32 #include "CallSceneRegister.h"
33 #include "CallTypes.h"
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::App;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Media;
40 using namespace Tizen::Social;
41 using namespace Tizen::Ui::Scenes;
42 using namespace Tizen::Telephony;
43
44 CallPresentationModel* CallPresentationModel::__pInstance = null;
45
46 CallPresentationModel::CallPresentationModel(void)
47 {
48         __pTelephonyMgr = null;
49         __pTelEventListener = null;
50         __pSettingsPresentor = null;
51         __isMessageAppControlRunning = false;
52         __isDialAppControlRunning = false;
53         __pAppControlMgr = null;
54 }
55
56 CallPresentationModel::~CallPresentationModel(void)
57 {
58         __pTelephonyMgr = null;
59         __pSettingsPresentor = null;
60         __pAppControlMgr =null;
61 }
62
63 void
64 CallPresentationModel::CreateInstance(void)
65 {
66         __pInstance = new (std::nothrow) CallPresentationModel();
67         result r = __pInstance->Construct();
68         if(IsFailed(r))
69         {
70                 delete __pInstance;
71                 __pInstance = null;
72                 return;
73         }
74
75         std::atexit(DestroyInstance);
76 }
77
78 CallPresentationModel*
79 CallPresentationModel::GetInstance(void)
80 {
81         if (__pInstance == null)
82         {
83                 CreateInstance();
84         }
85         return __pInstance;
86 }
87
88 void
89 CallPresentationModel::DestroyInstance(void)
90 {
91         if (__pInstance != null)
92         {
93                 delete __pInstance;
94                 __pInstance = null;
95         }
96 }
97
98 result
99 CallPresentationModel::Construct(void)
100 {
101         //Fetch Telephony Manager
102         __pTelephonyMgr = TelephonyManager::GetInstance(this);
103         __pSettingsPresentor = SettingsPresentationModel::GetInstance();
104         __pAppControlMgr = CallAppControlRequestMgr::GetInstance();
105         return E_SUCCESS;
106 }
107
108 void
109 CallPresentationModel::SetTelEventListener(ITelephonyEventListener* pTelEventListener)
110 {
111         //set form as telephony event listener
112         __pTelEventListener = pTelEventListener;
113 }
114
115 void
116 CallPresentationModel::DialCall(String& contactNumber, bool isEmergency)
117 {
118         int errorCode = ERROR_NONE;
119         bool isCallServiceAvailable = false;
120         NetworkStatus networkStatus;
121         NetworkManager* pNetworkManager = new NetworkManager();
122         result r;
123         //Check if Telephony Manager is initialized
124         TryCatch(__pTelephonyMgr != null, (errorCode = ERROR_TAPI_INIT_FAILED), "TAPI initialization failed");
125
126         //check if phone is in flight mode
127         if(__pSettingsPresentor != null && __pSettingsPresentor->GetFlightModeStatus() == true)
128         {
129                 __pTelEventListener->HandleTelephonyError(ERROR_FLIGHT_MODE_SET);
130                 return;
131         }
132         //Check if dialing a call is possible - Check if sim is available
133         if (GetSimInfo() == E_FAILURE)
134         {
135                 __pTelEventListener->HandleTelephonyError(ERROR_CODE_SIM_INITIALIZATION_FAILED);
136                 return ;
137         }
138
139         //fetch call service status
140         r = pNetworkManager->Construct(null);
141         if (r == E_SUCCESS)
142         {
143                 r = pNetworkManager->GetNetworkStatus(networkStatus);
144                 if (r == E_SUCCESS)
145                 {
146                         isCallServiceAvailable = networkStatus.IsCallServiceAvailable();
147                 }
148         }
149         delete pNetworkManager;
150
151         if (isCallServiceAvailable == false)
152         {
153                 __pTelEventListener->HandleTelephonyError(ERROR_DIAL_FAILED);
154                 return ;
155         }
156         //setup outgoing call
157         errorCode = __pTelephonyMgr->SetupMoCall(contactNumber, isEmergency);
158         TryCatch(errorCode == ERROR_NONE,,"Error occurred while setup MO call");
159         if(__pSettingsPresentor != null)
160         {
161                 __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_CONNECTING);
162         }
163         return;
164
165 CATCH:
166         __pTelEventListener->HandleTelephonyError(errorCode);
167 }
168
169 void
170 CallPresentationModel::EndActiveCall(Long callHandle)
171 {
172         if(__pTelephonyMgr != null)
173         {
174                 __pTelephonyMgr->EndActiveCall(callHandle);
175         }
176 }
177
178 void
179 CallPresentationModel::EndDialingCall(String& contactNumber)
180 {
181         if(__pTelephonyMgr != null)
182         {
183                 __pTelephonyMgr->EndDialingCall(contactNumber);
184         }
185 }
186
187 bool
188 CallPresentationModel::EndConferenceCall(void)
189 {
190         result r = __pTelephonyMgr->EndConferenceCall();
191         if (IsFailed(r))
192         {
193                 //TODO: send proper error code
194                 __pTelEventListener->HandleTelephonyError(ERROR_GENERAL);
195                 return false;
196         }
197         return true;
198 }
199
200 void
201 CallPresentationModel::EndAllCall(void)
202 {
203         if(__pTelephonyMgr != null)
204         {
205                 __pTelephonyMgr->EndAllCalls();
206         }
207 }
208 bool
209 CallPresentationModel::HoldCall(Tizen::Base::Long callHandle)
210 {
211         result r = __pTelephonyMgr->HoldCall(callHandle, true);
212         return (!IsFailed(r));
213 }
214
215 bool
216 CallPresentationModel::UnHoldCall(Tizen::Base::Long callHandle)
217 {
218         result r = __pTelephonyMgr->HoldCall(callHandle, false);
219         return (!IsFailed(r));
220 }
221
222 bool
223 CallPresentationModel::HoldConferenceCall(void)
224 {
225         result r = __pTelephonyMgr->HoldConferenceCall(true);
226         return (!IsFailed(r));
227 }
228
229 bool
230 CallPresentationModel::ActivateConferenceCall(void)
231 {
232         result r = __pTelephonyMgr->HoldConferenceCall(false);
233         return (!IsFailed(r));
234 }
235
236 void
237 CallPresentationModel::JoinCall(void)
238 {
239         result r = __pTelephonyMgr->JoinCall();
240         if (IsFailed(r))
241         {
242                 __pTelEventListener->HandleTelephonyError(ERROR_JOIN_FAILED);
243         }
244 }
245
246 void
247 CallPresentationModel::SwapCalls(void)
248 {
249         result r = __pTelephonyMgr->SwapCalls();
250         if (IsFailed(r))
251         {
252                 __pTelEventListener->HandleTelephonyError(ERROR_SWAP_FAILED);
253         }
254 }
255
256 bool
257 CallPresentationModel::SetMuteStatus(bool setMute)
258 {
259         result r = __pTelephonyMgr->SetMuteStatus(setMute);
260         return (!IsFailed(r));
261 }
262
263 bool
264 CallPresentationModel::IsCallMuted(void)
265 {
266         return __pTelephonyMgr->IsCallMuted();
267 }
268
269 bool
270 CallPresentationModel::SetSpeakerStatus(bool setSpeaker)
271 {
272         result r = __pTelephonyMgr->SetSpeakerStatus(setSpeaker);
273         return (!IsFailed(r));
274 }
275
276 bool
277 CallPresentationModel::IsSpeakerOn(void)
278 {
279         return __pTelephonyMgr->IsSpeakerOn();
280 }
281 void
282 CallPresentationModel::SendDTMFSignal(String& textToBeSent)
283 {
284         __pTelephonyMgr->SendCallDTMF(textToBeSent);
285 }
286
287 AppCallInfo*
288 CallPresentationModel::GetConferenceCallInfoN(void)
289 {
290         return __pTelephonyMgr->GetConferenceCallInfoN();
291 }
292
293 bool
294 CallPresentationModel::SplitFromConference(SplitConfCallerCmdIds splitCallerCmdId, IListT<AppCallInfo>* pConfCallList)
295 {
296         int callIndex = -1;
297         AppCallInfo callToBeSpli;
298         switch (splitCallerCmdId)
299         {
300         case IDA_SPLIT_CALLER1:
301                 callIndex = 0;
302                 break;
303
304         case IDA_SPLIT_CALLER2:
305                 callIndex = 1;
306                 break;
307
308         case IDA_SPLIT_CALLER3:
309                 callIndex = 2;
310                 break;
311
312         case IDA_SPLIT_CALLER4:
313                 callIndex = 3;
314                 break;
315
316         case IDA_SPLIT_CALLER5:
317                 callIndex = 4;
318                 break;
319
320         default:
321         break;
322         }
323
324         result r = pConfCallList->GetAt(callIndex, callToBeSpli);
325         TryCatch(r == E_SUCCESS,,"conf. call list corrupted");
326         //split single call from conference
327         r = __pTelephonyMgr->SplitFromConference(callToBeSpli.GetCallHandle()->ToLong());
328         TryCatch(r == E_SUCCESS,,"Split from conf. call failed");
329         return true;
330
331 CATCH:
332         __pTelEventListener->HandleTelephonyError(ERROR_SPLIT_FROM_CONFERENCE_FAILED);
333         return false;
334 }
335
336 void
337 CallPresentationModel::EndCallFromConference(EndConfCallerCmdIds endCallerCmdId, IListT<AppCallInfo>* pConfCallList)
338 {
339         int callIndex = -1;
340         AppCallInfo callToBeEnded;
341         switch (endCallerCmdId)
342         {
343         case IDA_END_CALLER1:
344                 callIndex = 0;
345                 break;
346
347         case IDA_END_CALLER2:
348                 callIndex = 1;
349                 break;
350
351         case IDA_END_CALLER3:
352                 callIndex = 2;
353                 break;
354
355         case IDA_END_CALLER4:
356                 callIndex = 3;
357                 break;
358
359         case IDA_END_CALLER5:
360                 callIndex = 4;
361                 break;
362
363         default:
364         break;
365         }
366
367         result r = pConfCallList->GetAt(callIndex, callToBeEnded);
368         TryCatch(r == E_SUCCESS,,"conference call list corrupted");
369         //end single call
370         r = __pTelephonyMgr->EndFromConference(callToBeEnded.GetCallHandle()->ToLong());
371         TryCatch(r == E_SUCCESS,,"End single call from conference call failed");
372
373         return;
374
375 CATCH:
376         __pTelEventListener->HandleTelephonyError(ERROR_END_CALL_FAILED);
377         return;
378 }
379
380 bool
381 CallPresentationModel::IsSplitAllowed(void)
382 {
383         return __pTelephonyMgr->IsSplitAllowed();
384 }
385
386 void
387 CallPresentationModel::AcceptIncomingCall(CallAnsweringOptions answerOptions,int callHandle)
388 {
389         result r = E_FAILURE;
390         if (answerOptions == ANSERWING_OPTION_ACCEPT_CALL)
391         {
392                 r = __pTelephonyMgr->AnswerCall(callHandle, true);
393         }
394         else
395         {
396                 r = __pTelephonyMgr->AcceptCall(answerOptions,callHandle);
397         }
398         if (IsFailed(r))
399         {
400                 __pTelEventListener->HandleTelephonyError(ERROR_GENERAL);
401         }
402 }
403
404 IListT<AppCallInfo>*
405 CallPresentationModel::GetCallListN(void)
406 {
407         return __pTelephonyMgr->GetCallListN();
408 }
409
410
411 bool
412 CallPresentationModel::RejectCall(int callHandle, bool sendMsg, const String& contactNumber)
413 {
414         AppLogDebug("Enter");
415         if (sendMsg == true && __pAppControlMgr != null)
416         {
417                 //launch compose message AppControl
418                 __isMessageAppControlRunning = __pAppControlMgr->LaunchComposeMessageAppControl(*(const_cast<String*>(&contactNumber)), this);
419         }
420         result r = __pTelephonyMgr->AnswerCall(callHandle, false);
421         if (IsFailed(r))
422         {
423                 __pTelEventListener->HandleTelephonyError(ERROR_GENERAL);
424                 return false;
425         }
426
427
428         AppLogDebug("Exit");
429         return true;
430 }
431
432 void CallPresentationModel::OnAppForeground(void)
433 {
434         if (__isDialAppControlRunning == true)
435         {
436                 //This comes here, when Dialer AppControl is finished working.
437                 __isDialAppControlRunning = false;
438                 __pAppControlMgr->AppControlRequestCompleted();
439         }
440         if (__isMessageAppControlRunning == true)
441         {
442                 //This comes here, when Message AppControl is finished working.
443                 __isMessageAppControlRunning = false;
444                 __pAppControlMgr->AppControlRequestCompleted();
445                 //Check if this was the last call, then terminate application.
446                 //And if any calls are active, then those cases are already handled from Other places.
447                 if( GetCurrentCallCount() == 0)
448                 {
449                         CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
450                         pPhoneApp->Terminate();
451                 }
452         }
453 }
454
455 void
456 CallPresentationModel::OnAppControlCompleteResponseReceived(const AppId& appId, const String& operationId, AppCtrlResult appControlResult, const IMap* pExtraData)
457 {
458         AppLogDebug("Enter");
459         if (__isMessageAppControlRunning == true)
460         {
461                 //This comes here, when Message AppControl is finished working.
462                 __isMessageAppControlRunning = false;
463                 __pAppControlMgr->AppControlRequestCompleted();
464                 //Check if this was the last call, then terminate application.
465                 //And if any calls are active, then those cases are already handled from Other places.
466                 if( GetCurrentCallCount() == 0)
467                 {
468                         CallApp* pPhoneApp = static_cast<CallApp*>(UiApp::GetInstance());
469                         pPhoneApp->Terminate();
470                 }
471         }
472         if(appId.Equals(PROVIDER_ID_PHONE,false) == true &&  operationId.Equals(OPERATION_ID_DIAL,false) == true)
473         {
474                 __isDialAppControlRunning = false;
475
476                 __pAppControlMgr->AppControlRequestCompleted();
477                 if(appControlResult == APP_CTRL_RESULT_SUCCEEDED)
478                 {
479                         String* pKey = new (std::nothrow) String(PARAM_PHONE_NUMBER);
480                         if (pExtraData->ContainsKey(*pKey) == true)
481                         {
482                                 const String* pPhoneNumber = static_cast<const String*>(pExtraData->GetValue(*pKey));
483                                 if(pPhoneNumber != null && pPhoneNumber->IsEmpty() == false)
484                                 {
485                                         AddCall(*pPhoneNumber);
486                                 }
487
488                         }
489
490                 }
491
492         }
493 }
494
495 void
496 CallPresentationModel::AddCall(const String& phoneNumber)
497 {
498         ArrayList* pLaunchArgs = null;
499         SceneManager* pSceneManager = SceneManager::GetInstance();
500         int currentActiveCallCount = GetCurrentCallCount();
501         if(currentActiveCallCount <= 1 && IsIncomingorDialingCallPresent() == false)
502         {
503                 //make an outgoing call with given number
504                 String* contactTxt = new (std::nothrow) String(phoneNumber);
505                 pLaunchArgs =  new (std::nothrow) ArrayList(SingleObjectDeleter);
506                 pLaunchArgs->Construct();
507                 pLaunchArgs->Add(contactTxt);
508                 bool isEmergencyCall = IsEmergencyNumber(*contactTxt, true);
509
510                 SceneId nextScene = IDSCN_SCENE_OUTCALL;
511                 if (isEmergencyCall)
512                 {
513                         nextScene = IDSCN_SCENE_OUT_EMERGENCYCALL;
514                 }
515                 pSceneManager->GoForward( ForwardSceneTransition( nextScene), pLaunchArgs);
516
517         }
518 }
519
520 int
521 CallPresentationModel::GetCurrentCallCount(void)
522 {
523         return __pTelephonyMgr->GetCurrentCallCount();
524 }
525
526 bool
527 CallPresentationModel::CheckSimInitializationIsCompleted()
528 {
529         result r = E_FAILURE;
530         if(__pTelephonyMgr != null)
531         {
532                 r = __pTelephonyMgr->CheckIfMOCallIsPossible();
533         }
534         return (!IsFailed(r));
535 }
536
537 bool
538 CallPresentationModel::IsEmergencyNumber(const Tizen::Base::String& phoneNumber, bool isSimInitialized)
539 {
540         return __pTelephonyMgr->CheckIfMOCallIsEmergency(phoneNumber, isSimInitialized);
541 }
542
543 void
544 CallPresentationModel::StartAlert(AppCallInfo& incomingCallInfo)
545 {
546         //Adding incoming call sate setting here
547         if(__pSettingsPresentor != null)
548         {
549                 __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_CONNECTING);
550         }
551         __pTelephonyMgr->StartAlert(incomingCallInfo);
552 }
553
554 void
555 CallPresentationModel::StopAlert(void)
556 {
557         __pTelephonyMgr->StopAlert();
558 }
559
560 Contact*
561 CallPresentationModel::GetContactN(const String& phoneNumber)
562 {
563         return __pTelephonyMgr->GetContactN(phoneNumber);
564 }
565
566 AppCallInfo*
567 CallPresentationModel::FetchIncomingCallDetailsN(const String& callHandle, const String& contactNumber)
568 {
569
570         return __pTelephonyMgr->FetchIncomingCallHandleN(callHandle, contactNumber);
571 }
572
573 bool
574 CallPresentationModel::CheckIncomingCallToBeRejected(AppCallInfo* pIncomingCallInfo)
575 {
576         return __pTelephonyMgr->CheckIncomingCallToBeRejected(pIncomingCallInfo);
577 }
578
579 /////////////////////////////////////////////////////////////////
580 /////  Event Listener methods from ITelephonyEventListener  /////
581 /////////////////////////////////////////////////////////////////
582 void
583 CallPresentationModel::HandleCallConnected(Tizen::Base::Collection::IListT<AppCallInfo>& pCallList)
584 {
585         if (__pTelEventListener != null)
586         {
587                 __pTelEventListener->HandleCallConnected(pCallList);
588         }
589         if(__pSettingsPresentor != null)
590         {
591                 __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_ACTIVE);
592         }
593 }
594
595 void
596 CallPresentationModel::HandleCallDisconnected(bool isLastCall, Tizen::Base::Collection::IListT<AppCallInfo>& pCallList)
597 {
598         AppLogDebug("Enter");
599         if (isLastCall == true)
600         {
601                 SetSpeakerStatus(false);
602                 SetMuteStatus(false);
603                 if(__pSettingsPresentor != null)
604                 {
605                         __pSettingsPresentor->SetCallState(CALL_STATE_CALL_OFF);
606                 }
607         }
608         else
609         {
610                 if(__pSettingsPresentor != null)
611                 {
612                         __pSettingsPresentor->SetCallState(CALL_STATE_CALL_VOICE_ACTIVE);
613                 }
614         }
615         //1) Defer from sending call disconnected event to form, in case Msg AppControl is running,
616         //to avoid PhoneApp from going to EndCall form, where it shows for 3 sec. and automatically closes.
617         //2) Do not send call disconnected event to any form, in case an incoming call or dialing call is present.
618         if (__pTelEventListener != null /*&& __isMessageAppControlRunning == false*/ )
619         {
620                 __pTelEventListener->HandleCallDisconnected(isLastCall, pCallList);
621         }
622 }
623
624 void
625 CallPresentationModel::HandleConferenceCall(AppCallInfo& pCallInfo)
626 {
627         if (__pTelEventListener != null)
628         {
629                 __pTelEventListener->HandleConferenceCall(pCallInfo);
630         }
631 }
632
633 void
634 CallPresentationModel::HandleIncomingCall(AppCallInfo& pCallInfo)
635 {
636         AppLogDebug("Error - This will never come here. Since, now we are getting incoming call event through AppControl!!");
637 }
638
639 void
640 CallPresentationModel::HandleCallSwapOccured(Tizen::Base::Collection::IListT<AppCallInfo>& pCallList)
641 {
642         if (__pTelEventListener != null)
643         {
644                 __pTelEventListener->HandleCallSwapOccured(pCallList);
645         }
646 }
647
648 void
649 CallPresentationModel::HandleConferenceChange(void)
650 {
651         //1) Do not send conf. call changed event to any form, in case an incoming call or dialing call is present.
652         if (__pTelEventListener != null)
653         {
654                 __pTelEventListener->HandleConferenceChange();
655         }
656 }
657
658 void
659 CallPresentationModel::HandleTelephonyError(int errorCode)
660 {
661         if (__pTelEventListener != null)
662         {
663                 __pTelEventListener->HandleTelephonyError(errorCode);
664         }
665 }
666
667 void
668 CallPresentationModel::LaunchDialAppControl()
669 {
670
671         if(__isDialAppControlRunning == true)
672         {
673                 //Do not allow another app control if already running
674                 return;
675         }
676
677         //Launch dialer AppControl
678         if (__pAppControlMgr != null)
679         {
680                 __isDialAppControlRunning = __pAppControlMgr->LaunchDialerAppControl(this);
681         }
682
683 }
684
685 bool
686 CallPresentationModel::IsEnableJoinCallButton(void)
687 {
688         //Check if conf. call has maximum participants
689         AppCallInfo* pConfCallInfo = GetConferenceCallInfoN();
690         if(pConfCallInfo != null && pConfCallInfo->GetCallerListCount() >= IDI_MAX_CONF_CALL_PARTICIPANTS)
691         {
692                 return false;
693         }
694
695         //check if either of the caller is same or present in conf call.
696         IListT<AppCallInfo>* pActiveCallList = GetCallListN();
697         if ( pActiveCallList != null && pActiveCallList->GetCount() == IDI_MAX_ACTIVE_CALLS)
698         {
699                 AppCallInfo firstCall;
700                 AppCallInfo secondCall;
701                 pActiveCallList->GetAt(0, firstCall);
702                 pActiveCallList->GetAt(1, secondCall);
703
704                 if (firstCall.IsConferenceCall() == true)
705                 {
706                         IListT<AppCallInfo>* pConfMemberList = firstCall.GetCallerList();
707                         for (int index = 0; index < pConfMemberList->GetCount(); index++)
708                         {
709                                 AppCallInfo singleConfMember;
710                                 pConfMemberList->GetAt(index, singleConfMember);
711                                 if (secondCall.GetContactNumber().IsEmpty() == false && secondCall.GetContactNumber().Equals(singleConfMember.GetContactNumber()) == true)
712                                 {
713                                         return false;
714                                 }
715                         }
716                 }
717                 else if (secondCall.IsConferenceCall() == true)
718                 {
719                         IListT<AppCallInfo>* pConfMemberList = secondCall.GetCallerList();
720                         for (int index = 0; index < pConfMemberList->GetCount(); index++)
721                         {
722                                 AppCallInfo singleConfMember;
723                                 pConfMemberList->GetAt(index, singleConfMember);
724                                 if (firstCall.GetContactNumber().IsEmpty() == false && firstCall.GetContactNumber().Equals(singleConfMember.GetContactNumber()) == true)
725                                 {
726                                         return false;
727                                 }
728                         }
729                 }
730                 else
731                 {
732                         //Now, we definitely know that both are single active calls.
733                         if (firstCall.GetContactNumber().IsEmpty() == false && firstCall.GetContactNumber().Equals(secondCall.GetContactNumber()) == true)
734                         {
735                                 return false;
736                         }
737                 }
738         }
739         delete pConfCallInfo;
740         pConfCallInfo = null;
741         return true;
742 }
743
744 bool
745 CallPresentationModel::IsIncomingorDialingCallPresent(void)
746 {
747         //returns false, if incoming call or dialed call is present.
748         return __pTelephonyMgr->IsIncomingorDialingCallPresent();
749 }
750
751 bool
752 CallPresentationModel::LaunchComposeMessageAppControl(String& contactNumber, IAppControlResponseListener* pListener)
753 {
754         if (__pAppControlMgr != null)
755         {
756                 return __pAppControlMgr->LaunchComposeMessageAppControl(contactNumber, pListener);
757         }
758         return false;
759 }
760
761 bool
762 CallPresentationModel::LaunchViewContactAppControl(String& contactId, IAppControlResponseListener* pListener)
763 {
764         if (__pAppControlMgr != null)
765         {
766                 return __pAppControlMgr->LaunchViewContactAppControl(contactId, pListener);
767         }
768         return false;
769 }
770
771 bool
772 CallPresentationModel::LaunchAddContactAppControl(Tizen::Base::String& contactNumber, Tizen::App::IAppControlResponseListener* pListener)
773 {
774         if (__pAppControlMgr != null)
775         {
776                 return __pAppControlMgr->LaunchAddContactAppControl(contactNumber, pListener);
777         }
778         return false;
779 }
780
781 bool
782 CallPresentationModel::IsAppControlRunning(void)
783 {
784         if (__pAppControlMgr != null)
785         {
786                 return __pAppControlMgr->IsAppControlRunning();
787         }
788         return false;
789 }
790
791 void
792 CallPresentationModel::AbortAppControlRequest(void)
793 {
794         if (__pAppControlMgr != null)
795         {
796                 __pAppControlMgr->AbortAppControlRequest();
797         }
798 }
799
800 void
801 CallPresentationModel::AppControlRequestCompleted(void)
802 {
803         if (__pAppControlMgr != null)
804         {
805                 __pAppControlMgr->AppControlRequestCompleted();
806         }
807 }
808
809 result
810 CallPresentationModel::GetSimInfo(void)
811 {
812         int mnc;
813         int mcc;
814         bool isAvailable;
815         String spn;
816         String iccId;
817         String operatorName;
818
819         SimStateManager simStateManager;
820         SimInfo simInfo;
821
822         result r = simStateManager.Construct();
823         if (IsFailed(r))
824         {
825                 return E_FAILURE;
826         }
827
828         r = simStateManager.GetSimInfo(simInfo);
829         if (IsFailed(r))
830         {
831                 return E_FAILURE;
832         }
833
834         mnc = simInfo.GetMnc();
835         mcc = simInfo.GetMcc();
836         spn = simInfo.GetSpn();
837         iccId = simInfo.GetIccId();
838         operatorName = simInfo.GetOperatorName();
839         //Checks whether a SIM card is present in the device or not
840         isAvailable = simInfo.IsAvailable();
841         if(isAvailable == true)
842         {
843                 return E_SUCCESS;
844         }
845         else
846         {
847                 return E_FAILURE;
848         }
849 }