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