TizenRefApp-8916 [Call UI] Rename main model class Call on CallUI 98/140198/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 24 Jul 2017 06:46:15 +0000 (09:46 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 24 Jul 2017 06:53:39 +0000 (09:53 +0300)
Change-Id: I7b977ecfe3bd7d796da0e116e89dfc87ba3f820d

15 files changed:
inc/model/CallBuilder.h [deleted file]
inc/model/CallUIBuilder.h [new file with mode: 0644]
inc/model/ICall.h [deleted file]
inc/model/ICallUI.h [new file with mode: 0644]
inc/model/types.h
inc/presenters/Instance.h
inc/presenters/MainPage.h
src/model/Call.cpp [deleted file]
src/model/Call.h [deleted file]
src/model/CallBuilder.cpp [deleted file]
src/model/CallUI.cpp [new file with mode: 0644]
src/model/CallUI.h [new file with mode: 0644]
src/model/CallUIBuilder.cpp [new file with mode: 0644]
src/presenters/Instance.cpp
src/presenters/MainPage.cpp

diff --git a/inc/model/CallBuilder.h b/inc/model/CallBuilder.h
deleted file mode 100644 (file)
index 1ade234..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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_CALL_BUILDER_H__
-#define __CALLUI_MODEL_CALL_BUILDER_H__
-
-#include "types.h"
-
-namespace callui {
-
-       class CallBuilder {
-       public:
-               CallBuilder();
-               ICallSRef build() const;
-       };
-
-}
-
-#endif // __CALLUI_MODEL_CALL_BUILDER_H__
diff --git a/inc/model/CallUIBuilder.h b/inc/model/CallUIBuilder.h
new file mode 100644 (file)
index 0000000..ddcb11e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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_CALL_UI_BUILDER_H__
+#define __CALLUI_MODEL_CALL_UI_BUILDER_H__
+
+#include "types.h"
+
+namespace callui {
+
+       class CallUIBuilder {
+       public:
+               CallUIBuilder();
+               ICallUISRef build() const;
+       };
+
+}
+
+#endif // __CALLUI_MODEL_CALL_UI_BUILDER_H__
diff --git a/inc/model/ICall.h b/inc/model/ICall.h
deleted file mode 100644 (file)
index 9cc6505..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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_I_CALL_H__
-#define __CALLUI_MODEL_I_CALL_H__
-
-#include <app_control.h>
-
-#include "types.h"
-
-namespace callui {
-
-       class ICall : public ucl::Polymorphic {
-       public:
-               virtual void setListener(const ICallListenerWRef &listener) = 0;
-               virtual ucl::Result processAppControl(app_control_h appControl) = 0;
-               virtual ISoundManagerSRef getSoundManager() = 0;
-               virtual ICallManagerSRef getCallManager() = 0;
-               virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0;
-       };
-
-}
-
-#endif // __CALLUI_MODEL_I_CALL_H__
diff --git a/inc/model/ICallUI.h b/inc/model/ICallUI.h
new file mode 100644 (file)
index 0000000..06deda1
--- /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_I_CALL_UI_H__
+#define __CALLUI_MODEL_I_CALL_UI_H__
+
+#include <app_control.h>
+
+#include "types.h"
+
+namespace callui {
+
+       class ICallUI : public ucl::Polymorphic {
+       public:
+               virtual void setListener(const ICallListenerWRef &listener) = 0;
+               virtual ucl::Result processAppControl(app_control_h appControl) = 0;
+               virtual ISoundManagerSRef getSoundManager() = 0;
+               virtual ICallManagerSRef getCallManager() = 0;
+               virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0;
+       };
+}
+
+#endif // __CALLUI_MODEL_I_CALL_UI_H__
index ea83dc292173843449a1fedd6fc5c01e07b17a0f..32839436a32425954d948ddc8f1c3e3a63532551 100644 (file)
@@ -140,7 +140,7 @@ namespace callui {
                HD_VOICE
        };
 
-       UCL_DECLARE_REF_ALIASES(ICall);
+       UCL_DECLARE_REF_ALIASES(ICallUI);
        UCL_DECLARE_REF_ALIASES(ICallListener);
 
        UCL_DECLARE_REF_ALIASES(ICallManager);
index ea8afab0a1dbfebd67cb386044495a2b25c1d47a..0c1507790e97e1ba32345d18c7b20f3b0671cfe6 100644 (file)
@@ -59,7 +59,7 @@ namespace callui {
                ucl::SysEventProvider &m_sysEventProvider;
                ucl::IInstanceContext *m_context;
 
-               ICallSRef m_call;
+               ICallUISRef m_call;
 
                ucl::WindowSRef m_win;
                ucl::NaviframeSRef m_navi;
index 4d9443a0e2beaa35eca8abcf095c2ed15ab20ba2..6366dea9a34b3e7d23cbf81d10a887691dceafb3 100644 (file)
@@ -36,11 +36,11 @@ namespace callui {
                        Builder();
                        ~Builder();
                        Builder &setNaviframe(const ucl::NaviframeSRef &navi);
-                       Builder &setCall(const ICallSRef &call);
+                       Builder &setCallUI(const ICallUISRef &call);
                        MainPageSRef build(const ExitRequestHandler handler) const;
                private:
                        ucl::NaviframeSRef m_navi;
-                       ICallSRef m_call;
+                       ICallUISRef m_call;
                };
 
        private:
@@ -48,7 +48,7 @@ namespace callui {
                MainPage(ucl::IRefCountObj &rc,
                                const ucl::NaviframeSRef &navi,
                                const ExitRequestHandler handler,
-                               const ICallSRef &call);
+                               const ICallUISRef &call);
                virtual ~MainPage();
 
                ucl::Result doPrepare(ucl::NaviItem &item);
@@ -104,7 +104,7 @@ namespace callui {
                ucl::LayoutSRef m_rmLy;
                ucl::StyledWidgetSRef m_bottomBtn;
 
-               ICallSRef m_call;
+               ICallUISRef m_call;
                ICallManagerSRef m_cm;
                IndicatorPresenterSRef m_indicator;
                CallInfoPresenterSRef m_callInfoPrs;
diff --git a/src/model/Call.cpp b/src/model/Call.cpp
deleted file mode 100644 (file)
index e54cd56..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * 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 "Call.h"
-
-#include <app_control.h>
-
-#include "model/ICallListener.h"
-#include "model/IIncomingCall.h"
-#include "model/IActiveCall.h"
-#include "model/IHeldCall.h"
-#include "model/IEndCall.h"
-#include "model/ICallInfo.h"
-
-#include "CallClient.h"
-#include "CallManager.h"
-#include "SoundManager.h"
-
-#include "VoiceControlStateProvider.h"
-#include "IndicatorStateProvider.h"
-
-#include "ConnectionStateSource.h"
-#include "RssiStateSource.h"
-#include "BatteryStateSource.h"
-#include "VoiceControlStateSource.h"
-#include "SimSlotStateSource.h"
-#include "HdVoiceStateSource.h"
-
-#include "common.h"
-
-namespace callui {
-
-       using namespace ucl;
-
-       Call::Call(IRefCountObj &rc):
-                       RefCountAware(&rc)
-       {
-       }
-
-       Call::~Call()
-       {
-       }
-
-       void Call::setListener(const ICallListenerWRef &listener)
-       {
-               m_listener = listener;
-       }
-
-       Result Call::processAppControl(app_control_h appControl)
-       {
-               if (!appControl) {
-                       FAIL_RETURN(RES_INVALID_ARGUMENTS, "appControl is NULL");
-               }
-
-               Result ret = RES_FAIL;
-
-               char *operation = nullptr;
-               int res = app_control_get_operation(appControl, &operation);
-               if (res != APP_CONTROL_ERROR_NONE) {
-                       LOG_RETURN(RES_FAIL, "app_control_get_operation() failed!");
-               }
-               if (!operation) {
-                       LOG_RETURN(RES_FAIL, "operation is NULL!");
-               }
-
-               char *uri = nullptr;
-               res = app_control_get_uri(appControl, &uri);
-               if (res != APP_CONTROL_ERROR_NONE) {
-                       free(operation);
-                       LOG_RETURN(RES_FAIL, "app_control_get_uri() failed!");
-               }
-               if (!uri) {
-                       free(operation);
-                       LOG_RETURN(RES_FAIL, "uri is NULL!");
-               }
-
-               if (strcmp(operation, APP_CONTROL_OPERATION_CALL) || strncmp(uri, "tel:", 4)) {
-                       free(operation);
-                       free(uri);
-                       LOG_RETURN(RES_FAIL, "Not processed operation!");
-               }
-
-               char *tmp = nullptr;
-               if (!strncmp(uri, "tel:MT", 6)) {
-                       res = app_control_get_extra_data(appControl, "sim_slot", &tmp);
-                       if (res != APP_CONTROL_ERROR_NONE) {
-                               ELOG("app_control_get_extra_data() failed!");
-                       }
-                       if (!tmp) {
-                               free(operation);
-                               free(uri);
-                               LOG_RETURN(RES_FAIL, "Sim slot is NULL!");
-                       }
-                       DLOG("Sim slot [%s]", tmp);
-                       free(tmp);
-
-                       ret = m_callManager->processIncomingCall(
-                                       convertCMSimSlot(static_cast<cm_multi_sim_slot_type_e>(atoi(tmp))));
-
-               } else {
-                       tmp = static_cast<char *>(uri + 4);
-                       DLOG("number [%s]", tmp);
-
-                       if (!tmp) {
-                               free(operation);
-                               free(uri);
-                               LOG_RETURN(RES_FAIL, "number is NULL");
-                       }
-
-                       ret = m_callManager->processOutgoingCall(tmp);
-               }
-
-               free(operation);
-               free(uri);
-
-               return ret;
-       }
-
-       Result Call::prepare()
-       {
-               auto callClient = CallClient::newInstance();
-               if (!callClient) {
-                       LOG_RETURN(RES_FAIL,
-                                       "Client::newInstance() failed!");
-               }
-
-               m_callManager = CallManager::newInstance(callClient, asWeak(*this));
-               if (!m_callManager) {
-                       LOG_RETURN(RES_FAIL,
-                                       "CallManager::newInstance() failed!");
-               }
-
-               m_soundManager = SoundManager::newInstance(callClient);
-               if (!m_soundManager) {
-                       LOG_RETURN(RES_FAIL,
-                                       "SoundManage::newInstance() failed!");
-               }
-
-               m_voiceControlPrv = VoiceControlStateProvider::newInstance();
-               if (!m_voiceControlPrv) {
-                       LOG_RETURN(RES_FAIL,
-                                       "VoiceControlStateProvider::newInstance() failed!");
-               }
-
-               FAIL_RETURN(initInidcatorStateProvider(),
-                               "Init Indicator State Provider failed!");
-
-               return RES_OK;
-       }
-
-       Result Call::initInidcatorStateProvider()
-       {
-               m_indicatorStPrv = IndicatorStateProvider::newInstance();
-               if (!m_indicatorStPrv) {
-                       LOG_RETURN(RES_FAIL, "IndicatorStateProvider::newInstance() failed!");
-               }
-
-               auto connStateSource = ConnectionStateSource::newInstance();
-               if (!connStateSource) {
-                       LOG_RETURN(RES_FAIL,
-                                       "ConnectionStateSource::newInstance() failed!");
-               }
-               FAIL_RETURN(m_indicatorStPrv->setStateSource(
-                               IndicatorProperty::NW_CONNECTION, connStateSource),
-                               "setStateSource() failed!");
-
-               auto rssiStSrc = RssiStateSource::newInstance();
-               if (!rssiStSrc) {
-                       LOG_RETURN(RES_FAIL,
-                                       "RssiStateSource::newInstance() failed!");
-               }
-               FAIL_RETURN(m_indicatorStPrv->setStateSource(
-                               IndicatorProperty::RSSI, rssiStSrc),
-                               "setStateSource() failed!");
-
-               auto batteryStSrc = BatteryStateSource::newInstance();
-               if (!batteryStSrc) {
-                       LOG_RETURN(RES_FAIL,
-                                       "BatteryStateSource::newInstance() failed!");
-               }
-               FAIL_RETURN(m_indicatorStPrv->setStateSource(
-                               IndicatorProperty::BATTERY, batteryStSrc),
-                               "setStateSource() failed!");
-
-               auto voiceControlStSrc =
-                               VoiceControlStateSource::newInstance(m_voiceControlPrv);
-               if (!voiceControlStSrc) {
-                       LOG_RETURN(RES_FAIL,
-                                       "VoiceControlStateSource::newInstance() failed!");
-               }
-               FAIL_RETURN(m_indicatorStPrv->setStateSource(
-                               IndicatorProperty::VOICE_CONTROL, voiceControlStSrc),
-                               "setStateSource() failed!");
-
-               m_simSlotStSrc = makeShared<SimSlotStateSource>(
-                               m_callManager->getSimSlot(), getForwardedCallStatus());
-               FAIL_RETURN(m_indicatorStPrv->setStateSource(
-                               IndicatorProperty::SIM_SLOT, m_simSlotStSrc),
-                               "setStateSource() failed!");
-
-               m_hdCallStSrc = makeShared<HdVoiceStateSource>(
-                               getHDVoiceStatus());
-               FAIL_RETURN(m_indicatorStPrv->setStateSource(
-                               IndicatorProperty::HD_VOICE, m_hdCallStSrc),
-                               "setStateSource() failed!");
-
-               return RES_OK;
-       }
-
-       ICallManagerSRef Call::getCallManager()
-       {
-               return m_callManager;
-       }
-
-       ISoundManagerSRef Call::getSoundManager()
-       {
-               return m_soundManager;
-       }
-
-       IIndicatorStateProviderSRef Call::getIndicatorStateProvider()
-       {
-               return m_indicatorStPrv;
-       }
-
-       ICallInfoSCRef Call::getCurrentCallInfo() const
-       {
-               CallMask calls = m_callManager->getAvailableCalls();
-               if (!calls) {
-                       DLOG("No available calls");
-                       return {};
-               } else if (calls & CALL_FLAG_INCOMING) {
-                       return m_callManager->getIncomingCall()->getInfo();
-               } else if (calls & CALL_FLAG_ACTIVE) {
-                       return m_callManager->getActiveCall()->getInfo();
-               } else if (calls & CALL_FLAG_HELD) {
-                       return m_callManager->getHeldCall()->getInfo();
-               } else if (calls & CALL_FLAG_END) {
-                       return m_callManager->getEndCall()->getInfo();
-               }
-               return {};
-       }
-
-       bool Call::getHDVoiceStatus() const
-       {
-               ICallInfoSCRef info = getCurrentCallInfo();
-               if (info) {
-                       return info->isHDVoice();
-               }
-               return false;
-       }
-
-       bool Call::getForwardedCallStatus() const
-       {
-               ICallInfoSCRef info = getCurrentCallInfo();
-               if (info) {
-                       return info->isForwarded();
-               }
-               return false;
-       }
-
-       void Call::updateHdVoiceStateSource()
-       {
-               m_hdCallStSrc->updateState(getHDVoiceStatus());
-       }
-
-       void Call::updateSimSlotStateSource()
-       {
-               m_simSlotStSrc->updateSimSlot(m_callManager->getSimSlot(),
-                               getForwardedCallStatus());
-       }
-
-       void Call::onCallEvent(CallEventType type)
-       {
-               updateSimSlotStateSource();
-               updateHdVoiceStateSource();
-
-               if (const auto listener = m_listener.lock()) {
-                       listener->onCallEvent(type);
-               }
-       }
-
-       void Call::onError(CallManagerErr err)
-       {
-               auto callErr = CallErr::DIAL_FAIL;
-               switch (err) {
-               case CallManagerErr::DIAL_CANCEL:
-                       callErr = CallErr::DIAL_CANCEL;
-                       break;
-               case CallManagerErr::DIAL_FLIGHT_MODE:
-                       callErr = CallErr::DIAL_FLIGHT_MODE;
-                       break;
-               default:
-                       callErr = CallErr::DIAL_FAIL;
-                       break;
-               }
-
-               if (const auto listener = m_listener.lock()) {
-                       listener->onError(callErr);
-               }
-       }
-
-}
diff --git a/src/model/Call.h b/src/model/Call.h
deleted file mode 100644 (file)
index cc18576..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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_CALL_H__
-#define __CALLUI_MODEL_CALL_H__
-
-#include "model/ICall.h"
-#include "ICallManagerListener.h"
-
-#include <app_control.h>
-
-#include "types.h"
-
-namespace callui {
-
-       UCL_DECLARE_REF_ALIASES(CallManager);
-       UCL_DECLARE_REF_ALIASES(SoundManager);
-
-       class Call final :
-               public ucl::RefCountAware,
-               public ICall,
-               public ICallManagerListener {
-       public:
-               virtual ~Call();
-
-               // ICall
-
-               virtual void setListener(const ICallListenerWRef &listener) override final;
-               virtual ucl::Result processAppControl(app_control_h appControl) override final;
-               virtual ISoundManagerSRef getSoundManager() override final;
-               virtual ICallManagerSRef getCallManager() override final;
-               virtual IIndicatorStateProviderSRef getIndicatorStateProvider() override final;
-
-               // ICallManagerListener
-
-               virtual void onCallEvent(CallEventType type) override final;
-               virtual void onError(CallManagerErr err) override final;
-
-       private:
-               friend class CallBuilder;
-               friend class ucl::ReffedObj<Call>;
-               Call(ucl::IRefCountObj &rc);
-
-               ucl::Result prepare();
-
-               ucl::Result initInidcatorStateProvider();
-
-               void updateHdVoiceStateSource();
-               void updateSimSlotStateSource();
-               ICallInfoSCRef getCurrentCallInfo() const;
-               bool getHDVoiceStatus() const;
-               bool getForwardedCallStatus() const;
-
-       private:
-               CallManagerSRef m_callManager;
-               SoundManagerSRef m_soundManager;
-               ICallListenerWRef m_listener;
-               SimSlotStateSourceSRef m_simSlotStSrc;
-               HdVoiceStateSourceSRef m_hdCallStSrc;
-               IndicatorStateProviderSRef m_indicatorStPrv;
-               VoiceControlStateProviderSRef m_voiceControlPrv;
-       };
-
-}
-
-#endif // __CALLUI_MODEL_CALL_H__
diff --git a/src/model/CallBuilder.cpp b/src/model/CallBuilder.cpp
deleted file mode 100644 (file)
index 5826135..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 "model/CallBuilder.h"
-
-#include "Call.h"
-
-#include "common.h"
-
-namespace callui {
-
-       using namespace ucl;
-
-       CallBuilder::CallBuilder()
-       {
-       }
-
-       ICallSRef CallBuilder::build() const
-       {
-               auto result = makeShared<Call>();
-               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-               return result;
-       }
-
-}
diff --git a/src/model/CallUI.cpp b/src/model/CallUI.cpp
new file mode 100644 (file)
index 0000000..11eb494
--- /dev/null
@@ -0,0 +1,315 @@
+/*
+ * 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 "CallUI.h"
+
+#include <app_control.h>
+
+#include "model/ICallListener.h"
+#include "model/IIncomingCall.h"
+#include "model/IActiveCall.h"
+#include "model/IHeldCall.h"
+#include "model/IEndCall.h"
+#include "model/ICallInfo.h"
+
+#include "CallClient.h"
+#include "CallManager.h"
+#include "SoundManager.h"
+
+#include "VoiceControlStateProvider.h"
+#include "IndicatorStateProvider.h"
+
+#include "ConnectionStateSource.h"
+#include "RssiStateSource.h"
+#include "BatteryStateSource.h"
+#include "VoiceControlStateSource.h"
+#include "SimSlotStateSource.h"
+#include "HdVoiceStateSource.h"
+
+#include "common.h"
+
+namespace callui {
+
+       using namespace ucl;
+
+       CallUI::CallUI(IRefCountObj &rc):
+                       RefCountAware(&rc)
+       {
+       }
+
+       CallUI::~CallUI()
+       {
+       }
+
+       void CallUI::setListener(const ICallListenerWRef &listener)
+       {
+               m_listener = listener;
+       }
+
+       Result CallUI::processAppControl(app_control_h appControl)
+       {
+               if (!appControl) {
+                       FAIL_RETURN(RES_INVALID_ARGUMENTS, "appControl is NULL");
+               }
+
+               Result ret = RES_FAIL;
+
+               char *operation = nullptr;
+               int res = app_control_get_operation(appControl, &operation);
+               if (res != APP_CONTROL_ERROR_NONE) {
+                       LOG_RETURN(RES_FAIL, "app_control_get_operation() failed!");
+               }
+               if (!operation) {
+                       LOG_RETURN(RES_FAIL, "operation is NULL!");
+               }
+
+               char *uri = nullptr;
+               res = app_control_get_uri(appControl, &uri);
+               if (res != APP_CONTROL_ERROR_NONE) {
+                       free(operation);
+                       LOG_RETURN(RES_FAIL, "app_control_get_uri() failed!");
+               }
+               if (!uri) {
+                       free(operation);
+                       LOG_RETURN(RES_FAIL, "uri is NULL!");
+               }
+
+               if (strcmp(operation, APP_CONTROL_OPERATION_CALL) || strncmp(uri, "tel:", 4)) {
+                       free(operation);
+                       free(uri);
+                       LOG_RETURN(RES_FAIL, "Not processed operation!");
+               }
+
+               char *tmp = nullptr;
+               if (!strncmp(uri, "tel:MT", 6)) {
+                       res = app_control_get_extra_data(appControl, "sim_slot", &tmp);
+                       if (res != APP_CONTROL_ERROR_NONE) {
+                               ELOG("app_control_get_extra_data() failed!");
+                       }
+                       if (!tmp) {
+                               free(operation);
+                               free(uri);
+                               LOG_RETURN(RES_FAIL, "Sim slot is NULL!");
+                       }
+                       DLOG("Sim slot [%s]", tmp);
+                       free(tmp);
+
+                       ret = m_callManager->processIncomingCall(
+                                       convertCMSimSlot(static_cast<cm_multi_sim_slot_type_e>(atoi(tmp))));
+
+               } else {
+                       tmp = static_cast<char *>(uri + 4);
+                       DLOG("number [%s]", tmp);
+
+                       if (!tmp) {
+                               free(operation);
+                               free(uri);
+                               LOG_RETURN(RES_FAIL, "number is NULL");
+                       }
+
+                       ret = m_callManager->processOutgoingCall(tmp);
+               }
+
+               free(operation);
+               free(uri);
+
+               return ret;
+       }
+
+       Result CallUI::prepare()
+       {
+               auto callClient = CallClient::newInstance();
+               if (!callClient) {
+                       LOG_RETURN(RES_FAIL,
+                                       "Client::newInstance() failed!");
+               }
+
+               m_callManager = CallManager::newInstance(callClient, asWeak(*this));
+               if (!m_callManager) {
+                       LOG_RETURN(RES_FAIL,
+                                       "CallManager::newInstance() failed!");
+               }
+
+               m_soundManager = SoundManager::newInstance(callClient);
+               if (!m_soundManager) {
+                       LOG_RETURN(RES_FAIL,
+                                       "SoundManage::newInstance() failed!");
+               }
+
+               m_voiceControlPrv = VoiceControlStateProvider::newInstance();
+               if (!m_voiceControlPrv) {
+                       LOG_RETURN(RES_FAIL,
+                                       "VoiceControlStateProvider::newInstance() failed!");
+               }
+
+               FAIL_RETURN(initInidcatorStateProvider(),
+                               "Init Indicator State Provider failed!");
+
+               return RES_OK;
+       }
+
+       Result CallUI::initInidcatorStateProvider()
+       {
+               m_indicatorStPrv = IndicatorStateProvider::newInstance();
+               if (!m_indicatorStPrv) {
+                       LOG_RETURN(RES_FAIL, "IndicatorStateProvider::newInstance() failed!");
+               }
+
+               auto connStateSource = ConnectionStateSource::newInstance();
+               if (!connStateSource) {
+                       LOG_RETURN(RES_FAIL,
+                                       "ConnectionStateSource::newInstance() failed!");
+               }
+               FAIL_RETURN(m_indicatorStPrv->setStateSource(
+                               IndicatorProperty::NW_CONNECTION, connStateSource),
+                               "setStateSource() failed!");
+
+               auto rssiStSrc = RssiStateSource::newInstance();
+               if (!rssiStSrc) {
+                       LOG_RETURN(RES_FAIL,
+                                       "RssiStateSource::newInstance() failed!");
+               }
+               FAIL_RETURN(m_indicatorStPrv->setStateSource(
+                               IndicatorProperty::RSSI, rssiStSrc),
+                               "setStateSource() failed!");
+
+               auto batteryStSrc = BatteryStateSource::newInstance();
+               if (!batteryStSrc) {
+                       LOG_RETURN(RES_FAIL,
+                                       "BatteryStateSource::newInstance() failed!");
+               }
+               FAIL_RETURN(m_indicatorStPrv->setStateSource(
+                               IndicatorProperty::BATTERY, batteryStSrc),
+                               "setStateSource() failed!");
+
+               auto voiceControlStSrc =
+                               VoiceControlStateSource::newInstance(m_voiceControlPrv);
+               if (!voiceControlStSrc) {
+                       LOG_RETURN(RES_FAIL,
+                                       "VoiceControlStateSource::newInstance() failed!");
+               }
+               FAIL_RETURN(m_indicatorStPrv->setStateSource(
+                               IndicatorProperty::VOICE_CONTROL, voiceControlStSrc),
+                               "setStateSource() failed!");
+
+               m_simSlotStSrc = makeShared<SimSlotStateSource>(
+                               m_callManager->getSimSlot(), getForwardedCallStatus());
+               FAIL_RETURN(m_indicatorStPrv->setStateSource(
+                               IndicatorProperty::SIM_SLOT, m_simSlotStSrc),
+                               "setStateSource() failed!");
+
+               m_hdCallStSrc = makeShared<HdVoiceStateSource>(
+                               getHDVoiceStatus());
+               FAIL_RETURN(m_indicatorStPrv->setStateSource(
+                               IndicatorProperty::HD_VOICE, m_hdCallStSrc),
+                               "setStateSource() failed!");
+
+               return RES_OK;
+       }
+
+       ICallManagerSRef CallUI::getCallManager()
+       {
+               return m_callManager;
+       }
+
+       ISoundManagerSRef CallUI::getSoundManager()
+       {
+               return m_soundManager;
+       }
+
+       IIndicatorStateProviderSRef CallUI::getIndicatorStateProvider()
+       {
+               return m_indicatorStPrv;
+       }
+
+       ICallInfoSCRef CallUI::getCurrentCallInfo() const
+       {
+               CallMask calls = m_callManager->getAvailableCalls();
+               if (!calls) {
+                       DLOG("No available calls");
+                       return {};
+               } else if (calls & CALL_FLAG_INCOMING) {
+                       return m_callManager->getIncomingCall()->getInfo();
+               } else if (calls & CALL_FLAG_ACTIVE) {
+                       return m_callManager->getActiveCall()->getInfo();
+               } else if (calls & CALL_FLAG_HELD) {
+                       return m_callManager->getHeldCall()->getInfo();
+               } else if (calls & CALL_FLAG_END) {
+                       return m_callManager->getEndCall()->getInfo();
+               }
+               return {};
+       }
+
+       bool CallUI::getHDVoiceStatus() const
+       {
+               ICallInfoSCRef info = getCurrentCallInfo();
+               if (info) {
+                       return info->isHDVoice();
+               }
+               return false;
+       }
+
+       bool CallUI::getForwardedCallStatus() const
+       {
+               ICallInfoSCRef info = getCurrentCallInfo();
+               if (info) {
+                       return info->isForwarded();
+               }
+               return false;
+       }
+
+       void CallUI::updateHdVoiceStateSource()
+       {
+               m_hdCallStSrc->updateState(getHDVoiceStatus());
+       }
+
+       void CallUI::updateSimSlotStateSource()
+       {
+               m_simSlotStSrc->updateSimSlot(m_callManager->getSimSlot(),
+                               getForwardedCallStatus());
+       }
+
+       void CallUI::onCallEvent(CallEventType type)
+       {
+               updateSimSlotStateSource();
+               updateHdVoiceStateSource();
+
+               if (const auto listener = m_listener.lock()) {
+                       listener->onCallEvent(type);
+               }
+       }
+
+       void CallUI::onError(CallManagerErr err)
+       {
+               auto callErr = CallErr::DIAL_FAIL;
+               switch (err) {
+               case CallManagerErr::DIAL_CANCEL:
+                       callErr = CallErr::DIAL_CANCEL;
+                       break;
+               case CallManagerErr::DIAL_FLIGHT_MODE:
+                       callErr = CallErr::DIAL_FLIGHT_MODE;
+                       break;
+               default:
+                       callErr = CallErr::DIAL_FAIL;
+                       break;
+               }
+
+               if (const auto listener = m_listener.lock()) {
+                       listener->onError(callErr);
+               }
+       }
+
+}
diff --git a/src/model/CallUI.h b/src/model/CallUI.h
new file mode 100644 (file)
index 0000000..1be1aa3
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * 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_CALL_UI_H__
+#define __CALLUI_MODEL_CALL_UI_H__
+
+#include "model/ICallUI.h"
+
+#include "ICallManagerListener.h"
+
+#include "types.h"
+
+namespace callui {
+
+       UCL_DECLARE_REF_ALIASES(CallManager);
+       UCL_DECLARE_REF_ALIASES(SoundManager);
+
+       class CallUI final :
+               public ucl::RefCountAware,
+               public ICallUI,
+               public ICallManagerListener {
+       public:
+               virtual ~CallUI();
+
+               // ICallUI
+
+               virtual void setListener(const ICallListenerWRef &listener) override final;
+               virtual ucl::Result processAppControl(app_control_h appControl) override final;
+               virtual ISoundManagerSRef getSoundManager() override final;
+               virtual ICallManagerSRef getCallManager() override final;
+               virtual IIndicatorStateProviderSRef getIndicatorStateProvider() override final;
+
+               // ICallManagerListener
+
+               virtual void onCallEvent(CallEventType type) override final;
+               virtual void onError(CallManagerErr err) override final;
+
+       private:
+               friend class CallUIBuilder;
+               friend class ucl::ReffedObj<CallUI>;
+               CallUI(ucl::IRefCountObj &rc);
+
+               ucl::Result prepare();
+
+               ucl::Result initInidcatorStateProvider();
+
+               void updateHdVoiceStateSource();
+               void updateSimSlotStateSource();
+               ICallInfoSCRef getCurrentCallInfo() const;
+               bool getHDVoiceStatus() const;
+               bool getForwardedCallStatus() const;
+
+       private:
+               CallManagerSRef m_callManager;
+               SoundManagerSRef m_soundManager;
+               ICallListenerWRef m_listener;
+               SimSlotStateSourceSRef m_simSlotStSrc;
+               HdVoiceStateSourceSRef m_hdCallStSrc;
+               IndicatorStateProviderSRef m_indicatorStPrv;
+               VoiceControlStateProviderSRef m_voiceControlPrv;
+       };
+
+}
+
+#endif // __CALLUI_MODEL_CALL_UI_H__
diff --git a/src/model/CallUIBuilder.cpp b/src/model/CallUIBuilder.cpp
new file mode 100644 (file)
index 0000000..5a9d5ba
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 "model/CallUIBuilder.h"
+
+#include "CallUI.h"
+
+#include "common.h"
+
+namespace callui {
+
+       using namespace ucl;
+
+       CallUIBuilder::CallUIBuilder()
+       {
+       }
+
+       ICallUISRef CallUIBuilder::build() const
+       {
+               auto result = makeShared<CallUI>();
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+               return result;
+       }
+
+}
index 8da864592a641bbfde20339445e81f26cee92c17..e77f8c411d7b419c31ebf9ce155fb4e201ddbc21 100644 (file)
@@ -22,8 +22,8 @@
 
 #include <system_settings.h>
 
-#include "model/CallBuilder.h"
-#include "model/ICall.h"
+#include "model/CallUIBuilder.h"
+#include "model/ICallUI.h"
 #include "model/ICallManager.h"
 #include "presenters/MainPage.h"
 
@@ -81,7 +81,7 @@ namespace callui {
 
                FAIL_RETURN(setupTheme(), "setupTheme() failed!");
 
-               m_call = CallBuilder().build();
+               m_call = CallUIBuilder().build();
                if (!m_call) {
                        LOG_RETURN(RES_FAIL, "m_call is NULL");
                }
@@ -118,7 +118,7 @@ namespace callui {
                if (!m_page) {
                        auto page = MainPage::Builder().
                                        setNaviframe(m_navi).
-                                       setCall(m_call).
+                                       setCallUI(m_call).
                                        build(WEAK_DELEGATE(Instance::onPageExitRequest,
                                                        asWeak(this)));
                        if (!page) {
index 0d10949f95dfba14ce28e89d6298a49472a4f0fb..1a491b452675c7676e19fc47948653899863d594 100644 (file)
@@ -19,7 +19,7 @@
 #include "ucl/gui/Window.h"
 #include "ucl/gui/Widget.h"
 
-#include "model/ICall.h"
+#include "model/ICallUI.h"
 #include "model/ICallManager.h"
 #include "model/IIncomingCall.h"
 #include "model/IActiveCall.h"
@@ -88,8 +88,8 @@ namespace callui {
                return *this;
        }
 
-       MainPage::Builder &MainPage::Builder::setCall(
-                       const ICallSRef &call)
+       MainPage::Builder &MainPage::Builder::setCallUI(
+                       const ICallUISRef &call)
        {
                m_call = call;
                return *this;
@@ -128,7 +128,7 @@ namespace callui {
        MainPage::MainPage(IRefCountObj &rc,
                        const NaviframeSRef &navi,
                        const ExitRequestHandler handler,
-                       const ICallSRef &call) :
+                       const ICallUISRef &call) :
                Page(rc, navi, handler),
                m_call(call),
                m_mode(CallMode::UNDEFINED),