diff options
24 files changed, 399 insertions, 157 deletions
diff --git a/inc/gallery/presenters/AlertDialog.h b/inc/gallery/presenters/AlertDialog.h index ce508ff..1842609 100644 --- a/inc/gallery/presenters/AlertDialog.h +++ b/inc/gallery/presenters/AlertDialog.h @@ -17,30 +17,29 @@ #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 index 0000000..9aa6246 --- /dev/null +++ b/inc/gallery/presenters/Dialog.h @@ -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 index 0000000..8542874 --- /dev/null +++ b/inc/gallery/presenters/Dialog.hpp @@ -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; + } +} diff --git a/inc/gallery/presenters/Presenter.h b/inc/gallery/presenters/Presenter.h index 1142452..af8a367 100644 --- a/inc/gallery/presenters/Presenter.h +++ b/inc/gallery/presenters/Presenter.h @@ -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; }; diff --git a/inc/gallery/presenters/PreviewPage.h b/inc/gallery/presenters/PreviewPage.h index c499db6..63c546b 100644 --- a/inc/gallery/presenters/PreviewPage.h +++ b/inc/gallery/presenters/PreviewPage.h @@ -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; diff --git a/inc/gallery/presenters/VideoPlayerPage.h b/inc/gallery/presenters/VideoPlayerPage.h index 9a61a4e..61df6f6 100644 --- a/inc/gallery/presenters/VideoPlayerPage.h +++ b/inc/gallery/presenters/VideoPlayerPage.h @@ -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; diff --git a/inc/gallery/resources.h b/inc/gallery/resources.h index 9403a67..6a6f372 100644 --- a/inc/gallery/resources.h +++ b/inc/gallery/resources.h @@ -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__ diff --git a/src/helpers.h b/src/helpers.h index 666ebc6..5dd0d63 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -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" diff --git a/src/helpers.hpp b/src/helpers.hpp index 1ed8f2b..5bca4c7 100644 --- a/src/helpers.hpp +++ b/src/helpers.hpp @@ -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; + } }} diff --git a/src/presenters/AlertDialog.cpp b/src/presenters/AlertDialog.cpp index da1ebe1..26d9bcd 100644 --- a/src/presenters/AlertDialog.cpp +++ b/src/presenters/AlertDialog.cpp @@ -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 index 0000000..3f16630 --- /dev/null +++ b/src/presenters/Dialog.cpp @@ -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(); + } +} diff --git a/src/presenters/Instance.cpp b/src/presenters/Instance.cpp index 2824d4e..4c0fa53 100644 --- a/src/presenters/Instance.cpp +++ b/src/presenters/Instance.cpp @@ -200,6 +200,10 @@ namespace gallery { break; } + if (!m_page) { + LOG_RETURN(RES_FAIL, "m_page is NULL"); + } + return RES_OK; } diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp index 15492dc..260fa30 100644 --- a/src/presenters/MoreOptionsPresenter.cpp +++ b/src/presenters/MoreOptionsPresenter.cpp @@ -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); } diff --git a/src/presenters/Presenter.cpp b/src/presenters/Presenter.cpp index dcbd7d9..7906044 100644 --- a/src/presenters/Presenter.cpp +++ b/src/presenters/Presenter.cpp @@ -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}); } diff --git a/src/presenters/PreviewPage.cpp b/src/presenters/PreviewPage.cpp index b91c7fe..d21fb77 100644 --- a/src/presenters/PreviewPage.cpp +++ b/src/presenters/PreviewPage.cpp @@ -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; } diff --git a/src/presenters/ProcessingPresenter.cpp b/src/presenters/ProcessingPresenter.cpp index 63bf0cd..619f122 100644 --- a/src/presenters/ProcessingPresenter.cpp +++ b/src/presenters/ProcessingPresenter.cpp @@ -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(); diff --git a/src/presenters/SelectModePresenter.cpp b/src/presenters/SelectModePresenter.cpp index c3e0c9c..0c0e8f1 100644 --- a/src/presenters/SelectModePresenter.cpp +++ b/src/presenters/SelectModePresenter.cpp @@ -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(); } } diff --git a/src/presenters/VideoPlayerPage.cpp b/src/presenters/VideoPlayerPage.cpp index de3dddb..cc0bf22 100644 --- a/src/presenters/VideoPlayerPage.cpp +++ b/src/presenters/VideoPlayerPage.cpp @@ -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) { diff --git a/src/resources.cpp b/src/resources.cpp index f685c91..256ccef 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -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."}; } diff --git a/ucl/inc/ucl/util/memory/IRefCountObj.h b/ucl/inc/ucl/util/memory/IRefCountObj.h index 567e12c..c2397d4 100644 --- a/ucl/inc/ucl/util/memory/IRefCountObj.h +++ b/ucl/inc/ucl/util/memory/IRefCountObj.h @@ -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; }; diff --git a/ucl/inc/ucl/util/memory/RefCountObj.h b/ucl/inc/ucl/util/memory/RefCountObj.h index e566179..7fa69c4 100644 --- a/ucl/inc/ucl/util/memory/RefCountObj.h +++ b/ucl/inc/ucl/util/memory/RefCountObj.h @@ -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]> diff --git a/ucl/inc/ucl/util/memory/RefCountObj.hpp b/ucl/inc/ucl/util/memory/RefCountObj.hpp index 8fce0e3..d3b4e97 100644 --- a/ucl/inc/ucl/util/memory/RefCountObj.hpp +++ b/ucl/inc/ucl/util/memory/RefCountObj.hpp @@ -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(); + } } diff --git a/ucl/inc/ucl/util/memory/ReffedObj.h b/ucl/inc/ucl/util/memory/ReffedObj.h index ed84b66..c521544 100644 --- a/ucl/inc/ucl/util/memory/ReffedObj.h +++ b/ucl/inc/ucl/util/memory/ReffedObj.h @@ -36,6 +36,7 @@ namespace ucl { void destroy() noexcept; T *get() noexcept; + const T *get() const noexcept; template <class T2> void dispatchOnUniqueChanged(bool isUnique); diff --git a/ucl/inc/ucl/util/memory/ReffedObj.hpp b/ucl/inc/ucl/util/memory/ReffedObj.hpp index 5e9f473..cfc1e84 100644 --- a/ucl/inc/ucl/util/memory/ReffedObj.hpp +++ b/ucl/inc/ucl/util/memory/ReffedObj.hpp @@ -36,6 +36,12 @@ namespace ucl { } 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) { |