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