TizenRefApp-8708 [Gallery] Implement Not supported format feature for 60/134460/2
authorIgor Nazarov <i.nazarov@samsung.com>
Fri, 16 Jun 2017 15:49:50 +0000 (18:49 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Fri, 16 Jun 2017 16:03:40 +0000 (19:03 +0300)
Video Player

- "Unsupported format." dialog was added into VidePlayerPage;
- Implemented Dialog base class;
- AlertDialog refactored to inherit from Dialog class;
- Implemented AlertDialog::Type::OK;
- Simplified Presenter protected interface;
- UCL: added IRefCountObj:getObjPtr() and implementation.

Change-Id: Ie26976109cba31b4201c686297630d48cf36d248

24 files changed:
inc/gallery/presenters/AlertDialog.h
inc/gallery/presenters/Dialog.h [new file with mode: 0644]
inc/gallery/presenters/Dialog.hpp [new file with mode: 0644]
inc/gallery/presenters/Presenter.h
inc/gallery/presenters/PreviewPage.h
inc/gallery/presenters/VideoPlayerPage.h
inc/gallery/resources.h
src/helpers.h
src/helpers.hpp
src/presenters/AlertDialog.cpp
src/presenters/Dialog.cpp [new file with mode: 0644]
src/presenters/Instance.cpp
src/presenters/MoreOptionsPresenter.cpp
src/presenters/Presenter.cpp
src/presenters/PreviewPage.cpp
src/presenters/ProcessingPresenter.cpp
src/presenters/SelectModePresenter.cpp
src/presenters/VideoPlayerPage.cpp
src/resources.cpp
ucl/inc/ucl/util/memory/IRefCountObj.h
ucl/inc/ucl/util/memory/RefCountObj.h
ucl/inc/ucl/util/memory/RefCountObj.hpp
ucl/inc/ucl/util/memory/ReffedObj.h
ucl/inc/ucl/util/memory/ReffedObj.hpp

index ce508ff300601a9da0fb257212c8843ef71da549..1842609975317d9b272a3365091c6af1350918d4 100644 (file)
 #ifndef __GALLERY_PRESENTERS_ALERT_DIALOG_H__
 #define __GALLERY_PRESENTERS_ALERT_DIALOG_H__
 
-#include "ucl/gui/StyledWidget.h"
 #include "ucl/gui/Layout.h"
 
-#include "Presenter.h"
+#include "Dialog.h"
 
 namespace gallery {
 
        UCL_DECLARE_REF_ALIASES(AlertDialog);
 
-       class AlertDialog final : public Presenter,
-                       public ucl::IDisposable {
+       class AlertDialog final : public Dialog {
        public:
                enum class Type {
+                       OK,
                        OK_CANCEL
                };
 
-               enum Event {
-                       EVENT_CANCEL,
-                       EVENT_OK,
-                       EVENT_BACK
+               enum class Event {
+                       CANCEL,
+                       OK,
+                       BACK
                };
 
                using EventHandler = ucl::WeakDelegate<
-                               bool(AlertDialog &dialog, int event)>;
+                               bool(AlertDialog &dialog, Event event)>;
 
                class Builder {
                public:
@@ -57,23 +56,18 @@ namespace gallery {
                        EventHandler m_handler;
                };
 
-       public:
-               void dismiss();
-
-               // ucl::IDisposable //
-
-               virtual void dispose() final override;
-               virtual bool isDisposed() const final override;
-
        private:
                friend class ucl::ReffedObj<AlertDialog>;
                AlertDialog(ucl::IRefCountObj &rc,
                                const EventHandler &handler);
-               virtual ~AlertDialog();
+               virtual ~AlertDialog() = default;
 
                ucl::Result prepare(ucl::ElmWidget &parent, Type type);
-               ucl::Result createPopup(ucl::ElmWidget &parent, ucl::ElmStyle style);
+
+               ucl::Result doPrepare(Type type);
                ucl::Result createLayout(ucl::LayoutTheme theme);
+               ucl::Result prepareOkPopup();
+               ucl::Result prepareOkCancelPopup();
                ucl::Result createButton(Event event, ucl::EdjePart part,
                                ucl::ElmStyle btnStyle, ucl::LayoutTheme iconTheme,
                                const ucl::TString &text = nullptr);
@@ -84,16 +78,15 @@ namespace gallery {
                void handleEvent(Event event);
                bool dispatchEvent(Event event);
 
-               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
-               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
-
                void onBtnClick(ucl::Widget &widget, void *eventInfo);
 
+               // Dialog //
+
+               virtual void onBackKey() final override;
+
        private:
                const EventHandler m_handler;
-               ucl::StyledWidgetSRef m_popup;
                ucl::LayoutWRef m_layout;
-               bool m_isDismissed;
        };
 }
 
diff --git a/inc/gallery/presenters/Dialog.h b/inc/gallery/presenters/Dialog.h
new file mode 100644 (file)
index 0000000..9aa6246
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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 __GALLERY_PRESENTERS_DIALOG_H__
+#define __GALLERY_PRESENTERS_DIALOG_H__
+
+#include "ucl/gui/StyledWidget.h"
+
+#include "Presenter.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(Dialog);
+
+       class Dialog : public Presenter,
+                       public ucl::IDisposable {
+       public:
+               void open();
+               void dismiss();
+
+               // ucl::IDisposable //
+
+               virtual void dispose() final override;
+               virtual bool isDisposed() const final override;
+
+       protected:
+               enum class PopupType {
+                       NORMAL,
+                       CONTEXT
+               };
+
+       protected:
+               Dialog(ucl::IRefCountObj &rc);
+               virtual ~Dialog() = default;
+
+               template <class ON_PREPARE>
+               ucl::Result prepare(ucl::ElmWidget &parent, PopupType popupType,
+                               ON_PREPARE &&onPrepare);
+
+               virtual void onBackKey();
+
+       private:
+               ucl::Result createPopup(ucl::ElmWidget &parent, PopupType popupType);
+
+               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
+               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
+
+       protected:
+               ucl::StyledWidgetSRef m_popup;
+               bool m_isDismissed;
+       };
+}
+
+#include "Dialog.hpp"
+
+#endif // __GALLERY_PRESENTERS_DIALOG_H__
diff --git a/inc/gallery/presenters/Dialog.hpp b/inc/gallery/presenters/Dialog.hpp
new file mode 100644 (file)
index 0000000..8542874
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 "ucl/util/logging.h"
+
+namespace gallery {
+
+       template <class ON_PREPARE>
+       inline ucl::Result Dialog::prepare(ucl::ElmWidget &parent,
+                       const PopupType popupType, ON_PREPARE &&onPrepare)
+       {
+               UCL_FAIL_RETURN(Presenter::prepare(parent),
+                               "Presenter::prepare() failed!");
+
+               UCL_FAIL_RETURN(createPopup(parent, popupType),
+                               "createPopup() failed!");
+
+               UCL_FAIL_RETURN(onPrepare(), "onPrepare() failed!");
+
+               m_rc->ref();
+
+               return ucl::RES_OK;
+       }
+}
index 1142452ce2a045e29a2785d3a4cd2801bff19fd2..af8a367b01ce0446000120e494f6a831fea4de0b 100644 (file)
@@ -30,20 +30,20 @@ namespace gallery {
        class Presenter : public ucl::RefCountAware {
        public:
                struct DeactivatorInfo {
-                       void *deactivator;
+                       const void *deactivator;
                        bool isBroadcast;
                };
 
        public:
                bool isActive() const;
-               bool isDeactivatedBy(void *deactivator) const;
+               bool isDeactivatedBy(const void *deactivator) const;
 
-               void activateBy(void *deactivator);
-               void deactivateBy(void *deactivator);
+               void activateBy(const void *deactivator);
+               void deactivateBy(const void *deactivator);
 
        protected:
                Presenter(ucl::IRefCountObj &rc);
-               virtual ~Presenter();
+               virtual ~Presenter() = default;
 
                ucl::Result prepare(ucl::ElmWidget &widget);
 
@@ -51,13 +51,13 @@ namespace gallery {
                bool isWindowReady() const;
 
                void addDeactivatorSource(ucl::Widget &source);
-               void addDeactivatorException(void *deactivator);
+               void addDeactivatorException(const void *deactivator);
 
-               void sendActivateBy(ucl::Widget &sender, void *deactivator);
-               void sendDeactivateBy(ucl::Widget &sender, void *deactivator);
+               void sendActivate(ucl::Widget &sender);
+               void sendDeactivate(ucl::Widget &sender);
 
-               void broadcastActivateBy(void *deactivator);
-               void broadcastDeactivateBy(void *deactivator);
+               void broadcastActivate();
+               void broadcastDeactivate();
 
                virtual void onActivate();
                virtual void onDeactivate();
@@ -66,8 +66,9 @@ namespace gallery {
 
        private:
                void sendDeactivator(ucl::Widget &sender,
-                               ucl::SmartEvent event, void *deactivator);
-               void broadcastDeactivator(ucl::SmartEvent event, void *deactivator);
+                               ucl::SmartEvent event, const void *deactivator);
+               void broadcastDeactivator(ucl::SmartEvent event,
+                               const void *deactivator);
 
                void sendDeactivatorInfo(ucl::Widget &sender, ucl::SmartEvent event,
                                const DeactivatorInfo &info);
@@ -79,8 +80,8 @@ namespace gallery {
                void onDeactivateBySmart(ucl::Widget &widget, void *eventInfo);
 
        private:
-               std::unordered_set<void *> m_deactivatorExceptions;
-               std::unordered_set<void *> m_deactivators;
+               std::unordered_set<const void *> m_deactivatorExceptions;
+               std::unordered_set<const void *> m_deactivators;
                ucl::WindowSRef m_window;
                bool m_isPrepared;
        };
index c499db6ba55568cdcfced3345d13bad5bf4eca74..63c546be8d89ef8faa3eb6639bfe6f105831fa31 100644 (file)
@@ -88,7 +88,7 @@ namespace gallery {
 
                void onPageExitRequest(Page &page);
 
-               bool onAlertEvent(AlertDialog &dialog, int event);
+               bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
                void onJobComplete();
 
                Elm_Interface_Atspi_Accessible *onAtspiHighlight(
@@ -137,7 +137,7 @@ namespace gallery {
                PageContentSRef m_content;
                MoreOptionsPresenterSRef m_more;
                SelectModePresenterSRef m_smp;
-               AlertDialogWRef m_alert;
+               DialogWRef m_alert;
                ProcessingPresenterSRef m_processing;
                AtspiHighlightHelperSRef m_atspiHelper;
 
index 9a61a4e65d618f7411f930e57fd11716a9c47070..61df6f6b54ab18e0dfd9aa9a6475688018cf9f6e 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "gallery/view/TouchParser.h"
 
+#include "AlertDialog.h"
+
 namespace gallery {
 
        UCL_DECLARE_REF_ALIASES(VideoPlayerPage);
@@ -67,6 +69,8 @@ namespace gallery {
                ucl::StyledWidgetSRef createButton(ucl::ElmStyle style,
                                ucl::EdjePart part, const ucl::WidgetEventHandler &handler);
 
+               void createErrorDialog();
+
                bool resetTimer(Ecore_Timer *&timer, double timeout, Ecore_Task_Cb func);
                void stopTimer(Ecore_Timer *&timer);
 
@@ -89,6 +93,8 @@ namespace gallery {
 
                ucl::Result launchVolumeSettings();
 
+               bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
+
                void onMediaDeviceStateChanged();
                void onMediaVolumeChanged();
 
@@ -122,6 +128,7 @@ namespace gallery {
                ucl::WidgetSRef m_image;
                ucl::StyledWidgetSRef m_volumeMuteBtn;
                TouchParserSRef m_touchParser;
+               DialogWRef m_alert;
                player_h m_player;
                int m_videoDuration;
                Ecore_Timer *m_autoStartTimer;
index 9403a67ad77b3032b0123bd32dd35d15fb9efb18..6a6f372d126ba958f40f5aa14ea75a5a8d075c43 100644 (file)
@@ -48,6 +48,8 @@ namespace gallery {
        extern const ucl::TString STR_SAVE_TO_GEAR;
        extern const ucl::TString STR_SAVING;
        extern const ucl::TString STR_SAVED;
+       extern const ucl::TString STR_OK_CAPS;
+       extern const ucl::TString STR_UNSUPPORTED_FORMAT;
 }
 
 #endif // __GALLERY_RESOURCES_H__
index 666ebc6ea44d3d15289c69ce1727c1c1daf6cf5c..5dd0d635a5583c384f7f4c8e64434ddf42a9c763 100644 (file)
@@ -29,6 +29,9 @@ namespace gallery { namespace util {
 
        template <class FUNC, class ...ARGS>
        ucl::Result call(FUNC &&func, ARGS &&...args);
+
+       template <class FUNC, class TO_RESULT, class ...ARGS>
+       ucl::Result callEx(FUNC &&func, TO_RESULT &&toResult, ARGS &&...args);
 }}
 
 #include "helpers.hpp"
index 1ed8f2bb457aba51468cbc4e6984798ee6d87e2c..5bca4c7b570eb3b377c8fd03ca671be5edab1899 100644 (file)
@@ -84,4 +84,12 @@ namespace gallery { namespace util {
                }
                return ucl::RES_OK;
        }
+
+       template <class FUNC, class TO_RESULT, class ...ARGS>
+       ucl::Result callEx(FUNC &&func, TO_RESULT &&toResult, ARGS &&...args)
+       {
+               const int ret = func(std::forward<ARGS>(args)...);
+               UCL_FAIL_RETURN(toResult(ret), "func() failed: %d", ret);
+               return ucl::RES_OK;
+       }
 }}
index da1ebe13b18b1b013e6ae252722426c46b8dbff3..26d9bcdaeb8806706aa4ddbbd5d662f39d022539 100644 (file)
@@ -30,9 +30,12 @@ namespace gallery { namespace { namespace impl {
 
        constexpr ElmStyle LEFT_POPUP_BTN_STYLE {"popup/circle/left"};
        constexpr ElmStyle RIGHT_POPUP_BTN_STYLE {"popup/circle/right"};
+       constexpr ElmStyle BOTTOM_BTN_STYLE {"bottom"};
 
        constexpr LayoutTheme LAYOUT_POPUP_2BUTTONS
                        {"layout", "popup", "content/circle/buttons2"};
+       constexpr LayoutTheme LAYOUT_POPUP_1BUTTON
+                       {"layout", "popup", "content/circle"};
 
        void *asData(const AlertDialog::Event event)
        {
@@ -60,7 +63,7 @@ namespace gallery {
        // AlertDialog::Builder //
 
        AlertDialog::Builder::Builder() :
-               m_type(Type::OK_CANCEL)
+               m_type(Type::OK)
        {
        }
 
@@ -102,6 +105,7 @@ namespace gallery {
 
                result->setTitle(m_title);
                result->setText(m_text);
+               result->open();
 
                return result;
        }
@@ -110,60 +114,34 @@ namespace gallery {
 
        AlertDialog::AlertDialog(IRefCountObj &rc,
                        const EventHandler &handler) :
-               Presenter(rc),
-               m_handler(handler),
-               m_isDismissed(false)
-       {
-       }
-
-       AlertDialog::~AlertDialog()
+               Dialog(rc),
+               m_handler(handler)
        {
        }
 
        Result AlertDialog::prepare(ElmWidget &parent, const Type type)
        {
-               FAIL_RETURN(Presenter::prepare(parent),
-                               "Presenter::prepare() failed!");
-
-               FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE),
-                               "createPopup() failed!");
-
-               FAIL_RETURN(createLayout(impl::LAYOUT_POPUP_2BUTTONS),
-                               "createLayout() failed!");
-
-               FAIL_RETURN(createButton(EVENT_CANCEL, impl::PART_BUTTON1,
-                               impl::LEFT_POPUP_BTN_STYLE, getImageTheme(ICON_POPUP_CANCEL)),
-                               "createButton() failed!");
-
-               FAIL_RETURN(createButton(EVENT_OK, impl::PART_BUTTON2,
-                               impl::RIGHT_POPUP_BTN_STYLE, getImageTheme(ICON_POPUP_OK)),
-                               "createButton() failed!");
-
-               m_rc->ref();
-
-               addDeactivatorException(this);
-               broadcastDeactivateBy(this);
+               FAIL_RETURN(Dialog::prepare(parent, PopupType::NORMAL,
+                               [this, type]() { return doPrepare(type); }),
+                               "Dialog::prepare() failed!");
 
                return RES_OK;
        }
 
-       Result AlertDialog::createPopup(ElmWidget &parent, const ElmStyle style)
+       Result AlertDialog::doPrepare(const Type type)
        {
-               Evas_Object *const popupEo = elm_popup_add(parent);
-               if (!popupEo) {
-                       LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
-               }
+               m_popup->setStyle(impl::POPUP_STYLE);
 
-               m_popup = makeShared<StyledWidget>(popupEo, true);
-               m_popup->setStyle(style);
+               const auto layoutTheme = ((type == Type::OK) ?
+                               impl::LAYOUT_POPUP_1BUTTON :
+                               impl::LAYOUT_POPUP_2BUTTONS);
+               FAIL_RETURN(createLayout(layoutTheme), "createLayout() failed!");
 
-               show(*m_popup);
-
-               m_popup->addEventHandler(POPUP_DISMISSED, WEAK_DELEGATE(
-                               AlertDialog::onPopupDismissed, asWeak(*this)));
-
-               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
-                               CALLBACK_A(AlertDialog::onPopupHWBackKey), this);
+               if (type == Type::OK) {
+                       FAIL_RETURN(prepareOkPopup(), "prepareOkPopup() failed!");
+               } else {
+                       FAIL_RETURN(prepareOkCancelPopup(), "prepareOkPopup() failed!");
+               }
 
                return RES_OK;
        }
@@ -184,6 +162,28 @@ namespace gallery {
                return RES_OK;
        }
 
+       Result AlertDialog::prepareOkPopup()
+       {
+               FAIL_RETURN(createButton(Event::OK, impl::PART_BUTTON1,
+                               impl::BOTTOM_BTN_STYLE, nullptr, STR_OK_CAPS),
+                               "createButton() failed!");
+
+               return RES_OK;
+       }
+
+       Result AlertDialog::prepareOkCancelPopup()
+       {
+               FAIL_RETURN(createButton(Event::CANCEL, impl::PART_BUTTON1,
+                               impl::LEFT_POPUP_BTN_STYLE, getImageTheme(ICON_POPUP_CANCEL)),
+                               "createButton() failed!");
+
+               FAIL_RETURN(createButton(Event::OK, impl::PART_BUTTON2,
+                               impl::RIGHT_POPUP_BTN_STYLE, getImageTheme(ICON_POPUP_OK)),
+                               "createButton() failed!");
+
+               return RES_OK;
+       }
+
        Result AlertDialog::createButton(const Event event,
                        const EdjePart part, const ElmStyle btnStyle,
                        const LayoutTheme iconTheme, const TString &text)
@@ -229,33 +229,6 @@ namespace gallery {
                }
        }
 
-       void AlertDialog::dismiss()
-       {
-               if (m_popup && !m_isDismissed) {
-                       m_isDismissed = true;
-                       deactivateBy(m_popup.get());
-                       elm_popup_dismiss(*m_popup);
-               }
-       }
-
-       void AlertDialog::dispose()
-       {
-               if (m_popup) {
-                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
-                                       CALLBACK_A(AlertDialog::onPopupHWBackKey));
-
-                       deactivateBy(m_popup.get());
-                       broadcastActivateBy(this);
-                       m_popup.reset();
-                       m_rc->unref();
-               }
-       }
-
-       bool AlertDialog::isDisposed() const
-       {
-               return !!m_popup;
-       }
-
        void AlertDialog::handleEvent(const Event event)
        {
                if (dispatchEvent(event)) {
@@ -272,22 +245,15 @@ namespace gallery {
                return m_handler(*this, event);
        }
 
-       void AlertDialog::onPopupDismissed(Widget &widget, void *eventInfo)
-       {
-               dispose();
-       }
-
-       void AlertDialog::onPopupHWBackKey(Evas_Object *obj, void *eventInfo)
+       void AlertDialog::onBtnClick(Widget &widget, void *eventInfo)
        {
                if (isActive()) {
-                       handleEvent(EVENT_BACK);
+                       handleEvent(impl::getEvent(widget));
                }
        }
 
-       void AlertDialog::onBtnClick(Widget &widget, void *eventInfo)
+       void AlertDialog::onBackKey()
        {
-               if (isActive()) {
-                       handleEvent(impl::getEvent(widget));
-               }
+               handleEvent(Event::BACK);
        }
 }
diff --git a/src/presenters/Dialog.cpp b/src/presenters/Dialog.cpp
new file mode 100644 (file)
index 0000000..3f16630
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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 "gallery/presenters/Dialog.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       Dialog::Dialog(IRefCountObj &rc) :
+               Presenter(rc),
+               m_isDismissed(false)
+       {
+       }
+
+       Result Dialog::createPopup(ElmWidget &parent, const PopupType popupType)
+       {
+               Evas_Object *const popupEo = ((popupType == PopupType::NORMAL) ?
+                               elm_popup_add(parent) : elm_ctxpopup_add(parent));
+               if (!popupEo) {
+                       LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
+               }
+
+               m_popup = makeShared<StyledWidget>(popupEo, true);
+
+               m_popup->addEventHandler(POPUP_DISMISSED, WEAK_DELEGATE(
+                               Dialog::onPopupDismissed, asWeak(*this)));
+
+               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
+                               CALLBACK_A(Dialog::onPopupHWBackKey), this);
+
+               return RES_OK;
+       }
+
+       void Dialog::open()
+       {
+               if (m_popup && !m_isDismissed) {
+                       show(*m_popup);
+                       broadcastDeactivate();
+               }
+       }
+
+       void Dialog::dismiss()
+       {
+               if (m_popup && !m_isDismissed) {
+                       m_isDismissed = true;
+                       deactivateBy(m_popup.get());
+                       elm_popup_dismiss(*m_popup);
+               }
+       }
+
+       void Dialog::dispose()
+       {
+               if (m_popup) {
+                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
+                                       CALLBACK_A(Dialog::onPopupHWBackKey));
+
+                       deactivateBy(m_popup.get());
+                       m_popup.reset();
+                       m_rc->unref();
+
+                       broadcastActivate();
+               }
+       }
+
+       bool Dialog::isDisposed() const
+       {
+               return !!m_popup;
+       }
+
+       void Dialog::onPopupDismissed(Widget &widget, void *eventInfo)
+       {
+               dispose();
+       }
+
+       void Dialog::onPopupHWBackKey(Evas_Object *obj, void *eventInfo)
+       {
+               if (isActive()) {
+                       onBackKey();
+               }
+       }
+
+       void Dialog::onBackKey()
+       {
+               dismiss();
+       }
+}
index 2824d4e8d41f8a80af663bc2361aac890058a563..4c0fa5389648dce57c58fc03db3fbbfee5d701ee 100644 (file)
@@ -200,6 +200,10 @@ namespace gallery {
                        break;
                }
 
+               if (!m_page) {
+                       LOG_RETURN(RES_FAIL, "m_page is NULL");
+               }
+
                return RES_OK;
        }
 
index 15492dc7f4e6ebb16387b550e5ecde6cf063d25e..260fa30500ee8a1c8c85c4d6914d9aedfb6940c1 100644 (file)
@@ -112,7 +112,7 @@ namespace gallery {
        {
                stopTimer();
                if (m_widget) {
-                       sendActivateBy(*m_widget, this);
+                       sendActivate(*m_widget);
                }
        }
 
@@ -142,7 +142,6 @@ namespace gallery {
                m_widget->addEventHandler(impl::MORE_ITEM_SELECTED, WEAK_DELEGATE(
                                MoreOptionsPresenter::onItemSelected, asWeak(*this)));
 
-               addDeactivatorException(this);
                deactivateBy(m_widget.get());
 
                return RES_OK;
@@ -207,7 +206,7 @@ namespace gallery {
        void MoreOptionsPresenter::onOpened(Widget &widget, void *eventInfo)
        {
                stopTimer();
-               sendDeactivateBy(*m_widget, this);
+               sendDeactivate(*m_widget);
                activateBy(m_widget.get());
                if (const auto listener = m_listener.lock()) {
                        listener->onMoreOptionsOpened(*this);
@@ -221,7 +220,7 @@ namespace gallery {
        {
                stopTimer();
                deactivateBy(m_widget.get());
-               sendActivateBy(*m_widget, this);
+               sendActivate(*m_widget);
                if (const auto listener = m_listener.lock()) {
                        listener->onMoreOptionsClosed(*this);
                }
index dcbd7d9575b6d3708649a2306a35f620678826f3..7906044d85032caec8c58a129ba41d7f39f1c8c0 100644 (file)
@@ -34,10 +34,6 @@ namespace gallery {
        {
        }
 
-       Presenter::~Presenter()
-       {
-       }
-
        Result Presenter::prepare(ElmWidget &widget)
        {
                m_window = asShared(widget.getWindow());
@@ -46,6 +42,7 @@ namespace gallery {
                }
 
                addDeactivatorSource(*m_window);
+               addDeactivatorException(m_rc->getObjPtr());
 
                m_isPrepared = true;
 
@@ -71,7 +68,7 @@ namespace gallery {
                                WEAK_DELEGATE(Presenter::onDeactivateBySmart, asWeak(*this)));
        }
 
-       void Presenter::addDeactivatorException(void *const deactivator)
+       void Presenter::addDeactivatorException(const void *const deactivator)
        {
                const auto pair = m_deactivatorExceptions.insert(deactivator);
                if (pair.second) {
@@ -79,34 +76,34 @@ namespace gallery {
                }
        }
 
-       void Presenter::sendActivateBy(Widget &sender, void *const deactivator)
+       void Presenter::sendActivate(Widget &sender)
        {
-               sendDeactivator(sender, impl::ACTIVATE_BY, deactivator);
+               sendDeactivator(sender, impl::ACTIVATE_BY, m_rc->getObjPtr());
        }
 
-       void Presenter::sendDeactivateBy(Widget &sender, void *const deactivator)
+       void Presenter::sendDeactivate(Widget &sender)
        {
-               sendDeactivator(sender, impl::DEACTIVATE_BY, deactivator);
+               sendDeactivator(sender, impl::DEACTIVATE_BY, m_rc->getObjPtr());
        }
 
-       void Presenter::broadcastActivateBy(void *const deactivator)
+       void Presenter::broadcastActivate()
        {
-               broadcastDeactivator(impl::ACTIVATE_BY, deactivator);
+               broadcastDeactivator(impl::ACTIVATE_BY, m_rc->getObjPtr());
        }
 
-       void Presenter::broadcastDeactivateBy(void *const deactivator)
+       void Presenter::broadcastDeactivate()
        {
-               broadcastDeactivator(impl::DEACTIVATE_BY, deactivator);
+               broadcastDeactivator(impl::DEACTIVATE_BY, m_rc->getObjPtr());
        }
 
        void Presenter::sendDeactivator(Widget &sender,
-                       SmartEvent event, void *deactivator)
+                       SmartEvent event, const void *deactivator)
        {
                sendDeactivatorInfo(sender, event, {deactivator, false});
        }
 
        void Presenter::broadcastDeactivator(const SmartEvent event,
-                       void *const deactivator)
+                       const void *const deactivator)
        {
                sendDeactivatorInfo(*m_window, event, {deactivator, true});
        }
@@ -122,17 +119,17 @@ namespace gallery {
                return isEmpty(m_deactivators);
        }
 
-       bool Presenter::isDeactivatedBy(void *const deactivator) const
+       bool Presenter::isDeactivatedBy(const void *const deactivator) const
        {
                return (m_deactivators.find(deactivator) != m_deactivators.end());
        }
 
-       void Presenter::activateBy(void *const deactivator)
+       void Presenter::activateBy(const void *const deactivator)
        {
                activateByImpl({deactivator, false});
        }
 
-       void Presenter::deactivateBy(void *const deactivator)
+       void Presenter::deactivateBy(const void *const deactivator)
        {
                deactivateByImpl({deactivator, false});
        }
index b91c7fe6cfd9ce715cca0c3c57d81864d9a86071..d21fb77af6d7c0b9536b2e663131c2ec7341fbe8 100644 (file)
@@ -590,9 +590,10 @@ namespace gallery {
                                build(getNaviframe());
        }
 
-       bool PreviewPage::onAlertEvent(AlertDialog &dialog, int event)
+       bool PreviewPage::onAlertEvent(AlertDialog &dialog,
+                       AlertDialog::Event event)
        {
-               if (event != AlertDialog::EVENT_OK) {
+               if (event != AlertDialog::Event::OK) {
                        return true;
                }
 
index 63bf0cd2bb301985d2a1a9f04f0b76853199d936..619f122d67279caebd2d0b88c006640485ad47c1 100644 (file)
@@ -127,8 +127,7 @@ namespace gallery {
                        }
                }
 
-               addDeactivatorException(this);
-               broadcastDeactivateBy(this);
+               broadcastDeactivate();
 
                return RES_OK;
        }
@@ -275,7 +274,7 @@ namespace gallery {
                                        CALLBACK_A(ProcessingPresenter::onPopupHWBackKey));
 
                        deactivateBy(m_popup.get());
-                       broadcastActivateBy(this);
+                       broadcastActivate();
                        m_popup.reset();
                        if (m_isComplete) {
                                m_rc->unref();
index c3e0c9c91fa110fe86b0c80c755d51d02ff83ef5..0c0e8f152fc9a11b54a87e032f6b08715c597ddb 100644 (file)
@@ -115,8 +115,6 @@ namespace gallery {
                                        SelectModePresenter::onRotary), this);
                }
 
-               addDeactivatorException(this);
-
                return RES_OK;
        }
 
@@ -277,7 +275,7 @@ namespace gallery {
                eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
                                CALLBACK_A(SelectModePresenter::onPopupHWBackKey), this);
 
-               broadcastDeactivateBy(this);
+               broadcastDeactivate();
        }
 
        void SelectModePresenter::movePopup()
@@ -310,7 +308,7 @@ namespace gallery {
 
                        m_popup.reset();
 
-                       broadcastActivateBy(this);
+                       broadcastActivate();
                }
        }
 
index de3dddbd5200334fa223d3d60cce1d4c2e08e19b..cc0bf227863eccf85334f01f8061fb712ddc47bc 100644 (file)
@@ -153,6 +153,10 @@ namespace gallery {
 
        VideoPlayerPage::~VideoPlayerPage()
        {
+               if (const auto alert = m_alert.lock()) {
+                       alert->dispose();
+               }
+
                if (m_soundMgr) {
                        m_soundMgr->delMediaDeviceStateChangeHandler(WEAK_DELEGATE(
                                        VideoPlayerPage::onMediaDeviceStateChanged, asWeak(*this)));
@@ -182,8 +186,6 @@ namespace gallery {
 
        Result VideoPlayerPage::prepare()
        {
-               FAIL_LOG(prepareSoundManager(), "prepareSoundManager() failed!");
-
                m_content = Layout::Builder().
                                setTheme(impl::LAYOUT_VIDEO_PLAYER).
                                setIsOwner(true).
@@ -200,7 +202,15 @@ namespace gallery {
                        "Page::prepare() failed!");
 
                createImage();
-               FAIL_RETURN(preparePlayer(), "preparePlayer() failed!");
+
+               const Result result = preparePlayer();
+               if (result == RES_NOT_SUPPORTED) {
+                       createErrorDialog();
+                       return RES_OK;
+               }
+               FAIL_RETURN(result, "preparePlayer() failed!");
+
+               FAIL_LOG(prepareSoundManager(), "prepareSoundManager() failed!");
 
                createControls();
                updatePlayTimeText();
@@ -265,8 +275,22 @@ namespace gallery {
                                m_media->getFilePath().c_str()),
                                "player_set_uri() failed!");
 
-               FAIL_RETURN(util::call(player_prepare, m_player),
-                               "player_prepare() failed!");
+               FAIL_RETURN(util::callEx(player_prepare,
+                       [](int ret)
+                       {
+                               switch (ret) {
+                               case PLAYER_ERROR_NONE:
+                                       return RES_OK;
+                               case PLAYER_ERROR_NOT_SUPPORTED_FILE:
+                               case PLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC:
+                               case PLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC:
+                                       return RES_NOT_SUPPORTED;
+                               default:
+                                       return RES_FAIL;
+                               }
+                       },
+                       m_player),
+                       "player_prepare() failed!");
 
                FAIL_RETURN(util::getNz(player_get_duration, m_videoDuration, m_player),
                                "player_get_duration() failed!");
@@ -326,6 +350,23 @@ namespace gallery {
                return btn;
        }
 
+       void VideoPlayerPage::createErrorDialog()
+       {
+               m_alert = AlertDialog::Builder().
+                               setType(AlertDialog::Type::OK).
+                               setText(STR_UNSUPPORTED_FORMAT).
+                               setHandler(WEAK_DELEGATE(
+                                               VideoPlayerPage::onAlertEvent, asWeak(*this))).
+                               build(getNaviframe());
+       }
+
+       bool VideoPlayerPage::onAlertEvent(AlertDialog &dialog,
+                       AlertDialog::Event event)
+       {
+               requestExit();
+               return true;
+       }
+
        bool VideoPlayerPage::resetTimer(Ecore_Timer *&timer,
                        const double timeout, Ecore_Task_Cb func)
        {
index f685c91d32be4ca64ae456f94446ec0863bc8209..256ccef439a7148922913a55436a566b55076e31 100644 (file)
@@ -36,4 +36,6 @@ namespace gallery {
        const TString STR_SAVE_TO_GEAR {"Save to Gear"};
        const TString STR_SAVING {"Saving..."};
        const TString STR_SAVED {"Saved."};
+       const TString STR_OK_CAPS {"OK"};
+       const TString STR_UNSUPPORTED_FORMAT {"Unsupported<br>format."};
 }
index 567e12c6a77e3839de077d908be760370f44f011..c2397d44a9a0ce7547dd107018f58630df9d45f0 100644 (file)
@@ -29,6 +29,7 @@ namespace ucl {
                virtual void refWeak() noexcept = 0;
                virtual void unrefWeak() noexcept = 0;
                virtual unsigned getUseCount() const noexcept = 0;
+               virtual const void *getObjPtr() const noexcept = 0;
        protected:
                virtual ~IRefCountObj() = default;
        };
index e566179d55cf2539d3f7b7a6490b55a3ead381d1..7fa69c4e4b4afe85c3283d49168373366870be60 100644 (file)
@@ -38,6 +38,7 @@ namespace ucl {
                virtual void refWeak() noexcept final override;
                virtual void unrefWeak() noexcept final override;
                virtual unsigned getUseCount() const noexcept final override;
+               virtual const void *getObjPtr() const noexcept final override;
 
        private:
                template <class T2, class = char[1]>
index 8fce0e3967dbcebdf3572055760466588c3052d5..d3b4e97eb2253ddee01668c268904f144037f2b2 100644 (file)
@@ -83,4 +83,10 @@ namespace ucl {
        {
                return m_useCounter.get();
        }
+
+       template <class T, class C>
+       inline const void *RefCountObj<T, C>::getObjPtr() const noexcept
+       {
+               return m_obj.get();
+       }
 }
index ed84b6618903758c008f251fce1a2b26a6edbc6a..c52154455705d69dd9b20925eeb518d045fb8edc 100644 (file)
@@ -36,6 +36,7 @@ namespace ucl {
                void destroy() noexcept;
 
                T *get() noexcept;
+               const T *get() const noexcept;
 
                template <class T2>
                void dispatchOnUniqueChanged(bool isUnique);
index 5e9f4733703ac19b3f5915ad9402ffb4b2c333d0..cfc1e84d01ca6ef1eaf215dc067a7d4943268e0a 100644 (file)
@@ -35,6 +35,12 @@ namespace ucl {
                return static_cast<T *>(static_cast<void *>(&m_obj));
        }
 
+       template <class T>
+       inline const T *ReffedObj<T>::get() const noexcept
+       {
+               return static_cast<const T *>(static_cast<const void *>(&m_obj));
+       }
+
        template <class T>
        template <class T2>
        inline void ReffedObj<T>::dispatchOnUniqueChanged(const bool isUnique)