TizenRefApp-8520 [Call UI] Update UCL 41/130441/2
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 17 May 2017 10:40:55 +0000 (13:40 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 22 May 2017 09:35:44 +0000 (12:35 +0300)
Change-Id: I2b07daf83f17bfd73e707c2f4de378bce462466d

36 files changed:
inc/presenters/AcceptDialog.h
inc/presenters/AcceptRejectPresenter.h
inc/presenters/CallInfoPresenter.h
inc/presenters/Indicator.h
inc/presenters/Page.h
inc/presenters/Page.hpp
inc/presenters/Presenter.h [new file with mode: 0644]
src/model/SoundManager.cpp
src/presenters/AcceptDialog.cpp
src/presenters/AcceptRejectPresenter.cpp
src/presenters/CallInfoPresenter.cpp
src/presenters/Indicator.cpp
src/presenters/Page.cpp
src/presenters/Presenter.cpp [new file with mode: 0644]
ucl/inc/ucl/gui/Layout.h
ucl/inc/ucl/gui/Naviframe.h
ucl/inc/ucl/gui/Naviframe.hpp
ucl/inc/ucl/misc/Event.h
ucl/inc/ucl/misc/Event.hpp
ucl/inc/ucl/misc/SharedObject.h [deleted file]
ucl/inc/ucl/misc/SharedObject.hpp [deleted file]
ucl/inc/ucl/util/threading/Mutex.h
ucl/inc/ucl/util/threading/Mutex.hpp
ucl/src/appfw/InstanceManagerBase.cpp
ucl/src/appfw/SysEventProvider.cpp
ucl/src/appfw/UIApp.cpp
ucl/src/appfw/common.h [new file with mode: 0644]
ucl/src/appfw/helpers.cpp
ucl/src/gui/Layout.cpp
ucl/src/gui/NaviItem.cpp
ucl/src/gui/Naviframe.cpp
ucl/src/gui/Widget.cpp
ucl/src/gui/Window.cpp
ucl/src/gui/common.h [new file with mode: 0644]
ucl/src/misc/Variant.cpp
ucl/src/misc/common.h [new file with mode: 0644]

index 8319efe71825ce0a35a1c66502ebacd49889cbc0..1efaa4ff20b2e21966a25032fc855059cc9ff130 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __CALLUI_VIEW_ACCEPT_DIALOG_H__
 #define __CALLUI_VIEW_ACCEPT_DIALOG_H__
 
+#include "Presenter.h"
+
 #include "ucl/gui/StyledWidget.h"
 #include "ucl/gui/ElmWidget.h"
 
@@ -25,7 +27,7 @@
 namespace callui {
 
        class AcceptDialog final :
-                       public ucl::RefCountAware,
+                       public Presenter,
                        public ucl::IDisposable {
        public:
                class Builder {
index 194ebe6b932b55de48bd61fac34e82dbfa163a5a..31eae7fa06ae5a230afec6912a69092d24f38ca4 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__
 #define __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__
 
+#include "Presenter.h"
+
 #include "ucl/gui/Layout.h"
 #include "ucl/gui/StyledWidget.h"
 
@@ -24,7 +26,7 @@
 
 namespace callui {
 
-       class AcceptRejectPresenter final : public ucl::RefCountAware {
+       class AcceptRejectPresenter final : public Presenter {
        public:
                class Builder {
                public:
@@ -52,9 +54,9 @@ namespace callui {
                                const IIncomingCallSRef &call,
                                CallMask calls);
 
-               ucl::Result prepare(ucl::Widget &parent);
+               ucl::Result prepare(ucl::ElmWidget &parent);
 
-               ucl::Result createWidget(ucl::Widget &parent);
+               ucl::Result createWidget(ucl::ElmWidget &parent);
                ucl::Result createAcceptBtn();
                ucl::Result createRejectBtn();
 
index 3320306acc2cb9df9e16c4a8565130ab0c0e2a65..1d69705410401ace8294535c9c8be02e9cf34858 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__
 #define __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__
 
+#include "Presenter.h"
+
 #include "ucl/gui/Layout.h"
 #include "ucl/gui/StyledWidget.h"
 
@@ -24,7 +26,7 @@
 
 namespace callui {
 
-       class CallInfoPresenter final : public ucl::RefCountAware {
+       class CallInfoPresenter final : public Presenter {
        public:
                class Builder {
                public:
@@ -51,11 +53,11 @@ namespace callui {
                                const ICallManagerSRef &cm,
                                CallInfoMode mode);
 
-               ucl::Result prepare(ucl::Widget &parent);
+               ucl::Result prepare(ucl::ElmWidget &parent);
 
                void initCallInfos(const ICallManagerSRef &cm);
 
-               ucl::Result createWidget(ucl::Widget &parent);
+               ucl::Result createWidget(ucl::ElmWidget &parent);
                ucl::Result createLabel(const std::string &text);
                ucl::Result createCallStatus();
 
index 6958df410b68b3dce9c46644f5f154a0eca7ca77..ed9843237c53806b111d09622ebab70516cb7a4f 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef __CALLUI_PRESENTERS_INDICATOR_H__
 #define __CALLUI_PRESENTERS_INDICATOR_H__
 
+#include "Presenter.h"
 #include "model/IIndicatorStateListener.h"
 
 #include "ucl/gui/Layout.h"
@@ -28,7 +29,7 @@ namespace callui {
 
        class Indicator final :
                        public IIndicatorStateListener,
-                       public ucl::RefCountAware {
+                       public Presenter {
        public:
                class Builder {
                public:
@@ -50,9 +51,9 @@ namespace callui {
                Indicator(ucl::RefCountObjBase &rc,
                                const IIndicatorStateProviderSRef &provider);
 
-               ucl::Result prepare(ucl::Widget &parent);
+               ucl::Result prepare(ucl::ElmWidget &parent);
 
-               ucl::Result createWidget(ucl::Widget &parent);
+               ucl::Result createWidget(ucl::ElmWidget &parent);
                ucl::Result createConnectionLayout();
                ucl::Result createRssiLayout();
                ucl::Result createBatteryLayout();
index bfe3ac29b7ab26259bb1fa77ccc0ccf6b3a6b162..1d6b37ec634707b523b7cfe7853b0142fe39060f 100644 (file)
 
 #include "ucl/gui/Naviframe.h"
 
-#include "types.h"
+#include "Presenter.h"
 
 namespace callui {
 
-       class Page : public ucl::RefCountAware {
+       class Page : public Presenter {
        public:
                using ExitRequestHandler = ucl::Delegate<void(Page &page)>;
 
        public:
                ucl::Naviframe &getNaviframe();
 
-               bool isActive() const;
-
                bool isAtTop() const;
                bool isAtBottom() const;
 
@@ -60,8 +58,6 @@ namespace callui {
 
                void requestExit();
 
-               virtual void onActivate();
-               virtual void onDeactivate();
                virtual void onBackKey();
 
        private:
@@ -69,8 +65,6 @@ namespace callui {
 
                void dispatchTopPageChanged();
 
-               void activate();
-               void deactivate();
                void updateActiveState();
 
                void onTransitionStarted(ucl::Widget &widget, void *eventInfo);
@@ -84,10 +78,9 @@ namespace callui {
                const ucl::NaviframeSRef m_navi;
                const ExitRequestHandler m_onExitRequest;
                ucl::NaviItem m_item;
-               bool m_isActive;
        };
 
-       // Non-member functions
+       // Non-member functions //
 
        bool isLast(const Page &page);
 }
index 58e11c58759b7726cd7b46d8541cfecb3d789c7c..2f777e4dfb5f5925e79a26fa6d2b942cc4c824fc 100644 (file)
@@ -46,11 +46,6 @@ namespace callui {
                return *m_navi;
        }
 
-       inline bool Page::isActive() const
-       {
-               return m_isActive;
-       }
-
        inline bool Page::isAtTop() const
        {
                return (m_navi->getTopItem() == m_item);
@@ -61,7 +56,7 @@ namespace callui {
                return (m_navi->getBottomItem() == m_item);
        }
 
-       // Non-member functions
+       // Non-member functions //
 
        inline bool isLast(const Page &page)
        {
diff --git a/inc/presenters/Presenter.h b/inc/presenters/Presenter.h
new file mode 100644 (file)
index 0000000..677abe0
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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_PRESENTERS_PRESENTER_H__
+#define __CALLUI_PRESENTERS_PRESENTER_H__
+
+#include <unordered_set>
+
+#include "ucl/gui/ElmWidget.h"
+
+#include "types.h"
+
+namespace callui {
+
+       class Presenter : public ucl::RefCountAware {
+       public:
+               struct DeactivatorInfo {
+                       void *deactivator;
+                       bool isBroadcast;
+               };
+
+       public:
+               bool isActive() const;
+               bool isDeactivatedBy(void *deactivator) const;
+
+               void activateBy(void *deactivator);
+               void deactivateBy(void *deactivator);
+
+       protected:
+               Presenter(ucl::RefCountObjBase &rc);
+               virtual ~Presenter();
+
+               ucl::Result prepare(ucl::ElmWidget &widget);
+
+               void addDeactivatorSource(ucl::Widget &source);
+               void addDeactivatorException(void *deactivator);
+
+               void sendActivateBy(ucl::Widget &sender, void *deactivator);
+               void sendDeactivateBy(ucl::Widget &sender, void *deactivator);
+
+               void broadcastActivateBy(void *deactivator);
+               void broadcastDeactivateBy(void *deactivator);
+
+               virtual void onActivate();
+               virtual void onDeactivate();
+               virtual void onActivateBy(const DeactivatorInfo &info);
+               virtual void onDeactivateBy(const DeactivatorInfo &info);
+
+       private:
+               void sendDeactivator(ucl::Widget &sender,
+                               ucl::SmartEvent event, void *deactivator);
+               void broadcastDeactivator(ucl::SmartEvent event, void *deactivator);
+
+               void sendDeactivatorInfo(ucl::Widget &sender, ucl::SmartEvent event,
+                               const DeactivatorInfo &info);
+
+               void activateByImpl(const DeactivatorInfo &info);
+               void deactivateByImpl(const DeactivatorInfo &info);
+
+               void onActivateBySmart(ucl::Widget &widget, void *eventInfo);
+               void onDeactivateBySmart(ucl::Widget &widget, void *eventInfo);
+
+       private:
+               std::unordered_set<void *> m_deactivatorExceptions;
+               std::unordered_set<void *> m_deactivators;
+               ucl::WidgetWRef m_topWidget;
+               bool m_isPrepared;
+       };
+}
+
+#endif // __CALLUI_PRESENTERS_PRESENTER_H__
index bcd5d95fe5894b67f4aa5e0a644bea618f367841..6092986b9a8df9f32c62f498c341fa3e9ea2f2c1 100644 (file)
@@ -49,12 +49,12 @@ namespace callui {
                        return;
                }
 
-               m_audioStateEvent.invoke(convertCMAudioState(state));
+               m_audioStateEvent.dispatch(convertCMAudioState(state));
        }
 
        void SoundManager::muteStateChangedCb(cm_mute_status_e status)
        {
-               m_muteStateEvent.invoke(status == CM_MUTE_STATUS_ON);
+               m_muteStateEvent.dispatch(status == CM_MUTE_STATUS_ON);
        }
 
        Result SoundManager::prepare()
index 2c7de25ce06bf39c7459a4efc49717176a8ddfec..e2687d6f65f0d8be8bcb3cf8a5971138581daf18 100644 (file)
@@ -73,7 +73,7 @@ namespace callui {
 
        AcceptDialog::AcceptDialog(RefCountObjBase &rc,
                        const AcceptDialogHandler &handler):
-                                       RefCountAware(&rc),
+                                       Presenter(rc),
                                        m_handler(handler),
                                        m_isDismissed(false)
        {
@@ -85,6 +85,9 @@ namespace callui {
 
        Result AcceptDialog::prepare(ElmWidget &parent)
        {
+               FAIL_RETURN(Presenter::prepare(parent),
+                               "Presenter::prepare() failed!");
+
                FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE),
                                "createPopup() failed!");
 
index d1a0c901dae21ca428393a6ad163e0fe187411a4..dd5a8d0d69ad93e344ca049c91ed9973ad082b95 100644 (file)
@@ -89,7 +89,7 @@ namespace callui {
        AcceptRejectPresenter::AcceptRejectPresenter(RefCountObjBase &rc,
                        const IIncomingCallSRef &call,
                        CallMask calls):
-                       RefCountAware(&rc),
+                       Presenter(rc),
                        m_call(call),
                        m_callMask(calls)
        {
@@ -101,14 +101,14 @@ namespace callui {
                        m_popup->dispose();
                }
 
-               eext_rotary_object_event_activated_set(m_widget->getEo(), EINA_FALSE);
-
                delRotaryEventHandler(CALLBACK_A(
                                AcceptRejectPresenter::onRotaryEvent), this);
        }
 
-       Result AcceptRejectPresenter::prepare(Widget &parent)
+       Result AcceptRejectPresenter::prepare(ElmWidget &parent)
        {
+               FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!");
+
                FAIL_RETURN(createWidget(parent), "createWidget() failed!");
 
                FAIL_RETURN(createAcceptBtn(), "createAcceptBtn() failed!");
@@ -118,8 +118,6 @@ namespace callui {
                addRotaryEventHandler(CALLBACK_A(
                                AcceptRejectPresenter::onRotaryEvent), this);
 
-               eext_rotary_object_event_activated_set(m_widget->getEo(), EINA_TRUE);
-
                return RES_OK;
        }
 
@@ -140,7 +138,7 @@ namespace callui {
                }
        }
 
-       Result AcceptRejectPresenter::createWidget(Widget &parent)
+       Result AcceptRejectPresenter::createWidget(ElmWidget &parent)
        {
                m_widget = Layout::Builder().
                                setTheme(impl::LAYOUT_ACCEPT_REJECT_WIDGET).
index 7699ddc2f57070cafbab81367ea0c1faaed6b652..d1057171fab33d9287be1388ca042c56bb941680 100644 (file)
@@ -124,7 +124,7 @@ namespace callui {
        CallInfoPresenter::CallInfoPresenter(RefCountObjBase &rc,
                        const ICallManagerSRef &cm,
                        CallInfoMode mode):
-                       RefCountAware(&rc),
+                       Presenter(rc),
                        m_mode(mode),
                        m_isCallerIdEnable(false),
                        m_isEmergency(false),
@@ -138,8 +138,10 @@ namespace callui {
        {
        }
 
-       Result CallInfoPresenter::prepare(Widget &parent)
+       Result CallInfoPresenter::prepare(ElmWidget &parent)
        {
+               FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!");
+
                FAIL_RETURN(createWidget(parent), "createWidget() failed!");
 
                FAIL_RETURN(createCallStatus(), "createCallStatus() failed!");
@@ -149,7 +151,7 @@ namespace callui {
                return RES_OK;
        }
 
-       Result CallInfoPresenter::createWidget(Widget &parent)
+       Result CallInfoPresenter::createWidget(ElmWidget &parent)
        {
                m_widget = Layout::Builder().
                                setTheme(impl::LAYOUT_CALLER_INFO_WIDGET).
index 284373d046624bee5a4c04eb399e637fdb4c4ba1..d26083c3315530e9035c7a1ec38022fa96beff9a 100644 (file)
@@ -190,7 +190,7 @@ namespace callui {
 
        Indicator::Indicator(RefCountObjBase &rc,
                        const IIndicatorStateProviderSRef &provider):
-                                       RefCountAware(&rc),
+                                       Presenter(rc),
                                        m_provider(provider)
        {
        }
@@ -199,8 +199,11 @@ namespace callui {
        {
        }
 
-       Result Indicator::prepare(Widget &parent)
+       Result Indicator::prepare(ElmWidget &parent)
        {
+               FAIL_RETURN(Presenter::prepare(parent),
+                               "Presenter::prepare() failed!");
+
                FAIL_RETURN(createWidget(parent),
                                "createWidget() failed!");
 
@@ -224,7 +227,7 @@ namespace callui {
                return RES_OK;
        }
 
-       Result Indicator::createWidget(Widget &parent)
+       Result Indicator::createWidget(ElmWidget &parent)
        {
                m_widget = Layout::Builder().
                                setTheme(impl::LAYOUT_INDICATOR_WIDGET).
index 19e8a9ff68b766c6d7c6957b22a631be8ab0fb4d..48afd5f0bb9098014318ea2c9bc70f6a0fe3f900 100644 (file)
@@ -31,13 +31,14 @@ namespace callui {
 
        Page::Page(RefCountObjBase &rc, const NaviframeSRef &navi,
                        const ExitRequestHandler onExitRequest) :
-               RefCountAware(&rc),
+               Presenter(rc),
                m_navi(navi),
-               m_onExitRequest(onExitRequest),
-               m_isActive(false)
+               m_onExitRequest(onExitRequest)
        {
                UCL_ASSERT(navi, "navi is NULL!");
                UCL_ASSERT(onExitRequest, "onExitRequest is NULL!");
+
+               deactivateBy(m_navi.get());
        }
 
        Page::~Page()
@@ -46,6 +47,9 @@ namespace callui {
 
        Result Page::preparePart2()
        {
+               FAIL_RETURN(Presenter::prepare(*m_navi),
+                               "Presenter::prepare() failed!");
+
                Evas_Object *content = m_item.getContent();
                if (!content) {
                        LOG_RETURN(RES_FAIL, "content is NULL");
@@ -77,7 +81,12 @@ namespace callui {
 
        void Page::dispatchTopPageChanged()
        {
-               m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr);
+               if (!m_navi->isInTransition()) {
+                       m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr);
+               } else {
+                       WLOG("Forcig Transition Finished!");
+                       m_navi->setInTransition(false);
+               }
        }
 
        void Page::onItemDel(Evas_Object *obj, void *eventInfo)
@@ -140,34 +149,18 @@ namespace callui {
                m_onExitRequest(*this);
        }
 
-       void Page::activate()
-       {
-               if (!m_isActive) {
-                       m_isActive = true;
-                       onActivate();
-               }
-       }
-
-       void Page::deactivate()
-       {
-               if (m_isActive) {
-                       m_isActive = false;
-                       onDeactivate();
-               }
-       }
-
        void Page::updateActiveState()
        {
                if (isAtTop()) {
-                       activate();
+                       activateBy(m_navi.get());
                } else {
-                       deactivate();
+                       deactivateBy(m_navi.get());
                }
        }
 
        void Page::onTransitionStarted(Widget &widget, void *eventInfo)
        {
-               deactivate();
+               deactivateBy(m_navi.get());
        }
 
        void Page::onTransitionFinished(Widget &widget, void *eventInfo)
@@ -182,19 +175,11 @@ namespace callui {
 
        void Page::onHWBackKey(Evas_Object *obj, void *eventInfo)
        {
-               if (m_isActive) {
+               if (isActive()) {
                        onBackKey();
                }
        }
 
-       void Page::onActivate()
-       {
-       }
-
-       void Page::onDeactivate()
-       {
-       }
-
        void Page::onBackKey()
        {
                requestExit();
diff --git a/src/presenters/Presenter.cpp b/src/presenters/Presenter.cpp
new file mode 100644 (file)
index 0000000..0dddce7
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * 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 "presenters/Presenter.h"
+
+#include "common.h"
+
+namespace callui { namespace { namespace impl {
+
+       using namespace ucl;
+
+       constexpr SmartEvent ACTIVATE_BY {"callui,activate,by"};
+       constexpr SmartEvent DEACTIVATE_BY {"callui,deactivate,by"};
+}}}
+
+namespace callui {
+
+       using namespace ucl;
+
+       Presenter::Presenter(RefCountObjBase &rc) :
+               RefCountAware(&rc),
+               m_isPrepared(false)
+       {
+       }
+
+       Presenter::~Presenter()
+       {
+       }
+
+       Result Presenter::prepare(ElmWidget &widget)
+       {
+               m_topWidget = asWeak(asWidget(widget.getTopWidget()));
+               if (!m_topWidget) {
+                       LOG_RETURN(RES_FAIL, "m_topWidget is NULL!");
+               }
+
+               addDeactivatorSource(*m_topWidget);
+
+               m_isPrepared = true;
+
+               return RES_OK;
+       }
+
+       void Presenter::addDeactivatorSource(Widget &source)
+       {
+               source.addEventHandler(impl::ACTIVATE_BY,
+                               WEAK_DELEGATE(Presenter::onActivateBySmart, asWeak(*this)));
+               source.addEventHandler(impl::DEACTIVATE_BY,
+                               WEAK_DELEGATE(Presenter::onDeactivateBySmart, asWeak(*this)));
+       }
+
+       void Presenter::addDeactivatorException(void *const deactivator)
+       {
+               const auto pair = m_deactivatorExceptions.insert(deactivator);
+               if (pair.second) {
+                       activateBy(deactivator);
+               }
+       }
+
+       void Presenter::sendActivateBy(Widget &sender, void *const deactivator)
+       {
+               sendDeactivator(sender, impl::ACTIVATE_BY, deactivator);
+       }
+
+       void Presenter::sendDeactivateBy(Widget &sender, void *const deactivator)
+       {
+               sendDeactivator(sender, impl::DEACTIVATE_BY, deactivator);
+       }
+
+       void Presenter::broadcastActivateBy(void *const deactivator)
+       {
+               broadcastDeactivator(impl::ACTIVATE_BY, deactivator);
+       }
+
+       void Presenter::broadcastDeactivateBy(void *const deactivator)
+       {
+               broadcastDeactivator(impl::DEACTIVATE_BY, deactivator);
+       }
+
+       void Presenter::sendDeactivator(Widget &sender,
+                       SmartEvent event, void *deactivator)
+       {
+               sendDeactivatorInfo(sender, event, {deactivator, false});
+       }
+
+       void Presenter::broadcastDeactivator(const SmartEvent event,
+                       void *const deactivator)
+       {
+               if (m_topWidget) {
+                       sendDeactivatorInfo(*m_topWidget, event, {deactivator, true});
+               } else {
+                       ELOG("m_topWidget is NULL!");
+               }
+       }
+
+       void Presenter::sendDeactivatorInfo(Widget &sender,
+                       const SmartEvent event, const DeactivatorInfo &info)
+       {
+               sender.callEvent(event, const_cast<DeactivatorInfo *>(&info));
+       }
+
+       bool Presenter::isActive() const
+       {
+               return isEmpty(m_deactivators);
+       }
+
+       bool Presenter::isDeactivatedBy(void *const deactivator) const
+       {
+               return (m_deactivators.find(deactivator) != m_deactivators.end());
+       }
+
+       void Presenter::activateBy(void *const deactivator)
+       {
+               activateByImpl({deactivator, false});
+       }
+
+       void Presenter::deactivateBy(void *const deactivator)
+       {
+               deactivateByImpl({deactivator, false});
+       }
+
+       void Presenter::activateByImpl(const DeactivatorInfo &info)
+       {
+               const auto count = m_deactivators.erase(info.deactivator);
+               if (m_isPrepared && (count > 0)) {
+                       onActivateBy(info);
+                       if (m_deactivators.size() == 0) {
+                               onActivate();
+                       }
+               }
+       }
+
+       void Presenter::deactivateByImpl(const DeactivatorInfo &info)
+       {
+               if (m_deactivatorExceptions.find(info.deactivator) !=
+                               m_deactivatorExceptions.end()) {
+                       return;
+               }
+               const auto pair = m_deactivators.insert(info.deactivator);
+               if (m_isPrepared && pair.second) {
+                       onDeactivateBy(info);
+                       if (m_deactivators.size() == 1) {
+                               onDeactivate();
+                       }
+               }
+       }
+
+       void Presenter::onActivateBySmart(Widget &widget, void *eventInfo)
+       {
+               activateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
+       }
+
+       void Presenter::onDeactivateBySmart(Widget &widget, void *eventInfo)
+       {
+               deactivateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
+       }
+
+       void Presenter::onActivate()
+       {
+       }
+
+       void Presenter::onDeactivate()
+       {
+       }
+
+       void Presenter::onActivateBy(const DeactivatorInfo &info)
+       {
+       }
+
+       void Presenter::onDeactivateBy(const DeactivatorInfo &info)
+       {
+       }
+}
index 0df33ab2e52d226008d334ba9812ef5148663eca..ec21f450e118b2d1c56e0d52d1b85aece9600fdd 100644 (file)
@@ -32,7 +32,7 @@ namespace ucl {
                        Builder &setEdjeFile(std::string filePath, EdjeGroup group);
                        Builder &setIsOwner(bool value);
                        Builder &setNeedBindToEo(bool value);
-                       LayoutSRef build(Widget &parent) const;
+                       LayoutSRef build(ElmWidget &parent) const;
                private:
                        LayoutTheme m_theme;
                        std::string m_edjeFilePath;
index 73c1d51db615e5348b534e0a344ebb691d5d758b..0cf36f61531edfab3039c424ea1efb15cca13999 100644 (file)
@@ -36,13 +36,14 @@ namespace ucl {
                        Builder();
                        Builder &setStyle(ElmStyle value);
                        Builder &setNeedBindToEo(bool value);
-                       NaviframeSRef build(Widget &parent) const;
+                       NaviframeSRef build(ElmWidget &parent) const;
                private:
                        ElmStyle m_style;
                        bool m_needBindToEo;
                };
 
        public:
+               void setInTransition(bool inTransition);
                bool isInTransition() const;
 
                void setAutoBackBtn(bool value);
@@ -85,11 +86,8 @@ namespace ucl {
 
        private:
                friend class RefCountObj<Naviframe>;
-               friend class NaviItem;
                Naviframe(RefCountObjBase &rc, Evas_Object *eo);
 
-               void startTransition();
-
                void onTransitionFinished(Widget &widget, void *eventInfo);
 
        private:
index 4c56f4adc8c044362ed285ec9486ffba909ec7e4..e8fdc19087cd296c9921dbe1aa106f33f0b863df 100644 (file)
@@ -78,7 +78,7 @@ namespace ucl {
        {
                auto result = elm_naviframe_item_pop(getEo());
                if (getBottomItem()) {
-                       startTransition();
+                       setInTransition(true);
                }
                return result;
        }
@@ -91,7 +91,7 @@ namespace ucl {
                                nullptr, backBtn, moreBtn, content, style.name));
                result.setTitle(title);
                if (result != getBottomItem()) {
-                       startTransition();
+                       setInTransition(true);
                }
                return result;
        }
index efa93ceb3c625943108fd3ea0fb51d26b1411b75..420954ae25494eb4c4daee96c7b783d341f860c2 100644 (file)
@@ -36,13 +36,13 @@ namespace ucl {
                bool isEmpty() const;
 
                template <class ...ARGS>
-               void invoke(ARGS &&...args);
+               void dispatch(ARGS &&...args);
                template <class PREDICATE, class ...ARGS>
-               void invokePred(PREDICATE &&pred, ARGS &&...args);
+               void dispatchPred(PREDICATE &&pred, ARGS &&...args);
 
        private:
                template <class DO_INVOKE, class ...ARGS>
-               void invokeImpl(const DO_INVOKE &doInvoke, ARGS &&...args);
+               void dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args);
 
                void lock();
                void unlock();
index 53e58a231a5f086494b7b1de7e200d386852c243..f0caec0837e4700e2abb95c0d01905307dbfd87d 100644 (file)
@@ -78,9 +78,9 @@ namespace ucl {
 
        template <class DELEGATE>
        template <class ...ARGS>
-       void Event<DELEGATE>::invoke(ARGS &&...args)
+       void Event<DELEGATE>::dispatch(ARGS &&...args)
        {
-               invokeImpl(
+               dispatchImpl(
                        [](const DELEGATE &delegate, ARGS &&...args)
                        {
                                delegate(std::forward<ARGS>(args)...);
@@ -91,9 +91,9 @@ namespace ucl {
 
        template <class DELEGATE>
        template <class PREDICATE, class ...ARGS>
-       void Event<DELEGATE>::invokePred(PREDICATE &&pred, ARGS &&...args)
+       void Event<DELEGATE>::dispatchPred(PREDICATE &&pred, ARGS &&...args)
        {
-               invokeImpl(
+               dispatchImpl(
                        [&pred](const DELEGATE &delegate, ARGS &&...args)
                        {
                                return impl::doInvokePred(std::forward<PREDICATE>(pred),
@@ -104,10 +104,11 @@ namespace ucl {
 
        template <class DELEGATE>
        template <class DO_INVOKE, class ...ARGS>
-       void Event<DELEGATE>::invokeImpl(const DO_INVOKE &doInvoke, ARGS &&...args)
+       void Event<DELEGATE>::dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args)
        {
                lock();
-               for (size_t i = 0; i < m_delegates.size(); ++i) {
+               const auto size = m_delegates.size();
+               for (size_t i = 0; i < size; ++i) {
                        const auto &delegate = m_delegates[i];
                        if (delegate) {
                                if (!doInvoke(delegate, std::forward<ARGS>(args)...)) {
diff --git a/ucl/inc/ucl/misc/SharedObject.h b/ucl/inc/ucl/misc/SharedObject.h
deleted file mode 100644 (file)
index a62fefd..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef __UCL_MISC_SHARED_OBJECT_H__
-#define __UCL_MISC_SHARED_OBJECT_H__
-
-#include "ucl/util/types.h"
-#include "ucl/util/memory.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(SharedObject);
-
-       class SharedObject : public NonCopyable {
-       public:
-               template <class T>
-               SharedRef<T> asShared();
-               template <class T>
-               WeakRef<T> asWeak();
-
-               template <class T>
-               SharedRef<const T> asShared() const;
-               template <class T>
-               WeakRef<const T> asWeak() const;
-
-               SharedObjectSRef asShared();
-               SharedObjectWRef asWeak();
-
-               SharedObjectSCRef asShared() const;
-               SharedObjectWCRef asWeak() const;
-
-       protected:
-               SharedObject(RefCountObjBase *rc);
-               ~SharedObject() = default;
-
-       protected:
-               RefCountObjBase *const m_rc;
-       };
-
-       // Non-member functions //
-
-       template <class T>
-       SharedRef<T> asShared(T *obj);
-       template <class T>
-       WeakRef<T> asWeak(T *obj);
-}
-
-#include "SharedObject.hpp"
-
-#endif // __UCL_MISC_SHARED_OBJECT_H__
diff --git a/ucl/inc/ucl/misc/SharedObject.hpp b/ucl/inc/ucl/misc/SharedObject.hpp
deleted file mode 100644 (file)
index 75a09a2..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-namespace ucl {
-
-       inline SharedObject::SharedObject(RefCountObjBase *const rc) :
-               m_rc(rc)
-       {
-       }
-
-       template <class T>
-       inline SharedRef<T> SharedObject::asShared()
-       {
-               if (!m_rc) {
-                       return {};
-               }
-               return {m_rc, static_cast<T *>(this)};
-       }
-
-       template <class T>
-       inline WeakRef<T> SharedObject::asWeak()
-       {
-               if (!m_rc) {
-                       return {};
-               }
-               return {m_rc, static_cast<T *>(this)};
-       }
-
-       template <class T>
-       inline SharedRef<const T> SharedObject::asShared() const
-       {
-               if (!m_rc) {
-                       return {};
-               }
-               return {m_rc, static_cast<const T *>(this)};
-       }
-
-       template <class T>
-       inline WeakRef<const T> SharedObject::asWeak() const
-       {
-               if (!m_rc) {
-                       return {};
-               }
-               return {m_rc, static_cast<const T *>(this)};
-       }
-
-       inline SharedObjectSRef SharedObject::asShared()
-       {
-               return asShared<SharedObject>();
-       }
-
-       inline SharedObjectWRef SharedObject::asWeak()
-       {
-               return asWeak<SharedObject>();
-       }
-
-       inline SharedObjectSCRef SharedObject::asShared() const
-       {
-               return asShared<SharedObject>();
-       }
-
-       inline SharedObjectWCRef SharedObject::asWeak() const
-       {
-               return asWeak<SharedObject>();
-       }
-
-       // Non-member functions //
-
-       template <class T>
-       inline SharedRef<T> asShared(T *obj)
-       {
-               return (obj ?
-                               obj->asShared<typename std::remove_cv<T>::type>() :
-                               SharedRef<T>());
-       }
-
-       template <class T>
-       inline WeakRef<T> asWeak(T *obj)
-       {
-               return (obj ?
-                               obj->asWeak<typename std::remove_cv<T>::type>() :
-                               WeakRef<T>());
-       }
-}
index a6280cc1d2ad9c4ec34ad7293a00def4f933ed12..e1951bc49a26386ee9701ded03a560ef9a5dd75b 100644 (file)
@@ -27,7 +27,7 @@ namespace ucl {
 
        class Mutex : public NonCopyable {
        public:
-               Mutex();
+               Mutex(bool recursive = false);
                ~Mutex();
                void lock();
                void unlock();
index d152df35e8f1bad33943abe6ca5014e22210eab3..c3b75be3bcea8d09a5c2fbbb27fa998d8d1c34a7 100644 (file)
 
 namespace ucl {
 
-       inline Mutex::Mutex() :
+       inline Mutex::Mutex(const bool recursive) :
                m_mutex()
        {
-               pthread_mutex_init(&m_mutex, NULL);
+               if (recursive) {
+                       pthread_mutexattr_t attr = {};
+                       pthread_mutexattr_init(&attr);
+                       pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+                       pthread_mutex_init(&m_mutex, &attr);
+                       pthread_mutexattr_destroy(&attr);
+               } else {
+                       pthread_mutex_init(&m_mutex, nullptr);
+               }
        }
 
        inline Mutex::~Mutex()
index a643b380ac30bb5f1ef9b71a3b4ea5ca14cbde9c..2e90b24c29970bece2aeae6f497d73de5e316403 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "ucl/appfw/InstanceManagerBase.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
index 3b8994e499f76f0b55744853b7de70ecc956617c..8958aaf401d5300888b2ff80aab12aa7a10c1960 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "ucl/appfw/SysEventProvider.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
@@ -108,6 +108,6 @@ namespace ucl {
 
        void SysEventProvider::dispatch(SysEvent sysEvent)
        {
-               m_event.invoke(sysEvent);
+               m_event.dispatch(sysEvent);
        }
 }
index 49c5e67bec76036b0a3dc77ffe571f7253130eea..4012ecac3be2ceee8ee60ddbe705816a31d59abf 100644 (file)
@@ -19,7 +19,7 @@
 #include <app.h>
 
 #include "ucl/appfw/IInstanceAppControlExt.h"
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
diff --git a/ucl/src/appfw/common.h b/ucl/src/appfw/common.h
new file mode 100644 (file)
index 0000000..b612dfb
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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 __UCL_APPFW_COMMON_H__
+#define __UCL_APPFW_COMMON_H__
+
+#include "../common.h"
+
+#endif // __UCL_APPFW_COMMON_H__
index a87e4acfc83b18760338320d78b07b407270cb8c..c547dce68ba556b6c02e4db0a6b618d7b255a6f2 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "ucl/appfw/helpers.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
index 070a8d6048bde1b67f00116836d5707a4a47d37e..1509fc5a8726a206db29d24dff86d92c765d0e22 100644 (file)
 
 #include "ucl/gui/stdTheme/layout.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
        // Layout::Builder //
 
-       LayoutSRef Layout::Builder::build(Widget &parent) const
+       LayoutSRef Layout::Builder::build(ElmWidget &parent) const
        {
                Evas_Object *const eo = elm_layout_add(parent);
                if (!eo) {
index 052a8ea159215eb8d938f645b161adaba1a65ae4..dd212bfa9add22473914a287485f9c349d5b1641 100644 (file)
@@ -30,7 +30,7 @@ namespace ucl {
                elm_naviframe_item_pop_to(getIt());
 
                if (needStartTransition) {
-                       navi->startTransition();
+                       navi->setInTransition(true);
                }
        }
 
@@ -43,7 +43,7 @@ namespace ucl {
                elm_naviframe_item_promote(getIt());
 
                if (needStartTransition) {
-                       navi->startTransition();
+                       navi->setInTransition(true);
                }
        }
 }
index 1f8a589da9355078648fb8a8cea095123f19cd40..881390c859983ab1d9bef404f94bcc06c9bfafa8 100644 (file)
 
 #include "ucl/gui/Naviframe.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
        // Naviframe::Builder //
 
-       NaviframeSRef Naviframe::Builder::build(Widget &parent) const
+       NaviframeSRef Naviframe::Builder::build(ElmWidget &parent) const
        {
                Evas_Object *const eo = elm_naviframe_add(parent);
                if (!eo) {
@@ -55,11 +55,15 @@ namespace ucl {
                                Naviframe::onTransitionFinished, asWeak(*this)));
        }
 
-       void Naviframe::startTransition()
+       void Naviframe::setInTransition(const bool inTransition)
        {
-               if (!m_isInTransition) {
-                       m_isInTransition = true;
-                       callEvent(NAVI_TRANSITION_STARTED);
+               if (inTransition != m_isInTransition) {
+                       m_isInTransition = inTransition;
+                       if (inTransition) {
+                               callEvent(NAVI_TRANSITION_STARTED);
+                       } else {
+                               callEvent(NAVI_TRANSITION_FINISHED);
+                       }
                }
        }
 
index 5012a6a8127225e2fd7ff8f5da87844b46a5dc6d..5129f18be13d71212d6a650504103512f7406c4e 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "ucl/gui/Widget.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl { namespace { namespace impl {
 
index e63a0e7fc2b0860808bff536c236024fe13d3ae1..3f74e9ec29b8526e734ba698a000b2820a670e6e 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "ucl/gui/Window.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
diff --git a/ucl/src/gui/common.h b/ucl/src/gui/common.h
new file mode 100644 (file)
index 0000000..6b543d3
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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 __UCL_GUI_COMMON_H__
+#define __UCL_GUI_COMMON_H__
+
+#include "../common.h"
+
+#endif // __UCL_GUI_COMMON_H__
index 6513076acf8bb37935a9607b16fce24d15000f2f..3859bc5f4e37edfed2a3372bd6aba65d086c3903 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "ucl/misc/Variant.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace ucl {
 
diff --git a/ucl/src/misc/common.h b/ucl/src/misc/common.h
new file mode 100644 (file)
index 0000000..372ad4d
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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 __UCL_MISC_COMMON_H__
+#define __UCL_MISC_COMMON_H__
+
+#include "../common.h"
+
+#endif // __UCL_MISC_COMMON_H__