Fixed recursive appcontrol issue. Fixed Call reject from event injector during answer...
[apps/osp/Call.git] / inc / CallPresentationModel.h
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                PhnCallPresentationModel.h
19  * @brief               This is the header file for the %CallPresentationModel class.
20  *
21  * This header file contains the declarations for %CallPresentationModel class.
22  */
23 #ifndef _PHN_CALL_PRESENTATION_MODEL_H_
24 #define _PHN_CALL_PRESENTATION_MODEL_H_
25
26 #include <FApp.h>
27 #include "CallAppControlRequestMgr.h"
28 #include "CallTypes.h"
29 #include "CallITelephonyEventListener.h"
30 #include "CalllogManager.h"
31
32 class AppCallInfo;
33 class TelephonyManager;
34 class SettingsPresentationModel;
35
36 /**
37  * @class CallPresentationModel
38  * @brief CallPresentationModel is Singleton class and acts as interface between
39  * events from other managers and all the views.
40  *
41  */
42 class CallPresentationModel: public ITelephonyEventListener
43                 , public Tizen::App::IAppControlResponseListener
44 {
45 public:
46         //create a singleton instance
47         static CallPresentationModel* GetInstance(void);
48
49 private:
50         CallPresentationModel(void);
51         CallPresentationModel(CallPresentationModel& presentor);
52         virtual ~CallPresentationModel(void);
53         CallPresentationModel& operator =(const CallPresentationModel& presentor);
54
55         result Construct(void);
56         static void CreateInstance(void);
57         static void DestroyInstance(void);
58
59 public:
60         //set the telephony event listener
61         void SetTelEventListener(ITelephonyEventListener* pTelEventListener);
62
63         //Dial an outgoing call
64         void DialCall(Tizen::Base::String& contactNumber, bool isEmergency);
65         //End the call
66         void EndActiveCall(Tizen::Base::Long callHandle);
67         void EndDialingCall(Tizen::Base::String& contactNumber);
68         //End the conference call
69         bool EndConferenceCall(void);
70         //Ends all active calls
71         void EndAllCall(void);
72         /**
73          * Hold the call.
74          * @returns true if successful.
75          */
76         bool HoldCall(Tizen::Base::Long callHandle);
77         /**
78          * Unhold the call.
79          * @returns true if successful.
80          */
81         bool UnHoldCall(Tizen::Base::Long callHandle);
82         //Hold conference call
83         bool HoldConferenceCall(void);
84         //UnHold conference call
85         bool ActivateConferenceCall(void);
86         //Join active and held call to conference call.
87         void JoinCall(void);
88         //Swap between active and held call
89         void SwapCalls(void);
90         //Mute or Unmute Call
91         bool SetMuteStatus(bool setMute);
92         //Get the call Muted status
93         bool IsCallMuted(void);
94         //Set speaker to On or Off mode.
95         bool SetSpeakerStatus(bool setSpeaker);
96         //Get the speaker status
97         bool IsSpeakerOn(void);
98         //Send DTMF strings
99         void SendDTMFSignal(Tizen::Base::String& textToBeSent);
100         //Function to get the conference call info
101         AppCallInfo* GetConferenceCallInfoN(void);
102         //Split this call from the conference call
103         bool SplitFromConference(SplitConfCallerCmdIds splitCallerCmdId, Tizen::Base::Collection::IListT<AppCallInfo>* pConfCallList);
104         //End this single call from the conference call
105         void EndCallFromConference(EndConfCallerCmdIds endCallerCmdId, Tizen::Base::Collection::IListT<AppCallInfo>* pConfCallList);
106         //returns true, if split operation is allowed. Else, returns false.
107         bool IsSplitAllowed(void);
108         //Accept the incoming call as per the options
109         void AcceptIncomingCall(CallAnsweringOptions answerOptions,int callHandle);
110         //Reject an incoming call and send message, if required.
111         bool RejectCall(int callHandle, bool sendMsg, const Tizen::Base::String& contactNumber);
112         //Function used to add call
113         void AddCall(const Tizen::Base::String& phoneNumber);
114         //Get the current call count
115         int GetCurrentCallCount(void);
116         //Get the current call list
117         Tizen::Base::Collection::IListT<AppCallInfo>* GetCallListN(void);
118         //Check if modem and sim initialization is complete.
119         bool CheckSimInitializationIsCompleted();
120         //This function returns true, if contact number is emergency no.
121         bool IsEmergencyNumber(const Tizen::Base::String& phoneNumber, bool isSimInitialized);
122         //Start the alert in case of incoming call
123         void StartAlert(AppCallInfo& incomingCallInfo);
124         //Stop the alert in case of incoming call
125         void StopAlert(void);
126         //Gets the contact for the given phonenumber.returns null if not present.
127         Tizen::Social::Contact* GetContactN(const Tizen::Base::String& phoneNumber);
128         //Fetch the incoming call details.
129         AppCallInfo* FetchIncomingCallDetailsN(const Tizen::Base::String& callHandle, const Tizen::Base::String& contactNumber);
130         //Function is used to auto reject the call based on call settings and return true, if rejected.
131         bool CheckIncomingCallToBeRejected(AppCallInfo* pIncomingCallInfo);
132         //Launch dial appcontrol for add call senario
133         void LaunchDialAppControl();
134         //Used to check if Join button should be enabled or not
135         bool IsEnableJoinCallButton(void);
136         //Used to check if incomig call is present
137         bool IsIncomingorDialingCallPresent(void);
138         //Used to launch Messaging AppControl to compose message.
139         bool LaunchComposeMessageAppControl(Tizen::Base::String& contactNumber, Tizen::App::IAppControlResponseListener* pListener);
140         //Used to make "ViewContact" AppControl request.
141         bool LaunchViewContactAppControl(Tizen::Base::String& contactId, Tizen::App::IAppControlResponseListener* pListener);
142         //Used to make "AddContact" AppControl request.
143         bool LaunchAddContactAppControl(Tizen::Base::String& contactNumber, Tizen::App::IAppControlResponseListener* pListener);
144         //Used to check if there is any AppControl request in progress.
145         bool IsAppControlRunning(void);
146         //Used to abort any running AppControl request.
147         void AbortAppControlRequest(void);
148         //Used to complete any running AppControl request.
149         void AppControlRequestCompleted(void);
150
151         //Event Listener methods from ITelephonyEventListener
152         virtual void HandleCallConnected(Tizen::Base::Collection::IListT<AppCallInfo>& pCallList);
153         virtual void HandleCallDisconnected(bool isLastCall, Tizen::Base::Collection::IListT<AppCallInfo>& pCallList);
154         virtual void HandleConferenceCall(AppCallInfo& pCallInfo);
155         virtual void HandleIncomingCall(AppCallInfo& pCallInfo);
156         virtual void HandleCallSwapOccured(Tizen::Base::Collection::IListT<AppCallInfo>& pCallList);
157         virtual void HandleConferenceChange(void);
158         virtual void HandleTelephonyError(int errorCode);
159         //From IAppControlResponseListener
160         virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData);
161         virtual void OnAppForeground(void);
162
163 private:
164         static CallPresentationModel* __pInstance;
165         //to forward telephony events
166         ITelephonyEventListener* __pTelEventListener;
167         TelephonyManager* __pTelephonyMgr;
168         SettingsPresentationModel* __pSettingsPresentor;
169         // This is only to save PhoneApp from closing when only 1 incoming call is present and
170         // incoming call is rejected with "Reject With message" by opening Msg AppControl.
171         bool __isMessageAppControlRunning;
172         bool __isDialAppControlRunning;
173         //Used to manage AppControl requests.
174         CallAppControlRequestMgr* __pAppControlMgr;
175 };
176
177 #endif // _PHN_CALL_PRESENTATION_MODEL_H_