TizenRefApp-8330 [Call UI] Implement CallManager 86/123286/3
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 5 Apr 2017 05:58:46 +0000 (08:58 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Thu, 6 Apr 2017 11:50:53 +0000 (14:50 +0300)
Change-Id: I59c62d85ebfb58b5c25d1ab8cb710119abdedfff

32 files changed:
inc/main/Instance.h
inc/model/IActiveCall.h
inc/model/ICallInfo.h
inc/model/ICallManager.h
inc/model/IConferenceCallInfo.h
inc/model/IIncomingCall.h
src/main/Instance.cpp
src/model/ActiveCall.cpp
src/model/ActiveCall.h
src/model/BaseCall.cpp [new file with mode: 0644]
src/model/BaseCall.h [new file with mode: 0644]
src/model/Call.cpp
src/model/CallClient.cpp
src/model/CallDialer.cpp
src/model/CallInfo.cpp
src/model/CallInfo.h
src/model/CallManager.cpp
src/model/CallManager.h
src/model/ConferenceCallInfo.cpp
src/model/ConferenceCallInfo.h
src/model/ContactInfo.cpp
src/model/EndCall.cpp
src/model/EndCall.h
src/model/HeldCall.cpp
src/model/HeldCall.h
src/model/IncomingCall.cpp
src/model/IncomingCall.h
src/model/SoundManager.cpp
src/model/common.h
src/model/helpers.h
src/model/helpers.hpp
tizen-manifest.xml

index 5fd2eb9101cad050c7e614392b91fb9f25d2a38f..6bfbfc362e8d1b17c984d5a6103f93467f5c970a 100644 (file)
@@ -24,6 +24,9 @@
 
 #include "ucl/appfw/SysEventProvider.h"
 
+
+#include "model/Call.h"
+
 namespace callui {
 
        class Instance :
@@ -51,6 +54,8 @@ namespace callui {
                ucl::SysEventProvider &m_sysEventProvider;
                ucl::IInstanceContext *m_context;
                ucl::WindowSRef m_win;
+
+               CallSRef m_call;
        };
 }
 
index 5d51eda6788a0e6e1ca43be1c879e103d7270836..c78fc6011516914716b859b3da5a8109f08a8f82 100644 (file)
@@ -24,7 +24,6 @@ namespace callui {
        class IActiveCall : public ucl::Polymorphic {
        public:
                virtual ICallInfoSCRef getInfo() const = 0;
-               virtual bool isDialingMode() const = 0;
                virtual ucl::Result hold() = 0;
                virtual ucl::Result end() = 0;
                virtual ucl::Result split(const IConferenceCallInfoSRef &confCallInfo) = 0;
index 568bf9dedb4c7672115a9ea5fbee10f88496a193..c94db98b73178d6b62a19e27ed843859e34a058e 100644 (file)
@@ -23,6 +23,7 @@ namespace callui {
 
        class ICallInfo : public ucl::Polymorphic {
        public:
+               virtual unsigned int getCallId() const = 0;
                virtual const std::string &getPhoneNumber() const = 0;
                virtual IContactInfoSCRef getContactInfo() const = 0;
                virtual long getStartTime() const = 0;
index 7ffe4f99e8e57d9b0a37d5e49839e09c97d2e577..8442cfd9a0ad1f3ba34e7cb325684922c2cb8935 100644 (file)
@@ -28,9 +28,8 @@ namespace callui {
                virtual IActiveCallWRef getActiveCall() = 0;
                virtual IHeldCallWRef getHeldCall() = 0;
                virtual IEndCallWRef getEndCall() = 0;
-               virtual CallMask getAvailableCallMask() const = 0;
-               virtual void addCallStateHandler(const CallStateHandler handler) = 0;
-               virtual void removeCallStateHandler(const CallStateHandler handler) = 0;
+               virtual void addCallStateHandler(CallStateHandler handler) = 0;
+               virtual void removeCallStateHandler(CallStateHandler handler) = 0;
        };
 }
 
index 0801b46ed3b66eba590099a67866ca7700bcb732..96873ebd0e6dcb209a9da74576765b98cd3b5d84 100644 (file)
@@ -23,6 +23,7 @@ namespace callui {
 
        class IConferenceCallInfo : public ucl::Polymorphic {
        public:
+               virtual unsigned int getCallId() const = 0;
                virtual const std::string &getPhoneNumber() const = 0;
                virtual IContactInfoSRef getContactInfo() const = 0;
        };
index a1f70da6477157f4ba4f38984ced07a37b3d7361..caa0ff0a4d8739a82b340e6a3525d195cd0b5014 100644 (file)
@@ -26,7 +26,6 @@ namespace callui {
                virtual ICallInfoSCRef getInfo() const = 0;
                virtual ucl::Result answer(CallAnswerType type) = 0;
                virtual ucl::Result reject() = 0;
-               virtual ucl::Result rejectWithMessage(const std::string &message) = 0;
                virtual ucl::Result stopAlert() = 0;
        };
 }
index 79b9f521723978389d1be56bc5ca86ac3640b988..cdb0278e80c2316d19e5c86d937f5c517741e1b7 100644 (file)
@@ -43,6 +43,8 @@ namespace callui {
                eext_object_event_callback_add(*m_win, EEXT_CALLBACK_BACK,
                                CALLBACK_A(Instance::onBack), this);
 
+               m_call = Call::newInstance();
+
                return RES_OK;
        }
 
index 93a128a60fe13f320904c6552f76a6f4da723586..6c09ebcd9fb1e67882db5fd06188e91e8b1f8eca 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "CallClient.h"
 #include "CallManager.h"
+#include "CallClient.h"
 #include "CallInfo.h"
 
 #include "common.h"
@@ -26,10 +27,12 @@ namespace callui {
 
        using namespace ucl;
 
-       ActiveCall::ActiveCall(CallManager &cm):
+       ActiveCall::ActiveCall(CallManager &cm, cm_call_data_h callData):
+                       BaseCall(callData),
                        m_cm(cm)
        {
        }
+
        ActiveCall::~ActiveCall()
        {
        }
@@ -40,14 +43,14 @@ namespace callui {
                        LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
                }
 
-               auto result = makeShared<ActiveCall>(cm);
-               FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
+               auto result = makeShared<ActiveCall>(cm, callData);
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
                return result;
        }
 
-       Result ActiveCall::prepare(cm_call_data_h callData)
+       Result ActiveCall::prepare()
        {
-               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), callData);
+               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
                if (!m_callInfo) {
                        LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
                }
@@ -59,24 +62,19 @@ namespace callui {
                return m_callInfo;
        }
 
-       bool ActiveCall::isDialingMode() const
-       {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
-       }
-
        Result ActiveCall::hold()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return convertCallManagerResult(cm_hold_call(*m_cm.getCallClient()));
        }
 
        Result ActiveCall::end()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_cm.endCall(0, CallReleaseType::ALL_ACTIVE);
        }
 
        Result ActiveCall::split(const IConferenceCallInfoSRef &confCallInfo)
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_cm.splitCalls(m_callInfo, confCallInfo);
        }
 
 }
index 106fa6d811d2290e3f4a41f302cdd8b07349c363..8d8e0cca78a7e4e9390fa426350dd9a35d3349d4 100644 (file)
 
 #include <call-manager-ext.h>
 
+#include "BaseCall.h"
 #include "model/IActiveCall.h"
 
 #include "implTypes.h"
 
 namespace callui {
 
-       class ActiveCall final : public IActiveCall {
+       class ActiveCall final :
+               public BaseCall,
+               public IActiveCall {
        public:
                static ActiveCallSRef newInstance(CallManager &cm, cm_call_data_h callData);
                virtual ~ActiveCall();
@@ -33,16 +36,15 @@ namespace callui {
                // IActiveCall
 
                virtual ICallInfoSCRef getInfo() const override final;
-               virtual bool isDialingMode() const override final;
                virtual ucl::Result hold() override final;
                virtual ucl::Result end() override final;
                virtual ucl::Result split(const IConferenceCallInfoSRef &confCallInfo) override final;
 
        private:
                friend class ucl::RefCountObj<ActiveCall>;
-               ActiveCall(CallManager &cm);
+               ActiveCall(CallManager &cm, cm_call_data_h callData);
 
-               ucl::Result prepare(cm_call_data_h callData);
+               ucl::Result prepare();
 
        private:
                CallManager &m_cm;
diff --git a/src/model/BaseCall.cpp b/src/model/BaseCall.cpp
new file mode 100644 (file)
index 0000000..ece1fbb
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "BaseCall.h"
+
+namespace callui {
+
+       BaseCall::BaseCall(cm_call_data_h callData):
+                       m_callData(callData)
+       {
+       }
+
+       BaseCall::~BaseCall()
+       {
+       }
+
+       cm_call_data_h BaseCall::getCallData()
+       {
+               return m_callData;
+       }
+
+}
diff --git a/src/model/BaseCall.h b/src/model/BaseCall.h
new file mode 100644 (file)
index 0000000..85c612b
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALLUI_MODEL_BASE_CALL_H__
+#define __CALLUI_MODEL_BASE_CALL_H__
+
+#include <call-manager-ext.h>
+
+namespace callui {
+
+       class BaseCall {
+       public:
+               BaseCall(cm_call_data_h callData);
+               virtual ~BaseCall();
+
+               cm_call_data_h getCallData();
+       protected:
+               cm_call_data_h m_callData;
+       };
+
+}
+
+#endif // __CALLUI_MODEL_BASE_CALL_H__
index 497e326e3434b236e5b2fff6600e8cea7c4614b5..7cc8828648274d905d417021dfe91c86051e0fad 100644 (file)
@@ -63,12 +63,12 @@ namespace callui {
 
        ICallManagerSRef Call::getCallManager()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_callManager;
        }
 
        ISoundManagerSRef Call::getSoundManager()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_soundManager;
        }
 
 }
index 73e8212a3fcfc31675eb6f6c1831cbb62c77a396..a86cacf0eeb308ad6221bdd0270af24440a9259f 100644 (file)
@@ -17,7 +17,6 @@
 #include "CallClient.h"
 
 #include "common.h"
-#include "helpers.h"
 
 namespace callui {
 
index b93765c0113950bc5ec539207e54bd89a05fadf7..eb8bc698d9f000efee38b45d3ac3f621b1e2e66e 100644 (file)
@@ -20,7 +20,6 @@
 #include "CallClient.h"
 
 #include "common.h"
-#include "helpers.h"
 
 namespace callui {
 
index d9b31929848bf201b6cc34c59f99f06bd760db87..31fddd6a3fbb83d8be67b58fc784d4508160c32d 100644 (file)
@@ -25,7 +25,6 @@
 #include "ConferenceCallInfo.h"
 
 #include "common.h"
-#include "helpers.h"
 
 namespace callui {
 
@@ -138,7 +137,7 @@ namespace callui {
                return res;
        }
 
-       unsigned int CallInfo::getCallId()
+       unsigned int CallInfo::getCallId() const
        {
                return m_callId;
        }
index 5b1cd8d4ea73762b7a26176102a1eeb2be87c4c5..b55b1225fc8232013ffdbc1fc331bfcf83b47f4f 100644 (file)
@@ -30,10 +30,9 @@ namespace callui {
                static CallInfoSRef newInstance(CallClient &client, cm_call_data_h callData);
                virtual ~CallInfo();
 
-               unsigned int getCallId();
-
                // ICallInfo
 
+               virtual unsigned int getCallId() const override final;
                virtual const std::string &getPhoneNumber() const override final;
                virtual IContactInfoSCRef getContactInfo() const override final;
                virtual long getStartTime() const override final;
index c01d3b00bd89874def9d85f9dce9fe408c701d10..caeab72453606f5f1f1e37ac1989da847d876b73 100644 (file)
 
 #include "CallManager.h"
 
-#include <call-manager-ext.h>
-#include <call-manager-extension.h>
-
 #include "CallClient.h"
 #include "CallDialer.h"
+
 #include "IncomingCall.h"
 #include "ActiveCall.h"
 #include "HeldCall.h"
 #include "EndCall.h"
 
-#include "helpers.h"
+#include "CallInfo.h"
+#include "ConferenceCallInfo.h"
+
 #include "common.h"
 
 namespace callui {
@@ -34,14 +34,12 @@ namespace callui {
        using namespace ucl;
 
        CallManager::CallManager(const CallClientSRef &client):
-                       m_client(client),
-                       m_availableCalls(0)
+                       m_client(client)
        {
        }
 
        CallManager::~CallManager()
        {
-               ILOG();
        }
 
        CallManagerSRef CallManager::newInstance(const CallClientSRef &client)
@@ -58,60 +56,86 @@ namespace callui {
                        LOG_RETURN(RES_FAIL, "CallDialer::getInstance() failed!");
                }
 
-               Result res = updateCalls();
-               FAIL_RETURN_VALUE(res, res, "updateCalls() failed");
+               FAIL_RETURN(initCalls(), "initCalls() failed!");
 
-               return RES_OK;
-       }
+               FAIL_RETURN(convertCallManagerResult(
+                               cm_set_call_event_cb(*m_client, CALLBACK_B(CallManager::callEventCb), this)),
+                               "cm_set_call_event_cb() failed!");
 
-       void CallManager::resetCalls()
-       {
-               m_incomingCall.reset();
-               m_activeCall.reset();
-               m_heldCall.reset();
-               m_endCall.reset();
-
-               m_availableCalls = 0;
+               return RES_OK;
        }
 
-       Result CallManager::updateCalls()
+       Result CallManager::initCalls()
        {
-               resetCalls();
-
                cm_call_data_h incom = nullptr;
                cm_call_data_h active = nullptr;
                cm_call_data_h held = nullptr;
-               Result res = convertCallManagerResult(cm_get_all_calldata(*m_client, &incom, &active, &held));
-               FAIL_RETURN_VALUE(res, res, "cm_get_all_calldata() failed");
 
+               FAIL_RETURN(convertCallManagerResult(
+                               cm_get_all_calldata(*m_client, &incom, &active, &held)),
+                               "cm_get_all_calldata() failed!");
+
+               FAIL_RETURN(updateIncomingCall(incom), "updateIncomingCall() failed!");
+               FAIL_RETURN(updateActiveCall(active), "updateActiveCall() failed!");
+               FAIL_RETURN(updateHeldCall(held), "updateHeldCall() failed!");
+
+               return RES_OK;
+       }
+
+       Result CallManager::updateIncomingCall(cm_call_data_h incom, SimSlot slot)
+       {
                if (incom) {
-                       m_incomingCall = IncomingCall::newInstance(*this, incom);
+                       m_incomingCall = IncomingCall::newInstance(*this, incom, slot);
                        if (!m_incomingCall) {
                                LOG_RETURN(RES_FAIL, "IncomingCall::newInstance() failed!");
                        }
-                       m_availableCalls |= CALL_FLAG_INCOMING;
+               } else {
+                       m_incomingCall.reset();
                }
 
+               return RES_OK;
+       }
+
+       Result CallManager::updateActiveCall(cm_call_data_h active)
+       {
                if (active) {
                        m_activeCall = ActiveCall::newInstance(*this, active);
                        if (!m_activeCall) {
                                LOG_RETURN(RES_FAIL, "ActiveCall::newInstance() failed!");
                        }
-                       m_availableCalls |= CALL_FLAG_ACTIVE;
+               } else {
+                       m_activeCall.reset();
                }
 
+               return RES_OK;
+       }
+
+       Result CallManager::updateHeldCall(cm_call_data_h held)
+       {
                if (held) {
                        m_heldCall = HeldCall::newInstance(*this, held);
                        if (!m_heldCall) {
                                LOG_RETURN(RES_FAIL, "HeldCall::newInstance() failed!");
                        }
-                       m_availableCalls |= CALL_FLAG_HELD;
+               } else {
+                       m_heldCall.reset();
                }
 
-               // TODO: need to implement End Call logic according to system call manager events
-
                return RES_OK;
+       }
+
+       Result CallManager::updateEndCall(cm_call_data_h end, SimSlot slot)
+       {
+               if (end) {
+                       m_endCall = EndCall::newInstance(*this, end, slot);
+                       if (!m_endCall) {
+                               LOG_RETURN(RES_FAIL, "EndCall::newInstance() failed!");
+                       }
+               } else {
+                       m_endCall.reset();
+               }
 
+               return RES_OK;
        }
 
        CallClientSRef CallManager::getCallClient()
@@ -144,19 +168,140 @@ namespace callui {
                return m_endCall;
        }
 
-       CallMask CallManager::getAvailableCallMask() const
+       void CallManager::addCallStateHandler(CallStateHandler handler)
        {
-               return m_availableCalls;
+               m_event += handler;
        }
 
-       void CallManager::addCallStateHandler(const CallStateHandler handler)
+       void CallManager::removeCallStateHandler(CallStateHandler handler)
        {
-               m_event += handler;
+               m_event -= handler;
        }
 
-       void CallManager::removeCallStateHandler(const CallStateHandler handler)
+       Result CallManager::endCall(unsigned int callId, CallReleaseType type)
        {
-               m_event -= handler;
+               return convertCallManagerResult(
+                               cm_end_call(*m_client, callId, convertCallAppReleaseType(type)));
+       }
+
+       Result CallManager::splitCalls(CallInfoSRef callInfo, const IConferenceCallInfoSRef &confCallInfo)
+       {
+               if (callInfo->getConferenceMemberCount() <= 1) {
+                       LOG_RETURN(RES_FAIL, "Not conference call");
+               }
+
+               auto confList = callInfo->getConferenceMemberList();
+               auto iter = std::find(confList.begin(), confList.end(), confCallInfo);
+               if (iter == confList.end()) {
+                       LOG_RETURN(RES_FAIL, "Not a member of conference call");
+               }
+
+               return endCall((*iter)->getCallId(), CallReleaseType::BY_CALL_HANDLE);
+       }
+
+       Result CallManager::processEndCallEvent(cm_call_event_data_h callEventData, SimSlot simSlot)
+       {
+               unsigned int callId = 0;
+               FAIL_RETURN(convertCallManagerResult(
+                               cm_call_event_data_get_call_id(callEventData, &callId)),
+                               "cm_call_event_data_get_call_id() failed!");
+
+               Result res = RES_OK;
+               if (m_incomingCall && callId == m_incomingCall->getInfo()->getCallId()) {
+                       res = updateEndCall(m_incomingCall->getCallData(), simSlot);
+                       m_incomingCall.reset();
+               } else if (m_activeCall && callId == m_activeCall->getInfo()->getCallId()) {
+                       res = updateEndCall(m_activeCall->getCallData(), simSlot);
+                       m_activeCall.reset();
+               } else if (m_heldCall && callId == m_heldCall->getInfo()->getCallId()) {
+                       res = updateEndCall(m_heldCall->getCallData(), simSlot);
+                       m_heldCall.reset();
+               } else if (m_activeCall && m_activeCall->getInfo()->getConferenceMemberCount() > 1) {
+                       res = updateEndCall(m_activeCall->getCallData(), simSlot);
+                       m_activeCall.reset();
+               } else if (m_heldCall && m_heldCall->getInfo()->getConferenceMemberCount() > 1) {
+                       res = updateEndCall(m_heldCall->getCallData(), simSlot);
+                       m_heldCall.reset();
+               }
+
+               return res;
+       }
+
+       Result CallManager::processCommonCallEvent(cm_call_event_data_h callEventData, CallEventType type, SimSlot simSlot)
+       {
+               unsigned int callId = 0;
+               cm_call_data_h cmIncom = nullptr;
+               cm_call_data_h cmActive = nullptr;
+               cm_call_data_h cmHeld = nullptr;
+
+               FAIL_RETURN(convertCallManagerResult(
+                               cm_call_event_data_get_call_id(callEventData, &callId)),
+                               "cm_call_event_data_get_call_id() failed!");
+
+               FAIL_RETURN(convertCallManagerResult(
+                               cm_call_event_data_get_incom_call(callEventData, &cmIncom)),
+                               "cm_call_event_data_get_incom_call() failed!");
+
+               FAIL_RETURN(convertCallManagerResult(
+                               cm_call_event_data_get_active_call(callEventData, &cmActive)),
+                               "cm_call_event_data_get_active_call() failed!");
+
+               FAIL_RETURN(convertCallManagerResult(
+                               cm_call_event_data_get_held_call(callEventData, &cmHeld)),
+                               "cm_call_event_data_get_held_call() failed!");
+
+               if (type == CallEventType::INCOMING) {
+                       FAIL_RETURN(updateIncomingCall(cmIncom, simSlot), "updateIncomingCall() failed!");
+               } else if (!cmIncom) {
+                       m_incomingCall.reset();
+               }
+               FAIL_RETURN(updateActiveCall(cmActive), "updateActiveCall() failed!");
+               FAIL_RETURN(updateHeldCall(cmHeld), "updateHeldCall() failed!");
+
+               return RES_OK;
+       }
+
+       void CallManager::callEventCb(cm_call_event_e callEvent, cm_call_event_data_h callEventData)
+       {
+               if (!callEventData) {
+                       ELOG("callEventData is NULL");
+                       return;
+               }
+
+               CallEventType type;
+               FAIL_RETURN_VOID(convertCallManagerEventType(callEvent, &type),
+                               "convertCallManagerEventType() failed!");
+
+               DLOG("Call event changed on [%d]", type);
+
+               cm_multi_sim_slot_type_e cmSimSlot;
+               FAIL_RETURN_VOID(convertCallManagerResult(
+                               cm_call_event_data_get_sim_slot(callEventData, &cmSimSlot)),
+                               "cm_call_event_data_get_sim_slot() failed!");
+               SimSlot simSlot = convertCallManagerSimSlot(cmSimSlot);
+
+               m_endCall.reset();
+
+               switch (type) {
+               case CallEventType::END:
+                       FAIL_RETURN_VOID(processEndCallEvent(callEventData, simSlot),
+                                       "processEndCallEvent() failed!");
+               case CallEventType::ACTIVE:
+               case CallEventType::INCOMING:
+               case CallEventType::DIALING:
+               case CallEventType::HELD:
+               case CallEventType::RETRIEVED:
+               case CallEventType::SWAPPED:
+               case CallEventType::JOIN:
+               case CallEventType::SPLIT:
+                       FAIL_RETURN_VOID(processCommonCallEvent(callEventData, type, simSlot),
+                                       "processCommonCallEvent() failed!");
+                       break;
+               default:
+                       return;
+               }
+
+               m_event.invoke(type);
        }
 
 }
index 6b7b9724fb7e6011e9f764de1264d3b57aa0113a..1470abc930c2509966170edb873359eb231ea594 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __CALLUI_MODEL_CALL_MANAGER_H__
 #define __CALLUI_MODEL_CALL_MANAGER_H__
 
+#include <call-manager-ext.h>
+
 #include "ucl/misc/Event.h"
 
 #include "model/ICallManager.h"
@@ -31,6 +33,8 @@ namespace callui {
                virtual ~CallManager();
 
                CallClientSRef getCallClient();
+               ucl::Result endCall(unsigned int callId, CallReleaseType type);
+               ucl::Result splitCalls(CallInfoSRef callInfo, const IConferenceCallInfoSRef &confCallInfo);
 
                // ICallManager
 
@@ -39,17 +43,23 @@ namespace callui {
                virtual IActiveCallWRef getActiveCall() override final;
                virtual IHeldCallWRef getHeldCall() override final;
                virtual IEndCallWRef getEndCall() override final;
-               virtual CallMask getAvailableCallMask() const override final;
-               virtual void addCallStateHandler(const CallStateHandler handler) override final;
-               virtual void removeCallStateHandler(const CallStateHandler handler) override final;
+               virtual void addCallStateHandler(CallStateHandler handler) override final;
+               virtual void removeCallStateHandler(CallStateHandler handler) override final;
 
        private:
                friend class ucl::RefCountObj<CallManager>;
                CallManager(const CallClientSRef &callClient);
 
                ucl::Result prepare();
-               ucl::Result updateCalls();
-               void resetCalls();
+               ucl::Result initCalls();
+               ucl::Result updateIncomingCall(cm_call_data_h incom, SimSlot slot = SimSlot::DEFAULT);
+               ucl::Result updateActiveCall(cm_call_data_h active);
+               ucl::Result updateHeldCall(cm_call_data_h active);
+               ucl::Result updateEndCall(cm_call_data_h end, SimSlot slot = SimSlot::DEFAULT);
+
+               ucl::Result processEndCallEvent(cm_call_event_data_h callEventData, SimSlot slot);
+               ucl::Result processCommonCallEvent(cm_call_event_data_h callEventData, CallEventType type, SimSlot simSlot);
+               void callEventCb(cm_call_event_e call_event, cm_call_event_data_h call_state_data);
 
        private:
                CallClientSRef m_client;
@@ -58,7 +68,6 @@ namespace callui {
                ActiveCallSRef m_activeCall;
                HeldCallSRef m_heldCall;
                EndCallSRef m_endCall;
-               CallMask m_availableCalls;
                CallStateEvent m_event;
        };
 
index 2cfd3853e97efe42e71c9cfe668715e5ce993665..f4119e376bfb4f1d9b6b0f34449d7ceb52c745fb 100644 (file)
@@ -21,7 +21,6 @@
 #include "ContactInfo.h"
 
 #include "common.h"
-#include "helpers.h"
 
 namespace callui {
 
@@ -72,7 +71,7 @@ namespace callui {
                return RES_OK;
        }
 
-       unsigned int ConferenceCallInfo::getCallId()
+       unsigned int ConferenceCallInfo::getCallId() const
        {
                return m_callId;
        }
index 8e2aaebbb194111ed46f6f0730900e86d8f34e92..8335d75a6fa76ff63934fc41f82e59bbc7dfbd8a 100644 (file)
@@ -30,10 +30,9 @@ namespace callui {
                static ConferenceCallInfoSRef newInstance(cm_conf_call_data_t *confCallData);
                virtual ~ConferenceCallInfo();
 
-               unsigned int getCallId();
-
                // IConferenceCallInfo
 
+               virtual unsigned int getCallId() const override final;
                virtual const std::string &getPhoneNumber() const override final;
                virtual IContactInfoSRef getContactInfo() const override final;
 
index e0ced61507dbd2e3d0648ab90287fb80c22bd358..5dc6a8ac948133f2f23196deef99b79c19b0bc3e 100644 (file)
@@ -20,7 +20,6 @@
 #include "ContactInfo.h"
 
 #include "common.h"
-#include "helpers.h"
 
 namespace callui {
 
index c93ef62bb80b2f68548ecdb1cfd41e56f144fb70..65a70c6d6bae032475e0282bdc9a34e210b8a29f 100644 (file)
@@ -19,6 +19,7 @@
 #include "CallClient.h"
 #include "CallManager.h"
 #include "CallInfo.h"
+#include "model/ICallDialer.h"
 
 #include "common.h"
 
@@ -26,8 +27,10 @@ namespace callui {
 
        using namespace ucl;
 
-       EndCall::EndCall(CallManager &cm):
-                       m_cm(cm)
+       EndCall::EndCall(CallManager &cm, cm_call_data_h callData, SimSlot slot):
+                       BaseCall(callData),
+                       m_cm(cm),
+                       m_slot(slot)
        {
        }
 
@@ -35,20 +38,20 @@ namespace callui {
        {
        }
 
-       EndCallSRef EndCall::newInstance(CallManager &cm, cm_call_data_h callData)
+       EndCallSRef EndCall::newInstance(CallManager &cm, cm_call_data_h callData, SimSlot slot)
        {
                if (!callData) {
                        LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
                }
 
-               auto result = makeShared<EndCall>(cm);
-               FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
+               auto result = makeShared<EndCall>(cm, callData, slot);
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
                return result;
        }
 
-       Result EndCall::prepare(cm_call_data_h callData)
+       Result EndCall::prepare()
        {
-               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), callData);
+               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
                if (!m_callInfo) {
                        LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
                }
@@ -62,7 +65,12 @@ namespace callui {
 
        Result EndCall::callBack()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               ICallDialerWRef dialer = m_cm.getDialer();
+               if (dialer) {
+                       return dialer->dialVoiceCall(m_callInfo->getPhoneNumber(), m_slot);
+               } else {
+                       return RES_FAIL;
+               }
        }
 
        Result EndCall::writeMessage()
index 2ea64ac6797b3b70ac6745f55def73e3fa082759..7a60d8995402c0d0560f5dc54b5a88ed3916b792 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <call-manager-ext.h>
 
+#include "BaseCall.h"
 #include "model/IEndCall.h"
 
 #include "implTypes.h"
@@ -27,9 +28,14 @@ namespace callui {
 
        class CallManager;
 
-       class EndCall final : public IEndCall {
+       class EndCall final :
+               public BaseCall,
+               public IEndCall {
        public:
-               static EndCallSRef newInstance(CallManager &cm, cm_call_data_h callData);
+               static EndCallSRef newInstance(CallManager &cm,
+                               cm_call_data_h callData,
+                               SimSlot slot = SimSlot::DEFAULT);
+
                virtual ~EndCall();
 
                // IEndCall
@@ -40,13 +46,14 @@ namespace callui {
 
        private:
                friend class ucl::RefCountObj<EndCall>;
-               EndCall(CallManager &cm);
+               EndCall(CallManager &cm, cm_call_data_h callData, SimSlot slot);
 
-               ucl::Result prepare(cm_call_data_h callData);
+               ucl::Result prepare();
 
        private:
                CallManager &m_cm;
                CallInfoSRef m_callInfo;
+               SimSlot m_slot;
        };
 
 }
index d5afa10d8c0c23616d750925c7f43bda1371bee0..098f5ba3421b6479e92acada5255c16d6b6b1c6a 100644 (file)
@@ -19,6 +19,7 @@
 #include "CallClient.h"
 #include "CallManager.h"
 #include "CallInfo.h"
+#include "CallClient.h"
 
 #include "common.h"
 
@@ -26,7 +27,8 @@ namespace callui {
 
        using namespace ucl;
 
-       HeldCall::HeldCall(CallManager &cm):
+       HeldCall::HeldCall(CallManager &cm, cm_call_data_h callData):
+                       BaseCall(callData),
                        m_cm(cm)
        {
        }
@@ -41,14 +43,14 @@ namespace callui {
                        LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
                }
 
-               auto result = makeShared<HeldCall>(cm);
-               FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
+               auto result = makeShared<HeldCall>(cm, callData);
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
                return result;
        }
 
-       Result HeldCall::prepare(cm_call_data_h callData)
+       Result HeldCall::prepare()
        {
-               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), callData);
+               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
                if (!m_callInfo) {
                        LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
                }
@@ -62,27 +64,27 @@ namespace callui {
 
        Result HeldCall::unhold()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return convertCallManagerResult(cm_unhold_call(*m_cm.getCallClient()));
        }
 
        Result HeldCall::joinWithActive()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return convertCallManagerResult(cm_join_call(*m_cm.getCallClient()));
        }
 
        Result HeldCall::swapWithActive()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return convertCallManagerResult(cm_swap_call(*m_cm.getCallClient()));
        }
 
        Result HeldCall::end()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_cm.endCall(0, CallReleaseType::ALL_HOLD);
        }
 
        Result HeldCall::split(const IConferenceCallInfoSRef &confCallInfo)
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_cm.splitCalls(m_callInfo, confCallInfo);
        }
 
-} /* namespace callui */
+}
index 44f8607daa6e121f19b792e5367c7bc0b79425cc..c584c552a909e8509da225e824b94df3f7d9739e 100644 (file)
 
 #include <call-manager-ext.h>
 
+#include "BaseCall.h"
 #include "model/IHeldCall.h"
 
 #include "implTypes.h"
 
 namespace callui {
 
-       class HeldCall final : public IHeldCall {
+       class HeldCall final :
+               public BaseCall,
+               public IHeldCall {
        public:
                static HeldCallSRef newInstance(CallManager &cm, cm_call_data_h callData);
                virtual ~HeldCall();
@@ -41,9 +44,9 @@ namespace callui {
 
        private:
                friend class ucl::RefCountObj<HeldCall>;
-               HeldCall(CallManager &cm);
+               HeldCall(CallManager &cm, cm_call_data_h callData);
 
-               ucl::Result prepare(cm_call_data_h callData);
+               ucl::Result prepare();
 
        private:
                CallManager &m_cm;
index 28cf1b08260687fdef084bbb9e73aab145494f58..4f803f24b352e1e68b8519a99f8c62ab53775711 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "CallClient.h"
 #include "CallManager.h"
+#include "CallClient.h"
 #include "CallInfo.h"
 
 #include "common.h"
@@ -26,8 +27,10 @@ namespace callui {
 
        using namespace ucl;
 
-       IncomingCall::IncomingCall(CallManager &cm):
-                       m_cm(cm)
+       IncomingCall::IncomingCall(CallManager &cm, cm_call_data_h callData, SimSlot slot):
+                       BaseCall(callData),
+                       m_cm(cm),
+                       m_simSlot(slot)
        {
        }
 
@@ -35,20 +38,20 @@ namespace callui {
        {
        }
 
-       IncomingCallSRef IncomingCall::newInstance(CallManager &cm, cm_call_data_h callData)
+       IncomingCallSRef IncomingCall::newInstance(CallManager &cm, cm_call_data_h callData, SimSlot slot)
        {
                if (!callData) {
                        LOG_RETURN_VALUE(RES_FAIL, {}, "callData is NULL");
                }
 
-               auto result = makeShared<IncomingCall>(cm);
-               FAIL_RETURN_VALUE(result->prepare(callData), {}, "result->prepare() failed!");
+               auto result = makeShared<IncomingCall>(cm, callData, slot);
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
                return result;
        }
 
-       Result IncomingCall::prepare(cm_call_data_h callData)
+       Result IncomingCall::prepare()
        {
-               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), callData);
+               m_callInfo = CallInfo::newInstance(*m_cm.getCallClient(), m_callData);
                if (!m_callInfo) {
                        LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
                }
@@ -62,21 +65,16 @@ namespace callui {
 
        Result IncomingCall::answer(CallAnswerType type)
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return convertCallManagerResult(cm_answer_call(*m_cm.getCallClient(),convertCallAppAnswerType(type)));
        }
 
        Result IncomingCall::reject()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
-       }
-
-       Result IncomingCall::rejectWithMessage(const std::string &message)
-       {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return convertCallManagerResult(cm_reject_call(*m_cm.getCallClient()));
        }
 
        Result IncomingCall::stopAlert()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return convertCallManagerResult(cm_stop_alert(*m_cm.getCallClient()));
        }
 }
index 536cdc977109e718d89195db9bbb74b24a5ba63f..a7261a5d57eb1c6c2b8f2489dc9607f1e7a29145 100644 (file)
 
 #include <call-manager-ext.h>
 
+#include "BaseCall.h"
 #include "model/IIncomingCall.h"
 
 #include "implTypes.h"
 
 namespace callui {
 
-       class IncomingCall final : public IIncomingCall {
+       class IncomingCall final :
+               public BaseCall,
+               public IIncomingCall {
        public:
-               static IncomingCallSRef newInstance(CallManager &cm, cm_call_data_h callData);
+               static IncomingCallSRef newInstance(CallManager &cm,
+                               cm_call_data_h callData,
+                               SimSlot slot = SimSlot::DEFAULT);
+
                virtual ~IncomingCall();
 
                // IIncomingCall
@@ -35,18 +41,18 @@ namespace callui {
                virtual ICallInfoSCRef getInfo() const override final;
                virtual ucl::Result answer(CallAnswerType type) override final;
                virtual ucl::Result reject() override final;
-               virtual ucl::Result rejectWithMessage(const std::string &message) override final;
                virtual ucl::Result stopAlert() override final;
 
        private:
                friend class ucl::RefCountObj<IncomingCall>;
-               IncomingCall(CallManager &cm);
+               IncomingCall(CallManager &cm, cm_call_data_h callData, SimSlot slot);
 
-               ucl::Result prepare(cm_call_data_h callData);
+               ucl::Result prepare();
 
        private:
                CallManager &m_cm;
                CallInfoSRef m_callInfo;
+               SimSlot m_simSlot;
        };
 
 }
index 3e1199f17a17ab2595de3025669de5e5b03cf1bb..edac34434d6b32f8ff616384950729a61a6904bb 100644 (file)
@@ -19,7 +19,6 @@
 #include "CallClient.h"
 
 #include "common.h"
-#include "helpers.h"
 
 namespace callui {
 
index 47bf580dd7ac054eb14835409122027153f00218..569d6af9712015c564c02f7b20159f52a8a2e9cd 100644 (file)
@@ -19,4 +19,6 @@
 
 #include "../common.h"
 
+#include "helpers.h"
+
 #endif // __CALLUI_MODEL_COMMON_H__
index c1d5ac26cad9e612d97955f65345c7c16effaed1..46448253bb9ae14458a71ae1a7243320221a7709 100644 (file)
@@ -30,6 +30,14 @@ namespace callui {
        DialStatus convertCallManagerDialStatus(cm_dial_status_e status);
 
        cm_multi_sim_slot_type_e convertCallAppSimSlot(SimSlot slot);
+
+       SimSlot convertCallManagerSimSlot(cm_multi_sim_slot_type_e slot);
+
+       cm_call_release_type_e convertCallAppReleaseType(CallReleaseType type);
+
+       ucl::Result convertCallManagerEventType(cm_call_event_e cmEvent, CallEventType *appEvent);
+
+       cm_call_answer_type_e convertCallAppAnswerType(CallAnswerType type);
 }
 
 #include "helpers.hpp"
index d5d411e3d743ec7a7838277052174aac2d392c56..cf8598de3b8fd37c528d1a552d22386f8532f41e 100644 (file)
@@ -70,4 +70,84 @@ namespace callui {
                        return CM_MULTI_SIM_SLOT_DEFAULT;
                }
        }
+
+       inline SimSlot convertCallManagerSimSlot(cm_multi_sim_slot_type_e slot)
+       {
+               switch (slot) {
+               case CM_MULTI_SIM_SLOT_1: return SimSlot::FIRST;
+               case CM_MULTI_SIM_SLOT_2: return SimSlot::SECOND;
+               default:
+                       return SimSlot::DEFAULT;
+               }
+       }
+
+       inline cm_call_release_type_e convertCallAppReleaseType(CallReleaseType type)
+       {
+               switch (type) {
+               case CallReleaseType::BY_CALL_HANDLE: return CM_CALL_RELEASE_TYPE_BY_CALL_HANDLE;
+               case CallReleaseType::ALL:            return CM_CALL_RELEASE_TYPE_ALL_CALLS;
+               case CallReleaseType::ALL_HOLD:       return CM_CALL_RELEASE_TYPE_ALL_HOLD_CALLS;
+               case CallReleaseType::ALL_ACTIVE:     return CM_CALL_RELEASE_TYPE_ALL_ACTIVE_CALLS;
+               default:
+                       return CM_CALL_RELEASE_TYPE_BY_CALL_HANDLE;
+               }
+       }
+
+       inline ucl::Result convertCallManagerEventType(cm_call_event_e cmEvent, CallEventType *appEvent)
+       {
+               switch (cmEvent) {
+               case CM_CALL_EVENT_IDLE:
+                       *appEvent = CallEventType::END;
+                       break;
+               case CM_CALL_EVENT_DIALING:
+                       *appEvent = CallEventType::DIALING;
+                       break;
+               case CM_CALL_EVENT_ACTIVE:
+                       *appEvent = CallEventType::ACTIVE;
+                       break;
+               case CM_CALL_EVENT_HELD:
+                       *appEvent = CallEventType::HELD;
+                       break;
+               case CM_CALL_EVENT_ALERT:
+                       *appEvent = CallEventType::ALERT;
+                       break;
+               case CM_CALL_EVENT_INCOMING:
+                       *appEvent = CallEventType::INCOMING;
+                       break;
+               case CM_CALL_EVENT_WAITING:
+                       *appEvent = CallEventType::WAITING;
+                       break;
+               case CM_CALL_EVENT_JOIN:
+                       *appEvent = CallEventType::JOIN;
+                       break;
+               case CM_CALL_EVENT_SPLIT:
+                       *appEvent = CallEventType::SPLIT;
+                       break;
+               case CM_CALL_EVENT_SWAPPED:
+                       *appEvent = CallEventType::SWAPPED;
+                       break;
+               case CM_CALL_EVENT_RETRIEVED:
+                       *appEvent = CallEventType::RETRIEVED;
+                       break;
+               case CM_CALL_EVENT_SAT_CALL_CONTROL:
+                       *appEvent = CallEventType::SAT_CALL_CONTROL;
+                       break;
+               default:
+                       return ucl::RES_FAIL;
+               }
+               return ucl::RES_OK;
+       }
+
+       inline cm_call_answer_type_e convertCallAppAnswerType(CallAnswerType type)
+       {
+               switch (type) {
+               case CallAnswerType::NORMAL:                    return CALL_ANSWER_TYPE_NORMAL;
+               case CallAnswerType::HOLD_ACTIVE_AND_ACCEPT:    return CALL_ANSWER_TYPE_HOLD_ACTIVE_AND_ACCEPT;
+               case CallAnswerType::RELEASE_ACTIVE_AND_ACCEPT: return CALL_ANSWER_TYPE_RELEASE_ACTIVE_AND_ACCEPT;
+               case CallAnswerType::RELEASE_HOLD_AND_ACCEPT:   return CALL_ANSWER_TYPE_RELEASE_HOLD_AND_ACCEPT;
+               case CallAnswerType::RELEASE_ALL_AND_ACCEPT:    return CALL_ANSWER_TYPE_RELEASE_ALL_AND_ACCEPT;
+               default:
+                       return CALL_ANSWER_TYPE_NORMAL;
+               }
+       }
 }
index 72ec9ffbf078e6a8967ae75ed8615b9a77cc9c77..c3ee103a7f0a68b6132b747e03bb6f81432dd1c8 100644 (file)
@@ -5,4 +5,14 @@
         <label>call-ui</label>
         <icon>call-ui.png</icon>
     </ui-application>
+    <privileges>
+        <privilege>http://tizen.org/privilege/keygrab</privilege>
+        <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        <privilege>http://tizen.org/privilege/window.priority.set</privilege>
+        <privilege>http://tizen.org/privilege/contact.read</privilege>
+        <privilege>http://tizen.org/privilege/message.write</privilege>
+        <privilege>http://tizen.org/privilege/notification</privilege>
+        <privilege>http://tizen.org/privilege/message.read</privilege>
+        <privilege>http://tizen.org/privilege/display</privilege>
+    </privileges>
 </manifest>