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