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