#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:
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);
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;
};
}
--- /dev/null
+/*
+ * 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__
--- /dev/null
+/*
+ * 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;
+ }
+}
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);
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();
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);
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;
};
void onPageExitRequest(Page &page);
- bool onAlertEvent(AlertDialog &dialog, int event);
+ bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
void onJobComplete();
Elm_Interface_Atspi_Accessible *onAtspiHighlight(
PageContentSRef m_content;
MoreOptionsPresenterSRef m_more;
SelectModePresenterSRef m_smp;
- AlertDialogWRef m_alert;
+ DialogWRef m_alert;
ProcessingPresenterSRef m_processing;
AtspiHighlightHelperSRef m_atspiHelper;
#include "gallery/view/TouchParser.h"
+#include "AlertDialog.h"
+
namespace gallery {
UCL_DECLARE_REF_ALIASES(VideoPlayerPage);
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);
ucl::Result launchVolumeSettings();
+ bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
+
void onMediaDeviceStateChanged();
void onMediaVolumeChanged();
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;
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__
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"
}
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;
+ }
}}
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)
{
// AlertDialog::Builder //
AlertDialog::Builder::Builder() :
- m_type(Type::OK_CANCEL)
+ m_type(Type::OK)
{
}
result->setTitle(m_title);
result->setText(m_text);
+ result->open();
return result;
}
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;
}
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)
}
}
- 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)) {
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);
}
}
--- /dev/null
+/*
+ * 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();
+ }
+}
break;
}
+ if (!m_page) {
+ LOG_RETURN(RES_FAIL, "m_page is NULL");
+ }
+
return RES_OK;
}
{
stopTimer();
if (m_widget) {
- sendActivateBy(*m_widget, this);
+ sendActivate(*m_widget);
}
}
m_widget->addEventHandler(impl::MORE_ITEM_SELECTED, WEAK_DELEGATE(
MoreOptionsPresenter::onItemSelected, asWeak(*this)));
- addDeactivatorException(this);
deactivateBy(m_widget.get());
return RES_OK;
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);
{
stopTimer();
deactivateBy(m_widget.get());
- sendActivateBy(*m_widget, this);
+ sendActivate(*m_widget);
if (const auto listener = m_listener.lock()) {
listener->onMoreOptionsClosed(*this);
}
{
}
- Presenter::~Presenter()
- {
- }
-
Result Presenter::prepare(ElmWidget &widget)
{
m_window = asShared(widget.getWindow());
}
addDeactivatorSource(*m_window);
+ addDeactivatorException(m_rc->getObjPtr());
m_isPrepared = true;
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) {
}
}
- 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});
}
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});
}
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;
}
}
}
- addDeactivatorException(this);
- broadcastDeactivateBy(this);
+ broadcastDeactivate();
return RES_OK;
}
CALLBACK_A(ProcessingPresenter::onPopupHWBackKey));
deactivateBy(m_popup.get());
- broadcastActivateBy(this);
+ broadcastActivate();
m_popup.reset();
if (m_isComplete) {
m_rc->unref();
SelectModePresenter::onRotary), this);
}
- addDeactivatorException(this);
-
return RES_OK;
}
eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
CALLBACK_A(SelectModePresenter::onPopupHWBackKey), this);
- broadcastDeactivateBy(this);
+ broadcastDeactivate();
}
void SelectModePresenter::movePopup()
m_popup.reset();
- broadcastActivateBy(this);
+ broadcastActivate();
}
}
VideoPlayerPage::~VideoPlayerPage()
{
+ if (const auto alert = m_alert.lock()) {
+ alert->dispose();
+ }
+
if (m_soundMgr) {
m_soundMgr->delMediaDeviceStateChangeHandler(WEAK_DELEGATE(
VideoPlayerPage::onMediaDeviceStateChanged, asWeak(*this)));
Result VideoPlayerPage::prepare()
{
- FAIL_LOG(prepareSoundManager(), "prepareSoundManager() failed!");
-
m_content = Layout::Builder().
setTheme(impl::LAYOUT_VIDEO_PLAYER).
setIsOwner(true).
"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();
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!");
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)
{
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."};
}
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;
};
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]>
{
return m_useCounter.get();
}
+
+ template <class T, class C>
+ inline const void *RefCountObj<T, C>::getObjPtr() const noexcept
+ {
+ return m_obj.get();
+ }
}
void destroy() noexcept;
T *get() noexcept;
+ const T *get() const noexcept;
template <class T2>
void dispatchOnUniqueChanged(bool isUnique);
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)