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 PhnTelephonyManager.h
19 * @brief This is the header file for the %TelephonyManager class.
21 * This header file contains the declarations for %TelephonyManager class.
23 #ifndef _PHN_TELEPHONY_MANAGER_H_
24 #define _PHN_TELEPHONY_MANAGER_H_
28 #include "ITapiCall.h"
29 #include "TapiUtility.h"
30 #include "PhnITelephonyEventListener.h"
31 #include "PhnSoundManager.h"
32 #include "PhnCalllogManager.h"
35 class SettingsManager;
38 * @class TelephonyManager
39 * @brief TelephonyManager is a singleton class used to intialize TAPI library.
40 * And register to telephony events, interact with TAPI library.
42 class TelephonyManager
45 //Get singleton instance
46 static TelephonyManager* GetInstance(ITelephonyEventListener* pEventListener);
47 //Function to initiate (dial) an outgoing call.
48 ErrorCodes SetupMoCall(Tizen::Base::String& contactNumber, bool isEmergency);
49 //Function to end a call
50 result EndCall(Tizen::Base::Long callHandle);
51 result EndCall(Tizen::Base::String& contactNumber);
52 //Function to accept/reject an incoming call
53 result AnswerCall(int callHandle, bool acceptCall);
54 //Function to accept call with the given options
55 result AcceptCall(CallAnswerOptions answerOptions,int callHandle);
56 //Function to end a conference call
57 result EndConferenceCall(void);
58 //Function to hold/retrieve a conference call
59 result HoldConferenceCall(bool holdCall);
60 //Function to join active and held call to conference
61 result JoinCall(void);
62 //Function to hold/unhold the call
63 result HoldCall(Tizen::Base::Long callHandle, bool holdCall);
64 //Function to swap the active and held call
65 result SwapCalls(void);
66 //Function to send DTMF strings
67 result SendCallDTMF(Tizen::Base::String& textToBeSent);
68 //Function to end a single call from the conference
69 result EndFromConference(int callHandle);
70 //Function to split a single call from the conference
71 result SplitFromConference(int callHandle);
72 //Function to set the mute status
73 result SetMuteStatus(bool setMute);
74 //Function to get the mute Status
75 bool IsCallMuted(void);
76 //Function to set the speaker status
77 result SetSpeakerStatus(bool setSpeaker);
78 //Function to get the speaker status
79 bool IsSpeakerOn(void);
80 //Function to check if split operation is allowed from the conference
81 bool IsSplitAllowed(void);
82 //Function to get the conference call info
83 CallInfo* GetConferenceCallInfoN(void);
84 //Get the current call list
85 Tizen::Base::Collection::IListT<CallInfo>* GetCallListN(void);
86 //Get the current call count
87 int GetCurrentCallCount(void);
88 //Start the alert in case of incoming call
89 void StartAlert(CallInfo& incomingCallInfo);
90 //Stop the alert in case of incoming call
92 //Main Callback function used while registering to TAPI
93 static void HandleCallback(TapiHandle* pHandle, const char* pNotiId, void* pData, void* pUserData);
94 //Dummy callback function used when nothing is to be done on response
95 static void HandleCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
96 //callback function used when dialed call is ended
97 static void HandleEndDialedCallResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
98 //callback function for dial operation
99 static void HandleDialCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
100 //callback function for the join operation
101 static void HandleJoinCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
102 //callback function for the reject call operation
103 static void HandleRejectCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
104 //callback function for the swap calls operation
105 static void HandleSwapCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
106 //callback function for the End from conference operation
107 static void HandleEndFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
108 //callback function for the split from conference operation
109 static void HandleSplitFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
110 //callback function to handle the idle callback(received when call is ended)
111 static void HandleIdleCallBack(void* pData, TelephonyManager* pTelManager);
112 //callback function to handle the active callback(received when call is connected)
113 static void HandleActiveCallBack(void* pData, TelephonyManager* pTelManager);
114 //callback function to handle the incoming call callback
115 static void HandleIncomingCallBack(void* pData, TelephonyManager* pTelManager);
116 //callback function to handle the dial call callback
117 static void HandleDialingCallBack(void* pData, TelephonyManager* pTelManager);
118 //Check if MOCall is emergency number and returns true. Otherwise, false.
119 bool CheckIfMOCallIsEmergency(const Tizen::Base::String& contactNumber, bool isSimInitialized);
120 //Check is modem and sim are initialised successfully and MO call can be made.
121 result CheckIfMOCallIsPossible();
122 //Gets the contact for the given phonenumber.returns null if not present.
123 Tizen::Social::Contact* GetContactN(const Tizen::Base::String& phoneNumber);
124 //This function make a synchronus API call to TAPI to fetch active/waiting incoming calls.
125 CallInfo* FetchIncomingCallHandleN(const Tizen::Base::String& callHandle, const Tizen::Base::String& contactNumber);
126 //This callback function is called by TAPI each time for every single call.
127 static void HandleIncomingCallStatusCallBack(TelCallStatus_t* pCallStatus, void* pUserData);
128 //function used to process incoming call and decide whether to reject call based on call settings.
129 //Rejects the call and returns true, Else returns false.
130 bool CheckIncomingCallToBeRejected(CallInfo* pIncomingCallInfo);
132 void EndAllCalls(void);
135 //create a singleton instance
136 static void CreateInstance(ITelephonyEventListener* pEventListener);
137 //used to destroy 'TelephonyManager' instance at application exit.
138 static void DestroyInstance(void);
140 virtual ~TelephonyManager(void);
141 TelephonyManager(ITelephonyEventListener* pEventListener);
142 TelephonyManager(TelephonyManager& manager);
143 TelephonyManager& operator =(TelephonyManager& manager);
144 //perform 2nd phase initialisation
145 result Initialize(void);
146 //initialise the TAPI library
147 result InitializeTelephonyLibrary(void);
148 //register for the TAPI events
149 int RegisterEvents(void);
150 //unregister from the TAPI events
151 void UnregisterEvents(void);
152 //internal function to hold an active call
153 result HoldActiveCall(CallInfo* pActiveCallInfo, bool holdCall);
154 //internal function to make a call
155 result DialOutgoingCall(Tizen::Base::String& contactNumber, bool isEmergency);
156 //internal function to handle waiting call options when single call is present
157 result AcceptSecondCall(CallAnswerOptions answerOptions,int callHandle);
158 //internal function to handle waiting call options when multiple calls are present
159 result AcceptMultipleCall(CallAnswerOptions answerOptions,int callHandle);
161 * This function is internally used to fetch contact person details -
162 * display name & photo id from AddressBook for the given phone number.
164 * @param[in] phoneNumber - The substring of the phoneNumber to search
165 * @return E_SUCCESS, if found else E_FAILURE.
167 result FetchContactInfoForNumber(const Tizen::Base::String& phoneNumberStr);
168 //check if given contact number is valid and returns 'E_SUCCESS', else 'E_FAILURE'.
169 result CheckValidTelePhoneNumber(const Tizen::Base::String& contactNumber);
172 static TelephonyManager* __pManager;
175 CallInfo* __pDialedCall;
177 CallInfo* __pIncomingCall;
178 //Active Calls - only 2 active calls at any time
179 //can hold both Single or Conf. Calls
180 //mapping of "Call handle" to "CallInfo"
181 Tizen::Base::Collection::HashMapT<long, CallInfo>* __pActiveCallList;
183 //Listener for telephony events
184 ITelephonyEventListener* __pEventListener;
186 SettingsManager* __pSettingsManager;
188 //handle to Telephony API
189 TapiHandle* __pTapiHandle;
190 bool __isIncomingCallPresent;
191 //used to connect to Address Book APIs.
192 Tizen::Social::Addressbook* __pAddressBook;
193 //used to store previously fetched contact.
194 Tizen::Social::Contact* __pCachedContact;
199 SoundManager* __pSoundManager;
200 CallLogManager* __pCalllogMgr;
203 #endif // _PHN_TELEPHONY_MANAGER_H_