Tizen 2.0 Release
[apps/osp/Phone.git] / inc / PhnCallPresentationModel.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 "PhnTypes.h"
28 #include "PhnITelephonyEventListener.h"
29 #include "PhnCalllogManager.h"
30
31 class CallInfo;
32 class TelephonyManager;
33 class SettingsPresentationModel;
34
35 /**
36  * @class CallPresentationModel
37  * @brief CallPresentationModel is Singleton class and acts as interface between
38  * events from other managers and all the views.
39  *
40  */
41 class CallPresentationModel: public ITelephonyEventListener
42                 , public Tizen::App::IAppControlResponseListener
43 {
44 public:
45         //create a singleton instance
46         static CallPresentationModel* GetInstance(void);
47
48 private:
49         CallPresentationModel(void);
50         CallPresentationModel(CallPresentationModel& presentor);
51         virtual ~CallPresentationModel(void);
52         CallPresentationModel& operator =(const CallPresentationModel& presentor);
53
54
55         result Construct(void);
56         static void CreateInstance(void);
57         static void DestroyInstance(void);
58
59 public:
60         //set the telephony event listener
61         void SetTelEventListener(ITelephonyEventListener* pTelEventListener);
62
63         //Dial an outgoing call
64         void DialCall(Tizen::Base::String& contactNumber, bool isEmergency);
65         //End the call
66         void EndCall(Tizen::Base::Long callHandle);
67         void EndCall(Tizen::Base::String& contactNumber);
68         //End the conference call
69         bool EndConferenceCall(void);
70         //Ends all active calls
71         void EndAllCall(void);
72         /**
73          * Hold the call.
74          * @returns true if successful.
75          */
76         bool HoldCall(Tizen::Base::Long callHandle);
77         /**
78          * Unhold the call.
79          * @returns true if successful.
80          */
81         bool UnHoldCall(Tizen::Base::Long callHandle);
82         //Hold conference call
83         bool HoldConferenceCall(void);
84         //UnHold conference call
85         bool ActivateConferenceCall(void);
86         //Join active and held call to conference call.
87         void JoinCall(void);
88         //Swap between active and held call
89         void SwapCalls(void);
90         //Mute or Unmute Call
91         bool SetMuteStatus(bool setMute);
92         //Get the call Muted status
93         bool IsCallMuted(void);
94         //Set speaker to On or Off mode.
95         bool SetSpeakerStatus(bool setSpeaker);
96         //Get the speaker status
97         bool IsSpeakerOn(void);
98         //Send DTMF strings
99         void SendDTMFSignal(Tizen::Base::String& textToBeSent);
100         //Function to get the conference call info
101         CallInfo* GetConferenceCallInfoN(void);
102         //Split this call from the conference call
103         void SplitFromConference(SplitConfCallerCmdIds splitCallerCmdId, Tizen::Base::Collection::IListT<CallInfo>* pConfCallList);
104         //End this single call from the conference call
105         void EndCallFromConference(EndConfCallerCmdIds endCallerCmdId, Tizen::Base::Collection::IListT<CallInfo>* pConfCallList);
106         //returns true, if split operation is allowed. Else, returns false.
107         bool IsSplitAllowed(void);
108         //Accept the incoming call as per the options
109         void AcceptIncomingCall(CallAnswerOptions answerOptions,int callHandle);
110         //Reject an incoming call and send message, if required.
111         bool RejectCall(int callHandle, bool sendMsg, const Tizen::Base::String& contactNumber);
112         //Get the current call count
113         int GetCurrentCallCount(void);
114         //Get the current call list
115         Tizen::Base::Collection::IListT<CallInfo>* GetCallListN(void);
116         //Check if modem and sim initialization is complete.
117         bool CheckSimInitializationIsCompleted();
118         //This function returns true, if contact number is emergency no.
119         bool IsEmergencyNumber(const Tizen::Base::String& phoneNumber, bool isSimInitialized);
120         //Start the alert in case of incoming call
121         void StartAlert(CallInfo& incomingCallInfo);
122         //Stop the alert in case of incoming call
123         void StopAlert(void);
124         //Gets the contact for the given phonenumber.returns null if not present.
125         Tizen::Social::Contact* GetContactN(const Tizen::Base::String& phoneNumber);
126         //Fetch the incoming call details.
127         CallInfo* FetchIncomingCallDetailsN(const Tizen::Base::String& callHandle, const Tizen::Base::String& contactNumber);
128         //Function is used to auto reject the call based on call settings and return true, if rejected.
129         bool CheckIncomingCallToBeRejected(CallInfo* pIncomingCallInfo);
130
131         //Event Listener methods from ITelephonyEventListener
132         virtual void HandleCallConnected(Tizen::Base::Collection::IListT<CallInfo>& pCallList);
133         virtual void HandleCallDisconnected(bool isLastCall, Tizen::Base::Collection::IListT<CallInfo>& pCallList);
134         virtual void HandleConferenceCall(CallInfo& pCallInfo);
135         virtual void HandleIncomingCall(CallInfo& pCallInfo);
136         virtual void HandleCallSwapOccured(Tizen::Base::Collection::IListT<CallInfo>& pCallList);
137         virtual void HandleConferenceChange(void);
138         virtual void HandleTelephonyError(int errorCode);
139         //From IAppControlResponseListener
140         virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData);
141
142 private:
143         static CallPresentationModel* __pInstance;
144         //to forward telephony events
145         ITelephonyEventListener* __pTelEventListener;
146         TelephonyManager* __pTelephonyMgr;
147         SettingsPresentationModel* __pSettingsPresentor;
148         // This is only to save PhoneApp from closing when only 1 incoming call is present and
149         // incoming call is rejected with "Reject With message" by opening Msg AppControl.
150         bool __isMessageAppControlRunning;
151 };
152
153 #endif // _PHN_CALL_PRESENTATION_MODEL_H_