Tizen 2.0 Release
[platform/framework/native/telephony.git] / src / FTel_CallManagerImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file  FTel_CallManagerImpl.h
19  * @brief This is the header file for the _CallManagerImpl class.
20  *
21  * This header file contains the declarations of the _CallManagerImpl Class.
22  */
23 #ifndef _FTEL_INTERNAL_CALL_MANAGER_IMPL_H_
24 #define _FTEL_INTERNAL_CALL_MANAGER_IMPL_H_
25
26
27 #include <unique_ptr.h>
28 #include <tapi_type.h>
29 #include <TelCall.h>
30 #include <FBaseObject.h>
31 #include <FTelCallInfo.h>
32 #include <FTelTypes.h>
33
34
35 namespace Tizen { namespace Base
36 {
37 class String;
38 }} // Tizen::Base
39
40 namespace Tizen { namespace Telephony
41 {
42 class ITelephonyCallForwardListener;
43 class ITelephonyCallEventListener;
44 class CallManager;
45 class _CallManagerEvent;
46 class _CallForwardEvent;
47 class _TelephonyIpcProxy;
48
49
50 /**
51  * @class   _CallManagerImpl
52  * @brief   This class provides methods to obtain information about the current call.
53  * @since 2.1
54  *
55  * This class provides methods to obtain information about the current call type and its status.
56  *
57  * The following code snippet illustrates how to obtain information about a call.
58  */
59 class _CallManagerImpl
60         : public Tizen::Base::Object
61 {
62         /**
63      *  @enum _CallForwardingState
64      *  Defines the state of the call forwarding.
65      */
66         enum _CallForwardingState
67         {
68             _CALL_FORWARD_IDLE,
69             _CALL_FORWARD_REQUESTING,
70             _CALL_FORWARD_ON_SERVICE,
71             _CALL_FORWARD_STOPPING
72         };
73
74         /**
75      *  @enum _CallNotificationId
76      *  Defines the call notification id
77      */
78         enum _CallNotificationId
79         {
80             _CALL_NOTI_VOICE_CALL_IDLE,
81             _CALL_NOTI_VOICE_CALL_COMMUNICATING,
82             _CALL_NOTI_VOICE_CALL_RINGING,
83             _CALL_NOTI_VOICE_CALL_DIALING,
84             _CALL_NOTI_VOICE_CALL_HOLDING,
85             _CALL_NOTI_VIDEO_CALL_IDLE,
86             _CALL_NOTI_VIDEO_CALL_COMMUNICATING,
87             _CALL_NOTI_VIDEO_CALL_RINGING,
88             _CALL_NOTI_VIDEO_CALL_DIALING,
89             _CALL_NOTI_PEER_CALL_HELD,
90             _CALL_NOTI_PEER_CALL_RETRIEVED,
91             _CALL_NOTI_MAX
92
93         };
94
95 public:
96         /**
97      * This is the default constructor for this class.
98      *
99      * @since 2.1
100      */
101         _CallManagerImpl(void);
102         /**
103      * This is the destructor for this class.
104      *
105      * @since 2.1
106      */
107         virtual ~_CallManagerImpl(void);
108
109         /**
110      * @see CallManager::Construct()
111      */
112         result Construct(ITelephonyCallEventListener* pListener = null);
113
114         /**
115      * @see CallManager::SetCallForwardListener()
116      */
117         result SetCallForwardListener(ITelephonyCallForwardListener* pListener);
118
119         /**
120      * @see CallManager::RequestCallForward(), OnCallForwardNumberReceivedCallback()
121      *
122      */
123         result RequestCallForward(const Tizen::Base::String& phoneNumber);
124
125         /**
126      * @see CallManager::StopCallForward(), OnCallForwardStoppedCallback()
127      */
128         result StopCallForward(void);
129
130         /**
131      * @see CallManager::GetCallForwardNumber(), OnCallForwardNumberReceivedCallback()
132      */
133         result GetCallForwardNumber(void);
134
135         /**
136      * @see CallManager::GetCurrentCallType()
137      */
138         CallType GetCurrentCallType(void) const;
139
140         /**
141      * @see CallManager::GetCurrentCallStatus()
142      */
143         CallStatus GetCurrentCallStatus(void) const;
144
145         void OnTelephonyCallForwardNumberReceived(Tizen::Base::String phoneNumber, result r);
146         void OnTelephonyCallForwardResponseReceived(Tizen::Base::String phoneNumber, result r);
147         void OnTelephonyCallForwardStopped(Tizen::Base::String phoneNumber, result r);
148
149         /**
150      * Called when the status of a call is changed.
151      *
152      * @param[in] pHandle   The call handle.
153      * @param[in] pNotiId   The notification id.
154      * @param[in] pData     The data of call status
155      * @param[in] pUserData The user data passed from the callback registration function
156      */
157         static void OnCallStatusChangedCallback(TapiHandle *pHandle, const char* pNotiId, void* pData, void* pUserData);
158
159         /**
160      * Called when you get the information of call status
161      *
162      * @param[in] status    The call status
163      * @param[in] pUserData The user data passed from the callback registration function
164      */
165         static void OnCallStatusCallback(TelCallStatus_t* pStatus, void* pUserData);
166
167         /**
168      * Called when you get the information of call type
169      *
170      * @param[in] status    The call status
171      * @param[in] pUserData The user data passed from the callback registration function
172      */
173         static void OnCallTypeCallback(TelCallStatus_t* pStatus, void* pUserData);
174
175         /**
176      * Gets the Impl instance.
177      *
178      * @since 2.1
179      * @return The pointer to _CallManagerImpl
180      * @param[in] callManager   An instance of CallManager
181      */
182         static _CallManagerImpl* GetInstance(CallManager& callManager);
183
184         /**
185      * Gets the Impl instance.
186      *
187      * @since 2.1
188      * @return The pointer to _CallManagerImpl
189      * @param[in] callManager   An instance of CallManager
190      */
191         static const _CallManagerImpl* GetInstance(const CallManager& callManager);
192
193 private:
194         /**
195      * Initialize the call status.
196      */
197         result InitializeInternalCallStatus(void);
198
199         /**
200      * Checks the valid state of phone number.
201      */
202         bool IsPhoneNumberValid(const Tizen::Base::String& phoneNumber) const;
203
204         /**
205      * Gets the phone number.
206      */
207         Tizen::Base::String GetPhoneNumber(TapiHandle* pCallHandle, int callId) const;
208
209         /**
210      * Gets the string of call state.
211      */
212         const char* GetStringOfCallState(void) const;
213
214         /**
215      * Gets the string of call forwarding state.
216      */
217         const char* GetStringOfCallFwdState(void) const;
218
219         /**
220      * Gets the string of call event type.
221      */
222         const char* GetStringOfCallEventType(int type) const;
223
224         /**
225      * This is the copy constructor for the %_CallManagerImpl class.
226      *
227      * @param[in] value An instance of %_CallManagerImpl
228      */
229         _CallManagerImpl(const _CallManagerImpl& value);
230
231         /**
232      * This is the assignment operator.
233      * Do @b not use directly.
234      *
235      * @param[in] rhs An instance of %_CallManagerImpl
236      */
237         _CallManagerImpl& operator =(const _CallManagerImpl& rhs);
238
239 private:
240         ITelephonyCallEventListener* __pCallEventListener;
241         ITelephonyCallForwardListener* __pCallForwardListener;
242
243         TapiHandle* __pHandle;
244
245         int __callFwdSubscriptionId;
246         int __callFwdStatusSubscriptionId;
247
248         int __callFwdReqId;
249         int __callFwdReqNumId;
250
251         bool __isReqCallFwdNumInProgress;
252
253         CallStatus __curCallState;
254         _CallForwardingState __curCallFwdState;
255
256     _TelephonyIpcProxy* __pTelephonyServiceProxy;
257
258     std::unique_ptr<_CallManagerEvent> __pCallManagerEvent;
259     std::unique_ptr<_CallForwardEvent> __pCallForwardEvent;
260
261     const char* __pCallEventType[_CALL_NOTI_MAX];
262
263 }; // _CallManagerImpl
264
265 }} // Tizen::Telephony
266 #endif // _FTEL_INTERNAL_CALL_MANAGER_IMPL_H_