Add package signature files generation code in spec file
[apps/osp/Call.git] / inc / CallTelephonyManager.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                CallTelephonyManager.h
19  * @brief               This is the header file for the %TelephonyManager class.
20  *
21  * This header file contains the declarations for %TelephonyManager class.
22  */
23 #ifndef _PHN_TELEPHONY_MANAGER_H_
24 #define _PHN_TELEPHONY_MANAGER_H_
25
26 #include <FBase.h>
27 #include <FSocial.h>
28 #include <FTelephony.h>
29 #include "ITapiCall.h"
30 #include "TapiUtility.h"
31 #include "CallITelephonyEventListener.h"
32 #include "CallSoundManager.h"
33 #include "CalllogManager.h"
34
35 class AppCallInfo;
36 class SettingsManager;
37
38 /**
39  * @class TelephonyManager
40  * @brief TelephonyManager is a singleton class used to intialize TAPI library.
41  * And register to telephony events, interact with TAPI library.
42  */
43 class TelephonyManager
44 : public Tizen::Telephony::ITelephonyNetworkEventListener
45 {
46 public:
47         //Get singleton instance
48         static TelephonyManager* GetInstance(ITelephonyEventListener* pEventListener);
49         //Function to initiate (dial) an outgoing call.
50         ErrorCodes SetupMoCall(Tizen::Base::String& contactNumber, bool isEmergency);
51         //Function to end a call
52         result EndActiveCall(Tizen::Base::Long callHandle);
53         result EndDialingCall(Tizen::Base::String& contactNumber);
54         //Function to accept/reject an incoming call
55         result AnswerCall(int callHandle, bool acceptCall);
56         //Auto Reject call
57         result AnswerAutoRejectCall(int callHandle);
58         //Function to accept call with the given options
59         result AcceptCall(CallAnsweringOptions answerOptions,int callHandle);
60         //Function to end a conference call
61         result EndConferenceCall(void);
62         //Function to hold/retrieve a conference call
63         result HoldConferenceCall(bool holdCall);
64         //Function to join active and held call to conference
65         result JoinCall(void);
66         //Function to hold/unhold the call
67         result HoldCall(Tizen::Base::Long callHandle, bool holdCall);
68         //Function to swap the active and held call
69         result SwapCalls(void);
70         //Function to send DTMF strings
71         result SendCallDTMF(Tizen::Base::String& textToBeSent);
72         //Function to end a single call from the conference
73         result EndFromConference(int callHandle);
74         //Function to split a single call from the conference
75         result SplitFromConference(int callHandle);
76         //Function to set the mute status
77         result SetMuteStatus(bool setMute);
78         //Function to get the mute Status
79         bool IsCallMuted(void);
80         //Function to set the speaker status
81         result SetSpeakerStatus(bool setSpeaker);
82         //Function to get the speaker status
83         bool IsSpeakerOn(void);
84         //Function to check if split operation is allowed from the conference
85         bool IsSplitAllowed(void);
86         //Function to get the conference call info
87         AppCallInfo* GetConferenceCallInfoN(void);
88         //Get the current call list
89         Tizen::Base::Collection::IListT<AppCallInfo>* GetCallListN(void);
90         //Get the current call count
91         int GetCurrentCallCount(void);
92         //Start the alert in case of incoming call
93         void StartAlert(AppCallInfo& incomingCallInfo);
94         //Stop the alert in case of incoming call
95         void StopAlert(void);
96         //Main Callback function used while registering to TAPI
97         static void HandleCallback(TapiHandle* pHandle, const char* pNotiId, void* pData, void* pUserData);
98         //Dummy callback function used when nothing is to be done on response
99         static void HandleCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
100         //callback function for dial operation
101         static void HandleDialCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
102         //callback function for the join operation
103         static void HandleJoinCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
104         //callback function for the reject call operation
105         static void HandleRejectCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
106         //callback function for the swap calls operation
107         static void HandleSwapCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
108         //callback function for the End from conference operation
109         static void HandleEndFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
110         //callback function for the split from conference operation
111         static void HandleSplitFromConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
112         //callback function for Ending conference call
113         static void HandleEndConferenceCallbackResponse(TapiHandle* pHandle, int callBackResult, void* pData, void* pUserData);
114         //Check if MOCall is emergency number and returns true. Otherwise, false.
115         bool CheckIfMOCallIsEmergency(const Tizen::Base::String& contactNumber, bool isSimInitialized);
116         //Check is modem and sim are initialised successfully and MO call can be made.
117         result CheckIfMOCallIsPossible();
118         //Gets the contact for the given phonenumber.returns null if not present.
119         Tizen::Social::Contact* GetContactN(const Tizen::Base::String& phoneNumber);
120         //This function make a synchronus API call to TAPI to fetch active/waiting incoming calls.
121         AppCallInfo* FetchIncomingCallHandleN(const Tizen::Base::String& callHandle, const Tizen::Base::String& contactNumber);
122         //This callback function is called by TAPI each time for every single call.
123         static void HandleIncomingCallStatusCallBack(TelCallStatus_t* pCallStatus, void* pUserData);
124         //function used to process incoming call and decide whether to reject call based on call settings.
125         //Rejects the call and returns true, Else returns false.
126         bool CheckIncomingCallToBeRejected(AppCallInfo* pIncomingCallInfo);
127         //End all active
128         void EndAllCalls(void);
129         //From ITelephonyNetworkEventListener
130         virtual void OnTelephonyNetworkStatusChanged(const Tizen::Telephony::NetworkStatus& networkStatus);
131         //Used to check if a call is in incoming or dialing state.
132         bool IsIncomingorDialingCallPresent(void);
133         
134 protected:
135         //function to handle the idle callback(received when call is ended)
136         void HandleIdleCallBack(void* pData);
137         //function used to handle events for normal call disconnected.
138         bool HandleEndNormalActiveCall(AppCallInfo& endCallInfo);
139         //function to handle the active callback(received when call is connected)
140         void HandleActiveCallBack(void* pData);
141         //function to handle call connected successfully
142         void HandleCallConnected(unsigned int connectedCallHandle);
143         //function to handle the dial call callback
144         void HandleDialingCallBack(void* pData);
145         //function to handle ending of single participant in conference call.
146         bool HandleParticipantEndedFromConference(unsigned int participantCallHandle, AppCallInfo& conferenceCall);
147
148 private:
149         //create a singleton instance
150         static void CreateInstance(ITelephonyEventListener* pEventListener);
151         //used to destroy 'TelephonyManager' instance at application exit.
152         static void DestroyInstance(void);
153         //private destructor
154         virtual ~TelephonyManager(void);
155         TelephonyManager(ITelephonyEventListener* pEventListener);
156         TelephonyManager(TelephonyManager& manager);
157         TelephonyManager& operator =(TelephonyManager& manager);
158         //perform 2nd phase initialisation
159         result Initialize(void);
160         //initialise the TAPI library
161         result InitializeTelephonyLibrary(void);
162         //register for the TAPI events
163         int RegisterEvents(void);
164         //unregister from the TAPI events
165         void UnregisterEvents(void);
166         //internal function to hold an active call
167         result HoldActiveCall(AppCallInfo* pActiveCallInfo, bool holdCall);
168         //internal function to make a call
169         result DialOutgoingCall(Tizen::Base::String& contactNumber, bool isEmergency);
170         //internal function to handle waiting call options when single call is present
171         result AcceptSecondCall(CallAnsweringOptions answerOptions, const int incomingCallHandle);
172         //internal function to handle waiting call options when multiple calls are present
173         result AcceptMultipleCall(CallAnsweringOptions answerOptions, const int incomingCallHandle);
174         //internal function to End Call
175         result EndCall(AppCallInfo& endCallInfo);
176         /**
177          * This function is internally used to fetch contact person details -
178          * display name & photo id from AddressBook for the given phone number.
179          *
180          * @param[in] phoneNumber - The substring of the phoneNumber to search
181          * @return E_SUCCESS, if found else E_FAILURE.
182          */
183         result FetchContactInfoForNumber(const Tizen::Base::String& phoneNumberStr);
184         //check if given contact number is valid and returns 'E_SUCCESS', else 'E_FAILURE'.
185         result CheckValidTelePhoneNumber(const Tizen::Base::String& contactNumber);
186         //Used to save ended call Log info to Logs database.
187         void SaveCallInfoToLogsDb(AppCallInfo& endCallInfo);
188
189 private:
190         static TelephonyManager* __pManager;
191
192         //Outgoing call Info
193         AppCallInfo* __pDialedCall;
194         //Incoming call Info
195         AppCallInfo* __pIncomingCall;
196         //Active Calls - only 2 active calls at any time
197         //can hold both Single or Conf. Calls
198         //mapping of "Call handle" to "CallInfo"
199         Tizen::Base::Collection::HashMapT<long, AppCallInfo>* __pActiveCallList;
200
201         //Listener for telephony events
202         ITelephonyEventListener* __pEventListener;
203
204         SettingsManager* __pSettingsManager;
205
206         //handle to Telephony API
207         TapiHandle* __pTapiHandle;
208         //used to connect to Address Book APIs.
209         Tizen::Social::Addressbook* __pAddressBook;
210         //used to store previously fetched contact.
211         Tizen::Social::Contact* __pCachedContact;
212         Tizen::Social::Category __Category;
213         //mute status
214         bool __isMuted;
215         //Speaker Status
216         bool __isSpeakerOn;
217         SoundManager* __pSoundManager;
218         CallLogManager* __pCalllogMgr;
219         Tizen::Telephony::NetworkManager* __pNetworkManager;
220 };
221
222 #endif // _PHN_TELEPHONY_MANAGER_H_