TizenRefApp-9010 [Gallery] Refactor project directory structure 20/142120/2
authorIgor Nazarov <i.nazarov@samsung.com>
Wed, 2 Aug 2017 14:21:14 +0000 (17:21 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Thu, 3 Aug 2017 10:36:48 +0000 (13:36 +0300)
- Directory structure refactoring;
- Fixed bug in delRotaryEventHandler() function;
- Fixed build warning in UCL.

Change-Id: Iea1960b83a3ccd25527529898bd154b69167ea23

441 files changed:
.cproject
edc/includes.h [new file with mode: 0644]
gallery/common.h [new file with mode: 0644]
gallery/config.h [new file with mode: 0644]
gallery/helpers.h [new file with mode: 0644]
gallery/helpers.hpp [new file with mode: 0644]
gallery/main.cpp [new file with mode: 0644]
gallery/model/Gallery.cpp [new file with mode: 0644]
gallery/model/Gallery.h [new file with mode: 0644]
gallery/model/IJob.h [new file with mode: 0644]
gallery/model/IMediaAlbum.h [new file with mode: 0644]
gallery/model/IMediaAlbum.hpp [new file with mode: 0644]
gallery/model/MediaItem.cpp [new file with mode: 0644]
gallery/model/MediaItem.h [new file with mode: 0644]
gallery/model/SoundManager.cpp [new file with mode: 0644]
gallery/model/SoundManager.h [new file with mode: 0644]
gallery/model/common.h [new file with mode: 0644]
gallery/model/impl/BaseJob.cpp [new file with mode: 0644]
gallery/model/impl/BaseJob.h [new file with mode: 0644]
gallery/model/impl/GalleryAlbum.cpp [new file with mode: 0644]
gallery/model/impl/GalleryAlbum.h [new file with mode: 0644]
gallery/model/impl/common.h [new file with mode: 0644]
gallery/model/impl/helpers.cpp [new file with mode: 0644]
gallery/model/impl/helpers.h [new file with mode: 0644]
gallery/model/impl/helpers.hpp [new file with mode: 0644]
gallery/model/types.h [new file with mode: 0644]
gallery/presenters/Instance.cpp [new file with mode: 0644]
gallery/presenters/Instance.h [new file with mode: 0644]
gallery/presenters/InstanceManager.cpp [new file with mode: 0644]
gallery/presenters/InstanceManager.h [new file with mode: 0644]
gallery/presenters/base/Dialog.cpp [new file with mode: 0644]
gallery/presenters/base/Dialog.h [new file with mode: 0644]
gallery/presenters/base/Dialog.hpp [new file with mode: 0644]
gallery/presenters/base/Page.cpp [new file with mode: 0644]
gallery/presenters/base/Page.h [new file with mode: 0644]
gallery/presenters/base/Page.hpp [new file with mode: 0644]
gallery/presenters/base/common.h [new file with mode: 0644]
gallery/presenters/common.h [new file with mode: 0644]
gallery/presenters/dialogs/AlertDialog.cpp [new file with mode: 0644]
gallery/presenters/dialogs/AlertDialog.h [new file with mode: 0644]
gallery/presenters/dialogs/common.h [new file with mode: 0644]
gallery/presenters/misc/AtspiHighlightHelper.cpp [new file with mode: 0644]
gallery/presenters/misc/AtspiHighlightHelper.h [new file with mode: 0644]
gallery/presenters/misc/MoreOptionsPresenter.cpp [new file with mode: 0644]
gallery/presenters/misc/MoreOptionsPresenter.h [new file with mode: 0644]
gallery/presenters/misc/ProcessingPresenter.cpp [new file with mode: 0644]
gallery/presenters/misc/ProcessingPresenter.h [new file with mode: 0644]
gallery/presenters/misc/SelectModePresenter.cpp [new file with mode: 0644]
gallery/presenters/misc/SelectModePresenter.h [new file with mode: 0644]
gallery/presenters/misc/common.h [new file with mode: 0644]
gallery/presenters/misc/helpers.cpp [new file with mode: 0644]
gallery/presenters/misc/helpers.h [new file with mode: 0644]
gallery/presenters/pages/NoContentPage.cpp [new file with mode: 0644]
gallery/presenters/pages/NoContentPage.h [new file with mode: 0644]
gallery/presenters/pages/PreviewPage.cpp [new file with mode: 0644]
gallery/presenters/pages/PreviewPage.h [new file with mode: 0644]
gallery/presenters/pages/ThumbnailPage.cpp [new file with mode: 0644]
gallery/presenters/pages/ThumbnailPage.h [new file with mode: 0644]
gallery/presenters/pages/VideoPlayerPage.cpp [new file with mode: 0644]
gallery/presenters/pages/VideoPlayerPage.h [new file with mode: 0644]
gallery/presenters/pages/ViewerPage.cpp [new file with mode: 0644]
gallery/presenters/pages/ViewerPage.h [new file with mode: 0644]
gallery/presenters/pages/common.h [new file with mode: 0644]
gallery/resources.cpp [new file with mode: 0644]
gallery/resources.h [new file with mode: 0644]
gallery/types.h [new file with mode: 0644]
gallery/view/ImageGrid.cpp [new file with mode: 0644]
gallery/view/ImageGrid.h [new file with mode: 0644]
gallery/view/ImageViewer.cpp [new file with mode: 0644]
gallery/view/ImageViewer.h [new file with mode: 0644]
gallery/view/PageContent.cpp [new file with mode: 0644]
gallery/view/PageContent.h [new file with mode: 0644]
gallery/view/TouchParser.cpp [new file with mode: 0644]
gallery/view/TouchParser.h [new file with mode: 0644]
gallery/view/common.h [new file with mode: 0644]
gallery/view/helpers.cpp [new file with mode: 0644]
gallery/view/helpers.h [new file with mode: 0644]
gallery/view/types.h [new file with mode: 0644]
inc/gallery/config.h [deleted file]
inc/gallery/model/Gallery.h [deleted file]
inc/gallery/model/IJob.h [deleted file]
inc/gallery/model/IMediaAlbum.h [deleted file]
inc/gallery/model/IMediaAlbum.hpp [deleted file]
inc/gallery/model/MediaItem.h [deleted file]
inc/gallery/model/SoundManager.h [deleted file]
inc/gallery/model/types.h [deleted file]
inc/gallery/presenters/AlertDialog.h [deleted file]
inc/gallery/presenters/AtspiHighlightHelper.h [deleted file]
inc/gallery/presenters/Dialog.h [deleted file]
inc/gallery/presenters/Dialog.hpp [deleted file]
inc/gallery/presenters/Instance.h [deleted file]
inc/gallery/presenters/InstanceManager.h [deleted file]
inc/gallery/presenters/MoreOptionsPresenter.h [deleted file]
inc/gallery/presenters/NoContentPage.h [deleted file]
inc/gallery/presenters/Page.h [deleted file]
inc/gallery/presenters/Page.hpp [deleted file]
inc/gallery/presenters/PreviewPage.h [deleted file]
inc/gallery/presenters/ProcessingPresenter.h [deleted file]
inc/gallery/presenters/SelectModePresenter.h [deleted file]
inc/gallery/presenters/ThumbnailPage.h [deleted file]
inc/gallery/presenters/VideoPlayerPage.h [deleted file]
inc/gallery/presenters/ViewerPage.h [deleted file]
inc/gallery/presenters/types.h [deleted file]
inc/gallery/resources.h [deleted file]
inc/gallery/types.h [deleted file]
inc/gallery/view/ImageGrid.h [deleted file]
inc/gallery/view/ImageViewer.h [deleted file]
inc/gallery/view/PageContent.h [deleted file]
inc/gallery/view/TouchParser.h [deleted file]
inc/gallery/view/helpers.h [deleted file]
inc/gallery/view/types.h [deleted file]
project_def.prop
res/edje/theme.edc
src/common.h [deleted file]
src/helpers.h [deleted file]
src/helpers.hpp [deleted file]
src/main.cpp [deleted file]
src/model/BaseJob.cpp [deleted file]
src/model/BaseJob.h [deleted file]
src/model/Gallery.cpp [deleted file]
src/model/GalleryAlbum.cpp [deleted file]
src/model/GalleryAlbum.h [deleted file]
src/model/MediaItem.cpp [deleted file]
src/model/SoundManager.cpp [deleted file]
src/model/common.h [deleted file]
src/model/helpers.cpp [deleted file]
src/model/helpers.h [deleted file]
src/model/helpers.hpp [deleted file]
src/presenters/AlertDialog.cpp [deleted file]
src/presenters/AtspiHighlightHelper.cpp [deleted file]
src/presenters/Dialog.cpp [deleted file]
src/presenters/Instance.cpp [deleted file]
src/presenters/InstanceManager.cpp [deleted file]
src/presenters/MoreOptionsPresenter.cpp [deleted file]
src/presenters/NoContentPage.cpp [deleted file]
src/presenters/Page.cpp [deleted file]
src/presenters/PreviewPage.cpp [deleted file]
src/presenters/ProcessingPresenter.cpp [deleted file]
src/presenters/SelectModePresenter.cpp [deleted file]
src/presenters/ThumbnailPage.cpp [deleted file]
src/presenters/VideoPlayerPage.cpp [deleted file]
src/presenters/ViewerPage.cpp [deleted file]
src/presenters/common.h [deleted file]
src/presenters/helpers.cpp [deleted file]
src/presenters/helpers.h [deleted file]
src/resources.cpp [deleted file]
src/view/ImageGrid.cpp [deleted file]
src/view/ImageViewer.cpp [deleted file]
src/view/PageContent.cpp [deleted file]
src/view/TouchParser.cpp [deleted file]
src/view/common.h [deleted file]
src/view/helpers.cpp [deleted file]
tizen-manifest.xml
ucl/inc/ucl/appfw/IInstance.h [deleted file]
ucl/inc/ucl/appfw/IInstanceAppControlExt.h [deleted file]
ucl/inc/ucl/appfw/IInstanceContext.h [deleted file]
ucl/inc/ucl/appfw/InstanceManagerBase.h [deleted file]
ucl/inc/ucl/appfw/SysEventProvider.h [deleted file]
ucl/inc/ucl/appfw/SysEventProvider.hpp [deleted file]
ucl/inc/ucl/appfw/UIApp.h [deleted file]
ucl/inc/ucl/appfw/helpers.h [deleted file]
ucl/inc/ucl/appfw/types.h [deleted file]
ucl/inc/ucl/config.h [deleted file]
ucl/inc/ucl/gui/EdjeWidget.h [deleted file]
ucl/inc/ucl/gui/EdjeWidget.hpp [deleted file]
ucl/inc/ucl/gui/ElmWidget.h [deleted file]
ucl/inc/ucl/gui/ElmWidget.hpp [deleted file]
ucl/inc/ucl/gui/Genlist.h [deleted file]
ucl/inc/ucl/gui/Genlist.hpp [deleted file]
ucl/inc/ucl/gui/GenlistItem.h [deleted file]
ucl/inc/ucl/gui/GenlistItem.hpp [deleted file]
ucl/inc/ucl/gui/Layout.h [deleted file]
ucl/inc/ucl/gui/Layout.hpp [deleted file]
ucl/inc/ucl/gui/NaviItem.h [deleted file]
ucl/inc/ucl/gui/NaviItem.hpp [deleted file]
ucl/inc/ucl/gui/Naviframe.h [deleted file]
ucl/inc/ucl/gui/Naviframe.hpp [deleted file]
ucl/inc/ucl/gui/StyledWidget.h [deleted file]
ucl/inc/ucl/gui/StyledWidget.hpp [deleted file]
ucl/inc/ucl/gui/Theme.h [deleted file]
ucl/inc/ucl/gui/Theme.hpp [deleted file]
ucl/inc/ucl/gui/Widget.h [deleted file]
ucl/inc/ucl/gui/Widget.hpp [deleted file]
ucl/inc/ucl/gui/WidgetItem.h [deleted file]
ucl/inc/ucl/gui/WidgetItem.hpp [deleted file]
ucl/inc/ucl/gui/Window.h [deleted file]
ucl/inc/ucl/gui/Window.hpp [deleted file]
ucl/inc/ucl/gui/helpers.h [deleted file]
ucl/inc/ucl/gui/helpers.hpp [deleted file]
ucl/inc/ucl/gui/stdTheme.h [deleted file]
ucl/inc/ucl/gui/stdTheme/common.h [deleted file]
ucl/inc/ucl/gui/stdTheme/layout.h [deleted file]
ucl/inc/ucl/gui/stdTheme/naviframe.h [deleted file]
ucl/inc/ucl/gui/types.h [deleted file]
ucl/inc/ucl/gui/types.hpp [deleted file]
ucl/inc/ucl/misc/Aspect.h [deleted file]
ucl/inc/ucl/misc/Aspect.hpp [deleted file]
ucl/inc/ucl/misc/AutoHandle.h [deleted file]
ucl/inc/ucl/misc/CString.h [deleted file]
ucl/inc/ucl/misc/CString.hpp [deleted file]
ucl/inc/ucl/misc/ConstCString.h [deleted file]
ucl/inc/ucl/misc/ConstCString.hpp [deleted file]
ucl/inc/ucl/misc/Event.h [deleted file]
ucl/inc/ucl/misc/Event.hpp [deleted file]
ucl/inc/ucl/misc/HashMap.h [deleted file]
ucl/inc/ucl/misc/HashMap.hpp [deleted file]
ucl/inc/ucl/misc/RefCountAware.h [deleted file]
ucl/inc/ucl/misc/RefCountAware.hpp [deleted file]
ucl/inc/ucl/misc/TString.h [deleted file]
ucl/inc/ucl/misc/TString.hpp [deleted file]
ucl/inc/ucl/misc/Timeout.h [deleted file]
ucl/inc/ucl/misc/Variant.h [deleted file]
ucl/inc/ucl/misc/Variant.hpp [deleted file]
ucl/inc/ucl/mvp/GuiPresenter.h [deleted file]
ucl/inc/ucl/mvp/ListItemPresenter.h [deleted file]
ucl/inc/ucl/mvp/ListPresenter.h [deleted file]
ucl/inc/ucl/mvp/types.h [deleted file]
ucl/inc/ucl/util/delegation.h [deleted file]
ucl/inc/ucl/util/delegation/BaseDelegate.h [deleted file]
ucl/inc/ucl/util/delegation/BaseDelegate.hpp [deleted file]
ucl/inc/ucl/util/delegation/BaseDelegate2.h [deleted file]
ucl/inc/ucl/util/delegation/BaseDelegate2.hpp [deleted file]
ucl/inc/ucl/util/delegation/Callback.h [deleted file]
ucl/inc/ucl/util/delegation/Callback.hpp [deleted file]
ucl/inc/ucl/util/delegation/Delegate.h [deleted file]
ucl/inc/ucl/util/delegation/Delegate.hpp [deleted file]
ucl/inc/ucl/util/delegation/Delegate2.h [deleted file]
ucl/inc/ucl/util/delegation/Delegate2.hpp [deleted file]
ucl/inc/ucl/util/delegation/helpers.h [deleted file]
ucl/inc/ucl/util/delegation/macro.h [deleted file]
ucl/inc/ucl/util/delegation/shortMacro.h [deleted file]
ucl/inc/ucl/util/helpers.h [deleted file]
ucl/inc/ucl/util/helpers.hpp [deleted file]
ucl/inc/ucl/util/logging.h [deleted file]
ucl/inc/ucl/util/memory.h [deleted file]
ucl/inc/ucl/util/memory/BaseRef.h [deleted file]
ucl/inc/ucl/util/memory/BaseRef.hpp [deleted file]
ucl/inc/ucl/util/memory/IRefCountObj.h [deleted file]
ucl/inc/ucl/util/memory/RefCountObj.h [deleted file]
ucl/inc/ucl/util/memory/RefCountObj.hpp [deleted file]
ucl/inc/ucl/util/memory/RefCounterMT.h [deleted file]
ucl/inc/ucl/util/memory/RefCounterMT.hpp [deleted file]
ucl/inc/ucl/util/memory/RefCounterST.h [deleted file]
ucl/inc/ucl/util/memory/RefCounterST.hpp [deleted file]
ucl/inc/ucl/util/memory/ReffedObj.h [deleted file]
ucl/inc/ucl/util/memory/ReffedObj.hpp [deleted file]
ucl/inc/ucl/util/memory/SharedRef.h [deleted file]
ucl/inc/ucl/util/memory/SharedRef.hpp [deleted file]
ucl/inc/ucl/util/memory/WeakRef.h [deleted file]
ucl/inc/ucl/util/memory/WeakRef.hpp [deleted file]
ucl/inc/ucl/util/memory/helpers.h [deleted file]
ucl/inc/ucl/util/memory/macro.h [deleted file]
ucl/inc/ucl/util/shortLogs.h [deleted file]
ucl/inc/ucl/util/smartDelegation.h [deleted file]
ucl/inc/ucl/util/smartDelegation/WeakDelegate.h [deleted file]
ucl/inc/ucl/util/smartDelegation/WeakDelegate.hpp [deleted file]
ucl/inc/ucl/util/smartDelegation/macro.h [deleted file]
ucl/inc/ucl/util/smartDelegation/shortMacro.h [deleted file]
ucl/inc/ucl/util/threading.h [deleted file]
ucl/inc/ucl/util/threading/CondVar.h [deleted file]
ucl/inc/ucl/util/threading/CondVar.hpp [deleted file]
ucl/inc/ucl/util/threading/Mutex.h [deleted file]
ucl/inc/ucl/util/threading/Mutex.hpp [deleted file]
ucl/inc/ucl/util/threading/MutexLock.h [deleted file]
ucl/inc/ucl/util/threading/MutexLock.hpp [deleted file]
ucl/inc/ucl/util/threading/Thread.h [deleted file]
ucl/inc/ucl/util/threading/Thread.hpp [deleted file]
ucl/inc/ucl/util/types.h [deleted file]
ucl/inc/ucl/util/types/Result.h [deleted file]
ucl/inc/ucl/util/types/Result.hpp [deleted file]
ucl/inc/ucl/util/types/baseTypes.h [deleted file]
ucl/inc/ucl/util/types/classTypes.h [deleted file]
ucl/include/ucl/appfw/IInstance.h [new file with mode: 0644]
ucl/include/ucl/appfw/IInstanceAppControlExt.h [new file with mode: 0644]
ucl/include/ucl/appfw/IInstanceContext.h [new file with mode: 0644]
ucl/include/ucl/appfw/InstanceManagerBase.h [new file with mode: 0644]
ucl/include/ucl/appfw/SysEventProvider.h [new file with mode: 0644]
ucl/include/ucl/appfw/SysEventProvider.hpp [new file with mode: 0644]
ucl/include/ucl/appfw/UIApp.h [new file with mode: 0644]
ucl/include/ucl/appfw/helpers.h [new file with mode: 0644]
ucl/include/ucl/appfw/types.h [new file with mode: 0644]
ucl/include/ucl/config.h [new file with mode: 0644]
ucl/include/ucl/gui/EdjeWidget.h [new file with mode: 0644]
ucl/include/ucl/gui/EdjeWidget.hpp [new file with mode: 0644]
ucl/include/ucl/gui/ElmWidget.h [new file with mode: 0644]
ucl/include/ucl/gui/ElmWidget.hpp [new file with mode: 0644]
ucl/include/ucl/gui/Genlist.h [new file with mode: 0644]
ucl/include/ucl/gui/Genlist.hpp [new file with mode: 0644]
ucl/include/ucl/gui/GenlistItem.h [new file with mode: 0644]
ucl/include/ucl/gui/GenlistItem.hpp [new file with mode: 0644]
ucl/include/ucl/gui/Layout.h [new file with mode: 0644]
ucl/include/ucl/gui/Layout.hpp [new file with mode: 0644]
ucl/include/ucl/gui/NaviItem.h [new file with mode: 0644]
ucl/include/ucl/gui/NaviItem.hpp [new file with mode: 0644]
ucl/include/ucl/gui/Naviframe.h [new file with mode: 0644]
ucl/include/ucl/gui/Naviframe.hpp [new file with mode: 0644]
ucl/include/ucl/gui/StyledWidget.h [new file with mode: 0644]
ucl/include/ucl/gui/StyledWidget.hpp [new file with mode: 0644]
ucl/include/ucl/gui/Theme.h [new file with mode: 0644]
ucl/include/ucl/gui/Theme.hpp [new file with mode: 0644]
ucl/include/ucl/gui/Widget.h [new file with mode: 0644]
ucl/include/ucl/gui/Widget.hpp [new file with mode: 0644]
ucl/include/ucl/gui/WidgetItem.h [new file with mode: 0644]
ucl/include/ucl/gui/WidgetItem.hpp [new file with mode: 0644]
ucl/include/ucl/gui/Window.h [new file with mode: 0644]
ucl/include/ucl/gui/Window.hpp [new file with mode: 0644]
ucl/include/ucl/gui/helpers.h [new file with mode: 0644]
ucl/include/ucl/gui/helpers.hpp [new file with mode: 0644]
ucl/include/ucl/gui/stdTheme.h [new file with mode: 0644]
ucl/include/ucl/gui/stdTheme/common.h [new file with mode: 0644]
ucl/include/ucl/gui/stdTheme/layout.h [new file with mode: 0644]
ucl/include/ucl/gui/stdTheme/naviframe.h [new file with mode: 0644]
ucl/include/ucl/gui/types.h [new file with mode: 0644]
ucl/include/ucl/gui/types.hpp [new file with mode: 0644]
ucl/include/ucl/misc/Aspect.h [new file with mode: 0644]
ucl/include/ucl/misc/Aspect.hpp [new file with mode: 0644]
ucl/include/ucl/misc/AutoHandle.h [new file with mode: 0644]
ucl/include/ucl/misc/CString.h [new file with mode: 0644]
ucl/include/ucl/misc/CString.hpp [new file with mode: 0644]
ucl/include/ucl/misc/ConstCString.h [new file with mode: 0644]
ucl/include/ucl/misc/ConstCString.hpp [new file with mode: 0644]
ucl/include/ucl/misc/Event.h [new file with mode: 0644]
ucl/include/ucl/misc/Event.hpp [new file with mode: 0644]
ucl/include/ucl/misc/HashMap.h [new file with mode: 0644]
ucl/include/ucl/misc/HashMap.hpp [new file with mode: 0644]
ucl/include/ucl/misc/RefCountAware.h [new file with mode: 0644]
ucl/include/ucl/misc/RefCountAware.hpp [new file with mode: 0644]
ucl/include/ucl/misc/TString.h [new file with mode: 0644]
ucl/include/ucl/misc/TString.hpp [new file with mode: 0644]
ucl/include/ucl/misc/Timeout.h [new file with mode: 0644]
ucl/include/ucl/misc/Variant.h [new file with mode: 0644]
ucl/include/ucl/misc/Variant.hpp [new file with mode: 0644]
ucl/include/ucl/mvp/GuiPresenter.h [new file with mode: 0644]
ucl/include/ucl/mvp/ListItemPresenter.h [new file with mode: 0644]
ucl/include/ucl/mvp/ListPresenter.h [new file with mode: 0644]
ucl/include/ucl/mvp/types.h [new file with mode: 0644]
ucl/include/ucl/util/delegation.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/BaseDelegate.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/BaseDelegate.hpp [new file with mode: 0644]
ucl/include/ucl/util/delegation/BaseDelegate2.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/BaseDelegate2.hpp [new file with mode: 0644]
ucl/include/ucl/util/delegation/Callback.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/Callback.hpp [new file with mode: 0644]
ucl/include/ucl/util/delegation/Delegate.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/Delegate.hpp [new file with mode: 0644]
ucl/include/ucl/util/delegation/Delegate2.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/Delegate2.hpp [new file with mode: 0644]
ucl/include/ucl/util/delegation/helpers.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/macro.h [new file with mode: 0644]
ucl/include/ucl/util/delegation/shortMacro.h [new file with mode: 0644]
ucl/include/ucl/util/helpers.h [new file with mode: 0644]
ucl/include/ucl/util/helpers.hpp [new file with mode: 0644]
ucl/include/ucl/util/logging.h [new file with mode: 0644]
ucl/include/ucl/util/memory.h [new file with mode: 0644]
ucl/include/ucl/util/memory/BaseRef.h [new file with mode: 0644]
ucl/include/ucl/util/memory/BaseRef.hpp [new file with mode: 0644]
ucl/include/ucl/util/memory/IRefCountObj.h [new file with mode: 0644]
ucl/include/ucl/util/memory/RefCountObj.h [new file with mode: 0644]
ucl/include/ucl/util/memory/RefCountObj.hpp [new file with mode: 0644]
ucl/include/ucl/util/memory/RefCounterMT.h [new file with mode: 0644]
ucl/include/ucl/util/memory/RefCounterMT.hpp [new file with mode: 0644]
ucl/include/ucl/util/memory/RefCounterST.h [new file with mode: 0644]
ucl/include/ucl/util/memory/RefCounterST.hpp [new file with mode: 0644]
ucl/include/ucl/util/memory/ReffedObj.h [new file with mode: 0644]
ucl/include/ucl/util/memory/ReffedObj.hpp [new file with mode: 0644]
ucl/include/ucl/util/memory/SharedRef.h [new file with mode: 0644]
ucl/include/ucl/util/memory/SharedRef.hpp [new file with mode: 0644]
ucl/include/ucl/util/memory/WeakRef.h [new file with mode: 0644]
ucl/include/ucl/util/memory/WeakRef.hpp [new file with mode: 0644]
ucl/include/ucl/util/memory/helpers.h [new file with mode: 0644]
ucl/include/ucl/util/memory/macro.h [new file with mode: 0644]
ucl/include/ucl/util/shortLogs.h [new file with mode: 0644]
ucl/include/ucl/util/smartDelegation.h [new file with mode: 0644]
ucl/include/ucl/util/smartDelegation/WeakDelegate.h [new file with mode: 0644]
ucl/include/ucl/util/smartDelegation/WeakDelegate.hpp [new file with mode: 0644]
ucl/include/ucl/util/smartDelegation/macro.h [new file with mode: 0644]
ucl/include/ucl/util/smartDelegation/shortMacro.h [new file with mode: 0644]
ucl/include/ucl/util/threading.h [new file with mode: 0644]
ucl/include/ucl/util/threading/CondVar.h [new file with mode: 0644]
ucl/include/ucl/util/threading/CondVar.hpp [new file with mode: 0644]
ucl/include/ucl/util/threading/Mutex.h [new file with mode: 0644]
ucl/include/ucl/util/threading/Mutex.hpp [new file with mode: 0644]
ucl/include/ucl/util/threading/MutexLock.h [new file with mode: 0644]
ucl/include/ucl/util/threading/MutexLock.hpp [new file with mode: 0644]
ucl/include/ucl/util/threading/Thread.h [new file with mode: 0644]
ucl/include/ucl/util/threading/Thread.hpp [new file with mode: 0644]
ucl/include/ucl/util/types.h [new file with mode: 0644]
ucl/include/ucl/util/types/Result.h [new file with mode: 0644]
ucl/include/ucl/util/types/Result.hpp [new file with mode: 0644]
ucl/include/ucl/util/types/baseTypes.h [new file with mode: 0644]
ucl/include/ucl/util/types/classTypes.h [new file with mode: 0644]
ucl/source/appfw/InstanceManagerBase.cpp [new file with mode: 0644]
ucl/source/appfw/SysEventProvider.cpp [new file with mode: 0644]
ucl/source/appfw/UIApp.cpp [new file with mode: 0644]
ucl/source/appfw/common.h [new file with mode: 0644]
ucl/source/appfw/helpers.cpp [new file with mode: 0644]
ucl/source/common.h [new file with mode: 0644]
ucl/source/gui/EdjeWidget.cpp [new file with mode: 0644]
ucl/source/gui/ElmWidget.cpp [new file with mode: 0644]
ucl/source/gui/Genlist.cpp [new file with mode: 0644]
ucl/source/gui/Layout.cpp [new file with mode: 0644]
ucl/source/gui/NaviItem.cpp [new file with mode: 0644]
ucl/source/gui/Naviframe.cpp [new file with mode: 0644]
ucl/source/gui/Widget.cpp [new file with mode: 0644]
ucl/source/gui/WidgetItem.cpp [new file with mode: 0644]
ucl/source/gui/Window.cpp [new file with mode: 0644]
ucl/source/gui/common.h [new file with mode: 0644]
ucl/source/misc/Timeout.cpp [new file with mode: 0644]
ucl/source/misc/Variant.cpp [new file with mode: 0644]
ucl/source/misc/common.h [new file with mode: 0644]
ucl/source/mvp/GuiPresenter.cpp [new file with mode: 0644]
ucl/source/mvp/ListItemPresenter.cpp [new file with mode: 0644]
ucl/source/mvp/ListPresenter.cpp [new file with mode: 0644]
ucl/source/mvp/common.h [new file with mode: 0644]
ucl/source/util/logging.cpp [new file with mode: 0644]
ucl/source/util/types/Result.cpp [new file with mode: 0644]
ucl/src/appfw/InstanceManagerBase.cpp [deleted file]
ucl/src/appfw/SysEventProvider.cpp [deleted file]
ucl/src/appfw/UIApp.cpp [deleted file]
ucl/src/appfw/common.h [deleted file]
ucl/src/appfw/helpers.cpp [deleted file]
ucl/src/common.h [deleted file]
ucl/src/gui/EdjeWidget.cpp [deleted file]
ucl/src/gui/ElmWidget.cpp [deleted file]
ucl/src/gui/Genlist.cpp [deleted file]
ucl/src/gui/Layout.cpp [deleted file]
ucl/src/gui/NaviItem.cpp [deleted file]
ucl/src/gui/Naviframe.cpp [deleted file]
ucl/src/gui/Widget.cpp [deleted file]
ucl/src/gui/WidgetItem.cpp [deleted file]
ucl/src/gui/Window.cpp [deleted file]
ucl/src/gui/common.h [deleted file]
ucl/src/misc/Timeout.cpp [deleted file]
ucl/src/misc/Variant.cpp [deleted file]
ucl/src/misc/common.h [deleted file]
ucl/src/mvp/GuiPresenter.cpp [deleted file]
ucl/src/mvp/ListItemPresenter.cpp [deleted file]
ucl/src/mvp/ListPresenter.cpp [deleted file]
ucl/src/mvp/common.h [deleted file]
ucl/src/util/logging.cpp [deleted file]
ucl/src/util/types/Result.cpp [deleted file]

index 6fb27a34da307f7e4035c0f5c2f839427317193f..e8c16625384fa27f6d68d04246e8e1f148a4926b 100644 (file)
--- a/.cproject
+++ b/.cproject
                                </extensions>
                        </storageModule>
                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-                               <configuration artifactName="gallery" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1049602791" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
+                               <configuration artifactName="w-gallery" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1049602791" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
                                        <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1049602791." name="/" resourcePath="">
                                                <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.531160032" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
                                                        <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.728531842" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
                                                        <builder autoBuildTarget="all" buildPath="${workspace_loc:/gallery}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1903374037" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.683429809" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
-                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1060076319" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+                                                       <tool command="arm-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1060076319" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
                                                                <option id="gnu.cpp.compiler.option.optimization.level.1602641110" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
                                                                <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1369151974" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.1996885248" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.1964350537" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm37.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_gcc62.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1290986068" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.cpp.compiler.option.include.paths.831915180" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/include}&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1738122246" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                <option id="gnu.cpp.compiler.option.dialect.std.220245897" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.c++11" valueType="enumerated"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.592894666" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
                                                        </tool>
-                                                       <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1433876771" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+                                                       <tool command="arm-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1433876771" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
                                                                <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.982057263" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
                                                                <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1672854934" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1117960579" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.c.compiler.option.2144981321" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm37.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_gcc62.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.625351371" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.2123823065" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/include}&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks.core.1669459306" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1564318540" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
                                                        </tool>
                                                        <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1520359031" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
-                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1597861570" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+                                                       <tool command="arm-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1597861570" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1262973541" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1726486558" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1232921885" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
-                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
-                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
-                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
-                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/inc"/>
-                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/src"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="gallery"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="res"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/source"/>
                                        </sourceEntries>
                                </configuration>
                        </storageModule>
                                                        <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1905316156" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
                                                        <builder buildPath="${workspace_loc:/gallery}/Release" id="org.tizen.nativecore.target.sbi.gnu.builder.2018439737" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.1278616718" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
-                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1877650577" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+                                                       <tool command="arm-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1877650577" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
                                                                <option id="gnu.cpp.compiler.option.optimization.level.1349943786" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
                                                                <option defaultValue="gnu.cpp.compiler.debugging.level.none" id="sbi.gnu.cpp.compiler.option.debugging.level.core.2118322735" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.350374090" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.205445558" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm37.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_gcc62.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.2129264981" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.cpp.compiler.option.include.paths.2064434934" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/include}&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks.core.1300541916" name="Tizen-Frameworks" superClass="sbi.gnu.cpp.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                <option id="gnu.cpp.compiler.option.dialect.std.1157770444" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.c++11" valueType="enumerated"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.67986536" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
                                                        </tool>
-                                                       <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.904054681" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+                                                       <tool command="arm-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.904054681" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
                                                                <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.877653241" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
                                                                <option defaultValue="gnu.c.debugging.level.default" id="sbi.gnu.c.compiler.option.debugging.level.core.530526098" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.658919778" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.c.compiler.option.1532282184" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm37.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_gcc62.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1707321532" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.1214715962" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/ucl/include}&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks.core.775372915" name="Tizen-Frameworks" superClass="sbi.gnu.c.compiler.option.frameworks.core" valueType="userObjs">
                                                                        <listOptionValue builtIn="false" value="Native_API"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1964837320" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
                                                        </tool>
                                                        <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.499300439" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
-                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1838325853" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+                                                       <tool command="arm-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1838325853" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1256173694" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.642735052" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1632577677" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
-                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="gallery"/>
                                                <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="res"/>
-                                               <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
-                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/inc"/>
-                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/src"/>
+                                               <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="ucl/source"/>
                                        </sourceEntries>
                                </configuration>
                        </storageModule>
                </scannerConfigBuildInfo>
        </storageModule>
        <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
-       <storageModule moduleId="refreshScope"/>
+       <storageModule moduleId="refreshScope" versionNumber="2">
+               <configuration configurationName="Debug">
+                       <resource resourceType="PROJECT" workspacePath="/gallery"/>
+               </configuration>
+               <configuration configurationName="Release">
+                       <resource resourceType="PROJECT" workspacePath="/gallery"/>
+               </configuration>
+       </storageModule>
 </cproject>
diff --git a/edc/includes.h b/edc/includes.h
new file mode 100644 (file)
index 0000000..46b53be
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_EDC_INCLUDES_H__
+#define __GALLERY_EDC_INCLUDES_H__
+
+#include "colors.h"
+#include "images.edc"
+#include "image-grid.edc"
+#include "button.edc"
+#include "layouts.edc"
+#include "naviframe.edc"
+
+#endif // __GALLERY_EDC_INCLUDES_H__
diff --git a/gallery/common.h b/gallery/common.h
new file mode 100644 (file)
index 0000000..659c330
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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_COMMON_H__
+#define __GALLERY_COMMON_H__
+
+#include <algorithm>
+
+#include "ucl/util/helpers.h"
+#include "ucl/util/logging.h"
+#include "ucl/util/shortLogs.h"
+
+#undef UCL_LOG_TAG
+#define UCL_LOG_TAG GALLERY_LOG_TAG
+
+#include "helpers.h"
+
+namespace gallery {
+
+       using ucl::UInt;
+
+       using ucl::Result;
+       using ucl::RES_OK;
+       using ucl::RES_FALSE;
+       using ucl::RES_FAIL;
+       using ucl::RES_INVALID_ARGUMENTS;
+       using ucl::RES_ILLEGAL_STATE;
+       using ucl::RES_NOT_SUPPORTED;
+       using ucl::RES_IO_ERROR;
+       using ucl::RES_INVALID_DATA;
+       using ucl::RES_FATAL;
+
+       using ucl::isEmpty;
+       using ucl::isNotEmpty;
+       using ucl::toEina;
+
+       using ucl::ReffedObj;
+       using ucl::IRefCountObj;
+       using ucl::SharedRef;
+       using ucl::WeakRef;
+
+       using ucl::makeShared;
+       using ucl::dynamicRefCast;
+
+       namespace util {
+
+               using ucl::util::makeUnique;
+               using ucl::util::dispose;
+       }
+}
+
+#endif // __GALLERY_COMMON_H__
diff --git a/gallery/config.h b/gallery/config.h
new file mode 100644 (file)
index 0000000..debdc9a
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_CONFIG_H__
+#define __GALLERY_CONFIG_H__
+
+#define GALLERY_LOG_TAG "GALLERY"
+
+namespace gallery {
+
+       constexpr auto WINDOW_NAME = "org.tizen.gallery";
+
+       constexpr auto BASE_SCALE = 1.3;
+
+       // TODO Temporary feature while support only offline mode
+       constexpr auto SCAN_MEDIA_ON_RESUME = false;
+}
+
+#endif // __GALLERY_CONFIG_H__
diff --git a/gallery/helpers.h b/gallery/helpers.h
new file mode 100644 (file)
index 0000000..fb79812
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_HELPERS_H__
+#define __GALLERY_HELPERS_H__
+
+#include "types.h"
+
+namespace gallery { namespace util {
+
+       template <class GETTER, class V, class ...ARGS>
+       ucl::Result get(GETTER &&getter, V &result, ARGS &&...args);
+
+       template <class GETTER, class V, class ...ARGS>
+       ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args);
+
+       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"
+
+#endif // __GALLERY_HELPERS_H__
diff --git a/gallery/helpers.hpp b/gallery/helpers.hpp
new file mode 100644 (file)
index 0000000..5bca4c7
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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/helpers.h"
+#include "ucl/util/logging.h"
+
+namespace gallery { namespace util { namespace himpl {
+
+       template <class GETTER, class ...ARGS>
+       inline ucl::Result get(GETTER &&getter, bool optional,
+                       std::string &result, ARGS &&...args)
+       {
+               char *value = nullptr;
+               const int ret = getter(std::forward<ARGS>(args)..., &value);
+               if ((ret != 0) || (!optional && ucl::isEmpty(value))) {
+                       UCL_ELOG("get() failed: %d", ret);
+                       return ucl::RES_FAIL;
+               }
+
+               if (value) {
+                       result = value;
+                       free(value);
+               } else {
+                       result.clear();
+               }
+
+               return ucl::RES_OK;
+       }
+
+       template <class GETTER, class V, class ...ARGS>
+       inline ucl::Result get(GETTER &&getter, bool optional,
+                       V &result, ARGS &&...args)
+       {
+               typename std::remove_pointer<decltype(&result)>::type value = {};
+
+               const int ret = getter(std::forward<ARGS>(args)..., &value);
+               if ((ret != 0) || (!optional && !value)) {
+                       UCL_ELOG("get() failed: %d", ret);
+                       return ucl::RES_FAIL;
+               }
+
+               result = value;
+
+               return ucl::RES_OK;
+       }
+}}}
+
+namespace gallery { namespace util {
+
+       template <class GETTER, class V, class ...ARGS>
+       inline ucl::Result get(GETTER &&getter, V &result, ARGS &&...args)
+       {
+               return himpl::get(std::forward<GETTER>(getter), true,
+                               result, std::forward<ARGS>(args)...);
+       }
+
+       template <class GETTER, class V, class ...ARGS>
+       inline ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args)
+       {
+               return himpl::get(std::forward<GETTER>(getter), false,
+                               result, std::forward<ARGS>(args)...);
+       }
+
+       template <class FUNC, class ...ARGS>
+       inline ucl::Result call(FUNC &&func, ARGS &&...args)
+       {
+               const int ret = func(std::forward<ARGS>(args)...);
+               if (ret != 0) {
+                       UCL_ELOG("func() failed: %d", ret);
+                       return ucl::RES_FAIL;
+               }
+               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/gallery/main.cpp b/gallery/main.cpp
new file mode 100644 (file)
index 0000000..0165f6f
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ucl/appfw/UIApp.h"
+
+#include "presenters/InstanceManager.h"
+
+#include "common.h"
+
+using ucl::UIApp;
+using gallery::InstanceManager;
+
+int main(int argc, char *argv[])
+{
+       InstanceManager mgr;
+       const int ret = UIApp(mgr).run(argc, argv);
+       ILOG("ret: %d", ret);
+       return ret;
+}
diff --git a/gallery/model/Gallery.cpp b/gallery/model/Gallery.cpp
new file mode 100644 (file)
index 0000000..a254c36
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.h"
+
+#include "impl/GalleryAlbum.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       Gallery::Gallery() :
+               m_isMediaDbConnected(false)
+       {
+       }
+
+       Gallery::~Gallery()
+       {
+               if (m_isMediaDbConnected) {
+                       releaseMediaDbConnection();
+               }
+       }
+
+       GallerySRef Gallery::newInstance()
+       {
+               auto result = makeShared<Gallery>();
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+               return result;
+       }
+
+       Result Gallery::prepare()
+       {
+               FAIL_RETURN(acquireMediaDbConnection(),
+                               "acquireMediaDbConnection() failed!");
+
+               m_isMediaDbConnected = true;
+
+               m_album = GalleryAlbum::newInstance();
+               if (!m_album) {
+                       LOG_RETURN(RES_FAIL, "GalleryAlbum::newInstance() failed!");
+               }
+
+               return RES_OK;
+       }
+
+       IMediaAlbumSRef Gallery::getAlbum()
+       {
+               return m_album;
+       }
+}
diff --git a/gallery/model/Gallery.h b/gallery/model/Gallery.h
new file mode 100644 (file)
index 0000000..e17b1f5
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_MODEL_GALLERY_H__
+#define __GALLERY_MODEL_GALLERY_H__
+
+#include "IMediaAlbum.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(Gallery);
+
+       class Gallery final : public ucl::NonCopyable {
+       public:
+               static GallerySRef newInstance();
+               ~Gallery();
+
+               IMediaAlbumSRef getAlbum();
+
+       private:
+               friend class ucl::ReffedObj<Gallery>;
+               Gallery();
+
+               ucl::Result prepare();
+
+       private:
+               IMediaAlbumSRef m_album;
+               bool m_isMediaDbConnected;
+       };
+}
+
+#endif // __GALLERY_MODEL_GALLERY_H__
diff --git a/gallery/model/IJob.h b/gallery/model/IJob.h
new file mode 100644 (file)
index 0000000..8c7d56e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_MODEL_I_JOB_H__
+#define __GALLERY_MODEL_I_JOB_H__
+
+#include "types.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(IJob);
+
+       class IJob : public ucl::Polymorphic {
+       public:
+               virtual ucl::Result getResult() const = 0;
+               virtual bool isCancelable() const = 0;
+               virtual ucl::Result cancel() = 0;
+       };
+}
+
+#endif // __GALLERY_MODEL_I_JOB_H__
diff --git a/gallery/model/IMediaAlbum.h b/gallery/model/IMediaAlbum.h
new file mode 100644 (file)
index 0000000..80eb222
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_MODEL_I_MEDIA_ALBUM_H__
+#define __GALLERY_MODEL_I_MEDIA_ALBUM_H__
+
+#include "MediaItem.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(IMediaAlbum);
+
+       class IMediaAlbum : public ucl::Polymorphic {
+       public:
+               using EachCb = ucl::Delegate<bool(MediaItemSRef &&media)>;
+
+       public:
+               virtual void addChangeHandler(const NotiHandler &handler) = 0;
+               virtual void delChangeHandler(const NotiHandler &handler) = 0;
+
+               virtual ucl::Result forEachMedia(EachCb cb) const = 0;
+               virtual ucl::Result getMediaCount(int &count) const = 0;
+
+               virtual void defragment() = 0;
+       };
+
+       // Non-member functions //
+
+       bool isEmpty(const IMediaAlbum &album);
+}
+
+#include "IMediaAlbum.hpp"
+
+#endif // __GALLERY_MODEL_I_MEDIA_ALBUM_H__
diff --git a/gallery/model/IMediaAlbum.hpp b/gallery/model/IMediaAlbum.hpp
new file mode 100644 (file)
index 0000000..5793dfc
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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 {
+
+       // Non-member functions //
+
+       inline bool isEmpty(const IMediaAlbum &album)
+       {
+               int count = 0;
+               UCL_FAIL_RETURN_VALUE(album.getMediaCount(count), true,
+                               "album.getMediaCount() failed!");
+               return (count == 0);
+       }
+}
diff --git a/gallery/model/MediaItem.cpp b/gallery/model/MediaItem.cpp
new file mode 100644 (file)
index 0000000..4e1c034
--- /dev/null
@@ -0,0 +1,542 @@
+/*
+ * 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 "MediaItem.h"
+
+#include <Ecore_File.h>
+#include <storage.h>
+#include <mime_type.h>
+
+#include "impl/BaseJob.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       using ucl::AutoHandle;
+
+       const std::string MIME_PREFIX_IMAGE {"image/"};
+       const std::string MIME_PREFIX_VIDEO {"video/"};
+       const std::string URI_PREFIX_FILE {"file://"};
+
+       using AutoImageMeta = AutoHandle<image_meta_h, int, image_meta_destroy>;
+
+       MediaType getFileMediaType(const std::string &filePath)
+       {
+               const auto ext = util::extractFileExtension(filePath);
+
+               std::string mime;
+               FAIL_RETURN_VALUE(util::get(mime_type_get_mime_type, mime, ext.c_str()),
+                               MediaType::OTHERS,
+                               "mime_type_get_mime_type() failed!");
+
+               if (util::beginsWith(mime, MIME_PREFIX_IMAGE)) {
+                       return MediaType::IMAGE;
+               }
+               if (util::beginsWith(mime, MIME_PREFIX_VIDEO)) {
+                       return MediaType::VIDEO;
+               }
+
+               return MediaType::OTHERS;
+       }
+
+       // Temp function until ecore_file_cp() fix.
+       Result copyFile(const std::string &src, const std::string &dst)
+       {
+               FILE *f1 = fopen(src.c_str(), "rb");
+               if (!f1) {
+                       LOG_RETURN(RES_IO_ERROR, "fopen(rb) failed!");
+               }
+
+               FILE *f2 = fopen(dst.c_str(), "wb");
+               if (!f2) {
+                       fclose(f1);
+                       LOG_RETURN(RES_IO_ERROR, "fopen(wb) failed!");
+               }
+
+               bool badCopy = false;
+
+               constexpr auto COPY_BUF_SIZE = 16384;
+               char buf[COPY_BUF_SIZE];
+               while (!feof(f1)) {
+                       const auto num = fread(buf, 1, sizeof(buf), f1);
+                       if (num == 0) {
+                               badCopy = true;
+                               LOG_BREAK(RES_IO_ERROR, "fread() failed!");
+                       }
+                       if (fwrite(buf, 1, num, f2) != num) {
+                               badCopy = true;
+                               LOG_BREAK(RES_IO_ERROR, "fwrite() failed!");
+                       }
+               }
+
+               fclose(f1);
+               fclose(f2);
+
+               if (badCopy) {
+                       const int r = remove(dst.c_str());
+                       if (r != 0) {
+                               WLOG("remove() failed: %d;", r);
+                       }
+                       return RES_IO_ERROR;
+               }
+
+               return RES_OK;
+       }
+}}}
+
+namespace gallery {
+
+       using ucl::MutexLock;
+
+       // MediaItem::Remover //
+
+       class MediaItem::Remover final : public BaseJob {
+       public:
+               friend class MediaItem::RemoverBuilder;
+               Remover(const NotiHandler &onComplete,
+                               const SharedRef<const MediaItems> &items) :
+                       BaseJob(onComplete, false),
+                       m_items(items)
+               {
+               }
+
+       protected:
+               // BaseJob //
+               virtual Result execute() final override
+               {
+                       Result result = RES_OK;
+
+                       MutexLock lock(getMediaMutex());
+
+                       for (auto &item: *m_items) {
+                               if (item) {
+                                       const Result tmpResult = item->removeFile();
+                                       if (isBad(tmpResult)) {
+                                               ELOG("item->removeFile() failed!");
+                                               if (isGood(result)) {
+                                                       result = tmpResult;
+                                               }
+                                       }
+                               } else {
+                                       ELOG("item is NULL!");
+                               }
+                       }
+
+                       return result;
+               }
+
+       private:
+               const SharedRef<const MediaItems> m_items;
+       };
+
+       // MediaItem::RemoverBuilder //
+
+       MediaItem::RemoverBuilder &MediaItem::RemoverBuilder::
+                       setItems(MediaItems items)
+       {
+               m_items = makeShared<MediaItems>(std::move(items));
+               return *this;
+       }
+
+       IJobSRef MediaItem::RemoverBuilder::build(
+                       const NotiHandler &onComplete) const
+       {
+               if (!onComplete) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "onComplete is NULL!");
+               }
+               if (isEmpty(m_items)) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!");
+               }
+
+               auto result = makeShared<Remover>(onComplete, m_items);
+
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+
+               return result;
+       }
+
+       // MediaItem::Saver //
+
+       class MediaItem::Saver final : public BaseJob {
+       public:
+               friend class MediaItem::SaverBuilder;
+               Saver(const NotiHandler &onComplete,
+                               const MediaItemSRef &item) :
+                       BaseJob(onComplete, false),
+                       m_item(item)
+               {
+               }
+
+       protected:
+               // BaseJob //
+               virtual Result execute() final override
+               {
+                       FAIL_RETURN(m_item->saveToDevice(),
+                                       "m_item->saveToDevice() failed!");
+                       return RES_OK;
+               }
+
+       private:
+               const MediaItemSRef m_item;
+       };
+
+       // MediaItem::SaverBuilder //
+
+       MediaItem::SaverBuilder &MediaItem::SaverBuilder::
+                       setItem(const MediaItemSRef &item)
+       {
+               m_item = item;
+               return *this;
+       }
+
+       IJobSRef MediaItem::SaverBuilder::build(
+                       const NotiHandler &onComplete) const
+       {
+               if (!onComplete) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "onComplete is NULL!");
+               }
+               if (!m_item) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_item is NULL!");
+               }
+
+               auto result = makeShared<Saver>(onComplete, m_item);
+
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+
+               return result;
+       }
+
+       // MediaItem //
+
+       MediaItem::MediaItem(const int flags, const MediaType type) :
+               m_flags(flags),
+               m_type(type),
+               m_resolutionX(0),
+               m_resolutionY(0),
+               m_isValid(false)
+       {
+       }
+
+       MediaItem::~MediaItem()
+       {
+               cancelThumbnailPathGet();
+       }
+
+       MediaItemSRef MediaItem::newInstance(const media_info_h media)
+       {
+               media_content_type_e contentType = MEDIA_CONTENT_TYPE_OTHERS;
+               FAIL_RETURN_VALUE(util::get(media_info_get_media_type, contentType,
+                               media), {}, "media_info_get_media_type() failed!");
+
+               auto result = makeShared<MediaItem>(FLAGS_FROM_MEDIA_DB,
+                               toMediaType(contentType));
+
+               FAIL_RETURN_VALUE(result->prepare(media), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       MediaItemSRef MediaItem::newInstance(std::string filePath)
+       {
+               util::removePrefix(filePath, impl::URI_PREFIX_FILE);
+
+               auto result = makeShared<MediaItem>(FLAGS_SIMPLE_FILE,
+                               impl::getFileMediaType(filePath));
+
+               FAIL_RETURN_VALUE(result->prepare(std::move(filePath)), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       Result MediaItem::prepare(const media_info_h media)
+       {
+               FAIL_RETURN(initThumbPath(media), "initThumbPath() failed!");
+
+               if (isEmpty(m_thumbPath)) {
+                       media_info_h mediaClone = nullptr;
+                       FAIL_RETURN(util::call(media_info_clone, &mediaClone, media),
+                                       "media_info_clone() failed!");
+                       m_media = mediaClone;
+               }
+
+               FAIL_RETURN(util::getNz(media_info_get_media_id, m_mediaId, media),
+                               "media_info_get_media_id() failed!");
+
+               FAIL_RETURN(util::getNz(media_info_get_file_path, m_filePath, media),
+                               "media_info_get_file_path() failed!");
+
+               if (m_type == MediaType::IMAGE) {
+                       prepareImage(media);
+               }
+
+               m_isValid = true;
+
+               return RES_OK;
+       }
+
+       Result MediaItem::prepareImage(const media_info_h media)
+       {
+               impl::AutoImageMeta imageMeta;
+
+               FAIL_RETURN(util::getNz(media_info_get_image, imageMeta, media),
+                               "media_info_get_image() failed!");
+
+               FAIL_RETURN(util::getNz(image_meta_get_width, m_resolutionX,
+                               imageMeta), "image_meta_get_width() failed!");
+
+               FAIL_RETURN(util::getNz(image_meta_get_height, m_resolutionY,
+                               imageMeta), "image_meta_get_height() failed!");
+
+               media_content_orientation_e orientation =
+                               MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
+               FAIL_RETURN(util::get(image_meta_get_orientation, orientation,
+                               imageMeta), "image_meta_get_orientation() failed!");
+
+               switch (orientation) {
+               case MEDIA_CONTENT_ORIENTATION_TRANSPOSE:
+               case MEDIA_CONTENT_ORIENTATION_ROT_90:
+               case MEDIA_CONTENT_ORIENTATION_TRANSVERSE:
+               case MEDIA_CONTENT_ORIENTATION_ROT_270:
+                       std::swap(m_resolutionX, m_resolutionY);
+                       break;
+               default:
+                       break;
+               }
+
+               return RES_OK;
+       }
+
+       Result MediaItem::initThumbPath(const media_info_h media) const
+       {
+               FAIL_RETURN(util::get(media_info_get_thumbnail_path, m_thumbPath,
+                               media), "media_info_get_thumbnail_path() failed!");
+               return RES_OK;
+       }
+
+       Result MediaItem::prepare(std::string filePath)
+       {
+               m_filePath = std::move(filePath);
+               m_isValid = true;
+               return RES_OK;
+       }
+
+       bool MediaItem::isValid() const
+       {
+               return m_isValid;
+       }
+
+       int MediaItem::getFlags() const
+       {
+               return m_flags;
+       }
+
+       MediaType MediaItem::getType() const
+       {
+               return m_type;
+       }
+
+       const std::string &MediaItem::getId() const
+       {
+               return m_mediaId;
+       }
+
+       Result MediaItem::getResolution(int &x, int &y) const
+       {
+               if (!(m_flags & FLAG_RESOLUTION)) {
+                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
+               }
+
+               x = m_resolutionX;
+               y = m_resolutionY;
+
+               return RES_OK;
+       }
+
+       const std::string &MediaItem::getFilePath() const
+       {
+               return m_filePath;
+       }
+
+       Result MediaItem::removeFile()
+       {
+               if (!(m_flags & FLAG_REMOVE)) {
+                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
+               }
+
+               const bool exists = ecore_file_exists(m_filePath.c_str());
+
+               if (exists && !ecore_file_can_write(m_filePath.c_str())) {
+                       LOG_RETURN(RES_FAIL, "File can't be removed!");
+               }
+
+               {
+                       MutexLock lock(getMediaMutex());
+
+                       const int ret = media_info_delete_from_db(m_mediaId.c_str());
+                       if (ret != 0) {
+                               LOG_RETURN(RES_FAIL, "media_info_delete_from_db() failed: %d", ret);
+                       }
+
+                       m_media = nullptr;
+                       m_isValid = false;
+               }
+
+               if (exists && !ecore_file_remove(m_filePath.c_str())) {
+                       FLOG("ecore_file_remove() failed! Attempting to rescan....");
+                       MutexLock lock(getMediaMutex());
+                       const int ret = media_content_scan_file(m_filePath.c_str());
+                       if (ret != 0) {
+                               ELOG("media_content_scan_file() failed: %d", ret);
+                       }
+                       return RES_FATAL;
+               }
+
+               return RES_OK;
+       }
+
+       Result MediaItem::saveToDevice()
+       {
+               if (!(m_flags & FLAG_SAVE)) {
+                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
+               }
+
+               int storageId = 0;
+               FAIL_RETURN(getInternalStorageId(storageId),
+                               "getInternalStorageId() failed!");
+
+               std::string imagesDir;
+               FAIL_RETURN(util::getNz(storage_get_directory, imagesDir,
+                               storageId, STORAGE_DIRECTORY_IMAGES),
+                               "storage_get_directory() failed!");
+
+               const std::string savePath = util::makeUniqueFilePath(
+                               m_filePath, imagesDir);
+
+               FAIL_RETURN(impl::copyFile(m_filePath, savePath), "copyFile() failed!");
+
+               {
+                       MutexLock lock(getMediaMutex());
+                       FAIL_RETURN(acquireMediaDbConnection(),
+                                       "acquireMediaDbConnection() failed!");
+                       const int ret = media_content_scan_file(savePath.c_str());
+                       releaseMediaDbConnection();
+                       if (ret == 0) {
+                               return RES_OK;
+                       }
+                       ELOG("media_content_scan_file() failed: %d", ret);
+               }
+
+               if (!ecore_file_remove(savePath.c_str())) {
+                       WLOG("ecore_file_remove() failed!");
+               }
+
+               return RES_FAIL;
+       }
+
+       Result MediaItem::getThumbnailPath(const ThumbnailPathGetCb &cb) const
+       {
+               if (!(m_flags & FLAG_THUMBNAIL)) {
+                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
+               }
+               if (!cb) {
+                       return RES_INVALID_ARGUMENTS;
+               }
+
+               if (isNotEmpty(m_thumbPath)) {
+                       cb(RES_OK, m_thumbPath);
+                       return RES_OK;
+               }
+
+               if (m_thumbCbProxy) {
+                       m_thumbCbProxy->callback = cb;
+                       return RES_FALSE;
+               }
+
+               auto cbProxy = util::makeUnique(new ThumbCbProxy{this, cb});
+
+               {
+                       MutexLock lock(getMediaMutex());
+
+                       FAIL_RETURN(util::call(media_info_create_thumbnail, m_media,
+                                       CALLBACK_B(ThumbCbProxy::completeCb), cbProxy.get()),
+                                       "media_info_create_thumbnail() failed!");
+               }
+
+               m_thumbCbProxy = std::move(cbProxy);
+
+               return RES_FALSE;
+       }
+
+       void MediaItem::cancelThumbnailPathGet() const
+       {
+               if (!m_thumbCbProxy) {
+                       return;
+               }
+
+               MutexLock lock(getMediaMutex());
+
+               const int ret = media_info_cancel_thumbnail(m_media);
+               if (ret != 0) {
+
+                       // XXX In this case complete callback will be called anyway
+                       // We need to report this issue to the platform
+                       m_thumbCbProxy->item = nullptr;
+                       m_thumbCbProxy.release();
+
+                       if (ret == MEDIA_CONTENT_ERROR_INVALID_OPERATION) {
+                               ILOG("Can't cancel. Thumbnail is already created.");
+                               FAIL_RETURN_VOID(initThumbPath(m_media),
+                                               "initThumbPath() failed!");
+                               return;
+                       }
+
+                       LOG_RETURN_VOID(RES_FAIL,
+                                       "media_info_cancel_thumbnail() failed: %d", ret);
+               }
+
+               m_thumbCbProxy.reset();
+       }
+
+       // ThumbCbProxy //
+
+       void MediaItem::ThumbCbProxy::completeCb(
+                       media_content_error_e error, const char *path)
+       {
+               if (!item) {
+                       delete this;
+                       return;
+               }
+
+               Result result = RES_OK;
+
+               if ((error != MEDIA_CONTENT_ERROR_NONE) || !path) {
+                       ELOG("Thumbnail generation failed: %d", error);
+                       result = RES_FAIL;
+               } else {
+                       item->m_thumbPath = path;
+                       item->m_media = nullptr;
+               }
+
+               const auto proxy = std::move(*item->m_thumbCbProxy);
+
+               item->m_thumbCbProxy.reset();
+
+               proxy.callback(result, proxy.item->m_thumbPath);
+       }
+}
diff --git a/gallery/model/MediaItem.h b/gallery/model/MediaItem.h
new file mode 100644 (file)
index 0000000..98491b1
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * 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_MODEL_MEDIA_ITEM_H__
+#define __GALLERY_MODEL_MEDIA_ITEM_H__
+
+#include <vector>
+
+#include <media_content.h>
+
+#include "ucl/misc/AutoHandle.h"
+
+#include "IJob.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(MediaItem);
+
+       using MediaItems = std::vector<MediaItemSRef>;
+
+       class MediaItem : public ucl::Polymorphic {
+       public:
+               using ThumbnailPathGetCb =
+                               ucl::WeakDelegate<void(ucl::Result, const std::string &path)>;
+
+               class Remover;
+               class RemoverBuilder final {
+               public:
+                       RemoverBuilder &setItems(MediaItems items);
+                       IJobSRef build(const NotiHandler &onComplete) const;
+               private:
+                       ucl::SharedRef<MediaItems> m_items;
+               };
+
+               class Saver;
+               class SaverBuilder final {
+               public:
+                       SaverBuilder &setItem(const MediaItemSRef &item);
+                       IJobSRef build(const NotiHandler &onComplete) const;
+               private:
+                       MediaItemSRef m_item;
+               };
+
+               enum {
+                       FLAG_THUMBNAIL = 1,
+                       FLAG_REMOVE = 2,
+                       FLAG_SAVE = 4,
+                       FLAG_RESOLUTION = 8,
+
+                       FLAGS_FROM_MEDIA_DB = (FLAG_THUMBNAIL | FLAG_REMOVE |
+                                       FLAG_RESOLUTION),
+                       FLAGS_SIMPLE_FILE = (FLAG_SAVE)
+               };
+
+       public:
+               static MediaItemSRef newInstance(media_info_h media);
+               static MediaItemSRef newInstance(std::string filePath);
+               virtual ~MediaItem();
+
+               bool isValid() const;
+               int getFlags() const;
+               MediaType getType() const;
+
+               const std::string &getId() const;
+
+               ucl::Result getResolution(int &x, int &y) const;
+
+               const std::string &getFilePath() const;
+
+               ucl::Result getThumbnailPath(const ThumbnailPathGetCb &cb) const;
+               void cancelThumbnailPathGet() const;
+
+               ucl::Result removeFile();
+               ucl::Result saveToDevice();
+
+       protected:
+               friend class ucl::ReffedObj<MediaItem>;
+               MediaItem(int flags, MediaType type);
+
+               ucl::Result prepare(media_info_h media);
+               ucl::Result prepareImage(media_info_h media);
+               ucl::Result prepare(std::string filePath);
+
+       private:
+               ucl::Result initThumbPath(media_info_h media) const;
+
+       private:
+               // XXX This proxy is needed to deal with cases when
+               // media_thumbnail_completed_cb can't be cancelled
+               struct ThumbCbProxy final {
+                       const MediaItem *item;
+                       ThumbnailPathGetCb callback;
+
+                       void completeCb(media_content_error_e error, const char *path);
+               };
+
+       private:
+               using AutoMediaInfo = ucl::AutoHandle<
+                               media_info_h, int, media_info_destroy>;
+
+       private:
+               const int m_flags;
+               const MediaType m_type;
+               std::string m_mediaId;
+               std::string m_filePath;
+               int m_resolutionX;
+               int m_resolutionY;
+               mutable AutoMediaInfo m_media;
+               mutable std::string m_thumbPath;
+               mutable std::unique_ptr<ThumbCbProxy> m_thumbCbProxy;
+               bool m_isValid;
+       };
+}
+
+#endif // __GALLERY_MODEL_MEDIA_ITEM_H__
diff --git a/gallery/model/SoundManager.cpp b/gallery/model/SoundManager.cpp
new file mode 100644 (file)
index 0000000..b56c0d4
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * 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 "SoundManager.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       SoundManagerSRef SoundManager::newInstance()
+       {
+               auto result = makeShared<SoundManager>();
+
+               FAIL_RETURN_VALUE(result->prepare(), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       SoundManager::SoundManager() :
+                       m_devConnChangedCbId(-1),
+                       m_devStateChangedCbId(-1),
+                       m_volumeChangedCbId(-1),
+                       m_currentMediaVolume(0),
+                       m_maxMediaVolume(0),
+                       m_isMediaDeviceReady(false)
+       {
+       }
+
+       SoundManager::~SoundManager()
+       {
+               if (m_devConnChangedCbId >= 0) {
+                       sound_manager_remove_device_connection_changed_cb(
+                                       m_devConnChangedCbId);
+               }
+               if (m_devStateChangedCbId >= 0) {
+                       sound_manager_remove_device_state_changed_cb(m_devStateChangedCbId);
+               }
+               if (m_volumeChangedCbId >= 0) {
+                       sound_manager_remove_volume_changed_cb(m_volumeChangedCbId);
+               }
+       }
+
+       Result SoundManager::prepare()
+       {
+               const int devMask = SOUND_DEVICE_ALL_MASK;
+
+               FAIL_RETURN(util::get(sound_manager_add_device_connection_changed_cb,
+                               m_devConnChangedCbId, devMask,
+                               CALLBACK_B(SoundManager::onDeviceConnectionChanged), this),
+                               "sound_manager_add_device_connection_changed_cb() failed!");
+
+               FAIL_RETURN(util::get(sound_manager_add_device_state_changed_cb,
+                               m_devStateChangedCbId, devMask,
+                               CALLBACK_B(SoundManager::onDeviceStateChanged), this),
+                               "sound_manager_add_device_state_changed_cb() failed!");
+
+               FAIL_RETURN(util::get(sound_manager_add_volume_changed_cb,
+                               m_volumeChangedCbId,
+                               CALLBACK_B(SoundManager::onVolumeChanged), this),
+                               "sound_manager_add_volume_changed_cb() failed!");
+
+               FAIL_RETURN(util::get(sound_manager_get_volume,
+                               m_currentMediaVolume, SOUND_TYPE_MEDIA),
+                               "sound_manager_get_max_volume() failed!");
+
+               FAIL_RETURN(util::get(sound_manager_get_max_volume,
+                               m_maxMediaVolume, SOUND_TYPE_MEDIA),
+                               "sound_manager_get_max_volume() failed!");
+
+               FAIL_RETURN(updateMediaDeviceState(),
+                               "updateMediaDeviceState() failed!");
+
+               return RES_OK;
+       }
+
+       bool SoundManager::isMediaDeviceReady() const
+       {
+               return m_isMediaDeviceReady;
+       }
+
+       int SoundManager::getCurrentMediaVolume() const
+       {
+               return m_currentMediaVolume;
+       }
+
+       int SoundManager::getMaxMediaVolume() const
+       {
+               return m_maxMediaVolume;
+       }
+
+       void SoundManager::addMediaDeviceStateChangeHandler(
+                       const NotiHandler &handler)
+       {
+               m_onMediaDeviceStateChange += handler;
+       }
+
+       void SoundManager::delMediaDeviceStateChangeHandler(
+                       const NotiHandler &handler)
+       {
+               m_onMediaDeviceStateChange -= handler;
+       }
+
+       void SoundManager::addMediaVolumeChangeHandler(const NotiHandler &handler)
+       {
+               m_onMediaVolumeChange += handler;
+       }
+
+       void SoundManager::delMediaVolumeChangeHandler(const NotiHandler &handler)
+       {
+               m_onMediaVolumeChange -= handler;
+       }
+
+       void SoundManager::setMediaDeviceState(const bool isReady)
+       {
+               if (isReady != m_isMediaDeviceReady) {
+                       m_isMediaDeviceReady = isReady;
+                       m_onMediaDeviceStateChange.dispatch();
+               }
+       }
+
+       void SoundManager::setCurrentMediaVolume(const int value)
+       {
+               if (value != m_currentMediaVolume) {
+                       m_currentMediaVolume = value;
+                       m_onMediaVolumeChange.dispatch();
+               }
+       }
+
+       Result SoundManager::updateMediaDeviceState()
+       {
+               sound_device_type_e devType = SOUND_DEVICE_BUILTIN_SPEAKER;
+               const int r = sound_manager_get_current_media_playback_device_type(
+                               &devType);
+               DLOG("devType: %d (r: %d);", devType, r);
+
+               switch (r) {
+               case 0:
+                       setMediaDeviceState(true);
+                       break;
+               case SOUND_MANAGER_ERROR_NO_DATA:
+                       setMediaDeviceState(false);
+                       break;
+               default:
+                       LOG_RETURN(RES_FAIL,
+                                       "sound_manager_get_current_media_playback_device_type() "
+                                       "failed: %d;", r);
+               }
+
+               return RES_OK;
+       }
+
+       void SoundManager::onDeviceConnectionChanged(sound_device_h device,
+                       bool isConnected)
+       {
+               updateMediaDeviceState();
+       }
+
+       void SoundManager::onDeviceStateChanged(sound_device_h device,
+                       sound_device_state_e state)
+       {
+               updateMediaDeviceState();
+       }
+
+       void SoundManager::onVolumeChanged(sound_type_e type, unsigned int volume)
+       {
+               if (type == SOUND_TYPE_MEDIA) {
+                       setCurrentMediaVolume(volume);
+               }
+       }
+}
diff --git a/gallery/model/SoundManager.h b/gallery/model/SoundManager.h
new file mode 100644 (file)
index 0000000..e5adddb
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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_MODEL_SOUND_MANAGER_H__
+#define __GALLERY_MODEL_SOUND_MANAGER_H__
+
+#include <sound_manager.h>
+
+#include "ucl/misc/Event.h"
+
+#include "types.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(SoundManager);
+
+       class SoundManager final : public ucl::NonCopyable {
+       public:
+               static SoundManagerSRef newInstance();
+
+               bool isMediaDeviceReady() const;
+
+               int getCurrentMediaVolume() const;
+               int getMaxMediaVolume() const;
+
+               void addMediaDeviceStateChangeHandler(const NotiHandler &handler);
+               void delMediaDeviceStateChangeHandler(const NotiHandler &handler);
+
+               void addMediaVolumeChangeHandler(const NotiHandler &handler);
+               void delMediaVolumeChangeHandler(const NotiHandler &handler);
+
+       private:
+               friend class ucl::ReffedObj<SoundManager>;
+               SoundManager();
+               ~SoundManager();
+
+               ucl::Result prepare();
+
+               void setMediaDeviceState(bool isReady);
+               void setCurrentMediaVolume(int value);
+
+               ucl::Result updateMediaDeviceState();
+
+               void onDeviceConnectionChanged(sound_device_h device, bool isConnected);
+               void onDeviceStateChanged(sound_device_h device,
+                               sound_device_state_e state);
+               void onVolumeChanged(sound_type_e type, unsigned int volume);
+
+       private:
+               ucl::Event<NotiHandler> m_onMediaDeviceStateChange;
+               ucl::Event<NotiHandler> m_onMediaVolumeChange;
+               int m_devConnChangedCbId;
+               int m_devStateChangedCbId;
+               int m_volumeChangedCbId;
+               int m_currentMediaVolume;
+               int m_maxMediaVolume;
+               bool m_isMediaDeviceReady;
+       };
+}
+
+#endif // __GALLERY_MODEL_SOUND_MANAGER_H__
diff --git a/gallery/model/common.h b/gallery/model/common.h
new file mode 100644 (file)
index 0000000..a46e1ff
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_MODEL_COMMON_H__
+#define __GALLERY_MODEL_COMMON_H__
+
+#include "impl/helpers.h"
+
+#include "gallery/common.h"
+
+#endif // __GALLERY_MODEL_COMMON_H__
diff --git a/gallery/model/impl/BaseJob.cpp b/gallery/model/impl/BaseJob.cpp
new file mode 100644 (file)
index 0000000..1a358fb
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * 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 "BaseJob.h"
+
+#include <Ecore.h>
+
+#include "common.h"
+
+namespace gallery {
+
+       BaseJob::BaseJob(const NotiHandler &onComplete,
+                       const bool isCancelable) :
+               m_onComplete(onComplete),
+               m_isCancelable(isCancelable),
+               m_result(RES_ILLEGAL_STATE),
+               m_selfPtr(new BaseJob *(this)),
+               m_isCancelled(0)
+       {
+       }
+
+       BaseJob::~BaseJob()
+       {
+               finish();
+       }
+
+       Result BaseJob::prepare()
+       {
+               if (!m_thread.start(
+                       [this]()
+                       {
+                               m_result = execute();
+                               notifyCompleteAsync();
+                       }
+                       )) {
+                       LOG_RETURN(RES_FAIL, "m_thread->start() failed!");
+               }
+               return RES_OK;
+       }
+
+       Result BaseJob::getResult() const
+       {
+               if (!m_thread.wasJoinded()) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Job is not complete!");
+               }
+               return m_result;
+       }
+
+       bool BaseJob::isCancelable() const
+       {
+               return m_isCancelable;
+       }
+
+       Result BaseJob::cancel()
+       {
+               if (!m_isCancelable) {
+                       LOG_RETURN(RES_NOT_SUPPORTED, "Not cancelable!");
+               }
+               if (isCancelled()) {
+                       return RES_FALSE;
+               }
+               m_isCancelled.store(true);
+               return RES_OK;
+       }
+
+       bool BaseJob::isCancelled() const
+       {
+               return m_isCancelled.load();
+       }
+
+       void BaseJob::notifyCompleteAsync()
+       {
+               ecore_main_loop_thread_safe_call_async(
+                       [](void *data)
+                       {
+                               const auto selfPtr = static_cast<BaseJob **>(data);
+                               const auto self = *selfPtr;
+                               delete selfPtr;
+                               if (self) {
+                                       self->m_selfPtr = nullptr;
+                                       self->finish();
+                               }
+                       },
+                       m_selfPtr);
+       }
+
+       void BaseJob::finish()
+       {
+               if (!m_thread.wasJoinded()) {
+                       m_thread.join();
+                       if (m_selfPtr) {
+                               *m_selfPtr = nullptr;
+                       }
+                       if (m_onComplete) {
+                               m_onComplete();
+                       }
+               }
+       }
+}
diff --git a/gallery/model/impl/BaseJob.h b/gallery/model/impl/BaseJob.h
new file mode 100644 (file)
index 0000000..42c6374
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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_MODEL_IMPL_BASE_JOB_H__
+#define __GALLERY_MODEL_IMPL_BASE_JOB_H__
+
+#include <atomic>
+
+#include "ucl/util/threading/Thread.h"
+
+#include "gallery/model/IJob.h"
+
+namespace gallery {
+
+       class BaseJob : public IJob {
+       public:
+               // IJob //
+
+               virtual ucl::Result getResult() const final override;
+               virtual bool isCancelable() const final override;
+               virtual ucl::Result cancel() final override;
+
+       protected:
+               BaseJob(const NotiHandler &onComplete,
+                               bool isCancelable);
+               virtual ~BaseJob();
+
+               ucl::Result prepare();
+
+               bool isCancelled() const;
+
+               virtual ucl::Result execute() = 0;
+
+       private:
+               void notifyCompleteAsync();
+               void finish();
+
+       private:
+               const NotiHandler m_onComplete;
+               const bool m_isCancelable;
+               ucl::Thread m_thread;
+               ucl::Result m_result;
+               BaseJob **m_selfPtr;
+               std::atomic_int m_isCancelled;
+       };
+}
+
+#endif // __GALLERY_MODEL_IMPL_BASE_JOB_H__
diff --git a/gallery/model/impl/GalleryAlbum.cpp b/gallery/model/impl/GalleryAlbum.cpp
new file mode 100644 (file)
index 0000000..fbe2ad6
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * 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 "GalleryAlbum.h"
+
+// Including next header in order to use: getpid().
+#include <unistd.h>
+
+#include "ucl/misc/TString.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       using ucl::TString;
+
+       const auto CONDITION = TString("%s=%d").format(
+                       MEDIA_TYPE, MEDIA_CONTENT_TYPE_IMAGE);
+
+       constexpr auto UPDATE_IDLE_TIMEOUT_SEC = 0.1;
+}}}
+
+namespace gallery {
+
+       using ucl::MutexLock;
+
+       GalleryAlbum::GalleryAlbum() :
+               m_pid(getpid()),
+               m_filter(nullptr),
+               m_noti(),
+               m_updateTimer(nullptr),
+               m_isValid(false)
+       {
+       }
+
+       GalleryAlbum::~GalleryAlbum()
+       {
+               stopUpdateTimer();
+               if (m_noti) {
+                       media_content_remove_db_updated_cb(m_noti);
+               }
+               if (m_filter) {
+                       const int ret = media_filter_destroy(m_filter);
+                       if (ret != 0) {
+                               WLOG("media_filter_destroy() failed: %d", ret);
+                       }
+               }
+       }
+
+       GalleryAlbumSRef GalleryAlbum::newInstance()
+       {
+               auto result = makeShared<GalleryAlbum>();
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+               return result;
+       }
+
+       Result GalleryAlbum::prepare()
+       {
+               int ret = 0;
+
+               ret = media_content_add_db_updated_cb(
+                               CALLBACK_B(GalleryAlbum::onContentDbUpdate), this, &m_noti);
+               if (ret != 0) {
+                       m_noti = {};
+                       LOG_RETURN(RES_FAIL,
+                                       "media_content_add_db_updated_cb() failed: %d", ret);
+               }
+
+               ret = media_filter_create(&m_filter);
+               if (ret != 0) {
+                       ELOG("media_filter_create() failed: %d", ret);
+                       m_filter = nullptr;
+                       return RES_FAIL;
+               }
+
+               ret = media_filter_set_condition(m_filter, impl::CONDITION.c_str(),
+                               MEDIA_CONTENT_COLLATE_DEFAULT);
+               if (ret != 0) {
+                       ELOG("media_filter_set_condition() failed: %d", ret);
+                       return RES_FAIL;
+               }
+
+               ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC,
+                               MEDIA_ADDED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
+               if (ret != 0) {
+                       ELOG("media_filter_set_order() failed: %d", ret);
+                       return RES_FAIL;
+               }
+
+               FAIL_RETURN(update(), "update() failed!");
+
+               return RES_OK;
+       }
+
+       void GalleryAlbum::onContentDbUpdate(
+                       media_content_error_e error, int pid,
+                       media_content_db_update_item_type_e update_item,
+                       media_content_db_update_type_e update_type,
+                       media_content_type_e media_type,
+                       char *uuid, char *path, char *mime_type)
+       {
+               if ((update_item == MEDIA_ITEM_FILE) &&
+                               (media_type == MEDIA_CONTENT_TYPE_IMAGE) &&
+                               ((pid != m_pid) || (update_type != MEDIA_CONTENT_DELETE))) {
+                       if (!resetUpdateTimer()) {
+                               update();
+                       }
+               }
+       }
+
+       bool GalleryAlbum::resetUpdateTimer()
+       {
+               stopUpdateTimer();
+
+               m_updateTimer = ecore_timer_add(impl::UPDATE_IDLE_TIMEOUT_SEC,
+                               CALLBACK_A(GalleryAlbum::onUpdateTimer), this);
+               if (!m_updateTimer) {
+                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
+               }
+
+               return true;
+       }
+
+       void GalleryAlbum::stopUpdateTimer()
+       {
+               if (m_updateTimer) {
+                       ecore_timer_del(m_updateTimer);
+                       m_updateTimer = nullptr;
+               }
+       }
+
+       Eina_Bool GalleryAlbum::onUpdateTimer()
+       {
+               m_updateTimer = nullptr;
+
+               update();
+
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       Result GalleryAlbum::update()
+       {
+               stopUpdateTimer();
+
+               MediaItems newItems;
+
+               {
+                       MutexLock lock(getMediaMutex());
+
+                       const int ret = media_info_foreach_media_from_db(m_filter,
+                               [](media_info_h media, void *user_data)
+                               {
+                                       MediaItems &newItems =
+                                                       (*static_cast<MediaItems *>(user_data));
+                                       auto item = MediaItem::newInstance(media);
+                                       if (!item) {
+                                               ELOG("MediaItem::newInstance() failed! Skipping");
+                                               return true;
+                                       }
+                                       newItems.emplace_back(std::move(item));
+                                       return true;
+                               },
+                               &newItems);
+
+                       if (ret != 0) {
+                               ELOG("media_info_foreach_media_from_db() failed: %d", ret);
+                               return RES_FAIL;
+                       }
+               }
+
+               swap(newItems, m_items);
+               m_isValid = true;
+
+               m_onChange.dispatch();
+
+               return RES_OK;
+       }
+
+       void GalleryAlbum::addChangeHandler(const NotiHandler &handler)
+       {
+               m_onChange += handler;
+       }
+
+       void GalleryAlbum::delChangeHandler(const NotiHandler &handler)
+       {
+               m_onChange -= handler;
+       }
+
+       Result GalleryAlbum::forEachMedia(EachCb cb) const
+       {
+               if (!m_isValid) {
+                       LOG_RETURN(RES_INVALID_DATA, "m_isValid: false;");
+               }
+
+               for (auto item: m_items) {
+                       if (!item->isValid()) {
+                               WLOG("Fragmented!");
+                       } else if (!cb(std::move(item))) {
+                               break;
+                       }
+               }
+
+               return RES_OK;
+       }
+
+       Result GalleryAlbum::getMediaCount(int &count) const
+       {
+               if (!m_isValid) {
+                       LOG_RETURN(RES_INVALID_DATA, "m_isValid: false;");
+               }
+
+               count = m_items.size();
+
+               return RES_OK;
+       }
+
+       void GalleryAlbum::defragment()
+       {
+               if (!m_isValid) {
+                       LOG_RETURN_VOID(RES_INVALID_DATA, "m_isValid: false;");
+               }
+
+               const auto newEnd = std::remove_if(
+                       m_items.begin(), m_items.end(),
+                       [](const MediaItemSRef &item)
+                       {
+                               return !item->isValid();
+                       });
+
+               if (newEnd != m_items.end()) {
+                       m_items.erase(newEnd, m_items.end());
+                       m_onChange.dispatch();
+               }
+       }
+}
diff --git a/gallery/model/impl/GalleryAlbum.h b/gallery/model/impl/GalleryAlbum.h
new file mode 100644 (file)
index 0000000..358e5b5
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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_MODEL_IMPL_GALLERY_ALBUM_H__
+#define __GALLERY_MODEL_IMPL_GALLERY_ALBUM_H__
+
+#include <vector>
+
+#include <Ecore.h>
+
+#include "ucl/misc/Event.h"
+
+#include "gallery/model/IMediaAlbum.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(GalleryAlbum);
+
+       class GalleryAlbum final : public IMediaAlbum {
+       public:
+               static GalleryAlbumSRef newInstance();
+               virtual ~GalleryAlbum();
+
+               // IMediaAlbum //
+
+               virtual void addChangeHandler(
+                               const NotiHandler &handler) final override;
+               virtual void delChangeHandler(
+                               const NotiHandler &handler) final override;
+
+               virtual ucl::Result forEachMedia(EachCb cb) const final override;
+               virtual ucl::Result getMediaCount(int &count) const final override;
+
+               virtual void defragment() final override;
+
+       private:
+               friend class ucl::ReffedObj<GalleryAlbum>;
+               GalleryAlbum();
+
+               ucl::Result prepare();
+
+               ucl::Result update();
+
+               bool resetUpdateTimer();
+               void stopUpdateTimer();
+
+               void onContentDbUpdate(
+                               media_content_error_e error, int pid,
+                               media_content_db_update_item_type_e update_item,
+                               media_content_db_update_type_e update_type,
+                               media_content_type_e media_type,
+                               char *uuid, char *path, char *mime_type);
+
+               Eina_Bool onUpdateTimer();
+
+       private:
+               const int m_pid;
+               filter_h m_filter;
+               media_content_noti_h m_noti;
+               Ecore_Timer *m_updateTimer;
+               ucl::Event<NotiHandler> m_onChange;
+               MediaItems m_items;
+               bool m_isValid;
+       };
+}
+
+#endif // __GALLERY_MODEL_IMPL_GALLERY_ALBUM_H__
diff --git a/gallery/model/impl/common.h b/gallery/model/impl/common.h
new file mode 100644 (file)
index 0000000..1b000dc
--- /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 __GALLERY_MODEL_IMPL_COMMON_H__
+#define __GALLERY_MODEL_IMPL_COMMON_H__
+
+#include "gallery/model/common.h"
+
+#endif // __GALLERY_MODEL_IMPL_COMMON_H__
diff --git a/gallery/model/impl/helpers.cpp b/gallery/model/impl/helpers.cpp
new file mode 100644 (file)
index 0000000..9bf5042
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * 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 "helpers.h"
+
+#include <Ecore_File.h>
+#include <storage.h>
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr auto UNIQUE_PATH_RESERVE = 10;
+
+       int MEDIA_DB_CONNECTION_COUNTER = 0;
+}}}
+
+namespace gallery {
+
+       using ucl::Mutex;
+
+       Mutex &getMediaMutex()
+       {
+               static Mutex mutex{true};
+               return mutex;
+       }
+
+       Result getInternalStorageId(int &result)
+       {
+               struct StorageIdRec final {
+                       int id;
+                       bool valid;
+               } storageIdRec {0, false};
+
+               const int ret = storage_foreach_device_supported(
+                       [](int storageId, storage_type_e type,
+                                       storage_state_e state, const char *path, void *userData)
+                       {
+                               if ((type != STORAGE_TYPE_INTERNAL) ||
+                                               (state != STORAGE_STATE_MOUNTED)) {
+                                       return true;
+                               }
+                               auto &storageIdRec = *static_cast<StorageIdRec *>(userData);
+                               storageIdRec.id = storageId;
+                               storageIdRec.valid = true;
+                               return false;
+                       },
+                       &storageIdRec);
+               if (ret != 0) {
+                       LOG_RETURN(RES_FAIL,
+                                       "storage_foreach_device_supported() failed: %d", ret);
+               }
+
+               if (!storageIdRec.valid) {
+                       LOG_RETURN(RES_FAIL, "Writable internal storage not found!");
+               }
+
+               result = storageIdRec.id;
+
+               return RES_OK;
+       }
+
+       Result acquireMediaDbConnection()
+       {
+               if (impl::MEDIA_DB_CONNECTION_COUNTER > 0) {
+                       ++impl::MEDIA_DB_CONNECTION_COUNTER;
+                       return RES_OK;
+               }
+
+               FAIL_RETURN(util::call(media_content_connect),
+                                       "media_content_connect() failed!");
+
+               impl::MEDIA_DB_CONNECTION_COUNTER = 1;
+
+               return RES_OK;
+       }
+
+       void releaseMediaDbConnection()
+       {
+               if (impl::MEDIA_DB_CONNECTION_COUNTER == 0) {
+                       WLOG("Not connected!");
+                       return;
+               }
+
+               if (impl::MEDIA_DB_CONNECTION_COUNTER == 1) {
+                       FAIL_LOG(util::call(media_content_disconnect),
+                                       "media_content_disconnect() failed!");
+               }
+
+               --impl::MEDIA_DB_CONNECTION_COUNTER;
+       }
+}
+
+namespace gallery { namespace util {
+
+       std::string extractFileName(const std::string &path)
+       {
+               const auto bsPos = path.rfind('/');
+               if (bsPos == (path.size() - 1)) {
+                       return {};
+               }
+               return path.substr(bsPos + 1);
+       }
+
+       std::string extractFileExtension(const std::string &name)
+       {
+               const auto dotPos = name.rfind('.');
+               if ((dotPos == std::string::npos) ||
+                               (dotPos == 0) || (dotPos == (name.size() - 1))) {
+                       return {};
+               }
+               return name.substr(dotPos + 1);
+       }
+
+       void splitFilePath(const std::string &path, std::string &directory,
+                       std::string &baseName, std::string &extension)
+       {
+               splitFileName(path, baseName, extension);
+               if (isNotEmpty(baseName)) {
+                       directory = path.substr(0, (path.size() - baseName.size() -
+                                       (isNotEmpty(extension) ? (extension.size() - 1) : 0)));
+               } else {
+                       directory = path;
+               }
+       }
+
+       void splitFileName(const std::string &path,
+                       std::string &baseName, std::string &extension)
+       {
+               baseName = extractFileName(path);
+               if (isNotEmpty(baseName)) {
+                       extension = extractFileExtension(baseName);
+                       if (isNotEmpty(extension)) {
+                               baseName.resize(baseName.size() - extension.size() - 1);
+                       }
+               } else {
+                       extension.clear();
+               }
+       }
+
+       std::string makeUniqueFilePath(const std::string &srcPath,
+                       const std::string &dstDir)
+       {
+               std::string baseName;
+               std::string extension;
+               splitFileName(srcPath, baseName, extension);
+
+               std::string result;
+               result.reserve(dstDir.size() + baseName.size() +
+                               extension.size() + impl::UNIQUE_PATH_RESERVE);
+
+               result = dstDir;
+               if (isNotEmpty(result) && (result.back() != '/')) {
+                       result += '/';
+               }
+               result += baseName;
+
+               const auto baseSize = result.size();
+
+               for (int counter = 2; ; ++counter) {
+                       if (isNotEmpty(extension)) {
+                               result += '.';
+                               result += extension;
+                       }
+                       if (!ecore_file_exists(result.c_str())) {
+                               break;
+                       }
+                       result.resize(baseSize);
+                       result += " (";
+                       result += std::to_string(counter);
+                       result += ')';
+               }
+
+               return result;
+       }
+}}
diff --git a/gallery/model/impl/helpers.h b/gallery/model/impl/helpers.h
new file mode 100644 (file)
index 0000000..5411c42
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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_MODEL_IMPL_HELPERS_H__
+#define __GALLERY_MODEL_IMPL_HELPERS_H__
+
+#include <media_content.h>
+
+#include "ucl/util/threading.h"
+
+#include "gallery/model/types.h"
+
+namespace gallery {
+
+       MediaType toMediaType(media_content_type_e contentType);
+
+       ucl::Mutex &getMediaMutex();
+
+       ucl::Result getInternalStorageId(int &result);
+
+       ucl::Result acquireMediaDbConnection();
+       void releaseMediaDbConnection();
+}
+
+namespace gallery { namespace util {
+
+       std::string extractFileName(const std::string &path);
+
+       std::string extractFileExtension(const std::string &name);
+
+       void splitFilePath(const std::string &path, std::string &directory,
+                       std::string &baseName, std::string &extension);
+
+       void splitFileName(const std::string &path,
+                       std::string &baseName, std::string &extension);
+
+       std::string makeUniqueFilePath(const std::string &srcPath,
+                       const std::string &dstDir);
+
+       bool beginsWith(const std::string &str, const std::string &prefix,
+                       bool caseSensitive = true);
+       bool removePrefix(std::string &str, const std::string &prefix,
+                       bool caseSensitive = true);
+}}
+
+#include "helpers.hpp"
+
+#endif // __GALLERY_MODEL_IMPL_HELPERS_H__
diff --git a/gallery/model/impl/helpers.hpp b/gallery/model/impl/helpers.hpp
new file mode 100644 (file)
index 0000000..56efe64
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+namespace gallery {
+
+       inline MediaType toMediaType(const media_content_type_e contentType)
+       {
+               switch (contentType) {
+               case MEDIA_CONTENT_TYPE_IMAGE: return MediaType::IMAGE;
+               case MEDIA_CONTENT_TYPE_VIDEO: return MediaType::VIDEO;
+               case MEDIA_CONTENT_TYPE_SOUND: return MediaType::SOUND;
+               case MEDIA_CONTENT_TYPE_MUSIC: return MediaType::MUSIC;
+               default:
+                       break;
+               }
+               return MediaType::OTHERS;
+       }
+}
+
+namespace gallery { namespace util {
+
+       inline bool beginsWith(const std::string &str, const std::string &prefix,
+                       bool caseSensitive)
+       {
+               if (caseSensitive) {
+                       return (str.compare(0, prefix.size(), prefix) == 0);
+               }
+               return (strncasecmp(str.c_str(), prefix.c_str(), prefix.size()) == 0);
+       }
+
+       inline bool removePrefix(std::string &str, const std::string &prefix,
+                       bool caseSensitive)
+       {
+               if (beginsWith(str, prefix, caseSensitive)) {
+                       str = str.substr(prefix.size());
+                       return true;
+               }
+               return false;
+       }
+}}
diff --git a/gallery/model/types.h b/gallery/model/types.h
new file mode 100644 (file)
index 0000000..38feee5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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_MODEL_TYPES_H__
+#define __GALLERY_MODEL_TYPES_H__
+
+#include "gallery/types.h"
+
+namespace gallery {
+
+       enum class MediaType {
+               IMAGE,
+               VIDEO,
+               SOUND,
+               MUSIC,
+               OTHERS
+       };
+}
+
+#endif // __GALLERY_MODEL_TYPES_H__
diff --git a/gallery/presenters/Instance.cpp b/gallery/presenters/Instance.cpp
new file mode 100644 (file)
index 0000000..e9b37b3
--- /dev/null
@@ -0,0 +1,371 @@
+/*
+ * 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 "Instance.h"
+
+#include <system_settings.h>
+
+#include "ucl/appfw/helpers.h"
+
+#include "pages/NoContentPage.h"
+#include "pages/ThumbnailPage.h"
+#include "pages/ViewerPage.h"
+#include "pages/VideoPlayerPage.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       // TODO Since feature is temporary using hard-coded path
+       constexpr auto MEDIA_FOLDER = "/opt/usr/home/owner/media";
+}}}
+
+namespace gallery {
+
+       using ucl::SysEvent;
+       using ucl::SysEventProvider;
+       using ucl::IInstanceContext;
+       using ucl::getResPath;
+
+       using ucl::Theme;
+       using ucl::Naviframe;
+
+       Instance::Instance(IRefCountObj &rc,
+                       SysEventProvider &sysEventProvider) :
+               RefCountAware(&rc),
+               m_sysEventProvider(sysEventProvider),
+               m_context(nullptr),
+               m_isScanInProgress(false),
+               m_isGroupMode(false)
+       {
+       }
+
+       Instance::~Instance()
+       {
+               stopMediaContentScan();
+               util::dispose(m_page);
+       }
+
+       Result Instance::onCreate(IInstanceContext *const context)
+       {
+               m_context = context;
+
+               m_win = m_context->getWindow();
+
+               FAIL_RETURN(setupTheme(), "setupTheme() failed!");
+
+               m_navi = Naviframe::Builder().
+                               build(m_win->getConformant());
+               if (!m_navi) {
+                       LOG_RETURN(RES_FAIL, "Naviframe::build() failed!");
+               }
+
+               m_win->getConformant().setContent(*m_navi);
+
+               FAIL_RETURN(util::createCircleSurface(*m_navi),
+                               "util::createCircleSurface() failed!");
+
+               m_sysEventProvider.addEventHandler(
+                               WEAK_DELEGATE(Instance::onSysEvent, asWeak(*this)));
+
+               return RES_OK;
+       }
+
+       Result Instance::setupTheme()
+       {
+               m_theme = Theme::create();
+               if (isNotValid(m_theme)) {
+                       LOG_RETURN(RES_FAIL, "Theme::create() failed!");
+               }
+
+               m_theme.addExtension(getResPath(THEME_EDJE_PATH));
+
+               m_win->setTheme(m_theme);
+
+               return RES_OK;
+       }
+
+       void Instance::onPause()
+       {
+               DLOG("PAUSE");
+
+               setInstancePaused(*m_win, true);
+       }
+
+       void Instance::onResume()
+       {
+               DLOG("RESUME");
+
+               setInstancePaused(*m_win, false);
+
+               if (m_gallery && SCAN_MEDIA_ON_RESUME) {
+                       rescanMediaContent();
+               }
+
+               ecore_animator_frametime_set(1.0 / 60.0);
+       }
+
+       void Instance::rescanMediaContent()
+       {
+               stopMediaContentScan();
+               startMediaContentScan();
+       }
+
+       void Instance::stopMediaContentScan()
+       {
+               if (m_isScanInProgress) {
+                       m_isScanInProgress = false;
+                       DLOG("Scan is in progress. Terminating...");
+                       const int ret = media_content_cancel_scan_folder(
+                                       impl::MEDIA_FOLDER);
+                       if (ret != 0) {
+                               WLOG("media_content_cancel_scan_folder() failed: %d", ret);
+                       }
+               }
+       }
+
+       void Instance::startMediaContentScan()
+       {
+               DLOG("Starting media scan...");
+
+               int ret = media_content_scan_folder(impl::MEDIA_FOLDER, true,
+                               CALLBACK_B(Instance::onScanComplete), this);
+               if (ret != 0) {
+                       ELOG("media_content_scan_folder() failed: %d", ret);
+                       return;
+               }
+
+               m_isScanInProgress = true;
+       }
+
+       void Instance::onScanComplete(media_content_error_e error)
+       {
+               DLOG("Media scan complete. error: %d", error);
+
+               m_isScanInProgress = false;
+       }
+
+       void Instance::onAppControl(app_control_h appControl)
+       {
+               DLOG("APP CONTROL");
+
+               if (isBad(handleAppControl(appControl))) {
+                       DLOG("Terminating the application...");
+                       m_context->exitApp();
+                       return;
+               }
+
+               if (!m_win->isVisible()) {
+                       DLOG("Show the window.");
+                       show(*m_win);
+               }
+       }
+
+       Result Instance::handleAppControl(app_control_h appControl)
+       {
+               std::string operation;
+               FAIL_LOG(util::getNz(app_control_get_operation, operation, appControl),
+                       "app_control_get_operation() failed!");
+
+               app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE;
+               FAIL_LOG(util::get(app_control_get_launch_mode, mode, appControl),
+                       "app_control_get_launch_mode() failed!");
+
+               DLOG("operation: %s; mode: %d;", operation.c_str(), mode);
+
+               switch (mode) {
+               case APP_CONTROL_LAUNCH_MODE_SINGLE:
+                       return handleSingleMode(operation, appControl);
+               case APP_CONTROL_LAUNCH_MODE_GROUP:
+                       return handleGroupMode(operation, appControl);
+               default:
+                       ELOG("Invalid mode: %d;", mode);
+                       break;
+               }
+
+               if (!m_page) {
+                       LOG_RETURN(RES_FAIL, "m_page is NULL");
+               }
+
+               return RES_OK;
+       }
+
+       Result Instance::handleSingleMode(const std::string &operation,
+                               app_control_h appControl)
+       {
+               FAIL_RETURN(ensureGalleryModel(), "ensureGalleryModel() failed!");
+
+               if (const auto page = m_page.lock()) {
+                       if (operation == APP_CONTROL_OPERATION_MAIN) {
+                               page->deleteTo();
+                       }
+               } else if (isEmpty(m_gallery->getAlbum())) {
+                       createNoContentPage();
+               } else {
+                       createThumbnailPage();
+               }
+
+               return RES_OK;
+       }
+
+       Result Instance::handleGroupMode(const std::string &operation,
+                       app_control_h appControl)
+       {
+               if (m_page) {
+                       WLOG("Page is already created. Ignoring second request!");
+                       return RES_OK;
+               }
+
+               if (operation == APP_CONTROL_OPERATION_VIEW) {
+                       std::string uri;
+                       FAIL_RETURN(util::getNz(app_control_get_uri, uri, appControl),
+                               "app_control_get_uri() failed!");
+
+                       const auto media = MediaItem::newInstance(std::move(uri));
+                       if (!media) {
+                               LOG_RETURN(RES_FAIL, "MediaItem::newInstance() failed!");
+                       }
+
+                       switch (media->getType()) {
+                       case MediaType::IMAGE:
+                               createViewerPage(media);
+                               break;
+                       case MediaType::VIDEO:
+                               createVideoPlayerPage(media);
+                               break;
+                       default:
+                               LOG_RETURN(RES_NOT_SUPPORTED,
+                                               "Media type is not supported: %d;", media->getType());
+                       }
+
+               } else {
+                       WLOG("Operation not supported for current mode!");
+                       return RES_NOT_SUPPORTED;
+               }
+
+               m_isGroupMode = true;
+
+               return RES_OK;
+       }
+
+       Result Instance::ensureGalleryModel()
+       {
+               if (m_gallery) {
+                       return RES_FALSE;
+               }
+
+               m_gallery = Gallery::newInstance();
+               if (!m_gallery) {
+                       LOG_RETURN(RES_FAIL, "Gallery::newInstance() failed!");
+               }
+
+               m_gallery->getAlbum()->addChangeHandler(WEAK_DELEGATE(
+                               Instance::onAlbumChanged, asWeak(*this)));
+
+               return RES_OK;
+       }
+
+       void Instance::createNoContentPage()
+       {
+               DLOG("Creating NoContentPage.");
+               m_page = NoContentPage::Builder().setNaviframe(m_navi).
+                               build(WEAK_DELEGATE(
+                                       Instance::onPageExitRequest, asWeak(*this)));
+       }
+
+       void Instance::createThumbnailPage()
+       {
+               DLOG("Creating ThumbnailPage.");
+               FAIL_RETURN_VOID(ensureGalleryModel(), "ensureGalleryModel() failed!");
+
+               m_page = ThumbnailPage::Builder().setNaviframe(m_navi).
+                               setAlbum(m_gallery->getAlbum()).
+                               build(WEAK_DELEGATE(
+                                       Instance::onPageExitRequest, asWeak(*this)));
+       }
+
+       void Instance::createViewerPage(const MediaItemSRef &media)
+       {
+               DLOG("Creating ViewerPage.");
+               m_page = ViewerPage::Builder().setNaviframe(m_navi).
+                               setMedia(media).
+                               setExitOnZoomOut(false).
+                               build(WEAK_DELEGATE(
+                                       Instance::onPageExitRequest, asWeak(*this)));
+       }
+
+       void Instance::createVideoPlayerPage(const MediaItemSRef &media)
+       {
+               DLOG("Creating VideoPlayerPage.");
+               m_page = VideoPlayerPage::Builder().setNaviframe(m_navi).
+                               setMedia(media).
+                               build(WEAK_DELEGATE(
+                                       Instance::onPageExitRequest, asWeak(*this)));
+       }
+
+       void Instance::onAlbumChanged()
+       {
+               if (isEmpty(m_gallery->getAlbum())) {
+                       if (auto page = dynamicRefCast<ThumbnailPage>(m_page).lock()) {
+                               util::dispose(page);
+                               createNoContentPage();
+                       }
+               } else {
+                       if (auto page = dynamicRefCast<NoContentPage>(m_page).lock()) {
+                               util::dispose(page);
+                               createThumbnailPage();
+                       }
+               }
+       }
+
+       void Instance::onPageExitRequest(Page &page)
+       {
+               if (page.isAtBottom()) {
+                       DLOG("Bottom page.");
+                       if (m_isGroupMode) {
+                               DLOG("In group mode. Exit the application...");
+                               m_context->exitApp();
+                       } else {
+                               DLOG("Lowering the window.");
+                               m_win->lower();
+                       }
+               } else {
+                       DLOG("Exit page.");
+                       page.exit();
+               }
+       }
+
+       void Instance::onSysEvent(const SysEvent sysEvent)
+       {
+               switch(sysEvent) {
+               case SysEvent::LANGUAGE_CHANGED:
+                       DLOG("SysEvent::LANGUAGE_CHANGED");
+                       {
+                               char *locale = NULL;
+                               system_settings_get_value_string(
+                                               SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+                               elm_language_set(locale);
+                               free(locale);
+                       }
+                       break;
+               default:
+                       DLOG("sysEvent: %d", sysEvent);
+                       break;
+               }
+       }
+}
diff --git a/gallery/presenters/Instance.h b/gallery/presenters/Instance.h
new file mode 100644 (file)
index 0000000..d1de739
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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_INSTANCE_H__
+#define __GALLERY_PRESENTERS_INSTANCE_H__
+
+#include "ucl/appfw/IInstance.h"
+#include "ucl/appfw/IInstanceAppControlExt.h"
+#include "ucl/appfw/SysEventProvider.h"
+
+#include "ucl/gui/Theme.h"
+#include "ucl/gui/Naviframe.h"
+
+#include "gallery/model/Gallery.h"
+
+#include "base/Page.h"
+
+namespace gallery {
+
+       class Instance final : public ucl::RefCountAware,
+                       public ucl::IInstance,
+                       public ucl::IInstanceAppControlExt {
+       public:
+               Instance(ucl::IRefCountObj &rc,
+                               ucl::SysEventProvider &sysEventProvider);
+               virtual ~Instance();
+
+               // IInstance //
+
+               virtual ucl::Result onCreate(
+                               ucl::IInstanceContext *context) final override;
+               virtual void onPause() final override;
+               virtual void onResume() final override;
+
+               // IInstanceAppControlExt //
+
+               virtual void onAppControl(app_control_h appControl) final override;
+
+       private:
+               ucl::Result setupTheme();
+
+               void rescanMediaContent();
+               void stopMediaContentScan();
+               void startMediaContentScan();
+               void onScanComplete(media_content_error_e error);
+
+               ucl::Result handleAppControl(app_control_h appControl);
+               ucl::Result handleSingleMode(const std::string &operation,
+                               app_control_h appControl);
+               ucl::Result handleGroupMode(const std::string &operation,
+                               app_control_h appControl);
+
+               ucl::Result ensureGalleryModel();
+
+               void createNoContentPage();
+               void createThumbnailPage();
+               void createViewerPage(const MediaItemSRef &media);
+               void createVideoPlayerPage(const MediaItemSRef &media);
+
+               void onAlbumChanged();
+               void onPageExitRequest(Page &page);
+
+               void onSysEvent(const ucl::SysEvent sysEvent);
+
+       private:
+               ucl::SysEventProvider &m_sysEventProvider;
+               ucl::IInstanceContext *m_context;
+
+               GallerySRef m_gallery;
+               bool m_isScanInProgress;
+
+               ucl::WindowSRef m_win;
+               ucl::Theme m_theme;
+               ucl::NaviframeSRef m_navi;
+
+               PageWRef m_page;
+
+               bool m_isGroupMode;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_INSTANCE_H__
diff --git a/gallery/presenters/InstanceManager.cpp b/gallery/presenters/InstanceManager.cpp
new file mode 100644 (file)
index 0000000..459eede
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 "InstanceManager.h"
+
+#include "Instance.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       using ucl::AppParam;
+       using ucl::AppParams;
+       using ucl::IInstanceSRef;
+
+       InstanceManager::InstanceManager() :
+               InstanceManagerBase(AppParams().
+                               set(AppParam::WINDOW_NAME, WINDOW_NAME).
+                               set(AppParam::BASE_SCALE, BASE_SCALE))
+       {
+       }
+
+       IInstanceSRef InstanceManager::newInstance() const
+       {
+               return makeShared<Instance>(getSysEventProvider());
+       }
+}
diff --git a/gallery/presenters/InstanceManager.h b/gallery/presenters/InstanceManager.h
new file mode 100644 (file)
index 0000000..f45dc0a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_INSTANCE_MANAGER_H__
+#define __GALLERY_PRESENTERS_INSTANCE_MANAGER_H__
+
+#include "ucl/appfw/InstanceManagerBase.h"
+
+namespace gallery {
+
+       class InstanceManager final : public ucl::InstanceManagerBase {
+       public:
+               InstanceManager();
+
+               // ucl::InstanceManagerBase //
+
+               virtual ucl::IInstanceSRef newInstance() const final override;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_INSTANCE_MANAGER_H__
diff --git a/gallery/presenters/base/Dialog.cpp b/gallery/presenters/base/Dialog.cpp
new file mode 100644 (file)
index 0000000..07a91b4
--- /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 "Dialog.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       Dialog::Dialog(IRefCountObj &rc) :
+               GuiPresenter(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);
+
+               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_selfRef.reset();
+
+                       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/gallery/presenters/base/Dialog.h b/gallery/presenters/base/Dialog.h
new file mode 100644 (file)
index 0000000..3092f68
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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_BASE_DIALOG_H__
+#define __GALLERY_PRESENTERS_BASE_DIALOG_H__
+
+#include "ucl/gui/StyledWidget.h"
+
+#include "ucl/mvp/GuiPresenter.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(Dialog);
+
+       class Dialog : public ucl::GuiPresenter,
+                       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;
+       private:
+               DialogSRef m_selfRef;
+               bool m_isDismissed;
+       };
+}
+
+#include "Dialog.hpp"
+
+#endif // __GALLERY_PRESENTERS_BASE_DIALOG_H__
diff --git a/gallery/presenters/base/Dialog.hpp b/gallery/presenters/base/Dialog.hpp
new file mode 100644 (file)
index 0000000..5bd8ecb
--- /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(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+                               "GuiPresenter::prepare() failed!");
+
+               UCL_FAIL_RETURN(createPopup(parent, popupType),
+                               "createPopup() failed!");
+
+               UCL_FAIL_RETURN(onPrepare(), "onPrepare() failed!");
+
+               m_selfRef = asShared(*this);
+
+               return ucl::RES_OK;
+       }
+}
diff --git a/gallery/presenters/base/Page.cpp b/gallery/presenters/base/Page.cpp
new file mode 100644 (file)
index 0000000..0aeb96d
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * 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 "Page.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr SmartEvent TOP_PAGE_CHANGED {"ucl,top,page,changed"};
+}}}
+
+namespace gallery {
+
+       using ucl::NaviItem;
+       using ucl::NaviframeSRef;
+
+       using ucl::NAVI_TRANSITION_STARTED;
+       using ucl::NAVI_TRANSITION_FINISHED;
+
+       Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
+                       const ExitRequestHandler &onExitRequest) :
+               GuiPresenter(rc),
+               m_navi(navi),
+               m_onExitRequest(onExitRequest)
+       {
+               UCL_ASSERT(navi, "navi is NULL!");
+               UCL_ASSERT(onExitRequest, "onExitRequest is NULL!");
+
+               deactivateBy(m_navi.get());
+       }
+
+       Page::~Page()
+       {
+       }
+
+       Result Page::preparePart2()
+       {
+               if (!m_item) {
+                       UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL");
+               }
+
+               Evas_Object *content = m_item.getContent();
+               if (!content) {
+                       LOG_RETURN(RES_FAIL, "content is NULL");
+               }
+
+               m_navi->addEventHandler(NAVI_TRANSITION_STARTED,
+                               WEAK_DELEGATE(Page::onTransitionStarted, asWeak(*this)));
+
+               m_navi->addEventHandler(NAVI_TRANSITION_FINISHED,
+                               WEAK_DELEGATE(Page::onTransitionFinished, asWeak(*this)));
+
+               m_navi->addEventHandler(impl::TOP_PAGE_CHANGED,
+                               WEAK_DELEGATE(Page::onTopPageChanged, asWeak(*this)));
+
+               eext_object_event_callback_add(content, EEXT_CALLBACK_BACK,
+                               CALLBACK_A(Page::onHWBackKey), this);
+
+               m_item.setData(this);
+               m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
+
+               m_selfRef = asShared(*this);
+
+               if (!m_navi->isInTransition() && isAtTop()) {
+                       dispatchTopPageChanged();
+               }
+
+               return RES_OK;
+       }
+
+       void Page::dispatchTopPageChanged()
+       {
+               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)
+       {
+               m_item = nullptr;
+               m_selfRef.reset();
+       }
+
+       void Page::exit()
+       {
+               if (isAtTop() && !isAtBottom() && !m_navi->isInTransition()) {
+                       m_navi->pop();
+                       m_item = nullptr;
+               } else {
+                       dispose();
+               }
+       }
+
+       void Page::dispose()
+       {
+               if (m_item) {
+                       if (isAtTop()) {
+                               m_item.del();
+                               dispatchTopPageChanged();
+                       } else {
+                               m_item.del();
+                       }
+               }
+       }
+
+       bool Page::isDisposed() const
+       {
+               return m_item;
+       }
+
+       void Page::popTo()
+       {
+               if (m_item && !isAtTop()) {
+                       m_item.popTo();
+               }
+       }
+
+       void Page::deleteTo()
+       {
+               if (m_item && !isAtTop()) {
+                       while (!isAtTop()) {
+                               m_navi->getTopItem().del();
+                       }
+                       dispatchTopPageChanged();
+               }
+       }
+
+       void Page::promote()
+       {
+               if (m_item && !isAtTop()) {
+                       m_item.promote();
+               }
+       }
+
+       NaviItem Page::getItem()
+       {
+               return m_item;
+       }
+
+       void Page::requestExit()
+       {
+               if (m_onExitRequest) {
+                       m_onExitRequest(*this);
+               } else {
+                       WLOG("m_onExitRequest is NULL");
+                       exit();
+               }
+       }
+
+       void Page::updateActiveState()
+       {
+               if (isAtTop()) {
+                       activateBy(m_navi.get());
+               } else {
+                       deactivateBy(m_navi.get());
+               }
+       }
+
+       void Page::onTransitionStarted(Widget &widget, void *eventInfo)
+       {
+               deactivateBy(m_navi.get());
+       }
+
+       void Page::onTransitionFinished(Widget &widget, void *eventInfo)
+       {
+               updateActiveState();
+       }
+
+       void Page::onTopPageChanged(Widget &widget, void *eventInfo)
+       {
+               updateActiveState();
+       }
+
+       void Page::onHWBackKey(Evas_Object *obj, void *eventInfo)
+       {
+               if (isActive()) {
+                       onBackKey();
+               }
+       }
+
+       void Page::onBackKey()
+       {
+               requestExit();
+       }
+}
diff --git a/gallery/presenters/base/Page.h b/gallery/presenters/base/Page.h
new file mode 100644 (file)
index 0000000..357a36e
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * 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_BASE_PAGE_H__
+#define __GALLERY_PRESENTERS_BASE_PAGE_H__
+
+#include "ucl/gui/Naviframe.h"
+
+#include "ucl/mvp/GuiPresenter.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(Page);
+
+       class Page : public ucl::GuiPresenter,
+                       public ucl::IDisposable {
+       public:
+               using ExitRequestHandler = ucl::WeakDelegate<void(Page &page)>;
+
+       public:
+               ucl::Naviframe &getNaviframe();
+
+               bool isAtTop() const;
+               bool isAtBottom() const;
+
+               void exit();
+
+               void popTo();
+               void deleteTo();
+               void promote();
+
+               template <class ...ARGS>
+               ucl::NaviItem insertAfter(ARGS &&...args);
+
+               template <class ...ARGS>
+               ucl::NaviItem insertBefore(ARGS &&...args);
+
+               // ucl::IDisposable //
+
+               virtual void dispose() override;
+               virtual bool isDisposed() const final override;
+
+       protected:
+               Page(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
+                               const ExitRequestHandler &onExitRequest);
+               virtual ~Page();
+
+               template <class ON_PREPARE>
+               ucl::Result prepare(ON_PREPARE &&onPrepare);
+
+               ucl::NaviItem getItem();
+
+               void requestExit();
+
+               virtual void onBackKey();
+
+       private:
+               ucl::Result preparePart2();
+
+               void dispatchTopPageChanged();
+
+               void updateActiveState();
+
+               void onTransitionStarted(ucl::Widget &widget, void *eventInfo);
+               void onTransitionFinished(ucl::Widget &widget, void *eventInfo);
+               void onTopPageChanged(ucl::Widget &widget, void *eventInfo);
+
+               void onHWBackKey(Evas_Object *obj, void *eventInfo);
+               void onItemDel(Evas_Object *obj, void *eventInfo);
+
+       private:
+               const ucl::NaviframeSRef m_navi;
+               const ExitRequestHandler m_onExitRequest;
+               ucl::NaviItem m_item;
+               PageSRef m_selfRef;
+       };
+
+       // Non-member functions //
+
+       bool isLast(const Page &page);
+}
+
+#include "Page.hpp"
+
+#endif // __GALLERY_PRESENTERS_BASE_PAGE_H__
diff --git a/gallery/presenters/base/Page.hpp b/gallery/presenters/base/Page.hpp
new file mode 100644 (file)
index 0000000..426445a
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 Page::prepare(ON_PREPARE &&onPrepare)
+       {
+               UCL_FAIL_RETURN(GuiPresenter::prepare(*m_navi),
+                               "GuiPresenter::prepare() failed!");
+
+               UCL_FAIL_RETURN(onPrepare(m_item), "onPrepare() failed!");
+
+               return preparePart2();
+       }
+
+       template <class ...ARGS>
+       inline ucl::NaviItem Page::insertAfter(ARGS &&...args)
+       {
+               return m_navi->insertAfter(m_item, std::forward<ARGS>(args)...);
+       }
+
+       template <class ...ARGS>
+       inline ucl::NaviItem Page::insertBefore(ARGS &&...args)
+       {
+               return m_navi->insertBefore(m_item, std::forward<ARGS>(args)...);
+       }
+
+       inline ucl::Naviframe &Page::getNaviframe()
+       {
+               UCL_ASSERT(m_navi, "m_navi is NULL");
+               return *m_navi;
+       }
+
+       inline bool Page::isAtTop() const
+       {
+               return (m_navi->getTopItem() == m_item);
+       }
+
+       inline bool Page::isAtBottom() const
+       {
+               return (m_navi->getBottomItem() == m_item);
+       }
+
+       // Non-member functions //
+
+       inline bool isLast(const Page &page)
+       {
+               return (page.isAtBottom() && page.isAtTop());
+       }
+}
diff --git a/gallery/presenters/base/common.h b/gallery/presenters/base/common.h
new file mode 100644 (file)
index 0000000..2444b53
--- /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 __GALLERY_PRESENTERS_BASE_COMMON_H__
+#define __GALLERY_PRESENTERS_BASE_COMMON_H__
+
+#include "gallery/presenters/common.h"
+
+#endif // __GALLERY_PRESENTERS_BASE_COMMON_H__
diff --git a/gallery/presenters/common.h b/gallery/presenters/common.h
new file mode 100644 (file)
index 0000000..6961b7f
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_COMMON_H__
+#define __GALLERY_PRESENTERS_COMMON_H__
+
+#include "misc/helpers.h"
+
+#include "gallery/view/common.h"
+
+#endif // __GALLERY_PRESENTERS_COMMON_H__
diff --git a/gallery/presenters/dialogs/AlertDialog.cpp b/gallery/presenters/dialogs/AlertDialog.cpp
new file mode 100644 (file)
index 0000000..016fb31
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * 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 "AlertDialog.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr EoDataKey BTN_EVENT_DATA {"gallery,btn,event,data"};
+
+       constexpr ElmStyle POPUP_STYLE {"circle"};
+       constexpr EdjePart PART_BUTTON1 {"button1"};
+       constexpr EdjePart PART_BUTTON2 {"button2"};
+
+       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)
+       {
+               return reinterpret_cast<void *>(static_cast<intptr_t>(event));
+       }
+
+       AlertDialog::Event asEvent(void *const data)
+       {
+               return static_cast<AlertDialog::Event>(
+                               reinterpret_cast<intptr_t>(data));
+       }
+
+       AlertDialog::Event getEvent(const Widget &widget)
+       {
+               return asEvent(widget.getData(BTN_EVENT_DATA));
+       }
+}}}
+
+namespace gallery {
+
+       using ucl::Layout;
+
+       using ucl::PART_TITLE;
+
+       // AlertDialog::Builder //
+
+       AlertDialog::Builder::Builder() :
+               m_type(Type::OK)
+       {
+       }
+
+       AlertDialog::Builder &AlertDialog::Builder::setType(const Type type)
+       {
+               m_type = type;
+               return *this;
+       }
+
+       AlertDialog::Builder &AlertDialog::Builder::setTitle(TString title)
+       {
+               m_title = std::move(title);
+               return *this;
+       }
+
+       AlertDialog::Builder &AlertDialog::Builder::setText(TString text)
+       {
+               m_text = std::move(text);
+               return *this;
+       }
+
+       AlertDialog::Builder &AlertDialog::Builder::setHandler(
+                       const EventHandler &handler)
+       {
+               m_handler = handler;
+               return *this;
+       }
+
+       AlertDialogWRef AlertDialog::Builder::build(ElmWidget &parent) const
+       {
+               if (!m_handler) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_handler is NULL");
+               }
+
+               auto result = makeShared<AlertDialog>(m_handler);
+
+               FAIL_RETURN_VALUE(result->prepare(parent, m_type), {},
+                               "result->prepare() failed!");
+
+               result->setTitle(m_title);
+               result->setText(m_text);
+               result->open();
+
+               return result;
+       }
+
+       // AlertDialog //
+
+       AlertDialog::AlertDialog(IRefCountObj &rc,
+                       const EventHandler &handler) :
+               Dialog(rc),
+               m_handler(handler)
+       {
+       }
+
+       Result AlertDialog::prepare(ElmWidget &parent, const Type type)
+       {
+               FAIL_RETURN(Dialog::prepare(parent, PopupType::NORMAL,
+                               [this, type]() { return doPrepare(type); }),
+                               "Dialog::prepare() failed!");
+
+               return RES_OK;
+       }
+
+       Result AlertDialog::doPrepare(const Type type)
+       {
+               m_popup->setStyle(impl::POPUP_STYLE);
+
+               const auto layoutTheme = ((type == Type::OK) ?
+                               impl::LAYOUT_POPUP_1BUTTON :
+                               impl::LAYOUT_POPUP_2BUTTONS);
+               FAIL_RETURN(createLayout(layoutTheme), "createLayout() failed!");
+
+               if (type == Type::OK) {
+                       FAIL_RETURN(prepareOkPopup(), "prepareOkPopup() failed!");
+               } else {
+                       FAIL_RETURN(prepareOkCancelPopup(), "prepareOkPopup() failed!");
+               }
+
+               return RES_OK;
+       }
+
+       Result AlertDialog::createLayout(const LayoutTheme theme)
+       {
+               const auto layout = Layout::Builder().
+                               setTheme(theme).
+                               setIsOwner(false).
+                               build(*m_popup);
+               if (!layout) {
+                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+               }
+
+               m_popup->setContent(*layout);
+
+               m_layout = layout;
+
+               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)
+       {
+               const auto btn = makeShared<StyledWidget>(
+                               elm_button_add(*m_popup), false);
+               btn->setStyle(btnStyle);
+               m_popup->setContent(*btn, part);
+
+               if (isValid(iconTheme)) {
+                       const auto icon = Layout::Builder().
+                                       setTheme(iconTheme).
+                                       setIsOwner(false).
+                                       build(*btn);
+                       if (!icon) {
+                               LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+                       }
+                       btn->setContent(*icon);
+               }
+
+               if (isNotEmpty(text)) {
+                       btn->setText(text);
+               }
+
+               show(*btn);
+
+               btn->setData(impl::BTN_EVENT_DATA, impl::asData(event));
+               btn->addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
+                               AlertDialog::onBtnClick, asWeak(*this)));
+
+               return RES_OK;
+       }
+
+       void AlertDialog::setTitle(const TString &title)
+       {
+               if (const auto layout = m_layout.lock()) {
+                       layout->setText(title, PART_TITLE);
+               }
+       }
+
+       void AlertDialog::setText(const TString &text)
+       {
+               if (const auto layout = m_layout.lock()) {
+                       layout->setText(text);
+               }
+       }
+
+       void AlertDialog::handleEvent(const Event event)
+       {
+               if (dispatchEvent(event)) {
+                       dismiss();
+               }
+       }
+
+       bool AlertDialog::dispatchEvent(const Event event)
+       {
+               if (!m_handler) {
+                       WLOG("Handler was destroyed!");
+                       return true;
+               }
+               return m_handler(*this, event);
+       }
+
+       void AlertDialog::onBtnClick(Widget &widget, void *eventInfo)
+       {
+               if (isActive()) {
+                       handleEvent(impl::getEvent(widget));
+               }
+       }
+
+       void AlertDialog::onBackKey()
+       {
+               handleEvent(Event::BACK);
+       }
+}
diff --git a/gallery/presenters/dialogs/AlertDialog.h b/gallery/presenters/dialogs/AlertDialog.h
new file mode 100644 (file)
index 0000000..76ae6ec
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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_DIALOGS_ALERT_DIALOG_H__
+#define __GALLERY_PRESENTERS_DIALOGS_ALERT_DIALOG_H__
+
+#include "ucl/gui/Layout.h"
+
+#include "gallery/presenters/base/Dialog.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(AlertDialog);
+
+       class AlertDialog final : public Dialog {
+       public:
+               enum class Type {
+                       OK,
+                       OK_CANCEL
+               };
+
+               enum class Event {
+                       CANCEL,
+                       OK,
+                       BACK
+               };
+
+               using EventHandler = ucl::WeakDelegate<
+                               bool(AlertDialog &dialog, Event event)>;
+
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setType(Type type);
+                       Builder &setTitle(ucl::TString title);
+                       Builder &setText(ucl::TString text);
+                       Builder &setHandler(const EventHandler &handler);
+                       AlertDialogWRef build(ucl::ElmWidget &parent) const;
+               private:
+                       Type m_type;
+                       ucl::TString m_title;
+                       ucl::TString m_text;
+                       EventHandler m_handler;
+               };
+
+       private:
+               friend class ucl::ReffedObj<AlertDialog>;
+               AlertDialog(ucl::IRefCountObj &rc,
+                               const EventHandler &handler);
+               virtual ~AlertDialog() = default;
+
+               ucl::Result prepare(ucl::ElmWidget &parent, Type type);
+
+               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 setTitle(const ucl::TString &title);
+               void setText(const ucl::TString &text);
+
+               void handleEvent(Event event);
+               bool dispatchEvent(Event event);
+
+               void onBtnClick(ucl::Widget &widget, void *eventInfo);
+
+               // Dialog //
+
+               virtual void onBackKey() final override;
+
+       private:
+               const EventHandler m_handler;
+               ucl::LayoutWRef m_layout;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_DIALOGS_ALERT_DIALOG_H__
diff --git a/gallery/presenters/dialogs/common.h b/gallery/presenters/dialogs/common.h
new file mode 100644 (file)
index 0000000..6820d90
--- /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 __GALLERY_PRESENTERS_DIALOGS_COMMON_H__
+#define __GALLERY_PRESENTERS_DIALOGS_COMMON_H__
+
+#include "gallery/presenters/common.h"
+
+#endif // __GALLERY_PRESENTERS_DIALOGS_COMMON_H__
diff --git a/gallery/presenters/misc/AtspiHighlightHelper.cpp b/gallery/presenters/misc/AtspiHighlightHelper.cpp
new file mode 100644 (file)
index 0000000..bdd0ead
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * 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 "AtspiHighlightHelper.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr EoDataKey ATSPI_HELPER_DATA {"gallery,atspi,highlight,helper"};
+}}}
+
+namespace gallery {
+
+       using ucl::AtspiGestureEventInfo;
+
+       using ucl::ATSPI_ON_GESTURE;
+
+       AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance(
+                       GuiPresenter &parent, ElmWidget &rootWidget)
+       {
+               auto result = makeShared<AtspiHighlightHelper>();
+
+               FAIL_RETURN_VALUE(result->prepare(parent, rootWidget), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       AtspiHighlightHelper::AtspiHighlightHelper(IRefCountObj &rc) :
+               GuiPresenter(rc)
+       {
+       }
+
+       AtspiHighlightHelper::~AtspiHighlightHelper()
+       {
+       }
+
+       Result AtspiHighlightHelper::prepare(GuiPresenter &parent,
+                       ElmWidget &rootWidget)
+       {
+               FAIL_RETURN(GuiPresenter::prepare(parent),
+                               "GuiPresenter::prepare() failed!");
+
+               registerWidget(rootWidget);
+
+               return RES_OK;
+       }
+
+       void AtspiHighlightHelper::setEventHandler(EventHandler handler)
+       {
+               m_eventHandler = handler;
+       }
+
+       void AtspiHighlightHelper::registerWidget(ElmWidget &widget)
+       {
+               widget.addEventHandler(ATSPI_ON_GESTURE, WEAK_DELEGATE(
+                               AtspiHighlightHelper::onAtspiGesture, asWeak(*this)));
+       }
+
+       void AtspiHighlightHelper::onAtspiGesture(
+                       Widget &widget, void *eventInfo)
+       {
+               auto &e = *static_cast<AtspiGestureEventInfo *>(eventInfo);
+               if (e.stopPropagation) {
+                       return;
+               }
+               if (!isActive()) {
+                       e.preventDefault = true;
+                       return;
+               }
+
+               e.preventDefault = false;
+               e.stopPropagation = true;
+
+               if (!m_eventHandler) {
+                       return;
+               }
+               const Elm_Atspi_Relation_Type relation = getFlowRelation(e.gestureInfo);
+               if (relation == ELM_ATSPI_RELATION_NULL) {
+                       return;
+               }
+               const auto relationObj = m_eventHandler(widget, relation);
+               if (!relationObj) {
+                       return;
+               }
+
+               auto &win = getWindow();
+               auto atspiHelper = static_cast<Elm_Interface_Atspi_Accessible *>
+                               (win.getData(impl::ATSPI_HELPER_DATA));
+
+               if (!atspiHelper) {
+                       const auto obj = util::createFakeAccessObject(win);
+                       if (!obj) {
+                               LOG_RETURN_VOID(RES_FAIL, "createFakeAccessObject() failed!");
+                       }
+                       obj->setIsOwner(false);
+                       atspiHelper = obj->getEo();
+                       win.setData(impl::ATSPI_HELPER_DATA, atspiHelper);
+               }
+
+               elm_atspi_component_highlight_grab(atspiHelper);
+
+               elm_atspi_accessible_relationships_clear(atspiHelper);
+               elm_atspi_accessible_relationship_append(atspiHelper,
+                               relation, relationObj);
+       }
+}
diff --git a/gallery/presenters/misc/AtspiHighlightHelper.h b/gallery/presenters/misc/AtspiHighlightHelper.h
new file mode 100644 (file)
index 0000000..0404786
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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_MISC_ATSPI_HIGHLIGH_HELPER_H__
+#define __GALLERY_PRESENTERS_MISC_ATSPI_HIGHLIGH_HELPER_H__
+
+#include "ucl/mvp/GuiPresenter.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(AtspiHighlightHelper);
+
+       class AtspiHighlightHelper final : public ucl::GuiPresenter {
+       public:
+               using EventHandler = ucl::WeakDelegate<Elm_Interface_Atspi_Accessible *(
+                               ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation)>;
+
+       public:
+               static AtspiHighlightHelperSRef newInstance(GuiPresenter &parent,
+                               ucl::ElmWidget &rootWidget);
+
+               void setEventHandler(EventHandler handler);
+               void registerWidget(ucl::ElmWidget &widget);
+
+       private:
+               friend class ucl::ReffedObj<AtspiHighlightHelper>;
+               AtspiHighlightHelper(ucl::IRefCountObj &rc);
+               virtual ~AtspiHighlightHelper();
+
+               ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &rootWidget);
+
+       private:
+               void onAtspiGesture(ucl::Widget &widget, void *eventInfo);
+
+       private:
+               EventHandler m_eventHandler;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_MISC_ATSPI_HIGHLIGH_HELPER_H__
diff --git a/gallery/presenters/misc/MoreOptionsPresenter.cpp b/gallery/presenters/misc/MoreOptionsPresenter.cpp
new file mode 100644 (file)
index 0000000..f2fa2c9
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ * 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 "MoreOptionsPresenter.h"
+
+#include "ucl/gui/Layout.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr SmartEvent MORE_OPENED {"more,option,opened"};
+       constexpr SmartEvent MORE_CLOSED {"more,option,closed"};
+       constexpr SmartEvent MORE_ITEM_CLICKED {"item,clicked"};
+       constexpr SmartEvent MORE_ITEM_SELECTED {"item,selected"};
+
+       constexpr EdjePart PART_ICON {"item,icon"};
+       constexpr EdjePart PART_MAIN_TEXT {"selector,main_text"};
+       constexpr EdjePart PART_SUB_TEXT {"selector,sub_text"};
+
+       // Warning! Do not mix translatable and not translatable text
+       // on a single item once it is created
+       void setText(Eext_Object_Item *item, const TString &value,
+                       const EdjePart part)
+       {
+               if (value.isTranslatable()) {
+                       eext_more_option_item_domain_translatable_part_text_set(
+                                               item, part.name, value.getDomain(), value);
+               } else {
+                       eext_more_option_item_part_text_set(item, part.name, value);
+               }
+       }
+}}}
+
+namespace gallery {
+
+       using ucl::Layout;
+
+       // MoreOptionsPresenter::Builder //
+
+       MoreOptionsPresenter::Builder::Builder()
+       {
+       }
+
+       MoreOptionsPresenter::Builder::~Builder()
+       {
+       }
+
+       bool MoreOptionsPresenter::Builder::isEmpty() const
+       {
+               return ucl::isEmpty(m_options);
+       }
+
+       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::clear()
+       {
+               m_options = {};
+               return *this;
+       }
+
+       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::addOption(
+                       Option option)
+       {
+               if (!m_options) {
+                       m_options = makeShared<MoreOptions>();
+               } else if (m_options.getUseCount() > 1) {
+                       m_options = makeShared<MoreOptions>(*m_options);
+               }
+               m_options->emplace_back(std::move(option));
+               return *this;
+       }
+
+       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::
+                       setParentWidget(const ElmWidgetSRef &parentWidget)
+       {
+               m_parentWidget = parentWidget;
+               return *this;
+       }
+
+       MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build(
+                       GuiPresenter &parent) const
+       {
+               if (isEmpty()) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!");
+               }
+               if (!m_parentWidget) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "m_parentWidget is NULL!");
+               }
+
+               auto result = makeShared<MoreOptionsPresenter>(m_options);
+
+               FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       // MoreOptionsPresenter //
+
+       MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
+                       const MoreOptionsCSRef &options) :
+               GuiPresenter(rc),
+               m_options(options),
+               m_timer(nullptr),
+               m_newOpenedState(false)
+       {
+       }
+
+       MoreOptionsPresenter::~MoreOptionsPresenter()
+       {
+               stopTimer();
+               if (m_widget) {
+                       sendActivate(*m_widget);
+               }
+       }
+
+       Result MoreOptionsPresenter::prepare(GuiPresenter &parent,
+                       ElmWidget &parentWidget)
+       {
+               FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+                               "GuiPresenter::prepare() failed!");
+
+               Evas_Object *const more = eext_more_option_add(parentWidget);
+               if (!more) {
+                       LOG_RETURN(RES_FAIL, "eext_more_option_add() failed!");
+               }
+
+               const auto layout = makeShared<Layout>(more, true);
+               m_widget = layout;
+
+               for (auto &option: *m_options) {
+                       FAIL_RETURN(addItem(option), "addItem() failed!");
+               }
+
+               m_widget->addEventHandler(impl::MORE_OPENED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onOpened, asWeak(*this)));
+               m_widget->addEventHandler(impl::MORE_CLOSED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onClosed, asWeak(*this)));
+
+               m_widget->addEventHandler(impl::MORE_ITEM_CLICKED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onItemClicked, asWeak(*this)));
+               m_widget->addEventHandler(impl::MORE_ITEM_SELECTED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onItemSelected, asWeak(*this)));
+
+               deactivateBy(m_widget.get());
+
+               parent.addDeactivatorSource(*m_widget);
+
+               return RES_OK;
+       }
+
+       Result MoreOptionsPresenter::addItem(const Option &option)
+       {
+               const auto item = eext_more_option_item_append(*m_widget);
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "eext_more_option_item_append() failed!");
+               }
+
+               if (isValid(option.iconTheme)) {
+                       const auto icon = Layout::Builder().
+                                       setTheme(option.iconTheme).
+                                       setIsOwner(false).
+                                       build(*m_widget);
+                       if (!icon) {
+                               LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+                       }
+                       eext_more_option_item_part_content_set(item,
+                                       impl::PART_ICON.name, *icon);
+               }
+
+               impl::setText(item, option.text, impl::PART_MAIN_TEXT);
+               impl::setText(item, option.subText, impl::PART_SUB_TEXT);
+
+               m_map.set(item, &option);
+
+               return RES_OK;
+       }
+
+       bool MoreOptionsPresenter::resetTimer(const double timeout)
+       {
+               stopTimer();
+
+               m_timer = ecore_timer_add(timeout, CALLBACK_A(
+                               MoreOptionsPresenter::onTimer), this);
+               if (!m_timer) {
+                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
+               }
+
+               return true;
+       }
+
+       void MoreOptionsPresenter::stopTimer()
+       {
+               if (m_timer) {
+                       ecore_timer_del(m_timer);
+                       m_timer = nullptr;
+               }
+       }
+
+       Eina_Bool MoreOptionsPresenter::onTimer()
+       {
+               m_timer = nullptr;
+
+               setOpened(m_newOpenedState);
+
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       void MoreOptionsPresenter::onOpened(Widget &widget, void *eventInfo)
+       {
+               stopTimer();
+               sendDeactivate(*m_widget);
+               activateBy(m_widget.get());
+               if (const auto listener = m_listener.lock()) {
+                       listener->onMoreOptionsOpened(*this);
+               }
+               if (!isActive()) {
+                       setOpened(false);
+               }
+       }
+
+       void MoreOptionsPresenter::onClosed(Widget &widget, void *eventInfo)
+       {
+               stopTimer();
+               deactivateBy(m_widget.get());
+               sendActivate(*m_widget);
+               if (const auto listener = m_listener.lock()) {
+                       listener->onMoreOptionsClosed(*this);
+               }
+       }
+
+       void MoreOptionsPresenter::onItemClicked(Widget &widget, void *eventInfo)
+       {
+               if (!isActive() || !isOpened()) {
+                       return;
+               }
+               if (const auto listener = m_listener.lock()) {
+                       const auto item = m_map.get(eventInfo);
+                       if (item) {
+                               listener->onMoreOptionClicked(*this, *item);
+                       } else {
+                               ELOG("Invalid eventInfo!");
+                       }
+               }
+       }
+
+       void MoreOptionsPresenter::onItemSelected(Widget &widget, void *eventInfo)
+       {
+               if (const auto listener = m_listener.lock()) {
+                       const auto item = m_map.get(eventInfo);
+                       if (item) {
+                               listener->onMoreOptionSelected(*this, *item);
+                       } else {
+                               ELOG("Invalid eventInfo!");
+                       }
+               }
+       }
+
+       void MoreOptionsPresenter::setListener(
+                       const IListenerWRef &listener)
+       {
+               m_listener = listener;
+       }
+
+       Widget &MoreOptionsPresenter::getWidget()
+       {
+               return *m_widget;
+       }
+
+       void MoreOptionsPresenter::setOpened(const bool isOpened)
+       {
+               stopTimer();
+               eext_more_option_opened_set(*m_widget, toEina(isOpened));
+       }
+
+       bool MoreOptionsPresenter::isOpened() const
+       {
+               return eext_more_option_opened_get(*m_widget);
+       }
+
+       void MoreOptionsPresenter::setOpenedDelayed(
+                       const bool isOpened, const double timeout)
+       {
+               if (!resetTimer(timeout)) {
+                       setOpened(isOpened);
+               } else {
+                       m_newOpenedState = isOpened;
+               }
+       }
+}
diff --git a/gallery/presenters/misc/MoreOptionsPresenter.h b/gallery/presenters/misc/MoreOptionsPresenter.h
new file mode 100644 (file)
index 0000000..95b432b
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * 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_MISC_MORE_OPTIONS_PRESENTER_H__
+#define __GALLERY_PRESENTERS_MISC_MORE_OPTIONS_PRESENTER_H__
+
+#include <list>
+
+#include "ucl/misc/HashMap.h"
+
+#include "ucl/mvp/GuiPresenter.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter);
+
+       class MoreOptionsPresenter final : public ucl::GuiPresenter {
+       public:
+               UCL_DECLARE_REF_ALIASES(IListener);
+
+               struct Option final {
+                       int id;
+                       ucl::TString text;
+                       ucl::TString subText;
+                       ucl::LayoutTheme iconTheme;
+               };
+
+               using MoreOptions = std::list<Option>;
+
+               class Builder final {
+               public:
+                       Builder();
+                       ~Builder();
+                       bool isEmpty() const;
+                       Builder &clear();
+                       Builder &addOption(Option option);
+                       Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
+                       MoreOptionsPresenterSRef build(GuiPresenter &parent) const;
+               private:
+                       ucl::SharedRef<MoreOptions> m_options;
+                       ucl::ElmWidgetSRef m_parentWidget;
+               };
+
+               class IListener : public ucl::Polymorphic {
+               public:
+                       virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
+                                       const Option &option) = 0;
+                       virtual void onMoreOptionSelected(MoreOptionsPresenter &sender,
+                                       const Option &option) {};
+                       virtual void onMoreOptionsOpened(MoreOptionsPresenter &sender) {};
+                       virtual void onMoreOptionsClosed(MoreOptionsPresenter &sender) {};
+               };
+
+       public:
+               void setListener(const IListenerWRef &listener);
+
+               ucl::Widget &getWidget();
+
+               void setOpened(bool isOpened);
+               bool isOpened() const;
+
+               void setOpenedDelayed(bool isOpened, double timeout);
+
+       private:
+               using MoreOptionsCSRef = ucl::SharedRef<const MoreOptions>;
+
+       private:
+               friend class ucl::ReffedObj<MoreOptionsPresenter>;
+               MoreOptionsPresenter(ucl::IRefCountObj &rc,
+                               const MoreOptionsCSRef &options);
+               virtual ~MoreOptionsPresenter();
+
+               ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &parentWidget);
+               ucl::Result addItem(const Option &option);
+
+               bool resetTimer(double timeout);
+               void stopTimer();
+
+               Eina_Bool onTimer();
+
+               void onOpened(ucl::Widget &widget, void *eventInfo);
+               void onClosed(ucl::Widget &widget, void *eventInfo);
+               void onItemClicked(ucl::Widget &widget, void *eventInfo);
+               void onItemSelected(ucl::Widget &widget, void *eventInfo);
+
+       private:
+               const MoreOptionsCSRef m_options;
+               ucl::HashMap<void *, const Option *> m_map;
+               ucl::ElmWidgetSRef m_widget;
+               IListenerWRef m_listener;
+               Ecore_Timer *m_timer;
+               bool m_newOpenedState;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_MISC_MORE_OPTIONS_PRESENTER_H__
diff --git a/gallery/presenters/misc/ProcessingPresenter.cpp b/gallery/presenters/misc/ProcessingPresenter.cpp
new file mode 100644 (file)
index 0000000..6307961
--- /dev/null
@@ -0,0 +1,364 @@
+/*
+ * 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 "ProcessingPresenter.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr auto IDLE_WAIT_TIME_SEC = 0.2;
+       constexpr auto PROCESSING_MIN_TIME_SEC = 0.5;
+
+       constexpr auto POPUP_SHOW_TIME_SEC = 0.3;
+       constexpr auto POPUP_DURATION_SEC = 2.0;
+       constexpr auto POPUP_TIMEOUT_SEC =
+                       (POPUP_DURATION_SEC - POPUP_SHOW_TIME_SEC);
+
+       constexpr LayoutTheme LAYOUT_PROCESSING_WIDGET
+                       {"layout", "gallery", "proccessing"};
+
+       constexpr EdjeSignal SIGNAL_SHOW {"gallery,show"};
+       constexpr EdjeSignal SIGNAL_SHOW_BG {"gallery,show,bg"};
+       constexpr EdjeSignal SIGNAL_HIDE {"gallery,hide"};
+       constexpr EdjeSignal SIGNAL_HIDE_PROGRESS {"gallery,hide,progress"};
+
+       constexpr LayoutTheme LAYOUT_POPUP_ICON
+                       {"layout", "gallery", "popup_icon"};
+
+       constexpr EdjeSignal SIGNAL_ANIMATE_CHECK {"gallery,animate,check"};
+
+       constexpr ElmStyle POPUP_STYLE {"toast/circle"};
+       constexpr EdjePart PART_TOAST_ICON {"toast,icon"};
+}}}
+
+namespace gallery {
+
+       using ucl::Layout;
+
+       using ucl::PART_TEXT;
+
+       // ProcessingPresenter::Builder //
+
+       ProcessingPresenter::Builder::Builder() :
+               m_forceProgress(false)
+       {
+       }
+
+       ProcessingPresenter::Builder &ProcessingPresenter::Builder::
+                       setProcessingText(TString text)
+       {
+               m_processingText = std::move(text);
+               return *this;
+       }
+
+       ProcessingPresenter::Builder &ProcessingPresenter::Builder::
+                       setForceProgress(const bool value)
+       {
+               m_forceProgress = value;
+               return *this;
+       }
+
+       ProcessingPresenterSRef ProcessingPresenter::Builder::
+                       build(ElmWidget &parent) const
+       {
+               auto result = makeShared<ProcessingPresenter>();
+
+               FAIL_RETURN_VALUE(result->prepare(parent,
+                               m_processingText, m_forceProgress), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       // ProcessingPresenter //
+
+       ProcessingPresenter::ProcessingPresenter(IRefCountObj &rc) :
+               GuiPresenter(rc),
+               m_iconType(IconType::NONE),
+               m_timer(nullptr),
+               m_state(State::WAITING),
+               m_mayComplete(true),
+               m_isComplete(false),
+               m_isDismissed(false)
+       {
+       }
+
+       ProcessingPresenter::~ProcessingPresenter()
+       {
+               stopTimer();
+               deletePopup();
+       }
+
+       Result ProcessingPresenter::prepare(ElmWidget &parent,
+                       const TString &processingText,
+                       const bool forceProgress)
+       {
+               FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
+                               "GuiPresenter::prepare() failed!");
+
+               FAIL_RETURN(createWidget(parent, processingText),
+                               "createWidget() failed!");
+               FAIL_RETURN(moveWidget(), "moveWidget() failed!");
+
+               FAIL_RETURN(createProgress(), "createProgress() failed!");
+
+               FAIL_RETURN(createPopup(), "createPopup() failed!");
+
+               if (forceProgress) {
+                       showProgress();
+               } else {
+                       m_widget->emit(impl::SIGNAL_SHOW_BG);
+                       if (!resetTimer(impl::IDLE_WAIT_TIME_SEC)) {
+                               LOG_RETURN(RES_FAIL, "resetTimer() failed!");
+                       }
+               }
+
+               broadcastDeactivate();
+
+               return RES_OK;
+       }
+
+       Result ProcessingPresenter::createWidget(ElmWidget &parent,
+                       const TString &processingText)
+       {
+               m_widget = Layout::Builder().
+                               setTheme(impl::LAYOUT_PROCESSING_WIDGET).
+                               build(parent);
+               if (!m_widget) {
+                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+               }
+
+               m_widget->setText(processingText);
+
+               return RES_OK;
+       }
+
+       Result ProcessingPresenter::moveWidget()
+       {
+               const auto win = m_widget->getWindow();
+               if (!win) {
+                       LOG_RETURN(RES_FAIL, "win is NULL!");
+               }
+
+               int w = 0;
+               int h = 0;
+               win->getScreenSize(&w, &h);
+
+               m_widget->setGeometry(0, 0, w, h);
+
+               return RES_OK;
+       }
+
+       Result ProcessingPresenter::createProgress()
+       {
+               Evas_Object *const progressEo = elm_progressbar_add(*m_widget);
+               if (!progressEo) {
+                       LOG_RETURN(RES_FAIL, "elm_progressbar_add() failed!");
+               }
+
+               StyledWidget progress{progressEo};
+               progress.setStyle(ElmStyle("process"));
+               m_widget->setContent(progress, EdjePart("gallery.swallow.progress"));
+               elm_progressbar_pulse(progress, EINA_TRUE);
+               show(progress);
+
+               return RES_OK;
+       }
+
+       Result ProcessingPresenter::createPopup()
+       {
+               Evas_Object *const popupEo = elm_popup_add(m_widget->getTopWidget());
+               if (!popupEo) {
+                       LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
+               }
+
+               m_popup = makeShared<StyledWidget>(popupEo);
+               m_popup->setStyle(impl::POPUP_STYLE);
+
+               m_popup->addEventHandler(POPUP_DISMISSED, WEAK_DELEGATE(
+                               ProcessingPresenter::onPopupDismissed, asWeak(*this)));
+
+               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
+                               CALLBACK_A(ProcessingPresenter::onPopupHWBackKey), this);
+
+               return RES_OK;
+       }
+
+       Result ProcessingPresenter::createIcon()
+       {
+               const auto icon = Layout::Builder().
+                               setTheme(impl::LAYOUT_POPUP_ICON).
+                               setIsOwner(false).
+                               build(*m_popup);
+               if (!icon) {
+                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+               }
+
+               m_popup->setContent(*icon, impl::PART_TOAST_ICON);
+
+               m_icon = icon;
+
+               return RES_OK;
+       }
+
+       bool ProcessingPresenter::resetTimer(const double timeout)
+       {
+               stopTimer();
+
+               m_timer = ecore_timer_add(timeout, CALLBACK_A(
+                               ProcessingPresenter::onTimer), this);
+               if (!m_timer) {
+                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
+               }
+
+               return true;
+       }
+
+       void ProcessingPresenter::stopTimer()
+       {
+               if (m_timer) {
+                       ecore_timer_del(m_timer);
+                       m_timer = nullptr;
+               }
+       }
+
+       void ProcessingPresenter::showProgress()
+       {
+               m_widget->emit(impl::SIGNAL_SHOW);
+
+               m_state = State::PROCESSING;
+               m_mayComplete = false;
+
+               resetTimer(impl::PROCESSING_MIN_TIME_SEC);
+       }
+
+       void ProcessingPresenter::tryShowPopup()
+       {
+               if (m_isComplete && m_mayComplete && m_popup) {
+                       m_widget->emit(impl::SIGNAL_HIDE_PROGRESS);
+
+                       show(*m_popup);
+
+                       m_state = State::POPUP_ANIMATION;
+                       resetTimer(impl::POPUP_SHOW_TIME_SEC);
+               }
+       }
+
+       void ProcessingPresenter::dismissPopup()
+       {
+               if (m_popup && !m_isDismissed) {
+                       m_isDismissed = true;
+                       deactivateBy(m_popup.get());
+                       elm_popup_dismiss(*m_popup);
+               }
+       }
+
+       void ProcessingPresenter::deletePopup()
+       {
+               if (m_popup) {
+                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
+                                       CALLBACK_A(ProcessingPresenter::onPopupHWBackKey));
+
+                       deactivateBy(m_popup.get());
+                       broadcastActivate();
+                       m_popup.reset();
+                       m_selfRef.reset();
+               }
+       }
+
+       void ProcessingPresenter::animateIcon()
+       {
+               if (const auto icon = m_icon.lock()) {
+                       if (m_iconType == IconType::CHECK) {
+                               icon->emit(impl::SIGNAL_ANIMATE_CHECK);
+                       }
+               }
+       }
+
+       Eina_Bool ProcessingPresenter::onTimer()
+       {
+               m_timer = nullptr;
+
+               switch (m_state) {
+               case State::WAITING:
+                       showProgress();
+                       break;
+
+               case State::PROCESSING:
+                       m_mayComplete = true;
+                       tryShowPopup();
+                       break;
+
+               case State::POPUP_ANIMATION:
+                       animateIcon();
+                       m_widget->emit(impl::SIGNAL_HIDE);
+                       m_state = State::COMPLETE;
+                       resetTimer(impl::POPUP_TIMEOUT_SEC);
+                       break;
+
+               case State::COMPLETE:
+                       dismissPopup();
+                       break;
+               }
+
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       void ProcessingPresenter::onPopupDismissed(Widget &widget, void *eventInfo)
+       {
+               if (m_dismissHandler) {
+                       m_dismissHandler();
+               }
+               m_widget.reset();
+               deletePopup();
+       }
+
+       void ProcessingPresenter::onPopupHWBackKey(
+                       Evas_Object *obj, void *eventInfo)
+       {
+               if (isActive()) {
+                       m_widget->emit(impl::SIGNAL_HIDE);
+                       stopTimer();
+                       dismissPopup();
+               }
+       }
+
+       void ProcessingPresenter::complete(const TString &completeText,
+                       const IconType iconType)
+       {
+               if (m_isComplete) {
+                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Already in complete state!");
+               }
+               m_isComplete = true;
+
+               m_popup->setText(completeText, PART_TEXT);
+
+               if (iconType != IconType::NONE) {
+                       m_iconType = iconType;
+                       FAIL_LOG(createIcon(), "createIcon() failed!");
+               }
+
+               m_selfRef = asShared(*this);
+
+               tryShowPopup();
+       }
+
+       void ProcessingPresenter::setDismissHandler(const DismissHandler &handler)
+       {
+               m_dismissHandler = handler;
+       }
+}
diff --git a/gallery/presenters/misc/ProcessingPresenter.h b/gallery/presenters/misc/ProcessingPresenter.h
new file mode 100644 (file)
index 0000000..56b1e9f
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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_MISC_PROCESSING_PRESENTER_H__
+#define __GALLERY_PRESENTERS_MISC_PROCESSING_PRESENTER_H__
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/StyledWidget.h"
+
+#include "ucl/mvp/GuiPresenter.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(ProcessingPresenter);
+
+       class ProcessingPresenter final : public ucl::GuiPresenter {
+       public:
+               enum class IconType {
+                       NONE,
+                       CHECK
+               };
+
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setProcessingText(ucl::TString text);
+                       Builder &setForceProgress(bool value);
+                       ProcessingPresenterSRef build(ucl::ElmWidget &parent) const;
+               private:
+                       ucl::TString m_processingText;
+                       bool m_forceProgress;
+               };
+
+               using DismissHandler = ucl::WeakDelegate<void()>;
+
+       public:
+               void complete(const ucl::TString &completeText,
+                               IconType iconType = IconType::NONE);
+
+               void setDismissHandler(const DismissHandler &handler);
+
+       private:
+               friend class ucl::ReffedObj<ProcessingPresenter>;
+               ProcessingPresenter(ucl::IRefCountObj &rc);
+               virtual ~ProcessingPresenter();
+
+               ucl::Result prepare(ucl::ElmWidget &parent,
+                               const ucl::TString &processingText,
+                               bool forceProgress);
+
+               ucl::Result createWidget(ucl::ElmWidget &parent,
+                               const ucl::TString &processingText);
+               ucl::Result moveWidget();
+               ucl::Result createProgress();
+               ucl::Result createPopup();
+               ucl::Result createIcon();
+
+               bool resetTimer(double timeout);
+               void stopTimer();
+
+               void showProgress();
+
+               void tryShowPopup();
+               void dismissPopup();
+               void deletePopup();
+
+               void animateIcon();
+
+               Eina_Bool onTimer();
+
+               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
+               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
+
+       private:
+               enum class State {
+                       WAITING,
+                       PROCESSING,
+                       POPUP_ANIMATION,
+                       COMPLETE
+               };
+
+       private:
+               ucl::LayoutSRef m_widget;
+               ucl::StyledWidgetSRef m_popup;
+               ucl::LayoutWRef m_icon;
+               IconType m_iconType;
+               DismissHandler m_dismissHandler;
+               Ecore_Timer *m_timer;
+               State m_state;
+               ProcessingPresenterSRef m_selfRef;
+               bool m_mayComplete;
+               bool m_isComplete;
+               bool m_isDismissed;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_MISC_PROCESSING_PRESENTER_H__
diff --git a/gallery/presenters/misc/SelectModePresenter.cpp b/gallery/presenters/misc/SelectModePresenter.cpp
new file mode 100644 (file)
index 0000000..ea83e76
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * 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 "SelectModePresenter.h"
+
+#include "ucl/gui/WidgetItem.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       const TString SELECT_BTN_TEXT_FMT {"%d"};
+
+       constexpr ElmStyle SELECT_POPUP_STYLE {"select_mode"};
+       constexpr ElmStyle TOP_SELECT_BTN_STYLE {"select_mode/top"};
+       constexpr ElmStyle BOTTOM_SELECT_BTN_STYLE {"select_mode/bottom"};
+
+       constexpr ElmStyle SELECT_BTN_STYLE {"select_mode"};
+       constexpr ElmStyle BOTTOM_BTN_STYLE {"bottom"};
+}}}
+
+namespace gallery {
+
+       using ucl::WidgetItem;
+
+       // SelectModePresenter::Builder //
+
+       SelectModePresenter::Builder::Builder() :
+               m_flags(0)
+       {
+       }
+
+       SelectModePresenter::Builder &SelectModePresenter::Builder::
+                       setFlags(const int flags)
+       {
+               m_flags = flags;
+               return *this;
+       }
+
+       SelectModePresenter::Builder &SelectModePresenter::Builder::
+                       setPageContent(const PageContentSRef &content)
+       {
+               m_content = content;
+               return *this;
+       }
+
+       SelectModePresenterSRef SelectModePresenter::Builder::build(
+                       GuiPresenter &parent) const
+       {
+               if (!m_content) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_content is NULL!");
+               }
+
+               auto result = makeShared<SelectModePresenter>(m_content, m_flags);
+
+               FAIL_RETURN_VALUE(result->prepare(parent), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       // SelectModePresenter //
+
+       SelectModePresenter::SelectModePresenter(IRefCountObj &rc,
+                       const PageContentSRef &content, const int flags) :
+               GuiPresenter(rc),
+               m_content(content),
+               m_flags(flags),
+               m_totalCount(0),
+               m_selectCount(0),
+               m_isVisible(false),
+               m_isPopupDismissed(false)
+       {
+       }
+
+       SelectModePresenter::~SelectModePresenter()
+       {
+               if ((m_flags & FLAG_NO_DISMISS_ON_ROTARY) == 0) {
+                       delRotaryEventHandler(CALLBACK_A(
+                                       SelectModePresenter::onRotary), this);
+               }
+               deletePopup();
+       }
+
+       Result SelectModePresenter::prepare(GuiPresenter &parent)
+       {
+               FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+                               "GuiPresenter::prepare() failed!");
+
+               m_selectButton = makeShared<StyledWidget>(elm_button_add(*m_content));
+               m_selectButton->setStyle(impl::SELECT_BTN_STYLE);
+               m_content->set(*m_selectButton, PageContent::Part::SELECT_BUTTON);
+               m_content->setSelectButtonVisible(false);
+               show(*m_selectButton);
+
+               m_selectButton->addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
+                               SelectModePresenter::onSelectBtnClick, asWeak(*this)));
+
+               if ((m_flags & FLAG_NO_BOTTOM_BUTTON) == 0) {
+                       m_bottomButton = makeShared<StyledWidget>(
+                                       elm_button_add(*m_content));
+                       m_bottomButton->setStyle(impl::BOTTOM_BTN_STYLE);
+                       hide(*m_bottomButton);
+
+                       m_bottomButton->addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
+                                       SelectModePresenter::onBottomBtnClick, asWeak(*this)));
+               }
+
+               if ((m_flags & FLAG_NO_DISMISS_ON_ROTARY) == 0) {
+                       addRotaryEventHandler(CALLBACK_A(
+                                       SelectModePresenter::onRotary), this);
+               }
+
+               deactivateBy(m_selectButton.get());
+
+               return RES_OK;
+       }
+
+       void SelectModePresenter::setListener(const IListenerWRef &listener)
+       {
+               m_listener = listener;
+       }
+
+
+       void SelectModePresenter::setVisible(const bool value)
+       {
+               if (value == m_isVisible) {
+                       return;
+               }
+               m_isVisible = value;
+
+               m_content->setSelectButtonVisible(m_isVisible);
+
+               if (m_bottomButton) {
+                       if (m_isVisible) {
+                               m_content->set(*m_bottomButton,
+                                               PageContent::Part::BOTTOM_BUTTON);
+                               show(*m_bottomButton);
+                       } else {
+                               m_content->unset(PageContent::Part::BOTTOM_BUTTON);
+                               hide(*m_bottomButton);
+                       }
+               }
+
+               if (m_isVisible) {
+                       activateBy(m_selectButton.get());
+                       doUpdate();
+               } else {
+                       deactivateBy(m_selectButton.get());
+                       if ((m_flags & (FLAG_NO_MORE_OPTIONS |
+                                       FLAG_NO_DIM_ON_ZERO_SELECT)) == 0) {
+                               m_content->setMoreOptionsVisible(true);
+                       }
+               }
+       }
+
+       bool SelectModePresenter::isVisible() const
+       {
+               return m_isVisible;
+       }
+
+       void SelectModePresenter::onDeactivate()
+       {
+               deletePopup();
+       }
+
+       ElmWidget &SelectModePresenter::getSelectButton()
+       {
+               return *m_selectButton;
+       }
+
+       ElmWidget &SelectModePresenter::getBottomButton()
+       {
+               UCL_ASSERT(m_bottomButton, "No bottom button!");
+               return *m_bottomButton;
+       }
+
+       void SelectModePresenter::setBottomButtonText(const TString &value)
+       {
+               if (m_bottomButton) {
+                       m_bottomButton->setText(value);
+               } else {
+                       WLOG("No bottom button!");
+               }
+       }
+
+       void SelectModePresenter::update(
+                       const int selectCount, const int totalCount)
+       {
+               if (m_isVisible) {
+                       dismissPopup();
+               }
+
+               const int newTotalCount = ((totalCount < 0) ?
+                               m_totalCount : totalCount);
+
+               int newSelectCount = selectCount;
+               if (newSelectCount < 0) {
+                       WLOG("newSelectCount: %d;", newSelectCount);
+                       newSelectCount = 0;
+               } else if (newSelectCount > newTotalCount) {
+                       WLOG("newSelectCount: %d; newTotalCount: %d",
+                                       newSelectCount, newTotalCount);
+                       newSelectCount = newTotalCount;
+               }
+
+               if ((newSelectCount == m_selectCount) &&
+                               (newTotalCount == m_totalCount)) {
+                       return;
+               }
+               m_selectCount = newSelectCount;
+               m_totalCount = newTotalCount;
+
+               if (m_isVisible) {
+                       doUpdate();
+               }
+       }
+
+       void SelectModePresenter::doUpdate()
+       {
+               m_selectButton->setText(impl::SELECT_BTN_TEXT_FMT.
+                               format(m_selectCount));
+
+               if ((m_flags & FLAG_NO_DIM_ON_ZERO_SELECT) == 0) {
+                       const bool isDimmed = (m_selectCount == 0);
+                       if (m_bottomButton) {
+                               m_bottomButton->setEnabled(!isDimmed);
+                       }
+                       if ((m_flags & FLAG_NO_MORE_OPTIONS) == 0) {
+                               m_content->setMoreOptionsVisible(!isDimmed);
+                       }
+               }
+       }
+
+       void SelectModePresenter::showPopup()
+       {
+               m_isPopupDismissed = false;
+
+               m_popup = makeShared<StyledWidget>(elm_ctxpopup_add(*m_content));
+               m_popup->setStyle(impl::SELECT_POPUP_STYLE);
+
+               elm_ctxpopup_direction_priority_set(*m_popup,
+                               ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP,
+                               ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP);
+
+               WidgetItem selectItem;
+               WidgetItem deselectItem;
+
+               if (m_selectCount < m_totalCount) {
+                       selectItem = WidgetItem{elm_ctxpopup_item_append(*m_popup,
+                                       STR_SELECT_ALL.translate(), nullptr, CALLBACK_A(
+                                               SelectModePresenter::onSelectAll), this)};
+               }
+
+               if (m_selectCount > 0) {
+                       deselectItem = WidgetItem{elm_ctxpopup_item_append(*m_popup,
+                                       STR_DESELECT_ALL.translate(), nullptr, CALLBACK_A(
+                                               SelectModePresenter::onDeselectAll), this)};
+               }
+
+               show(*m_popup);
+
+               if (selectItem && deselectItem) {
+                       selectItem.setStyle(impl::TOP_SELECT_BTN_STYLE);
+                       deselectItem.setStyle(impl::BOTTOM_SELECT_BTN_STYLE);
+               }
+
+               movePopup();
+
+               m_popup->addEventHandler(POPUP_DISMISSED, WEAK_DELEGATE(
+                               SelectModePresenter::onPopupDismissed, asWeak(*this)));
+
+               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
+                               CALLBACK_A(SelectModePresenter::onPopupHWBackKey), this);
+
+               broadcastDeactivate();
+       }
+
+       void SelectModePresenter::movePopup()
+       {
+               int cx = 0;
+               int cy = 0;
+               int cw = 0;
+               int ch = 0;
+               m_content->getGeometry(&cx, &cy, &cw, &ch);
+
+               int ph = 0;
+               getSize(*m_popup, nullptr, &ph);
+
+               m_popup->move(cx + (cw / 2), cy + ((ch - ph) / 2));
+       }
+
+       void SelectModePresenter::dismissPopup()
+       {
+               if (m_popup && !m_isPopupDismissed) {
+                       m_isPopupDismissed = true;
+                       elm_ctxpopup_dismiss(*m_popup);
+               }
+       }
+
+       void SelectModePresenter::deletePopup()
+       {
+               if (m_popup) {
+                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
+                                       CALLBACK_A(SelectModePresenter::onPopupHWBackKey));
+
+                       m_popup.reset();
+
+                       broadcastActivate();
+               }
+       }
+
+       void SelectModePresenter::dispatchEvent(const Event event)
+       {
+               if (const auto listener = m_listener.lock()) {
+                       listener->onSelectModeEvent(event);
+               }
+       }
+
+       void SelectModePresenter::onPopupDismissed(
+                       Widget &widget, void *eventInfo)
+       {
+               deletePopup();
+       }
+
+       void SelectModePresenter::onPopupHWBackKey(
+                       Evas_Object *obj, void *eventInfo)
+       {
+               if (isActive()) {
+                       dismissPopup();
+               }
+       }
+
+       void SelectModePresenter::onSelectAll(
+                       Evas_Object *obj, void *eventInfo)
+       {
+               if (m_popup && (m_popup->getEo() == obj)) {
+                       dismissPopup();
+                       dispatchEvent(Event::SELECT_ALL);
+               }
+       }
+
+       void SelectModePresenter::onDeselectAll(
+                       Evas_Object *obj, void *eventInfo)
+       {
+               if (m_popup && (m_popup->getEo() == obj)) {
+                       dismissPopup();
+                       dispatchEvent(Event::DESELECT_ALL);
+               }
+       }
+
+       void SelectModePresenter::onSelectBtnClick(
+                       Widget &widget, void *eventInfo)
+       {
+               if (isActive() && !m_popup && (m_totalCount > 0)) {
+                       showPopup();
+               }
+       }
+
+       void SelectModePresenter::onBottomBtnClick(
+                       Widget &widget, void *eventInfo)
+       {
+               if (isActive() && !m_popup && (m_selectCount > 0)) {
+                       dispatchEvent(Event::BOTTOM_BUTTON_CLICK);
+               }
+       }
+
+       Eina_Bool SelectModePresenter::onRotary(Eext_Rotary_Event_Info *info)
+       {
+               if (isActive()) {
+                       dismissPopup();
+               }
+               return EINA_TRUE;
+       }
+}
diff --git a/gallery/presenters/misc/SelectModePresenter.h b/gallery/presenters/misc/SelectModePresenter.h
new file mode 100644 (file)
index 0000000..f52722f
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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_MISC_SELECT_MODE_PRESENTER_H__
+#define __GALLERY_PRESENTERS_MISC_SELECT_MODE_PRESENTER_H__
+
+#include "ucl/gui/StyledWidget.h"
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "gallery/view/PageContent.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(SelectModePresenter);
+
+       class SelectModePresenter final : public ucl::GuiPresenter {
+       public:
+               UCL_DECLARE_REF_ALIASES(IListener);
+
+               enum {
+                       FLAG_NO_BOTTOM_BUTTON = 1,
+                       FLAG_NO_MORE_OPTIONS = 2,
+                       FLAG_NO_DIM_ON_ZERO_SELECT = 4,
+                       FLAG_NO_DISMISS_ON_ROTARY = 8
+               };
+
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setFlags(int flags);
+                       Builder &setPageContent(const PageContentSRef &content);
+                       SelectModePresenterSRef build(GuiPresenter &parent) const;
+               private:
+                       PageContentSRef m_content;
+                       int m_flags;
+               };
+
+               enum class Event {
+                       SELECT_ALL,
+                       DESELECT_ALL,
+                       BOTTOM_BUTTON_CLICK
+               };
+
+               class IListener : public ucl::Polymorphic {
+               public:
+                       virtual void onSelectModeEvent(Event event) = 0;
+               };
+
+       public:
+               void setListener(const IListenerWRef &listener);
+
+               void setVisible(bool value);
+               bool isVisible() const;
+
+               ucl::ElmWidget &getSelectButton();
+               ucl::ElmWidget &getBottomButton();
+
+               void setBottomButtonText(const ucl::TString &value);
+
+               void update(int selectCount, int totalCount = -1);
+
+       private:
+               friend class ucl::ReffedObj<SelectModePresenter>;
+               SelectModePresenter(ucl::IRefCountObj &rc,
+                               const PageContentSRef &content, int flags);
+               virtual ~SelectModePresenter();
+
+               ucl::Result prepare(GuiPresenter &parent);
+
+               void doUpdate();
+
+               void showPopup();
+               void movePopup();
+               void dismissPopup();
+               void deletePopup();
+
+               void dispatchEvent(Event event);
+
+               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
+               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
+
+               void onSelectAll(Evas_Object *obj, void *eventInfo);
+               void onDeselectAll(Evas_Object *obj, void *eventInfo);
+
+               void onSelectBtnClick(ucl::Widget &widget, void *eventInfo);
+               void onBottomBtnClick(ucl::Widget &widget, void *eventInfo);
+               Eina_Bool onRotary(Eext_Rotary_Event_Info *info);
+
+               // GuiPresenter //
+               virtual void onDeactivate() final override;
+
+       private:
+               const PageContentSRef m_content;
+               const int m_flags;
+               ucl::StyledWidgetSRef m_selectButton;
+               ucl::StyledWidgetSRef m_bottomButton;
+               ucl::StyledWidgetSRef m_popup;
+               IListenerWRef m_listener;
+               int m_totalCount;
+               int m_selectCount;
+               bool m_isVisible;
+               bool m_isPopupDismissed;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_MISC_SELECT_MODE_PRESENTER_H__
diff --git a/gallery/presenters/misc/common.h b/gallery/presenters/misc/common.h
new file mode 100644 (file)
index 0000000..67dfea8
--- /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 __GALLERY_PRESENTERS_MISC_COMMON_H__
+#define __GALLERY_PRESENTERS_MISC_COMMON_H__
+
+#include "gallery/presenters/common.h"
+
+#endif // __GALLERY_PRESENTERS_MISC_COMMON_H__
diff --git a/gallery/presenters/misc/helpers.cpp b/gallery/presenters/misc/helpers.cpp
new file mode 100644 (file)
index 0000000..c325932
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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 "helpers.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr EoDataKey INSTANCE_PTR {"gallery,instance,data,ptr"};
+}}}
+
+namespace gallery {
+
+       using ucl::Window;
+
+       void setInstancePaused(Window &win, const bool value)
+       {
+               win.setData(impl::INSTANCE_PTR, reinterpret_cast<void *>(value));
+               win.callEvent((value ? INSTANCE_PAUSED : INSTANCE_RESUMED), nullptr);
+       }
+
+       bool isInstancePaused(const Window &win)
+       {
+               return (reinterpret_cast<intptr_t>(
+                               win.getData(impl::INSTANCE_PTR)) != 0);
+       }
+}
diff --git a/gallery/presenters/misc/helpers.h b/gallery/presenters/misc/helpers.h
new file mode 100644 (file)
index 0000000..8892553
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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_MISC_HELPERS_H__
+#define __GALLERY_PRESENTERS_MISC_HELPERS_H__
+
+#include "ucl/gui/Window.h"
+
+namespace gallery {
+
+       constexpr ucl::SmartEvent INSTANCE_PAUSED {"gallery,instance,paused"};
+       constexpr ucl::SmartEvent INSTANCE_RESUMED {"gallery,instance,resumed"};
+
+       void setInstancePaused(ucl::Window &win, bool value);
+       bool isInstancePaused(const ucl::Window &win);
+}
+
+#endif // __GALLERY_PRESENTERS_MISC_HELPERS_H__
diff --git a/gallery/presenters/pages/NoContentPage.cpp b/gallery/presenters/pages/NoContentPage.cpp
new file mode 100644 (file)
index 0000000..fb00b83
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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 "NoContentPage.h"
+
+#include "ucl/gui/Layout.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       using ucl::NaviItem;
+       using ucl::NaviframeSRef;
+       using ucl::Layout;
+
+       using ucl::LAYOUT_NO_CONTENTS;
+       using ucl::PART_TITLE;
+
+       // NoContentPage::Builder //
+
+       NoContentPage::Builder::Builder()
+       {
+       }
+
+       NoContentPage::Builder::~Builder()
+       {
+       }
+
+       NoContentPage::Builder &NoContentPage::Builder::setNaviframe(
+                       const NaviframeSRef &navi)
+       {
+               m_navi = navi;
+               return *this;
+       }
+
+       NoContentPageWRef NoContentPage::Builder::build(
+                       const ExitRequestHandler &onExitRequest) const
+       {
+               if (!onExitRequest) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "onExitRequest is NULL");
+               }
+               if (!m_navi) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+               }
+
+               auto result = makeShared<NoContentPage>(m_navi, onExitRequest);
+
+               FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
+                       {
+                               return result->doPrepare(item);
+                       }),
+                       {}, "result->prepare() failed!");
+
+               return result;
+       }
+
+       // NoContentPage //
+
+       NoContentPage::NoContentPage(IRefCountObj &rc,
+                       const NaviframeSRef &navi,
+                       const ExitRequestHandler &onExitRequest) :
+               Page(rc, navi, onExitRequest)
+       {
+       }
+
+       NoContentPage::~NoContentPage()
+       {
+       }
+
+       Result NoContentPage::doPrepare(NaviItem &item)
+       {
+               const auto layout = Layout::Builder().
+                               setTheme(LAYOUT_NO_CONTENTS).
+                               build(getNaviframe());
+               if (!layout) {
+                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+               }
+
+               const auto icon = Layout::Builder().
+                               setTheme(getImageTheme(ICON_NO_PHOTOS)).
+                               setIsOwner(false).
+                               build(*layout);
+               if (!icon) {
+                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+               }
+
+               layout->setContent(*icon);
+               layout->setText(STR_APP_NAME, PART_TITLE);
+               layout->setText(STR_NO_PHOTOS);
+
+               item = getNaviframe().push(*layout, NAVIFRAME_NO_CLIP);
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+               }
+
+               layout->setIsOwner(false);
+
+               return RES_OK;
+       }
+}
diff --git a/gallery/presenters/pages/NoContentPage.h b/gallery/presenters/pages/NoContentPage.h
new file mode 100644 (file)
index 0000000..26e64dd
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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_PAGES_NO_CONTENT_PAGE_H__
+#define __GALLERY_PRESENTERS_PAGES_NO_CONTENT_PAGE_H__
+
+#include "gallery/presenters/base/Page.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(NoContentPage);
+
+       class NoContentPage final : public Page {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       ~Builder();
+                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+                       NoContentPageWRef build(
+                                       const ExitRequestHandler &onExitRequest) const;
+               private:
+                       ucl::NaviframeSRef m_navi;
+               };
+
+       private:
+               friend class ucl::ReffedObj<NoContentPage>;
+               NoContentPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
+                               const ExitRequestHandler &onExitRequest);
+               virtual ~NoContentPage();
+
+               ucl::Result doPrepare(ucl::NaviItem &item);
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_PAGES_NO_CONTENT_PAGE_H__
diff --git a/gallery/presenters/pages/PreviewPage.cpp b/gallery/presenters/pages/PreviewPage.cpp
new file mode 100644 (file)
index 0000000..7b70dc5
--- /dev/null
@@ -0,0 +1,722 @@
+/*
+ * 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 "PreviewPage.h"
+
+#include "ViewerPage.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr auto POPUP_SHOW_TIME_SEC = 0.3;
+
+       constexpr auto BRING_IN_SCROLL_FRICTION = 0.25;
+       constexpr auto PAGE_SCROLL_IN_FRICTION = 0.25;
+
+       enum {
+               MORE_OPTION_ID_DELETE
+       };
+}}}
+
+namespace gallery {
+
+       using ucl::NaviItem;
+       using ucl::NaviframeSRef;
+       using ucl::RefCountAware;
+
+       // PreviewPage::Builder //
+
+       PreviewPage::Builder::Builder() :
+               m_startItemIndex(0),
+               m_selectModeStartup(false),
+               m_autoSelectStartItem(false)
+       {
+       }
+
+       PreviewPage::Builder::~Builder()
+       {
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setNaviframe(
+                       const NaviframeSRef &navi)
+       {
+               m_navi = navi;
+               return *this;
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setAlbum(
+                       const IMediaAlbumSRef &album)
+       {
+               m_album = album;
+               return *this;
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setStartItemIndex(
+                       const int index)
+       {
+               m_startItemIndex = index;
+               return *this;
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setSelectModeStartup(
+                       const bool value)
+       {
+               m_selectModeStartup = value;
+               return *this;
+       }
+
+       PreviewPage::Builder &PreviewPage::Builder::setAutoSelectStartItem(
+                       const bool value)
+       {
+               m_autoSelectStartItem = value;
+               return *this;
+       }
+
+       PreviewPageWRef PreviewPage::Builder::build(
+                       const ExitRequestHandler &onExitRequest) const
+       {
+               if (!onExitRequest) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "onExitRequest is NULL");
+               }
+               if (!m_navi) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+               }
+               if (!m_album) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
+               }
+
+               auto result = makeShared<PreviewPage>(
+                               m_navi, onExitRequest, m_album, m_selectModeStartup);
+
+               FAIL_RETURN_VALUE(result->prepare([this, &result](NaviItem &item)
+                       {
+                               return result->doPrepare(m_startItemIndex, item);
+                       }),
+                       {}, "result->prepare() failed!");
+
+               if (m_selectModeStartup && m_autoSelectStartItem) {
+                       result->selectItem(m_startItemIndex);
+               }
+
+               return result;
+       }
+
+       // PreviewPage::Item //
+
+       class PreviewPage::Item : public RefCountAware {
+       public:
+               Item(IRefCountObj &rc, MediaItemSRef &&media,
+                               ImageGrid &imageGrid, const int itemIndex) :
+                       RefCountAware(&rc),
+                       m_media(std::move(media)),
+                       m_imageGrid(imageGrid),
+                       m_index(itemIndex),
+                       m_isSelected(false)
+               {
+               }
+
+               void realize()
+               {
+                       FAIL_LOG(m_media->getThumbnailPath(
+                                       WEAK_DELEGATE(Item::onThumbnail, asWeak(*this))),
+                                       "getThumbnailPath() failed!");
+               }
+
+               void unrealize()
+               {
+                       m_media->cancelThumbnailPathGet();
+               }
+
+               MediaItemSRef getMedia()
+               {
+                       return m_media;
+               }
+
+               void setSelected(const bool selected)
+               {
+                       if (selected == m_isSelected) {
+                               return;
+                       }
+                       m_isSelected = selected;
+
+                       if (m_imageGrid.isInSelectMode() && !m_imageGrid.isInTransition()) {
+                               ImageGrid::ItemParams params = {};
+                               addFlags(params);
+                               m_imageGrid.updateItem(m_index, params);
+                       }
+               }
+
+               bool isSelected() const
+               {
+                       return m_isSelected;
+               }
+
+               void toggleSelected()
+               {
+                       setSelected(!m_isSelected);
+               }
+
+       private:
+               void onThumbnail(const Result result, const std::string &path)
+               {
+                       FAIL_LOG(result, "Failed to get thumbnail!");
+
+                       ImageGrid::ItemParams params = {};
+                       params.imagePath = m_media->getFilePath();
+                       params.bgImagePath = path;
+                       m_media->getResolution(params.imageWidth, params.imageHeight);
+                       addFlags(params);
+
+                       m_imageGrid.updateItem(m_index, params);
+               }
+
+               void addFlags(ImageGrid::ItemParams &params) const
+               {
+                       params.flags |= (m_imageGrid.isInSelectMode() ?
+                                       0 : ImageGrid::UF_BLOCK_CLICKS);
+                       params.flags |= (m_isSelected ? ImageGrid::UF_SELECTED : 0);
+               }
+
+       private:
+               const MediaItemSRef m_media;
+               ImageGrid &m_imageGrid;
+               const int m_index;
+               bool m_isSelected;
+       };
+
+       // PreviewPage //
+
+       PreviewPage::PreviewPage(IRefCountObj &rc,
+                       const NaviframeSRef &navi,
+                       const ExitRequestHandler &onExitRequest,
+                       const IMediaAlbumSRef &album,
+                       const bool selectModeStartup) :
+               Page(rc, navi, onExitRequest),
+               m_album(album),
+               m_selectModeStartup(selectModeStartup),
+               m_selectCount(0),
+               m_isInSelectMode(false),
+               m_needReload(false)
+       {
+       }
+
+       PreviewPage::~PreviewPage()
+       {
+               if (m_album) {
+                       m_album->delChangeHandler(WEAK_DELEGATE(
+                                       PreviewPage::onAlbumChanged, asWeak(*this)));
+               }
+               closeTempViews();
+               util::dispose(m_page);
+               if (m_imageGrid) {
+                       m_imageGrid->setListener(nullptr);
+               }
+       }
+
+       void PreviewPage::reload()
+       {
+               if (m_imageGrid->isInTransition()) {
+                       m_needReload = true;
+                       return;
+               }
+
+               {
+                       ImageGrid::Unrealizer u(*m_imageGrid);
+
+                       m_items.clear();
+
+                       FAIL_LOG(m_album->forEachMedia(
+                                       DELEGATE(PreviewPage::onEachMedia, this)),
+                                       "m_album->forEachMedia() failed!");
+
+                       m_imageGrid->setItemCount(m_items.size());
+               }
+
+               // TODO Temp solution.
+               // Need to add synchronization with curent state in the future.
+               closeTempViews();
+               switchToNormalMode();
+
+               checkViewerPage();
+       }
+
+       void PreviewPage::checkViewerPage()
+       {
+               if (const auto page = dynamicRefCast<ViewerPage>(m_page).lock()) {
+                       const auto mediaId = page->getMediaId();
+                       const auto it = std::find_if(m_items.begin(), m_items.end(),
+                               [&mediaId](const ItemSRef &item)
+                               {
+                                       return (item->getMedia()->getId() == mediaId);
+                               });
+                       if (it == m_items.end()) {
+                               DLOG("Viewed media item was removed.");
+                               deleteTo();
+                       } else {
+                               m_imageGrid->scrollToItem(it - m_items.begin());
+                       }
+               }
+       }
+
+       int PreviewPage::getCurrentItemIndex() const
+       {
+               return getSafeItemIndex(m_imageGrid->getScrolledToItemIndex());
+       }
+
+       Result PreviewPage::doPrepare(const int startItemIndex, NaviItem &item)
+       {
+               m_content = PageContent::Builder().
+                               setFlags(PageContent::FLAG_BOTTOM_BUTTON |
+                                               PageContent::FLAG_SELECT_BUTTON |
+                                               PageContent::FLAG_MORE_OPTIONS).
+                               build(getNaviframe());
+               if (!m_content) {
+                       LOG_RETURN(RES_FAIL, "PageContent::build() failed!");
+               }
+               setDeactivatorSink(m_content);
+
+               m_imageGrid = ImageGrid::Builder().
+                               setListener(asWeakThis<ImageGrid::IListener>(this)).
+                               setType(ImageGrid::Type::LINEAR).
+                               setSelectModeStartup(m_selectModeStartup).
+                               build(*m_content);
+               if (!m_imageGrid) {
+                       LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
+               }
+               m_content->set(*m_imageGrid);
+               ImageGrid::Unrealizer u(*m_imageGrid);
+
+               m_more = MoreOptionsPresenter::Builder().
+                               setParentWidget(m_content).
+                               addOption({impl::MORE_OPTION_ID_DELETE,
+                                       STR_DELETE, nullptr,
+                                       getImageTheme(ICON_MORE_OPT_DELETE)}).
+                               build(*this);
+               if (!m_more) {
+                       LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!");
+               }
+               m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS);
+
+               m_smp = SelectModePresenter::Builder().
+                               setPageContent(m_content).
+                               setFlags(SelectModePresenter::FLAG_NO_MORE_OPTIONS).
+                               build(*this);
+               if (!m_smp) {
+                       LOG_RETURN(RES_FAIL, "SelectModePresenter::build() failed!");
+               }
+
+               m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
+               if (!m_atspiHelper) {
+                       LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!");
+               }
+
+               FAIL_RETURN(m_album->forEachMedia(
+                               DELEGATE(PreviewPage::onEachMedia, this)),
+                               "m_album->forEachMedia() failed!");
+
+               m_imageGrid->setItemCount(m_items.size());
+
+               item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP);
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+               }
+
+               m_album->addChangeHandler(WEAK_DELEGATE(
+                               PreviewPage::onAlbumChanged, asWeak(*this)));
+
+               m_more->setListener(asWeakThis<MoreOptionsPresenter::IListener>(this));
+               m_smp->setListener(asWeakThis<SelectModePresenter::IListener>(this));
+
+               m_atspiHelper->setEventHandler(WEAK_DELEGATE(
+                               PreviewPage::onAtspiHighlight, asWeak(*this)));
+               m_atspiHelper->registerWidget(m_smp->getSelectButton());
+               m_atspiHelper->registerWidget(m_smp->getBottomButton());
+
+               if (m_selectModeStartup) {
+                       switchToSelectMode();
+               }
+               if (startItemIndex > 0) {
+                       showItem(startItemIndex);
+               }
+
+               return RES_OK;
+       }
+
+       void PreviewPage::showItem(const int itemIndex)
+       {
+               m_imageGrid->scrollToItem(getSafeItemIndex(itemIndex));
+       }
+
+       void PreviewPage::selectItem(const int itemIndex)
+       {
+               if (!m_isInSelectMode) {
+                       LOG_RETURN_VOID(RES_INVALID_ARGUMENTS, "Not in select mode!");
+               }
+               if (getSafeItemIndex(itemIndex) != itemIndex) {
+                       LOG_RETURN_VOID(RES_INVALID_ARGUMENTS, "itemIndex out of range!");
+               }
+               if (!m_items[itemIndex]->isSelected()) {
+                       toggleItemSelected(itemIndex);
+               }
+       }
+
+       int PreviewPage::getSafeItemIndex(const int itemIndex) const
+       {
+               if (itemIndex < 0) {
+                       return 0;
+               }
+               if (itemIndex >= static_cast<int>(m_items.size())) {
+                       return (m_items.size() - 1);
+               }
+               return itemIndex;
+       }
+
+       void PreviewPage::onAlbumChanged()
+       {
+               if (m_selectModeStartup) {
+                       requestExit();
+               } else if (!isEmpty(m_album)) {
+                       reload();
+               }
+       }
+
+       bool PreviewPage::onEachMedia(MediaItemSRef &&media)
+       {
+               m_items.emplace_back(makeShared<Item>(
+                               std::move(media), *m_imageGrid, m_items.size()));
+               return true;
+       }
+
+       void PreviewPage::onActivateBy(const DeactivatorInfo &info)
+       {
+               if (info.deactivator == &getNaviframe()) {
+                       elm_config_scroll_page_scroll_friction_set(
+                                       impl::PAGE_SCROLL_IN_FRICTION);
+                       elm_config_scroll_bring_in_scroll_friction_set(
+                                       impl::BRING_IN_SCROLL_FRICTION);
+               }
+
+               if (isActive() || m_smp->isActive()) {
+                       m_imageGrid->activateRotary();
+               }
+       }
+
+       void PreviewPage::onDeactivateBy(const DeactivatorInfo &info)
+       {
+               if (!m_smp->isActive()) {
+                       m_imageGrid->deactivateRotary();
+               }
+       }
+
+       void PreviewPage::onBackKey()
+       {
+               if (m_isInSelectMode && !m_selectModeStartup) {
+                       switchToNormalMode();
+                       return;
+               }
+               requestExit();
+       }
+
+       void PreviewPage::onItemRealized(const int itemIndex)
+       {
+               m_items[itemIndex]->realize();
+       }
+
+       void PreviewPage::onItemUnrealized(const int itemIndex)
+       {
+               m_items[itemIndex]->unrealize();
+       }
+
+       void PreviewPage::onItemEvent(const int itemIndex,
+                       const ImageGrid::ItemEvent event, const int x, const int y)
+       {
+               if (!isActive() || m_more->isOpened()) {
+                       return;
+               }
+
+               if (m_isInSelectMode) {
+                       if (event == ImageGrid::ItemEvent::CLICK) {
+                               toggleItemSelected(itemIndex);
+                               m_imageGrid->bringInItem(itemIndex);
+                       }
+                       return;
+               }
+
+               switch (event) {
+               case ImageGrid::ItemEvent::TAP_AND_HOLD:
+                       switchToSelectMode();
+                       toggleItemSelected(itemIndex);
+                       break;
+               case ImageGrid::ItemEvent::DOUBLE_TAP:
+                       openViewer(itemIndex, x, y);
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       void PreviewPage::onTransitionFinished()
+       {
+               if (m_needReload) {
+                       m_needReload = false;
+                       reload();
+               } else {
+                       m_imageGrid->update();
+               }
+               activateBy(m_imageGrid.get());
+       }
+
+       Elm_Interface_Atspi_Accessible *PreviewPage::onAccessObjectRequest(
+                       bool isFlowsTo)
+       {
+               if (m_isInSelectMode) {
+                       return (isFlowsTo ?
+                                       m_smp->getBottomButton() :
+                                       m_smp->getSelectButton());
+               }
+               return nullptr;
+       }
+
+       Elm_Interface_Atspi_Accessible *PreviewPage::onAtspiHighlight(
+                               Widget &widget, Elm_Atspi_Relation_Type flowRelation)
+       {
+               if (widget == m_smp->getSelectButton()) {
+                       if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
+                               return m_imageGrid->getAccessObject(true);
+                       }
+               } else if (widget == m_smp->getBottomButton()) {
+                       if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
+                               return m_imageGrid->getAccessObject(false);
+                       }
+               } else if (widget == getWindow()) {
+                       return (m_isInSelectMode ?
+                                       m_smp->getSelectButton() :
+                                       m_imageGrid->getAccessObject(true));
+               } else {
+                       LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
+               }
+               return widget.getEo();
+       }
+
+       void PreviewPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
+                       const MoreOptionsPresenter::Option &option)
+       {
+               switch (option.id) {
+               case impl::MORE_OPTION_ID_DELETE:
+                       sender.setOpenedDelayed(false, impl::POPUP_SHOW_TIME_SEC);
+                       confirmItemsDelete();
+                       break;
+               default:
+                       sender.setOpened(false);
+                       WLOG("Unknown option id: %d;", option.id);
+                       break;
+               }
+       }
+
+       void PreviewPage::onSelectModeEvent(const SelectModePresenter::Event event)
+       {
+               if (m_more->isOpened()) {
+                       return;
+               }
+
+               switch (event) {
+               case SelectModePresenter::Event::SELECT_ALL:
+               case SelectModePresenter::Event::DESELECT_ALL:
+                       {
+                               const bool isSelect =
+                                               (event == SelectModePresenter::Event::SELECT_ALL);
+                               for (auto &item: m_items) {
+                                       item->setSelected(isSelect);
+                               }
+                               m_selectCount = (isSelect * m_items.size());
+                               m_smp->update(m_selectCount);
+                       }
+                       break;
+
+               case SelectModePresenter::Event::BOTTOM_BUTTON_CLICK:
+                       confirmItemsDelete();
+                       break;
+               }
+       }
+
+       void PreviewPage::confirmItemsDelete()
+       {
+               const int itemCount = (m_isInSelectMode ? m_selectCount : 1);
+               if (itemCount == 0) {
+                       WLOG("itemCount == 0");
+                       return;
+               }
+
+               m_alert = AlertDialog::Builder().
+                               setType(AlertDialog::Type::OK_CANCEL).
+                               setText((itemCount == 1) ?
+                                       STR_DELETE_1_PHOTO :
+                                       TString(STR_DELETE_N_PHOTO.format(itemCount))).
+                               setHandler(WEAK_DELEGATE(
+                                       PreviewPage::onAlertEvent, asWeak(*this))).
+                               build(getNaviframe());
+       }
+
+       bool PreviewPage::onAlertEvent(AlertDialog &dialog,
+                       AlertDialog::Event event)
+       {
+               if (event != AlertDialog::Event::OK) {
+                       return true;
+               }
+
+               MediaItems items;
+
+               if (m_isInSelectMode) {
+                       for (auto &item: m_items) {
+                               if (item->isSelected()) {
+                                       items.emplace_back(item->getMedia());
+                               }
+                       }
+               } else {
+                       const int itemIndex = getCurrentItemIndex();
+                       if (itemIndex < 0) {
+                               ELOG("Invalid item index!");
+                               return true;
+                       }
+                       items.emplace_back(m_items[itemIndex]->getMedia());
+               }
+
+               m_job = MediaItem::RemoverBuilder().
+                               setItems(items).
+                               build(WEAK_DELEGATE(
+                                       PreviewPage::onJobComplete, asWeak(*this)));
+               if (!m_job) {
+                       ELOG("MediaItem::RemoverBuilder::build() failed!");
+                       return true;
+               }
+
+               m_processing = ProcessingPresenter::Builder().
+                       setProcessingText(STR_DELETING).
+                       build(*m_content);
+
+               return true;
+       }
+
+       void PreviewPage::onJobComplete()
+       {
+               if (m_processing) {
+                       if (isGood(m_job->getResult())) {
+                               m_processing->complete(STR_DELETED,
+                                               ProcessingPresenter::IconType::CHECK);
+                       } else {
+                               m_processing->complete(STR_FAILED);
+                       }
+                       m_processing.reset();
+               }
+
+               m_job.reset();
+
+               m_album->defragment();
+       }
+
+       void PreviewPage::closeTempViews()
+       {
+               util::dispose(m_alert);
+               if (m_more) {
+                       m_more->setOpened(false);
+               }
+       }
+
+       void PreviewPage::switchToSelectMode()
+       {
+               if (m_isInSelectMode) {
+                       return;
+               }
+               m_isInSelectMode = true;
+
+               m_selectCount = 0;
+               for (auto &item: m_items) {
+                       item->setSelected(false);
+               }
+
+               m_imageGrid->setSelectModeEnabled(true);
+               if (m_imageGrid->isInTransition()) {
+                       deactivateBy(m_imageGrid.get());
+               }
+
+               m_content->setMoreOptionsVisible(false);
+
+               m_smp->setBottomButtonText(STR_DELETE_CAPS);
+               m_smp->update(m_selectCount, m_items.size());
+               m_smp->setVisible(true);
+       }
+
+       void PreviewPage::switchToNormalMode()
+       {
+               if (!m_isInSelectMode) {
+                       return;
+               }
+               m_isInSelectMode = false;
+
+               m_imageGrid->setSelectModeEnabled(false);
+               if (m_imageGrid->isInTransition()) {
+                       deactivateBy(m_imageGrid.get());
+               }
+
+               m_content->setMoreOptionsVisible(true);
+
+               m_smp->setVisible(false);
+       }
+
+       void PreviewPage::toggleItemSelected(const int itemIndex)
+       {
+               m_items[itemIndex]->toggleSelected();
+
+               m_selectCount = 0;
+               for (auto &item: m_items) {
+                       m_selectCount += item->isSelected();
+               }
+
+               m_smp->update(m_selectCount);
+
+               if (m_selectCount == 0) {
+                       m_more->setOpened(false);
+               }
+       }
+
+       void PreviewPage::openViewer(const int itemIndex, const int x, const int y)
+       {
+               ViewerPage::Builder builder;
+               builder.setNaviframe(asShared(getNaviframe()));
+               builder.setZoomIn(x, y);
+               builder.setMedia(m_items[itemIndex]->getMedia());
+
+               ImageGrid::ItemInfo info = {};
+               m_imageGrid->getItemInfo(itemIndex, info);
+               if (info.isImageLoaded) {
+                       builder.setImageLoadSize(info.imageLoadSize,
+                                       info.isImageLoadSizeFull);
+               }
+
+               m_page = builder.build(WEAK_DELEGATE(
+                               PreviewPage::onPageExitRequest, asWeak(*this)));
+       }
+
+       void PreviewPage::onPageExitRequest(Page &page)
+       {
+               m_page.reset();
+               deleteTo();
+       }
+}
diff --git a/gallery/presenters/pages/PreviewPage.h b/gallery/presenters/pages/PreviewPage.h
new file mode 100644 (file)
index 0000000..0df248d
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * 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_PAGES_PREVIEW_PAGE_H__
+#define __GALLERY_PRESENTERS_PAGES_PREVIEW_PAGE_H__
+
+#include "gallery/model/IMediaAlbum.h"
+
+#include "gallery/view/PageContent.h"
+#include "gallery/view/ImageGrid.h"
+
+#include "gallery/presenters/base/Page.h"
+
+#include "gallery/presenters/misc/MoreOptionsPresenter.h"
+#include "gallery/presenters/misc/SelectModePresenter.h"
+#include "gallery/presenters/misc/ProcessingPresenter.h"
+#include "gallery/presenters/misc/AtspiHighlightHelper.h"
+
+#include "gallery/presenters/dialogs/AlertDialog.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(PreviewPage);
+
+       class PreviewPage final : public Page,
+                       private ImageGrid::IListener,
+                       private MoreOptionsPresenter::IListener,
+                       private SelectModePresenter::IListener {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       ~Builder();
+                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+                       Builder &setAlbum(const IMediaAlbumSRef &album);
+                       Builder &setStartItemIndex(int index);
+                       Builder &setSelectModeStartup(bool value);
+                       Builder &setAutoSelectStartItem(bool value);
+                       PreviewPageWRef build(
+                                       const ExitRequestHandler &onExitRequest) const;
+               private:
+                       ucl::NaviframeSRef m_navi;
+                       IMediaAlbumSRef m_album;
+                       int m_startItemIndex;
+                       bool m_selectModeStartup;
+                       bool m_autoSelectStartItem;
+               };
+
+       public:
+               int getCurrentItemIndex() const;
+
+       private:
+               friend class ucl::ReffedObj<PreviewPage>;
+               PreviewPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
+                               const ExitRequestHandler &onExitRequest,
+                               const IMediaAlbumSRef &album, bool selectModeStartup);
+               virtual ~PreviewPage();
+
+               ucl::Result doPrepare(int startItemIndex, ucl::NaviItem &item);
+               void showItem(int itemIndex);
+               void selectItem(int itemIndex);
+               int getSafeItemIndex(int itemIndex) const;
+
+               void reload();
+               void checkViewerPage();
+
+               void onAlbumChanged();
+               bool onEachMedia(MediaItemSRef &&media);
+
+               void closeTempViews();
+               void switchToSelectMode();
+               void switchToNormalMode();
+               void toggleItemSelected(int itemIndex);
+               void confirmItemsDelete();
+               void openViewer(int itemIndex, int x, int y);
+
+               void onPageExitRequest(Page &page);
+
+               bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
+               void onJobComplete();
+
+               Elm_Interface_Atspi_Accessible *onAtspiHighlight(
+                               ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation);
+
+               // GuiPresenter //
+
+               virtual void onActivateBy(const DeactivatorInfo &info) final override;
+               virtual void onDeactivateBy(const DeactivatorInfo &info) final override;
+
+               // Page //
+
+               virtual void onBackKey() final override;
+
+               // ImageGrid::IListener //
+
+               virtual void onItemRealized(int itemIndex) final override;
+               virtual void onItemUnrealized(int itemIndex) final override;
+               virtual void onItemEvent(int itemIndex,
+                               ImageGrid::ItemEvent event, int x, int y) final override;
+               virtual void onTransitionFinished() final override;
+               virtual Elm_Interface_Atspi_Accessible *onAccessObjectRequest(
+                               bool isFlowsTo) final override;
+
+               // MoreOptionsPresenter::IListener //
+
+               virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
+                               const MoreOptionsPresenter::Option &option) final override;
+
+               // SelectModePresenter::IListener //
+
+               virtual void onSelectModeEvent(
+                               SelectModePresenter::Event event) final override;
+
+       private:
+               class Item;
+               using ItemSRef = ucl::SharedRef<Item>;
+
+       private:
+               const IMediaAlbumSRef m_album;
+               const bool m_selectModeStartup;
+               ImageGridSRef m_imageGrid;
+               std::vector<ItemSRef> m_items;
+               IJobSRef m_job;
+
+               PageContentSRef m_content;
+               MoreOptionsPresenterSRef m_more;
+               SelectModePresenterSRef m_smp;
+               DialogWRef m_alert;
+               ProcessingPresenterSRef m_processing;
+               AtspiHighlightHelperSRef m_atspiHelper;
+
+               PageWRef m_page;
+               int m_selectCount;
+               bool m_isInSelectMode;
+               bool m_needReload;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_PAGES_PREVIEW_PAGE_H__
diff --git a/gallery/presenters/pages/ThumbnailPage.cpp b/gallery/presenters/pages/ThumbnailPage.cpp
new file mode 100644 (file)
index 0000000..13ffdc5
--- /dev/null
@@ -0,0 +1,361 @@
+/*
+ * 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 "ThumbnailPage.h"
+
+#include "PreviewPage.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr auto NAVIFRAME_TRANSITION_TIME_SEC = 0.3;
+
+       constexpr auto BRING_IN_SCROLL_FRICTION = 0.5;
+       constexpr auto PAGE_SCROLL_IN_FRICTION = 0.5;
+
+       enum {
+               MORE_OPTION_ID_DELETE
+       };
+}}}
+
+namespace gallery {
+
+       using ucl::NaviItem;
+       using ucl::NaviframeSRef;
+       using ucl::RefCountAware;
+
+       // ThumbnailPage::Builder //
+
+       ThumbnailPage::Builder::Builder()
+       {
+       }
+
+       ThumbnailPage::Builder::~Builder()
+       {
+       }
+
+       ThumbnailPage::Builder &ThumbnailPage::Builder::setNaviframe(
+                       const NaviframeSRef &navi)
+       {
+               m_navi = navi;
+               return *this;
+       }
+
+       ThumbnailPage::Builder &ThumbnailPage::Builder::setAlbum(
+                       const IMediaAlbumSRef &album)
+       {
+               m_album = album;
+               return *this;
+       }
+
+       ThumbnailPageWRef ThumbnailPage::Builder::build(
+                       const ExitRequestHandler &onExitRequest) const
+       {
+               if (!onExitRequest) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "onExitRequest is NULL");
+               }
+               if (!m_navi) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+               }
+               if (!m_album) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
+               }
+
+               auto result = makeShared<ThumbnailPage>(
+                               m_navi, onExitRequest, m_album);
+
+               FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
+                       {
+                               return result->doPrepare(item);
+                       }),
+                       {}, "result->prepare() failed!");
+
+               return result;
+       }
+
+       // ThumbnailPage::RealizedItem //
+
+       class ThumbnailPage::RealizedItem : public RefCountAware {
+       public:
+               RealizedItem(IRefCountObj &rc,
+                               ThumbnailPage &parent, const int index) :
+                       RefCountAware(&rc),
+                       m_parent(parent),
+                       m_index(index)
+               {
+                       FAIL_LOG(m_parent.m_mediaItems[m_index]->getThumbnailPath(
+                                       WEAK_DELEGATE(RealizedItem::onThumbnail, asWeak(this))),
+                                       "getThumbnailPath() failed!");
+               }
+
+               virtual ~RealizedItem()
+               {
+                       m_parent.m_mediaItems[m_index]->cancelThumbnailPathGet();
+               }
+
+               int getIndex() const
+               {
+                       return m_index;
+               }
+
+       private:
+               void onThumbnail(const Result result, const std::string &path)
+               {
+                       FAIL_RETURN_VOID(result, "Failed to get thumbnail!");
+
+                       ImageGrid::ItemParams params = {};
+                       params.imagePath = path;
+                       m_parent.m_mediaItems[m_index]->getResolution(
+                                       params.imageWidth, params.imageHeight);
+
+                       m_parent.m_imageGrid->updateItem(m_index, params);
+               }
+
+       private:
+               ThumbnailPage &m_parent;
+               int m_index;
+       };
+
+       // ThumbnailPage //
+
+       ThumbnailPage::ThumbnailPage(IRefCountObj &rc,
+                       const NaviframeSRef &navi,
+                       const ExitRequestHandler &onExitRequest,
+                       const IMediaAlbumSRef &album) :
+               Page(rc, navi, onExitRequest),
+               m_album(album)
+       {
+       }
+
+       ThumbnailPage::~ThumbnailPage()
+       {
+               if (m_album) {
+                       m_album->delChangeHandler(WEAK_DELEGATE(
+                                       ThumbnailPage::onAlbumChanged, asWeak(*this)));
+               }
+               if (m_more) {
+                       m_more->setOpened(false);
+               }
+               util::dispose(m_page);
+               if (m_imageGrid) {
+                       m_imageGrid->setListener(nullptr);
+               }
+       }
+
+       void ThumbnailPage::reload()
+       {
+               ImageGrid::Unrealizer u(*m_imageGrid);
+
+               m_mediaItems.clear();
+
+               FAIL_LOG(m_album->forEachMedia(
+                               DELEGATE(ThumbnailPage::onEachMedia, this)),
+                               "m_album->forEachMedia() failed!");
+
+               m_imageGrid->setItemCount(m_mediaItems.size());
+       }
+
+       Result ThumbnailPage::doPrepare(NaviItem &item)
+       {
+               m_content = PageContent::Builder().
+                               setFlags(PageContent::FLAG_MORE_OPTIONS).
+                               build(getNaviframe());
+               if (!m_content) {
+                       LOG_RETURN(RES_FAIL, "PageContent::build() failed!");
+               }
+               setDeactivatorSink(m_content);
+
+               m_imageGrid = ImageGrid::Builder().
+                               setListener(asWeakThis<ImageGrid::IListener>(this)).
+                               setType(ImageGrid::Type::HCOMB_3X3).
+                               build(*m_content);
+               if (!m_imageGrid) {
+                       LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
+               }
+               m_content->set(*m_imageGrid);
+
+               m_more = MoreOptionsPresenter::Builder().
+                               setParentWidget(m_content).
+                               addOption({impl::MORE_OPTION_ID_DELETE,
+                                       STR_DELETE, nullptr,
+                                       getImageTheme(ICON_MORE_OPT_DELETE)}).
+                               build(*this);
+               if (!m_more) {
+                       LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!");
+               }
+               m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS);
+
+               m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
+               if (!m_atspiHelper) {
+                       LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!");
+               }
+
+               FAIL_RETURN(m_album->forEachMedia(
+                               DELEGATE(ThumbnailPage::onEachMedia, this)),
+                               "m_album->forEachMedia() failed!");
+
+               m_imageGrid->setItemCount(m_mediaItems.size());
+
+               item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP);
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+               }
+
+               m_album->addChangeHandler(WEAK_DELEGATE(
+                               ThumbnailPage::onAlbumChanged, asWeak(*this)));
+
+               m_more->setListener(asWeakThis<MoreOptionsPresenter::IListener>(this));
+
+               m_atspiHelper->setEventHandler(WEAK_DELEGATE(
+                               ThumbnailPage::onAtspiHighlight, asWeak(*this)));
+
+               return RES_OK;
+       }
+
+       void ThumbnailPage::onAlbumChanged()
+       {
+               if (!isEmpty(m_album)) {
+                       reload();
+               }
+       }
+
+       bool ThumbnailPage::onEachMedia(MediaItemSRef &&media)
+       {
+               m_mediaItems.emplace_back(std::move(media));
+               return true;
+       }
+
+       void ThumbnailPage::onActivateBy(const DeactivatorInfo &info)
+       {
+               if (info.deactivator == &getNaviframe()) {
+                       elm_config_scroll_page_scroll_friction_set(
+                                       impl::PAGE_SCROLL_IN_FRICTION);
+                       elm_config_scroll_bring_in_scroll_friction_set(
+                                       impl::BRING_IN_SCROLL_FRICTION);
+               }
+
+               if (isActive()) {
+                       m_imageGrid->activateRotary();
+               }
+       }
+
+       void ThumbnailPage::onDeactivateBy(const DeactivatorInfo &info)
+       {
+               m_imageGrid->deactivateRotary();
+       }
+
+       Elm_Interface_Atspi_Accessible *ThumbnailPage::onAtspiHighlight(
+                               Widget &widget, Elm_Atspi_Relation_Type flowRelation)
+       {
+               return m_imageGrid->getAccessObject(true);
+       }
+
+       void ThumbnailPage::onItemRealized(const int itemIndex)
+       {
+               m_realizedItems.emplace_back(
+                               makeShared<RealizedItem>(*this, itemIndex));
+       }
+
+       void ThumbnailPage::onItemUnrealized(const int itemIndex)
+       {
+               const auto it = std::find_if(
+                               m_realizedItems.begin(), m_realizedItems.end(),
+                               [itemIndex](const RealizedItemSRef &item)
+                               {
+                                       return (item->getIndex() == itemIndex);
+                               });
+               if (it != m_realizedItems.end()) {
+                       m_realizedItems.erase(it);
+               } else {
+                       WLOG("Item is not found in realized list!");
+               }
+       }
+
+       void ThumbnailPage::onItemEvent(const int itemIndex,
+                       const ImageGrid::ItemEvent event, const int x, const int y)
+       {
+               if (!isActive() || m_more->isOpened()) {
+                       return;
+               }
+
+               bool selectModeStartup = false;
+
+               switch (event) {
+               case ImageGrid::ItemEvent::CLICK:
+                       break;
+               case ImageGrid::ItemEvent::TAP_AND_HOLD:
+                       selectModeStartup = true;
+                       break;
+               default:
+                       return;
+               }
+
+               m_page = PreviewPage::Builder().
+                               setNaviframe(asShared(getNaviframe())).
+                               setAlbum(m_album).
+                               setStartItemIndex(itemIndex).
+                               setSelectModeStartup(selectModeStartup).
+                               setAutoSelectStartItem(true).
+                               build(WEAK_DELEGATE(
+                                       ThumbnailPage::onPageExitRequest, asWeak(*this)));
+       }
+
+       void ThumbnailPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
+                       const MoreOptionsPresenter::Option &option)
+       {
+               switch (option.id) {
+               case impl::MORE_OPTION_ID_DELETE:
+                       sender.setOpenedDelayed(false, impl::NAVIFRAME_TRANSITION_TIME_SEC);
+                       m_page = PreviewPage::Builder().
+                                       setNaviframe(asShared(getNaviframe())).
+                                       setAlbum(m_album).
+                                       setStartItemIndex(m_imageGrid->getScrolledToItemIndex()).
+                                       setSelectModeStartup(true).
+                                       build(WEAK_DELEGATE(
+                                               ThumbnailPage::onPageExitRequest, asWeak(*this)));
+                       break;
+               default:
+                       sender.setOpened(false);
+                       WLOG("Unknown option id: %d;", option.id);
+                       break;
+               }
+       }
+
+       void ThumbnailPage::onPageExitRequest(Page &page)
+       {
+               if (const auto page = dynamicRefCast<PreviewPage>(m_page).lock()) {
+                       m_imageGrid->scrollToItem(getSafeItemIndex(
+                                       page->getCurrentItemIndex()));
+               }
+               m_page.reset();
+               popTo();
+       }
+
+       int ThumbnailPage::getSafeItemIndex(const int itemIndex) const
+       {
+               if (itemIndex < 0) {
+                       return 0;
+               }
+               if (itemIndex >= static_cast<int>(m_mediaItems.size())) {
+                       return (m_mediaItems.size() - 1);
+               }
+               return itemIndex;
+       }
+}
diff --git a/gallery/presenters/pages/ThumbnailPage.h b/gallery/presenters/pages/ThumbnailPage.h
new file mode 100644 (file)
index 0000000..f808c8a
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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_PAGES_THUMBNAIL_PAGE_H__
+#define __GALLERY_PRESENTERS_PAGES_THUMBNAIL_PAGE_H__
+
+#include "gallery/model/IMediaAlbum.h"
+
+#include "gallery/view/PageContent.h"
+#include "gallery/view/ImageGrid.h"
+
+#include "gallery/presenters/base/Page.h"
+
+#include "gallery/presenters/misc/MoreOptionsPresenter.h"
+#include "gallery/presenters/misc/AtspiHighlightHelper.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(ThumbnailPage);
+
+       class ThumbnailPage final : public Page,
+                       private ImageGrid::IListener,
+                       private MoreOptionsPresenter::IListener {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       ~Builder();
+                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+                       Builder &setAlbum(const IMediaAlbumSRef &album);
+                       ThumbnailPageWRef build(
+                                       const ExitRequestHandler &onExitRequest) const;
+               private:
+                       ucl::NaviframeSRef m_navi;
+                       IMediaAlbumSRef m_album;
+               };
+
+       private:
+               friend class ucl::ReffedObj<ThumbnailPage>;
+               ThumbnailPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
+                               const ExitRequestHandler &onExitRequest,
+                               const IMediaAlbumSRef &album);
+               virtual ~ThumbnailPage();
+
+               ucl::Result doPrepare(ucl::NaviItem &item);
+
+               void reload();
+
+               int getSafeItemIndex(int itemIndex) const;
+
+               void onAlbumChanged();
+               bool onEachMedia(MediaItemSRef &&media);
+
+               void onPageExitRequest(Page &page);
+
+               Elm_Interface_Atspi_Accessible *onAtspiHighlight(
+                               ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation);
+
+               // GuiPresenter //
+
+               virtual void onActivateBy(const DeactivatorInfo &info) final override;
+               virtual void onDeactivateBy(const DeactivatorInfo &info) final override;
+
+               // ImageGrid::IListener //
+
+               virtual void onItemRealized(int itemIndex) final override;
+               virtual void onItemUnrealized(int itemIndex) final override;
+               virtual void onItemEvent(int itemIndex,
+                               ImageGrid::ItemEvent event, int x, int y) final override;
+
+               // MoreOptionsPresenter::IListener //
+
+               virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
+                               const MoreOptionsPresenter::Option &option) final override;
+
+       private:
+               class RealizedItem;
+               using RealizedItemSRef = ucl::SharedRef<RealizedItem>;
+
+       private:
+               const IMediaAlbumSRef m_album;
+               MediaItems m_mediaItems;
+
+               std::vector<RealizedItemSRef> m_realizedItems;
+
+               PageContentSRef m_content;
+               ImageGridSRef m_imageGrid;
+               MoreOptionsPresenterSRef m_more;
+               AtspiHighlightHelperSRef m_atspiHelper;
+
+               PageWRef m_page;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_PAGES_THUMBNAIL_PAGE_H__
diff --git a/gallery/presenters/pages/VideoPlayerPage.cpp b/gallery/presenters/pages/VideoPlayerPage.cpp
new file mode 100644 (file)
index 0000000..b2f695d
--- /dev/null
@@ -0,0 +1,714 @@
+/*
+ * 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 "VideoPlayerPage.h"
+
+#include <efl_util.h>
+
+#include "ucl/appfw/types.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr auto AUTO_START_TIMEOUT_SEC = 0.3;
+       constexpr auto CONTROLS_PLAYBACK_HIDE_TIMEOUT_SEC = 3.0;
+       constexpr auto CONTROLS_PAUSE_HIDE_TIMEOUT_SEC = 6.0;
+
+       constexpr auto TICK_TIMER_INTERVAL_SEC = 0.1;
+
+       constexpr auto TIME_SEC_MS = 1000;
+       constexpr auto TIME_MIN_SEC = 60;
+       constexpr auto TIME_HOUR_MIN = 60;
+
+       const TString TIME_SHORT_FORMAT {"%02d:%02d / %02d:%02d"};
+       const TString TIME_LONG_FORMAT {"%02d:%02d:%02d / %02d:%02d:%02d"};
+
+       constexpr LayoutTheme LAYOUT_VIDEO_PLAYER
+                       {"layout", "gallery", "video_player"};
+
+       constexpr ElmStyle STYLE_VOLUME_ON_BTN {"gallery_video_volume_on"};
+       constexpr ElmStyle STYLE_VOLUME_MUTE_BTN {"gallery_video_volume_mute"};
+       constexpr ElmStyle STYLE_PLAY_BTN {"gallery_video_play"};
+       constexpr ElmStyle STYLE_PAUSE_BTN {"gallery_video_pause"};
+
+       constexpr EdjePart PART_VOLUME_ON_BTN {"gallery.swallow.volume_on"};
+       constexpr EdjePart PART_VOLUME_MUTE_BTN {"gallery.swallow.volume_mute"};
+       constexpr EdjePart PART_PLAY_BTN {"gallery.swallow.play"};
+       constexpr EdjePart PART_PAUSE_BTN {"gallery.swallow.pause"};
+
+       constexpr EdjeSignal SHOW_VOLUME_ON_BTN {"show,volume_on,btn"};
+       constexpr EdjeSignal SHOW_VOLUME_MUTE_BTN {"show,volume_mute,btn"};
+       constexpr EdjeSignal HIDE_VOLUME_BTN {"hide,volume,btn"};
+
+       constexpr EdjeSignal SHOW_PLAY_BTN {"show,play,btn"};
+       constexpr EdjeSignal SHOW_PAUSE_BTN {"show,pause,btn"};
+       constexpr EdjeSignal HIDE_PLAY_PAUSE_BTN {"hide,play_pause,btn"};
+
+       constexpr EdjeSignal SHOW_TEXT {"show,text"};
+       constexpr EdjeSignal HIDE_TEXT {"hide,text"};
+
+       void timeMsToHMS(int timeMs, int &h, int &m, int &s)
+       {
+               int t = (timeMs / TIME_SEC_MS);
+               s = (t % TIME_MIN_SEC);
+               t /= TIME_MIN_SEC;
+               m = (t % TIME_HOUR_MIN);
+               h = (t / TIME_HOUR_MIN);
+       }
+}}}
+
+namespace gallery {
+
+       using ucl::AutoAppCtrl;
+
+       using ucl::NaviItem;
+       using ucl::NaviframeSRef;
+       using ucl::Layout;
+       using ucl::StyledWidgetSRef;
+       using ucl::WidgetEventHandler;
+
+       // VideoPlayerPage::Builder //
+
+       VideoPlayerPage::Builder::Builder()
+       {
+       }
+
+       VideoPlayerPage::Builder::~Builder()
+       {
+       }
+
+       VideoPlayerPage::Builder &VideoPlayerPage::Builder::setNaviframe(
+                       const NaviframeSRef &navi)
+       {
+               m_navi = navi;
+               return *this;
+       }
+
+       VideoPlayerPage::Builder &VideoPlayerPage::Builder::setMedia(
+                       const MediaItemSRef &media)
+       {
+               m_media = media;
+               return *this;
+       }
+
+       VideoPlayerPageWRef VideoPlayerPage::Builder::build(
+                       const ExitRequestHandler &onExitRequest) const
+       {
+               if (!onExitRequest) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "onExitRequest is NULL");
+               }
+               if (!m_navi) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+               }
+               if (!m_media) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_media is NULL");
+               }
+               if (m_media->getType() != MediaType::VIDEO) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Wrong media type");
+               }
+
+               auto result = makeShared<VideoPlayerPage>(
+                               m_navi, onExitRequest, m_media);
+
+               FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
+                       {
+                               return result->doPrepare(item);
+                       }),
+                       {}, "result->prepare() failed!");
+
+               return result;
+       }
+
+       // VideoPlayerPage //
+
+       VideoPlayerPage::VideoPlayerPage(IRefCountObj &rc,
+                       const NaviframeSRef &navi,
+                       const ExitRequestHandler &onExitRequest,
+                       const MediaItemSRef &media) :
+               Page(rc, navi, onExitRequest),
+               m_media(media),
+               m_player(),
+               m_videoDuration(0),
+               m_autoStartTimer(nullptr),
+               m_controlsHideTimer(nullptr),
+               m_tickTimer(nullptr),
+               m_state(State::PAUSED),
+               m_isControlsVisible(false),
+               m_needAutoStart(true),
+               m_isPlaybackCompleted(false)
+       {
+       }
+
+       VideoPlayerPage::~VideoPlayerPage()
+       {
+               util::dispose(m_alert);
+
+               if (m_soundMgr) {
+                       m_soundMgr->delMediaDeviceStateChangeHandler(WEAK_DELEGATE(
+                                       VideoPlayerPage::onMediaDeviceStateChanged, asWeak(*this)));
+                       m_soundMgr->delMediaVolumeChangeHandler(WEAK_DELEGATE(
+                                       VideoPlayerPage::onMediaVolumeChanged, asWeak(*this)));
+               }
+
+               if (isWindowReady()) {
+                       setScreenAlwaysOn(false);
+               }
+
+               delRotaryEventHandler(CALLBACK_A(VideoPlayerPage::onRotary), this);
+
+               stopTimer(m_autoStartTimer);
+               stopTimer(m_controlsHideTimer);
+               stopTimer(m_tickTimer);
+
+               if (m_player) {
+                       if (getPlayerState() != PLAYER_STATE_IDLE) {
+                               FAIL_LOG(util::call(player_unprepare, m_player),
+                                               "player_unprepare() failed!");
+                       }
+                       FAIL_LOG(util::call(player_destroy, m_player),
+                                       "player_destroy() failed!");
+               }
+       }
+
+       Result VideoPlayerPage::doPrepare(NaviItem &item)
+       {
+               m_content = Layout::Builder().
+                               setTheme(impl::LAYOUT_VIDEO_PLAYER).
+                               build(getNaviframe());
+               if (!m_content) {
+                       LOG_RETURN(RES_FAIL, "m_content is NULL");
+               }
+
+               item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP);
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+               }
+
+               createImage();
+
+               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_touchParser = makeShared<TouchParser>(*m_image);
+               m_touchParser->setTapHandler(WEAK_DELEGATE(
+                               VideoPlayerPage::onTap, asWeak(*this)));
+
+               getWindow().addEventHandler(INSTANCE_PAUSED, WEAK_DELEGATE(
+                               VideoPlayerPage::onInstancePaused, asWeak(*this)));
+               getWindow().addEventHandler(INSTANCE_RESUMED, WEAK_DELEGATE(
+                               VideoPlayerPage::onInstanceResumed, asWeak(*this)));
+
+               addRotaryEventHandler(CALLBACK_A(VideoPlayerPage::onRotary), this);
+
+               if (!isInstancePaused(getWindow())) {
+                       resetAutoStartTimer();
+               }
+
+               return RES_OK;
+       }
+
+       Result VideoPlayerPage::prepareSoundManager()
+       {
+               m_soundMgr = SoundManager::newInstance();
+               if (!m_soundMgr) {
+                       LOG_RETURN(RES_FAIL, "SoundManager::newInstance() failed!");
+               }
+
+               m_soundMgr->addMediaDeviceStateChangeHandler(WEAK_DELEGATE(
+                               VideoPlayerPage::onMediaDeviceStateChanged, asWeak(*this)));
+
+               m_soundMgr->addMediaVolumeChangeHandler(WEAK_DELEGATE(
+                               VideoPlayerPage::onMediaVolumeChanged, asWeak(*this)));
+
+               return RES_OK;
+       }
+
+       void VideoPlayerPage::createImage()
+       {
+               m_image = makeShared<Widget>(
+                               evas_object_image_filled_add(m_content->getEvas()));
+               show(*m_image);
+
+               m_content->setContent(*m_image);
+       }
+
+       Result VideoPlayerPage::preparePlayer()
+       {
+               FAIL_RETURN(util::getNz(player_create, m_player),
+                               "player_create() failed!");
+
+               FAIL_RETURN(util::call(player_set_display_mode, m_player,
+                               PLAYER_DISPLAY_MODE_CROPPED_FULL),
+                               "player_set_display_mode() failed!");
+
+               FAIL_RETURN(util::call(player_set_display, m_player,
+                               PLAYER_DISPLAY_TYPE_EVAS, GET_DISPLAY(m_image->getEo())),
+                               "player_set_display() failed!");
+
+               FAIL_RETURN(util::call(player_set_uri, m_player,
+                               m_media->getFilePath().c_str()),
+                               "player_set_uri() 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!");
+
+               FAIL_RETURN(seekToStart(), "seekToStart() failed!");
+
+               FAIL_RETURN(util::call(player_set_completed_cb, m_player,
+                               CALLBACK_B(VideoPlayerPage::onPlaybackComplete), this),
+                               "player_set_completed_cb() failed!");
+
+               FAIL_RETURN(util::call(player_set_interrupted_cb, m_player,
+                               CALLBACK_B(VideoPlayerPage::onPlaybackInterrupted),
+                               this), "player_set_interrupted_cb() failed!");
+
+               return RES_OK;
+       }
+
+       Result VideoPlayerPage::seekToStart()
+       {
+               FAIL_RETURN(util::call(player_set_play_position, m_player, true, 0,
+                               CALLBACK_B(VideoPlayerPage::onSeekComplete), this),
+                               "player_set_play_position() failed!");
+               return RES_OK;
+       }
+
+       void VideoPlayerPage::createControls()
+       {
+               createButton(impl::STYLE_VOLUME_ON_BTN, impl::PART_VOLUME_ON_BTN,
+                               WEAK_DELEGATE(VideoPlayerPage::onVolumeBtnClick,
+                               asWeak(*this)));
+
+               m_volumeMuteBtn = createButton(impl::STYLE_VOLUME_MUTE_BTN,
+                               impl::PART_VOLUME_MUTE_BTN,
+                               WEAK_DELEGATE(VideoPlayerPage::onVolumeBtnClick,
+                               asWeak(*this)));
+
+               createButton(impl::STYLE_PLAY_BTN, impl::PART_PLAY_BTN,
+                               WEAK_DELEGATE(VideoPlayerPage::onPlayBtnClick,
+                               asWeak(*this)));
+
+               createButton(impl::STYLE_PAUSE_BTN, impl::PART_PAUSE_BTN,
+                               WEAK_DELEGATE(VideoPlayerPage::onPauseBtnClick,
+                               asWeak(*this)));
+       }
+
+       StyledWidgetSRef VideoPlayerPage::createButton(const ElmStyle style,
+                       const EdjePart part, const WidgetEventHandler &handler)
+       {
+               const auto btn = makeShared<StyledWidget>(
+                               elm_button_add(*m_content), false);
+               btn->setStyle(style);
+               show(*btn);
+
+               m_content->setContent(*btn, part);
+
+               btn->addEventHandler(BTN_CLICKED, handler);
+
+               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)
+       {
+               stopTimer(timer);
+
+               timer = ecore_timer_add(timeout, func, this);
+               if (!timer) {
+                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
+               }
+
+               return true;
+       }
+
+       void VideoPlayerPage::stopTimer(Ecore_Timer *&timer)
+       {
+               if (timer) {
+                       ecore_timer_del(timer);
+                       timer = nullptr;
+               }
+       }
+
+       bool VideoPlayerPage::resetAutoStartTimer()
+       {
+               return resetTimer(m_autoStartTimer, impl::AUTO_START_TIMEOUT_SEC,
+                               CALLBACK_A(VideoPlayerPage::onAutoStartTimer));
+       }
+
+       bool VideoPlayerPage::resetControlsHideTimer()
+       {
+               if (m_isPlaybackCompleted) {
+                       stopTimer(m_controlsHideTimer);
+                       return true;
+               }
+               return resetTimer(m_controlsHideTimer,
+                               ((m_state == State::PLAYING) ?
+                                       impl::CONTROLS_PLAYBACK_HIDE_TIMEOUT_SEC :
+                                       impl::CONTROLS_PAUSE_HIDE_TIMEOUT_SEC
+                               ),
+                               CALLBACK_A(VideoPlayerPage::onControlsHideTimer));
+       }
+
+       bool VideoPlayerPage::resetTickTimer()
+       {
+               return resetTimer(m_tickTimer, impl::TICK_TIMER_INTERVAL_SEC,
+                               CALLBACK_A(VideoPlayerPage::onTickTimer));
+       }
+
+       void VideoPlayerPage::showControls()
+       {
+               if (!m_isControlsVisible) {
+                       m_isControlsVisible = true;
+
+                       showVolumeBtn();
+
+                       if (m_state == State::PLAYING) {
+                               m_content->emit(impl::SHOW_PAUSE_BTN);
+                               resetTickTimer();
+                               updatePlayTimeText();
+                       } else {
+                               m_content->emit(impl::SHOW_PLAY_BTN);
+                       }
+
+                       m_content->emit(impl::SHOW_TEXT);
+               }
+
+               resetControlsHideTimer();
+       }
+
+       void VideoPlayerPage::hideControls()
+       {
+               if (m_isControlsVisible) {
+                       m_isControlsVisible = false;
+
+                       m_content->emit(impl::HIDE_VOLUME_BTN);
+                       m_content->emit(impl::HIDE_PLAY_PAUSE_BTN);
+                       m_content->emit(impl::HIDE_TEXT);
+
+                       stopTimer(m_tickTimer);
+                       stopTimer(m_controlsHideTimer);
+               }
+       }
+
+       void VideoPlayerPage::showVolumeBtn()
+       {
+               if (!m_soundMgr || !m_soundMgr->isMediaDeviceReady()) {
+                       m_content->emit(impl::SHOW_VOLUME_MUTE_BTN);
+                       disable(*m_volumeMuteBtn);
+               } else {
+                       if (m_soundMgr->getCurrentMediaVolume() > 0) {
+                               m_content->emit(impl::SHOW_VOLUME_ON_BTN);
+                       } else {
+                               m_content->emit(impl::SHOW_VOLUME_MUTE_BTN);
+                               enable(*m_volumeMuteBtn);
+                       }
+               }
+       }
+
+       bool VideoPlayerPage::updatePlayTimeText()
+       {
+               int playPosition = 0;
+
+               if (isBad(util::get(player_get_play_position,
+                               playPosition, m_player))) {
+                       ELOG("player_get_play_position() failed!");
+                       return false;
+               }
+
+               updatePlayTimeText(std::min(playPosition, m_videoDuration));
+
+               return true;
+       }
+
+       void VideoPlayerPage::updatePlayTimeText(const int timeMs)
+       {
+               int posH = 0;
+               int posM = 0;
+               int posS = 0;
+               impl::timeMsToHMS(timeMs, posH, posM, posS);
+
+               int durH = 0;
+               int durM = 0;
+               int durS = 0;
+               impl::timeMsToHMS(m_videoDuration, durH, durM, durS);
+
+               if (durH == 0) {
+                       m_content->setText(impl::TIME_SHORT_FORMAT.format(
+                                       posM, posS, durM, durS));
+               } else {
+                       m_content->setText(impl::TIME_LONG_FORMAT.format(
+                                       posH, posM, posS, durH, durM, durS));
+               }
+       }
+
+       player_state_e VideoPlayerPage::getPlayerState() const
+       {
+               player_state_e result = PLAYER_STATE_NONE;
+               FAIL_LOG(util::getNz(player_get_state, result, m_player),
+                               "player_get_state() failed!");
+               return result;
+       }
+
+       void VideoPlayerPage::startPlayback()
+       {
+               if (m_state != State::PAUSED) {
+                       return;
+               }
+               m_state = State::PLAYING;
+
+               const auto playerState = getPlayerState();
+               switch (playerState) {
+               case PLAYER_STATE_READY:
+               case PLAYER_STATE_PAUSED:
+                       if (m_isPlaybackCompleted) {
+                               m_isPlaybackCompleted = false;
+                               FAIL_LOG(seekToStart(), "seekToStart() failed!");
+                       } else {
+                               FAIL_LOG(util::call(player_start, m_player),
+                                               "player_start() failed!");
+                       }
+                       break;
+               default:
+                       WLOG("Unexpected player state: %d;", playerState);
+                       break;
+               }
+
+               setScreenAlwaysOn(true);
+               resetTickTimer();
+               stopTimer(m_autoStartTimer);
+               m_needAutoStart = false;
+
+               if (m_isControlsVisible) {
+                       m_content->emit(impl::SHOW_PAUSE_BTN);
+               }
+       }
+
+       void VideoPlayerPage::pausePlayback()
+       {
+               if (m_state != State::PLAYING) {
+                       return;
+               }
+               m_state = State::PAUSED;
+
+               const auto playerState = getPlayerState();
+               switch (playerState) {
+               case PLAYER_STATE_PLAYING:
+                       FAIL_LOG(util::call(player_pause, m_player),
+                                       "player_pause() failed!");
+                       break;
+               default:
+                       WLOG("Unexpected player state: %d;", playerState);
+                       break;
+               }
+
+               setScreenAlwaysOn(false);
+               stopTimer(m_tickTimer);
+               updatePlayTimeText();
+
+               if (m_isControlsVisible) {
+                       m_content->emit(impl::SHOW_PLAY_BTN);
+               }
+       }
+
+       void VideoPlayerPage::setScreenAlwaysOn(bool isAlwaysOn)
+       {
+               efl_util_set_window_screen_mode(getWindow(),
+                               (isAlwaysOn ? EFL_UTIL_SCREEN_MODE_ALWAYS_ON :
+                                       EFL_UTIL_SCREEN_MODE_DEFAULT));
+       }
+
+       Result VideoPlayerPage::launchVolumeSettings()
+       {
+               AutoAppCtrl appCtrl;
+
+               FAIL_RETURN(util::getNz(app_control_create, appCtrl),
+                               "app_control_create() failed!");
+
+               FAIL_RETURN(util::call(app_control_set_app_id,
+                               appCtrl, "org.tizen.watch-setting"),
+                               "app_control_set_app_id() failed!");
+
+               FAIL_RETURN(util::call(app_control_add_extra_data,
+                               appCtrl, "launch-type", "volume"),
+                               "app_control_add_extra_data() failed!");
+
+               FAIL_RETURN(util::call(app_control_send_launch_request,
+                               appCtrl, nullptr, nullptr),
+                               "app_control_send_launch_request() failed!");
+
+               return RES_OK;
+       }
+
+       void VideoPlayerPage::onMediaDeviceStateChanged()
+       {
+               if (m_isControlsVisible) {
+                       showVolumeBtn();
+               }
+       }
+
+       void VideoPlayerPage::onMediaVolumeChanged()
+       {
+               if (m_isControlsVisible) {
+                       showVolumeBtn();
+               }
+       }
+
+       void VideoPlayerPage::onPlaybackComplete()
+       {
+               m_isPlaybackCompleted = true;
+               pausePlayback();
+               requestExit();
+       }
+
+       void VideoPlayerPage::onPlaybackInterrupted(player_interrupted_code_e code)
+       {
+               if (code != PLAYER_INTERRUPTED_COMPLETED) {
+                       pausePlayback();
+                       showControls();
+               }
+       }
+
+       void VideoPlayerPage::onSeekComplete()
+       {
+               if ((m_state == State::PLAYING) &&
+                               (getPlayerState() != PLAYER_STATE_PLAYING)) {
+                       FAIL_LOG(util::call(player_start, m_player),
+                                       "player_start() failed!");
+               }
+       }
+
+       Eina_Bool VideoPlayerPage::onAutoStartTimer()
+       {
+               m_autoStartTimer = nullptr;
+
+               startPlayback();
+
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       Eina_Bool VideoPlayerPage::onControlsHideTimer()
+       {
+               m_controlsHideTimer = nullptr;
+
+               hideControls();
+
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       Eina_Bool VideoPlayerPage::onTickTimer()
+       {
+               if (!updatePlayTimeText()) {
+                       m_tickTimer = nullptr;
+                       return ECORE_CALLBACK_CANCEL;
+               }
+               return ECORE_CALLBACK_RENEW;
+       }
+
+       void VideoPlayerPage::onVolumeBtnClick(Widget &sender, void *eventInfo)
+       {
+               FAIL_LOG(launchVolumeSettings(), "launchVolumeSettings() failed!");
+       }
+
+       void VideoPlayerPage::onPlayBtnClick(Widget &sender, void *eventInfo)
+       {
+               startPlayback();
+               resetControlsHideTimer();
+       }
+
+       void VideoPlayerPage::onPauseBtnClick(Widget &sender, void *eventInfo)
+       {
+               pausePlayback();
+               resetControlsHideTimer();
+       }
+
+       void VideoPlayerPage::onTap(int x, int y)
+       {
+               if (m_isControlsVisible) {
+                       hideControls();
+               } else {
+                       showControls();
+               }
+       }
+
+       Eina_Bool VideoPlayerPage::onRotary(Eext_Rotary_Event_Info *info)
+       {
+               showControls();
+               return EINA_TRUE;
+       }
+
+       void VideoPlayerPage::onInstancePaused(Widget &sender, void *eventInfo)
+       {
+               pausePlayback();
+               stopTimer(m_autoStartTimer);
+               stopTimer(m_controlsHideTimer);
+       }
+
+       void VideoPlayerPage::onInstanceResumed(Widget &sender, void *eventInfo)
+       {
+               if (m_needAutoStart) {
+                       resetAutoStartTimer();
+               } else {
+                       showControls();
+               }
+       }
+}
diff --git a/gallery/presenters/pages/VideoPlayerPage.h b/gallery/presenters/pages/VideoPlayerPage.h
new file mode 100644 (file)
index 0000000..d8e3db5
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * 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_PAGES_VIDEO_PLAYER_PAGE_H__
+#define __GALLERY_PRESENTERS_PAGES_VIDEO_PLAYER_PAGE_H__
+
+#include <player.h>
+
+#include "ucl/gui/Layout.h"
+
+#include "gallery/model/SoundManager.h"
+#include "gallery/model/MediaItem.h"
+
+#include "gallery/view/TouchParser.h"
+
+#include "gallery/presenters/base/Page.h"
+
+#include "gallery/presenters/dialogs/AlertDialog.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(VideoPlayerPage);
+
+       class VideoPlayerPage final : public Page {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       ~Builder();
+                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+                       Builder &setMedia(const MediaItemSRef &media);
+                       VideoPlayerPageWRef build(
+                                       const ExitRequestHandler &onExitRequest) const;
+               private:
+                       ucl::NaviframeSRef m_navi;
+                       MediaItemSRef m_media;
+               };
+
+       private:
+               friend class ucl::ReffedObj<VideoPlayerPage>;
+               VideoPlayerPage(ucl::IRefCountObj &rc,
+                               const ucl::NaviframeSRef &navi,
+                               const ExitRequestHandler &onExitRequest,
+                               const MediaItemSRef &media);
+               virtual ~VideoPlayerPage();
+
+               ucl::Result doPrepare(ucl::NaviItem &item);
+
+               ucl::Result prepareSoundManager();
+
+               void createImage();
+               ucl::Result preparePlayer();
+               ucl::Result seekToStart();
+
+               void createControls();
+               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);
+
+               bool resetAutoStartTimer();
+               bool resetControlsHideTimer();
+               bool resetTickTimer();
+
+               void showControls();
+               void hideControls();
+               void showVolumeBtn();
+
+               bool updatePlayTimeText();
+               void updatePlayTimeText(int timeMs);
+
+               player_state_e getPlayerState() const;
+               void startPlayback();
+               void pausePlayback();
+
+               void setScreenAlwaysOn(bool isAlwaysOn);
+
+               ucl::Result launchVolumeSettings();
+
+               bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
+
+               void onMediaDeviceStateChanged();
+               void onMediaVolumeChanged();
+
+               void onPlaybackComplete();
+               void onPlaybackInterrupted(player_interrupted_code_e code);
+               void onSeekComplete();
+
+               Eina_Bool onAutoStartTimer();
+               Eina_Bool onControlsHideTimer();
+               Eina_Bool onTickTimer();
+
+               void onVolumeBtnClick(ucl::Widget &sender, void *eventInfo);
+               void onPlayBtnClick(ucl::Widget &sender, void *eventInfo);
+               void onPauseBtnClick(ucl::Widget &sender, void *eventInfo);
+               void onTap(int x, int y);
+               Eina_Bool onRotary(Eext_Rotary_Event_Info *info);
+
+               void onInstancePaused(ucl::Widget &sender, void *eventInfo);
+               void onInstanceResumed(ucl::Widget &sender, void *eventInfo);
+
+       private:
+               enum class State {
+                       PAUSED,
+                       PLAYING
+               };
+
+       private:
+               const MediaItemSRef m_media;
+               SoundManagerSRef m_soundMgr;
+               ucl::LayoutSRef m_content;
+               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;
+               Ecore_Timer *m_controlsHideTimer;
+               Ecore_Timer *m_tickTimer;
+               State m_state;
+               bool m_isControlsVisible;
+               bool m_needAutoStart;
+               bool m_isPlaybackCompleted;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_PAGES_VIDEO_PLAYER_PAGE_H__
diff --git a/gallery/presenters/pages/ViewerPage.cpp b/gallery/presenters/pages/ViewerPage.cpp
new file mode 100644 (file)
index 0000000..ce51c00
--- /dev/null
@@ -0,0 +1,299 @@
+/*
+ * 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 "ViewerPage.h"
+
+#include "gallery/resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       enum {
+               MORE_OPTION_ID_SAVE
+       };
+}}}
+
+namespace gallery {
+
+       using ucl::NaviItem;
+       using ucl::NaviframeSRef;
+
+       // ViewerPage::Builder //
+
+       ViewerPage::Builder::Builder() :
+               m_zoomInX(-1),
+               m_zoomInY(-1),
+               m_imageLoadSize(-1),
+               m_isImageLoadSizeFull(false),
+               m_exitOnZoomOut(true)
+       {
+       }
+
+       ViewerPage::Builder::~Builder()
+       {
+       }
+
+       ViewerPage::Builder &ViewerPage::Builder::setNaviframe(
+                       const NaviframeSRef &navi)
+       {
+               m_navi = navi;
+               return *this;
+       }
+
+       ViewerPage::Builder &ViewerPage::Builder::setMedia(
+                       const MediaItemSRef &media)
+       {
+               m_media = media;
+               return *this;
+       }
+
+       ViewerPage::Builder &ViewerPage::Builder::setZoomIn(
+                       const int x, const int y)
+       {
+               m_zoomInX = x;
+               m_zoomInY = y;
+               return *this;
+       }
+
+       ViewerPage::Builder &ViewerPage::Builder::setImageLoadSize(
+                       const int size, const bool isFull)
+       {
+               m_imageLoadSize = size;
+               m_isImageLoadSizeFull = isFull;
+               return *this;
+       }
+
+       ViewerPage::Builder &ViewerPage::Builder::setExitOnZoomOut(const bool value)
+       {
+               m_exitOnZoomOut = value;
+               return *this;
+       }
+
+       ViewerPageWRef ViewerPage::Builder::build(
+                       const ExitRequestHandler &onExitRequest) const
+       {
+               if (!onExitRequest) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "onExitRequest is NULL");
+               }
+               if (!m_navi) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+               }
+               if (!m_media) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_media is NULL");
+               }
+               if (m_media->getType() != MediaType::IMAGE) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Wrong media type");
+               }
+
+               auto result = makeShared<ViewerPage>(
+                               m_navi, onExitRequest, m_media, m_exitOnZoomOut);
+
+               FAIL_RETURN_VALUE(result->prepare([this, &result](NaviItem &item)
+                       {
+                               return result->doPrepare(m_imageLoadSize,
+                                               m_isImageLoadSizeFull, item);
+                       }),
+                       {}, "result->prepare() failed!");
+
+               if ((m_zoomInX >= 0) && (m_zoomInY >= 0)) {
+                       result->zoomIn(m_zoomInX, m_zoomInY);
+               }
+
+               return result;
+       }
+
+       // ViewerPage //
+
+       ViewerPage::ViewerPage(IRefCountObj &rc,
+                       const NaviframeSRef &navi,
+                       const ExitRequestHandler &onExitRequest,
+                       const MediaItemSRef &media,
+                       const bool exitOnZoomOut) :
+               Page(rc, navi, onExitRequest),
+               m_media(media),
+               m_exitOnZoomOut(exitOnZoomOut)
+       {
+       }
+
+       ViewerPage::~ViewerPage()
+       {
+               if (m_more) {
+                       m_more->setOpened(false);
+               }
+       }
+
+       Result ViewerPage::doPrepare(const int imageLoadSize,
+                       const bool isImageLoadSizeFull, NaviItem &item)
+       {
+               const int mediaFlags = m_media->getFlags();
+               const bool canSave = (mediaFlags & MediaItem::FLAG_SAVE);
+               const bool hasThumb = (mediaFlags & MediaItem::FLAG_THUMBNAIL);
+               const bool useThumb = (hasThumb && (imageLoadSize < 0));
+               const bool forceLoad = (!useThumb && isImageLoadSizeFull);
+
+               m_imageViewer = ImageViewer::Builder().
+                               setHighResImagePath(m_media->getFilePath()).
+                               setLoadSize(imageLoadSize).
+                               setForceLoad(forceLoad).
+                               build(getNaviframe());
+               if (!m_imageViewer) {
+                       LOG_RETURN(RES_FAIL, "ImageViewer::build() failed!");
+               }
+
+               ElmWidget *rootWidget = m_imageViewer.get();
+
+               if (canSave) {
+                       m_content = PageContent::Builder().
+                                       setFlags(PageContent::FLAG_MORE_OPTIONS).
+                                       build(getNaviframe());
+                       if (!m_content) {
+                               LOG_RETURN(RES_FAIL, "PageContent::build() failed!");
+                       }
+                       setDeactivatorSink(m_content);
+
+                       rootWidget = m_content.get();
+                       m_content->set(*m_imageViewer);
+
+                       m_more = MoreOptionsPresenter::Builder().
+                                       setParentWidget(m_content).
+                                       addOption({impl::MORE_OPTION_ID_SAVE,
+                                               STR_SAVE_TO_GEAR, nullptr,
+                                               getImageTheme(ICON_MORE_OPT_SAVE)}).
+                                       build(*this);
+                       if (!m_more) {
+                               LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!");
+                       }
+
+                       m_content->set(m_more->getWidget(),
+                                       PageContent::Part::MORE_OPTIONS);
+
+                       m_more->setListener(asWeakThis<
+                                       MoreOptionsPresenter::IListener>(this));
+               }
+
+               if (useThumb) {
+                       FAIL_RETURN(m_media->getThumbnailPath(WEAK_DELEGATE(
+                                       ViewerPage::onThumbnail, asWeak(*this))),
+                                       "m_media->getThumbnailPath() failed!");
+               } else if (!forceLoad) {
+                       m_imageViewer->setLowResImagePath(m_media->getFilePath());
+               }
+
+               m_imageViewer->addEventHandler(IMAGE_VIEWER_ZOOM_END,
+                               WEAK_DELEGATE(ViewerPage::onZoomEnd, asWeak(*this)));
+
+               const auto topItem = getNaviframe().getTopItem();
+               if (topItem) {
+                       item = getNaviframe().insertAfter(topItem,
+                                       *rootWidget, NAVIFRAME_NO_CLIP);
+               } else {
+                       item = getNaviframe().push(*rootWidget, NAVIFRAME_NO_CLIP);
+               }
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
+               }
+
+               m_touchParser = makeShared<TouchParser>(*m_imageViewer);
+               m_touchParser->setDoubleTapHandler(WEAK_DELEGATE(
+                               ViewerPage::onDoubleTap, asWeak(*this)));
+
+               return RES_OK;
+       }
+
+       void ViewerPage::zoomIn(const int originX, const int originY)
+       {
+               m_imageViewer->zoomIn(originX, originY);
+       }
+
+       const std::string &ViewerPage::getMediaId() const
+       {
+               return m_media->getId();
+       }
+
+       void ViewerPage::onThumbnail(const Result result, const std::string &path)
+       {
+               FAIL_RETURN_VOID(result, "Failed to get thumbnail!");
+
+               m_imageViewer->setLowResImagePath(path);
+       }
+
+       void ViewerPage::onZoomEnd(Widget &widget, void *eventInfo)
+       {
+               if (m_exitOnZoomOut && m_imageViewer->isZoomedOut()) {
+                       requestExit();
+               }
+       }
+
+       void ViewerPage::onDoubleTap(int x, int y)
+       {
+               if (!isActive()) {
+                       return;
+               }
+               if (m_imageViewer->isZoomedOut()) {
+                       m_imageViewer->zoomIn(x, y);
+               } else if (m_imageViewer->isZoomedIn()) {
+                       m_imageViewer->zoomOut();
+               }
+       }
+
+       void ViewerPage::onBackKey()
+       {
+               if (m_imageViewer->isZoomedOut()) {
+                       requestExit();
+               } else if (m_imageViewer->isZoomedIn()) {
+                       m_imageViewer->zoomOut();
+               }
+       }
+
+       void ViewerPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
+                       const MoreOptionsPresenter::Option &option)
+       {
+               sender.setOpened(false);
+
+               if (m_job) {
+                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "m_job is not NULL");
+               }
+
+               m_job = MediaItem::SaverBuilder().
+                               setItem(m_media).
+                               build(WEAK_DELEGATE(ViewerPage::onJobComplete, asWeak(*this)));
+               if (!m_job) {
+                       LOG_RETURN_VOID(RES_FAIL,
+                                       "MediaItem::SaverBuilder::build() failed!");
+               }
+
+               m_processing = ProcessingPresenter::Builder().
+                               setProcessingText(STR_SAVING).
+                               build(*m_content);
+       }
+
+       void ViewerPage::onJobComplete()
+       {
+               if (m_processing) {
+                       if (isGood(m_job->getResult())) {
+                               m_processing->complete(STR_SAVED,
+                                               ProcessingPresenter::IconType::CHECK);
+                       } else {
+                               m_processing->complete(STR_FAILED);
+                       }
+                       m_processing.reset();
+               }
+
+               m_job.reset();
+       }
+}
diff --git a/gallery/presenters/pages/ViewerPage.h b/gallery/presenters/pages/ViewerPage.h
new file mode 100644 (file)
index 0000000..44380fa
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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_PAGES_VIEWER_PAGE_H__
+#define __GALLERY_PRESENTERS_PAGES_VIEWER_PAGE_H__
+
+#include "gallery/model/MediaItem.h"
+
+#include "gallery/view/PageContent.h"
+#include "gallery/view/ImageViewer.h"
+#include "gallery/view/TouchParser.h"
+
+#include "gallery/presenters/base/Page.h"
+
+#include "gallery/presenters/misc/MoreOptionsPresenter.h"
+#include "gallery/presenters/misc/ProcessingPresenter.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(ViewerPage);
+
+       class ViewerPage final : public Page,
+                       private MoreOptionsPresenter::IListener {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       ~Builder();
+                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+                       Builder &setMedia(const MediaItemSRef &media);
+                       Builder &setZoomIn(int x, int y);
+                       Builder &setImageLoadSize(int size, bool isFull);
+                       Builder &setExitOnZoomOut(bool value);
+                       ViewerPageWRef build(
+                                       const ExitRequestHandler &onExitRequest) const;
+               private:
+                       ucl::NaviframeSRef m_navi;
+                       MediaItemSRef m_media;
+                       int m_zoomInX;
+                       int m_zoomInY;
+                       int m_imageLoadSize;
+                       bool m_isImageLoadSizeFull;
+                       bool m_exitOnZoomOut;
+               };
+
+       public:
+               const std::string &getMediaId() const;
+
+       private:
+               friend class ucl::ReffedObj<ViewerPage>;
+               ViewerPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
+                               const ExitRequestHandler &onExitRequest,
+                               const MediaItemSRef &media, bool exitOnZoomOut);
+               virtual ~ViewerPage();
+
+               ucl::Result doPrepare(int imageLoadSize, bool isImageLoadSizeFull,
+                               ucl::NaviItem &item);
+
+               void zoomIn(int originX, int originY);
+
+               void onThumbnail(ucl::Result result, const std::string &path);
+               void onZoomEnd(ucl::Widget &widget, void *eventInfo);
+               void onDoubleTap(int x, int y);
+
+               void onJobComplete();
+
+               // Page //
+
+               virtual void onBackKey() final override;
+
+               // MoreOptionsPresenter::IListener //
+
+               virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
+                               const MoreOptionsPresenter::Option &option) final override;
+
+       private:
+               const MediaItemSRef m_media;
+               const bool m_exitOnZoomOut;
+               ImageViewerSRef m_imageViewer;
+               TouchParserSRef m_touchParser;
+               IJobSRef m_job;
+               PageContentSRef m_content;
+               MoreOptionsPresenterSRef m_more;
+               ProcessingPresenterSRef m_processing;
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_PAGES_VIEWER_PAGE_H__
diff --git a/gallery/presenters/pages/common.h b/gallery/presenters/pages/common.h
new file mode 100644 (file)
index 0000000..8396561
--- /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 __GALLERY_PRESENTERS_PAGES_COMMON_H__
+#define __GALLERY_PRESENTERS_PAGES_COMMON_H__
+
+#include "gallery/presenters/common.h"
+
+#endif // __GALLERY_PRESENTERS_PAGES_COMMON_H__
diff --git a/gallery/resources.cpp b/gallery/resources.cpp
new file mode 100644 (file)
index 0000000..ba4247e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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 "resources.h"
+
+namespace gallery {
+
+       using ucl::TString;
+
+       // TODO replace with IDS in the future
+
+       const TString STR_APP_NAME {"Gallery"};
+       const TString STR_NO_PHOTOS {"No photos"};
+       const TString STR_SELECT_ALL {"Select all"};
+       const TString STR_DESELECT_ALL {"Deselect all"};
+       const TString STR_DELETE {"Delete"};
+       const TString STR_DELETE_CAPS {"DELETE"};
+       const TString STR_DELETE_1_PHOTO {"Delete 1 photo?"};
+       const TString STR_DELETE_N_PHOTO {"Delete %d photo?"};
+       const TString STR_DELETING {"Deleting..."};
+       const TString STR_DELETED {"Deleted."};
+       const TString STR_FAILED {"Failed."};
+       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/gallery/resources.h b/gallery/resources.h
new file mode 100644 (file)
index 0000000..6a6f372
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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_RESOURCES_H__
+#define __GALLERY_RESOURCES_H__
+
+#include "ucl/misc/TString.h"
+
+#include "config.h"
+
+namespace gallery {
+
+       constexpr auto THEME_EDJE_PATH = "edje/theme.edj";
+
+       constexpr auto ICON_NO_PHOTOS = "gallery_icon_no_photos.png";
+
+       constexpr auto ICON_MORE_OPT_DELETE = "gallery_more_opt_delete.png";
+       constexpr auto ICON_MORE_OPT_SAVE = "gallery_more_opt_save.png";
+       constexpr auto ICON_MORE_OPT_SEND = "gallery_more_opt_send_to_mobile.png";
+
+       constexpr auto ICON_POPUP_OK = "tw_ic_popup_btn_check.png";
+       constexpr auto ICON_POPUP_CANCEL = "tw_ic_popup_btn_delete.png";
+
+       extern const ucl::TString STR_APP_NAME;
+       extern const ucl::TString STR_NO_PHOTOS;
+       extern const ucl::TString STR_SELECT_ALL;
+       extern const ucl::TString STR_DESELECT_ALL;
+       extern const ucl::TString STR_DELETE;
+       extern const ucl::TString STR_DELETE_CAPS;
+       extern const ucl::TString STR_DELETE_1_PHOTO;
+       extern const ucl::TString STR_DELETE_N_PHOTO;
+       extern const ucl::TString STR_DELETING;
+       extern const ucl::TString STR_DELETED;
+       extern const ucl::TString STR_FAILED;
+       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/gallery/types.h b/gallery/types.h
new file mode 100644 (file)
index 0000000..9a1476e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_TYPES_H__
+#define __GALLERY_TYPES_H__
+
+#include "config.h"
+
+#include "ucl/util/types.h"
+#include "ucl/util/memory.h"
+#include "ucl/util/delegation.h"
+#include "ucl/util/smartDelegation.h"
+
+namespace gallery {
+
+       using NotiHandler = ucl::WeakDelegate<void()>;
+}
+
+#endif // __GALLERY_TYPES_H__
diff --git a/gallery/view/ImageGrid.cpp b/gallery/view/ImageGrid.cpp
new file mode 100644 (file)
index 0000000..7cae9b2
--- /dev/null
@@ -0,0 +1,1807 @@
+/*
+ * 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 "ImageGrid.h"
+
+#include <array>
+#include <vector>
+
+#include "ucl/gui/Layout.h"
+#include "ucl/gui/Window.h"
+
+#include "TouchParser.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       // Related to ImageGrid //
+       const TString SLOT_PART_FMT {"swallow.cell_%d"};
+
+       const TString SIGNAL_SELECT_ITEM_FMT {"gallery,select,%d"};
+       const TString SIGNAL_UNSELECT_ITEM_FMT {"gallery,unselect,%d"};
+
+       constexpr EdjeDataKey DATA_IMAGE_MIN_LOAD_SIZE {"image_min_load_size"};
+
+       constexpr EdjeSignal SIGNAL_FORCE_SELECT_MODE
+                       {"gallery,force,select,mode"};
+       constexpr EdjeSignal SIGNAL_ENABLE_SELECT_MODE
+                       {"gallery,enable,select,mode"};
+       constexpr EdjeSignal SIGNAL_DISABLE_SELECT_MODE
+                       {"gallery,disable,select,mode"};
+       constexpr EdjeSignal SIGNAL_TRANSITION_FINISHED
+                       {"gallery,transition,finished"};
+
+       // Related to Button //
+       constexpr EdjePart BTN_PART_BG {"swallow.bg"};
+       constexpr EdjeSignal BTN_BLOCK_CLICKS {"gallery,block,clicks"};
+       constexpr EdjeSignal BTN_UNBLOCK_CLICKS {"gallery,unblock,clicks"};
+
+       // Other //
+       constexpr auto HCOMB_SCROLL_LIMIT = 1000;
+       constexpr auto SCROLL_HIGHLIGHT_TIMEOUT_SEC = 0.1;
+
+       bool getImageSize(const Widget &image, int &w, int &h)
+       {
+               int tmpW = 0;
+               int tmpH = 0;
+
+               evas_object_image_size_get(image, &tmpW, &tmpH);
+
+               if ((tmpW <= 0) || (tmpH <= 0)) {
+                       return false;
+               }
+
+               w = tmpW;
+               h = tmpH;
+
+               return true;
+       }
+}}}
+
+namespace gallery {
+
+       using ucl::Layout;
+
+       using ucl::Timeout;
+       using ucl::ceilDiv;
+
+       // ImageGrid::Builder //
+
+       ImageGrid::Builder::Builder() :
+               m_type(Type::HCOMB_3X3),
+               m_selectModeStartup(false)
+       {
+       }
+
+       ImageGrid::Builder &ImageGrid::Builder::setType(const Type value)
+       {
+               m_type = value;
+               return *this;
+       }
+
+       ImageGrid::Builder &ImageGrid::Builder::setListener(
+                       const IListenerWRef &value)
+       {
+               m_listener = value;
+               return *this;
+       }
+
+       ImageGrid::Builder &ImageGrid::Builder::setSelectModeStartup(
+                       const bool value)
+       {
+               m_selectModeStartup = value;
+               return *this;
+       }
+
+       ImageGridSRef ImageGrid::Builder::build(ElmWidget &parent) const
+       {
+               Evas_Object *const scrollerEo = elm_scroller_add(parent);
+               if (!scrollerEo) {
+                       ELOG("elm_scroller_add() failed!");
+                       return {};
+               }
+
+               auto result = makeShared<ImageGrid>(scrollerEo,
+                               m_type, m_selectModeStartup);
+
+               result->bindToEo();
+               result->setListener(m_listener);
+
+               return result;
+       }
+
+       // ImageGrid::Info //
+
+       struct ImageGrid::Info {
+               const std::array<LayoutTheme, 2> slotThemes;
+               const std::array<int, 2> slotLens;
+               const ElmStyle btnStyle;
+               const int scrollLimit;
+               const int slotsPerPage;
+               const bool isHorizontal;
+
+               virtual int calcItemIndexFromCell(
+                               const int slotIndex, const int itemOffset) const = 0;
+               virtual void calcCellFromItemIndex(const int itemIndex,
+                               int &slotIndex, int &itemOffset) const = 0;
+
+               virtual int calcMaxSlotCount(const int itemCount) const = 0;
+
+               virtual int calcExtraPaddingSize(const int slotSize) const
+               {
+                       return 0;
+               }
+
+               virtual int getHighlightScanRange() const
+               {
+                       return 1;
+               }
+
+               Info(const std::array<LayoutTheme, 2> &slotThemes,
+                               const std::array<int, 2> &slotLens,
+                               const ElmStyle btnStyle,
+                               const int scrollLimit, const int slotsPerPage,
+                               const bool isHorizontal) :
+                       slotThemes(slotThemes),
+                       slotLens(slotLens),
+                       btnStyle(btnStyle),
+                       scrollLimit(scrollLimit),
+                       slotsPerPage(slotsPerPage),
+                       isHorizontal(isHorizontal)
+               {
+               }
+
+               virtual ~Info() = default;
+       };
+
+       // ImageGrid::HcombInfo //
+
+       struct ImageGrid::HcombInfo : Info {
+               const int totalLength;
+
+               virtual int calcItemIndexFromCell(
+                               const int slotIndex, const int itemOffset) const final override
+               {
+                       return ((slotIndex / 2 * totalLength) +
+                                       (itemOffset * 2) + ((slotIndex ^ 1) & 1));
+               }
+
+               virtual void calcCellFromItemIndex(const int itemIndex,
+                               int &slotIndex, int &itemOffset) const final override
+               {
+                       slotIndex = (itemIndex / totalLength);
+                       itemOffset = (itemIndex % totalLength);
+                       slotIndex += (slotIndex + ((itemOffset ^ 1) & 1));
+                       itemOffset /= 2;
+               }
+
+               virtual int calcMaxSlotCount(const int itemCount) const final override
+               {
+                       return ((itemCount + (totalLength - 1)) / totalLength * 2);
+               }
+
+               virtual int calcExtraPaddingSize(
+                               const int slotSize) const final override
+               {
+                       return slotSize;
+               }
+
+               virtual int getHighlightScanRange() const final override
+               {
+                       return totalLength;
+               }
+
+               HcombInfo(const int totalLength,
+                               const std::array<LayoutTheme, 2> &slotThemes,
+                               const ElmStyle btnStyle) :
+                       Info(slotThemes, {{(totalLength / 2), ceilDiv<2>(totalLength)}},
+                               btnStyle, impl::HCOMB_SCROLL_LIMIT, 1, true),
+                       totalLength(totalLength)
+               {
+               }
+       };
+
+       // ImageGrid::LinearInfo //
+
+       struct ImageGrid::LinearInfo : Info {
+               virtual int calcItemIndexFromCell(
+                               const int slotIndex, const int itemOffset) const final override
+               {
+                       return (slotIndex / 2);
+               }
+
+               virtual void calcCellFromItemIndex(const int itemIndex,
+                               int &slotIndex, int &itemOffset) const final override
+               {
+                       slotIndex = (itemIndex * 2);
+                       itemOffset = 0;
+               }
+
+               virtual int calcMaxSlotCount(const int itemCount) const final override
+               {
+                       return (itemCount * 2);
+               }
+
+               LinearInfo(const LayoutTheme &slotTheme, const ElmStyle btnStyle,
+                               const bool isHorizontal) :
+                       Info({{slotTheme}}, {{1, 0}}, btnStyle, 1, 1, isHorizontal)
+               {
+               }
+       };
+
+       // ImageGrid::Slot //
+
+       class ImageGrid::Slot {
+       private:
+               class Item final : public RefCountAware {
+               public:
+                       friend class ReffedObj<Item>;
+                       Item(IRefCountObj &rc,
+                                       ImageGrid &imageGrid, ElmWidget &parent) :
+                               RefCountAware(&rc),
+                               m_imageGrid(imageGrid),
+                               m_btn(elm_button_add(parent)),
+                               m_image(evas_object_image_filled_add(m_btn.getEvas()))
+                       {
+                               m_btn.setFocusAlowed(false);
+                               m_btn.setStyle(imageGrid.m_info.btnStyle);
+                               show(m_btn);
+
+                               evas_object_image_load_orientation_set(m_image, EINA_TRUE);
+                               m_btn.setContent(m_image);
+                               show(m_image);
+
+                               m_image.addEventHandler(WidgetEvent::IMAGE_PRELOADED,
+                                               WEAK_DELEGATE(Item::onImagePreloaded, asWeak(*this)));
+
+                               m_btn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
+                                               Item::onClicked, asWeak(*this)));
+                               m_btn.addEventHandler(ATSPI_HIGHLIGHTED, WEAK_DELEGATE(
+                                               Item::onHighlighted, asWeak(*this)));
+                               m_btn.addEventHandler(ATSPI_UNHIGHLIGHTED, WEAK_DELEGATE(
+                                               Item::onUnhighlighted, asWeak(*this)));
+
+                               elm_atspi_accessible_gesture_cb_set(m_btn,
+                                               CALLBACK_A(Item::onAtspiGesture), this);
+
+                               m_touchParser = makeShared<TouchParser>(m_btn);
+                               m_touchParser->setDoubleTapHandler(
+                                               WEAK_DELEGATE(Item::onDoubleTap, asWeak(*this)));
+                               m_touchParser->setTapAndHoldHandler(
+                                               WEAK_DELEGATE(Item::onTapAndHold, asWeak(*this)));
+                       }
+
+                       ~Item()
+                       {
+                               elm_atspi_accessible_gesture_cb_set(m_btn, nullptr, nullptr);
+                       }
+
+                       Widget &getWidget()
+                       {
+                               return m_btn;
+                       }
+
+                       void setImageMinLoadSize(const int value)
+                       {
+                               m_imageMinLoadSize = std::max(value, 1);
+                       }
+
+                       bool isRealized() const
+                       {
+                               return (m_realizeIndex >= 0);
+                       }
+
+                       void getInfo(ItemInfo &info) const
+                       {
+                               int w = m_imageWidth;
+                               int h = m_imageHeight;
+                               if (!impl::getImageSize(m_image, w, h)) {
+                                       WLOG("Invalid image size!");
+                               }
+
+                               info.imageLoadSize = m_imageLoadSize;
+                               info.isImageLoadSizeFull = (
+                                               (w == m_imageWidth) && (h == m_imageHeight));
+                               info.isImageLoaded = m_isImageLoaded;
+                       }
+
+                       void realize(const int itemIndex)
+                       {
+                               if (isRealized()) {
+                                       return;
+                               }
+
+                               m_wasUpdated = false;
+
+                               if (itemIndex < m_imageGrid.m_itemCount) {
+                                       m_realizeIndex = itemIndex;
+
+                                       if (const auto listener = m_imageGrid.m_listener.lock()) {
+                                               listener->onItemRealized(itemIndex);
+                                       }
+                               }
+
+                               if (!m_wasUpdated) {
+                                       makeTransparent(m_btn);
+                               }
+                       }
+
+                       void unrealize()
+                       {
+                               if (!isRealized()) {
+                                       return;
+                               }
+
+                               if ((m_imageGrid.m_highlightID == m_realizeIndex) &&
+                                               m_imageGrid.m_highlightTimeout) {
+                                       m_imageGrid.m_isHighlightLocked = true;
+                                       elm_atspi_component_highlight_clear(m_btn);
+                               }
+
+                               const int itemIndex = m_realizeIndex;
+                               m_realizeIndex = -1;
+
+                               if (const auto listener = m_imageGrid.m_listener.lock()) {
+                                       listener->onItemUnrealized(itemIndex);
+                               }
+                       }
+
+                       bool setSelected(const bool selected)
+                       {
+                               if (selected == m_isSelected) {
+                                       return false;
+                               }
+                               if (selected && !m_imageGrid.m_isInSelectMode) {
+                                       return false;
+                               }
+                               m_isSelected = selected;
+                               return true;
+                       }
+
+                       bool update(const ItemParams &params)
+                       {
+                               if (!isRealized()) {
+                                       return false;
+                               }
+
+                               updateClicksBlock(params);
+                               updateImage(params);
+                               updateBgImage(params);
+
+                               makeWhite(m_btn);
+
+                               m_wasUpdated = true;
+
+                               return true;
+                       }
+
+               private:
+                       void updateClicksBlock(const ItemParams &params)
+                       {
+                               if (params.flags & UF_BLOCK_CLICKS) {
+                                       if (!m_isClicksBlocked) {
+                                               m_isClicksBlocked = true;
+                                               m_btn.emit(impl::BTN_BLOCK_CLICKS);
+                                       }
+                               } else if (m_isClicksBlocked) {
+                                       m_isClicksBlocked = false;
+                                       m_btn.emit(impl::BTN_UNBLOCK_CLICKS);
+                               }
+                       }
+
+                       void updateImage(const ItemParams &params)
+                       {
+                               if (isEmpty(params.imagePath)) {
+                                       if (!m_wasUpdated || (params.flags & UF_LOSE_IMAGE)) {
+                                               makeTransparent(m_image);
+                                               m_isImageEmpty = true;
+                                               m_isImageLoaded = false;
+                                       }
+                                       return;
+                               }
+
+                               makeTransparent(m_image);
+                               m_isImageEmpty = false;
+                               m_isImageLoaded = false;
+
+                               m_imageWidth = std::max(params.imageWidth, 1);
+                               m_imageHeight = std::max(params.imageHeight, 1);
+
+                               evas_object_image_file_set(m_image,
+                                               params.imagePath.c_str(), NULL);
+
+                               updateImageLoadSize();
+
+                               evas_object_image_preload(m_image, EINA_FALSE);
+                       }
+
+                       void updateImageLoadSize()
+                       {
+                               const int newLoadSize = ((m_imageWidth > m_imageHeight) ?
+                                               (m_imageMinLoadSize * m_imageWidth / m_imageHeight) :
+                                               (m_imageMinLoadSize * m_imageHeight / m_imageWidth));
+                               if (newLoadSize == m_imageLoadSize) {
+                                       return;
+                               }
+
+                               int w = m_imageWidth;
+                               int h = m_imageHeight;
+                               if (!impl::getImageSize(m_image, w, h)) {
+                                       WLOG("Invalid image size!");
+                               }
+
+                               if (isCurentLoadSizeSatisfying(w, h) ||
+                                               !isImageRespectsLoadSize(w, h)) {
+                                       return;
+                               }
+
+                               m_imageLoadSize = newLoadSize;
+                               evas_object_image_load_size_set(m_image,
+                                               newLoadSize, newLoadSize);
+                       }
+
+                       bool isCurentLoadSizeSatisfying(
+                                       const int curImgW, const int curImgH) const
+                       {
+                               const int kw = ((m_imageWidth > m_imageMinLoadSize) ?
+                                               (curImgW / m_imageMinLoadSize) : 1);
+                               const int kh = ((m_imageHeight > m_imageMinLoadSize) ?
+                                               (curImgH / m_imageMinLoadSize) : 1);
+                               return (((kw == 1) && (kh >= 1)) || ((kh == 1) && (kw >= 1)));
+                       }
+
+                       bool isImageRespectsLoadSize(
+                                       const int curImgW, const int curImgH) const
+                       {
+                               return ((m_imageLoadSize <= 0) ||
+                                               (curImgW != m_imageWidth) ||
+                                               (curImgH != m_imageHeight) || (
+                                                       ((curImgW / m_imageLoadSize) <= 1) &&
+                                                       ((curImgH / m_imageLoadSize) <= 1)
+                                               ));
+                       }
+
+                       void onImagePreloaded(Widget &widget, void *eventInfo)
+                       {
+                               if (m_isImageEmpty) {
+                                       return;
+                               }
+
+                               m_isImageLoaded = true;
+
+                               m_image.setARHint(WidgetARHint::NEITHER,
+                                               m_imageWidth, m_imageHeight);
+
+                               makeWhite(m_image);
+                       }
+
+                       void updateBgImage(const ItemParams &params)
+                       {
+                               if (isEmpty(params.bgImagePath)) {
+                                       if (m_bgImage && (!m_wasUpdated ||
+                                                       (params.flags & UF_LOSE_BG))) {
+                                               makeTransparent(*m_bgImage);
+                                       }
+                                       return;
+                               }
+
+                               if (!m_bgImage) {
+                                       m_bgImage = makeShared<Widget>(
+                                                       evas_object_image_filled_add(m_btn.getEvas()));
+                                       evas_object_image_load_orientation_set(*m_bgImage,
+                                                       EINA_TRUE);
+                                       m_btn.setContent(*m_bgImage, impl::BTN_PART_BG);
+                                       show(*m_bgImage);
+                               }
+
+                               evas_object_image_file_set(*m_bgImage,
+                                               params.bgImagePath.c_str(), NULL);
+
+                               m_bgImage->setARHint(WidgetARHint::NEITHER,
+                                               m_imageWidth, m_imageHeight);
+
+                               makeWhite(*m_bgImage);
+                       }
+
+                       void onClicked(Widget &widget, void *eventInfo)
+                       {
+                               if (!isRealized()) {
+                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
+                               }
+                               m_imageGrid.handleItemEvent(m_realizeIndex,
+                                               ItemEvent::CLICK, -1, -1);
+                       }
+
+                       void onDoubleTap(const int x, const int y)
+                       {
+                               if (!isRealized()) {
+                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
+                               }
+                               m_imageGrid.handleItemEvent(m_realizeIndex,
+                                               ItemEvent::DOUBLE_TAP, x, y);
+                       }
+
+                       void onTapAndHold(const int x, const int y)
+                       {
+                               if (!isRealized()) {
+                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
+                               }
+                               m_imageGrid.handleItemEvent(m_realizeIndex,
+                                               ItemEvent::TAP_AND_HOLD, x, y);
+                       }
+
+                       void onHighlighted(Widget &widget, void *eventInfo)
+                       {
+                               if (!isRealized()) {
+                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
+                               }
+                               m_imageGrid.onItemHighlighted(m_realizeIndex);
+                       }
+
+                       void onUnhighlighted(Widget &widget, void *eventInfo)
+                       {
+                               if (!isRealized()) {
+                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
+                               }
+                               m_imageGrid.onItemUnhighlighted(m_realizeIndex);
+                       }
+
+                       Eina_Bool onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
+                                       Evas_Object *obj)
+                       {
+                               if (!isRealized()) {
+                                       LOG_RETURN_VALUE(RES_ILLEGAL_STATE, EINA_FALSE,
+                                                       "Item is not realized!");
+                               }
+
+                               const Elm_Atspi_Relation_Type relation =
+                                               getFlowRelation(gestureInfo);
+                               if (relation == ELM_ATSPI_RELATION_NULL) {
+                                       return EINA_FALSE;
+                               }
+
+                               const int relationIndex =
+                                               ((relation == ELM_ATSPI_RELATION_FLOWS_TO) ?
+                                                       (m_realizeIndex + 1) :
+                                                       (m_realizeIndex - 1));
+
+                               auto relationObject = m_imageGrid.requestAtspi(relationIndex);
+                               if (!relationObject) {
+                                       relationObject = m_btn.getEo();
+                               }
+
+                               elm_atspi_accessible_relationships_clear(m_btn);
+                               elm_atspi_accessible_relationship_append(m_btn,
+                                               relation, relationObject);
+
+                               return EINA_FALSE;
+                       }
+
+               private:
+                       ImageGrid &m_imageGrid;
+                       StyledWidget m_btn;
+                       StyledWidget m_image;
+                       WidgetSRef m_bgImage;
+                       TouchParserSRef m_touchParser;
+                       int m_realizeIndex = -1;
+                       int m_imageLoadSize = 0;
+                       int m_imageMinLoadSize = 1;
+                       int m_imageWidth = 1;
+                       int m_imageHeight = 1;
+                       bool m_wasUpdated = false;
+                       bool m_isImageEmpty = false;
+                       bool m_isImageLoaded = false;
+                       bool m_isClicksBlocked = false;
+                       bool m_isSelected = false;
+               };
+
+       public:
+               Slot(ImageGrid &imageGrid, const bool isOdd) :
+                       m_info(imageGrid.m_info),
+                       m_layout(elm_layout_add(imageGrid.m_box), true),
+                       m_isRealized(false)
+               {
+                       int imageMinLoadSize = 0;
+
+                       if (isValid(m_info.slotThemes[isOdd])) {
+                               if (!m_layout.setTheme(m_info.slotThemes[isOdd])) {
+                                       ELOG("setTheme() failed!");
+                               } else if (imageGrid.m_isInSelectMode) {
+                                       m_layout.emit(impl::SIGNAL_FORCE_SELECT_MODE);
+                                       edje_object_message_signal_process(
+                                                       elm_layout_edje_get(m_layout));
+                               }
+                               imageMinLoadSize = ELM_SCALE_SIZE(m_layout.getData(
+                                               impl::DATA_IMAGE_MIN_LOAD_SIZE).asInt());
+                       }
+                       fill(m_layout);
+                       show(m_layout);
+
+                       const int length = m_info.slotLens[isOdd];
+                       for (int i = 0; i < length; ++i) {
+                               m_items.emplace_back(makeShared<Item>(imageGrid, m_layout));
+
+                               const auto partName = impl::SLOT_PART_FMT.format(i);
+                               m_layout.setContent(m_items.back()->getWidget(),
+                                               EdjePart(partName.c_str()));
+
+                               m_items.back()->setImageMinLoadSize(imageMinLoadSize);
+                       }
+               }
+
+               Layout &getLayout()
+               {
+                       return m_layout;
+               }
+
+               int getSize()
+               {
+                       int w = 0;
+                       int h = 0;
+                       m_layout.getMin(&w, &h);
+                       return std::max((m_info.isHorizontal ? w : h), 1);
+               }
+
+               void unrealize()
+               {
+                       if (!m_isRealized) {
+                               return;
+                       }
+                       m_isRealized = false;
+
+                       for (auto &item: m_items) {
+                               item->unrealize();
+                       }
+               }
+
+               void realize(const int slotIndex)
+               {
+                       if (m_isRealized) {
+                               return;
+                       }
+                       m_isRealized = true;
+
+                       for (UInt i = 0; i < m_items.size(); ++i) {
+                               m_items[i]->realize(
+                                               m_info.calcItemIndexFromCell(slotIndex, i));
+                       }
+               }
+
+               void unselect()
+               {
+                       for (UInt i = 0; i < m_items.size(); ++i) {
+                               setSelected(i, false);
+                       }
+               }
+
+               bool updateItem(const int itemOffset, const ItemParams &params)
+               {
+                       setSelected(itemOffset, (params.flags & UF_SELECTED));
+                       return m_items[itemOffset]->update(params);
+               }
+
+               bool isItemRealized(const int itemOffset) const
+               {
+                       return m_items[itemOffset]->isRealized();
+               }
+
+               void getItemInfo(const int itemOffset, ItemInfo &info) const
+               {
+                       m_items[itemOffset]->getInfo(info);
+               }
+
+               Elm_Interface_Atspi_Accessible *getItemAtspi(const int itemOffset)
+               {
+                       return m_items[itemOffset]->getWidget().getEo();
+               }
+
+       private:
+               void setSelected(const int itemOffset, const bool selected)
+               {
+                       if (!m_items[itemOffset]->setSelected(selected)) {
+                               return;
+                       }
+                       const auto signalName = (selected ?
+                                       impl::SIGNAL_SELECT_ITEM_FMT.format(itemOffset) :
+                                       impl::SIGNAL_UNSELECT_ITEM_FMT.format(itemOffset));
+                       m_layout.emit(EdjeSignal(signalName.c_str()));
+               }
+
+       private:
+               const Info &m_info;
+               std::vector<SharedRef<Item>> m_items;
+               Layout m_layout;
+               bool m_isRealized;
+       };
+
+       // ImageGrid::Unrealizer //
+
+       ImageGrid::Unrealizer::Unrealizer(ImageGrid &imageGrid) :
+               m_imageGrid(imageGrid)
+       {
+               m_imageGrid.addUnrealizeLock();
+       }
+
+       ImageGrid::Unrealizer::~Unrealizer()
+       {
+               m_imageGrid.removeUnrealizeLock();
+       }
+
+       // ImageGrid //
+
+       ImageGrid::ImageGrid(IRefCountObj *const rc, Evas_Object *const scroller,
+                       const Type type, const bool selectModeStartup) :
+               ElmWidget(rc, scroller),
+               m_info(getInfo(type)),
+
+               m_scroller(makeShared<StyledWidget>(scroller, false).get()),
+               m_box(elm_box_add(*m_scroller)),
+               m_rect1(evas_object_rectangle_add(m_box.getEvas())),
+               m_rect2(evas_object_rectangle_add(m_box.getEvas())),
+               m_circleScroller(nullptr),
+
+               m_itemCount(0),
+
+               m_slotCount(0), // Must be even >= 2
+               m_optimalSlotCount(2), // Must be even >= 2
+               m_maxSlotCount(2), // Must be even >= 2
+
+               m_beginSlotIndex(0),
+               m_maxBeginSlotIndex(0),
+
+               m_scrollBias(0),
+               m_padSize1(0),
+               m_padSize2(0),
+
+               m_slotSize(0), // Must not be 0
+               m_scrollerSize(1), // Must not be 0
+               m_scrollOffset(0),
+
+               m_unrealizeLock(0),
+               m_eventsLock(0),
+
+               m_animator(nullptr),
+               m_scrollLockIndex(0),
+               m_isInSelectMode(selectModeStartup),
+               m_isRotaryActive(false),
+
+               m_highlightID(-1),
+               m_isHighlightLocked(false)
+       {
+               prepare();
+
+               ++m_eventsLock;
+
+               updateSlotCount();
+
+               updatePadSizes();
+               updateScrollBias();
+               updateRectMins();
+
+               --m_eventsLock;
+       }
+
+       ImageGrid::~ImageGrid()
+       {
+               if (m_animator) {
+                       finalizeTransition();
+               }
+       }
+
+       const ImageGrid::Info &ImageGrid::getInfo(const Type type)
+       {
+               switch (type) {
+               case Type::HCOMB_3X3: {
+                               static HcombInfo info{3, {{
+                                               {"layout", "gallery_image_grid", "hcomb_3x3_even"},
+                                               {"layout", "gallery_image_grid", "hcomb_3x3_odd"}}},
+                                               ElmStyle{"gallery_image_thumb"}};
+                               return info;
+                       }
+               case Type::LINEAR:
+               default: {
+                               static LinearInfo info{
+                                               {"layout", "gallery_image_grid", "linear"},
+                                               ElmStyle{"gallery_image_full"}, true};
+                               return info;
+                       }
+               }
+       }
+
+       void ImageGrid::prepare()
+       {
+               fill(m_rect1);
+               elm_box_pack_end(m_box, m_rect1);
+               makeTransparent(m_rect1);
+               show(m_rect1);
+
+               expandAndFill(m_rect2);
+               elm_box_pack_end(m_box, m_rect2);
+               makeTransparent(m_rect2);
+               show(m_rect2);
+
+               m_scroller->setContent(m_box);
+               elm_box_horizontal_set(m_box, toEina(m_info.isHorizontal));
+               show(m_box);
+
+               m_scroller->setStyle(SCROLLER_STYLE);
+               expandAndFill(*m_scroller);
+               if (m_info.isHorizontal) {
+                       elm_scroller_page_scroll_limit_set(
+                                       *m_scroller, m_info.scrollLimit, 0);
+                       elm_scroller_bounce_set(*m_scroller, EINA_TRUE, EINA_FALSE);
+               } else {
+                       elm_scroller_page_scroll_limit_set(
+                                       *m_scroller, 0, m_info.scrollLimit);
+                       elm_scroller_bounce_set(*m_scroller, EINA_FALSE, EINA_TRUE);
+               }
+               show(*m_scroller);
+
+               createCircleScroller();
+
+               createHighlighKeeper();
+
+               m_scroller->addEventHandler(WidgetEvent::RESIZE,
+                               WEAK_DELEGATE(ImageGrid::onScrollerResize, asWeak(*this)));
+
+               m_scroller->addEventHandler(WidgetEvent::MOVE,
+                               WEAK_DELEGATE(ImageGrid::onScrollerMove, asWeak(*this)));
+
+               m_box.addEventHandler(WidgetEvent::MOVE,
+                               WEAK_DELEGATE(ImageGrid::onBoxMove, asWeak(*this)));
+       }
+
+       void ImageGrid::createCircleScroller()
+       {
+               const auto sfc = util::getCircleSurface(*m_scroller);
+               if (!sfc) {
+                       LOG_RETURN_VOID(RES_FAIL, "util::getCircleSurface() failed!");
+               }
+
+               m_circleScroller = eext_circle_object_scroller_add(*m_scroller, sfc);
+               if (!m_circleScroller) {
+                       LOG_RETURN_VOID(RES_FAIL,
+                                       "eext_circle_object_scroller_add() failed!");
+               }
+
+               if (m_info.isHorizontal) {
+                       eext_circle_object_scroller_policy_set(m_circleScroller,
+                                       ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
+               } else {
+                       eext_circle_object_scroller_policy_set(m_circleScroller,
+                                       ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+               }
+       }
+
+       void ImageGrid::createHighlighKeeper()
+       {
+               m_highlighKeeper = util::createFakeAccessObject(*m_box.getWindow());
+               UCL_ASSERT(m_highlighKeeper, "m_highlighKeeper is NULL");
+
+               m_highlighKeeper->addEventHandler(ATSPI_UNHIGHLIGHTED,
+                               WEAK_DELEGATE(ImageGrid::onKeeperUnhighlighted, asWeak(*this)));
+       }
+
+       void ImageGrid::setListener(const IListenerWRef &listener)
+       {
+               m_listener = listener;
+       }
+
+       Result ImageGrid::setItemCount(const int count)
+       {
+               if (m_animator) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
+               }
+
+               if (m_itemCount == count) {
+                       return RES_FALSE;
+               }
+
+               ++m_eventsLock;
+
+               unrealizeSlots(0, m_slotCount);
+
+               m_itemCount = count;
+
+               if (updateMaxSlotCount()) {
+                       updateSlotCount();
+                       if (updateMaxBeginSlotIndex()) {
+                               updateBeginSlotIndex();
+                       }
+               }
+
+               realizeSlots();
+               updateRectMins();
+
+               --m_eventsLock;
+
+               return RES_OK;
+       }
+
+       Result ImageGrid::setSelectModeEnabled(const bool enabled)
+       {
+               if (m_animator) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
+               }
+
+               if (enabled == m_isInSelectMode) {
+                       return RES_FALSE;
+               }
+
+               if ((m_scrollOffset % m_slotSize) > 0) {
+                       DLOG("Can't handle it right now!");
+                       return RES_FAIL;
+               }
+
+               m_scrollLockIndex = std::min(
+                               (m_scrollOffset / m_slotSize), (m_itemCount - 1));
+
+               m_isInSelectMode = enabled;
+
+               elm_object_scroll_freeze_push(*m_scroller);
+               evas_object_freeze_events_set(*m_scroller, EINA_TRUE);
+               eext_rotary_object_event_activated_set(m_circleScroller, EINA_FALSE);
+
+               for (auto &slot: m_slots) {
+                       slot->unselect();
+               }
+
+               const auto aSignal = (enabled ?
+                               impl::SIGNAL_ENABLE_SELECT_MODE :
+                               impl::SIGNAL_DISABLE_SELECT_MODE);
+               for (auto &slot: m_slots) {
+                       slot->getLayout().emit(aSignal);
+               }
+
+               m_animator = ecore_animator_add(
+                               CALLBACK_A(ImageGrid::onAnimationFrame), this);
+
+               evas_object_event_callback_priority_add(m_box,
+                                       EVAS_CALLBACK_RESIZE, EO_CALLBACK_PRIORITY_AFTER,
+                                       CALLBACK_A(ImageGrid::onBoxResize), this);
+
+               auto &slotlayout = m_slots[m_beginSlotIndex & 1]->getLayout();
+
+               slotlayout.addEventHandler(WidgetEvent::CHANGED_SIZE_HINTS,
+                               WEAK_DELEGATE(ImageGrid::onSlotResize, asWeak(*this)));
+
+               elm_object_signal_callback_add(slotlayout,
+                               impl::SIGNAL_TRANSITION_FINISHED.name, "",
+                               CALLBACK_A(ImageGrid::onTransitonFinished), this);
+
+               return RES_OK;
+       }
+
+       bool ImageGrid::isInSelectMode() const
+       {
+               return m_isInSelectMode;
+       }
+
+       bool ImageGrid::isInTransition() const
+       {
+               return !!m_animator;
+       }
+
+       void ImageGrid::onTransitonFinished(Evas_Object *obj,
+                       const char *emission, const char *source)
+       {
+               evalSlotSizes();
+
+               finalizeTransition();
+
+               elm_object_scroll_freeze_pop(*m_scroller);
+               evas_object_freeze_events_set(*m_scroller, EINA_FALSE);
+               if (m_isRotaryActive) {
+                       eext_rotary_object_event_activated_set(m_circleScroller, EINA_TRUE);
+               }
+
+               if (const auto listener = m_listener.lock()) {
+                       listener->onTransitionFinished();
+               }
+       }
+
+       void ImageGrid::finalizeTransition()
+       {
+               if (m_animator) {
+                       ecore_animator_del(m_animator);
+                       m_animator = nullptr;
+               }
+
+               evas_object_event_callback_del_full(m_box, EVAS_CALLBACK_RESIZE,
+                               CALLBACK_A(ImageGrid::onBoxResize), this);
+
+               auto &slotlayout = m_slots[m_beginSlotIndex & 1]->getLayout();
+
+               slotlayout.delEventHandler(WidgetEvent::CHANGED_SIZE_HINTS,
+                               WEAK_DELEGATE(ImageGrid::onSlotResize, asWeak(*this)));
+
+               elm_object_signal_callback_del(slotlayout,
+                               "gallery,transition,finished", "",
+                               CALLBACK_A(ImageGrid::onTransitonFinished));
+       }
+
+       Eina_Bool ImageGrid::onAnimationFrame()
+       {
+               evalSlotSizes();
+               return ECORE_CALLBACK_RENEW;
+       }
+
+       void ImageGrid::evalSlotSizes()
+       {
+               for (auto &slot: m_slots) {
+                       elm_layout_sizing_eval(slot->getLayout());
+               }
+       }
+
+       void ImageGrid::onSlotResize(Widget &widget, void *eventInfo)
+       {
+               if (updateSlotSize()) {
+                       updatePadSizes();
+                       updateScrollBias();
+                       updateRectMins();
+               }
+       }
+
+       void ImageGrid::onBoxResize(Evas *e, Evas_Object *obj, void *eventInfo)
+       {
+               m_scrollOffset = (m_scrollLockIndex * m_slotSize);
+               if (m_info.isHorizontal) {
+                       elm_scroller_region_show(*m_scroller,
+                                       m_scrollOffset, 0, m_scrollerSize, 1);
+               } else {
+                       elm_scroller_region_show(*m_scroller,
+                                       0, m_scrollOffset, 1, m_scrollerSize);
+               }
+       }
+
+       void ImageGrid::update()
+       {
+               Unrealizer(*this);
+       }
+
+       Result ImageGrid::updateItem(const int itemIndex, const ItemParams &params)
+       {
+               if (m_animator) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
+               }
+               return doWithItem(itemIndex,
+                       [&params](Slot &slot, const int itemOffset)
+                       {
+                               return (slot.updateItem(itemOffset, params) ?
+                                               RES_OK : RES_FALSE);
+                       });
+       }
+
+       Result ImageGrid::isItemRealized(const int itemIndex) const
+       {
+               return doWithItem(itemIndex,
+                       [](Slot &slot, const int itemOffset)
+                       {
+                               return (slot.isItemRealized(itemOffset) ? RES_OK : RES_FALSE);
+                       });
+       }
+
+       Result ImageGrid::getItemInfo(const int itemIndex, ItemInfo &info) const
+       {
+               return doWithItem(itemIndex,
+                       [&info](Slot &slot, const int itemOffset)
+                       {
+                               slot.getItemInfo(itemOffset, info);
+                               return RES_OK;
+                       });
+       }
+
+       Elm_Interface_Atspi_Accessible *ImageGrid::getAccessObject(
+                       const bool isFlowsTo)
+       {
+               return getItemAtspi(isFlowsTo ? 0 : (m_itemCount - 1));
+       }
+
+       template <class FUNC>
+       Result ImageGrid::doWithItem(const int itemIndex, FUNC &&func) const
+       {
+               return doWithCell(itemIndex,
+                       [this, &func](const int slotIndex, const int itemOffset)
+                       {
+                               const int slotOffset = (slotIndex - m_beginSlotIndex);
+                               if ((slotOffset < 0) || (slotOffset >= m_slotCount)) {
+                                       return RES_FALSE;
+                               }
+                               return func(*m_slots[slotOffset], itemOffset);
+                       });
+       }
+
+       template <class FUNC>
+       Result ImageGrid::doWithCell(const int itemIndex, FUNC &&func) const
+       {
+               if ((itemIndex < 0) || (itemIndex >= m_itemCount)) {
+                       LOG_RETURN(RES_INVALID_ARGUMENTS,
+                                       "Item index out of range: %d", itemIndex);
+               }
+
+               int slotIndex = 0;
+               int itemOffset = 0;
+               m_info.calcCellFromItemIndex(itemIndex, slotIndex, itemOffset);
+
+               return func(slotIndex, itemOffset);
+       }
+
+       int ImageGrid::getScrolledToItemIndex() const
+       {
+               const int evenSlotIndex = (std::lround(1.0 * m_scrollOffset /
+                               m_slotSize) * 2);
+               return std::min((m_itemCount - 1), std::min(
+                       m_info.calcItemIndexFromCell(evenSlotIndex, 0),
+                       m_info.calcItemIndexFromCell((evenSlotIndex + 1), 0)));
+       }
+
+       Result ImageGrid::scrollToItem(const int itemIndex)
+       {
+               if (m_animator) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
+               }
+               forceBoxSizeCalculate();
+               return showItem(itemIndex, elm_scroller_region_show);
+       }
+
+       Result ImageGrid::bringInItem(int itemIndex)
+       {
+               if (m_animator) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
+               }
+               return showItem(itemIndex, elm_scroller_region_bring_in);
+       }
+
+       template <class SHOW_FUNC>
+       Result ImageGrid::showItem(const int itemIndex, SHOW_FUNC &&showFunc)
+       {
+               return doWithCell(itemIndex,
+                       [this, &showFunc](const int slotIndex, const int itemOffset)
+                       {
+                               int minVisibleOffset = 0;
+                               int maxVisibleOffset = 0;
+                               if (isItemFullyVisible(slotIndex, itemOffset,
+                                               minVisibleOffset, maxVisibleOffset)) {
+                                       return RES_OK;
+                               }
+
+                               const int scrollOffset = ((m_scrollOffset > maxVisibleOffset) ?
+                                               maxVisibleOffset : minVisibleOffset);
+                               if (m_info.isHorizontal) {
+                                       showFunc(*m_scroller, scrollOffset, 0, m_scrollerSize, 1);
+                               } else {
+                                       showFunc(*m_scroller, 0, scrollOffset, 1, m_scrollerSize);
+                               }
+
+                               return RES_OK;
+                       });
+       }
+
+       bool ImageGrid::isItemFullyVisible(int itemIndex)
+       {
+               int minVisibleOffset = 0;
+               int maxVisibleOffset = 0;
+               return isItemFullyVisible(itemIndex,
+                               minVisibleOffset, maxVisibleOffset);
+       }
+
+       bool ImageGrid::isItemFullyVisible(const int itemIndex,
+                       int &minVisibleOffset, int &maxVisibleOffset) const
+       {
+               return (doWithCell(itemIndex,
+                               [this, &minVisibleOffset, &maxVisibleOffset](
+                                               const int slotIndex, const int itemOffset)
+                               {
+                                       return (isItemFullyVisible(slotIndex, itemOffset,
+                                                       minVisibleOffset, maxVisibleOffset) ?
+                                                               RES_OK : RES_FALSE);
+                               }
+                       ) == RES_OK);
+       }
+
+       bool ImageGrid::isItemFullyVisible(
+                       const int slotIndex, const int itemOffset,
+                       int &minVisibleOffset, int &maxVisibleOffset) const
+       {
+               const int extraPadding = ((slotIndex & 1) ?
+                               m_info.calcExtraPaddingSize(m_slotSize) : 0);
+
+               maxVisibleOffset = ((slotIndex / 2) * m_slotSize);
+               minVisibleOffset = (maxVisibleOffset + extraPadding -
+                               ((m_scrollerSize / m_slotSize) - 1) * m_slotSize);
+
+               if ((m_scrollOffset >= minVisibleOffset) &&
+                               (m_scrollOffset <= maxVisibleOffset)) {
+                       return true;
+               }
+
+               return false;
+       }
+
+       void ImageGrid::forceBoxSizeCalculate()
+       {
+               for (int i = 0; i < m_slotCount; ++i) {
+                       if (((m_beginSlotIndex + i) & 1) == 0) {
+                               m_slots[i]->getLayout().calculate();
+                       }
+               }
+               m_box.calculate();
+       }
+
+       void ImageGrid::activateRotary()
+       {
+               m_isRotaryActive = true;
+               if (!m_animator) {
+                       eext_rotary_object_event_activated_set(m_circleScroller, EINA_TRUE);
+               }
+       }
+
+       void ImageGrid::deactivateRotary()
+       {
+               m_isRotaryActive = false;
+               eext_rotary_object_event_activated_set(m_circleScroller, EINA_FALSE);
+       }
+
+       void ImageGrid::addUnrealizeLock()
+       {
+               if (m_animator) {
+                       ELOG("Transition is in progress.");
+               } else {
+                       unrealizeSlots(0, m_slotCount);
+               }
+               ++m_unrealizeLock;
+       }
+
+       void ImageGrid::removeUnrealizeLock()
+       {
+               if (m_unrealizeLock > 0) {
+                       --m_unrealizeLock;
+                       if (m_animator) {
+                               ELOG("Transition is in progress.");
+                       } else {
+                               realizeSlots();
+                       }
+               } else {
+                       WLOG("m_unrealizeLock = 0!");
+               }
+       }
+
+       void ImageGrid::handleItemEvent(const int itemIndex,
+                       const ItemEvent event, const int x, const int y) const
+       {
+               if (const auto listener = m_listener.lock()) {
+                       listener->onItemEvent(itemIndex, event, x, y);
+               }
+       }
+
+       void ImageGrid::onItemHighlighted(const int itemIndex)
+       {
+               m_highlightID = itemIndex;
+               m_highlightTimeout.reset();
+       }
+
+       void ImageGrid::onItemUnhighlighted(const int itemIndex)
+       {
+               if (m_highlightID == itemIndex) {
+                       m_highlightID = (-1 - itemIndex);
+                       if (m_isHighlightLocked) {
+                               elm_atspi_component_highlight_grab(*m_highlighKeeper);
+                       } else {
+                               m_highlightTimeout.reset();
+                       }
+               }
+       }
+
+       void ImageGrid::onKeeperUnhighlighted(Widget &sender, void *eventInfo)
+       {
+               m_isHighlightLocked = false;
+               m_highlightTimeout.reset();
+       }
+
+       void ImageGrid::updateHighlightTimeout()
+       {
+               if (m_highlightID >= 0) {
+                       if (isItemFullyVisible(m_highlightID)) {
+                               m_highlightTimeout.reset();
+                               return;
+                       }
+               } else if (!m_isHighlightLocked) {
+                       return;
+               }
+
+               m_highlightTimeout = Timeout::create(
+                               impl::SCROLL_HIGHLIGHT_TIMEOUT_SEC, WEAK_DELEGATE(
+                                       ImageGrid::onHighlightTimeout, asWeak(*this)));
+       }
+
+       void ImageGrid::onHighlightTimeout(Timeout *sender)
+       {
+               m_highlightTimeout.reset();
+
+               int itemIndex = ((m_highlightID >= 0) ?
+                               m_highlightID : (-1 - m_highlightID));
+               bool found = false;
+
+               for (int i = m_info.getHighlightScanRange(); ((i >= 0) &&
+                               (itemIndex >= 0) && (itemIndex < m_itemCount)); --i) {
+                       int minVisibleOffset = 0;
+                       int maxVisibleOffset = 0;
+                       if (isItemFullyVisible(itemIndex,
+                                       minVisibleOffset, maxVisibleOffset)) {
+                               found = true;
+                       } else if (m_scrollOffset > maxVisibleOffset) {
+                               ++itemIndex;
+                       } else {
+                               --itemIndex;
+                       }
+               }
+
+               if (!found) {
+                       itemIndex = getScrolledToItemIndex();
+               }
+
+               FAIL_RETURN_VOID(doWithItem(itemIndex,
+                       [](Slot &slot, const int itemOffset)
+                       {
+                               elm_atspi_component_highlight_grab(
+                                               slot.getItemAtspi(itemOffset));
+                               return RES_OK;
+                       }), "Failed to Grab item highlight!");
+       }
+
+       Elm_Interface_Atspi_Accessible *ImageGrid::requestAtspi(const int itemIndex)
+       {
+               if ((itemIndex < 0) || (itemIndex >= m_itemCount)) {
+                       if (const auto listener = m_listener.lock()) {
+                               return listener->onAccessObjectRequest(
+                                               (itemIndex >= m_itemCount));
+                       }
+                       return nullptr;
+               }
+
+               const int oldHighlightID = m_highlightID;
+               m_highlightID = itemIndex; // To prevent autohighlight timer to start
+
+               const auto result = getItemAtspi(itemIndex);
+               if (!result) {
+                       m_highlightID = oldHighlightID;
+                       return nullptr;
+               }
+
+               m_highlightTimeout.reset();
+
+               return result;
+       }
+
+       Elm_Interface_Atspi_Accessible *ImageGrid::getItemAtspi(
+                       const int itemIndex)
+       {
+               FAIL_RETURN_VALUE(scrollToItem(itemIndex), nullptr,
+                               "scrollToItem() failed!");
+
+               Elm_Interface_Atspi_Accessible *result = nullptr;
+
+               FAIL_RETURN_VALUE(doWithItem(itemIndex,
+                       [&result](Slot &slot, const int itemOffset)
+                       {
+                               result = slot.getItemAtspi(itemOffset);
+                               return RES_OK;
+                       }), nullptr, "Failed to get item Atspi!");
+
+               return result;
+       }
+
+       bool ImageGrid::updateSlotCount()
+       {
+               const int newSlotCount = calcSlotCount();
+
+               if (newSlotCount != m_slotCount) {
+                       DLOG("newSlotCount: %d; m_slotCount: %d;",
+                                       newSlotCount, m_slotCount);
+                       setSlotCount(newSlotCount);
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcSlotCount()
+       {
+               return std::min(m_optimalSlotCount, m_maxSlotCount);
+       }
+
+       void ImageGrid::setSlotCount(const int newSlotCount)
+       {
+               for (int i = m_slotCount; i < newSlotCount; ++i) {
+                       const bool isOdd = ((m_beginSlotIndex + i) & 1);
+
+                       auto slot = util::makeUnique(new Slot(*this, isOdd));
+
+                       if (m_slotSize == 0) {
+                               UCL_ASSERT(!isOdd, "Must be even!");
+                               slot->getLayout().calculate();
+                               setSlotSize(slot->getSize());
+                       }
+
+                       elm_box_pack_before(m_box, slot->getLayout(), m_rect2);
+
+                       m_slots.emplace_back(std::move(slot));
+               }
+
+               unrealizeSlots(newSlotCount, m_slotCount);
+
+               m_slots.resize(newSlotCount);
+               m_slotCount = newSlotCount;
+       }
+
+       bool ImageGrid::updateOptimalSlotCount()
+       {
+               const int newOptimalSlotCount = calcOptimalSlotCount();
+
+               if (newOptimalSlotCount != m_optimalSlotCount) {
+                       DLOG("newOptimalSlotCount: %d; m_optimalSlotCount: %d;",
+                                       newOptimalSlotCount, m_optimalSlotCount);
+                       m_optimalSlotCount = newOptimalSlotCount;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcOptimalSlotCount()
+       {
+               return (((m_scrollerSize / m_slotSize) + 3) * 2);
+       }
+
+       bool ImageGrid::updateMaxSlotCount()
+       {
+               const int newMaxSlotCount = calcMaxSlotCount();
+
+               if (newMaxSlotCount != m_maxSlotCount) {
+                       DLOG("newMaxSlotCount: %d; m_maxSlotCount: %d;",
+                                       newMaxSlotCount, m_maxSlotCount);
+                       m_maxSlotCount = newMaxSlotCount;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcMaxSlotCount()
+       {
+               return std::max(m_info.calcMaxSlotCount(m_itemCount), 2);
+       }
+
+       bool ImageGrid::updateBeginSlotIndex()
+       {
+               const int newBeginSlotIndex = calcBeginSlotIndex();
+
+               if (newBeginSlotIndex != m_beginSlotIndex) {
+                       DLOG("newBeginSlotIndex: %d; m_beginSlotIndex: %d;",
+                                       newBeginSlotIndex, m_beginSlotIndex);
+                       setBeginSlotIndex(newBeginSlotIndex);
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcBeginSlotIndex()
+       {
+               const int evenScrolledSize = (m_scrollOffset - m_scrollBias);
+               const int oddScrolledSize = (evenScrolledSize - m_slotSize / 2);
+
+               const int beginEvenSlotIndex = (evenScrolledSize / m_slotSize);
+               const int beginOddSlotIndex = (oddScrolledSize / m_slotSize);
+
+               int beginSlotIndex = ((beginEvenSlotIndex <= beginOddSlotIndex) ?
+                               (beginEvenSlotIndex * 2) : (beginOddSlotIndex * 2 + 1));
+
+               if (beginSlotIndex < 0) {
+                       beginSlotIndex = 0;
+               } else if (beginSlotIndex > m_maxBeginSlotIndex) {
+                       beginSlotIndex = m_maxBeginSlotIndex;
+               }
+
+               return beginSlotIndex;
+       }
+
+       void ImageGrid::setBeginSlotIndex(const int newBeginSlotIndex)
+       {
+               const int beginSlotIndex = m_beginSlotIndex;
+               const int endSlotIndex = (beginSlotIndex + m_slotCount);
+               const int newEndSlotIndex = (newBeginSlotIndex + m_slotCount);
+
+               if ((newEndSlotIndex <= beginSlotIndex) ||
+                               (endSlotIndex <= newBeginSlotIndex)) {
+
+                       unrealizeSlots(0, m_slotCount);
+
+                       if ((beginSlotIndex ^ newBeginSlotIndex) & 1) {
+                               rotateSlotsRight(1);
+                       }
+
+               } else if (newBeginSlotIndex < beginSlotIndex) {
+                       const int goodSlots = (newEndSlotIndex - beginSlotIndex);
+                       const int badSlots = (m_slotCount - goodSlots);
+
+                       unrealizeSlots(goodSlots, m_slotCount);
+
+                       if (goodSlots > badSlots) {
+                               rotateSlotsRight(badSlots);
+                       } else {
+                               rotateSlotsLeft(goodSlots);
+                       }
+               } else {
+                       const int goodSlots = (endSlotIndex - newBeginSlotIndex);
+                       const int badSlots = (m_slotCount - goodSlots);
+
+                       unrealizeSlots(0, badSlots);
+
+                       if (goodSlots > badSlots) {
+                               rotateSlotsLeft(badSlots);
+                       } else {
+                               rotateSlotsRight(goodSlots);
+                       }
+               }
+
+               m_beginSlotIndex = newBeginSlotIndex;
+       }
+
+       bool ImageGrid::updateMaxBeginSlotIndex()
+       {
+               const int newMaxBeginSlotIndex = calcMaxBeginSlotIndex();
+
+               if (newMaxBeginSlotIndex != m_maxBeginSlotIndex) {
+                       DLOG("newMaxBeginSlotIndex: %d; m_maxBeginSlotIndex: %d;",
+                                       newMaxBeginSlotIndex, m_maxBeginSlotIndex);
+                       m_maxBeginSlotIndex = newMaxBeginSlotIndex;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcMaxBeginSlotIndex()
+       {
+               return (m_maxSlotCount - m_slotCount);
+       }
+
+       void ImageGrid::updatePadSizes()
+       {
+               const int spaceSize = (m_scrollerSize -
+                               (std::max((m_scrollerSize / m_slotSize), 1) * m_slotSize));
+
+               m_padSize1 = std::lround(spaceSize / 2.0);
+               m_padSize2 = (spaceSize - m_padSize1 +
+                               m_info.calcExtraPaddingSize(m_slotSize));
+       }
+
+       void ImageGrid::updateScrollBias()
+       {
+               m_scrollBias = (((m_optimalSlotCount / 2 - 1) * m_slotSize -
+                               m_scrollerSize) / 2 + m_padSize1);
+       }
+
+       void ImageGrid::updateRectMins()
+       {
+               const int beginEvenCols = ((m_beginSlotIndex + 1) / 2);
+               const int sideEvenCols = ((m_maxSlotCount - m_slotCount) / 2);
+               const int endEvenCols = (sideEvenCols - beginEvenCols);
+
+               const int rectMin1 = (m_padSize1 + (beginEvenCols * m_slotSize));
+               const int rectMin2 = (m_padSize2 + (endEvenCols * m_slotSize));
+
+               if (m_info.isHorizontal) {
+                       m_rect1.setMin(rectMin1, 0);
+                       m_rect2.setMin(rectMin2, 0);
+               } else {
+                       m_rect1.setMin(0, rectMin1);
+                       m_rect2.setMin(0, rectMin2);
+               }
+       }
+
+       bool ImageGrid::updateSlotSize()
+       {
+               const int newSlotSize = m_slots[m_beginSlotIndex & 1]->getSize();
+
+               if (newSlotSize != m_slotSize) {
+                       DLOG("newSlotSize: %d; m_slotSize: %d;",
+                                       newSlotSize, m_slotSize);
+                       setSlotSize(newSlotSize);
+                       return true;
+               }
+
+               return false;
+       }
+
+       void ImageGrid::setSlotSize(const int newSlotSize)
+       {
+               m_slotSize = newSlotSize;
+               const int pageSize = (m_slotSize * m_info.slotsPerPage);
+               if (m_info.isHorizontal) {
+                       elm_scroller_page_size_set(*m_scroller, pageSize, 0);
+               } else {
+                       elm_scroller_page_size_set(*m_scroller, 0, pageSize);
+               }
+       }
+
+       int ImageGrid::calcScrollerSize()
+       {
+               int scrollerW = 0;
+               int scrollerH = 0;
+               getSize(*m_scroller, &scrollerW, &scrollerH);
+
+               return std::max((m_info.isHorizontal ? scrollerW : scrollerH), 1);
+       }
+
+       bool ImageGrid::updateScrollerSize()
+       {
+               const int newScrollerSize = calcScrollerSize();
+
+               if (newScrollerSize != m_scrollerSize) {
+                       DLOG("newScrollerSize: %d; m_scrollerSize: %d;",
+                                       newScrollerSize, m_scrollerSize);
+                       m_scrollerSize = newScrollerSize;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcScrollOffset()
+       {
+               int scrollOffsetX = 0;
+               int scrollOffsetY = 0;
+               elm_scroller_region_get(*m_scroller, &scrollOffsetX, &scrollOffsetY,
+                               nullptr, nullptr);
+
+               return (m_info.isHorizontal ? scrollOffsetX : scrollOffsetY);
+       }
+
+       bool ImageGrid::updateScrollOffset()
+       {
+               const int newScrollOffset = calcScrollOffset();
+
+               if (newScrollOffset != m_scrollOffset) {
+                       DLOG("newScrollOffset: %d; m_scrollOffset: %d;",
+                                       newScrollOffset, m_scrollOffset);
+                       m_scrollOffset = newScrollOffset;
+                       return true;
+               }
+
+               return false;
+       }
+
+       void ImageGrid::rotateSlotsRight(const int count)
+       {
+               DLOG("count: %d", count);
+               for (int i = 0; i < count; ++i) {
+                       SlotUPtr slot = std::move(m_slots.back());
+                       m_slots.pop_back();
+                       elm_box_unpack(m_box, slot->getLayout());
+                       elm_box_pack_after(m_box, slot->getLayout(), m_rect1);
+                       m_slots.emplace_front(std::move(slot));
+               }
+       }
+
+       void ImageGrid::rotateSlotsLeft(const int count)
+       {
+               DLOG("count: %d", count);
+               for (int i = 0; i < count; ++i) {
+                       SlotUPtr slot = std::move(m_slots.front());
+                       m_slots.pop_front();
+                       elm_box_unpack(m_box, slot->getLayout());
+                       elm_box_pack_before(m_box, slot->getLayout(), m_rect2);
+                       m_slots.emplace_back(std::move(slot));
+               }
+       }
+
+       void ImageGrid::realizeSlots()
+       {
+               if (m_unrealizeLock == 0) {
+                       for (int i = 0; i < m_slotCount; ++i) {
+                               m_slots[i]->realize(m_beginSlotIndex + i);
+                       }
+               }
+       }
+
+       void ImageGrid::unrealizeSlots(
+                       const int beginSlotOffset, const int endSlotOffset)
+       {
+               if (m_unrealizeLock == 0) {
+                       for (int i = beginSlotOffset; i < endSlotOffset; ++i) {
+                               m_slots[i]->unrealize();
+                       }
+               }
+       }
+
+       void ImageGrid::handleScrolling()
+       {
+               if (m_animator) {
+                       return;
+               }
+
+               if (m_eventsLock > 0) {
+                       WLOG("Event handling was blocked!");
+                       return;
+               }
+               ++m_eventsLock;
+
+               if (updateScrollOffset()) {
+                       updateHighlightTimeout();
+                       if (updateBeginSlotIndex()) {
+                               realizeSlots();
+                               updateRectMins();
+                       }
+               }
+
+               --m_eventsLock;
+       }
+
+       void ImageGrid::handleResize()
+       {
+               if (m_animator) {
+                       return;
+               }
+
+               if (m_eventsLock > 0) {
+                       WLOG("Event handling was blocked!");
+                       return;
+               }
+               ++m_eventsLock;
+
+               if (updateScrollerSize()) {
+                       bool needRealize = false;
+
+                       updatePadSizes();
+
+                       if (updateOptimalSlotCount() && updateSlotCount()) {
+                               updateMaxBeginSlotIndex();
+                               needRealize = true;
+                       }
+
+                       updateScrollBias();
+
+                       if (updateBeginSlotIndex()) {
+                               needRealize = true;
+                       }
+
+                       if (needRealize) {
+                               realizeSlots();
+                       }
+                       updateRectMins();
+               }
+
+               --m_eventsLock;
+       }
+
+       void ImageGrid::onScrollerResize(Widget &sender, void *eventInfo)
+       {
+               handleResize();
+       }
+
+       void ImageGrid::onScrollerMove(Widget &sender, void *eventInfo)
+       {
+               handleScrolling();
+       }
+
+       void ImageGrid::onBoxMove(Widget &sender, void *eventInfo)
+       {
+               handleScrolling();
+       }
+}
diff --git a/gallery/view/ImageGrid.h b/gallery/view/ImageGrid.h
new file mode 100644 (file)
index 0000000..2eff5f5
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * 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_VIEW_IMAGE_GRID_H__
+#define __GALLERY_VIEW_IMAGE_GRID_H__
+
+#include <deque>
+
+#include "ucl/gui/StyledWidget.h"
+
+#include "ucl/misc/Timeout.h"
+
+#include "types.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(ImageGrid);
+
+       class ImageGrid : public ucl::ElmWidget {
+       public:
+               UCL_DECLARE_REF_ALIASES(IListener);
+
+               enum class Type {
+                       HCOMB_3X3,
+                       LINEAR
+               };
+
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setType(Type value);
+                       Builder &setListener(const IListenerWRef &value);
+                       Builder &setSelectModeStartup(bool value);
+                       ImageGridSRef build(ElmWidget &parent) const;
+               private:
+                       Type m_type;
+                       IListenerWRef m_listener;
+                       bool m_selectModeStartup;
+               };
+
+               enum class ItemEvent {
+                       CLICK,
+                       DOUBLE_TAP,
+                       TAP_AND_HOLD
+               };
+
+               class IListener : public ucl::Polymorphic {
+               public:
+                       virtual void onItemRealized(int itemIndex) = 0;
+                       virtual void onItemUnrealized(int itemIndex) = 0;
+                       virtual void onItemEvent(int itemIndex,
+                                       ItemEvent event, int x, int y) = 0;
+                       virtual void onTransitionFinished() {}
+                       virtual Elm_Interface_Atspi_Accessible *onAccessObjectRequest(
+                                       bool isFlowsTo) { return nullptr; }
+               };
+
+               enum {
+                       UF_LOSE_IMAGE = 1,
+                       UF_LOSE_BG = 2,
+                       UF_BLOCK_CLICKS = 4,
+                       UF_SELECTED = 8
+               };
+
+               struct ItemParams final {
+                       std::string imagePath;
+                       std::string bgImagePath;
+                       int imageWidth;
+                       int imageHeight;
+                       int flags;
+               };
+
+               struct ItemInfo final {
+                       int imageLoadSize;
+                       bool isImageLoadSizeFull;
+                       bool isImageLoaded;
+               };
+
+               class Unrealizer final : ucl::NonCopyable {
+               public:
+                       Unrealizer(ImageGrid &imageGrid);
+                       ~Unrealizer();
+               private:
+                       ImageGrid &m_imageGrid;
+               };
+
+       public:
+               void setListener(const IListenerWRef &listener);
+
+               ucl::Result setItemCount(int count);
+
+               ucl::Result setSelectModeEnabled(bool enabled);
+               bool isInSelectMode() const;
+               bool isInTransition() const;
+
+               void update();
+
+               ucl::Result updateItem(int itemIndex, const ItemParams &params);
+
+               ucl::Result isItemRealized(int itemIndex) const;
+
+               ucl::Result getItemInfo(int itemIndex, ItemInfo &info) const;
+               Elm_Interface_Atspi_Accessible *getAccessObject(bool isFlowsTo);
+
+               int getScrolledToItemIndex() const;
+               ucl::Result scrollToItem(int itemIndex);
+               ucl::Result bringInItem(int itemIndex);
+
+               void activateRotary();
+               void deactivateRotary();
+
+       private:
+               class Slot;
+               using SlotUPtr = std::unique_ptr<Slot>;
+
+               struct Info;
+               struct HcombInfo;
+               struct LinearInfo;
+
+       private:
+               friend class ucl::ReffedObj<ImageGrid>;
+               ImageGrid(ucl::IRefCountObj *rc, Evas_Object *scroller,
+                               Type type, bool selectModeStartup);
+               virtual ~ImageGrid();
+
+               static const Info &getInfo(Type type);
+
+               template <class FUNC>
+               ucl::Result doWithItem(int itemIndex, FUNC &&func) const;
+               template <class FUNC>
+               ucl::Result doWithCell(int itemIndex, FUNC &&func) const;
+
+               template <class SHOW_FUNC>
+               ucl::Result showItem(int itemIndex, SHOW_FUNC &&showFunc);
+
+               bool isItemFullyVisible(int itemIndex);
+               bool isItemFullyVisible(int itemIndex,
+                               int &minVisibleOffset, int &maxVisibleOffset) const;
+               bool isItemFullyVisible(int slotIndex, int itemOffset,
+                               int &minVisibleOffset, int &maxVisibleOffset) const;
+
+               void forceBoxSizeCalculate();
+
+               void addUnrealizeLock();
+               void removeUnrealizeLock();
+
+               void handleItemEvent(int itemIndex,
+                               ItemEvent event, int x, int y) const;
+
+               // Accessibility
+
+               void onItemHighlighted(int itemIndex);
+               void onItemUnhighlighted(int itemIndex);
+               void onKeeperUnhighlighted(Widget &sender, void *eventInfo);
+
+               void updateHighlightTimeout();
+               void onHighlightTimeout(ucl::Timeout *sender);
+
+               Elm_Interface_Atspi_Accessible *requestAtspi(int itemIndex);
+               Elm_Interface_Atspi_Accessible *getItemAtspi(int itemIndex);
+
+               // Selection mode hanling
+               void evalSlotSizes();
+               void finalizeTransition();
+               Eina_Bool onAnimationFrame();
+               void onSlotResize(Widget &widget, void *eventInfo);
+               void onBoxResize(Evas *e, Evas_Object *obj, void *eventInfo);
+               void onTransitonFinished(Evas_Object *obj, const char *emission,
+                               const char *source);
+
+               // Initialization
+               void prepare();
+               void createCircleScroller();
+               void createHighlighKeeper();
+
+               // Actual slots count
+               bool updateSlotCount();
+               int calcSlotCount();
+               void setSlotCount(int newSlotCount);
+
+               // Optimal slots count
+               bool updateOptimalSlotCount();
+               int calcOptimalSlotCount();
+
+               // Maximum slots count
+               bool updateMaxSlotCount();
+               int calcMaxSlotCount();
+
+               // Actual begin slot index
+               bool updateBeginSlotIndex();
+               int calcBeginSlotIndex();
+               void setBeginSlotIndex(int newBeginSlotIndex);
+
+               // Maximum begin slot index
+               bool updateMaxBeginSlotIndex();
+               int calcMaxBeginSlotIndex();
+
+               // Misc
+               void updatePadSizes();
+               void updateScrollBias();
+               void updateRectMins();
+
+               // Slot size
+               bool updateSlotSize();
+               void setSlotSize(int newSlotSize);
+
+               // Scroller size
+               bool updateScrollerSize();
+               int calcScrollerSize();
+
+               // Scroller scroll offset
+               bool updateScrollOffset();
+               int calcScrollOffset();
+
+               // Slots rotations
+               void rotateSlotsRight(int count);
+               void rotateSlotsLeft(int count);
+
+               // Slots realization/unrealization
+               void realizeSlots();
+               void unrealizeSlots(int beginSlotOffset, int endSlotOffset);
+
+               // Event handling
+               void handleScrolling();
+               void handleResize();
+
+               // Events
+               void onScrollerResize(Widget &sender, void *eventInfo);
+               void onScrollerMove(Widget &sender, void *eventInfo);
+               void onBoxMove(Widget &sender, void *eventInfo);
+
+       private:
+               const Info &m_info;
+
+               ucl::StyledWidget *m_scroller;
+               ucl::ElmWidget m_box;
+               ucl::Widget m_rect1;
+               ucl::Widget m_rect2;
+               Evas_Object *m_circleScroller;
+
+               IListenerWRef m_listener;
+               int m_itemCount;
+
+               std::deque<SlotUPtr> m_slots;
+
+               int m_slotCount;
+               int m_optimalSlotCount;
+               int m_maxSlotCount;
+
+               int m_beginSlotIndex;
+               int m_maxBeginSlotIndex;
+
+               int m_scrollBias;
+               int m_padSize1;
+               int m_padSize2;
+
+               int m_slotSize;
+               int m_scrollerSize;
+               int m_scrollOffset;
+
+               int m_unrealizeLock;
+               int m_eventsLock;
+
+               Ecore_Animator *m_animator;
+               int m_scrollLockIndex;
+               bool m_isInSelectMode;
+               bool m_isRotaryActive;
+
+               ucl::ElmWidgetSRef m_highlighKeeper;
+               ucl::TimeoutSRef m_highlightTimeout;
+               int m_highlightID;
+               bool m_isHighlightLocked;
+       };
+}
+
+#endif // __GALLERY_VIEW_IMAGE_GRID_H__
diff --git a/gallery/view/ImageViewer.cpp b/gallery/view/ImageViewer.cpp
new file mode 100644 (file)
index 0000000..da3a0c2
--- /dev/null
@@ -0,0 +1,393 @@
+/*
+ * 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/view/ImageViewer.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr auto ANIMATION_START_TIMEOUT_SEC = (1.0 / 30.0);
+       constexpr auto ANIMATION_RUNTIME_SEC = (300.0 / 1000.0);
+       constexpr auto ANIMATION_STOP_POS = 0.999999;
+}}}
+
+namespace gallery {
+
+       using ucl::LAYOUT_DEFAULT;
+
+       // ImageViewer::Builder //
+
+       ImageViewer::Builder::Builder() :
+               m_loadSize(0),
+               m_forceLoad(false)
+       {
+       }
+
+       ImageViewer::Builder &ImageViewer::Builder::
+                       setHighResImagePath(std::string path)
+       {
+               m_highResPath = std::move(path);
+               return *this;
+       }
+
+       ImageViewer::Builder &ImageViewer::Builder::setLoadSize(const int value)
+       {
+               m_loadSize = value;
+               return *this;
+       }
+
+       ImageViewer::Builder &ImageViewer::Builder::setForceLoad(const bool value)
+       {
+               m_forceLoad = value;
+               return *this;
+       }
+
+       ImageViewerSRef ImageViewer::Builder::build(ElmWidget &parent) const
+       {
+               if (isEmpty(m_highResPath)) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "m_highResPath is empty!");
+               }
+
+               auto scroller = elm_scroller_add(parent);
+               if (!scroller) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "elm_scroller_add() failed!");
+               }
+
+               return makeShared<ImageViewer>(scroller, m_highResPath,
+                               m_loadSize, m_forceLoad);
+       }
+
+       // ImageViewer //
+
+       ImageViewer::ImageViewer(IRefCountObj &rc, Evas_Object *const scroller,
+                       const std::string &highResPath, const int loadSize,
+                       const bool forceLoad) :
+               ElmWidget(&rc, scroller),
+
+               m_scroller(makeShared<StyledWidget>(scroller, false).get()),
+               m_layout(elm_layout_add(*m_scroller)),
+               m_grid(evas_object_grid_add(m_layout.getEvas())),
+               m_lowResImage(evas_object_image_filled_add(m_grid.getEvas())),
+               m_highResImage(evas_object_image_filled_add(m_grid.getEvas())),
+
+               m_imageW(0),
+               m_imageH(0),
+
+               m_scrollerW(0),
+               m_scrollerH(0),
+               m_gridW(0),
+               m_gridH(0),
+               m_scale0(0),
+               m_scale1(0),
+
+               m_xf1(0.5),
+               m_yf1(0.5),
+               m_xf2(0.5),
+               m_yf2(0.5),
+               m_zoom(0.0),
+
+               m_animationStartTimer(nullptr),
+               m_animator(nullptr),
+               m_state(State::ZOOMED_OUT)
+       {
+               prepare(highResPath, loadSize, forceLoad);
+       }
+
+       ImageViewer::~ImageViewer()
+       {
+               if (m_animationStartTimer) {
+                       ecore_timer_del(m_animationStartTimer);
+               }
+               if (m_animator) {
+                       ecore_animator_del(m_animator);
+               }
+       }
+
+       void ImageViewer::prepare(const std::string &highResPath,
+                       const int loadSize, const bool forceLoad)
+       {
+               expandAndFill(*m_scroller);
+               m_scroller->setStyle(SCROLLER_STYLE);
+               elm_scroller_bounce_set(*m_scroller, EINA_TRUE, EINA_TRUE);
+               elm_scroller_policy_set(*m_scroller,
+                               ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+               elm_scroller_single_direction_set(*m_scroller,
+                               ELM_SCROLLER_SINGLE_DIRECTION_NONE);
+               show(*m_scroller);
+
+               expandAndFill(m_layout);
+               m_layout.setTheme(LAYOUT_DEFAULT);
+               m_scroller->setContent(m_layout);
+               show(m_layout);
+
+               evas_object_grid_size_set(m_grid, 1, 1);
+               m_layout.setContent(m_grid);
+               show(m_grid);
+
+               evas_object_image_load_orientation_set(m_lowResImage, EINA_TRUE);
+               evas_object_grid_pack(m_grid, m_lowResImage, 0, 0, 1, 1);
+               if (loadSize > 0) {
+                       evas_object_image_load_size_set(m_lowResImage, loadSize, loadSize);
+               }
+               show(m_lowResImage);
+               makeTransparent(m_lowResImage);
+
+               evas_object_image_load_orientation_set(m_highResImage, EINA_TRUE);
+               evas_object_grid_pack(m_grid, m_highResImage, 0, 0, 1, 1);
+               if (forceLoad) {
+                       if (loadSize > 0) {
+                               evas_object_image_load_size_set(m_highResImage,
+                                               loadSize, loadSize);
+                       }
+                       evas_object_image_file_set(m_highResImage,
+                                       highResPath.c_str(), nullptr);
+                       show(m_highResImage);
+               } else {
+                       hide(m_highResImage);
+                       m_highResImage.addEventHandler(WidgetEvent::IMAGE_PRELOADED,
+                                       WEAK_DELEGATE(ImageViewer::onImagePreloaded,
+                                               asWeak(*this)));
+                       evas_object_image_file_set(m_highResImage,
+                                       highResPath.c_str(), nullptr);
+                       evas_object_image_preload(m_highResImage, EINA_FALSE);
+               }
+
+               evas_object_image_size_get(m_highResImage, &m_imageW, &m_imageH);
+               if ((m_imageW == 0) || (m_imageH == 0)) {
+                       WLOG("Invalid image size!");
+                       m_imageW = 1;
+                       m_imageH = 1;
+               }
+
+               m_scroller->addEventHandler(WidgetEvent::RESIZE,
+                               WEAK_DELEGATE(ImageViewer::onScrollerResize, asWeak(*this)));
+       }
+
+       void ImageViewer::onScrollerResize(Widget &widget, void *eventInfo)
+       {
+               if (updateScrollerSize()) {
+                       updateScales();
+                       updateGridSize();
+                       updateScrollOffset();
+               }
+       }
+
+       bool ImageViewer::updateScrollerSize()
+       {
+               int scrollerW = 0;
+               int scrollerH = 0;
+               getSize(*m_scroller, &scrollerW, &scrollerH);
+
+               if ((scrollerW == 0) || (scrollerH == 0)) {
+                       DLOG("Scroller has 0 size. Skip.");
+                       return false;
+               }
+
+               if ((scrollerW != m_scrollerW) || (scrollerH != m_scrollerH)) {
+                       m_scrollerW = scrollerW;
+                       m_scrollerH = scrollerH;
+                       return true;
+               }
+
+               return false;
+       }
+
+       void ImageViewer::updateScales()
+       {
+               const double sx = (1.0 * m_scrollerW / m_imageW);
+               const double sy = (1.0 * m_scrollerH / m_imageH);
+
+               m_scale0 = ((sx > sy) ? sx : sy);
+               m_scale1 = 1.0;
+       }
+
+       void ImageViewer::updateGridSize()
+       {
+               const double scale = (m_scale0 + m_zoom * (m_scale1 - m_scale0));
+
+               m_gridW = std::lround(scale * m_imageW);
+               m_gridH = std::lround(scale * m_imageH);
+
+               m_grid.setMin(m_gridW, m_gridH);
+               m_grid.setMax(m_gridW, m_gridH);
+
+               m_layout.calculate();
+       }
+
+       void ImageViewer::updateScrollOffset()
+       {
+               const double xf2 = (m_xf2 + m_zoom * (0.5 - m_xf2));
+               const double yf2 = (m_yf2 + m_zoom * (0.5 - m_yf2));
+
+               const int sx = std::lround((m_xf1 * m_gridW) - (xf2 * m_scrollerW));
+               const int sy = std::lround((m_yf1 * m_gridH) - (yf2 * m_scrollerH));
+
+               elm_scroller_region_show(*m_scroller, sx, sy, m_scrollerW, m_scrollerH);
+       }
+
+       void ImageViewer::setLowResImagePath(const std::string &path)
+       {
+               evas_object_image_file_set(m_lowResImage, path.c_str(), nullptr);
+               makeWhite(m_lowResImage);
+       }
+
+       void ImageViewer::onImagePreloaded(Widget &widget, void *eventInfo)
+       {
+               show(widget);
+       }
+
+       bool ImageViewer::zoomIn(const int originX, const int originY)
+       {
+               if (m_state != State::ZOOMED_OUT) {
+                       WLOG("Can't zoom in!");
+                       return false;
+               }
+
+               m_state = State::ZOOMING_IN;
+
+               calcZoomInFactors(originX, originY);
+               startAnimation();
+
+               return true;
+       }
+
+       bool ImageViewer::zoomOut()
+       {
+               if (m_state != State::ZOOMED_IN) {
+                       WLOG("Can't zoom out!");
+                       return false;
+               }
+
+               m_state = State::ZOOMING_OUT;
+
+               calcZoomOutFactors();
+               startAnimation();
+
+               return true;
+       }
+
+       bool ImageViewer::isZooming() const
+       {
+               return ((m_state == State::ZOOMING_IN) ||
+                               (m_state == State::ZOOMING_OUT));
+       }
+
+       bool ImageViewer::isZoomedIn() const
+       {
+               return (m_state == State::ZOOMED_IN);
+       }
+
+       bool ImageViewer::isZoomedOut() const
+       {
+               return (m_state == State::ZOOMED_OUT);
+       }
+
+       void ImageViewer::calcZoomInFactors(const int originX, const int originY)
+       {
+               if (m_scale0 > m_scale1) {
+                       m_xf1 = 0.5;
+                       m_yf1 = 0.5;
+                       m_xf2 = 0.5;
+                       m_yf2 = 0.5;
+                       return;
+               }
+
+               int x = 0;
+               int y = 0;
+               getPosition(*m_scroller, &x, &y);
+
+               const int newOriginX = (originX - x);
+               const int newOriginY = (originY - x);
+
+               int sx = 0;
+               int sy = 0;
+               elm_scroller_region_get(*m_scroller, &sx, &sy, nullptr, nullptr);
+
+               m_xf1 = (1.0 * (sx + newOriginX) / m_gridW);
+               m_yf1 = (1.0 * (sy + newOriginY) / m_gridH);
+               m_xf2 = (1.0 * newOriginX / m_scrollerW);
+               m_yf2 = (1.0 * newOriginY / m_scrollerH);
+       }
+
+       void ImageViewer::calcZoomOutFactors()
+       {
+               int sx = 0;
+               int sy = 0;
+               elm_scroller_region_get(*m_scroller, &sx, &sy, nullptr, nullptr);
+
+               if (m_gridW < m_scrollerW) {
+                       sx = (0.5 * (m_gridW - m_scrollerW));
+               }
+               if (m_gridH < m_scrollerH) {
+                       sy = (0.5 * (m_gridH - m_scrollerH));
+               }
+
+               m_xf1 = ((sx + 0.5 * m_scrollerW) / m_gridW);
+               m_yf1 = ((sy + 0.5 * m_scrollerH) / m_gridH);
+               m_xf2 = (m_scale0 * m_imageW * (m_xf1 - 0.5) / m_scrollerW + 0.5);
+               m_yf2 = (m_scale0 * m_imageH * (m_yf1 - 0.5) / m_scrollerH + 0.5);
+       }
+
+       void ImageViewer::startAnimation()
+       {
+               if (m_animationStartTimer) {
+                       WLOG("Timer is running!");
+                       ecore_timer_del(m_animationStartTimer);
+               }
+
+               m_animationStartTimer = ecore_timer_add(
+                               impl::ANIMATION_START_TIMEOUT_SEC,
+                               CALLBACK_A(ImageViewer::onAnimationStartTimer), this);
+       }
+
+       Eina_Bool ImageViewer::onAnimationStartTimer()
+       {
+               m_animationStartTimer = nullptr;
+
+               if (m_animator) {
+                       WLOG("Animator is running!");
+                       ecore_animator_del(m_animator);
+               }
+               m_animator = ecore_animator_timeline_add(
+                               impl::ANIMATION_RUNTIME_SEC,
+                               CALLBACK_A(ImageViewer::onAnimationFrame), this);
+
+               return ECORE_CALLBACK_CANCEL;
+       }
+
+       Eina_Bool ImageViewer::onAnimationFrame(const double pos)
+       {
+               const double t = ecore_animator_pos_map(
+                               pos, ECORE_POS_MAP_DECELERATE, 0.0, 0.0);
+
+               m_zoom = ((m_state == State::ZOOMING_IN) ? t : (1.0 - t));
+
+               updateGridSize();
+               updateScrollOffset();
+
+               if (pos >= impl::ANIMATION_STOP_POS) {
+                       m_animator = nullptr;
+                       m_state = ((m_state == State::ZOOMING_IN) ?
+                                       State::ZOOMED_IN : State::ZOOMED_OUT);
+                       callEvent(IMAGE_VIEWER_ZOOM_END, nullptr);
+                       return ECORE_CALLBACK_CANCEL;
+               }
+
+               return ECORE_CALLBACK_RENEW;
+       }
+}
diff --git a/gallery/view/ImageViewer.h b/gallery/view/ImageViewer.h
new file mode 100644 (file)
index 0000000..409b010
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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_VIEW_IMAGE_VIEWER_H__
+#define __GALLERY_VIEW_IMAGE_VIEWER_H__
+
+#include "ucl/gui/StyledWidget.h"
+#include "ucl/gui/Layout.h"
+
+#include "types.h"
+
+namespace gallery {
+
+       constexpr ucl::SmartEvent IMAGE_VIEWER_ZOOM_END {"gallery,zoom,end"};
+
+       UCL_DECLARE_REF_ALIASES(ImageViewer);
+
+       class ImageViewer final : public ucl::ElmWidget {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setHighResImagePath(std::string path);
+                       Builder &setLoadSize(int value);
+                       Builder &setForceLoad(bool value);
+                       ImageViewerSRef build(ucl::ElmWidget &parent) const;
+               private:
+                       std::string m_highResPath;
+                       int m_loadSize;
+                       bool m_forceLoad;
+               };
+
+       public:
+               void setLowResImagePath(const std::string &path);
+               bool zoomIn(int originX, int originY);
+               bool zoomOut();
+
+               bool isZooming() const;
+               bool isZoomedIn() const;
+               bool isZoomedOut() const;
+
+       private:
+               friend class ucl::ReffedObj<ImageViewer>;
+               ImageViewer(ucl::IRefCountObj &rc, Evas_Object *scroller,
+                               const std::string &highResPath, int loadSize, bool forceLoad);
+               virtual ~ImageViewer();
+
+               void prepare(const std::string &highResPath,
+                               int loadSize, bool forceLoad);
+
+               void onImagePreloaded(ucl::Widget &widget, void *eventInfo);
+               void onScrollerResize(ucl::Widget &widget, void *eventInfo);
+
+               bool updateScrollerSize();
+               void updateScales();
+               void updateGridSize();
+               void updateScrollOffset();
+
+               void calcZoomInFactors(int originX, int originY);
+               void calcZoomOutFactors();
+               void startAnimation();
+
+               Eina_Bool onAnimationStartTimer();
+               Eina_Bool onAnimationFrame(double pos);
+
+       private:
+               enum class State {
+                       ZOOMED_OUT,
+                       ZOOMED_IN,
+                       ZOOMING_OUT,
+                       ZOOMING_IN
+               };
+
+       private:
+               ucl::StyledWidget *m_scroller;
+               ucl::Layout m_layout;
+               ucl::Widget m_grid;
+               ucl::Widget m_lowResImage;
+               ucl::Widget m_highResImage;
+
+               int m_imageW;
+               int m_imageH;
+
+               int m_scrollerW;
+               int m_scrollerH;
+               int m_gridW;
+               int m_gridH;
+               double m_scale0;
+               double m_scale1;
+
+               double m_xf1;
+               double m_yf1;
+               double m_xf2;
+               double m_yf2;
+               double m_zoom;
+
+               Ecore_Timer *m_animationStartTimer;
+               Ecore_Animator *m_animator;
+               State m_state;
+       };
+}
+
+#endif // __GALLERY_VIEW_IMAGE_VIEWER_H__
diff --git a/gallery/view/PageContent.cpp b/gallery/view/PageContent.cpp
new file mode 100644 (file)
index 0000000..40966ba
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * 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 "PageContent.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr LayoutTheme LAYOUT_MORE_OPTIONS
+                       {"layout", "gallery", "more_options"};
+
+       constexpr LayoutTheme LAYOUT_SELECT_MODE
+                       {"layout", "select_mode", "default"};
+
+       constexpr LayoutTheme LAYOUT_BOTTOM_BUTTON
+                       {"layout", "bottom_button", "default"};
+
+       constexpr EdjePart PART_MORE_OPTIONS {"gallery.swallow.more_options"};
+       constexpr EdjePart PART_OVERLAY {"gallery.swallow.overlay"};
+
+       constexpr EdjeSignal SIGNAL_SHOW_SELECT_BUTTON {"select_mode,button,show"};
+       constexpr EdjeSignal SIGNAL_HIDE_SELECT_BUTTON {"select_mode,button,hide"};
+
+       constexpr EdjeSignal SIGNAL_SHOW_MORE_OPTIONS {"cue,show"};
+       constexpr EdjeSignal SIGNAL_HIDE_MORE_OPTIONS {"cue,hide"};
+       constexpr EdjeSignalSrc SIGNAL_SRC_EXT {"ext"};
+
+       template <class OBJ, class FUNC, class ...ARGS>
+       Result callSafe(OBJ *obj, FUNC &&func, ARGS &&...args)
+       {
+               if (!obj) {
+                       FAIL_RETURN(RES_FAIL, "obj is NULL!");
+               }
+               func(*obj, std::forward<ARGS>(args)...);
+               return RES_OK;
+       }
+}}}
+
+namespace gallery {
+
+       using ucl::Layout;
+       using ucl::LayoutSRef;
+
+       using ucl::PART_BUTTON;
+       using ucl::PART_CONTENT;
+       using ucl::PART_ICON;
+
+       // PageContent::Builder //
+
+       PageContent::Builder::Builder() :
+               m_flags(0)
+       {
+       }
+
+       PageContent::Builder &PageContent::Builder::setFlags(const int flags)
+       {
+               m_flags = flags;
+               return *this;
+       }
+
+       PageContentSRef PageContent::Builder::build(ElmWidget &parent) const
+       {
+               auto layout = Layout::Builder().
+                               setTheme(impl::LAYOUT_MORE_OPTIONS).
+                               build(parent);
+               if (!layout) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+               }
+
+               auto result = makeShared<PageContent>(layout, m_flags);
+
+               result->bindToEo();
+
+               return result;
+       }
+
+       // PageContent //
+
+       PageContent::PageContent(IRefCountObj &rc,
+                       const LayoutSRef &layout, const int flags) :
+               ElmWidget(&rc, *layout),
+               m_mainLayout(layout.get())
+       {
+               prepare(flags);
+       }
+
+       PageContent::~PageContent()
+       {
+       }
+
+       void PageContent::prepare(const int flags)
+       {
+               m_mainLayout->setIsOwner(false);
+
+               Layout *parent = m_mainLayout;
+
+               if (flags & FLAG_SELECT_BUTTON) {
+                       m_selectMode = Layout::Builder().
+                               setTheme(impl::LAYOUT_SELECT_MODE).
+                               build(*parent);
+                       if (m_selectMode) {
+                               parent->setContent(*m_selectMode);
+                               parent = m_selectMode.get();
+                       }
+               }
+
+               if (flags & FLAG_BOTTOM_BUTTON) {
+                       m_bottomButton = Layout::Builder().
+                               setTheme(impl::LAYOUT_BOTTOM_BUTTON).
+                               build(*parent);
+                       if (m_bottomButton) {
+                               parent->setContent(*m_bottomButton);
+                               parent = m_bottomButton.get();
+                       }
+               }
+       }
+
+       Result PageContent::set(Evas_Object *const eo, const Part part)
+       {
+               return doWithPart(part,
+                       [eo](Layout &layout, const EdjePart part)
+                       {
+                               layout.setContent(eo, part);
+                       });
+       }
+
+       Evas_Object *PageContent::unset(const Part part)
+       {
+               Evas_Object *result = {};
+               doWithPart(part,
+                       [&result](Layout &layout, const EdjePart part)
+                       {
+                               result = layout.unsetContent(part);
+                       });
+               return result;
+       }
+
+       Evas_Object *PageContent::get(const Part part) const
+       {
+               Evas_Object *result = {};
+               doWithPart(part,
+                       [&result](Layout &layout, const EdjePart part)
+                       {
+                               result = layout.getContent(part);
+                       });
+               return result;
+       }
+
+       Result PageContent::setSelectButtonVisible(const bool visible)
+       {
+               if (!m_selectMode) {
+                       LOG_RETURN(RES_FAIL, "Select button is not supported!");
+               }
+               m_selectMode->emit(visible ? impl::SIGNAL_SHOW_SELECT_BUTTON :
+                               impl::SIGNAL_HIDE_SELECT_BUTTON);
+               return RES_OK;
+       }
+
+       Result PageContent::setMoreOptionsVisible(const bool visible)
+       {
+               const auto content = m_mainLayout->getContent(impl::PART_MORE_OPTIONS);
+               if (!content) {
+                       LOG_RETURN(RES_FAIL, "More option is not created!");
+               }
+               elm_layout_signal_emit(content, (visible ?
+                               impl::SIGNAL_SHOW_MORE_OPTIONS :
+                               impl::SIGNAL_HIDE_MORE_OPTIONS),
+                               impl::SIGNAL_SRC_EXT);
+               return RES_OK;
+       }
+
+       template <class FUNC>
+       Result PageContent::doWithPart(const Part part, FUNC &&func) const
+       {
+               switch (part) {
+               case Part::DEFAULT:
+                       return impl::callSafe(getTopLayout(), func, PART_CONTENT);
+               case Part::OVERLAY:
+                       func(*m_mainLayout, impl::PART_OVERLAY);
+                       return RES_OK;
+               case Part::MORE_OPTIONS:
+                       func(*m_mainLayout, impl::PART_MORE_OPTIONS);
+                       return RES_OK;
+               case Part::SELECT_BUTTON:
+                       return impl::callSafe(m_selectMode.get(), func, PART_ICON);
+               case Part::BOTTOM_BUTTON:
+                       return impl::callSafe(m_bottomButton.get(), func, PART_BUTTON);
+               }
+               LOG_RETURN(RES_FATAL, "Should not be here!");
+       }
+
+       Layout *PageContent::getTopLayout() const
+       {
+               if (m_bottomButton) {
+                       return m_bottomButton.get();
+               }
+               if (m_selectMode) {
+                       return m_selectMode.get();
+               }
+               return m_mainLayout;
+       }
+}
diff --git a/gallery/view/PageContent.h b/gallery/view/PageContent.h
new file mode 100644 (file)
index 0000000..85a6c59
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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_VIEW_PAGE_CONTENT_H__
+#define __GALLERY_VIEW_PAGE_CONTENT_H__
+
+#include "ucl/gui/Layout.h"
+
+#include "types.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(PageContent);
+
+       class PageContent final : public ucl::ElmWidget {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setFlags(int flags);
+                       PageContentSRef build(ucl::ElmWidget &parent) const;
+               private:
+                       int m_flags;
+               };
+
+               enum {
+                       FLAG_MORE_OPTIONS = 1,
+                       FLAG_SELECT_BUTTON = 2,
+                       FLAG_BOTTOM_BUTTON = 4,
+
+                       FLAGS_SELECT_MODE = (FLAG_SELECT_BUTTON | FLAG_BOTTOM_BUTTON),
+                       FLAGS_ALL = (FLAG_MORE_OPTIONS | FLAGS_SELECT_MODE)
+               };
+
+               enum class Part {
+                       DEFAULT,
+                       OVERLAY,
+                       MORE_OPTIONS,
+                       SELECT_BUTTON,
+                       BOTTOM_BUTTON
+               };
+
+       public:
+               ucl::Result set(Evas_Object *eo, Part part = Part::DEFAULT);
+               Evas_Object *unset(Part part = Part::DEFAULT);
+
+               Evas_Object *get(Part part = Part::DEFAULT) const;
+
+               ucl::Result setSelectButtonVisible(bool visible);
+               ucl::Result setMoreOptionsVisible(bool visible);
+
+       private:
+               friend class ucl::ReffedObj<PageContent>;
+               PageContent(ucl::IRefCountObj &rc,
+                               const ucl::LayoutSRef &layout, int flags);
+               virtual ~PageContent();
+
+               void prepare(int flags);
+
+               template <class FUNC>
+               ucl::Result doWithPart(Part part, FUNC &&func) const;
+
+               ucl::Layout *getTopLayout() const;
+
+       private:
+               ucl::Layout *m_mainLayout;
+               ucl::LayoutSRef m_selectMode;
+               ucl::LayoutSRef m_bottomButton;
+       };
+}
+
+#endif // __GALLERY_VIEW_PAGE_CONTENT_H__
diff --git a/gallery/view/TouchParser.cpp b/gallery/view/TouchParser.cpp
new file mode 100644 (file)
index 0000000..ef8a153
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * 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 "TouchParser.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr auto TAP_MOVE_THRESHOLD = 30;
+       constexpr auto FAST_TAP_DISTANCE = 60;
+       constexpr auto FAST_TAP_DELAY_MS = 300;
+       constexpr auto TAP_AND_HOLD_DELAY_SEC = (500.0 / 1000.0);
+}}}
+
+namespace gallery {
+
+       TouchParser::TouchParser(IRefCountObj &rc, Widget &eventSource) :
+               RefCountAware(&rc),
+               m_holdTimer(nullptr),
+               m_downTime(0),
+               m_downX(0),
+               m_downY(0),
+               m_tapCounter(0),
+               m_isMouseDown(false),
+               m_isTapPossible(false)
+       {
+               eventSource.addEventHandler(WidgetEvent::MOUSE_DOWN,
+                               WEAK_DELEGATE(TouchParser::onMouseDown, asWeak(*this)));
+
+               eventSource.addEventHandler(WidgetEvent::MOUSE_UP,
+                               WEAK_DELEGATE(TouchParser::onMouseUp, asWeak(*this)));
+
+               eventSource.addEventHandler(WidgetEvent::MOUSE_MOVE,
+                               WEAK_DELEGATE(TouchParser::onMouseMove, asWeak(*this)));
+       }
+
+       TouchParser::~TouchParser()
+       {
+               stopHoldTimer();
+       }
+
+       void TouchParser::setTapHandler(const TapHandler &handler)
+       {
+               m_tapHandler = handler;
+       }
+
+       void TouchParser::setDoubleTapHandler(const TapHandler &handler)
+       {
+               m_doubleTapHandler = handler;
+       }
+
+       void TouchParser::setTapAndHoldHandler(const TapHandler &handler)
+       {
+               m_tapAndHoldHandler = handler;
+       }
+
+       void TouchParser::onMouseDown(Widget &widget, void *eventInfo)
+       {
+               if (m_isMouseDown) {
+                       return;
+               }
+               m_isMouseDown = true;
+
+               const auto e = static_cast<Evas_Event_Mouse_Down *>(eventInfo);
+
+               if (!isFastTap(e->timestamp, e->canvas.x, e->canvas.y)) {
+                       m_tapCounter = 0;
+                       restartHoldTimer();
+               } else if (m_doubleTapHandler && (m_tapCounter == 1)) {
+                       m_doubleTapHandler(m_downX, m_downY);
+               }
+
+               m_downTime = e->timestamp;
+               m_downX = e->canvas.x;
+               m_downY = e->canvas.y;
+               m_isTapPossible = true;
+       }
+
+       void TouchParser::onMouseUp(Widget &widget, void *eventInfo)
+       {
+               if (!m_isMouseDown) {
+                       return;
+               }
+               m_isMouseDown = false;
+
+               const auto e = static_cast<Evas_Event_Mouse_Up *>(eventInfo);
+
+               stopHoldTimer();
+               updateIsTapPossible(e->event_flags, e->canvas.x, e->canvas.y);
+
+               if (!m_isTapPossible) {
+                       m_tapCounter = 0;
+                       return;
+               }
+
+               ++m_tapCounter;
+
+               if (m_tapHandler) {
+                       m_tapHandler(e->canvas.x, e->canvas.y);
+               }
+       }
+
+       void TouchParser::onMouseMove(Widget &widget, void *eventInfo)
+       {
+               if (!m_isMouseDown || !m_isTapPossible) {
+                       return;
+               }
+
+               const auto e = static_cast<Evas_Event_Mouse_Move *>(eventInfo);
+
+               updateIsTapPossible(e->event_flags, e->cur.canvas.x, e->cur.canvas.y);
+
+               if (!m_isTapPossible) {
+                       stopHoldTimer();
+               }
+       }
+
+       void TouchParser::updateIsTapPossible(const int flags,
+                       const int curX, const int curY)
+       {
+               if (!m_isTapPossible) {
+                       return;
+               }
+               if ((flags & EVAS_EVENT_FLAG_ON_HOLD) || (calcDownDistance(curX, curY) >
+                               ELM_SCALE_SIZE(impl::TAP_MOVE_THRESHOLD))) {
+                       m_isTapPossible = false;
+               }
+       }
+
+       bool TouchParser::isFastTap(const UInt curTime,
+                       const int curX, const int curY) const
+       {
+               return (((curTime - m_downTime) <= impl::FAST_TAP_DELAY_MS) &&
+                               (calcDownDistance(curX, curY) <=
+                                               ELM_SCALE_SIZE(impl::FAST_TAP_DISTANCE)));
+       }
+
+       double TouchParser::calcDownDistance(int curX, int curY) const
+       {
+               const auto dx = (curX - m_downX);
+               const auto dy = (curY - m_downY);
+
+               return sqrt(1.0 * dx * dx + 1.0 * dy * dy);
+       }
+
+       void TouchParser::restartHoldTimer()
+       {
+               stopHoldTimer();
+               m_holdTimer = ecore_timer_add(impl::TAP_AND_HOLD_DELAY_SEC,
+                               CALLBACK_A(TouchParser::onHoldTimer), this);
+       }
+
+       void TouchParser::stopHoldTimer()
+       {
+               if (m_holdTimer) {
+                       ecore_timer_del(m_holdTimer);
+                       m_holdTimer = nullptr;
+               }
+       }
+
+       Eina_Bool TouchParser::onHoldTimer()
+       {
+               m_holdTimer = nullptr;
+               if (m_tapAndHoldHandler) {
+                       m_tapAndHoldHandler(m_downX, m_downY);
+               }
+               return ECORE_CALLBACK_CANCEL;
+       }
+}
diff --git a/gallery/view/TouchParser.h b/gallery/view/TouchParser.h
new file mode 100644 (file)
index 0000000..be391a3
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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_VIEW_TOUCH_PARSER_H__
+#define __GALLERY_VIEW_TOUCH_PARSER_H__
+
+#include "ucl/gui/Widget.h"
+
+#include "types.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(TouchParser);
+
+       class TouchParser final : public ucl::RefCountAware {
+       public:
+               using TapHandler = ucl::WeakDelegate<void(int x, int y)>;
+
+       private:
+               friend class ucl::ReffedObj<TouchParser>;
+               TouchParser(ucl::IRefCountObj &rc, ucl::Widget &eventSource);
+               virtual ~TouchParser();
+
+       public:
+               void setTapHandler(const TapHandler &handler);
+               void setDoubleTapHandler(const TapHandler &handler);
+               void setTapAndHoldHandler(const TapHandler &handler);
+
+       private:
+               void onMouseDown(ucl::Widget &widget, void *eventInfo);
+               void onMouseUp(ucl::Widget &widget, void *eventInfo);
+               void onMouseMove(ucl::Widget &widget, void *eventInfo);
+
+               void updateIsTapPossible(int flags, int curX, int curY);
+
+               bool isFastTap(ucl::UInt curTime, int curX, int curY) const;
+               double calcDownDistance(int curX, int curY) const;
+
+               void restartHoldTimer();
+               void stopHoldTimer();
+               Eina_Bool onHoldTimer();
+
+       private:
+               TapHandler m_tapHandler;
+               TapHandler m_doubleTapHandler;
+               TapHandler m_tapAndHoldHandler;
+               Ecore_Timer *m_holdTimer;
+               ucl::UInt m_downTime;
+               int m_downX;
+               int m_downY;
+               int m_tapCounter;
+               bool m_isMouseDown;
+               bool m_isTapPossible;
+       };
+}
+
+#endif // __GALLERY_VIEW_TOUCH_PARSER_H__
diff --git a/gallery/view/common.h b/gallery/view/common.h
new file mode 100644 (file)
index 0000000..1cc35a3
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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_VIEW_COMMON_H__
+#define __GALLERY_VIEW_COMMON_H__
+
+#include "ucl/gui/StyledWidget.h"
+#include "ucl/gui/stdTheme.h"
+#include "ucl/gui/helpers.h"
+
+#include "helpers.h"
+
+#include "gallery/common.h"
+
+namespace gallery {
+
+       using ucl::EdjePart;
+       using ucl::EdjeDataKey;
+       using ucl::EdjeSignal;
+       using ucl::EdjeSignalSrc;
+       using ucl::ElmStyle;
+       using ucl::SmartEvent;
+       using ucl::EoDataKey;
+       using ucl::LayoutTheme;
+       using ucl::WidgetEvent;
+       using ucl::WidgetARHint;
+
+       using ucl::TString;
+
+       UCL_USING_REF_ALIASES(ucl::Widget);
+       UCL_USING_REF_ALIASES(ucl::ElmWidget);
+       UCL_USING_REF_ALIASES(ucl::EdjeWidget);
+       UCL_USING_REF_ALIASES(ucl::StyledWidget);
+
+       constexpr ucl::SmartEvent BTN_CLICKED {"clicked"};
+       constexpr ucl::SmartEvent POPUP_DISMISSED {"dismissed"};
+
+       constexpr ucl::SmartEvent ATSPI_HIGHLIGHTED {"atspi,highlighted"};
+       constexpr ucl::SmartEvent ATSPI_UNHIGHLIGHTED {"atspi,unhighlighted"};
+
+       constexpr ucl::ElmStyle SCROLLER_STYLE {"effect"};
+
+       constexpr ucl::ElmStyle NAVIFRAME_NO_CLIP {"gallery_no_clip"};
+}
+
+#endif // __GALLERY_VIEW_COMMON_H__
diff --git a/gallery/view/helpers.cpp b/gallery/view/helpers.cpp
new file mode 100644 (file)
index 0000000..6388200
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * 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 "helpers.h"
+
+#include <vector>
+
+#include "ucl/gui/Window.h"
+#include "ucl/gui/Layout.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       constexpr EoDataKey CIRCLE_SURFACE {"gallery,eext,circle,surface"};
+
+       constexpr LayoutTheme LAYOUT_FAKE_ACCESS_OBJECT
+                       {"layout", "gallery", "fake_access_object"};
+}}}
+
+namespace gallery { namespace util {
+
+       using ucl::Layout;
+       using ucl::Naviframe;
+
+       Result createCircleSurface(Naviframe &navi)
+       {
+               const auto win = navi.getWindow();
+               if (!win) {
+                       LOG_RETURN(RES_FAIL, "Failed to get Window from Naviframe!");
+               }
+
+               if (win->getData(impl::CIRCLE_SURFACE)) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Circle Surface data already set!");
+               }
+
+               const auto sfc = eext_circle_surface_naviframe_add(navi);
+               if (!sfc) {
+                       LOG_RETURN(RES_FAIL,
+                                       "eext_circle_surface_conformant_add() failed!");
+               }
+
+               win->setData(impl::CIRCLE_SURFACE, sfc);
+
+               return RES_OK;
+       }
+
+       Eext_Circle_Surface *getCircleSurface(const ElmWidget &widget)
+       {
+               const auto win = widget.getWindow();
+               if (!win) {
+                       LOG_RETURN_VALUE(RES_FAIL, nullptr,
+                                       "Failed to get Window from widget!");
+               }
+
+               const auto sfc = static_cast<Eext_Circle_Surface *>(
+                               win->getData(impl::CIRCLE_SURFACE));
+               if (!sfc) {
+                       LOG_RETURN_VALUE(RES_FAIL, nullptr,
+                                       "Failed to get Eext_Circle_Surface from window!");
+               }
+
+               return sfc;
+       }
+
+       ElmWidgetSRef createFakeAccessObject(ElmWidget &parent)
+       {
+               const auto result = Layout::Builder().
+                               setTheme(impl::LAYOUT_FAKE_ACCESS_OBJECT).
+                               setNeedBindToEo(true).
+                               build(parent);
+               if (!result) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+               }
+
+               result->setGeometry(0, 0, 1, 1);
+               show(*result);
+
+               elm_atspi_accessible_reading_info_type_set(*result, 0);
+
+               elm_atspi_accessible_gesture_cb_set(*result,
+                       [](void *, Elm_Atspi_Gesture_Info, Evas_Object *) -> Eina_Bool
+                       {
+                               return EINA_TRUE;
+                       },
+                       nullptr);
+
+               return result;
+       }
+}}
+
+namespace gallery {
+
+       void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
+       {
+               eext_rotary_event_handler_add(func, data);
+       }
+
+       void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
+       {
+               std::vector<void *> backup;
+               while (true) {
+                       void *const oldData = eext_rotary_event_handler_del(func);
+                       if (!oldData || (oldData == data)) {
+                               break;
+                       }
+                       backup.push_back(oldData);
+               }
+               for (auto i = backup.size(); i-- > 0; ) {
+                       eext_rotary_event_handler_add(func, backup[i]);
+               }
+       }
+
+       LayoutTheme getImageTheme(const char *const fileName)
+       {
+               return {"layout", "gallery_image", fileName};
+       }
+
+       Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo)
+       {
+               switch (gestureInfo.type) {
+               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_RIGHT:
+               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_DOWN:
+                       return ELM_ATSPI_RELATION_FLOWS_TO;
+               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_LEFT:
+               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_UP:
+                       return ELM_ATSPI_RELATION_FLOWS_FROM;
+               default:
+                       break;
+               }
+               return ELM_ATSPI_RELATION_NULL;
+       }
+}
diff --git a/gallery/view/helpers.h b/gallery/view/helpers.h
new file mode 100644 (file)
index 0000000..5a13ab4
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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_VIEW_HELPERS_H__
+#define __GALLERY_VIEW_HELPERS_H__
+
+#include "ucl/gui/Naviframe.h"
+
+#include "types.h"
+
+namespace gallery { namespace util {
+
+       ucl::Result createCircleSurface(ucl::Naviframe &navi);
+       Eext_Circle_Surface *getCircleSurface(const ucl::ElmWidget &widget);
+
+       ucl::ElmWidgetSRef createFakeAccessObject(ucl::ElmWidget &parent);
+}}
+
+namespace gallery {
+
+       void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
+       void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
+
+       ucl::LayoutTheme getImageTheme(const char *fileName);
+
+       Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo);
+}
+
+#endif // __GALLERY_VIEW_HELPERS_H__
diff --git a/gallery/view/types.h b/gallery/view/types.h
new file mode 100644 (file)
index 0000000..35b0594
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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_VIEW_TYPES_H__
+#define __GALLERY_VIEW_TYPES_H__
+
+#include <efl_extension.h>
+
+#include "ucl/gui/types.h"
+
+#include "gallery/types.h"
+
+#endif // __GALLERY_VIEW_TYPES_H__
diff --git a/inc/gallery/config.h b/inc/gallery/config.h
deleted file mode 100644 (file)
index debdc9a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_CONFIG_H__
-#define __GALLERY_CONFIG_H__
-
-#define GALLERY_LOG_TAG "GALLERY"
-
-namespace gallery {
-
-       constexpr auto WINDOW_NAME = "org.tizen.gallery";
-
-       constexpr auto BASE_SCALE = 1.3;
-
-       // TODO Temporary feature while support only offline mode
-       constexpr auto SCAN_MEDIA_ON_RESUME = false;
-}
-
-#endif // __GALLERY_CONFIG_H__
diff --git a/inc/gallery/model/Gallery.h b/inc/gallery/model/Gallery.h
deleted file mode 100644 (file)
index e17b1f5..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_GALLERY_H__
-#define __GALLERY_MODEL_GALLERY_H__
-
-#include "IMediaAlbum.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(Gallery);
-
-       class Gallery final : public ucl::NonCopyable {
-       public:
-               static GallerySRef newInstance();
-               ~Gallery();
-
-               IMediaAlbumSRef getAlbum();
-
-       private:
-               friend class ucl::ReffedObj<Gallery>;
-               Gallery();
-
-               ucl::Result prepare();
-
-       private:
-               IMediaAlbumSRef m_album;
-               bool m_isMediaDbConnected;
-       };
-}
-
-#endif // __GALLERY_MODEL_GALLERY_H__
diff --git a/inc/gallery/model/IJob.h b/inc/gallery/model/IJob.h
deleted file mode 100644 (file)
index 8c7d56e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_I_JOB_H__
-#define __GALLERY_MODEL_I_JOB_H__
-
-#include "types.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(IJob);
-
-       class IJob : public ucl::Polymorphic {
-       public:
-               virtual ucl::Result getResult() const = 0;
-               virtual bool isCancelable() const = 0;
-               virtual ucl::Result cancel() = 0;
-       };
-}
-
-#endif // __GALLERY_MODEL_I_JOB_H__
diff --git a/inc/gallery/model/IMediaAlbum.h b/inc/gallery/model/IMediaAlbum.h
deleted file mode 100644 (file)
index 80eb222..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_I_MEDIA_ALBUM_H__
-#define __GALLERY_MODEL_I_MEDIA_ALBUM_H__
-
-#include "MediaItem.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(IMediaAlbum);
-
-       class IMediaAlbum : public ucl::Polymorphic {
-       public:
-               using EachCb = ucl::Delegate<bool(MediaItemSRef &&media)>;
-
-       public:
-               virtual void addChangeHandler(const NotiHandler &handler) = 0;
-               virtual void delChangeHandler(const NotiHandler &handler) = 0;
-
-               virtual ucl::Result forEachMedia(EachCb cb) const = 0;
-               virtual ucl::Result getMediaCount(int &count) const = 0;
-
-               virtual void defragment() = 0;
-       };
-
-       // Non-member functions //
-
-       bool isEmpty(const IMediaAlbum &album);
-}
-
-#include "IMediaAlbum.hpp"
-
-#endif // __GALLERY_MODEL_I_MEDIA_ALBUM_H__
diff --git a/inc/gallery/model/IMediaAlbum.hpp b/inc/gallery/model/IMediaAlbum.hpp
deleted file mode 100644 (file)
index 5793dfc..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/logging.h"
-
-namespace gallery {
-
-       // Non-member functions //
-
-       inline bool isEmpty(const IMediaAlbum &album)
-       {
-               int count = 0;
-               UCL_FAIL_RETURN_VALUE(album.getMediaCount(count), true,
-                               "album.getMediaCount() failed!");
-               return (count == 0);
-       }
-}
diff --git a/inc/gallery/model/MediaItem.h b/inc/gallery/model/MediaItem.h
deleted file mode 100644 (file)
index 98491b1..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_MEDIA_ITEM_H__
-#define __GALLERY_MODEL_MEDIA_ITEM_H__
-
-#include <vector>
-
-#include <media_content.h>
-
-#include "ucl/misc/AutoHandle.h"
-
-#include "IJob.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(MediaItem);
-
-       using MediaItems = std::vector<MediaItemSRef>;
-
-       class MediaItem : public ucl::Polymorphic {
-       public:
-               using ThumbnailPathGetCb =
-                               ucl::WeakDelegate<void(ucl::Result, const std::string &path)>;
-
-               class Remover;
-               class RemoverBuilder final {
-               public:
-                       RemoverBuilder &setItems(MediaItems items);
-                       IJobSRef build(const NotiHandler &onComplete) const;
-               private:
-                       ucl::SharedRef<MediaItems> m_items;
-               };
-
-               class Saver;
-               class SaverBuilder final {
-               public:
-                       SaverBuilder &setItem(const MediaItemSRef &item);
-                       IJobSRef build(const NotiHandler &onComplete) const;
-               private:
-                       MediaItemSRef m_item;
-               };
-
-               enum {
-                       FLAG_THUMBNAIL = 1,
-                       FLAG_REMOVE = 2,
-                       FLAG_SAVE = 4,
-                       FLAG_RESOLUTION = 8,
-
-                       FLAGS_FROM_MEDIA_DB = (FLAG_THUMBNAIL | FLAG_REMOVE |
-                                       FLAG_RESOLUTION),
-                       FLAGS_SIMPLE_FILE = (FLAG_SAVE)
-               };
-
-       public:
-               static MediaItemSRef newInstance(media_info_h media);
-               static MediaItemSRef newInstance(std::string filePath);
-               virtual ~MediaItem();
-
-               bool isValid() const;
-               int getFlags() const;
-               MediaType getType() const;
-
-               const std::string &getId() const;
-
-               ucl::Result getResolution(int &x, int &y) const;
-
-               const std::string &getFilePath() const;
-
-               ucl::Result getThumbnailPath(const ThumbnailPathGetCb &cb) const;
-               void cancelThumbnailPathGet() const;
-
-               ucl::Result removeFile();
-               ucl::Result saveToDevice();
-
-       protected:
-               friend class ucl::ReffedObj<MediaItem>;
-               MediaItem(int flags, MediaType type);
-
-               ucl::Result prepare(media_info_h media);
-               ucl::Result prepareImage(media_info_h media);
-               ucl::Result prepare(std::string filePath);
-
-       private:
-               ucl::Result initThumbPath(media_info_h media) const;
-
-       private:
-               // XXX This proxy is needed to deal with cases when
-               // media_thumbnail_completed_cb can't be cancelled
-               struct ThumbCbProxy final {
-                       const MediaItem *item;
-                       ThumbnailPathGetCb callback;
-
-                       void completeCb(media_content_error_e error, const char *path);
-               };
-
-       private:
-               using AutoMediaInfo = ucl::AutoHandle<
-                               media_info_h, int, media_info_destroy>;
-
-       private:
-               const int m_flags;
-               const MediaType m_type;
-               std::string m_mediaId;
-               std::string m_filePath;
-               int m_resolutionX;
-               int m_resolutionY;
-               mutable AutoMediaInfo m_media;
-               mutable std::string m_thumbPath;
-               mutable std::unique_ptr<ThumbCbProxy> m_thumbCbProxy;
-               bool m_isValid;
-       };
-}
-
-#endif // __GALLERY_MODEL_MEDIA_ITEM_H__
diff --git a/inc/gallery/model/SoundManager.h b/inc/gallery/model/SoundManager.h
deleted file mode 100644 (file)
index e5adddb..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_SOUND_MANAGER_H__
-#define __GALLERY_MODEL_SOUND_MANAGER_H__
-
-#include <sound_manager.h>
-
-#include "ucl/misc/Event.h"
-
-#include "types.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(SoundManager);
-
-       class SoundManager final : public ucl::NonCopyable {
-       public:
-               static SoundManagerSRef newInstance();
-
-               bool isMediaDeviceReady() const;
-
-               int getCurrentMediaVolume() const;
-               int getMaxMediaVolume() const;
-
-               void addMediaDeviceStateChangeHandler(const NotiHandler &handler);
-               void delMediaDeviceStateChangeHandler(const NotiHandler &handler);
-
-               void addMediaVolumeChangeHandler(const NotiHandler &handler);
-               void delMediaVolumeChangeHandler(const NotiHandler &handler);
-
-       private:
-               friend class ucl::ReffedObj<SoundManager>;
-               SoundManager();
-               ~SoundManager();
-
-               ucl::Result prepare();
-
-               void setMediaDeviceState(bool isReady);
-               void setCurrentMediaVolume(int value);
-
-               ucl::Result updateMediaDeviceState();
-
-               void onDeviceConnectionChanged(sound_device_h device, bool isConnected);
-               void onDeviceStateChanged(sound_device_h device,
-                               sound_device_state_e state);
-               void onVolumeChanged(sound_type_e type, unsigned int volume);
-
-       private:
-               ucl::Event<NotiHandler> m_onMediaDeviceStateChange;
-               ucl::Event<NotiHandler> m_onMediaVolumeChange;
-               int m_devConnChangedCbId;
-               int m_devStateChangedCbId;
-               int m_volumeChangedCbId;
-               int m_currentMediaVolume;
-               int m_maxMediaVolume;
-               bool m_isMediaDeviceReady;
-       };
-}
-
-#endif // __GALLERY_MODEL_SOUND_MANAGER_H__
diff --git a/inc/gallery/model/types.h b/inc/gallery/model/types.h
deleted file mode 100644 (file)
index 38feee5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_TYPES_H__
-#define __GALLERY_MODEL_TYPES_H__
-
-#include "gallery/types.h"
-
-namespace gallery {
-
-       enum class MediaType {
-               IMAGE,
-               VIDEO,
-               SOUND,
-               MUSIC,
-               OTHERS
-       };
-}
-
-#endif // __GALLERY_MODEL_TYPES_H__
diff --git a/inc/gallery/presenters/AlertDialog.h b/inc/gallery/presenters/AlertDialog.h
deleted file mode 100644 (file)
index 641c536..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_ALERT_DIALOG_H__
-#define __GALLERY_PRESENTERS_ALERT_DIALOG_H__
-
-#include "ucl/gui/Layout.h"
-
-#include "Dialog.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(AlertDialog);
-
-       class AlertDialog final : public Dialog {
-       public:
-               enum class Type {
-                       OK,
-                       OK_CANCEL
-               };
-
-               enum class Event {
-                       CANCEL,
-                       OK,
-                       BACK
-               };
-
-               using EventHandler = ucl::WeakDelegate<
-                               bool(AlertDialog &dialog, Event event)>;
-
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setType(Type type);
-                       Builder &setTitle(ucl::TString title);
-                       Builder &setText(ucl::TString text);
-                       Builder &setHandler(const EventHandler &handler);
-                       AlertDialogWRef build(ucl::ElmWidget &parent) const;
-               private:
-                       Type m_type;
-                       ucl::TString m_title;
-                       ucl::TString m_text;
-                       EventHandler m_handler;
-               };
-
-       private:
-               friend class ucl::ReffedObj<AlertDialog>;
-               AlertDialog(ucl::IRefCountObj &rc,
-                               const EventHandler &handler);
-               virtual ~AlertDialog() = default;
-
-               ucl::Result prepare(ucl::ElmWidget &parent, Type type);
-
-               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 setTitle(const ucl::TString &title);
-               void setText(const ucl::TString &text);
-
-               void handleEvent(Event event);
-               bool dispatchEvent(Event event);
-
-               void onBtnClick(ucl::Widget &widget, void *eventInfo);
-
-               // Dialog //
-
-               virtual void onBackKey() final override;
-
-       private:
-               const EventHandler m_handler;
-               ucl::LayoutWRef m_layout;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_ALERT_DIALOG_H__
diff --git a/inc/gallery/presenters/AtspiHighlightHelper.h b/inc/gallery/presenters/AtspiHighlightHelper.h
deleted file mode 100644 (file)
index 650860e..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_ATSPI_HIGHLIGH_HELPER_H__
-#define __GALLERY_PRESENTERS_ATSPI_HIGHLIGH_HELPER_H__
-
-#include "ucl/mvp/GuiPresenter.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(AtspiHighlightHelper);
-
-       class AtspiHighlightHelper final : public ucl::GuiPresenter {
-       public:
-               using EventHandler = ucl::WeakDelegate<Elm_Interface_Atspi_Accessible *(
-                               ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation)>;
-
-       public:
-               static AtspiHighlightHelperSRef newInstance(GuiPresenter &parent,
-                               ucl::ElmWidget &rootWidget);
-
-               void setEventHandler(EventHandler handler);
-               void registerWidget(ucl::ElmWidget &widget);
-
-       private:
-               friend class ucl::ReffedObj<AtspiHighlightHelper>;
-               AtspiHighlightHelper(ucl::IRefCountObj &rc);
-               virtual ~AtspiHighlightHelper();
-
-               ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &rootWidget);
-
-       private:
-               void onAtspiGesture(ucl::Widget &widget, void *eventInfo);
-
-       private:
-               EventHandler m_eventHandler;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_ATSPI_HIGHLIGH_HELPER_H__
diff --git a/inc/gallery/presenters/Dialog.h b/inc/gallery/presenters/Dialog.h
deleted file mode 100644 (file)
index 7c26010..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_DIALOG_H__
-#define __GALLERY_PRESENTERS_DIALOG_H__
-
-#include "ucl/gui/StyledWidget.h"
-
-#include "ucl/mvp/GuiPresenter.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(Dialog);
-
-       class Dialog : public ucl::GuiPresenter,
-                       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;
-       private:
-               DialogSRef m_selfRef;
-               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
deleted file mode 100644 (file)
index 5bd8ecb..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#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(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
-                               "GuiPresenter::prepare() failed!");
-
-               UCL_FAIL_RETURN(createPopup(parent, popupType),
-                               "createPopup() failed!");
-
-               UCL_FAIL_RETURN(onPrepare(), "onPrepare() failed!");
-
-               m_selfRef = asShared(*this);
-
-               return ucl::RES_OK;
-       }
-}
diff --git a/inc/gallery/presenters/Instance.h b/inc/gallery/presenters/Instance.h
deleted file mode 100644 (file)
index bdc4fa6..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_INSTANCE_H__
-#define __GALLERY_PRESENTERS_INSTANCE_H__
-
-#include "ucl/appfw/IInstance.h"
-#include "ucl/appfw/IInstanceAppControlExt.h"
-#include "ucl/appfw/SysEventProvider.h"
-
-#include "ucl/gui/Theme.h"
-#include "ucl/gui/Naviframe.h"
-
-#include "gallery/model/Gallery.h"
-#include "Page.h"
-
-namespace gallery {
-
-       class Instance final : public ucl::RefCountAware,
-                       public ucl::IInstance,
-                       public ucl::IInstanceAppControlExt {
-       public:
-               Instance(ucl::IRefCountObj &rc,
-                               ucl::SysEventProvider &sysEventProvider);
-               virtual ~Instance();
-
-               // IInstance //
-
-               virtual ucl::Result onCreate(
-                               ucl::IInstanceContext *context) final override;
-               virtual void onPause() final override;
-               virtual void onResume() final override;
-
-               // IInstanceAppControlExt //
-
-               virtual void onAppControl(app_control_h appControl) final override;
-
-       private:
-               ucl::Result setupTheme();
-
-               void rescanMediaContent();
-               void stopMediaContentScan();
-               void startMediaContentScan();
-               void onScanComplete(media_content_error_e error);
-
-               ucl::Result handleAppControl(app_control_h appControl);
-               ucl::Result handleSingleMode(const std::string &operation,
-                               app_control_h appControl);
-               ucl::Result handleGroupMode(const std::string &operation,
-                               app_control_h appControl);
-
-               ucl::Result ensureGalleryModel();
-
-               void createNoContentPage();
-               void createThumbnailPage();
-               void createViewerPage(const MediaItemSRef &media);
-               void createVideoPlayerPage(const MediaItemSRef &media);
-
-               void onAlbumChanged();
-               void onPageExitRequest(Page &page);
-
-               void onSysEvent(const ucl::SysEvent sysEvent);
-
-       private:
-               ucl::SysEventProvider &m_sysEventProvider;
-               ucl::IInstanceContext *m_context;
-
-               GallerySRef m_gallery;
-               bool m_isScanInProgress;
-
-               ucl::WindowSRef m_win;
-               ucl::Theme m_theme;
-               ucl::NaviframeSRef m_navi;
-
-               PageWRef m_page;
-
-               bool m_isGroupMode;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_INSTANCE_H__
diff --git a/inc/gallery/presenters/InstanceManager.h b/inc/gallery/presenters/InstanceManager.h
deleted file mode 100644 (file)
index 66710ae..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_INSTANCE_MANAGER_H__
-#define __GALLERY_PRESENTERS_INSTANCE_MANAGER_H__
-
-#include "ucl/appfw/InstanceManagerBase.h"
-
-#include "types.h"
-
-namespace gallery {
-
-       class InstanceManager final : public ucl::InstanceManagerBase {
-       public:
-               InstanceManager();
-
-               // ucl::InstanceManagerBase //
-
-               virtual ucl::IInstanceSRef newInstance() const final override;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_INSTANCE_MANAGER_H__
diff --git a/inc/gallery/presenters/MoreOptionsPresenter.h b/inc/gallery/presenters/MoreOptionsPresenter.h
deleted file mode 100644 (file)
index 461bc7e..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
-#define __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
-
-#include <list>
-
-#include "ucl/misc/HashMap.h"
-
-#include "ucl/mvp/GuiPresenter.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter);
-
-       class MoreOptionsPresenter final : public ucl::GuiPresenter {
-       public:
-               UCL_DECLARE_REF_ALIASES(IListener);
-
-               struct Option final {
-                       int id;
-                       ucl::TString text;
-                       ucl::TString subText;
-                       ucl::LayoutTheme iconTheme;
-               };
-
-               using MoreOptions = std::list<Option>;
-
-               class Builder final {
-               public:
-                       Builder();
-                       ~Builder();
-                       bool isEmpty() const;
-                       Builder &clear();
-                       Builder &addOption(Option option);
-                       Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
-                       MoreOptionsPresenterSRef build(GuiPresenter &parent) const;
-               private:
-                       ucl::SharedRef<MoreOptions> m_options;
-                       ucl::ElmWidgetSRef m_parentWidget;
-               };
-
-               class IListener : public ucl::Polymorphic {
-               public:
-                       virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
-                                       const Option &option) = 0;
-                       virtual void onMoreOptionSelected(MoreOptionsPresenter &sender,
-                                       const Option &option) {};
-                       virtual void onMoreOptionsOpened(MoreOptionsPresenter &sender) {};
-                       virtual void onMoreOptionsClosed(MoreOptionsPresenter &sender) {};
-               };
-
-       public:
-               void setListener(const IListenerWRef &listener);
-
-               ucl::Widget &getWidget();
-
-               void setOpened(bool isOpened);
-               bool isOpened() const;
-
-               void setOpenedDelayed(bool isOpened, double timeout);
-
-       private:
-               using MoreOptionsCSRef = ucl::SharedRef<const MoreOptions>;
-
-       private:
-               friend class ucl::ReffedObj<MoreOptionsPresenter>;
-               MoreOptionsPresenter(ucl::IRefCountObj &rc,
-                               const MoreOptionsCSRef &options);
-               virtual ~MoreOptionsPresenter();
-
-               ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &parentWidget);
-               ucl::Result addItem(const Option &option);
-
-               bool resetTimer(double timeout);
-               void stopTimer();
-
-               Eina_Bool onTimer();
-
-               void onOpened(ucl::Widget &widget, void *eventInfo);
-               void onClosed(ucl::Widget &widget, void *eventInfo);
-               void onItemClicked(ucl::Widget &widget, void *eventInfo);
-               void onItemSelected(ucl::Widget &widget, void *eventInfo);
-
-       private:
-               const MoreOptionsCSRef m_options;
-               ucl::HashMap<void *, const Option *> m_map;
-               ucl::ElmWidgetSRef m_widget;
-               IListenerWRef m_listener;
-               Ecore_Timer *m_timer;
-               bool m_newOpenedState;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
diff --git a/inc/gallery/presenters/NoContentPage.h b/inc/gallery/presenters/NoContentPage.h
deleted file mode 100644 (file)
index aeb1ff8..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_NO_CONTENT_PAGE_H__
-#define __GALLERY_PRESENTERS_NO_CONTENT_PAGE_H__
-
-#include "Page.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(NoContentPage);
-
-       class NoContentPage final : public Page {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       ~Builder();
-                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
-                       NoContentPageWRef build(
-                                       const ExitRequestHandler &onExitRequest) const;
-               private:
-                       ucl::NaviframeSRef m_navi;
-               };
-
-       private:
-               friend class ucl::ReffedObj<NoContentPage>;
-               NoContentPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
-                               const ExitRequestHandler &onExitRequest);
-               virtual ~NoContentPage();
-
-               ucl::Result doPrepare(ucl::NaviItem &item);
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_NO_CONTENT_PAGE_H__
diff --git a/inc/gallery/presenters/Page.h b/inc/gallery/presenters/Page.h
deleted file mode 100644 (file)
index d4de6f0..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_PAGE_H__
-#define __GALLERY_PRESENTERS_PAGE_H__
-
-#include "ucl/gui/Naviframe.h"
-
-#include "ucl/mvp/GuiPresenter.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(Page);
-
-       class Page : public ucl::GuiPresenter,
-                       public ucl::IDisposable {
-       public:
-               using ExitRequestHandler = ucl::WeakDelegate<void(Page &page)>;
-
-       public:
-               ucl::Naviframe &getNaviframe();
-
-               bool isAtTop() const;
-               bool isAtBottom() const;
-
-               void exit();
-
-               void popTo();
-               void deleteTo();
-               void promote();
-
-               template <class ...ARGS>
-               ucl::NaviItem insertAfter(ARGS &&...args);
-
-               template <class ...ARGS>
-               ucl::NaviItem insertBefore(ARGS &&...args);
-
-               // ucl::IDisposable //
-
-               virtual void dispose() override;
-               virtual bool isDisposed() const final override;
-
-       protected:
-               Page(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
-                               const ExitRequestHandler &onExitRequest);
-               virtual ~Page();
-
-               template <class ON_PREPARE>
-               ucl::Result prepare(ON_PREPARE &&onPrepare);
-
-               ucl::NaviItem getItem();
-
-               void requestExit();
-
-               virtual void onBackKey();
-
-       private:
-               ucl::Result preparePart2();
-
-               void dispatchTopPageChanged();
-
-               void updateActiveState();
-
-               void onTransitionStarted(ucl::Widget &widget, void *eventInfo);
-               void onTransitionFinished(ucl::Widget &widget, void *eventInfo);
-               void onTopPageChanged(ucl::Widget &widget, void *eventInfo);
-
-               void onHWBackKey(Evas_Object *obj, void *eventInfo);
-               void onItemDel(Evas_Object *obj, void *eventInfo);
-
-       private:
-               const ucl::NaviframeSRef m_navi;
-               const ExitRequestHandler m_onExitRequest;
-               ucl::NaviItem m_item;
-               PageSRef m_selfRef;
-       };
-
-       // Non-member functions //
-
-       bool isLast(const Page &page);
-}
-
-#include "Page.hpp"
-
-#endif // __GALLERY_PRESENTERS_PAGE_H__
diff --git a/inc/gallery/presenters/Page.hpp b/inc/gallery/presenters/Page.hpp
deleted file mode 100644 (file)
index 426445a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/logging.h"
-
-namespace gallery {
-
-       template <class ON_PREPARE>
-       inline ucl::Result Page::prepare(ON_PREPARE &&onPrepare)
-       {
-               UCL_FAIL_RETURN(GuiPresenter::prepare(*m_navi),
-                               "GuiPresenter::prepare() failed!");
-
-               UCL_FAIL_RETURN(onPrepare(m_item), "onPrepare() failed!");
-
-               return preparePart2();
-       }
-
-       template <class ...ARGS>
-       inline ucl::NaviItem Page::insertAfter(ARGS &&...args)
-       {
-               return m_navi->insertAfter(m_item, std::forward<ARGS>(args)...);
-       }
-
-       template <class ...ARGS>
-       inline ucl::NaviItem Page::insertBefore(ARGS &&...args)
-       {
-               return m_navi->insertBefore(m_item, std::forward<ARGS>(args)...);
-       }
-
-       inline ucl::Naviframe &Page::getNaviframe()
-       {
-               UCL_ASSERT(m_navi, "m_navi is NULL");
-               return *m_navi;
-       }
-
-       inline bool Page::isAtTop() const
-       {
-               return (m_navi->getTopItem() == m_item);
-       }
-
-       inline bool Page::isAtBottom() const
-       {
-               return (m_navi->getBottomItem() == m_item);
-       }
-
-       // Non-member functions //
-
-       inline bool isLast(const Page &page)
-       {
-               return (page.isAtBottom() && page.isAtTop());
-       }
-}
diff --git a/inc/gallery/presenters/PreviewPage.h b/inc/gallery/presenters/PreviewPage.h
deleted file mode 100644 (file)
index 2f41752..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_PREVIEW_PAGE_H__
-#define __GALLERY_PRESENTERS_PREVIEW_PAGE_H__
-
-#include "Page.h"
-
-#include "gallery/model/IMediaAlbum.h"
-
-#include "gallery/view/PageContent.h"
-#include "gallery/view/ImageGrid.h"
-
-#include "MoreOptionsPresenter.h"
-#include "SelectModePresenter.h"
-#include "AlertDialog.h"
-#include "ProcessingPresenter.h"
-#include "AtspiHighlightHelper.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(PreviewPage);
-
-       class PreviewPage final : public Page,
-                       private ImageGrid::IListener,
-                       private MoreOptionsPresenter::IListener,
-                       private SelectModePresenter::IListener {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       ~Builder();
-                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
-                       Builder &setAlbum(const IMediaAlbumSRef &album);
-                       Builder &setStartItemIndex(int index);
-                       Builder &setSelectModeStartup(bool value);
-                       Builder &setAutoSelectStartItem(bool value);
-                       PreviewPageWRef build(
-                                       const ExitRequestHandler &onExitRequest) const;
-               private:
-                       ucl::NaviframeSRef m_navi;
-                       IMediaAlbumSRef m_album;
-                       int m_startItemIndex;
-                       bool m_selectModeStartup;
-                       bool m_autoSelectStartItem;
-               };
-
-       public:
-               int getCurrentItemIndex() const;
-
-       private:
-               friend class ucl::ReffedObj<PreviewPage>;
-               PreviewPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
-                               const ExitRequestHandler &onExitRequest,
-                               const IMediaAlbumSRef &album, bool selectModeStartup);
-               virtual ~PreviewPage();
-
-               ucl::Result doPrepare(int startItemIndex, ucl::NaviItem &item);
-               void showItem(int itemIndex);
-               void selectItem(int itemIndex);
-               int getSafeItemIndex(int itemIndex) const;
-
-               void reload();
-               void checkViewerPage();
-
-               void onAlbumChanged();
-               bool onEachMedia(MediaItemSRef &&media);
-
-               void closeTempViews();
-               void switchToSelectMode();
-               void switchToNormalMode();
-               void toggleItemSelected(int itemIndex);
-               void confirmItemsDelete();
-               void openViewer(int itemIndex, int x, int y);
-
-               void onPageExitRequest(Page &page);
-
-               bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
-               void onJobComplete();
-
-               Elm_Interface_Atspi_Accessible *onAtspiHighlight(
-                               ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation);
-
-               // GuiPresenter //
-
-               virtual void onActivateBy(const DeactivatorInfo &info) final override;
-               virtual void onDeactivateBy(const DeactivatorInfo &info) final override;
-
-               // Page //
-
-               virtual void onBackKey() final override;
-
-               // ImageGrid::IListener //
-
-               virtual void onItemRealized(int itemIndex) final override;
-               virtual void onItemUnrealized(int itemIndex) final override;
-               virtual void onItemEvent(int itemIndex,
-                               ImageGrid::ItemEvent event, int x, int y) final override;
-               virtual void onTransitionFinished() final override;
-               virtual Elm_Interface_Atspi_Accessible *onAccessObjectRequest(
-                               bool isFlowsTo) final override;
-
-               // MoreOptionsPresenter::IListener //
-
-               virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
-                               const MoreOptionsPresenter::Option &option) final override;
-
-               // SelectModePresenter::IListener //
-
-               virtual void onSelectModeEvent(
-                               SelectModePresenter::Event event) final override;
-
-       private:
-               class Item;
-               using ItemSRef = ucl::SharedRef<Item>;
-
-       private:
-               const IMediaAlbumSRef m_album;
-               const bool m_selectModeStartup;
-               ImageGridSRef m_imageGrid;
-               std::vector<ItemSRef> m_items;
-               IJobSRef m_job;
-
-               PageContentSRef m_content;
-               MoreOptionsPresenterSRef m_more;
-               SelectModePresenterSRef m_smp;
-               DialogWRef m_alert;
-               ProcessingPresenterSRef m_processing;
-               AtspiHighlightHelperSRef m_atspiHelper;
-
-               PageWRef m_page;
-               int m_selectCount;
-               bool m_isInSelectMode;
-               bool m_needReload;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_PREVIEW_PAGE_H__
diff --git a/inc/gallery/presenters/ProcessingPresenter.h b/inc/gallery/presenters/ProcessingPresenter.h
deleted file mode 100644 (file)
index ff0477a..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_PROCESSING_PRESENTER_H__
-#define __GALLERY_PRESENTERS_PROCESSING_PRESENTER_H__
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/StyledWidget.h"
-
-#include "ucl/mvp/GuiPresenter.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(ProcessingPresenter);
-
-       class ProcessingPresenter final : public ucl::GuiPresenter {
-       public:
-               enum class IconType {
-                       NONE,
-                       CHECK
-               };
-
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setProcessingText(ucl::TString text);
-                       Builder &setForceProgress(bool value);
-                       ProcessingPresenterSRef build(ucl::ElmWidget &parent) const;
-               private:
-                       ucl::TString m_processingText;
-                       bool m_forceProgress;
-               };
-
-               using DismissHandler = ucl::WeakDelegate<void()>;
-
-       public:
-               void complete(const ucl::TString &completeText,
-                               IconType iconType = IconType::NONE);
-
-               void setDismissHandler(const DismissHandler &handler);
-
-       private:
-               friend class ucl::ReffedObj<ProcessingPresenter>;
-               ProcessingPresenter(ucl::IRefCountObj &rc);
-               virtual ~ProcessingPresenter();
-
-               ucl::Result prepare(ucl::ElmWidget &parent,
-                               const ucl::TString &processingText,
-                               bool forceProgress);
-
-               ucl::Result createWidget(ucl::ElmWidget &parent,
-                               const ucl::TString &processingText);
-               ucl::Result moveWidget();
-               ucl::Result createProgress();
-               ucl::Result createPopup();
-               ucl::Result createIcon();
-
-               bool resetTimer(double timeout);
-               void stopTimer();
-
-               void showProgress();
-
-               void tryShowPopup();
-               void dismissPopup();
-               void deletePopup();
-
-               void animateIcon();
-
-               Eina_Bool onTimer();
-
-               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
-               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
-
-       private:
-               enum class State {
-                       WAITING,
-                       PROCESSING,
-                       POPUP_ANIMATION,
-                       COMPLETE
-               };
-
-       private:
-               ucl::LayoutSRef m_widget;
-               ucl::StyledWidgetSRef m_popup;
-               ucl::LayoutWRef m_icon;
-               IconType m_iconType;
-               DismissHandler m_dismissHandler;
-               Ecore_Timer *m_timer;
-               State m_state;
-               ProcessingPresenterSRef m_selfRef;
-               bool m_mayComplete;
-               bool m_isComplete;
-               bool m_isDismissed;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_PROCESSING_PRESENTER_H__
diff --git a/inc/gallery/presenters/SelectModePresenter.h b/inc/gallery/presenters/SelectModePresenter.h
deleted file mode 100644 (file)
index b7b78f1..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_SELECT_MODE_PRESENTER_H__
-#define __GALLERY_PRESENTERS_SELECT_MODE_PRESENTER_H__
-
-#include "ucl/gui/StyledWidget.h"
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "gallery/view/PageContent.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(SelectModePresenter);
-
-       class SelectModePresenter final : public ucl::GuiPresenter {
-       public:
-               UCL_DECLARE_REF_ALIASES(IListener);
-
-               enum {
-                       FLAG_NO_BOTTOM_BUTTON = 1,
-                       FLAG_NO_MORE_OPTIONS = 2,
-                       FLAG_NO_DIM_ON_ZERO_SELECT = 4,
-                       FLAG_NO_DISMISS_ON_ROTARY = 8
-               };
-
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setFlags(int flags);
-                       Builder &setPageContent(const PageContentSRef &content);
-                       SelectModePresenterSRef build(GuiPresenter &parent) const;
-               private:
-                       PageContentSRef m_content;
-                       int m_flags;
-               };
-
-               enum class Event {
-                       SELECT_ALL,
-                       DESELECT_ALL,
-                       BOTTOM_BUTTON_CLICK
-               };
-
-               class IListener : public ucl::Polymorphic {
-               public:
-                       virtual void onSelectModeEvent(Event event) = 0;
-               };
-
-       public:
-               void setListener(const IListenerWRef &listener);
-
-               void setVisible(bool value);
-               bool isVisible() const;
-
-               ucl::ElmWidget &getSelectButton();
-               ucl::ElmWidget &getBottomButton();
-
-               void setBottomButtonText(const ucl::TString &value);
-
-               void update(int selectCount, int totalCount = -1);
-
-       private:
-               friend class ucl::ReffedObj<SelectModePresenter>;
-               SelectModePresenter(ucl::IRefCountObj &rc,
-                               const PageContentSRef &content, int flags);
-               virtual ~SelectModePresenter();
-
-               ucl::Result prepare(GuiPresenter &parent);
-
-               void doUpdate();
-
-               void showPopup();
-               void movePopup();
-               void dismissPopup();
-               void deletePopup();
-
-               void dispatchEvent(Event event);
-
-               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
-               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
-
-               void onSelectAll(Evas_Object *obj, void *eventInfo);
-               void onDeselectAll(Evas_Object *obj, void *eventInfo);
-
-               void onSelectBtnClick(ucl::Widget &widget, void *eventInfo);
-               void onBottomBtnClick(ucl::Widget &widget, void *eventInfo);
-               Eina_Bool onRotary(Eext_Rotary_Event_Info *info);
-
-               // GuiPresenter //
-               virtual void onDeactivate() final override;
-
-       private:
-               const PageContentSRef m_content;
-               const int m_flags;
-               ucl::StyledWidgetSRef m_selectButton;
-               ucl::StyledWidgetSRef m_bottomButton;
-               ucl::StyledWidgetSRef m_popup;
-               IListenerWRef m_listener;
-               int m_totalCount;
-               int m_selectCount;
-               bool m_isVisible;
-               bool m_isPopupDismissed;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_SELECT_MODE_PRESENTER_H__
diff --git a/inc/gallery/presenters/ThumbnailPage.h b/inc/gallery/presenters/ThumbnailPage.h
deleted file mode 100644 (file)
index 5222e86..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_THUMBNAIL_PAGE_H__
-#define __GALLERY_PRESENTERS_THUMBNAIL_PAGE_H__
-
-#include "Page.h"
-
-#include "gallery/model/IMediaAlbum.h"
-
-#include "gallery/view/PageContent.h"
-#include "gallery/view/ImageGrid.h"
-
-#include "MoreOptionsPresenter.h"
-#include "AtspiHighlightHelper.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(ThumbnailPage);
-
-       class ThumbnailPage final : public Page,
-                       private ImageGrid::IListener,
-                       private MoreOptionsPresenter::IListener {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       ~Builder();
-                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
-                       Builder &setAlbum(const IMediaAlbumSRef &album);
-                       ThumbnailPageWRef build(
-                                       const ExitRequestHandler &onExitRequest) const;
-               private:
-                       ucl::NaviframeSRef m_navi;
-                       IMediaAlbumSRef m_album;
-               };
-
-       private:
-               friend class ucl::ReffedObj<ThumbnailPage>;
-               ThumbnailPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
-                               const ExitRequestHandler &onExitRequest,
-                               const IMediaAlbumSRef &album);
-               virtual ~ThumbnailPage();
-
-               ucl::Result doPrepare(ucl::NaviItem &item);
-
-               void reload();
-
-               int getSafeItemIndex(int itemIndex) const;
-
-               void onAlbumChanged();
-               bool onEachMedia(MediaItemSRef &&media);
-
-               void onPageExitRequest(Page &page);
-
-               Elm_Interface_Atspi_Accessible *onAtspiHighlight(
-                               ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation);
-
-               // GuiPresenter //
-
-               virtual void onActivateBy(const DeactivatorInfo &info) final override;
-               virtual void onDeactivateBy(const DeactivatorInfo &info) final override;
-
-               // ImageGrid::IListener //
-
-               virtual void onItemRealized(int itemIndex) final override;
-               virtual void onItemUnrealized(int itemIndex) final override;
-               virtual void onItemEvent(int itemIndex,
-                               ImageGrid::ItemEvent event, int x, int y) final override;
-
-               // MoreOptionsPresenter::IListener //
-
-               virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
-                               const MoreOptionsPresenter::Option &option) final override;
-
-       private:
-               class RealizedItem;
-               using RealizedItemSRef = ucl::SharedRef<RealizedItem>;
-
-       private:
-               const IMediaAlbumSRef m_album;
-               MediaItems m_mediaItems;
-
-               std::vector<RealizedItemSRef> m_realizedItems;
-
-               PageContentSRef m_content;
-               ImageGridSRef m_imageGrid;
-               MoreOptionsPresenterSRef m_more;
-               AtspiHighlightHelperSRef m_atspiHelper;
-
-               PageWRef m_page;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_THUMBNAIL_PAGE_H__
diff --git a/inc/gallery/presenters/VideoPlayerPage.h b/inc/gallery/presenters/VideoPlayerPage.h
deleted file mode 100644 (file)
index 36d3262..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_VIDEO_PLAYER_PAGE_H__
-#define __GALLERY_PRESENTERS_VIDEO_PLAYER_PAGE_H__
-
-#include <player.h>
-
-#include "ucl/gui/Layout.h"
-
-#include "Page.h"
-
-#include "gallery/model/SoundManager.h"
-#include "gallery/model/MediaItem.h"
-
-#include "gallery/view/TouchParser.h"
-
-#include "AlertDialog.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(VideoPlayerPage);
-
-       class VideoPlayerPage final : public Page {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       ~Builder();
-                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
-                       Builder &setMedia(const MediaItemSRef &media);
-                       VideoPlayerPageWRef build(
-                                       const ExitRequestHandler &onExitRequest) const;
-               private:
-                       ucl::NaviframeSRef m_navi;
-                       MediaItemSRef m_media;
-               };
-
-       private:
-               friend class ucl::ReffedObj<VideoPlayerPage>;
-               VideoPlayerPage(ucl::IRefCountObj &rc,
-                               const ucl::NaviframeSRef &navi,
-                               const ExitRequestHandler &onExitRequest,
-                               const MediaItemSRef &media);
-               virtual ~VideoPlayerPage();
-
-               ucl::Result doPrepare(ucl::NaviItem &item);
-
-               ucl::Result prepareSoundManager();
-
-               void createImage();
-               ucl::Result preparePlayer();
-               ucl::Result seekToStart();
-
-               void createControls();
-               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);
-
-               bool resetAutoStartTimer();
-               bool resetControlsHideTimer();
-               bool resetTickTimer();
-
-               void showControls();
-               void hideControls();
-               void showVolumeBtn();
-
-               bool updatePlayTimeText();
-               void updatePlayTimeText(int timeMs);
-
-               player_state_e getPlayerState() const;
-               void startPlayback();
-               void pausePlayback();
-
-               void setScreenAlwaysOn(bool isAlwaysOn);
-
-               ucl::Result launchVolumeSettings();
-
-               bool onAlertEvent(AlertDialog &dialog, AlertDialog::Event event);
-
-               void onMediaDeviceStateChanged();
-               void onMediaVolumeChanged();
-
-               void onPlaybackComplete();
-               void onPlaybackInterrupted(player_interrupted_code_e code);
-               void onSeekComplete();
-
-               Eina_Bool onAutoStartTimer();
-               Eina_Bool onControlsHideTimer();
-               Eina_Bool onTickTimer();
-
-               void onVolumeBtnClick(ucl::Widget &sender, void *eventInfo);
-               void onPlayBtnClick(ucl::Widget &sender, void *eventInfo);
-               void onPauseBtnClick(ucl::Widget &sender, void *eventInfo);
-               void onTap(int x, int y);
-               Eina_Bool onRotary(Eext_Rotary_Event_Info *info);
-
-               void onInstancePaused(ucl::Widget &sender, void *eventInfo);
-               void onInstanceResumed(ucl::Widget &sender, void *eventInfo);
-
-       private:
-               enum class State {
-                       PAUSED,
-                       PLAYING
-               };
-
-       private:
-               const MediaItemSRef m_media;
-               SoundManagerSRef m_soundMgr;
-               ucl::LayoutSRef m_content;
-               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;
-               Ecore_Timer *m_controlsHideTimer;
-               Ecore_Timer *m_tickTimer;
-               State m_state;
-               bool m_isControlsVisible;
-               bool m_needAutoStart;
-               bool m_isPlaybackCompleted;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_VIDEO_PLAYER_PAGE_H__
diff --git a/inc/gallery/presenters/ViewerPage.h b/inc/gallery/presenters/ViewerPage.h
deleted file mode 100644 (file)
index 30a8fe4..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_VIEWER_PAGE_H__
-#define __GALLERY_PRESENTERS_VIEWER_PAGE_H__
-
-#include "Page.h"
-
-#include "gallery/model/MediaItem.h"
-
-#include "gallery/view/PageContent.h"
-#include "gallery/view/ImageViewer.h"
-#include "gallery/view/TouchParser.h"
-
-#include "MoreOptionsPresenter.h"
-#include "ProcessingPresenter.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(ViewerPage);
-
-       class ViewerPage final : public Page,
-                       private MoreOptionsPresenter::IListener {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       ~Builder();
-                       Builder &setNaviframe(const ucl::NaviframeSRef &navi);
-                       Builder &setMedia(const MediaItemSRef &media);
-                       Builder &setZoomIn(int x, int y);
-                       Builder &setImageLoadSize(int size, bool isFull);
-                       Builder &setExitOnZoomOut(bool value);
-                       ViewerPageWRef build(
-                                       const ExitRequestHandler &onExitRequest) const;
-               private:
-                       ucl::NaviframeSRef m_navi;
-                       MediaItemSRef m_media;
-                       int m_zoomInX;
-                       int m_zoomInY;
-                       int m_imageLoadSize;
-                       bool m_isImageLoadSizeFull;
-                       bool m_exitOnZoomOut;
-               };
-
-       public:
-               const std::string &getMediaId() const;
-
-       private:
-               friend class ucl::ReffedObj<ViewerPage>;
-               ViewerPage(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
-                               const ExitRequestHandler &onExitRequest,
-                               const MediaItemSRef &media, bool exitOnZoomOut);
-               virtual ~ViewerPage();
-
-               ucl::Result doPrepare(int imageLoadSize, bool isImageLoadSizeFull,
-                               ucl::NaviItem &item);
-
-               void zoomIn(int originX, int originY);
-
-               void onThumbnail(ucl::Result result, const std::string &path);
-               void onZoomEnd(ucl::Widget &widget, void *eventInfo);
-               void onDoubleTap(int x, int y);
-
-               void onJobComplete();
-
-               // Page //
-
-               virtual void onBackKey() final override;
-
-               // MoreOptionsPresenter::IListener //
-
-               virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
-                               const MoreOptionsPresenter::Option &option) final override;
-
-       private:
-               const MediaItemSRef m_media;
-               const bool m_exitOnZoomOut;
-               ImageViewerSRef m_imageViewer;
-               TouchParserSRef m_touchParser;
-               IJobSRef m_job;
-               PageContentSRef m_content;
-               MoreOptionsPresenterSRef m_more;
-               ProcessingPresenterSRef m_processing;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_VIEWER_PAGE_H__
diff --git a/inc/gallery/presenters/types.h b/inc/gallery/presenters/types.h
deleted file mode 100644 (file)
index 2d862ff..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_TYPES_H__
-#define __GALLERY_PRESENTERS_TYPES_H__
-
-#include "gallery/view/types.h"
-#include "gallery/model/types.h"
-
-#endif // __GALLERY_PRESENTERS_TYPES_H__
diff --git a/inc/gallery/resources.h b/inc/gallery/resources.h
deleted file mode 100644 (file)
index 6a6f372..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_RESOURCES_H__
-#define __GALLERY_RESOURCES_H__
-
-#include "ucl/misc/TString.h"
-
-#include "config.h"
-
-namespace gallery {
-
-       constexpr auto THEME_EDJE_PATH = "edje/theme.edj";
-
-       constexpr auto ICON_NO_PHOTOS = "gallery_icon_no_photos.png";
-
-       constexpr auto ICON_MORE_OPT_DELETE = "gallery_more_opt_delete.png";
-       constexpr auto ICON_MORE_OPT_SAVE = "gallery_more_opt_save.png";
-       constexpr auto ICON_MORE_OPT_SEND = "gallery_more_opt_send_to_mobile.png";
-
-       constexpr auto ICON_POPUP_OK = "tw_ic_popup_btn_check.png";
-       constexpr auto ICON_POPUP_CANCEL = "tw_ic_popup_btn_delete.png";
-
-       extern const ucl::TString STR_APP_NAME;
-       extern const ucl::TString STR_NO_PHOTOS;
-       extern const ucl::TString STR_SELECT_ALL;
-       extern const ucl::TString STR_DESELECT_ALL;
-       extern const ucl::TString STR_DELETE;
-       extern const ucl::TString STR_DELETE_CAPS;
-       extern const ucl::TString STR_DELETE_1_PHOTO;
-       extern const ucl::TString STR_DELETE_N_PHOTO;
-       extern const ucl::TString STR_DELETING;
-       extern const ucl::TString STR_DELETED;
-       extern const ucl::TString STR_FAILED;
-       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/inc/gallery/types.h b/inc/gallery/types.h
deleted file mode 100644 (file)
index 9a1476e..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_TYPES_H__
-#define __GALLERY_TYPES_H__
-
-#include "config.h"
-
-#include "ucl/util/types.h"
-#include "ucl/util/memory.h"
-#include "ucl/util/delegation.h"
-#include "ucl/util/smartDelegation.h"
-
-namespace gallery {
-
-       using NotiHandler = ucl::WeakDelegate<void()>;
-}
-
-#endif // __GALLERY_TYPES_H__
diff --git a/inc/gallery/view/ImageGrid.h b/inc/gallery/view/ImageGrid.h
deleted file mode 100644 (file)
index ddcae7a..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_VIEW_IMAGE_GRID_H__
-#define __GALLERY_VIEW_IMAGE_GRID_H__
-
-#include <deque>
-
-#include "ucl/gui/StyledWidget.h"
-
-#include "ucl/misc/Timeout.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(ImageGrid);
-
-       class ImageGrid : public ucl::ElmWidget {
-       public:
-               UCL_DECLARE_REF_ALIASES(IListener);
-
-               enum class Type {
-                       HCOMB_3X3,
-                       LINEAR
-               };
-
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setType(Type value);
-                       Builder &setListener(const IListenerWRef &value);
-                       Builder &setSelectModeStartup(bool value);
-                       ImageGridSRef build(ElmWidget &parent) const;
-               private:
-                       Type m_type;
-                       IListenerWRef m_listener;
-                       bool m_selectModeStartup;
-               };
-
-               enum class ItemEvent {
-                       CLICK,
-                       DOUBLE_TAP,
-                       TAP_AND_HOLD
-               };
-
-               class IListener : public ucl::Polymorphic {
-               public:
-                       virtual void onItemRealized(int itemIndex) = 0;
-                       virtual void onItemUnrealized(int itemIndex) = 0;
-                       virtual void onItemEvent(int itemIndex,
-                                       ItemEvent event, int x, int y) = 0;
-                       virtual void onTransitionFinished() {}
-                       virtual Elm_Interface_Atspi_Accessible *onAccessObjectRequest(
-                                       bool isFlowsTo) { return nullptr; }
-               };
-
-               enum {
-                       UF_LOSE_IMAGE = 1,
-                       UF_LOSE_BG = 2,
-                       UF_BLOCK_CLICKS = 4,
-                       UF_SELECTED = 8
-               };
-
-               struct ItemParams final {
-                       std::string imagePath;
-                       std::string bgImagePath;
-                       int imageWidth;
-                       int imageHeight;
-                       int flags;
-               };
-
-               struct ItemInfo final {
-                       int imageLoadSize;
-                       bool isImageLoadSizeFull;
-                       bool isImageLoaded;
-               };
-
-               class Unrealizer final : ucl::NonCopyable {
-               public:
-                       Unrealizer(ImageGrid &imageGrid);
-                       ~Unrealizer();
-               private:
-                       ImageGrid &m_imageGrid;
-               };
-
-       public:
-               void setListener(const IListenerWRef &listener);
-
-               ucl::Result setItemCount(int count);
-
-               ucl::Result setSelectModeEnabled(bool enabled);
-               bool isInSelectMode() const;
-               bool isInTransition() const;
-
-               void update();
-
-               ucl::Result updateItem(int itemIndex, const ItemParams &params);
-
-               ucl::Result isItemRealized(int itemIndex) const;
-
-               ucl::Result getItemInfo(int itemIndex, ItemInfo &info) const;
-               Elm_Interface_Atspi_Accessible *getAccessObject(bool isFlowsTo);
-
-               int getScrolledToItemIndex() const;
-               ucl::Result scrollToItem(int itemIndex);
-               ucl::Result bringInItem(int itemIndex);
-
-               void activateRotary();
-               void deactivateRotary();
-
-       private:
-               class Slot;
-               using SlotUPtr = std::unique_ptr<Slot>;
-
-               struct Info;
-               struct HcombInfo;
-               struct LinearInfo;
-
-       private:
-               friend class ucl::ReffedObj<ImageGrid>;
-               ImageGrid(ucl::IRefCountObj *rc, Evas_Object *scroller,
-                               Type type, bool selectModeStartup);
-               virtual ~ImageGrid();
-
-               static const Info &getInfo(Type type);
-
-               template <class FUNC>
-               ucl::Result doWithItem(int itemIndex, FUNC &&func) const;
-               template <class FUNC>
-               ucl::Result doWithCell(int itemIndex, FUNC &&func) const;
-
-               template <class SHOW_FUNC>
-               ucl::Result showItem(int itemIndex, SHOW_FUNC &&showFunc);
-
-               bool isItemFullyVisible(int itemIndex);
-               bool isItemFullyVisible(int itemIndex,
-                               int &minVisibleOffset, int &maxVisibleOffset) const;
-               bool isItemFullyVisible(int slotIndex, int itemOffset,
-                               int &minVisibleOffset, int &maxVisibleOffset) const;
-
-               void forceBoxSizeCalculate();
-
-               void addUnrealizeLock();
-               void removeUnrealizeLock();
-
-               void handleItemEvent(int itemIndex,
-                               ItemEvent event, int x, int y) const;
-
-               // Accessibility
-
-               void onItemHighlighted(int itemIndex);
-               void onItemUnhighlighted(int itemIndex);
-               void onKeeperUnhighlighted(Widget &sender, void *eventInfo);
-
-               void updateHighlightTimeout();
-               void onHighlightTimeout(ucl::Timeout *sender);
-
-               Elm_Interface_Atspi_Accessible *requestAtspi(int itemIndex);
-               Elm_Interface_Atspi_Accessible *getItemAtspi(int itemIndex);
-
-               // Selection mode hanling
-               void evalSlotSizes();
-               void finalizeTransition();
-               Eina_Bool onAnimationFrame();
-               void onSlotResize(Widget &widget, void *eventInfo);
-               void onBoxResize(Evas *e, Evas_Object *obj, void *eventInfo);
-               void onTransitonFinished(Evas_Object *obj, const char *emission,
-                               const char *source);
-
-               // Initialization
-               void prepare();
-               void createCircleScroller();
-               void createHighlighKeeper();
-
-               // Actual slots count
-               bool updateSlotCount();
-               int calcSlotCount();
-               void setSlotCount(int newSlotCount);
-
-               // Optimal slots count
-               bool updateOptimalSlotCount();
-               int calcOptimalSlotCount();
-
-               // Maximum slots count
-               bool updateMaxSlotCount();
-               int calcMaxSlotCount();
-
-               // Actual begin slot index
-               bool updateBeginSlotIndex();
-               int calcBeginSlotIndex();
-               void setBeginSlotIndex(int newBeginSlotIndex);
-
-               // Maximum begin slot index
-               bool updateMaxBeginSlotIndex();
-               int calcMaxBeginSlotIndex();
-
-               // Misc
-               void updatePadSizes();
-               void updateScrollBias();
-               void updateRectMins();
-
-               // Slot size
-               bool updateSlotSize();
-               void setSlotSize(int newSlotSize);
-
-               // Scroller size
-               bool updateScrollerSize();
-               int calcScrollerSize();
-
-               // Scroller scroll offset
-               bool updateScrollOffset();
-               int calcScrollOffset();
-
-               // Slots rotations
-               void rotateSlotsRight(int count);
-               void rotateSlotsLeft(int count);
-
-               // Slots realization/unrealization
-               void realizeSlots();
-               void unrealizeSlots(int beginSlotOffset, int endSlotOffset);
-
-               // Event handling
-               void handleScrolling();
-               void handleResize();
-
-               // Events
-               void onScrollerResize(Widget &sender, void *eventInfo);
-               void onScrollerMove(Widget &sender, void *eventInfo);
-               void onBoxMove(Widget &sender, void *eventInfo);
-
-       private:
-               const Info &m_info;
-
-               ucl::StyledWidget *m_scroller;
-               ucl::ElmWidget m_box;
-               ucl::Widget m_rect1;
-               ucl::Widget m_rect2;
-               Evas_Object *m_circleScroller;
-
-               IListenerWRef m_listener;
-               int m_itemCount;
-
-               std::deque<SlotUPtr> m_slots;
-
-               int m_slotCount;
-               int m_optimalSlotCount;
-               int m_maxSlotCount;
-
-               int m_beginSlotIndex;
-               int m_maxBeginSlotIndex;
-
-               int m_scrollBias;
-               int m_padSize1;
-               int m_padSize2;
-
-               int m_slotSize;
-               int m_scrollerSize;
-               int m_scrollOffset;
-
-               int m_unrealizeLock;
-               int m_eventsLock;
-
-               Ecore_Animator *m_animator;
-               int m_scrollLockIndex;
-               bool m_isInSelectMode;
-               bool m_isRotaryActive;
-
-               ucl::ElmWidgetSRef m_highlighKeeper;
-               ucl::TimeoutSRef m_highlightTimeout;
-               int m_highlightID;
-               bool m_isHighlightLocked;
-       };
-}
-
-#endif // __GALLERY_VIEW_IMAGE_GRID_H__
diff --git a/inc/gallery/view/ImageViewer.h b/inc/gallery/view/ImageViewer.h
deleted file mode 100644 (file)
index 409b010..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_VIEW_IMAGE_VIEWER_H__
-#define __GALLERY_VIEW_IMAGE_VIEWER_H__
-
-#include "ucl/gui/StyledWidget.h"
-#include "ucl/gui/Layout.h"
-
-#include "types.h"
-
-namespace gallery {
-
-       constexpr ucl::SmartEvent IMAGE_VIEWER_ZOOM_END {"gallery,zoom,end"};
-
-       UCL_DECLARE_REF_ALIASES(ImageViewer);
-
-       class ImageViewer final : public ucl::ElmWidget {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setHighResImagePath(std::string path);
-                       Builder &setLoadSize(int value);
-                       Builder &setForceLoad(bool value);
-                       ImageViewerSRef build(ucl::ElmWidget &parent) const;
-               private:
-                       std::string m_highResPath;
-                       int m_loadSize;
-                       bool m_forceLoad;
-               };
-
-       public:
-               void setLowResImagePath(const std::string &path);
-               bool zoomIn(int originX, int originY);
-               bool zoomOut();
-
-               bool isZooming() const;
-               bool isZoomedIn() const;
-               bool isZoomedOut() const;
-
-       private:
-               friend class ucl::ReffedObj<ImageViewer>;
-               ImageViewer(ucl::IRefCountObj &rc, Evas_Object *scroller,
-                               const std::string &highResPath, int loadSize, bool forceLoad);
-               virtual ~ImageViewer();
-
-               void prepare(const std::string &highResPath,
-                               int loadSize, bool forceLoad);
-
-               void onImagePreloaded(ucl::Widget &widget, void *eventInfo);
-               void onScrollerResize(ucl::Widget &widget, void *eventInfo);
-
-               bool updateScrollerSize();
-               void updateScales();
-               void updateGridSize();
-               void updateScrollOffset();
-
-               void calcZoomInFactors(int originX, int originY);
-               void calcZoomOutFactors();
-               void startAnimation();
-
-               Eina_Bool onAnimationStartTimer();
-               Eina_Bool onAnimationFrame(double pos);
-
-       private:
-               enum class State {
-                       ZOOMED_OUT,
-                       ZOOMED_IN,
-                       ZOOMING_OUT,
-                       ZOOMING_IN
-               };
-
-       private:
-               ucl::StyledWidget *m_scroller;
-               ucl::Layout m_layout;
-               ucl::Widget m_grid;
-               ucl::Widget m_lowResImage;
-               ucl::Widget m_highResImage;
-
-               int m_imageW;
-               int m_imageH;
-
-               int m_scrollerW;
-               int m_scrollerH;
-               int m_gridW;
-               int m_gridH;
-               double m_scale0;
-               double m_scale1;
-
-               double m_xf1;
-               double m_yf1;
-               double m_xf2;
-               double m_yf2;
-               double m_zoom;
-
-               Ecore_Timer *m_animationStartTimer;
-               Ecore_Animator *m_animator;
-               State m_state;
-       };
-}
-
-#endif // __GALLERY_VIEW_IMAGE_VIEWER_H__
diff --git a/inc/gallery/view/PageContent.h b/inc/gallery/view/PageContent.h
deleted file mode 100644 (file)
index 85a6c59..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_VIEW_PAGE_CONTENT_H__
-#define __GALLERY_VIEW_PAGE_CONTENT_H__
-
-#include "ucl/gui/Layout.h"
-
-#include "types.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(PageContent);
-
-       class PageContent final : public ucl::ElmWidget {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setFlags(int flags);
-                       PageContentSRef build(ucl::ElmWidget &parent) const;
-               private:
-                       int m_flags;
-               };
-
-               enum {
-                       FLAG_MORE_OPTIONS = 1,
-                       FLAG_SELECT_BUTTON = 2,
-                       FLAG_BOTTOM_BUTTON = 4,
-
-                       FLAGS_SELECT_MODE = (FLAG_SELECT_BUTTON | FLAG_BOTTOM_BUTTON),
-                       FLAGS_ALL = (FLAG_MORE_OPTIONS | FLAGS_SELECT_MODE)
-               };
-
-               enum class Part {
-                       DEFAULT,
-                       OVERLAY,
-                       MORE_OPTIONS,
-                       SELECT_BUTTON,
-                       BOTTOM_BUTTON
-               };
-
-       public:
-               ucl::Result set(Evas_Object *eo, Part part = Part::DEFAULT);
-               Evas_Object *unset(Part part = Part::DEFAULT);
-
-               Evas_Object *get(Part part = Part::DEFAULT) const;
-
-               ucl::Result setSelectButtonVisible(bool visible);
-               ucl::Result setMoreOptionsVisible(bool visible);
-
-       private:
-               friend class ucl::ReffedObj<PageContent>;
-               PageContent(ucl::IRefCountObj &rc,
-                               const ucl::LayoutSRef &layout, int flags);
-               virtual ~PageContent();
-
-               void prepare(int flags);
-
-               template <class FUNC>
-               ucl::Result doWithPart(Part part, FUNC &&func) const;
-
-               ucl::Layout *getTopLayout() const;
-
-       private:
-               ucl::Layout *m_mainLayout;
-               ucl::LayoutSRef m_selectMode;
-               ucl::LayoutSRef m_bottomButton;
-       };
-}
-
-#endif // __GALLERY_VIEW_PAGE_CONTENT_H__
diff --git a/inc/gallery/view/TouchParser.h b/inc/gallery/view/TouchParser.h
deleted file mode 100644 (file)
index be391a3..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_VIEW_TOUCH_PARSER_H__
-#define __GALLERY_VIEW_TOUCH_PARSER_H__
-
-#include "ucl/gui/Widget.h"
-
-#include "types.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(TouchParser);
-
-       class TouchParser final : public ucl::RefCountAware {
-       public:
-               using TapHandler = ucl::WeakDelegate<void(int x, int y)>;
-
-       private:
-               friend class ucl::ReffedObj<TouchParser>;
-               TouchParser(ucl::IRefCountObj &rc, ucl::Widget &eventSource);
-               virtual ~TouchParser();
-
-       public:
-               void setTapHandler(const TapHandler &handler);
-               void setDoubleTapHandler(const TapHandler &handler);
-               void setTapAndHoldHandler(const TapHandler &handler);
-
-       private:
-               void onMouseDown(ucl::Widget &widget, void *eventInfo);
-               void onMouseUp(ucl::Widget &widget, void *eventInfo);
-               void onMouseMove(ucl::Widget &widget, void *eventInfo);
-
-               void updateIsTapPossible(int flags, int curX, int curY);
-
-               bool isFastTap(ucl::UInt curTime, int curX, int curY) const;
-               double calcDownDistance(int curX, int curY) const;
-
-               void restartHoldTimer();
-               void stopHoldTimer();
-               Eina_Bool onHoldTimer();
-
-       private:
-               TapHandler m_tapHandler;
-               TapHandler m_doubleTapHandler;
-               TapHandler m_tapAndHoldHandler;
-               Ecore_Timer *m_holdTimer;
-               ucl::UInt m_downTime;
-               int m_downX;
-               int m_downY;
-               int m_tapCounter;
-               bool m_isMouseDown;
-               bool m_isTapPossible;
-       };
-}
-
-#endif // __GALLERY_VIEW_TOUCH_PARSER_H__
diff --git a/inc/gallery/view/helpers.h b/inc/gallery/view/helpers.h
deleted file mode 100644 (file)
index 5a13ab4..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_VIEW_HELPERS_H__
-#define __GALLERY_VIEW_HELPERS_H__
-
-#include "ucl/gui/Naviframe.h"
-
-#include "types.h"
-
-namespace gallery { namespace util {
-
-       ucl::Result createCircleSurface(ucl::Naviframe &navi);
-       Eext_Circle_Surface *getCircleSurface(const ucl::ElmWidget &widget);
-
-       ucl::ElmWidgetSRef createFakeAccessObject(ucl::ElmWidget &parent);
-}}
-
-namespace gallery {
-
-       void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
-       void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
-
-       ucl::LayoutTheme getImageTheme(const char *fileName);
-
-       Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo);
-}
-
-#endif // __GALLERY_VIEW_HELPERS_H__
diff --git a/inc/gallery/view/types.h b/inc/gallery/view/types.h
deleted file mode 100644 (file)
index 35b0594..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_VIEW_TYPES_H__
-#define __GALLERY_VIEW_TYPES_H__
-
-#include <efl_extension.h>
-
-#include "ucl/gui/types.h"
-
-#include "gallery/types.h"
-
-#endif // __GALLERY_VIEW_TYPES_H__
index 405f2c56e53c5cd914e189858598e95846e95f4a..d779955d0706b076d9b5ab04e2036adf2e5292d4 100644 (file)
@@ -1,6 +1,6 @@
 \r
 # Project Name\r
-APPNAME = gallery\r
+APPNAME = w-gallery\r
 \r
 # Project Type\r
 type = app\r
@@ -9,7 +9,7 @@ type = app
 profile = wearable-4.0\r
 \r
 # C/CPP Sources\r
-USER_SRCS = ucl/src/gui/NaviItem.cpp src/resources.cpp ucl/src/gui/Layout.cpp src/model/Gallery.cpp src/presenters/ThumbnailPage.cpp ucl/src/misc/Timeout.cpp src/view/PageContent.cpp src/presenters/ViewerPage.cpp ucl/src/appfw/UIApp.cpp src/model/MediaItem.cpp ucl/src/gui/ElmWidget.cpp ucl/src/appfw/helpers.cpp src/presenters/SelectModePresenter.cpp ucl/src/gui/EdjeWidget.cpp src/model/helpers.cpp src/view/ImageViewer.cpp src/presenters/AtspiHighlightHelper.cpp src/view/TouchParser.cpp ucl/src/gui/Window.cpp ucl/src/gui/Widget.cpp ucl/src/util/types/Result.cpp src/model/SoundManager.cpp ucl/src/mvp/ListItemPresenter.cpp src/model/GalleryAlbum.cpp ucl/src/mvp/ListPresenter.cpp src/presenters/Instance.cpp ucl/src/misc/Variant.cpp src/main.cpp src/presenters/InstanceManager.cpp src/presenters/AlertDialog.cpp src/model/BaseJob.cpp ucl/src/appfw/InstanceManagerBase.cpp src/presenters/VideoPlayerPage.cpp ucl/src/util/logging.cpp ucl/src/appfw/SysEventProvider.cpp src/view/helpers.cpp src/presenters/MoreOptionsPresenter.cpp src/presenters/PreviewPage.cpp ucl/src/mvp/GuiPresenter.cpp src/presenters/NoContentPage.cpp ucl/src/gui/Genlist.cpp src/presenters/ProcessingPresenter.cpp ucl/src/gui/Naviframe.cpp src/presenters/Dialog.cpp src/presenters/Page.cpp src/view/ImageGrid.cpp src/presenters/helpers.cpp ucl/src/gui/WidgetItem.cpp \r
+USER_SRCS = gallery/presenters/Instance.cpp ucl/source/mvp/GuiPresenter.cpp gallery/presenters/pages/ThumbnailPage.cpp ucl/source/appfw/InstanceManagerBase.cpp gallery/presenters/InstanceManager.cpp gallery/presenters/misc/SelectModePresenter.cpp ucl/source/util/logging.cpp gallery/resources.cpp gallery/presenters/pages/ViewerPage.cpp gallery/presenters/misc/MoreOptionsPresenter.cpp gallery/presenters/misc/AtspiHighlightHelper.cpp ucl/source/mvp/ListPresenter.cpp gallery/model/SoundManager.cpp ucl/source/misc/Variant.cpp gallery/presenters/base/Dialog.cpp ucl/source/misc/Timeout.cpp gallery/presenters/misc/ProcessingPresenter.cpp ucl/source/util/types/Result.cpp gallery/model/impl/GalleryAlbum.cpp gallery/presenters/misc/helpers.cpp ucl/source/gui/Genlist.cpp gallery/presenters/pages/NoContentPage.cpp gallery/view/ImageViewer.cpp gallery/presenters/pages/PreviewPage.cpp gallery/view/PageContent.cpp gallery/view/TouchParser.cpp ucl/source/gui/WidgetItem.cpp gallery/presenters/dialogs/AlertDialog.cpp gallery/model/Gallery.cpp gallery/model/impl/helpers.cpp ucl/source/gui/Naviframe.cpp ucl/source/appfw/UIApp.cpp ucl/source/appfw/SysEventProvider.cpp gallery/presenters/pages/VideoPlayerPage.cpp gallery/main.cpp ucl/source/gui/Layout.cpp gallery/presenters/base/Page.cpp gallery/model/MediaItem.cpp gallery/view/helpers.cpp ucl/source/gui/Window.cpp ucl/source/gui/Widget.cpp gallery/model/impl/BaseJob.cpp ucl/source/mvp/ListItemPresenter.cpp ucl/source/gui/NaviItem.cpp ucl/source/gui/ElmWidget.cpp gallery/view/ImageGrid.cpp ucl/source/appfw/helpers.cpp ucl/source/gui/EdjeWidget.cpp \r
 \r
 # EDC Sources\r
 USER_EDCS =  \r
@@ -36,7 +36,7 @@ USER_OBJS =
 USER_C_INC_DIRS = \r
 USER_INC_FILES = \r
 ## C++ Compiler\r
-USER_CPP_INC_DIRS = inc ucl/inc \r
+USER_CPP_INC_DIRS = . ucl/include \r
 USER_CPP_INC_FILES = \r
 \r
 USER_INC_DIRS = $(USER_C_INC_DIRS) $(USER_CPP_INC_DIRS)\r
index ceb51c9957c445f76e8330490254881758efe12b..6aa29e92bf87ba56b5766c717380c1b2fbdba152 100644 (file)
@@ -34,10 +34,5 @@ collections {
       }
    }
 
-   #include "../../edc/colors.h"
-   #include "../../edc/images.edc"
-   #include "../../edc/image-grid.edc"
-   #include "../../edc/button.edc"
-   #include "../../edc/layouts.edc"
-   #include "../../edc/naviframe.edc"
+   #include "../../edc/includes.h"
 }
diff --git a/src/common.h b/src/common.h
deleted file mode 100644 (file)
index 659c330..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_COMMON_H__
-#define __GALLERY_COMMON_H__
-
-#include <algorithm>
-
-#include "ucl/util/helpers.h"
-#include "ucl/util/logging.h"
-#include "ucl/util/shortLogs.h"
-
-#undef UCL_LOG_TAG
-#define UCL_LOG_TAG GALLERY_LOG_TAG
-
-#include "helpers.h"
-
-namespace gallery {
-
-       using ucl::UInt;
-
-       using ucl::Result;
-       using ucl::RES_OK;
-       using ucl::RES_FALSE;
-       using ucl::RES_FAIL;
-       using ucl::RES_INVALID_ARGUMENTS;
-       using ucl::RES_ILLEGAL_STATE;
-       using ucl::RES_NOT_SUPPORTED;
-       using ucl::RES_IO_ERROR;
-       using ucl::RES_INVALID_DATA;
-       using ucl::RES_FATAL;
-
-       using ucl::isEmpty;
-       using ucl::isNotEmpty;
-       using ucl::toEina;
-
-       using ucl::ReffedObj;
-       using ucl::IRefCountObj;
-       using ucl::SharedRef;
-       using ucl::WeakRef;
-
-       using ucl::makeShared;
-       using ucl::dynamicRefCast;
-
-       namespace util {
-
-               using ucl::util::makeUnique;
-               using ucl::util::dispose;
-       }
-}
-
-#endif // __GALLERY_COMMON_H__
diff --git a/src/helpers.h b/src/helpers.h
deleted file mode 100644 (file)
index 5dd0d63..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_HELPERS_H__
-#define __GALLERY_HELPERS_H__
-
-#include "gallery/types.h"
-
-namespace gallery { namespace util {
-
-       template <class GETTER, class V, class ...ARGS>
-       ucl::Result get(GETTER &&getter, V &result, ARGS &&...args);
-
-       template <class GETTER, class V, class ...ARGS>
-       ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args);
-
-       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"
-
-#endif // __GALLERY_HELPERS_H__
diff --git a/src/helpers.hpp b/src/helpers.hpp
deleted file mode 100644 (file)
index 5bca4c7..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/helpers.h"
-#include "ucl/util/logging.h"
-
-namespace gallery { namespace util { namespace himpl {
-
-       template <class GETTER, class ...ARGS>
-       inline ucl::Result get(GETTER &&getter, bool optional,
-                       std::string &result, ARGS &&...args)
-       {
-               char *value = nullptr;
-               const int ret = getter(std::forward<ARGS>(args)..., &value);
-               if ((ret != 0) || (!optional && ucl::isEmpty(value))) {
-                       UCL_ELOG("get() failed: %d", ret);
-                       return ucl::RES_FAIL;
-               }
-
-               if (value) {
-                       result = value;
-                       free(value);
-               } else {
-                       result.clear();
-               }
-
-               return ucl::RES_OK;
-       }
-
-       template <class GETTER, class V, class ...ARGS>
-       inline ucl::Result get(GETTER &&getter, bool optional,
-                       V &result, ARGS &&...args)
-       {
-               typename std::remove_pointer<decltype(&result)>::type value = {};
-
-               const int ret = getter(std::forward<ARGS>(args)..., &value);
-               if ((ret != 0) || (!optional && !value)) {
-                       UCL_ELOG("get() failed: %d", ret);
-                       return ucl::RES_FAIL;
-               }
-
-               result = value;
-
-               return ucl::RES_OK;
-       }
-}}}
-
-namespace gallery { namespace util {
-
-       template <class GETTER, class V, class ...ARGS>
-       inline ucl::Result get(GETTER &&getter, V &result, ARGS &&...args)
-       {
-               return himpl::get(std::forward<GETTER>(getter), true,
-                               result, std::forward<ARGS>(args)...);
-       }
-
-       template <class GETTER, class V, class ...ARGS>
-       inline ucl::Result getNz(GETTER &&getter, V &result, ARGS &&...args)
-       {
-               return himpl::get(std::forward<GETTER>(getter), false,
-                               result, std::forward<ARGS>(args)...);
-       }
-
-       template <class FUNC, class ...ARGS>
-       inline ucl::Result call(FUNC &&func, ARGS &&...args)
-       {
-               const int ret = func(std::forward<ARGS>(args)...);
-               if (ret != 0) {
-                       UCL_ELOG("func() failed: %d", ret);
-                       return ucl::RES_FAIL;
-               }
-               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/main.cpp b/src/main.cpp
deleted file mode 100644 (file)
index 826f6c3..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/appfw/UIApp.h"
-
-#include "gallery/presenters/InstanceManager.h"
-
-#include "common.h"
-
-using ucl::UIApp;
-using gallery::InstanceManager;
-
-int main(int argc, char *argv[])
-{
-       InstanceManager mgr;
-       const int ret = UIApp(mgr).run(argc, argv);
-       ILOG("ret: %d", ret);
-       return ret;
-}
diff --git a/src/model/BaseJob.cpp b/src/model/BaseJob.cpp
deleted file mode 100644 (file)
index 1a358fb..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "BaseJob.h"
-
-#include <Ecore.h>
-
-#include "common.h"
-
-namespace gallery {
-
-       BaseJob::BaseJob(const NotiHandler &onComplete,
-                       const bool isCancelable) :
-               m_onComplete(onComplete),
-               m_isCancelable(isCancelable),
-               m_result(RES_ILLEGAL_STATE),
-               m_selfPtr(new BaseJob *(this)),
-               m_isCancelled(0)
-       {
-       }
-
-       BaseJob::~BaseJob()
-       {
-               finish();
-       }
-
-       Result BaseJob::prepare()
-       {
-               if (!m_thread.start(
-                       [this]()
-                       {
-                               m_result = execute();
-                               notifyCompleteAsync();
-                       }
-                       )) {
-                       LOG_RETURN(RES_FAIL, "m_thread->start() failed!");
-               }
-               return RES_OK;
-       }
-
-       Result BaseJob::getResult() const
-       {
-               if (!m_thread.wasJoinded()) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "Job is not complete!");
-               }
-               return m_result;
-       }
-
-       bool BaseJob::isCancelable() const
-       {
-               return m_isCancelable;
-       }
-
-       Result BaseJob::cancel()
-       {
-               if (!m_isCancelable) {
-                       LOG_RETURN(RES_NOT_SUPPORTED, "Not cancelable!");
-               }
-               if (isCancelled()) {
-                       return RES_FALSE;
-               }
-               m_isCancelled.store(true);
-               return RES_OK;
-       }
-
-       bool BaseJob::isCancelled() const
-       {
-               return m_isCancelled.load();
-       }
-
-       void BaseJob::notifyCompleteAsync()
-       {
-               ecore_main_loop_thread_safe_call_async(
-                       [](void *data)
-                       {
-                               const auto selfPtr = static_cast<BaseJob **>(data);
-                               const auto self = *selfPtr;
-                               delete selfPtr;
-                               if (self) {
-                                       self->m_selfPtr = nullptr;
-                                       self->finish();
-                               }
-                       },
-                       m_selfPtr);
-       }
-
-       void BaseJob::finish()
-       {
-               if (!m_thread.wasJoinded()) {
-                       m_thread.join();
-                       if (m_selfPtr) {
-                               *m_selfPtr = nullptr;
-                       }
-                       if (m_onComplete) {
-                               m_onComplete();
-                       }
-               }
-       }
-}
diff --git a/src/model/BaseJob.h b/src/model/BaseJob.h
deleted file mode 100644 (file)
index 5b12d54..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_BASE_JOB_H__
-#define __GALLERY_MODEL_BASE_JOB_H__
-
-#include <atomic>
-
-#include "ucl/util/threading/Thread.h"
-
-#include "gallery/model/IJob.h"
-
-namespace gallery {
-
-       class BaseJob : public IJob {
-       public:
-               // IJob //
-
-               virtual ucl::Result getResult() const final override;
-               virtual bool isCancelable() const final override;
-               virtual ucl::Result cancel() final override;
-
-       protected:
-               BaseJob(const NotiHandler &onComplete,
-                               bool isCancelable);
-               virtual ~BaseJob();
-
-               ucl::Result prepare();
-
-               bool isCancelled() const;
-
-               virtual ucl::Result execute() = 0;
-
-       private:
-               void notifyCompleteAsync();
-               void finish();
-
-       private:
-               const NotiHandler m_onComplete;
-               const bool m_isCancelable;
-               ucl::Thread m_thread;
-               ucl::Result m_result;
-               BaseJob **m_selfPtr;
-               std::atomic_int m_isCancelled;
-       };
-}
-
-#endif // __GALLERY_MODEL_BASE_JOB_H__
diff --git a/src/model/Gallery.cpp b/src/model/Gallery.cpp
deleted file mode 100644 (file)
index ad7c1c1..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/model/Gallery.h"
-
-#include "GalleryAlbum.h"
-
-#include "common.h"
-
-namespace gallery {
-
-       Gallery::Gallery() :
-               m_isMediaDbConnected(false)
-       {
-       }
-
-       Gallery::~Gallery()
-       {
-               if (m_isMediaDbConnected) {
-                       releaseMediaDbConnection();
-               }
-       }
-
-       GallerySRef Gallery::newInstance()
-       {
-               auto result = makeShared<Gallery>();
-               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-               return result;
-       }
-
-       Result Gallery::prepare()
-       {
-               FAIL_RETURN(acquireMediaDbConnection(),
-                               "acquireMediaDbConnection() failed!");
-
-               m_isMediaDbConnected = true;
-
-               m_album = GalleryAlbum::newInstance();
-               if (!m_album) {
-                       LOG_RETURN(RES_FAIL, "GalleryAlbum::newInstance() failed!");
-               }
-
-               return RES_OK;
-       }
-
-       IMediaAlbumSRef Gallery::getAlbum()
-       {
-               return m_album;
-       }
-}
diff --git a/src/model/GalleryAlbum.cpp b/src/model/GalleryAlbum.cpp
deleted file mode 100644 (file)
index fbe2ad6..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "GalleryAlbum.h"
-
-// Including next header in order to use: getpid().
-#include <unistd.h>
-
-#include "ucl/misc/TString.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       using ucl::TString;
-
-       const auto CONDITION = TString("%s=%d").format(
-                       MEDIA_TYPE, MEDIA_CONTENT_TYPE_IMAGE);
-
-       constexpr auto UPDATE_IDLE_TIMEOUT_SEC = 0.1;
-}}}
-
-namespace gallery {
-
-       using ucl::MutexLock;
-
-       GalleryAlbum::GalleryAlbum() :
-               m_pid(getpid()),
-               m_filter(nullptr),
-               m_noti(),
-               m_updateTimer(nullptr),
-               m_isValid(false)
-       {
-       }
-
-       GalleryAlbum::~GalleryAlbum()
-       {
-               stopUpdateTimer();
-               if (m_noti) {
-                       media_content_remove_db_updated_cb(m_noti);
-               }
-               if (m_filter) {
-                       const int ret = media_filter_destroy(m_filter);
-                       if (ret != 0) {
-                               WLOG("media_filter_destroy() failed: %d", ret);
-                       }
-               }
-       }
-
-       GalleryAlbumSRef GalleryAlbum::newInstance()
-       {
-               auto result = makeShared<GalleryAlbum>();
-               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-               return result;
-       }
-
-       Result GalleryAlbum::prepare()
-       {
-               int ret = 0;
-
-               ret = media_content_add_db_updated_cb(
-                               CALLBACK_B(GalleryAlbum::onContentDbUpdate), this, &m_noti);
-               if (ret != 0) {
-                       m_noti = {};
-                       LOG_RETURN(RES_FAIL,
-                                       "media_content_add_db_updated_cb() failed: %d", ret);
-               }
-
-               ret = media_filter_create(&m_filter);
-               if (ret != 0) {
-                       ELOG("media_filter_create() failed: %d", ret);
-                       m_filter = nullptr;
-                       return RES_FAIL;
-               }
-
-               ret = media_filter_set_condition(m_filter, impl::CONDITION.c_str(),
-                               MEDIA_CONTENT_COLLATE_DEFAULT);
-               if (ret != 0) {
-                       ELOG("media_filter_set_condition() failed: %d", ret);
-                       return RES_FAIL;
-               }
-
-               ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC,
-                               MEDIA_ADDED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
-               if (ret != 0) {
-                       ELOG("media_filter_set_order() failed: %d", ret);
-                       return RES_FAIL;
-               }
-
-               FAIL_RETURN(update(), "update() failed!");
-
-               return RES_OK;
-       }
-
-       void GalleryAlbum::onContentDbUpdate(
-                       media_content_error_e error, int pid,
-                       media_content_db_update_item_type_e update_item,
-                       media_content_db_update_type_e update_type,
-                       media_content_type_e media_type,
-                       char *uuid, char *path, char *mime_type)
-       {
-               if ((update_item == MEDIA_ITEM_FILE) &&
-                               (media_type == MEDIA_CONTENT_TYPE_IMAGE) &&
-                               ((pid != m_pid) || (update_type != MEDIA_CONTENT_DELETE))) {
-                       if (!resetUpdateTimer()) {
-                               update();
-                       }
-               }
-       }
-
-       bool GalleryAlbum::resetUpdateTimer()
-       {
-               stopUpdateTimer();
-
-               m_updateTimer = ecore_timer_add(impl::UPDATE_IDLE_TIMEOUT_SEC,
-                               CALLBACK_A(GalleryAlbum::onUpdateTimer), this);
-               if (!m_updateTimer) {
-                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
-               }
-
-               return true;
-       }
-
-       void GalleryAlbum::stopUpdateTimer()
-       {
-               if (m_updateTimer) {
-                       ecore_timer_del(m_updateTimer);
-                       m_updateTimer = nullptr;
-               }
-       }
-
-       Eina_Bool GalleryAlbum::onUpdateTimer()
-       {
-               m_updateTimer = nullptr;
-
-               update();
-
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       Result GalleryAlbum::update()
-       {
-               stopUpdateTimer();
-
-               MediaItems newItems;
-
-               {
-                       MutexLock lock(getMediaMutex());
-
-                       const int ret = media_info_foreach_media_from_db(m_filter,
-                               [](media_info_h media, void *user_data)
-                               {
-                                       MediaItems &newItems =
-                                                       (*static_cast<MediaItems *>(user_data));
-                                       auto item = MediaItem::newInstance(media);
-                                       if (!item) {
-                                               ELOG("MediaItem::newInstance() failed! Skipping");
-                                               return true;
-                                       }
-                                       newItems.emplace_back(std::move(item));
-                                       return true;
-                               },
-                               &newItems);
-
-                       if (ret != 0) {
-                               ELOG("media_info_foreach_media_from_db() failed: %d", ret);
-                               return RES_FAIL;
-                       }
-               }
-
-               swap(newItems, m_items);
-               m_isValid = true;
-
-               m_onChange.dispatch();
-
-               return RES_OK;
-       }
-
-       void GalleryAlbum::addChangeHandler(const NotiHandler &handler)
-       {
-               m_onChange += handler;
-       }
-
-       void GalleryAlbum::delChangeHandler(const NotiHandler &handler)
-       {
-               m_onChange -= handler;
-       }
-
-       Result GalleryAlbum::forEachMedia(EachCb cb) const
-       {
-               if (!m_isValid) {
-                       LOG_RETURN(RES_INVALID_DATA, "m_isValid: false;");
-               }
-
-               for (auto item: m_items) {
-                       if (!item->isValid()) {
-                               WLOG("Fragmented!");
-                       } else if (!cb(std::move(item))) {
-                               break;
-                       }
-               }
-
-               return RES_OK;
-       }
-
-       Result GalleryAlbum::getMediaCount(int &count) const
-       {
-               if (!m_isValid) {
-                       LOG_RETURN(RES_INVALID_DATA, "m_isValid: false;");
-               }
-
-               count = m_items.size();
-
-               return RES_OK;
-       }
-
-       void GalleryAlbum::defragment()
-       {
-               if (!m_isValid) {
-                       LOG_RETURN_VOID(RES_INVALID_DATA, "m_isValid: false;");
-               }
-
-               const auto newEnd = std::remove_if(
-                       m_items.begin(), m_items.end(),
-                       [](const MediaItemSRef &item)
-                       {
-                               return !item->isValid();
-                       });
-
-               if (newEnd != m_items.end()) {
-                       m_items.erase(newEnd, m_items.end());
-                       m_onChange.dispatch();
-               }
-       }
-}
diff --git a/src/model/GalleryAlbum.h b/src/model/GalleryAlbum.h
deleted file mode 100644 (file)
index 715b708..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_GALLERY_ALBUM_H__
-#define __GALLERY_MODEL_GALLERY_ALBUM_H__
-
-#include <vector>
-
-#include <Ecore.h>
-
-#include "ucl/misc/Event.h"
-
-#include "gallery/model/IMediaAlbum.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(GalleryAlbum);
-
-       class GalleryAlbum final : public IMediaAlbum {
-       public:
-               static GalleryAlbumSRef newInstance();
-               virtual ~GalleryAlbum();
-
-               // IMediaAlbum //
-
-               virtual void addChangeHandler(
-                               const NotiHandler &handler) final override;
-               virtual void delChangeHandler(
-                               const NotiHandler &handler) final override;
-
-               virtual ucl::Result forEachMedia(EachCb cb) const final override;
-               virtual ucl::Result getMediaCount(int &count) const final override;
-
-               virtual void defragment() final override;
-
-       private:
-               friend class ucl::ReffedObj<GalleryAlbum>;
-               GalleryAlbum();
-
-               ucl::Result prepare();
-
-               ucl::Result update();
-
-               bool resetUpdateTimer();
-               void stopUpdateTimer();
-
-               void onContentDbUpdate(
-                               media_content_error_e error, int pid,
-                               media_content_db_update_item_type_e update_item,
-                               media_content_db_update_type_e update_type,
-                               media_content_type_e media_type,
-                               char *uuid, char *path, char *mime_type);
-
-               Eina_Bool onUpdateTimer();
-
-       private:
-               const int m_pid;
-               filter_h m_filter;
-               media_content_noti_h m_noti;
-               Ecore_Timer *m_updateTimer;
-               ucl::Event<NotiHandler> m_onChange;
-               MediaItems m_items;
-               bool m_isValid;
-       };
-}
-
-#endif // __GALLERY_MODEL_GALLERY_ALBUM_H__
diff --git a/src/model/MediaItem.cpp b/src/model/MediaItem.cpp
deleted file mode 100644 (file)
index c20148a..0000000
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/model/MediaItem.h"
-
-#include <Ecore_File.h>
-#include <storage.h>
-#include <mime_type.h>
-
-#include "BaseJob.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       using ucl::AutoHandle;
-
-       const std::string MIME_PREFIX_IMAGE {"image/"};
-       const std::string MIME_PREFIX_VIDEO {"video/"};
-       const std::string URI_PREFIX_FILE {"file://"};
-
-       using AutoImageMeta = AutoHandle<image_meta_h, int, image_meta_destroy>;
-
-       MediaType getFileMediaType(const std::string &filePath)
-       {
-               const auto ext = util::extractFileExtension(filePath);
-
-               std::string mime;
-               FAIL_RETURN_VALUE(util::get(mime_type_get_mime_type, mime, ext.c_str()),
-                               MediaType::OTHERS,
-                               "mime_type_get_mime_type() failed!");
-
-               if (util::beginsWith(mime, MIME_PREFIX_IMAGE)) {
-                       return MediaType::IMAGE;
-               }
-               if (util::beginsWith(mime, MIME_PREFIX_VIDEO)) {
-                       return MediaType::VIDEO;
-               }
-
-               return MediaType::OTHERS;
-       }
-
-       // Temp function until ecore_file_cp() fix.
-       Result copyFile(const std::string &src, const std::string &dst)
-       {
-               FILE *f1 = fopen(src.c_str(), "rb");
-               if (!f1) {
-                       LOG_RETURN(RES_IO_ERROR, "fopen(rb) failed!");
-               }
-
-               FILE *f2 = fopen(dst.c_str(), "wb");
-               if (!f2) {
-                       fclose(f1);
-                       LOG_RETURN(RES_IO_ERROR, "fopen(wb) failed!");
-               }
-
-               bool badCopy = false;
-
-               constexpr auto COPY_BUF_SIZE = 16384;
-               char buf[COPY_BUF_SIZE];
-               while (!feof(f1)) {
-                       const auto num = fread(buf, 1, sizeof(buf), f1);
-                       if (num == 0) {
-                               badCopy = true;
-                               LOG_BREAK(RES_IO_ERROR, "fread() failed!");
-                       }
-                       if (fwrite(buf, 1, num, f2) != num) {
-                               badCopy = true;
-                               LOG_BREAK(RES_IO_ERROR, "fwrite() failed!");
-                       }
-               }
-
-               fclose(f1);
-               fclose(f2);
-
-               if (badCopy) {
-                       const int r = remove(dst.c_str());
-                       if (r != 0) {
-                               WLOG("remove() failed: %d;", r);
-                       }
-                       return RES_IO_ERROR;
-               }
-
-               return RES_OK;
-       }
-}}}
-
-namespace gallery {
-
-       using ucl::MutexLock;
-
-       // MediaItem::Remover //
-
-       class MediaItem::Remover final : public BaseJob {
-       public:
-               friend class MediaItem::RemoverBuilder;
-               Remover(const NotiHandler &onComplete,
-                               const SharedRef<const MediaItems> &items) :
-                       BaseJob(onComplete, false),
-                       m_items(items)
-               {
-               }
-
-       protected:
-               // BaseJob //
-               virtual Result execute() final override
-               {
-                       Result result = RES_OK;
-
-                       MutexLock lock(getMediaMutex());
-
-                       for (auto &item: *m_items) {
-                               if (item) {
-                                       const Result tmpResult = item->removeFile();
-                                       if (isBad(tmpResult)) {
-                                               ELOG("item->removeFile() failed!");
-                                               if (isGood(result)) {
-                                                       result = tmpResult;
-                                               }
-                                       }
-                               } else {
-                                       ELOG("item is NULL!");
-                               }
-                       }
-
-                       return result;
-               }
-
-       private:
-               const SharedRef<const MediaItems> m_items;
-       };
-
-       // MediaItem::RemoverBuilder //
-
-       MediaItem::RemoverBuilder &MediaItem::RemoverBuilder::
-                       setItems(MediaItems items)
-       {
-               m_items = makeShared<MediaItems>(std::move(items));
-               return *this;
-       }
-
-       IJobSRef MediaItem::RemoverBuilder::build(
-                       const NotiHandler &onComplete) const
-       {
-               if (!onComplete) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "onComplete is NULL!");
-               }
-               if (isEmpty(m_items)) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!");
-               }
-
-               auto result = makeShared<Remover>(onComplete, m_items);
-
-               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-
-               return result;
-       }
-
-       // MediaItem::Saver //
-
-       class MediaItem::Saver final : public BaseJob {
-       public:
-               friend class MediaItem::SaverBuilder;
-               Saver(const NotiHandler &onComplete,
-                               const MediaItemSRef &item) :
-                       BaseJob(onComplete, false),
-                       m_item(item)
-               {
-               }
-
-       protected:
-               // BaseJob //
-               virtual Result execute() final override
-               {
-                       FAIL_RETURN(m_item->saveToDevice(),
-                                       "m_item->saveToDevice() failed!");
-                       return RES_OK;
-               }
-
-       private:
-               const MediaItemSRef m_item;
-       };
-
-       // MediaItem::SaverBuilder //
-
-       MediaItem::SaverBuilder &MediaItem::SaverBuilder::
-                       setItem(const MediaItemSRef &item)
-       {
-               m_item = item;
-               return *this;
-       }
-
-       IJobSRef MediaItem::SaverBuilder::build(
-                       const NotiHandler &onComplete) const
-       {
-               if (!onComplete) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "onComplete is NULL!");
-               }
-               if (!m_item) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_item is NULL!");
-               }
-
-               auto result = makeShared<Saver>(onComplete, m_item);
-
-               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
-
-               return result;
-       }
-
-       // MediaItem //
-
-       MediaItem::MediaItem(const int flags, const MediaType type) :
-               m_flags(flags),
-               m_type(type),
-               m_resolutionX(0),
-               m_resolutionY(0),
-               m_isValid(false)
-       {
-       }
-
-       MediaItem::~MediaItem()
-       {
-               cancelThumbnailPathGet();
-       }
-
-       MediaItemSRef MediaItem::newInstance(const media_info_h media)
-       {
-               media_content_type_e contentType = MEDIA_CONTENT_TYPE_OTHERS;
-               FAIL_RETURN_VALUE(util::get(media_info_get_media_type, contentType,
-                               media), {}, "media_info_get_media_type() failed!");
-
-               auto result = makeShared<MediaItem>(FLAGS_FROM_MEDIA_DB,
-                               toMediaType(contentType));
-
-               FAIL_RETURN_VALUE(result->prepare(media), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       MediaItemSRef MediaItem::newInstance(std::string filePath)
-       {
-               util::removePrefix(filePath, impl::URI_PREFIX_FILE);
-
-               auto result = makeShared<MediaItem>(FLAGS_SIMPLE_FILE,
-                               impl::getFileMediaType(filePath));
-
-               FAIL_RETURN_VALUE(result->prepare(std::move(filePath)), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       Result MediaItem::prepare(const media_info_h media)
-       {
-               FAIL_RETURN(initThumbPath(media), "initThumbPath() failed!");
-
-               if (isEmpty(m_thumbPath)) {
-                       media_info_h mediaClone = nullptr;
-                       FAIL_RETURN(util::call(media_info_clone, &mediaClone, media),
-                                       "media_info_clone() failed!");
-                       m_media = mediaClone;
-               }
-
-               FAIL_RETURN(util::getNz(media_info_get_media_id, m_mediaId, media),
-                               "media_info_get_media_id() failed!");
-
-               FAIL_RETURN(util::getNz(media_info_get_file_path, m_filePath, media),
-                               "media_info_get_file_path() failed!");
-
-               if (m_type == MediaType::IMAGE) {
-                       prepareImage(media);
-               }
-
-               m_isValid = true;
-
-               return RES_OK;
-       }
-
-       Result MediaItem::prepareImage(const media_info_h media)
-       {
-               impl::AutoImageMeta imageMeta;
-
-               FAIL_RETURN(util::getNz(media_info_get_image, imageMeta, media),
-                               "media_info_get_image() failed!");
-
-               FAIL_RETURN(util::getNz(image_meta_get_width, m_resolutionX,
-                               imageMeta), "image_meta_get_width() failed!");
-
-               FAIL_RETURN(util::getNz(image_meta_get_height, m_resolutionY,
-                               imageMeta), "image_meta_get_height() failed!");
-
-               media_content_orientation_e orientation =
-                               MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
-               FAIL_RETURN(util::get(image_meta_get_orientation, orientation,
-                               imageMeta), "image_meta_get_orientation() failed!");
-
-               switch (orientation) {
-               case MEDIA_CONTENT_ORIENTATION_TRANSPOSE:
-               case MEDIA_CONTENT_ORIENTATION_ROT_90:
-               case MEDIA_CONTENT_ORIENTATION_TRANSVERSE:
-               case MEDIA_CONTENT_ORIENTATION_ROT_270:
-                       std::swap(m_resolutionX, m_resolutionY);
-                       break;
-               default:
-                       break;
-               }
-
-               return RES_OK;
-       }
-
-       Result MediaItem::initThumbPath(const media_info_h media) const
-       {
-               FAIL_RETURN(util::get(media_info_get_thumbnail_path, m_thumbPath,
-                               media), "media_info_get_thumbnail_path() failed!");
-               return RES_OK;
-       }
-
-       Result MediaItem::prepare(std::string filePath)
-       {
-               m_filePath = std::move(filePath);
-               m_isValid = true;
-               return RES_OK;
-       }
-
-       bool MediaItem::isValid() const
-       {
-               return m_isValid;
-       }
-
-       int MediaItem::getFlags() const
-       {
-               return m_flags;
-       }
-
-       MediaType MediaItem::getType() const
-       {
-               return m_type;
-       }
-
-       const std::string &MediaItem::getId() const
-       {
-               return m_mediaId;
-       }
-
-       Result MediaItem::getResolution(int &x, int &y) const
-       {
-               if (!(m_flags & FLAG_RESOLUTION)) {
-                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
-               }
-
-               x = m_resolutionX;
-               y = m_resolutionY;
-
-               return RES_OK;
-       }
-
-       const std::string &MediaItem::getFilePath() const
-       {
-               return m_filePath;
-       }
-
-       Result MediaItem::removeFile()
-       {
-               if (!(m_flags & FLAG_REMOVE)) {
-                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
-               }
-
-               const bool exists = ecore_file_exists(m_filePath.c_str());
-
-               if (exists && !ecore_file_can_write(m_filePath.c_str())) {
-                       LOG_RETURN(RES_FAIL, "File can't be removed!");
-               }
-
-               {
-                       MutexLock lock(getMediaMutex());
-
-                       const int ret = media_info_delete_from_db(m_mediaId.c_str());
-                       if (ret != 0) {
-                               LOG_RETURN(RES_FAIL, "media_info_delete_from_db() failed: %d", ret);
-                       }
-
-                       m_media = nullptr;
-                       m_isValid = false;
-               }
-
-               if (exists && !ecore_file_remove(m_filePath.c_str())) {
-                       FLOG("ecore_file_remove() failed! Attempting to rescan....");
-                       MutexLock lock(getMediaMutex());
-                       const int ret = media_content_scan_file(m_filePath.c_str());
-                       if (ret != 0) {
-                               ELOG("media_content_scan_file() failed: %d", ret);
-                       }
-                       return RES_FATAL;
-               }
-
-               return RES_OK;
-       }
-
-       Result MediaItem::saveToDevice()
-       {
-               if (!(m_flags & FLAG_SAVE)) {
-                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
-               }
-
-               int storageId = 0;
-               FAIL_RETURN(getInternalStorageId(storageId),
-                               "getInternalStorageId() failed!");
-
-               std::string imagesDir;
-               FAIL_RETURN(util::getNz(storage_get_directory, imagesDir,
-                               storageId, STORAGE_DIRECTORY_IMAGES),
-                               "storage_get_directory() failed!");
-
-               const std::string savePath = util::makeUniqueFilePath(
-                               m_filePath, imagesDir);
-
-               FAIL_RETURN(impl::copyFile(m_filePath, savePath), "copyFile() failed!");
-
-               {
-                       MutexLock lock(getMediaMutex());
-                       FAIL_RETURN(acquireMediaDbConnection(),
-                                       "acquireMediaDbConnection() failed!");
-                       const int ret = media_content_scan_file(savePath.c_str());
-                       releaseMediaDbConnection();
-                       if (ret == 0) {
-                               return RES_OK;
-                       }
-                       ELOG("media_content_scan_file() failed: %d", ret);
-               }
-
-               if (!ecore_file_remove(savePath.c_str())) {
-                       WLOG("ecore_file_remove() failed!");
-               }
-
-               return RES_FAIL;
-       }
-
-       Result MediaItem::getThumbnailPath(const ThumbnailPathGetCb &cb) const
-       {
-               if (!(m_flags & FLAG_THUMBNAIL)) {
-                       LOG_RETURN(RES_NOT_SUPPORTED, "Operation not supported!");
-               }
-               if (!cb) {
-                       return RES_INVALID_ARGUMENTS;
-               }
-
-               if (isNotEmpty(m_thumbPath)) {
-                       cb(RES_OK, m_thumbPath);
-                       return RES_OK;
-               }
-
-               if (m_thumbCbProxy) {
-                       m_thumbCbProxy->callback = cb;
-                       return RES_FALSE;
-               }
-
-               auto cbProxy = util::makeUnique(new ThumbCbProxy{this, cb});
-
-               {
-                       MutexLock lock(getMediaMutex());
-
-                       FAIL_RETURN(util::call(media_info_create_thumbnail, m_media,
-                                       CALLBACK_B(ThumbCbProxy::completeCb), cbProxy.get()),
-                                       "media_info_create_thumbnail() failed!");
-               }
-
-               m_thumbCbProxy = std::move(cbProxy);
-
-               return RES_FALSE;
-       }
-
-       void MediaItem::cancelThumbnailPathGet() const
-       {
-               if (!m_thumbCbProxy) {
-                       return;
-               }
-
-               MutexLock lock(getMediaMutex());
-
-               const int ret = media_info_cancel_thumbnail(m_media);
-               if (ret != 0) {
-
-                       // XXX In this case complete callback will be called anyway
-                       // We need to report this issue to the platform
-                       m_thumbCbProxy->item = nullptr;
-                       m_thumbCbProxy.release();
-
-                       if (ret == MEDIA_CONTENT_ERROR_INVALID_OPERATION) {
-                               ILOG("Can't cancel. Thumbnail is already created.");
-                               FAIL_RETURN_VOID(initThumbPath(m_media),
-                                               "initThumbPath() failed!");
-                               return;
-                       }
-
-                       LOG_RETURN_VOID(RES_FAIL,
-                                       "media_info_cancel_thumbnail() failed: %d", ret);
-               }
-
-               m_thumbCbProxy.reset();
-       }
-
-       // ThumbCbProxy //
-
-       void MediaItem::ThumbCbProxy::completeCb(
-                       media_content_error_e error, const char *path)
-       {
-               if (!item) {
-                       delete this;
-                       return;
-               }
-
-               Result result = RES_OK;
-
-               if ((error != MEDIA_CONTENT_ERROR_NONE) || !path) {
-                       ELOG("Thumbnail generation failed: %d", error);
-                       result = RES_FAIL;
-               } else {
-                       item->m_thumbPath = path;
-                       item->m_media = nullptr;
-               }
-
-               const auto proxy = std::move(*item->m_thumbCbProxy);
-
-               item->m_thumbCbProxy.reset();
-
-               proxy.callback(result, proxy.item->m_thumbPath);
-       }
-}
diff --git a/src/model/SoundManager.cpp b/src/model/SoundManager.cpp
deleted file mode 100644 (file)
index 0d83a73..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/model/SoundManager.h"
-
-#include "common.h"
-
-namespace gallery {
-
-       SoundManagerSRef SoundManager::newInstance()
-       {
-               auto result = makeShared<SoundManager>();
-
-               FAIL_RETURN_VALUE(result->prepare(), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       SoundManager::SoundManager() :
-                       m_devConnChangedCbId(-1),
-                       m_devStateChangedCbId(-1),
-                       m_volumeChangedCbId(-1),
-                       m_currentMediaVolume(0),
-                       m_maxMediaVolume(0),
-                       m_isMediaDeviceReady(false)
-       {
-       }
-
-       SoundManager::~SoundManager()
-       {
-               if (m_devConnChangedCbId >= 0) {
-                       sound_manager_remove_device_connection_changed_cb(
-                                       m_devConnChangedCbId);
-               }
-               if (m_devStateChangedCbId >= 0) {
-                       sound_manager_remove_device_state_changed_cb(m_devStateChangedCbId);
-               }
-               if (m_volumeChangedCbId >= 0) {
-                       sound_manager_remove_volume_changed_cb(m_volumeChangedCbId);
-               }
-       }
-
-       Result SoundManager::prepare()
-       {
-               const int devMask = SOUND_DEVICE_ALL_MASK;
-
-               FAIL_RETURN(util::get(sound_manager_add_device_connection_changed_cb,
-                               m_devConnChangedCbId, devMask,
-                               CALLBACK_B(SoundManager::onDeviceConnectionChanged), this),
-                               "sound_manager_add_device_connection_changed_cb() failed!");
-
-               FAIL_RETURN(util::get(sound_manager_add_device_state_changed_cb,
-                               m_devStateChangedCbId, devMask,
-                               CALLBACK_B(SoundManager::onDeviceStateChanged), this),
-                               "sound_manager_add_device_state_changed_cb() failed!");
-
-               FAIL_RETURN(util::get(sound_manager_add_volume_changed_cb,
-                               m_volumeChangedCbId,
-                               CALLBACK_B(SoundManager::onVolumeChanged), this),
-                               "sound_manager_add_volume_changed_cb() failed!");
-
-               FAIL_RETURN(util::get(sound_manager_get_volume,
-                               m_currentMediaVolume, SOUND_TYPE_MEDIA),
-                               "sound_manager_get_max_volume() failed!");
-
-               FAIL_RETURN(util::get(sound_manager_get_max_volume,
-                               m_maxMediaVolume, SOUND_TYPE_MEDIA),
-                               "sound_manager_get_max_volume() failed!");
-
-               FAIL_RETURN(updateMediaDeviceState(),
-                               "updateMediaDeviceState() failed!");
-
-               return RES_OK;
-       }
-
-       bool SoundManager::isMediaDeviceReady() const
-       {
-               return m_isMediaDeviceReady;
-       }
-
-       int SoundManager::getCurrentMediaVolume() const
-       {
-               return m_currentMediaVolume;
-       }
-
-       int SoundManager::getMaxMediaVolume() const
-       {
-               return m_maxMediaVolume;
-       }
-
-       void SoundManager::addMediaDeviceStateChangeHandler(
-                       const NotiHandler &handler)
-       {
-               m_onMediaDeviceStateChange += handler;
-       }
-
-       void SoundManager::delMediaDeviceStateChangeHandler(
-                       const NotiHandler &handler)
-       {
-               m_onMediaDeviceStateChange -= handler;
-       }
-
-       void SoundManager::addMediaVolumeChangeHandler(const NotiHandler &handler)
-       {
-               m_onMediaVolumeChange += handler;
-       }
-
-       void SoundManager::delMediaVolumeChangeHandler(const NotiHandler &handler)
-       {
-               m_onMediaVolumeChange -= handler;
-       }
-
-       void SoundManager::setMediaDeviceState(const bool isReady)
-       {
-               if (isReady != m_isMediaDeviceReady) {
-                       m_isMediaDeviceReady = isReady;
-                       m_onMediaDeviceStateChange.dispatch();
-               }
-       }
-
-       void SoundManager::setCurrentMediaVolume(const int value)
-       {
-               if (value != m_currentMediaVolume) {
-                       m_currentMediaVolume = value;
-                       m_onMediaVolumeChange.dispatch();
-               }
-       }
-
-       Result SoundManager::updateMediaDeviceState()
-       {
-               sound_device_type_e devType = SOUND_DEVICE_BUILTIN_SPEAKER;
-               const int r = sound_manager_get_current_media_playback_device_type(
-                               &devType);
-               DLOG("devType: %d (r: %d);", devType, r);
-
-               switch (r) {
-               case 0:
-                       setMediaDeviceState(true);
-                       break;
-               case SOUND_MANAGER_ERROR_NO_DATA:
-                       setMediaDeviceState(false);
-                       break;
-               default:
-                       LOG_RETURN(RES_FAIL,
-                                       "sound_manager_get_current_media_playback_device_type() "
-                                       "failed: %d;", r);
-               }
-
-               return RES_OK;
-       }
-
-       void SoundManager::onDeviceConnectionChanged(sound_device_h device,
-                       bool isConnected)
-       {
-               updateMediaDeviceState();
-       }
-
-       void SoundManager::onDeviceStateChanged(sound_device_h device,
-                       sound_device_state_e state)
-       {
-               updateMediaDeviceState();
-       }
-
-       void SoundManager::onVolumeChanged(sound_type_e type, unsigned int volume)
-       {
-               if (type == SOUND_TYPE_MEDIA) {
-                       setCurrentMediaVolume(volume);
-               }
-       }
-}
diff --git a/src/model/common.h b/src/model/common.h
deleted file mode 100644 (file)
index 7581a14..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_COMMON_H__
-#define __GALLERY_MODEL_COMMON_H__
-
-#include "helpers.h"
-
-#include "../common.h"
-
-#endif // __GALLERY_MODEL_COMMON_H__
diff --git a/src/model/helpers.cpp b/src/model/helpers.cpp
deleted file mode 100644 (file)
index 9bf5042..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "helpers.h"
-
-#include <Ecore_File.h>
-#include <storage.h>
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr auto UNIQUE_PATH_RESERVE = 10;
-
-       int MEDIA_DB_CONNECTION_COUNTER = 0;
-}}}
-
-namespace gallery {
-
-       using ucl::Mutex;
-
-       Mutex &getMediaMutex()
-       {
-               static Mutex mutex{true};
-               return mutex;
-       }
-
-       Result getInternalStorageId(int &result)
-       {
-               struct StorageIdRec final {
-                       int id;
-                       bool valid;
-               } storageIdRec {0, false};
-
-               const int ret = storage_foreach_device_supported(
-                       [](int storageId, storage_type_e type,
-                                       storage_state_e state, const char *path, void *userData)
-                       {
-                               if ((type != STORAGE_TYPE_INTERNAL) ||
-                                               (state != STORAGE_STATE_MOUNTED)) {
-                                       return true;
-                               }
-                               auto &storageIdRec = *static_cast<StorageIdRec *>(userData);
-                               storageIdRec.id = storageId;
-                               storageIdRec.valid = true;
-                               return false;
-                       },
-                       &storageIdRec);
-               if (ret != 0) {
-                       LOG_RETURN(RES_FAIL,
-                                       "storage_foreach_device_supported() failed: %d", ret);
-               }
-
-               if (!storageIdRec.valid) {
-                       LOG_RETURN(RES_FAIL, "Writable internal storage not found!");
-               }
-
-               result = storageIdRec.id;
-
-               return RES_OK;
-       }
-
-       Result acquireMediaDbConnection()
-       {
-               if (impl::MEDIA_DB_CONNECTION_COUNTER > 0) {
-                       ++impl::MEDIA_DB_CONNECTION_COUNTER;
-                       return RES_OK;
-               }
-
-               FAIL_RETURN(util::call(media_content_connect),
-                                       "media_content_connect() failed!");
-
-               impl::MEDIA_DB_CONNECTION_COUNTER = 1;
-
-               return RES_OK;
-       }
-
-       void releaseMediaDbConnection()
-       {
-               if (impl::MEDIA_DB_CONNECTION_COUNTER == 0) {
-                       WLOG("Not connected!");
-                       return;
-               }
-
-               if (impl::MEDIA_DB_CONNECTION_COUNTER == 1) {
-                       FAIL_LOG(util::call(media_content_disconnect),
-                                       "media_content_disconnect() failed!");
-               }
-
-               --impl::MEDIA_DB_CONNECTION_COUNTER;
-       }
-}
-
-namespace gallery { namespace util {
-
-       std::string extractFileName(const std::string &path)
-       {
-               const auto bsPos = path.rfind('/');
-               if (bsPos == (path.size() - 1)) {
-                       return {};
-               }
-               return path.substr(bsPos + 1);
-       }
-
-       std::string extractFileExtension(const std::string &name)
-       {
-               const auto dotPos = name.rfind('.');
-               if ((dotPos == std::string::npos) ||
-                               (dotPos == 0) || (dotPos == (name.size() - 1))) {
-                       return {};
-               }
-               return name.substr(dotPos + 1);
-       }
-
-       void splitFilePath(const std::string &path, std::string &directory,
-                       std::string &baseName, std::string &extension)
-       {
-               splitFileName(path, baseName, extension);
-               if (isNotEmpty(baseName)) {
-                       directory = path.substr(0, (path.size() - baseName.size() -
-                                       (isNotEmpty(extension) ? (extension.size() - 1) : 0)));
-               } else {
-                       directory = path;
-               }
-       }
-
-       void splitFileName(const std::string &path,
-                       std::string &baseName, std::string &extension)
-       {
-               baseName = extractFileName(path);
-               if (isNotEmpty(baseName)) {
-                       extension = extractFileExtension(baseName);
-                       if (isNotEmpty(extension)) {
-                               baseName.resize(baseName.size() - extension.size() - 1);
-                       }
-               } else {
-                       extension.clear();
-               }
-       }
-
-       std::string makeUniqueFilePath(const std::string &srcPath,
-                       const std::string &dstDir)
-       {
-               std::string baseName;
-               std::string extension;
-               splitFileName(srcPath, baseName, extension);
-
-               std::string result;
-               result.reserve(dstDir.size() + baseName.size() +
-                               extension.size() + impl::UNIQUE_PATH_RESERVE);
-
-               result = dstDir;
-               if (isNotEmpty(result) && (result.back() != '/')) {
-                       result += '/';
-               }
-               result += baseName;
-
-               const auto baseSize = result.size();
-
-               for (int counter = 2; ; ++counter) {
-                       if (isNotEmpty(extension)) {
-                               result += '.';
-                               result += extension;
-                       }
-                       if (!ecore_file_exists(result.c_str())) {
-                               break;
-                       }
-                       result.resize(baseSize);
-                       result += " (";
-                       result += std::to_string(counter);
-                       result += ')';
-               }
-
-               return result;
-       }
-}}
diff --git a/src/model/helpers.h b/src/model/helpers.h
deleted file mode 100644 (file)
index 2c956c4..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MODEL_HELPERS_H__
-#define __GALLERY_MODEL_HELPERS_H__
-
-#include <media_content.h>
-
-#include "ucl/util/threading.h"
-
-#include "gallery/model/types.h"
-
-namespace gallery {
-
-       MediaType toMediaType(media_content_type_e contentType);
-
-       ucl::Mutex &getMediaMutex();
-
-       ucl::Result getInternalStorageId(int &result);
-
-       ucl::Result acquireMediaDbConnection();
-       void releaseMediaDbConnection();
-}
-
-namespace gallery { namespace util {
-
-       std::string extractFileName(const std::string &path);
-
-       std::string extractFileExtension(const std::string &name);
-
-       void splitFilePath(const std::string &path, std::string &directory,
-                       std::string &baseName, std::string &extension);
-
-       void splitFileName(const std::string &path,
-                       std::string &baseName, std::string &extension);
-
-       std::string makeUniqueFilePath(const std::string &srcPath,
-                       const std::string &dstDir);
-
-       bool beginsWith(const std::string &str, const std::string &prefix,
-                       bool caseSensitive = true);
-       bool removePrefix(std::string &str, const std::string &prefix,
-                       bool caseSensitive = true);
-}}
-
-#include "helpers.hpp"
-
-#endif // __GALLERY_MODEL_HELPERS_H__
diff --git a/src/model/helpers.hpp b/src/model/helpers.hpp
deleted file mode 100644 (file)
index 56efe64..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace gallery {
-
-       inline MediaType toMediaType(const media_content_type_e contentType)
-       {
-               switch (contentType) {
-               case MEDIA_CONTENT_TYPE_IMAGE: return MediaType::IMAGE;
-               case MEDIA_CONTENT_TYPE_VIDEO: return MediaType::VIDEO;
-               case MEDIA_CONTENT_TYPE_SOUND: return MediaType::SOUND;
-               case MEDIA_CONTENT_TYPE_MUSIC: return MediaType::MUSIC;
-               default:
-                       break;
-               }
-               return MediaType::OTHERS;
-       }
-}
-
-namespace gallery { namespace util {
-
-       inline bool beginsWith(const std::string &str, const std::string &prefix,
-                       bool caseSensitive)
-       {
-               if (caseSensitive) {
-                       return (str.compare(0, prefix.size(), prefix) == 0);
-               }
-               return (strncasecmp(str.c_str(), prefix.c_str(), prefix.size()) == 0);
-       }
-
-       inline bool removePrefix(std::string &str, const std::string &prefix,
-                       bool caseSensitive)
-       {
-               if (beginsWith(str, prefix, caseSensitive)) {
-                       str = str.substr(prefix.size());
-                       return true;
-               }
-               return false;
-       }
-}}
diff --git a/src/presenters/AlertDialog.cpp b/src/presenters/AlertDialog.cpp
deleted file mode 100644 (file)
index e8e7c9a..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/AlertDialog.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr EoDataKey BTN_EVENT_DATA {"gallery,btn,event,data"};
-
-       constexpr ElmStyle POPUP_STYLE {"circle"};
-       constexpr EdjePart PART_BUTTON1 {"button1"};
-       constexpr EdjePart PART_BUTTON2 {"button2"};
-
-       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)
-       {
-               return reinterpret_cast<void *>(static_cast<intptr_t>(event));
-       }
-
-       AlertDialog::Event asEvent(void *const data)
-       {
-               return static_cast<AlertDialog::Event>(
-                               reinterpret_cast<intptr_t>(data));
-       }
-
-       AlertDialog::Event getEvent(const Widget &widget)
-       {
-               return asEvent(widget.getData(BTN_EVENT_DATA));
-       }
-}}}
-
-namespace gallery {
-
-       using ucl::Layout;
-
-       using ucl::PART_TITLE;
-
-       // AlertDialog::Builder //
-
-       AlertDialog::Builder::Builder() :
-               m_type(Type::OK)
-       {
-       }
-
-       AlertDialog::Builder &AlertDialog::Builder::setType(const Type type)
-       {
-               m_type = type;
-               return *this;
-       }
-
-       AlertDialog::Builder &AlertDialog::Builder::setTitle(TString title)
-       {
-               m_title = std::move(title);
-               return *this;
-       }
-
-       AlertDialog::Builder &AlertDialog::Builder::setText(TString text)
-       {
-               m_text = std::move(text);
-               return *this;
-       }
-
-       AlertDialog::Builder &AlertDialog::Builder::setHandler(
-                       const EventHandler &handler)
-       {
-               m_handler = handler;
-               return *this;
-       }
-
-       AlertDialogWRef AlertDialog::Builder::build(ElmWidget &parent) const
-       {
-               if (!m_handler) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_handler is NULL");
-               }
-
-               auto result = makeShared<AlertDialog>(m_handler);
-
-               FAIL_RETURN_VALUE(result->prepare(parent, m_type), {},
-                               "result->prepare() failed!");
-
-               result->setTitle(m_title);
-               result->setText(m_text);
-               result->open();
-
-               return result;
-       }
-
-       // AlertDialog //
-
-       AlertDialog::AlertDialog(IRefCountObj &rc,
-                       const EventHandler &handler) :
-               Dialog(rc),
-               m_handler(handler)
-       {
-       }
-
-       Result AlertDialog::prepare(ElmWidget &parent, const Type type)
-       {
-               FAIL_RETURN(Dialog::prepare(parent, PopupType::NORMAL,
-                               [this, type]() { return doPrepare(type); }),
-                               "Dialog::prepare() failed!");
-
-               return RES_OK;
-       }
-
-       Result AlertDialog::doPrepare(const Type type)
-       {
-               m_popup->setStyle(impl::POPUP_STYLE);
-
-               const auto layoutTheme = ((type == Type::OK) ?
-                               impl::LAYOUT_POPUP_1BUTTON :
-                               impl::LAYOUT_POPUP_2BUTTONS);
-               FAIL_RETURN(createLayout(layoutTheme), "createLayout() failed!");
-
-               if (type == Type::OK) {
-                       FAIL_RETURN(prepareOkPopup(), "prepareOkPopup() failed!");
-               } else {
-                       FAIL_RETURN(prepareOkCancelPopup(), "prepareOkPopup() failed!");
-               }
-
-               return RES_OK;
-       }
-
-       Result AlertDialog::createLayout(const LayoutTheme theme)
-       {
-               const auto layout = Layout::Builder().
-                               setTheme(theme).
-                               setIsOwner(false).
-                               build(*m_popup);
-               if (!layout) {
-                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
-               }
-
-               m_popup->setContent(*layout);
-
-               m_layout = layout;
-
-               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)
-       {
-               const auto btn = makeShared<StyledWidget>(
-                               elm_button_add(*m_popup), false);
-               btn->setStyle(btnStyle);
-               m_popup->setContent(*btn, part);
-
-               if (isValid(iconTheme)) {
-                       const auto icon = Layout::Builder().
-                                       setTheme(iconTheme).
-                                       setIsOwner(false).
-                                       build(*btn);
-                       if (!icon) {
-                               LOG_RETURN(RES_FAIL, "Layout::build() failed!");
-                       }
-                       btn->setContent(*icon);
-               }
-
-               if (isNotEmpty(text)) {
-                       btn->setText(text);
-               }
-
-               show(*btn);
-
-               btn->setData(impl::BTN_EVENT_DATA, impl::asData(event));
-               btn->addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
-                               AlertDialog::onBtnClick, asWeak(*this)));
-
-               return RES_OK;
-       }
-
-       void AlertDialog::setTitle(const TString &title)
-       {
-               if (const auto layout = m_layout.lock()) {
-                       layout->setText(title, PART_TITLE);
-               }
-       }
-
-       void AlertDialog::setText(const TString &text)
-       {
-               if (const auto layout = m_layout.lock()) {
-                       layout->setText(text);
-               }
-       }
-
-       void AlertDialog::handleEvent(const Event event)
-       {
-               if (dispatchEvent(event)) {
-                       dismiss();
-               }
-       }
-
-       bool AlertDialog::dispatchEvent(const Event event)
-       {
-               if (!m_handler) {
-                       WLOG("Handler was destroyed!");
-                       return true;
-               }
-               return m_handler(*this, event);
-       }
-
-       void AlertDialog::onBtnClick(Widget &widget, void *eventInfo)
-       {
-               if (isActive()) {
-                       handleEvent(impl::getEvent(widget));
-               }
-       }
-
-       void AlertDialog::onBackKey()
-       {
-               handleEvent(Event::BACK);
-       }
-}
diff --git a/src/presenters/AtspiHighlightHelper.cpp b/src/presenters/AtspiHighlightHelper.cpp
deleted file mode 100644 (file)
index d960cb0..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/AtspiHighlightHelper.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr EoDataKey ATSPI_HELPER_DATA {"gallery,atspi,highlight,helper"};
-}}}
-
-namespace gallery {
-
-       using ucl::AtspiGestureEventInfo;
-
-       using ucl::ATSPI_ON_GESTURE;
-
-       AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance(
-                       GuiPresenter &parent, ElmWidget &rootWidget)
-       {
-               auto result = makeShared<AtspiHighlightHelper>();
-
-               FAIL_RETURN_VALUE(result->prepare(parent, rootWidget), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       AtspiHighlightHelper::AtspiHighlightHelper(IRefCountObj &rc) :
-               GuiPresenter(rc)
-       {
-       }
-
-       AtspiHighlightHelper::~AtspiHighlightHelper()
-       {
-       }
-
-       Result AtspiHighlightHelper::prepare(GuiPresenter &parent,
-                       ElmWidget &rootWidget)
-       {
-               FAIL_RETURN(GuiPresenter::prepare(parent),
-                               "GuiPresenter::prepare() failed!");
-
-               registerWidget(rootWidget);
-
-               return RES_OK;
-       }
-
-       void AtspiHighlightHelper::setEventHandler(EventHandler handler)
-       {
-               m_eventHandler = handler;
-       }
-
-       void AtspiHighlightHelper::registerWidget(ElmWidget &widget)
-       {
-               widget.addEventHandler(ATSPI_ON_GESTURE, WEAK_DELEGATE(
-                               AtspiHighlightHelper::onAtspiGesture, asWeak(*this)));
-       }
-
-       void AtspiHighlightHelper::onAtspiGesture(
-                       Widget &widget, void *eventInfo)
-       {
-               auto &e = *static_cast<AtspiGestureEventInfo *>(eventInfo);
-               if (e.stopPropagation) {
-                       return;
-               }
-               if (!isActive()) {
-                       e.preventDefault = true;
-                       return;
-               }
-
-               e.preventDefault = false;
-               e.stopPropagation = true;
-
-               if (!m_eventHandler) {
-                       return;
-               }
-               const Elm_Atspi_Relation_Type relation = getFlowRelation(e.gestureInfo);
-               if (relation == ELM_ATSPI_RELATION_NULL) {
-                       return;
-               }
-               const auto relationObj = m_eventHandler(widget, relation);
-               if (!relationObj) {
-                       return;
-               }
-
-               auto &win = getWindow();
-               auto atspiHelper = static_cast<Elm_Interface_Atspi_Accessible *>
-                               (win.getData(impl::ATSPI_HELPER_DATA));
-
-               if (!atspiHelper) {
-                       const auto obj = util::createFakeAccessObject(win);
-                       if (!obj) {
-                               LOG_RETURN_VOID(RES_FAIL, "createFakeAccessObject() failed!");
-                       }
-                       obj->setIsOwner(false);
-                       atspiHelper = obj->getEo();
-                       win.setData(impl::ATSPI_HELPER_DATA, atspiHelper);
-               }
-
-               elm_atspi_component_highlight_grab(atspiHelper);
-
-               elm_atspi_accessible_relationships_clear(atspiHelper);
-               elm_atspi_accessible_relationship_append(atspiHelper,
-                               relation, relationObj);
-       }
-}
diff --git a/src/presenters/Dialog.cpp b/src/presenters/Dialog.cpp
deleted file mode 100644 (file)
index 0c15e9f..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/Dialog.h"
-
-#include "common.h"
-
-namespace gallery {
-
-       Dialog::Dialog(IRefCountObj &rc) :
-               GuiPresenter(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);
-
-               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_selfRef.reset();
-
-                       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
deleted file mode 100644 (file)
index 392ce50..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/Instance.h"
-
-#include <system_settings.h>
-
-#include "ucl/appfw/helpers.h"
-
-#include "gallery/presenters/NoContentPage.h"
-#include "gallery/presenters/ThumbnailPage.h"
-#include "gallery/presenters/ViewerPage.h"
-#include "gallery/presenters/VideoPlayerPage.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       // TODO Since feature is temporary using hard-coded path
-       constexpr auto MEDIA_FOLDER = "/opt/usr/home/owner/media";
-}}}
-
-namespace gallery {
-
-       using ucl::SysEvent;
-       using ucl::SysEventProvider;
-       using ucl::IInstanceContext;
-       using ucl::getResPath;
-
-       using ucl::Theme;
-       using ucl::Naviframe;
-
-       Instance::Instance(IRefCountObj &rc,
-                       SysEventProvider &sysEventProvider) :
-               RefCountAware(&rc),
-               m_sysEventProvider(sysEventProvider),
-               m_context(nullptr),
-               m_isScanInProgress(false),
-               m_isGroupMode(false)
-       {
-       }
-
-       Instance::~Instance()
-       {
-               stopMediaContentScan();
-               util::dispose(m_page);
-       }
-
-       Result Instance::onCreate(IInstanceContext *const context)
-       {
-               m_context = context;
-
-               m_win = m_context->getWindow();
-
-               FAIL_RETURN(setupTheme(), "setupTheme() failed!");
-
-               m_navi = Naviframe::Builder().
-                               build(m_win->getConformant());
-               if (!m_navi) {
-                       LOG_RETURN(RES_FAIL, "Naviframe::build() failed!");
-               }
-
-               m_win->getConformant().setContent(*m_navi);
-
-               FAIL_RETURN(util::createCircleSurface(*m_navi),
-                               "util::createCircleSurface() failed!");
-
-               m_sysEventProvider.addEventHandler(
-                               WEAK_DELEGATE(Instance::onSysEvent, asWeak(*this)));
-
-               return RES_OK;
-       }
-
-       Result Instance::setupTheme()
-       {
-               m_theme = Theme::create();
-               if (isNotValid(m_theme)) {
-                       LOG_RETURN(RES_FAIL, "Theme::create() failed!");
-               }
-
-               m_theme.addExtension(getResPath(THEME_EDJE_PATH));
-
-               m_win->setTheme(m_theme);
-
-               return RES_OK;
-       }
-
-       void Instance::onPause()
-       {
-               DLOG("PAUSE");
-
-               setInstancePaused(*m_win, true);
-       }
-
-       void Instance::onResume()
-       {
-               DLOG("RESUME");
-
-               setInstancePaused(*m_win, false);
-
-               if (m_gallery && SCAN_MEDIA_ON_RESUME) {
-                       rescanMediaContent();
-               }
-
-               ecore_animator_frametime_set(1.0 / 60.0);
-       }
-
-       void Instance::rescanMediaContent()
-       {
-               stopMediaContentScan();
-               startMediaContentScan();
-       }
-
-       void Instance::stopMediaContentScan()
-       {
-               if (m_isScanInProgress) {
-                       m_isScanInProgress = false;
-                       DLOG("Scan is in progress. Terminating...");
-                       const int ret = media_content_cancel_scan_folder(
-                                       impl::MEDIA_FOLDER);
-                       if (ret != 0) {
-                               WLOG("media_content_cancel_scan_folder() failed: %d", ret);
-                       }
-               }
-       }
-
-       void Instance::startMediaContentScan()
-       {
-               DLOG("Starting media scan...");
-
-               int ret = media_content_scan_folder(impl::MEDIA_FOLDER, true,
-                               CALLBACK_B(Instance::onScanComplete), this);
-               if (ret != 0) {
-                       ELOG("media_content_scan_folder() failed: %d", ret);
-                       return;
-               }
-
-               m_isScanInProgress = true;
-       }
-
-       void Instance::onScanComplete(media_content_error_e error)
-       {
-               DLOG("Media scan complete. error: %d", error);
-
-               m_isScanInProgress = false;
-       }
-
-       void Instance::onAppControl(app_control_h appControl)
-       {
-               DLOG("APP CONTROL");
-
-               if (isBad(handleAppControl(appControl))) {
-                       DLOG("Terminating the application...");
-                       m_context->exitApp();
-                       return;
-               }
-
-               if (!m_win->isVisible()) {
-                       DLOG("Show the window.");
-                       show(*m_win);
-               }
-       }
-
-       Result Instance::handleAppControl(app_control_h appControl)
-       {
-               std::string operation;
-               FAIL_LOG(util::getNz(app_control_get_operation, operation, appControl),
-                       "app_control_get_operation() failed!");
-
-               app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE;
-               FAIL_LOG(util::get(app_control_get_launch_mode, mode, appControl),
-                       "app_control_get_launch_mode() failed!");
-
-               DLOG("operation: %s; mode: %d;", operation.c_str(), mode);
-
-               switch (mode) {
-               case APP_CONTROL_LAUNCH_MODE_SINGLE:
-                       return handleSingleMode(operation, appControl);
-               case APP_CONTROL_LAUNCH_MODE_GROUP:
-                       return handleGroupMode(operation, appControl);
-               default:
-                       ELOG("Invalid mode: %d;", mode);
-                       break;
-               }
-
-               if (!m_page) {
-                       LOG_RETURN(RES_FAIL, "m_page is NULL");
-               }
-
-               return RES_OK;
-       }
-
-       Result Instance::handleSingleMode(const std::string &operation,
-                               app_control_h appControl)
-       {
-               FAIL_RETURN(ensureGalleryModel(), "ensureGalleryModel() failed!");
-
-               if (const auto page = m_page.lock()) {
-                       if (operation == APP_CONTROL_OPERATION_MAIN) {
-                               page->deleteTo();
-                       }
-               } else if (isEmpty(m_gallery->getAlbum())) {
-                       createNoContentPage();
-               } else {
-                       createThumbnailPage();
-               }
-
-               return RES_OK;
-       }
-
-       Result Instance::handleGroupMode(const std::string &operation,
-                       app_control_h appControl)
-       {
-               if (m_page) {
-                       WLOG("Page is already created. Ignoring second request!");
-                       return RES_OK;
-               }
-
-               if (operation == APP_CONTROL_OPERATION_VIEW) {
-                       std::string uri;
-                       FAIL_RETURN(util::getNz(app_control_get_uri, uri, appControl),
-                               "app_control_get_uri() failed!");
-
-                       const auto media = MediaItem::newInstance(std::move(uri));
-                       if (!media) {
-                               LOG_RETURN(RES_FAIL, "MediaItem::newInstance() failed!");
-                       }
-
-                       switch (media->getType()) {
-                       case MediaType::IMAGE:
-                               createViewerPage(media);
-                               break;
-                       case MediaType::VIDEO:
-                               createVideoPlayerPage(media);
-                               break;
-                       default:
-                               LOG_RETURN(RES_NOT_SUPPORTED,
-                                               "Media type is not supported: %d;", media->getType());
-                       }
-
-               } else {
-                       WLOG("Operation not supported for current mode!");
-                       return RES_NOT_SUPPORTED;
-               }
-
-               m_isGroupMode = true;
-
-               return RES_OK;
-       }
-
-       Result Instance::ensureGalleryModel()
-       {
-               if (m_gallery) {
-                       return RES_FALSE;
-               }
-
-               m_gallery = Gallery::newInstance();
-               if (!m_gallery) {
-                       LOG_RETURN(RES_FAIL, "Gallery::newInstance() failed!");
-               }
-
-               m_gallery->getAlbum()->addChangeHandler(WEAK_DELEGATE(
-                               Instance::onAlbumChanged, asWeak(*this)));
-
-               return RES_OK;
-       }
-
-       void Instance::createNoContentPage()
-       {
-               DLOG("Creating NoContentPage.");
-               m_page = NoContentPage::Builder().setNaviframe(m_navi).
-                               build(WEAK_DELEGATE(
-                                       Instance::onPageExitRequest, asWeak(*this)));
-       }
-
-       void Instance::createThumbnailPage()
-       {
-               DLOG("Creating ThumbnailPage.");
-               FAIL_RETURN_VOID(ensureGalleryModel(), "ensureGalleryModel() failed!");
-
-               m_page = ThumbnailPage::Builder().setNaviframe(m_navi).
-                               setAlbum(m_gallery->getAlbum()).
-                               build(WEAK_DELEGATE(
-                                       Instance::onPageExitRequest, asWeak(*this)));
-       }
-
-       void Instance::createViewerPage(const MediaItemSRef &media)
-       {
-               DLOG("Creating ViewerPage.");
-               m_page = ViewerPage::Builder().setNaviframe(m_navi).
-                               setMedia(media).
-                               setExitOnZoomOut(false).
-                               build(WEAK_DELEGATE(
-                                       Instance::onPageExitRequest, asWeak(*this)));
-       }
-
-       void Instance::createVideoPlayerPage(const MediaItemSRef &media)
-       {
-               DLOG("Creating VideoPlayerPage.");
-               m_page = VideoPlayerPage::Builder().setNaviframe(m_navi).
-                               setMedia(media).
-                               build(WEAK_DELEGATE(
-                                       Instance::onPageExitRequest, asWeak(*this)));
-       }
-
-       void Instance::onAlbumChanged()
-       {
-               if (isEmpty(m_gallery->getAlbum())) {
-                       if (auto page = dynamicRefCast<ThumbnailPage>(m_page).lock()) {
-                               util::dispose(page);
-                               createNoContentPage();
-                       }
-               } else {
-                       if (auto page = dynamicRefCast<NoContentPage>(m_page).lock()) {
-                               util::dispose(page);
-                               createThumbnailPage();
-                       }
-               }
-       }
-
-       void Instance::onPageExitRequest(Page &page)
-       {
-               if (page.isAtBottom()) {
-                       DLOG("Bottom page.");
-                       if (m_isGroupMode) {
-                               DLOG("In group mode. Exit the application...");
-                               m_context->exitApp();
-                       } else {
-                               DLOG("Lowering the window.");
-                               m_win->lower();
-                       }
-               } else {
-                       DLOG("Exit page.");
-                       page.exit();
-               }
-       }
-
-       void Instance::onSysEvent(const SysEvent sysEvent)
-       {
-               switch(sysEvent) {
-               case SysEvent::LANGUAGE_CHANGED:
-                       DLOG("SysEvent::LANGUAGE_CHANGED");
-                       {
-                               char *locale = NULL;
-                               system_settings_get_value_string(
-                                               SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
-                               elm_language_set(locale);
-                               free(locale);
-                       }
-                       break;
-               default:
-                       DLOG("sysEvent: %d", sysEvent);
-                       break;
-               }
-       }
-}
diff --git a/src/presenters/InstanceManager.cpp b/src/presenters/InstanceManager.cpp
deleted file mode 100644 (file)
index dd187d7..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/InstanceManager.h"
-
-#include "gallery/presenters/Instance.h"
-
-#include "common.h"
-
-namespace gallery {
-
-       using ucl::AppParam;
-       using ucl::AppParams;
-       using ucl::IInstanceSRef;
-
-       InstanceManager::InstanceManager() :
-               InstanceManagerBase(AppParams().
-                               set(AppParam::WINDOW_NAME, WINDOW_NAME).
-                               set(AppParam::BASE_SCALE, BASE_SCALE))
-       {
-       }
-
-       IInstanceSRef InstanceManager::newInstance() const
-       {
-               return makeShared<Instance>(getSysEventProvider());
-       }
-}
diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp
deleted file mode 100644 (file)
index bae6640..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/MoreOptionsPresenter.h"
-
-#include "ucl/gui/Layout.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr SmartEvent MORE_OPENED {"more,option,opened"};
-       constexpr SmartEvent MORE_CLOSED {"more,option,closed"};
-       constexpr SmartEvent MORE_ITEM_CLICKED {"item,clicked"};
-       constexpr SmartEvent MORE_ITEM_SELECTED {"item,selected"};
-
-       constexpr EdjePart PART_ICON {"item,icon"};
-       constexpr EdjePart PART_MAIN_TEXT {"selector,main_text"};
-       constexpr EdjePart PART_SUB_TEXT {"selector,sub_text"};
-
-       // Warning! Do not mix translatable and not translatable text
-       // on a single item once it is created
-       void setText(Eext_Object_Item *item, const TString &value,
-                       const EdjePart part)
-       {
-               if (value.isTranslatable()) {
-                       eext_more_option_item_domain_translatable_part_text_set(
-                                               item, part.name, value.getDomain(), value);
-               } else {
-                       eext_more_option_item_part_text_set(item, part.name, value);
-               }
-       }
-}}}
-
-namespace gallery {
-
-       using ucl::Layout;
-
-       // MoreOptionsPresenter::Builder //
-
-       MoreOptionsPresenter::Builder::Builder()
-       {
-       }
-
-       MoreOptionsPresenter::Builder::~Builder()
-       {
-       }
-
-       bool MoreOptionsPresenter::Builder::isEmpty() const
-       {
-               return ucl::isEmpty(m_options);
-       }
-
-       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::clear()
-       {
-               m_options = {};
-               return *this;
-       }
-
-       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::addOption(
-                       Option option)
-       {
-               if (!m_options) {
-                       m_options = makeShared<MoreOptions>();
-               } else if (m_options.getUseCount() > 1) {
-                       m_options = makeShared<MoreOptions>(*m_options);
-               }
-               m_options->emplace_back(std::move(option));
-               return *this;
-       }
-
-       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::
-                       setParentWidget(const ElmWidgetSRef &parentWidget)
-       {
-               m_parentWidget = parentWidget;
-               return *this;
-       }
-
-       MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build(
-                       GuiPresenter &parent) const
-       {
-               if (isEmpty()) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!");
-               }
-               if (!m_parentWidget) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "m_parentWidget is NULL!");
-               }
-
-               auto result = makeShared<MoreOptionsPresenter>(m_options);
-
-               FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       // MoreOptionsPresenter //
-
-       MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
-                       const MoreOptionsCSRef &options) :
-               GuiPresenter(rc),
-               m_options(options),
-               m_timer(nullptr),
-               m_newOpenedState(false)
-       {
-       }
-
-       MoreOptionsPresenter::~MoreOptionsPresenter()
-       {
-               stopTimer();
-               if (m_widget) {
-                       sendActivate(*m_widget);
-               }
-       }
-
-       Result MoreOptionsPresenter::prepare(GuiPresenter &parent,
-                       ElmWidget &parentWidget)
-       {
-               FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
-                               "GuiPresenter::prepare() failed!");
-
-               Evas_Object *const more = eext_more_option_add(parentWidget);
-               if (!more) {
-                       LOG_RETURN(RES_FAIL, "eext_more_option_add() failed!");
-               }
-
-               const auto layout = makeShared<Layout>(more, true);
-               m_widget = layout;
-
-               for (auto &option: *m_options) {
-                       FAIL_RETURN(addItem(option), "addItem() failed!");
-               }
-
-               m_widget->addEventHandler(impl::MORE_OPENED, WEAK_DELEGATE(
-                               MoreOptionsPresenter::onOpened, asWeak(*this)));
-               m_widget->addEventHandler(impl::MORE_CLOSED, WEAK_DELEGATE(
-                               MoreOptionsPresenter::onClosed, asWeak(*this)));
-
-               m_widget->addEventHandler(impl::MORE_ITEM_CLICKED, WEAK_DELEGATE(
-                               MoreOptionsPresenter::onItemClicked, asWeak(*this)));
-               m_widget->addEventHandler(impl::MORE_ITEM_SELECTED, WEAK_DELEGATE(
-                               MoreOptionsPresenter::onItemSelected, asWeak(*this)));
-
-               deactivateBy(m_widget.get());
-
-               parent.addDeactivatorSource(*m_widget);
-
-               return RES_OK;
-       }
-
-       Result MoreOptionsPresenter::addItem(const Option &option)
-       {
-               const auto item = eext_more_option_item_append(*m_widget);
-               if (!item) {
-                       LOG_RETURN(RES_FAIL, "eext_more_option_item_append() failed!");
-               }
-
-               if (isValid(option.iconTheme)) {
-                       const auto icon = Layout::Builder().
-                                       setTheme(option.iconTheme).
-                                       setIsOwner(false).
-                                       build(*m_widget);
-                       if (!icon) {
-                               LOG_RETURN(RES_FAIL, "Layout::build() failed!");
-                       }
-                       eext_more_option_item_part_content_set(item,
-                                       impl::PART_ICON.name, *icon);
-               }
-
-               impl::setText(item, option.text, impl::PART_MAIN_TEXT);
-               impl::setText(item, option.subText, impl::PART_SUB_TEXT);
-
-               m_map.set(item, &option);
-
-               return RES_OK;
-       }
-
-       bool MoreOptionsPresenter::resetTimer(const double timeout)
-       {
-               stopTimer();
-
-               m_timer = ecore_timer_add(timeout, CALLBACK_A(
-                               MoreOptionsPresenter::onTimer), this);
-               if (!m_timer) {
-                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
-               }
-
-               return true;
-       }
-
-       void MoreOptionsPresenter::stopTimer()
-       {
-               if (m_timer) {
-                       ecore_timer_del(m_timer);
-                       m_timer = nullptr;
-               }
-       }
-
-       Eina_Bool MoreOptionsPresenter::onTimer()
-       {
-               m_timer = nullptr;
-
-               setOpened(m_newOpenedState);
-
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       void MoreOptionsPresenter::onOpened(Widget &widget, void *eventInfo)
-       {
-               stopTimer();
-               sendDeactivate(*m_widget);
-               activateBy(m_widget.get());
-               if (const auto listener = m_listener.lock()) {
-                       listener->onMoreOptionsOpened(*this);
-               }
-               if (!isActive()) {
-                       setOpened(false);
-               }
-       }
-
-       void MoreOptionsPresenter::onClosed(Widget &widget, void *eventInfo)
-       {
-               stopTimer();
-               deactivateBy(m_widget.get());
-               sendActivate(*m_widget);
-               if (const auto listener = m_listener.lock()) {
-                       listener->onMoreOptionsClosed(*this);
-               }
-       }
-
-       void MoreOptionsPresenter::onItemClicked(Widget &widget, void *eventInfo)
-       {
-               if (!isActive() || !isOpened()) {
-                       return;
-               }
-               if (const auto listener = m_listener.lock()) {
-                       const auto item = m_map.get(eventInfo);
-                       if (item) {
-                               listener->onMoreOptionClicked(*this, *item);
-                       } else {
-                               ELOG("Invalid eventInfo!");
-                       }
-               }
-       }
-
-       void MoreOptionsPresenter::onItemSelected(Widget &widget, void *eventInfo)
-       {
-               if (const auto listener = m_listener.lock()) {
-                       const auto item = m_map.get(eventInfo);
-                       if (item) {
-                               listener->onMoreOptionSelected(*this, *item);
-                       } else {
-                               ELOG("Invalid eventInfo!");
-                       }
-               }
-       }
-
-       void MoreOptionsPresenter::setListener(
-                       const IListenerWRef &listener)
-       {
-               m_listener = listener;
-       }
-
-       Widget &MoreOptionsPresenter::getWidget()
-       {
-               return *m_widget;
-       }
-
-       void MoreOptionsPresenter::setOpened(const bool isOpened)
-       {
-               stopTimer();
-               eext_more_option_opened_set(*m_widget, toEina(isOpened));
-       }
-
-       bool MoreOptionsPresenter::isOpened() const
-       {
-               return eext_more_option_opened_get(*m_widget);
-       }
-
-       void MoreOptionsPresenter::setOpenedDelayed(
-                       const bool isOpened, const double timeout)
-       {
-               if (!resetTimer(timeout)) {
-                       setOpened(isOpened);
-               } else {
-                       m_newOpenedState = isOpened;
-               }
-       }
-}
diff --git a/src/presenters/NoContentPage.cpp b/src/presenters/NoContentPage.cpp
deleted file mode 100644 (file)
index b7a96db..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/NoContentPage.h"
-
-#include "ucl/gui/Layout.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery {
-
-       using ucl::NaviItem;
-       using ucl::NaviframeSRef;
-       using ucl::Layout;
-
-       using ucl::LAYOUT_NO_CONTENTS;
-       using ucl::PART_TITLE;
-
-       // NoContentPage::Builder //
-
-       NoContentPage::Builder::Builder()
-       {
-       }
-
-       NoContentPage::Builder::~Builder()
-       {
-       }
-
-       NoContentPage::Builder &NoContentPage::Builder::setNaviframe(
-                       const NaviframeSRef &navi)
-       {
-               m_navi = navi;
-               return *this;
-       }
-
-       NoContentPageWRef NoContentPage::Builder::build(
-                       const ExitRequestHandler &onExitRequest) const
-       {
-               if (!onExitRequest) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "onExitRequest is NULL");
-               }
-               if (!m_navi) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
-               }
-
-               auto result = makeShared<NoContentPage>(m_navi, onExitRequest);
-
-               FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
-                       {
-                               return result->doPrepare(item);
-                       }),
-                       {}, "result->prepare() failed!");
-
-               return result;
-       }
-
-       // NoContentPage //
-
-       NoContentPage::NoContentPage(IRefCountObj &rc,
-                       const NaviframeSRef &navi,
-                       const ExitRequestHandler &onExitRequest) :
-               Page(rc, navi, onExitRequest)
-       {
-       }
-
-       NoContentPage::~NoContentPage()
-       {
-       }
-
-       Result NoContentPage::doPrepare(NaviItem &item)
-       {
-               const auto layout = Layout::Builder().
-                               setTheme(LAYOUT_NO_CONTENTS).
-                               build(getNaviframe());
-               if (!layout) {
-                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
-               }
-
-               const auto icon = Layout::Builder().
-                               setTheme(getImageTheme(ICON_NO_PHOTOS)).
-                               setIsOwner(false).
-                               build(*layout);
-               if (!icon) {
-                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
-               }
-
-               layout->setContent(*icon);
-               layout->setText(STR_APP_NAME, PART_TITLE);
-               layout->setText(STR_NO_PHOTOS);
-
-               item = getNaviframe().push(*layout, NAVIFRAME_NO_CLIP);
-               if (!item) {
-                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
-               }
-
-               layout->setIsOwner(false);
-
-               return RES_OK;
-       }
-}
diff --git a/src/presenters/Page.cpp b/src/presenters/Page.cpp
deleted file mode 100644 (file)
index 3ba8919..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/Page.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr SmartEvent TOP_PAGE_CHANGED {"ucl,top,page,changed"};
-}}}
-
-namespace gallery {
-
-       using ucl::NaviItem;
-       using ucl::NaviframeSRef;
-
-       using ucl::NAVI_TRANSITION_STARTED;
-       using ucl::NAVI_TRANSITION_FINISHED;
-
-       Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
-                       const ExitRequestHandler &onExitRequest) :
-               GuiPresenter(rc),
-               m_navi(navi),
-               m_onExitRequest(onExitRequest)
-       {
-               UCL_ASSERT(navi, "navi is NULL!");
-               UCL_ASSERT(onExitRequest, "onExitRequest is NULL!");
-
-               deactivateBy(m_navi.get());
-       }
-
-       Page::~Page()
-       {
-       }
-
-       Result Page::preparePart2()
-       {
-               if (!m_item) {
-                       UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL");
-               }
-
-               Evas_Object *content = m_item.getContent();
-               if (!content) {
-                       LOG_RETURN(RES_FAIL, "content is NULL");
-               }
-
-               m_navi->addEventHandler(NAVI_TRANSITION_STARTED,
-                               WEAK_DELEGATE(Page::onTransitionStarted, asWeak(*this)));
-
-               m_navi->addEventHandler(NAVI_TRANSITION_FINISHED,
-                               WEAK_DELEGATE(Page::onTransitionFinished, asWeak(*this)));
-
-               m_navi->addEventHandler(impl::TOP_PAGE_CHANGED,
-                               WEAK_DELEGATE(Page::onTopPageChanged, asWeak(*this)));
-
-               eext_object_event_callback_add(content, EEXT_CALLBACK_BACK,
-                               CALLBACK_A(Page::onHWBackKey), this);
-
-               m_item.setData(this);
-               m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
-
-               m_selfRef = asShared(*this);
-
-               if (!m_navi->isInTransition() && isAtTop()) {
-                       dispatchTopPageChanged();
-               }
-
-               return RES_OK;
-       }
-
-       void Page::dispatchTopPageChanged()
-       {
-               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)
-       {
-               m_item = nullptr;
-               m_selfRef.reset();
-       }
-
-       void Page::exit()
-       {
-               if (isAtTop() && !isAtBottom() && !m_navi->isInTransition()) {
-                       m_navi->pop();
-                       m_item = nullptr;
-               } else {
-                       dispose();
-               }
-       }
-
-       void Page::dispose()
-       {
-               if (m_item) {
-                       if (isAtTop()) {
-                               m_item.del();
-                               dispatchTopPageChanged();
-                       } else {
-                               m_item.del();
-                       }
-               }
-       }
-
-       bool Page::isDisposed() const
-       {
-               return m_item;
-       }
-
-       void Page::popTo()
-       {
-               if (m_item && !isAtTop()) {
-                       m_item.popTo();
-               }
-       }
-
-       void Page::deleteTo()
-       {
-               if (m_item && !isAtTop()) {
-                       while (!isAtTop()) {
-                               m_navi->getTopItem().del();
-                       }
-                       dispatchTopPageChanged();
-               }
-       }
-
-       void Page::promote()
-       {
-               if (m_item && !isAtTop()) {
-                       m_item.promote();
-               }
-       }
-
-       NaviItem Page::getItem()
-       {
-               return m_item;
-       }
-
-       void Page::requestExit()
-       {
-               if (m_onExitRequest) {
-                       m_onExitRequest(*this);
-               } else {
-                       WLOG("m_onExitRequest is NULL");
-                       exit();
-               }
-       }
-
-       void Page::updateActiveState()
-       {
-               if (isAtTop()) {
-                       activateBy(m_navi.get());
-               } else {
-                       deactivateBy(m_navi.get());
-               }
-       }
-
-       void Page::onTransitionStarted(Widget &widget, void *eventInfo)
-       {
-               deactivateBy(m_navi.get());
-       }
-
-       void Page::onTransitionFinished(Widget &widget, void *eventInfo)
-       {
-               updateActiveState();
-       }
-
-       void Page::onTopPageChanged(Widget &widget, void *eventInfo)
-       {
-               updateActiveState();
-       }
-
-       void Page::onHWBackKey(Evas_Object *obj, void *eventInfo)
-       {
-               if (isActive()) {
-                       onBackKey();
-               }
-       }
-
-       void Page::onBackKey()
-       {
-               requestExit();
-       }
-}
diff --git a/src/presenters/PreviewPage.cpp b/src/presenters/PreviewPage.cpp
deleted file mode 100644 (file)
index cfb0412..0000000
+++ /dev/null
@@ -1,722 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/PreviewPage.h"
-
-#include "gallery/presenters/ViewerPage.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr auto POPUP_SHOW_TIME_SEC = 0.3;
-
-       constexpr auto BRING_IN_SCROLL_FRICTION = 0.25;
-       constexpr auto PAGE_SCROLL_IN_FRICTION = 0.25;
-
-       enum {
-               MORE_OPTION_ID_DELETE
-       };
-}}}
-
-namespace gallery {
-
-       using ucl::NaviItem;
-       using ucl::NaviframeSRef;
-       using ucl::RefCountAware;
-
-       // PreviewPage::Builder //
-
-       PreviewPage::Builder::Builder() :
-               m_startItemIndex(0),
-               m_selectModeStartup(false),
-               m_autoSelectStartItem(false)
-       {
-       }
-
-       PreviewPage::Builder::~Builder()
-       {
-       }
-
-       PreviewPage::Builder &PreviewPage::Builder::setNaviframe(
-                       const NaviframeSRef &navi)
-       {
-               m_navi = navi;
-               return *this;
-       }
-
-       PreviewPage::Builder &PreviewPage::Builder::setAlbum(
-                       const IMediaAlbumSRef &album)
-       {
-               m_album = album;
-               return *this;
-       }
-
-       PreviewPage::Builder &PreviewPage::Builder::setStartItemIndex(
-                       const int index)
-       {
-               m_startItemIndex = index;
-               return *this;
-       }
-
-       PreviewPage::Builder &PreviewPage::Builder::setSelectModeStartup(
-                       const bool value)
-       {
-               m_selectModeStartup = value;
-               return *this;
-       }
-
-       PreviewPage::Builder &PreviewPage::Builder::setAutoSelectStartItem(
-                       const bool value)
-       {
-               m_autoSelectStartItem = value;
-               return *this;
-       }
-
-       PreviewPageWRef PreviewPage::Builder::build(
-                       const ExitRequestHandler &onExitRequest) const
-       {
-               if (!onExitRequest) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "onExitRequest is NULL");
-               }
-               if (!m_navi) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
-               }
-               if (!m_album) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
-               }
-
-               auto result = makeShared<PreviewPage>(
-                               m_navi, onExitRequest, m_album, m_selectModeStartup);
-
-               FAIL_RETURN_VALUE(result->prepare([this, &result](NaviItem &item)
-                       {
-                               return result->doPrepare(m_startItemIndex, item);
-                       }),
-                       {}, "result->prepare() failed!");
-
-               if (m_selectModeStartup && m_autoSelectStartItem) {
-                       result->selectItem(m_startItemIndex);
-               }
-
-               return result;
-       }
-
-       // PreviewPage::Item //
-
-       class PreviewPage::Item : public RefCountAware {
-       public:
-               Item(IRefCountObj &rc, MediaItemSRef &&media,
-                               ImageGrid &imageGrid, const int itemIndex) :
-                       RefCountAware(&rc),
-                       m_media(std::move(media)),
-                       m_imageGrid(imageGrid),
-                       m_index(itemIndex),
-                       m_isSelected(false)
-               {
-               }
-
-               void realize()
-               {
-                       FAIL_LOG(m_media->getThumbnailPath(
-                                       WEAK_DELEGATE(Item::onThumbnail, asWeak(*this))),
-                                       "getThumbnailPath() failed!");
-               }
-
-               void unrealize()
-               {
-                       m_media->cancelThumbnailPathGet();
-               }
-
-               MediaItemSRef getMedia()
-               {
-                       return m_media;
-               }
-
-               void setSelected(const bool selected)
-               {
-                       if (selected == m_isSelected) {
-                               return;
-                       }
-                       m_isSelected = selected;
-
-                       if (m_imageGrid.isInSelectMode() && !m_imageGrid.isInTransition()) {
-                               ImageGrid::ItemParams params = {};
-                               addFlags(params);
-                               m_imageGrid.updateItem(m_index, params);
-                       }
-               }
-
-               bool isSelected() const
-               {
-                       return m_isSelected;
-               }
-
-               void toggleSelected()
-               {
-                       setSelected(!m_isSelected);
-               }
-
-       private:
-               void onThumbnail(const Result result, const std::string &path)
-               {
-                       FAIL_LOG(result, "Failed to get thumbnail!");
-
-                       ImageGrid::ItemParams params = {};
-                       params.imagePath = m_media->getFilePath();
-                       params.bgImagePath = path;
-                       m_media->getResolution(params.imageWidth, params.imageHeight);
-                       addFlags(params);
-
-                       m_imageGrid.updateItem(m_index, params);
-               }
-
-               void addFlags(ImageGrid::ItemParams &params) const
-               {
-                       params.flags |= (m_imageGrid.isInSelectMode() ?
-                                       0 : ImageGrid::UF_BLOCK_CLICKS);
-                       params.flags |= (m_isSelected ? ImageGrid::UF_SELECTED : 0);
-               }
-
-       private:
-               const MediaItemSRef m_media;
-               ImageGrid &m_imageGrid;
-               const int m_index;
-               bool m_isSelected;
-       };
-
-       // PreviewPage //
-
-       PreviewPage::PreviewPage(IRefCountObj &rc,
-                       const NaviframeSRef &navi,
-                       const ExitRequestHandler &onExitRequest,
-                       const IMediaAlbumSRef &album,
-                       const bool selectModeStartup) :
-               Page(rc, navi, onExitRequest),
-               m_album(album),
-               m_selectModeStartup(selectModeStartup),
-               m_selectCount(0),
-               m_isInSelectMode(false),
-               m_needReload(false)
-       {
-       }
-
-       PreviewPage::~PreviewPage()
-       {
-               if (m_album) {
-                       m_album->delChangeHandler(WEAK_DELEGATE(
-                                       PreviewPage::onAlbumChanged, asWeak(*this)));
-               }
-               closeTempViews();
-               util::dispose(m_page);
-               if (m_imageGrid) {
-                       m_imageGrid->setListener(nullptr);
-               }
-       }
-
-       void PreviewPage::reload()
-       {
-               if (m_imageGrid->isInTransition()) {
-                       m_needReload = true;
-                       return;
-               }
-
-               {
-                       ImageGrid::Unrealizer u(*m_imageGrid);
-
-                       m_items.clear();
-
-                       FAIL_LOG(m_album->forEachMedia(
-                                       DELEGATE(PreviewPage::onEachMedia, this)),
-                                       "m_album->forEachMedia() failed!");
-
-                       m_imageGrid->setItemCount(m_items.size());
-               }
-
-               // TODO Temp solution.
-               // Need to add synchronization with curent state in the future.
-               closeTempViews();
-               switchToNormalMode();
-
-               checkViewerPage();
-       }
-
-       void PreviewPage::checkViewerPage()
-       {
-               if (const auto page = dynamicRefCast<ViewerPage>(m_page).lock()) {
-                       const auto mediaId = page->getMediaId();
-                       const auto it = std::find_if(m_items.begin(), m_items.end(),
-                               [&mediaId](const ItemSRef &item)
-                               {
-                                       return (item->getMedia()->getId() == mediaId);
-                               });
-                       if (it == m_items.end()) {
-                               DLOG("Viewed media item was removed.");
-                               deleteTo();
-                       } else {
-                               m_imageGrid->scrollToItem(it - m_items.begin());
-                       }
-               }
-       }
-
-       int PreviewPage::getCurrentItemIndex() const
-       {
-               return getSafeItemIndex(m_imageGrid->getScrolledToItemIndex());
-       }
-
-       Result PreviewPage::doPrepare(const int startItemIndex, NaviItem &item)
-       {
-               m_content = PageContent::Builder().
-                               setFlags(PageContent::FLAG_BOTTOM_BUTTON |
-                                               PageContent::FLAG_SELECT_BUTTON |
-                                               PageContent::FLAG_MORE_OPTIONS).
-                               build(getNaviframe());
-               if (!m_content) {
-                       LOG_RETURN(RES_FAIL, "PageContent::build() failed!");
-               }
-               setDeactivatorSink(m_content);
-
-               m_imageGrid = ImageGrid::Builder().
-                               setListener(asWeakThis<ImageGrid::IListener>(this)).
-                               setType(ImageGrid::Type::LINEAR).
-                               setSelectModeStartup(m_selectModeStartup).
-                               build(*m_content);
-               if (!m_imageGrid) {
-                       LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
-               }
-               m_content->set(*m_imageGrid);
-               ImageGrid::Unrealizer u(*m_imageGrid);
-
-               m_more = MoreOptionsPresenter::Builder().
-                               setParentWidget(m_content).
-                               addOption({impl::MORE_OPTION_ID_DELETE,
-                                       STR_DELETE, nullptr,
-                                       getImageTheme(ICON_MORE_OPT_DELETE)}).
-                               build(*this);
-               if (!m_more) {
-                       LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!");
-               }
-               m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS);
-
-               m_smp = SelectModePresenter::Builder().
-                               setPageContent(m_content).
-                               setFlags(SelectModePresenter::FLAG_NO_MORE_OPTIONS).
-                               build(*this);
-               if (!m_smp) {
-                       LOG_RETURN(RES_FAIL, "SelectModePresenter::build() failed!");
-               }
-
-               m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
-               if (!m_atspiHelper) {
-                       LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!");
-               }
-
-               FAIL_RETURN(m_album->forEachMedia(
-                               DELEGATE(PreviewPage::onEachMedia, this)),
-                               "m_album->forEachMedia() failed!");
-
-               m_imageGrid->setItemCount(m_items.size());
-
-               item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP);
-               if (!item) {
-                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
-               }
-
-               m_album->addChangeHandler(WEAK_DELEGATE(
-                               PreviewPage::onAlbumChanged, asWeak(*this)));
-
-               m_more->setListener(asWeakThis<MoreOptionsPresenter::IListener>(this));
-               m_smp->setListener(asWeakThis<SelectModePresenter::IListener>(this));
-
-               m_atspiHelper->setEventHandler(WEAK_DELEGATE(
-                               PreviewPage::onAtspiHighlight, asWeak(*this)));
-               m_atspiHelper->registerWidget(m_smp->getSelectButton());
-               m_atspiHelper->registerWidget(m_smp->getBottomButton());
-
-               if (m_selectModeStartup) {
-                       switchToSelectMode();
-               }
-               if (startItemIndex > 0) {
-                       showItem(startItemIndex);
-               }
-
-               return RES_OK;
-       }
-
-       void PreviewPage::showItem(const int itemIndex)
-       {
-               m_imageGrid->scrollToItem(getSafeItemIndex(itemIndex));
-       }
-
-       void PreviewPage::selectItem(const int itemIndex)
-       {
-               if (!m_isInSelectMode) {
-                       LOG_RETURN_VOID(RES_INVALID_ARGUMENTS, "Not in select mode!");
-               }
-               if (getSafeItemIndex(itemIndex) != itemIndex) {
-                       LOG_RETURN_VOID(RES_INVALID_ARGUMENTS, "itemIndex out of range!");
-               }
-               if (!m_items[itemIndex]->isSelected()) {
-                       toggleItemSelected(itemIndex);
-               }
-       }
-
-       int PreviewPage::getSafeItemIndex(const int itemIndex) const
-       {
-               if (itemIndex < 0) {
-                       return 0;
-               }
-               if (itemIndex >= static_cast<int>(m_items.size())) {
-                       return (m_items.size() - 1);
-               }
-               return itemIndex;
-       }
-
-       void PreviewPage::onAlbumChanged()
-       {
-               if (m_selectModeStartup) {
-                       requestExit();
-               } else if (!isEmpty(m_album)) {
-                       reload();
-               }
-       }
-
-       bool PreviewPage::onEachMedia(MediaItemSRef &&media)
-       {
-               m_items.emplace_back(makeShared<Item>(
-                               std::move(media), *m_imageGrid, m_items.size()));
-               return true;
-       }
-
-       void PreviewPage::onActivateBy(const DeactivatorInfo &info)
-       {
-               if (info.deactivator == &getNaviframe()) {
-                       elm_config_scroll_page_scroll_friction_set(
-                                       impl::PAGE_SCROLL_IN_FRICTION);
-                       elm_config_scroll_bring_in_scroll_friction_set(
-                                       impl::BRING_IN_SCROLL_FRICTION);
-               }
-
-               if (isActive() || m_smp->isActive()) {
-                       m_imageGrid->activateRotary();
-               }
-       }
-
-       void PreviewPage::onDeactivateBy(const DeactivatorInfo &info)
-       {
-               if (!m_smp->isActive()) {
-                       m_imageGrid->deactivateRotary();
-               }
-       }
-
-       void PreviewPage::onBackKey()
-       {
-               if (m_isInSelectMode && !m_selectModeStartup) {
-                       switchToNormalMode();
-                       return;
-               }
-               requestExit();
-       }
-
-       void PreviewPage::onItemRealized(const int itemIndex)
-       {
-               m_items[itemIndex]->realize();
-       }
-
-       void PreviewPage::onItemUnrealized(const int itemIndex)
-       {
-               m_items[itemIndex]->unrealize();
-       }
-
-       void PreviewPage::onItemEvent(const int itemIndex,
-                       const ImageGrid::ItemEvent event, const int x, const int y)
-       {
-               if (!isActive() || m_more->isOpened()) {
-                       return;
-               }
-
-               if (m_isInSelectMode) {
-                       if (event == ImageGrid::ItemEvent::CLICK) {
-                               toggleItemSelected(itemIndex);
-                               m_imageGrid->bringInItem(itemIndex);
-                       }
-                       return;
-               }
-
-               switch (event) {
-               case ImageGrid::ItemEvent::TAP_AND_HOLD:
-                       switchToSelectMode();
-                       toggleItemSelected(itemIndex);
-                       break;
-               case ImageGrid::ItemEvent::DOUBLE_TAP:
-                       openViewer(itemIndex, x, y);
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       void PreviewPage::onTransitionFinished()
-       {
-               if (m_needReload) {
-                       m_needReload = false;
-                       reload();
-               } else {
-                       m_imageGrid->update();
-               }
-               activateBy(m_imageGrid.get());
-       }
-
-       Elm_Interface_Atspi_Accessible *PreviewPage::onAccessObjectRequest(
-                       bool isFlowsTo)
-       {
-               if (m_isInSelectMode) {
-                       return (isFlowsTo ?
-                                       m_smp->getBottomButton() :
-                                       m_smp->getSelectButton());
-               }
-               return nullptr;
-       }
-
-       Elm_Interface_Atspi_Accessible *PreviewPage::onAtspiHighlight(
-                               Widget &widget, Elm_Atspi_Relation_Type flowRelation)
-       {
-               if (widget == m_smp->getSelectButton()) {
-                       if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) {
-                               return m_imageGrid->getAccessObject(true);
-                       }
-               } else if (widget == m_smp->getBottomButton()) {
-                       if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) {
-                               return m_imageGrid->getAccessObject(false);
-                       }
-               } else if (widget == getWindow()) {
-                       return (m_isInSelectMode ?
-                                       m_smp->getSelectButton() :
-                                       m_imageGrid->getAccessObject(true));
-               } else {
-                       LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!");
-               }
-               return widget.getEo();
-       }
-
-       void PreviewPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
-                       const MoreOptionsPresenter::Option &option)
-       {
-               switch (option.id) {
-               case impl::MORE_OPTION_ID_DELETE:
-                       sender.setOpenedDelayed(false, impl::POPUP_SHOW_TIME_SEC);
-                       confirmItemsDelete();
-                       break;
-               default:
-                       sender.setOpened(false);
-                       WLOG("Unknown option id: %d;", option.id);
-                       break;
-               }
-       }
-
-       void PreviewPage::onSelectModeEvent(const SelectModePresenter::Event event)
-       {
-               if (m_more->isOpened()) {
-                       return;
-               }
-
-               switch (event) {
-               case SelectModePresenter::Event::SELECT_ALL:
-               case SelectModePresenter::Event::DESELECT_ALL:
-                       {
-                               const bool isSelect =
-                                               (event == SelectModePresenter::Event::SELECT_ALL);
-                               for (auto &item: m_items) {
-                                       item->setSelected(isSelect);
-                               }
-                               m_selectCount = (isSelect * m_items.size());
-                               m_smp->update(m_selectCount);
-                       }
-                       break;
-
-               case SelectModePresenter::Event::BOTTOM_BUTTON_CLICK:
-                       confirmItemsDelete();
-                       break;
-               }
-       }
-
-       void PreviewPage::confirmItemsDelete()
-       {
-               const int itemCount = (m_isInSelectMode ? m_selectCount : 1);
-               if (itemCount == 0) {
-                       WLOG("itemCount == 0");
-                       return;
-               }
-
-               m_alert = AlertDialog::Builder().
-                               setType(AlertDialog::Type::OK_CANCEL).
-                               setText((itemCount == 1) ?
-                                       STR_DELETE_1_PHOTO :
-                                       TString(STR_DELETE_N_PHOTO.format(itemCount))).
-                               setHandler(WEAK_DELEGATE(
-                                       PreviewPage::onAlertEvent, asWeak(*this))).
-                               build(getNaviframe());
-       }
-
-       bool PreviewPage::onAlertEvent(AlertDialog &dialog,
-                       AlertDialog::Event event)
-       {
-               if (event != AlertDialog::Event::OK) {
-                       return true;
-               }
-
-               MediaItems items;
-
-               if (m_isInSelectMode) {
-                       for (auto &item: m_items) {
-                               if (item->isSelected()) {
-                                       items.emplace_back(item->getMedia());
-                               }
-                       }
-               } else {
-                       const int itemIndex = getCurrentItemIndex();
-                       if (itemIndex < 0) {
-                               ELOG("Invalid item index!");
-                               return true;
-                       }
-                       items.emplace_back(m_items[itemIndex]->getMedia());
-               }
-
-               m_job = MediaItem::RemoverBuilder().
-                               setItems(items).
-                               build(WEAK_DELEGATE(
-                                       PreviewPage::onJobComplete, asWeak(*this)));
-               if (!m_job) {
-                       ELOG("MediaItem::RemoverBuilder::build() failed!");
-                       return true;
-               }
-
-               m_processing = ProcessingPresenter::Builder().
-                       setProcessingText(STR_DELETING).
-                       build(*m_content);
-
-               return true;
-       }
-
-       void PreviewPage::onJobComplete()
-       {
-               if (m_processing) {
-                       if (isGood(m_job->getResult())) {
-                               m_processing->complete(STR_DELETED,
-                                               ProcessingPresenter::IconType::CHECK);
-                       } else {
-                               m_processing->complete(STR_FAILED);
-                       }
-                       m_processing.reset();
-               }
-
-               m_job.reset();
-
-               m_album->defragment();
-       }
-
-       void PreviewPage::closeTempViews()
-       {
-               util::dispose(m_alert);
-               if (m_more) {
-                       m_more->setOpened(false);
-               }
-       }
-
-       void PreviewPage::switchToSelectMode()
-       {
-               if (m_isInSelectMode) {
-                       return;
-               }
-               m_isInSelectMode = true;
-
-               m_selectCount = 0;
-               for (auto &item: m_items) {
-                       item->setSelected(false);
-               }
-
-               m_imageGrid->setSelectModeEnabled(true);
-               if (m_imageGrid->isInTransition()) {
-                       deactivateBy(m_imageGrid.get());
-               }
-
-               m_content->setMoreOptionsVisible(false);
-
-               m_smp->setBottomButtonText(STR_DELETE_CAPS);
-               m_smp->update(m_selectCount, m_items.size());
-               m_smp->setVisible(true);
-       }
-
-       void PreviewPage::switchToNormalMode()
-       {
-               if (!m_isInSelectMode) {
-                       return;
-               }
-               m_isInSelectMode = false;
-
-               m_imageGrid->setSelectModeEnabled(false);
-               if (m_imageGrid->isInTransition()) {
-                       deactivateBy(m_imageGrid.get());
-               }
-
-               m_content->setMoreOptionsVisible(true);
-
-               m_smp->setVisible(false);
-       }
-
-       void PreviewPage::toggleItemSelected(const int itemIndex)
-       {
-               m_items[itemIndex]->toggleSelected();
-
-               m_selectCount = 0;
-               for (auto &item: m_items) {
-                       m_selectCount += item->isSelected();
-               }
-
-               m_smp->update(m_selectCount);
-
-               if (m_selectCount == 0) {
-                       m_more->setOpened(false);
-               }
-       }
-
-       void PreviewPage::openViewer(const int itemIndex, const int x, const int y)
-       {
-               ViewerPage::Builder builder;
-               builder.setNaviframe(asShared(getNaviframe()));
-               builder.setZoomIn(x, y);
-               builder.setMedia(m_items[itemIndex]->getMedia());
-
-               ImageGrid::ItemInfo info = {};
-               m_imageGrid->getItemInfo(itemIndex, info);
-               if (info.isImageLoaded) {
-                       builder.setImageLoadSize(info.imageLoadSize,
-                                       info.isImageLoadSizeFull);
-               }
-
-               m_page = builder.build(WEAK_DELEGATE(
-                               PreviewPage::onPageExitRequest, asWeak(*this)));
-       }
-
-       void PreviewPage::onPageExitRequest(Page &page)
-       {
-               m_page.reset();
-               deleteTo();
-       }
-}
diff --git a/src/presenters/ProcessingPresenter.cpp b/src/presenters/ProcessingPresenter.cpp
deleted file mode 100644 (file)
index b8f1b05..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/ProcessingPresenter.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr auto IDLE_WAIT_TIME_SEC = 0.2;
-       constexpr auto PROCESSING_MIN_TIME_SEC = 0.5;
-
-       constexpr auto POPUP_SHOW_TIME_SEC = 0.3;
-       constexpr auto POPUP_DURATION_SEC = 2.0;
-       constexpr auto POPUP_TIMEOUT_SEC =
-                       (POPUP_DURATION_SEC - POPUP_SHOW_TIME_SEC);
-
-       constexpr LayoutTheme LAYOUT_PROCESSING_WIDGET
-                       {"layout", "gallery", "proccessing"};
-
-       constexpr EdjeSignal SIGNAL_SHOW {"gallery,show"};
-       constexpr EdjeSignal SIGNAL_SHOW_BG {"gallery,show,bg"};
-       constexpr EdjeSignal SIGNAL_HIDE {"gallery,hide"};
-       constexpr EdjeSignal SIGNAL_HIDE_PROGRESS {"gallery,hide,progress"};
-
-       constexpr LayoutTheme LAYOUT_POPUP_ICON
-                       {"layout", "gallery", "popup_icon"};
-
-       constexpr EdjeSignal SIGNAL_ANIMATE_CHECK {"gallery,animate,check"};
-
-       constexpr ElmStyle POPUP_STYLE {"toast/circle"};
-       constexpr EdjePart PART_TOAST_ICON {"toast,icon"};
-}}}
-
-namespace gallery {
-
-       using ucl::Layout;
-
-       using ucl::PART_TEXT;
-
-       // ProcessingPresenter::Builder //
-
-       ProcessingPresenter::Builder::Builder() :
-               m_forceProgress(false)
-       {
-       }
-
-       ProcessingPresenter::Builder &ProcessingPresenter::Builder::
-                       setProcessingText(TString text)
-       {
-               m_processingText = std::move(text);
-               return *this;
-       }
-
-       ProcessingPresenter::Builder &ProcessingPresenter::Builder::
-                       setForceProgress(const bool value)
-       {
-               m_forceProgress = value;
-               return *this;
-       }
-
-       ProcessingPresenterSRef ProcessingPresenter::Builder::
-                       build(ElmWidget &parent) const
-       {
-               auto result = makeShared<ProcessingPresenter>();
-
-               FAIL_RETURN_VALUE(result->prepare(parent,
-                               m_processingText, m_forceProgress), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       // ProcessingPresenter //
-
-       ProcessingPresenter::ProcessingPresenter(IRefCountObj &rc) :
-               GuiPresenter(rc),
-               m_iconType(IconType::NONE),
-               m_timer(nullptr),
-               m_state(State::WAITING),
-               m_mayComplete(true),
-               m_isComplete(false),
-               m_isDismissed(false)
-       {
-       }
-
-       ProcessingPresenter::~ProcessingPresenter()
-       {
-               stopTimer();
-               deletePopup();
-       }
-
-       Result ProcessingPresenter::prepare(ElmWidget &parent,
-                       const TString &processingText,
-                       const bool forceProgress)
-       {
-               FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
-                               "GuiPresenter::prepare() failed!");
-
-               FAIL_RETURN(createWidget(parent, processingText),
-                               "createWidget() failed!");
-               FAIL_RETURN(moveWidget(), "moveWidget() failed!");
-
-               FAIL_RETURN(createProgress(), "createProgress() failed!");
-
-               FAIL_RETURN(createPopup(), "createPopup() failed!");
-
-               if (forceProgress) {
-                       showProgress();
-               } else {
-                       m_widget->emit(impl::SIGNAL_SHOW_BG);
-                       if (!resetTimer(impl::IDLE_WAIT_TIME_SEC)) {
-                               LOG_RETURN(RES_FAIL, "resetTimer() failed!");
-                       }
-               }
-
-               broadcastDeactivate();
-
-               return RES_OK;
-       }
-
-       Result ProcessingPresenter::createWidget(ElmWidget &parent,
-                       const TString &processingText)
-       {
-               m_widget = Layout::Builder().
-                               setTheme(impl::LAYOUT_PROCESSING_WIDGET).
-                               build(parent);
-               if (!m_widget) {
-                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
-               }
-
-               m_widget->setText(processingText);
-
-               return RES_OK;
-       }
-
-       Result ProcessingPresenter::moveWidget()
-       {
-               const auto win = m_widget->getWindow();
-               if (!win) {
-                       LOG_RETURN(RES_FAIL, "win is NULL!");
-               }
-
-               int w = 0;
-               int h = 0;
-               win->getScreenSize(&w, &h);
-
-               m_widget->setGeometry(0, 0, w, h);
-
-               return RES_OK;
-       }
-
-       Result ProcessingPresenter::createProgress()
-       {
-               Evas_Object *const progressEo = elm_progressbar_add(*m_widget);
-               if (!progressEo) {
-                       LOG_RETURN(RES_FAIL, "elm_progressbar_add() failed!");
-               }
-
-               StyledWidget progress{progressEo};
-               progress.setStyle(ElmStyle("process"));
-               m_widget->setContent(progress, EdjePart("gallery.swallow.progress"));
-               elm_progressbar_pulse(progress, EINA_TRUE);
-               show(progress);
-
-               return RES_OK;
-       }
-
-       Result ProcessingPresenter::createPopup()
-       {
-               Evas_Object *const popupEo = elm_popup_add(m_widget->getTopWidget());
-               if (!popupEo) {
-                       LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
-               }
-
-               m_popup = makeShared<StyledWidget>(popupEo);
-               m_popup->setStyle(impl::POPUP_STYLE);
-
-               m_popup->addEventHandler(POPUP_DISMISSED, WEAK_DELEGATE(
-                               ProcessingPresenter::onPopupDismissed, asWeak(*this)));
-
-               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
-                               CALLBACK_A(ProcessingPresenter::onPopupHWBackKey), this);
-
-               return RES_OK;
-       }
-
-       Result ProcessingPresenter::createIcon()
-       {
-               const auto icon = Layout::Builder().
-                               setTheme(impl::LAYOUT_POPUP_ICON).
-                               setIsOwner(false).
-                               build(*m_popup);
-               if (!icon) {
-                       LOG_RETURN(RES_FAIL, "Layout::build() failed!");
-               }
-
-               m_popup->setContent(*icon, impl::PART_TOAST_ICON);
-
-               m_icon = icon;
-
-               return RES_OK;
-       }
-
-       bool ProcessingPresenter::resetTimer(const double timeout)
-       {
-               stopTimer();
-
-               m_timer = ecore_timer_add(timeout, CALLBACK_A(
-                               ProcessingPresenter::onTimer), this);
-               if (!m_timer) {
-                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
-               }
-
-               return true;
-       }
-
-       void ProcessingPresenter::stopTimer()
-       {
-               if (m_timer) {
-                       ecore_timer_del(m_timer);
-                       m_timer = nullptr;
-               }
-       }
-
-       void ProcessingPresenter::showProgress()
-       {
-               m_widget->emit(impl::SIGNAL_SHOW);
-
-               m_state = State::PROCESSING;
-               m_mayComplete = false;
-
-               resetTimer(impl::PROCESSING_MIN_TIME_SEC);
-       }
-
-       void ProcessingPresenter::tryShowPopup()
-       {
-               if (m_isComplete && m_mayComplete && m_popup) {
-                       m_widget->emit(impl::SIGNAL_HIDE_PROGRESS);
-
-                       show(*m_popup);
-
-                       m_state = State::POPUP_ANIMATION;
-                       resetTimer(impl::POPUP_SHOW_TIME_SEC);
-               }
-       }
-
-       void ProcessingPresenter::dismissPopup()
-       {
-               if (m_popup && !m_isDismissed) {
-                       m_isDismissed = true;
-                       deactivateBy(m_popup.get());
-                       elm_popup_dismiss(*m_popup);
-               }
-       }
-
-       void ProcessingPresenter::deletePopup()
-       {
-               if (m_popup) {
-                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
-                                       CALLBACK_A(ProcessingPresenter::onPopupHWBackKey));
-
-                       deactivateBy(m_popup.get());
-                       broadcastActivate();
-                       m_popup.reset();
-                       m_selfRef.reset();
-               }
-       }
-
-       void ProcessingPresenter::animateIcon()
-       {
-               if (const auto icon = m_icon.lock()) {
-                       if (m_iconType == IconType::CHECK) {
-                               icon->emit(impl::SIGNAL_ANIMATE_CHECK);
-                       }
-               }
-       }
-
-       Eina_Bool ProcessingPresenter::onTimer()
-       {
-               m_timer = nullptr;
-
-               switch (m_state) {
-               case State::WAITING:
-                       showProgress();
-                       break;
-
-               case State::PROCESSING:
-                       m_mayComplete = true;
-                       tryShowPopup();
-                       break;
-
-               case State::POPUP_ANIMATION:
-                       animateIcon();
-                       m_widget->emit(impl::SIGNAL_HIDE);
-                       m_state = State::COMPLETE;
-                       resetTimer(impl::POPUP_TIMEOUT_SEC);
-                       break;
-
-               case State::COMPLETE:
-                       dismissPopup();
-                       break;
-               }
-
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       void ProcessingPresenter::onPopupDismissed(Widget &widget, void *eventInfo)
-       {
-               if (m_dismissHandler) {
-                       m_dismissHandler();
-               }
-               m_widget.reset();
-               deletePopup();
-       }
-
-       void ProcessingPresenter::onPopupHWBackKey(
-                       Evas_Object *obj, void *eventInfo)
-       {
-               if (isActive()) {
-                       m_widget->emit(impl::SIGNAL_HIDE);
-                       stopTimer();
-                       dismissPopup();
-               }
-       }
-
-       void ProcessingPresenter::complete(const TString &completeText,
-                       const IconType iconType)
-       {
-               if (m_isComplete) {
-                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Already in complete state!");
-               }
-               m_isComplete = true;
-
-               m_popup->setText(completeText, PART_TEXT);
-
-               if (iconType != IconType::NONE) {
-                       m_iconType = iconType;
-                       FAIL_LOG(createIcon(), "createIcon() failed!");
-               }
-
-               m_selfRef = asShared(*this);
-
-               tryShowPopup();
-       }
-
-       void ProcessingPresenter::setDismissHandler(const DismissHandler &handler)
-       {
-               m_dismissHandler = handler;
-       }
-}
diff --git a/src/presenters/SelectModePresenter.cpp b/src/presenters/SelectModePresenter.cpp
deleted file mode 100644 (file)
index 385a2d5..0000000
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/SelectModePresenter.h"
-
-#include "ucl/gui/WidgetItem.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       const TString SELECT_BTN_TEXT_FMT {"%d"};
-
-       constexpr ElmStyle SELECT_POPUP_STYLE {"select_mode"};
-       constexpr ElmStyle TOP_SELECT_BTN_STYLE {"select_mode/top"};
-       constexpr ElmStyle BOTTOM_SELECT_BTN_STYLE {"select_mode/bottom"};
-
-       constexpr ElmStyle SELECT_BTN_STYLE {"select_mode"};
-       constexpr ElmStyle BOTTOM_BTN_STYLE {"bottom"};
-}}}
-
-namespace gallery {
-
-       using ucl::WidgetItem;
-
-       // SelectModePresenter::Builder //
-
-       SelectModePresenter::Builder::Builder() :
-               m_flags(0)
-       {
-       }
-
-       SelectModePresenter::Builder &SelectModePresenter::Builder::
-                       setFlags(const int flags)
-       {
-               m_flags = flags;
-               return *this;
-       }
-
-       SelectModePresenter::Builder &SelectModePresenter::Builder::
-                       setPageContent(const PageContentSRef &content)
-       {
-               m_content = content;
-               return *this;
-       }
-
-       SelectModePresenterSRef SelectModePresenter::Builder::build(
-                       GuiPresenter &parent) const
-       {
-               if (!m_content) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_content is NULL!");
-               }
-
-               auto result = makeShared<SelectModePresenter>(m_content, m_flags);
-
-               FAIL_RETURN_VALUE(result->prepare(parent), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       // SelectModePresenter //
-
-       SelectModePresenter::SelectModePresenter(IRefCountObj &rc,
-                       const PageContentSRef &content, const int flags) :
-               GuiPresenter(rc),
-               m_content(content),
-               m_flags(flags),
-               m_totalCount(0),
-               m_selectCount(0),
-               m_isVisible(false),
-               m_isPopupDismissed(false)
-       {
-       }
-
-       SelectModePresenter::~SelectModePresenter()
-       {
-               if ((m_flags & FLAG_NO_DISMISS_ON_ROTARY) == 0) {
-                       delRotaryEventHandler(CALLBACK_A(
-                                       SelectModePresenter::onRotary), this);
-               }
-               deletePopup();
-       }
-
-       Result SelectModePresenter::prepare(GuiPresenter &parent)
-       {
-               FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
-                               "GuiPresenter::prepare() failed!");
-
-               m_selectButton = makeShared<StyledWidget>(elm_button_add(*m_content));
-               m_selectButton->setStyle(impl::SELECT_BTN_STYLE);
-               m_content->set(*m_selectButton, PageContent::Part::SELECT_BUTTON);
-               m_content->setSelectButtonVisible(false);
-               show(*m_selectButton);
-
-               m_selectButton->addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
-                               SelectModePresenter::onSelectBtnClick, asWeak(*this)));
-
-               if ((m_flags & FLAG_NO_BOTTOM_BUTTON) == 0) {
-                       m_bottomButton = makeShared<StyledWidget>(
-                                       elm_button_add(*m_content));
-                       m_bottomButton->setStyle(impl::BOTTOM_BTN_STYLE);
-                       hide(*m_bottomButton);
-
-                       m_bottomButton->addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
-                                       SelectModePresenter::onBottomBtnClick, asWeak(*this)));
-               }
-
-               if ((m_flags & FLAG_NO_DISMISS_ON_ROTARY) == 0) {
-                       addRotaryEventHandler(CALLBACK_A(
-                                       SelectModePresenter::onRotary), this);
-               }
-
-               deactivateBy(m_selectButton.get());
-
-               return RES_OK;
-       }
-
-       void SelectModePresenter::setListener(const IListenerWRef &listener)
-       {
-               m_listener = listener;
-       }
-
-
-       void SelectModePresenter::setVisible(const bool value)
-       {
-               if (value == m_isVisible) {
-                       return;
-               }
-               m_isVisible = value;
-
-               m_content->setSelectButtonVisible(m_isVisible);
-
-               if (m_bottomButton) {
-                       if (m_isVisible) {
-                               m_content->set(*m_bottomButton,
-                                               PageContent::Part::BOTTOM_BUTTON);
-                               show(*m_bottomButton);
-                       } else {
-                               m_content->unset(PageContent::Part::BOTTOM_BUTTON);
-                               hide(*m_bottomButton);
-                       }
-               }
-
-               if (m_isVisible) {
-                       activateBy(m_selectButton.get());
-                       doUpdate();
-               } else {
-                       deactivateBy(m_selectButton.get());
-                       if ((m_flags & (FLAG_NO_MORE_OPTIONS |
-                                       FLAG_NO_DIM_ON_ZERO_SELECT)) == 0) {
-                               m_content->setMoreOptionsVisible(true);
-                       }
-               }
-       }
-
-       bool SelectModePresenter::isVisible() const
-       {
-               return m_isVisible;
-       }
-
-       void SelectModePresenter::onDeactivate()
-       {
-               deletePopup();
-       }
-
-       ElmWidget &SelectModePresenter::getSelectButton()
-       {
-               return *m_selectButton;
-       }
-
-       ElmWidget &SelectModePresenter::getBottomButton()
-       {
-               UCL_ASSERT(m_bottomButton, "No bottom button!");
-               return *m_bottomButton;
-       }
-
-       void SelectModePresenter::setBottomButtonText(const TString &value)
-       {
-               if (m_bottomButton) {
-                       m_bottomButton->setText(value);
-               } else {
-                       WLOG("No bottom button!");
-               }
-       }
-
-       void SelectModePresenter::update(
-                       const int selectCount, const int totalCount)
-       {
-               if (m_isVisible) {
-                       dismissPopup();
-               }
-
-               const int newTotalCount = ((totalCount < 0) ?
-                               m_totalCount : totalCount);
-
-               int newSelectCount = selectCount;
-               if (newSelectCount < 0) {
-                       WLOG("newSelectCount: %d;", newSelectCount);
-                       newSelectCount = 0;
-               } else if (newSelectCount > newTotalCount) {
-                       WLOG("newSelectCount: %d; newTotalCount: %d",
-                                       newSelectCount, newTotalCount);
-                       newSelectCount = newTotalCount;
-               }
-
-               if ((newSelectCount == m_selectCount) &&
-                               (newTotalCount == m_totalCount)) {
-                       return;
-               }
-               m_selectCount = newSelectCount;
-               m_totalCount = newTotalCount;
-
-               if (m_isVisible) {
-                       doUpdate();
-               }
-       }
-
-       void SelectModePresenter::doUpdate()
-       {
-               m_selectButton->setText(impl::SELECT_BTN_TEXT_FMT.
-                               format(m_selectCount));
-
-               if ((m_flags & FLAG_NO_DIM_ON_ZERO_SELECT) == 0) {
-                       const bool isDimmed = (m_selectCount == 0);
-                       if (m_bottomButton) {
-                               m_bottomButton->setEnabled(!isDimmed);
-                       }
-                       if ((m_flags & FLAG_NO_MORE_OPTIONS) == 0) {
-                               m_content->setMoreOptionsVisible(!isDimmed);
-                       }
-               }
-       }
-
-       void SelectModePresenter::showPopup()
-       {
-               m_isPopupDismissed = false;
-
-               m_popup = makeShared<StyledWidget>(elm_ctxpopup_add(*m_content));
-               m_popup->setStyle(impl::SELECT_POPUP_STYLE);
-
-               elm_ctxpopup_direction_priority_set(*m_popup,
-                               ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP,
-                               ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP);
-
-               WidgetItem selectItem;
-               WidgetItem deselectItem;
-
-               if (m_selectCount < m_totalCount) {
-                       selectItem = WidgetItem{elm_ctxpopup_item_append(*m_popup,
-                                       STR_SELECT_ALL.translate(), nullptr, CALLBACK_A(
-                                               SelectModePresenter::onSelectAll), this)};
-               }
-
-               if (m_selectCount > 0) {
-                       deselectItem = WidgetItem{elm_ctxpopup_item_append(*m_popup,
-                                       STR_DESELECT_ALL.translate(), nullptr, CALLBACK_A(
-                                               SelectModePresenter::onDeselectAll), this)};
-               }
-
-               show(*m_popup);
-
-               if (selectItem && deselectItem) {
-                       selectItem.setStyle(impl::TOP_SELECT_BTN_STYLE);
-                       deselectItem.setStyle(impl::BOTTOM_SELECT_BTN_STYLE);
-               }
-
-               movePopup();
-
-               m_popup->addEventHandler(POPUP_DISMISSED, WEAK_DELEGATE(
-                               SelectModePresenter::onPopupDismissed, asWeak(*this)));
-
-               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
-                               CALLBACK_A(SelectModePresenter::onPopupHWBackKey), this);
-
-               broadcastDeactivate();
-       }
-
-       void SelectModePresenter::movePopup()
-       {
-               int cx = 0;
-               int cy = 0;
-               int cw = 0;
-               int ch = 0;
-               m_content->getGeometry(&cx, &cy, &cw, &ch);
-
-               int ph = 0;
-               getSize(*m_popup, nullptr, &ph);
-
-               m_popup->move(cx + (cw / 2), cy + ((ch - ph) / 2));
-       }
-
-       void SelectModePresenter::dismissPopup()
-       {
-               if (m_popup && !m_isPopupDismissed) {
-                       m_isPopupDismissed = true;
-                       elm_ctxpopup_dismiss(*m_popup);
-               }
-       }
-
-       void SelectModePresenter::deletePopup()
-       {
-               if (m_popup) {
-                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
-                                       CALLBACK_A(SelectModePresenter::onPopupHWBackKey));
-
-                       m_popup.reset();
-
-                       broadcastActivate();
-               }
-       }
-
-       void SelectModePresenter::dispatchEvent(const Event event)
-       {
-               if (const auto listener = m_listener.lock()) {
-                       listener->onSelectModeEvent(event);
-               }
-       }
-
-       void SelectModePresenter::onPopupDismissed(
-                       Widget &widget, void *eventInfo)
-       {
-               deletePopup();
-       }
-
-       void SelectModePresenter::onPopupHWBackKey(
-                       Evas_Object *obj, void *eventInfo)
-       {
-               if (isActive()) {
-                       dismissPopup();
-               }
-       }
-
-       void SelectModePresenter::onSelectAll(
-                       Evas_Object *obj, void *eventInfo)
-       {
-               if (m_popup && (m_popup->getEo() == obj)) {
-                       dismissPopup();
-                       dispatchEvent(Event::SELECT_ALL);
-               }
-       }
-
-       void SelectModePresenter::onDeselectAll(
-                       Evas_Object *obj, void *eventInfo)
-       {
-               if (m_popup && (m_popup->getEo() == obj)) {
-                       dismissPopup();
-                       dispatchEvent(Event::DESELECT_ALL);
-               }
-       }
-
-       void SelectModePresenter::onSelectBtnClick(
-                       Widget &widget, void *eventInfo)
-       {
-               if (isActive() && !m_popup && (m_totalCount > 0)) {
-                       showPopup();
-               }
-       }
-
-       void SelectModePresenter::onBottomBtnClick(
-                       Widget &widget, void *eventInfo)
-       {
-               if (isActive() && !m_popup && (m_selectCount > 0)) {
-                       dispatchEvent(Event::BOTTOM_BUTTON_CLICK);
-               }
-       }
-
-       Eina_Bool SelectModePresenter::onRotary(Eext_Rotary_Event_Info *info)
-       {
-               if (isActive()) {
-                       dismissPopup();
-               }
-               return EINA_TRUE;
-       }
-}
diff --git a/src/presenters/ThumbnailPage.cpp b/src/presenters/ThumbnailPage.cpp
deleted file mode 100644 (file)
index abd1ce2..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/ThumbnailPage.h"
-
-#include "gallery/presenters/PreviewPage.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr auto NAVIFRAME_TRANSITION_TIME_SEC = 0.3;
-
-       constexpr auto BRING_IN_SCROLL_FRICTION = 0.5;
-       constexpr auto PAGE_SCROLL_IN_FRICTION = 0.5;
-
-       enum {
-               MORE_OPTION_ID_DELETE
-       };
-}}}
-
-namespace gallery {
-
-       using ucl::NaviItem;
-       using ucl::NaviframeSRef;
-       using ucl::RefCountAware;
-
-       // ThumbnailPage::Builder //
-
-       ThumbnailPage::Builder::Builder()
-       {
-       }
-
-       ThumbnailPage::Builder::~Builder()
-       {
-       }
-
-       ThumbnailPage::Builder &ThumbnailPage::Builder::setNaviframe(
-                       const NaviframeSRef &navi)
-       {
-               m_navi = navi;
-               return *this;
-       }
-
-       ThumbnailPage::Builder &ThumbnailPage::Builder::setAlbum(
-                       const IMediaAlbumSRef &album)
-       {
-               m_album = album;
-               return *this;
-       }
-
-       ThumbnailPageWRef ThumbnailPage::Builder::build(
-                       const ExitRequestHandler &onExitRequest) const
-       {
-               if (!onExitRequest) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "onExitRequest is NULL");
-               }
-               if (!m_navi) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
-               }
-               if (!m_album) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
-               }
-
-               auto result = makeShared<ThumbnailPage>(
-                               m_navi, onExitRequest, m_album);
-
-               FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
-                       {
-                               return result->doPrepare(item);
-                       }),
-                       {}, "result->prepare() failed!");
-
-               return result;
-       }
-
-       // ThumbnailPage::RealizedItem //
-
-       class ThumbnailPage::RealizedItem : public RefCountAware {
-       public:
-               RealizedItem(IRefCountObj &rc,
-                               ThumbnailPage &parent, const int index) :
-                       RefCountAware(&rc),
-                       m_parent(parent),
-                       m_index(index)
-               {
-                       FAIL_LOG(m_parent.m_mediaItems[m_index]->getThumbnailPath(
-                                       WEAK_DELEGATE(RealizedItem::onThumbnail, asWeak(this))),
-                                       "getThumbnailPath() failed!");
-               }
-
-               virtual ~RealizedItem()
-               {
-                       m_parent.m_mediaItems[m_index]->cancelThumbnailPathGet();
-               }
-
-               int getIndex() const
-               {
-                       return m_index;
-               }
-
-       private:
-               void onThumbnail(const Result result, const std::string &path)
-               {
-                       FAIL_RETURN_VOID(result, "Failed to get thumbnail!");
-
-                       ImageGrid::ItemParams params = {};
-                       params.imagePath = path;
-                       m_parent.m_mediaItems[m_index]->getResolution(
-                                       params.imageWidth, params.imageHeight);
-
-                       m_parent.m_imageGrid->updateItem(m_index, params);
-               }
-
-       private:
-               ThumbnailPage &m_parent;
-               int m_index;
-       };
-
-       // ThumbnailPage //
-
-       ThumbnailPage::ThumbnailPage(IRefCountObj &rc,
-                       const NaviframeSRef &navi,
-                       const ExitRequestHandler &onExitRequest,
-                       const IMediaAlbumSRef &album) :
-               Page(rc, navi, onExitRequest),
-               m_album(album)
-       {
-       }
-
-       ThumbnailPage::~ThumbnailPage()
-       {
-               if (m_album) {
-                       m_album->delChangeHandler(WEAK_DELEGATE(
-                                       ThumbnailPage::onAlbumChanged, asWeak(*this)));
-               }
-               if (m_more) {
-                       m_more->setOpened(false);
-               }
-               util::dispose(m_page);
-               if (m_imageGrid) {
-                       m_imageGrid->setListener(nullptr);
-               }
-       }
-
-       void ThumbnailPage::reload()
-       {
-               ImageGrid::Unrealizer u(*m_imageGrid);
-
-               m_mediaItems.clear();
-
-               FAIL_LOG(m_album->forEachMedia(
-                               DELEGATE(ThumbnailPage::onEachMedia, this)),
-                               "m_album->forEachMedia() failed!");
-
-               m_imageGrid->setItemCount(m_mediaItems.size());
-       }
-
-       Result ThumbnailPage::doPrepare(NaviItem &item)
-       {
-               m_content = PageContent::Builder().
-                               setFlags(PageContent::FLAG_MORE_OPTIONS).
-                               build(getNaviframe());
-               if (!m_content) {
-                       LOG_RETURN(RES_FAIL, "PageContent::build() failed!");
-               }
-               setDeactivatorSink(m_content);
-
-               m_imageGrid = ImageGrid::Builder().
-                               setListener(asWeakThis<ImageGrid::IListener>(this)).
-                               setType(ImageGrid::Type::HCOMB_3X3).
-                               build(*m_content);
-               if (!m_imageGrid) {
-                       LOG_RETURN(RES_FAIL, "ImageGrid::build() failed!");
-               }
-               m_content->set(*m_imageGrid);
-
-               m_more = MoreOptionsPresenter::Builder().
-                               setParentWidget(m_content).
-                               addOption({impl::MORE_OPTION_ID_DELETE,
-                                       STR_DELETE, nullptr,
-                                       getImageTheme(ICON_MORE_OPT_DELETE)}).
-                               build(*this);
-               if (!m_more) {
-                       LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!");
-               }
-               m_content->set(m_more->getWidget(), PageContent::Part::MORE_OPTIONS);
-
-               m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow());
-               if (!m_atspiHelper) {
-                       LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!");
-               }
-
-               FAIL_RETURN(m_album->forEachMedia(
-                               DELEGATE(ThumbnailPage::onEachMedia, this)),
-                               "m_album->forEachMedia() failed!");
-
-               m_imageGrid->setItemCount(m_mediaItems.size());
-
-               item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP);
-               if (!item) {
-                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
-               }
-
-               m_album->addChangeHandler(WEAK_DELEGATE(
-                               ThumbnailPage::onAlbumChanged, asWeak(*this)));
-
-               m_more->setListener(asWeakThis<MoreOptionsPresenter::IListener>(this));
-
-               m_atspiHelper->setEventHandler(WEAK_DELEGATE(
-                               ThumbnailPage::onAtspiHighlight, asWeak(*this)));
-
-               return RES_OK;
-       }
-
-       void ThumbnailPage::onAlbumChanged()
-       {
-               if (!isEmpty(m_album)) {
-                       reload();
-               }
-       }
-
-       bool ThumbnailPage::onEachMedia(MediaItemSRef &&media)
-       {
-               m_mediaItems.emplace_back(std::move(media));
-               return true;
-       }
-
-       void ThumbnailPage::onActivateBy(const DeactivatorInfo &info)
-       {
-               if (info.deactivator == &getNaviframe()) {
-                       elm_config_scroll_page_scroll_friction_set(
-                                       impl::PAGE_SCROLL_IN_FRICTION);
-                       elm_config_scroll_bring_in_scroll_friction_set(
-                                       impl::BRING_IN_SCROLL_FRICTION);
-               }
-
-               if (isActive()) {
-                       m_imageGrid->activateRotary();
-               }
-       }
-
-       void ThumbnailPage::onDeactivateBy(const DeactivatorInfo &info)
-       {
-               m_imageGrid->deactivateRotary();
-       }
-
-       Elm_Interface_Atspi_Accessible *ThumbnailPage::onAtspiHighlight(
-                               Widget &widget, Elm_Atspi_Relation_Type flowRelation)
-       {
-               return m_imageGrid->getAccessObject(true);
-       }
-
-       void ThumbnailPage::onItemRealized(const int itemIndex)
-       {
-               m_realizedItems.emplace_back(
-                               makeShared<RealizedItem>(*this, itemIndex));
-       }
-
-       void ThumbnailPage::onItemUnrealized(const int itemIndex)
-       {
-               const auto it = std::find_if(
-                               m_realizedItems.begin(), m_realizedItems.end(),
-                               [itemIndex](const RealizedItemSRef &item)
-                               {
-                                       return (item->getIndex() == itemIndex);
-                               });
-               if (it != m_realizedItems.end()) {
-                       m_realizedItems.erase(it);
-               } else {
-                       WLOG("Item is not found in realized list!");
-               }
-       }
-
-       void ThumbnailPage::onItemEvent(const int itemIndex,
-                       const ImageGrid::ItemEvent event, const int x, const int y)
-       {
-               if (!isActive() || m_more->isOpened()) {
-                       return;
-               }
-
-               bool selectModeStartup = false;
-
-               switch (event) {
-               case ImageGrid::ItemEvent::CLICK:
-                       break;
-               case ImageGrid::ItemEvent::TAP_AND_HOLD:
-                       selectModeStartup = true;
-                       break;
-               default:
-                       return;
-               }
-
-               m_page = PreviewPage::Builder().
-                               setNaviframe(asShared(getNaviframe())).
-                               setAlbum(m_album).
-                               setStartItemIndex(itemIndex).
-                               setSelectModeStartup(selectModeStartup).
-                               setAutoSelectStartItem(true).
-                               build(WEAK_DELEGATE(
-                                       ThumbnailPage::onPageExitRequest, asWeak(*this)));
-       }
-
-       void ThumbnailPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
-                       const MoreOptionsPresenter::Option &option)
-       {
-               switch (option.id) {
-               case impl::MORE_OPTION_ID_DELETE:
-                       sender.setOpenedDelayed(false, impl::NAVIFRAME_TRANSITION_TIME_SEC);
-                       m_page = PreviewPage::Builder().
-                                       setNaviframe(asShared(getNaviframe())).
-                                       setAlbum(m_album).
-                                       setStartItemIndex(m_imageGrid->getScrolledToItemIndex()).
-                                       setSelectModeStartup(true).
-                                       build(WEAK_DELEGATE(
-                                               ThumbnailPage::onPageExitRequest, asWeak(*this)));
-                       break;
-               default:
-                       sender.setOpened(false);
-                       WLOG("Unknown option id: %d;", option.id);
-                       break;
-               }
-       }
-
-       void ThumbnailPage::onPageExitRequest(Page &page)
-       {
-               if (const auto page = dynamicRefCast<PreviewPage>(m_page).lock()) {
-                       m_imageGrid->scrollToItem(getSafeItemIndex(
-                                       page->getCurrentItemIndex()));
-               }
-               m_page.reset();
-               popTo();
-       }
-
-       int ThumbnailPage::getSafeItemIndex(const int itemIndex) const
-       {
-               if (itemIndex < 0) {
-                       return 0;
-               }
-               if (itemIndex >= static_cast<int>(m_mediaItems.size())) {
-                       return (m_mediaItems.size() - 1);
-               }
-               return itemIndex;
-       }
-}
diff --git a/src/presenters/VideoPlayerPage.cpp b/src/presenters/VideoPlayerPage.cpp
deleted file mode 100644 (file)
index ebeb3f7..0000000
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/VideoPlayerPage.h"
-
-#include <efl_util.h>
-
-#include "ucl/appfw/types.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr auto AUTO_START_TIMEOUT_SEC = 0.3;
-       constexpr auto CONTROLS_PLAYBACK_HIDE_TIMEOUT_SEC = 3.0;
-       constexpr auto CONTROLS_PAUSE_HIDE_TIMEOUT_SEC = 6.0;
-
-       constexpr auto TICK_TIMER_INTERVAL_SEC = 0.1;
-
-       constexpr auto TIME_SEC_MS = 1000;
-       constexpr auto TIME_MIN_SEC = 60;
-       constexpr auto TIME_HOUR_MIN = 60;
-
-       const TString TIME_SHORT_FORMAT {"%02d:%02d / %02d:%02d"};
-       const TString TIME_LONG_FORMAT {"%02d:%02d:%02d / %02d:%02d:%02d"};
-
-       constexpr LayoutTheme LAYOUT_VIDEO_PLAYER
-                       {"layout", "gallery", "video_player"};
-
-       constexpr ElmStyle STYLE_VOLUME_ON_BTN {"gallery_video_volume_on"};
-       constexpr ElmStyle STYLE_VOLUME_MUTE_BTN {"gallery_video_volume_mute"};
-       constexpr ElmStyle STYLE_PLAY_BTN {"gallery_video_play"};
-       constexpr ElmStyle STYLE_PAUSE_BTN {"gallery_video_pause"};
-
-       constexpr EdjePart PART_VOLUME_ON_BTN {"gallery.swallow.volume_on"};
-       constexpr EdjePart PART_VOLUME_MUTE_BTN {"gallery.swallow.volume_mute"};
-       constexpr EdjePart PART_PLAY_BTN {"gallery.swallow.play"};
-       constexpr EdjePart PART_PAUSE_BTN {"gallery.swallow.pause"};
-
-       constexpr EdjeSignal SHOW_VOLUME_ON_BTN {"show,volume_on,btn"};
-       constexpr EdjeSignal SHOW_VOLUME_MUTE_BTN {"show,volume_mute,btn"};
-       constexpr EdjeSignal HIDE_VOLUME_BTN {"hide,volume,btn"};
-
-       constexpr EdjeSignal SHOW_PLAY_BTN {"show,play,btn"};
-       constexpr EdjeSignal SHOW_PAUSE_BTN {"show,pause,btn"};
-       constexpr EdjeSignal HIDE_PLAY_PAUSE_BTN {"hide,play_pause,btn"};
-
-       constexpr EdjeSignal SHOW_TEXT {"show,text"};
-       constexpr EdjeSignal HIDE_TEXT {"hide,text"};
-
-       void timeMsToHMS(int timeMs, int &h, int &m, int &s)
-       {
-               int t = (timeMs / TIME_SEC_MS);
-               s = (t % TIME_MIN_SEC);
-               t /= TIME_MIN_SEC;
-               m = (t % TIME_HOUR_MIN);
-               h = (t / TIME_HOUR_MIN);
-       }
-}}}
-
-namespace gallery {
-
-       using ucl::AutoAppCtrl;
-
-       using ucl::NaviItem;
-       using ucl::NaviframeSRef;
-       using ucl::Layout;
-       using ucl::StyledWidgetSRef;
-       using ucl::WidgetEventHandler;
-
-       // VideoPlayerPage::Builder //
-
-       VideoPlayerPage::Builder::Builder()
-       {
-       }
-
-       VideoPlayerPage::Builder::~Builder()
-       {
-       }
-
-       VideoPlayerPage::Builder &VideoPlayerPage::Builder::setNaviframe(
-                       const NaviframeSRef &navi)
-       {
-               m_navi = navi;
-               return *this;
-       }
-
-       VideoPlayerPage::Builder &VideoPlayerPage::Builder::setMedia(
-                       const MediaItemSRef &media)
-       {
-               m_media = media;
-               return *this;
-       }
-
-       VideoPlayerPageWRef VideoPlayerPage::Builder::build(
-                       const ExitRequestHandler &onExitRequest) const
-       {
-               if (!onExitRequest) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "onExitRequest is NULL");
-               }
-               if (!m_navi) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
-               }
-               if (!m_media) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_media is NULL");
-               }
-               if (m_media->getType() != MediaType::VIDEO) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Wrong media type");
-               }
-
-               auto result = makeShared<VideoPlayerPage>(
-                               m_navi, onExitRequest, m_media);
-
-               FAIL_RETURN_VALUE(result->prepare([&result](NaviItem &item)
-                       {
-                               return result->doPrepare(item);
-                       }),
-                       {}, "result->prepare() failed!");
-
-               return result;
-       }
-
-       // VideoPlayerPage //
-
-       VideoPlayerPage::VideoPlayerPage(IRefCountObj &rc,
-                       const NaviframeSRef &navi,
-                       const ExitRequestHandler &onExitRequest,
-                       const MediaItemSRef &media) :
-               Page(rc, navi, onExitRequest),
-               m_media(media),
-               m_player(),
-               m_videoDuration(0),
-               m_autoStartTimer(nullptr),
-               m_controlsHideTimer(nullptr),
-               m_tickTimer(nullptr),
-               m_state(State::PAUSED),
-               m_isControlsVisible(false),
-               m_needAutoStart(true),
-               m_isPlaybackCompleted(false)
-       {
-       }
-
-       VideoPlayerPage::~VideoPlayerPage()
-       {
-               util::dispose(m_alert);
-
-               if (m_soundMgr) {
-                       m_soundMgr->delMediaDeviceStateChangeHandler(WEAK_DELEGATE(
-                                       VideoPlayerPage::onMediaDeviceStateChanged, asWeak(*this)));
-                       m_soundMgr->delMediaVolumeChangeHandler(WEAK_DELEGATE(
-                                       VideoPlayerPage::onMediaVolumeChanged, asWeak(*this)));
-               }
-
-               if (isWindowReady()) {
-                       setScreenAlwaysOn(false);
-               }
-
-               delRotaryEventHandler(CALLBACK_A(VideoPlayerPage::onRotary), this);
-
-               stopTimer(m_autoStartTimer);
-               stopTimer(m_controlsHideTimer);
-               stopTimer(m_tickTimer);
-
-               if (m_player) {
-                       if (getPlayerState() != PLAYER_STATE_IDLE) {
-                               FAIL_LOG(util::call(player_unprepare, m_player),
-                                               "player_unprepare() failed!");
-                       }
-                       FAIL_LOG(util::call(player_destroy, m_player),
-                                       "player_destroy() failed!");
-               }
-       }
-
-       Result VideoPlayerPage::doPrepare(NaviItem &item)
-       {
-               m_content = Layout::Builder().
-                               setTheme(impl::LAYOUT_VIDEO_PLAYER).
-                               build(getNaviframe());
-               if (!m_content) {
-                       LOG_RETURN(RES_FAIL, "m_content is NULL");
-               }
-
-               item = getNaviframe().push(*m_content, NAVIFRAME_NO_CLIP);
-               if (!item) {
-                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
-               }
-
-               createImage();
-
-               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_touchParser = makeShared<TouchParser>(*m_image);
-               m_touchParser->setTapHandler(WEAK_DELEGATE(
-                               VideoPlayerPage::onTap, asWeak(*this)));
-
-               getWindow().addEventHandler(INSTANCE_PAUSED, WEAK_DELEGATE(
-                               VideoPlayerPage::onInstancePaused, asWeak(*this)));
-               getWindow().addEventHandler(INSTANCE_RESUMED, WEAK_DELEGATE(
-                               VideoPlayerPage::onInstanceResumed, asWeak(*this)));
-
-               addRotaryEventHandler(CALLBACK_A(VideoPlayerPage::onRotary), this);
-
-               if (!isInstancePaused(getWindow())) {
-                       resetAutoStartTimer();
-               }
-
-               return RES_OK;
-       }
-
-       Result VideoPlayerPage::prepareSoundManager()
-       {
-               m_soundMgr = SoundManager::newInstance();
-               if (!m_soundMgr) {
-                       LOG_RETURN(RES_FAIL, "SoundManager::newInstance() failed!");
-               }
-
-               m_soundMgr->addMediaDeviceStateChangeHandler(WEAK_DELEGATE(
-                               VideoPlayerPage::onMediaDeviceStateChanged, asWeak(*this)));
-
-               m_soundMgr->addMediaVolumeChangeHandler(WEAK_DELEGATE(
-                               VideoPlayerPage::onMediaVolumeChanged, asWeak(*this)));
-
-               return RES_OK;
-       }
-
-       void VideoPlayerPage::createImage()
-       {
-               m_image = makeShared<Widget>(
-                               evas_object_image_filled_add(m_content->getEvas()));
-               show(*m_image);
-
-               m_content->setContent(*m_image);
-       }
-
-       Result VideoPlayerPage::preparePlayer()
-       {
-               FAIL_RETURN(util::getNz(player_create, m_player),
-                               "player_create() failed!");
-
-               FAIL_RETURN(util::call(player_set_display_mode, m_player,
-                               PLAYER_DISPLAY_MODE_CROPPED_FULL),
-                               "player_set_display_mode() failed!");
-
-               FAIL_RETURN(util::call(player_set_display, m_player,
-                               PLAYER_DISPLAY_TYPE_EVAS, GET_DISPLAY(m_image->getEo())),
-                               "player_set_display() failed!");
-
-               FAIL_RETURN(util::call(player_set_uri, m_player,
-                               m_media->getFilePath().c_str()),
-                               "player_set_uri() 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!");
-
-               FAIL_RETURN(seekToStart(), "seekToStart() failed!");
-
-               FAIL_RETURN(util::call(player_set_completed_cb, m_player,
-                               CALLBACK_B(VideoPlayerPage::onPlaybackComplete), this),
-                               "player_set_completed_cb() failed!");
-
-               FAIL_RETURN(util::call(player_set_interrupted_cb, m_player,
-                               CALLBACK_B(VideoPlayerPage::onPlaybackInterrupted),
-                               this), "player_set_interrupted_cb() failed!");
-
-               return RES_OK;
-       }
-
-       Result VideoPlayerPage::seekToStart()
-       {
-               FAIL_RETURN(util::call(player_set_play_position, m_player, true, 0,
-                               CALLBACK_B(VideoPlayerPage::onSeekComplete), this),
-                               "player_set_play_position() failed!");
-               return RES_OK;
-       }
-
-       void VideoPlayerPage::createControls()
-       {
-               createButton(impl::STYLE_VOLUME_ON_BTN, impl::PART_VOLUME_ON_BTN,
-                               WEAK_DELEGATE(VideoPlayerPage::onVolumeBtnClick,
-                               asWeak(*this)));
-
-               m_volumeMuteBtn = createButton(impl::STYLE_VOLUME_MUTE_BTN,
-                               impl::PART_VOLUME_MUTE_BTN,
-                               WEAK_DELEGATE(VideoPlayerPage::onVolumeBtnClick,
-                               asWeak(*this)));
-
-               createButton(impl::STYLE_PLAY_BTN, impl::PART_PLAY_BTN,
-                               WEAK_DELEGATE(VideoPlayerPage::onPlayBtnClick,
-                               asWeak(*this)));
-
-               createButton(impl::STYLE_PAUSE_BTN, impl::PART_PAUSE_BTN,
-                               WEAK_DELEGATE(VideoPlayerPage::onPauseBtnClick,
-                               asWeak(*this)));
-       }
-
-       StyledWidgetSRef VideoPlayerPage::createButton(const ElmStyle style,
-                       const EdjePart part, const WidgetEventHandler &handler)
-       {
-               const auto btn = makeShared<StyledWidget>(
-                               elm_button_add(*m_content), false);
-               btn->setStyle(style);
-               show(*btn);
-
-               m_content->setContent(*btn, part);
-
-               btn->addEventHandler(BTN_CLICKED, handler);
-
-               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)
-       {
-               stopTimer(timer);
-
-               timer = ecore_timer_add(timeout, func, this);
-               if (!timer) {
-                       LOG_RETURN_VALUE(RES_FAIL, false, "ecore_timer_add() failed!");
-               }
-
-               return true;
-       }
-
-       void VideoPlayerPage::stopTimer(Ecore_Timer *&timer)
-       {
-               if (timer) {
-                       ecore_timer_del(timer);
-                       timer = nullptr;
-               }
-       }
-
-       bool VideoPlayerPage::resetAutoStartTimer()
-       {
-               return resetTimer(m_autoStartTimer, impl::AUTO_START_TIMEOUT_SEC,
-                               CALLBACK_A(VideoPlayerPage::onAutoStartTimer));
-       }
-
-       bool VideoPlayerPage::resetControlsHideTimer()
-       {
-               if (m_isPlaybackCompleted) {
-                       stopTimer(m_controlsHideTimer);
-                       return true;
-               }
-               return resetTimer(m_controlsHideTimer,
-                               ((m_state == State::PLAYING) ?
-                                       impl::CONTROLS_PLAYBACK_HIDE_TIMEOUT_SEC :
-                                       impl::CONTROLS_PAUSE_HIDE_TIMEOUT_SEC
-                               ),
-                               CALLBACK_A(VideoPlayerPage::onControlsHideTimer));
-       }
-
-       bool VideoPlayerPage::resetTickTimer()
-       {
-               return resetTimer(m_tickTimer, impl::TICK_TIMER_INTERVAL_SEC,
-                               CALLBACK_A(VideoPlayerPage::onTickTimer));
-       }
-
-       void VideoPlayerPage::showControls()
-       {
-               if (!m_isControlsVisible) {
-                       m_isControlsVisible = true;
-
-                       showVolumeBtn();
-
-                       if (m_state == State::PLAYING) {
-                               m_content->emit(impl::SHOW_PAUSE_BTN);
-                               resetTickTimer();
-                               updatePlayTimeText();
-                       } else {
-                               m_content->emit(impl::SHOW_PLAY_BTN);
-                       }
-
-                       m_content->emit(impl::SHOW_TEXT);
-               }
-
-               resetControlsHideTimer();
-       }
-
-       void VideoPlayerPage::hideControls()
-       {
-               if (m_isControlsVisible) {
-                       m_isControlsVisible = false;
-
-                       m_content->emit(impl::HIDE_VOLUME_BTN);
-                       m_content->emit(impl::HIDE_PLAY_PAUSE_BTN);
-                       m_content->emit(impl::HIDE_TEXT);
-
-                       stopTimer(m_tickTimer);
-                       stopTimer(m_controlsHideTimer);
-               }
-       }
-
-       void VideoPlayerPage::showVolumeBtn()
-       {
-               if (!m_soundMgr || !m_soundMgr->isMediaDeviceReady()) {
-                       m_content->emit(impl::SHOW_VOLUME_MUTE_BTN);
-                       disable(*m_volumeMuteBtn);
-               } else {
-                       if (m_soundMgr->getCurrentMediaVolume() > 0) {
-                               m_content->emit(impl::SHOW_VOLUME_ON_BTN);
-                       } else {
-                               m_content->emit(impl::SHOW_VOLUME_MUTE_BTN);
-                               enable(*m_volumeMuteBtn);
-                       }
-               }
-       }
-
-       bool VideoPlayerPage::updatePlayTimeText()
-       {
-               int playPosition = 0;
-
-               if (isBad(util::get(player_get_play_position,
-                               playPosition, m_player))) {
-                       ELOG("player_get_play_position() failed!");
-                       return false;
-               }
-
-               updatePlayTimeText(std::min(playPosition, m_videoDuration));
-
-               return true;
-       }
-
-       void VideoPlayerPage::updatePlayTimeText(const int timeMs)
-       {
-               int posH = 0;
-               int posM = 0;
-               int posS = 0;
-               impl::timeMsToHMS(timeMs, posH, posM, posS);
-
-               int durH = 0;
-               int durM = 0;
-               int durS = 0;
-               impl::timeMsToHMS(m_videoDuration, durH, durM, durS);
-
-               if (durH == 0) {
-                       m_content->setText(impl::TIME_SHORT_FORMAT.format(
-                                       posM, posS, durM, durS));
-               } else {
-                       m_content->setText(impl::TIME_LONG_FORMAT.format(
-                                       posH, posM, posS, durH, durM, durS));
-               }
-       }
-
-       player_state_e VideoPlayerPage::getPlayerState() const
-       {
-               player_state_e result = PLAYER_STATE_NONE;
-               FAIL_LOG(util::getNz(player_get_state, result, m_player),
-                               "player_get_state() failed!");
-               return result;
-       }
-
-       void VideoPlayerPage::startPlayback()
-       {
-               if (m_state != State::PAUSED) {
-                       return;
-               }
-               m_state = State::PLAYING;
-
-               const auto playerState = getPlayerState();
-               switch (playerState) {
-               case PLAYER_STATE_READY:
-               case PLAYER_STATE_PAUSED:
-                       if (m_isPlaybackCompleted) {
-                               m_isPlaybackCompleted = false;
-                               FAIL_LOG(seekToStart(), "seekToStart() failed!");
-                       } else {
-                               FAIL_LOG(util::call(player_start, m_player),
-                                               "player_start() failed!");
-                       }
-                       break;
-               default:
-                       WLOG("Unexpected player state: %d;", playerState);
-                       break;
-               }
-
-               setScreenAlwaysOn(true);
-               resetTickTimer();
-               stopTimer(m_autoStartTimer);
-               m_needAutoStart = false;
-
-               if (m_isControlsVisible) {
-                       m_content->emit(impl::SHOW_PAUSE_BTN);
-               }
-       }
-
-       void VideoPlayerPage::pausePlayback()
-       {
-               if (m_state != State::PLAYING) {
-                       return;
-               }
-               m_state = State::PAUSED;
-
-               const auto playerState = getPlayerState();
-               switch (playerState) {
-               case PLAYER_STATE_PLAYING:
-                       FAIL_LOG(util::call(player_pause, m_player),
-                                       "player_pause() failed!");
-                       break;
-               default:
-                       WLOG("Unexpected player state: %d;", playerState);
-                       break;
-               }
-
-               setScreenAlwaysOn(false);
-               stopTimer(m_tickTimer);
-               updatePlayTimeText();
-
-               if (m_isControlsVisible) {
-                       m_content->emit(impl::SHOW_PLAY_BTN);
-               }
-       }
-
-       void VideoPlayerPage::setScreenAlwaysOn(bool isAlwaysOn)
-       {
-               efl_util_set_window_screen_mode(getWindow(),
-                               (isAlwaysOn ? EFL_UTIL_SCREEN_MODE_ALWAYS_ON :
-                                       EFL_UTIL_SCREEN_MODE_DEFAULT));
-       }
-
-       Result VideoPlayerPage::launchVolumeSettings()
-       {
-               AutoAppCtrl appCtrl;
-
-               FAIL_RETURN(util::getNz(app_control_create, appCtrl),
-                               "app_control_create() failed!");
-
-               FAIL_RETURN(util::call(app_control_set_app_id,
-                               appCtrl, "org.tizen.watch-setting"),
-                               "app_control_set_app_id() failed!");
-
-               FAIL_RETURN(util::call(app_control_add_extra_data,
-                               appCtrl, "launch-type", "volume"),
-                               "app_control_add_extra_data() failed!");
-
-               FAIL_RETURN(util::call(app_control_send_launch_request,
-                               appCtrl, nullptr, nullptr),
-                               "app_control_send_launch_request() failed!");
-
-               return RES_OK;
-       }
-
-       void VideoPlayerPage::onMediaDeviceStateChanged()
-       {
-               if (m_isControlsVisible) {
-                       showVolumeBtn();
-               }
-       }
-
-       void VideoPlayerPage::onMediaVolumeChanged()
-       {
-               if (m_isControlsVisible) {
-                       showVolumeBtn();
-               }
-       }
-
-       void VideoPlayerPage::onPlaybackComplete()
-       {
-               m_isPlaybackCompleted = true;
-               pausePlayback();
-               requestExit();
-       }
-
-       void VideoPlayerPage::onPlaybackInterrupted(player_interrupted_code_e code)
-       {
-               if (code != PLAYER_INTERRUPTED_COMPLETED) {
-                       pausePlayback();
-                       showControls();
-               }
-       }
-
-       void VideoPlayerPage::onSeekComplete()
-       {
-               if ((m_state == State::PLAYING) &&
-                               (getPlayerState() != PLAYER_STATE_PLAYING)) {
-                       FAIL_LOG(util::call(player_start, m_player),
-                                       "player_start() failed!");
-               }
-       }
-
-       Eina_Bool VideoPlayerPage::onAutoStartTimer()
-       {
-               m_autoStartTimer = nullptr;
-
-               startPlayback();
-
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       Eina_Bool VideoPlayerPage::onControlsHideTimer()
-       {
-               m_controlsHideTimer = nullptr;
-
-               hideControls();
-
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       Eina_Bool VideoPlayerPage::onTickTimer()
-       {
-               if (!updatePlayTimeText()) {
-                       m_tickTimer = nullptr;
-                       return ECORE_CALLBACK_CANCEL;
-               }
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       void VideoPlayerPage::onVolumeBtnClick(Widget &sender, void *eventInfo)
-       {
-               FAIL_LOG(launchVolumeSettings(), "launchVolumeSettings() failed!");
-       }
-
-       void VideoPlayerPage::onPlayBtnClick(Widget &sender, void *eventInfo)
-       {
-               startPlayback();
-               resetControlsHideTimer();
-       }
-
-       void VideoPlayerPage::onPauseBtnClick(Widget &sender, void *eventInfo)
-       {
-               pausePlayback();
-               resetControlsHideTimer();
-       }
-
-       void VideoPlayerPage::onTap(int x, int y)
-       {
-               if (m_isControlsVisible) {
-                       hideControls();
-               } else {
-                       showControls();
-               }
-       }
-
-       Eina_Bool VideoPlayerPage::onRotary(Eext_Rotary_Event_Info *info)
-       {
-               showControls();
-               return EINA_TRUE;
-       }
-
-       void VideoPlayerPage::onInstancePaused(Widget &sender, void *eventInfo)
-       {
-               pausePlayback();
-               stopTimer(m_autoStartTimer);
-               stopTimer(m_controlsHideTimer);
-       }
-
-       void VideoPlayerPage::onInstanceResumed(Widget &sender, void *eventInfo)
-       {
-               if (m_needAutoStart) {
-                       resetAutoStartTimer();
-               } else {
-                       showControls();
-               }
-       }
-}
diff --git a/src/presenters/ViewerPage.cpp b/src/presenters/ViewerPage.cpp
deleted file mode 100644 (file)
index 87135b8..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/presenters/ViewerPage.h"
-
-#include "gallery/resources.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       enum {
-               MORE_OPTION_ID_SAVE
-       };
-}}}
-
-namespace gallery {
-
-       using ucl::NaviItem;
-       using ucl::NaviframeSRef;
-
-       // ViewerPage::Builder //
-
-       ViewerPage::Builder::Builder() :
-               m_zoomInX(-1),
-               m_zoomInY(-1),
-               m_imageLoadSize(-1),
-               m_isImageLoadSizeFull(false),
-               m_exitOnZoomOut(true)
-       {
-       }
-
-       ViewerPage::Builder::~Builder()
-       {
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setNaviframe(
-                       const NaviframeSRef &navi)
-       {
-               m_navi = navi;
-               return *this;
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setMedia(
-                       const MediaItemSRef &media)
-       {
-               m_media = media;
-               return *this;
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setZoomIn(
-                       const int x, const int y)
-       {
-               m_zoomInX = x;
-               m_zoomInY = y;
-               return *this;
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setImageLoadSize(
-                       const int size, const bool isFull)
-       {
-               m_imageLoadSize = size;
-               m_isImageLoadSizeFull = isFull;
-               return *this;
-       }
-
-       ViewerPage::Builder &ViewerPage::Builder::setExitOnZoomOut(const bool value)
-       {
-               m_exitOnZoomOut = value;
-               return *this;
-       }
-
-       ViewerPageWRef ViewerPage::Builder::build(
-                       const ExitRequestHandler &onExitRequest) const
-       {
-               if (!onExitRequest) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "onExitRequest is NULL");
-               }
-               if (!m_navi) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
-               }
-               if (!m_media) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_media is NULL");
-               }
-               if (m_media->getType() != MediaType::IMAGE) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Wrong media type");
-               }
-
-               auto result = makeShared<ViewerPage>(
-                               m_navi, onExitRequest, m_media, m_exitOnZoomOut);
-
-               FAIL_RETURN_VALUE(result->prepare([this, &result](NaviItem &item)
-                       {
-                               return result->doPrepare(m_imageLoadSize,
-                                               m_isImageLoadSizeFull, item);
-                       }),
-                       {}, "result->prepare() failed!");
-
-               if ((m_zoomInX >= 0) && (m_zoomInY >= 0)) {
-                       result->zoomIn(m_zoomInX, m_zoomInY);
-               }
-
-               return result;
-       }
-
-       // ViewerPage //
-
-       ViewerPage::ViewerPage(IRefCountObj &rc,
-                       const NaviframeSRef &navi,
-                       const ExitRequestHandler &onExitRequest,
-                       const MediaItemSRef &media,
-                       const bool exitOnZoomOut) :
-               Page(rc, navi, onExitRequest),
-               m_media(media),
-               m_exitOnZoomOut(exitOnZoomOut)
-       {
-       }
-
-       ViewerPage::~ViewerPage()
-       {
-               if (m_more) {
-                       m_more->setOpened(false);
-               }
-       }
-
-       Result ViewerPage::doPrepare(const int imageLoadSize,
-                       const bool isImageLoadSizeFull, NaviItem &item)
-       {
-               const int mediaFlags = m_media->getFlags();
-               const bool canSave = (mediaFlags & MediaItem::FLAG_SAVE);
-               const bool hasThumb = (mediaFlags & MediaItem::FLAG_THUMBNAIL);
-               const bool useThumb = (hasThumb && (imageLoadSize < 0));
-               const bool forceLoad = (!useThumb && isImageLoadSizeFull);
-
-               m_imageViewer = ImageViewer::Builder().
-                               setHighResImagePath(m_media->getFilePath()).
-                               setLoadSize(imageLoadSize).
-                               setForceLoad(forceLoad).
-                               build(getNaviframe());
-               if (!m_imageViewer) {
-                       LOG_RETURN(RES_FAIL, "ImageViewer::build() failed!");
-               }
-
-               ElmWidget *rootWidget = m_imageViewer.get();
-
-               if (canSave) {
-                       m_content = PageContent::Builder().
-                                       setFlags(PageContent::FLAG_MORE_OPTIONS).
-                                       build(getNaviframe());
-                       if (!m_content) {
-                               LOG_RETURN(RES_FAIL, "PageContent::build() failed!");
-                       }
-                       setDeactivatorSink(m_content);
-
-                       rootWidget = m_content.get();
-                       m_content->set(*m_imageViewer);
-
-                       m_more = MoreOptionsPresenter::Builder().
-                                       setParentWidget(m_content).
-                                       addOption({impl::MORE_OPTION_ID_SAVE,
-                                               STR_SAVE_TO_GEAR, nullptr,
-                                               getImageTheme(ICON_MORE_OPT_SAVE)}).
-                                       build(*this);
-                       if (!m_more) {
-                               LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!");
-                       }
-
-                       m_content->set(m_more->getWidget(),
-                                       PageContent::Part::MORE_OPTIONS);
-
-                       m_more->setListener(asWeakThis<
-                                       MoreOptionsPresenter::IListener>(this));
-               }
-
-               if (useThumb) {
-                       FAIL_RETURN(m_media->getThumbnailPath(WEAK_DELEGATE(
-                                       ViewerPage::onThumbnail, asWeak(*this))),
-                                       "m_media->getThumbnailPath() failed!");
-               } else if (!forceLoad) {
-                       m_imageViewer->setLowResImagePath(m_media->getFilePath());
-               }
-
-               m_imageViewer->addEventHandler(IMAGE_VIEWER_ZOOM_END,
-                               WEAK_DELEGATE(ViewerPage::onZoomEnd, asWeak(*this)));
-
-               const auto topItem = getNaviframe().getTopItem();
-               if (topItem) {
-                       item = getNaviframe().insertAfter(topItem,
-                                       *rootWidget, NAVIFRAME_NO_CLIP);
-               } else {
-                       item = getNaviframe().push(*rootWidget, NAVIFRAME_NO_CLIP);
-               }
-               if (!item) {
-                       LOG_RETURN(RES_FAIL, "Naviframe::push() failed!");
-               }
-
-               m_touchParser = makeShared<TouchParser>(*m_imageViewer);
-               m_touchParser->setDoubleTapHandler(WEAK_DELEGATE(
-                               ViewerPage::onDoubleTap, asWeak(*this)));
-
-               return RES_OK;
-       }
-
-       void ViewerPage::zoomIn(const int originX, const int originY)
-       {
-               m_imageViewer->zoomIn(originX, originY);
-       }
-
-       const std::string &ViewerPage::getMediaId() const
-       {
-               return m_media->getId();
-       }
-
-       void ViewerPage::onThumbnail(const Result result, const std::string &path)
-       {
-               FAIL_RETURN_VOID(result, "Failed to get thumbnail!");
-
-               m_imageViewer->setLowResImagePath(path);
-       }
-
-       void ViewerPage::onZoomEnd(Widget &widget, void *eventInfo)
-       {
-               if (m_exitOnZoomOut && m_imageViewer->isZoomedOut()) {
-                       requestExit();
-               }
-       }
-
-       void ViewerPage::onDoubleTap(int x, int y)
-       {
-               if (!isActive()) {
-                       return;
-               }
-               if (m_imageViewer->isZoomedOut()) {
-                       m_imageViewer->zoomIn(x, y);
-               } else if (m_imageViewer->isZoomedIn()) {
-                       m_imageViewer->zoomOut();
-               }
-       }
-
-       void ViewerPage::onBackKey()
-       {
-               if (m_imageViewer->isZoomedOut()) {
-                       requestExit();
-               } else if (m_imageViewer->isZoomedIn()) {
-                       m_imageViewer->zoomOut();
-               }
-       }
-
-       void ViewerPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
-                       const MoreOptionsPresenter::Option &option)
-       {
-               sender.setOpened(false);
-
-               if (m_job) {
-                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "m_job is not NULL");
-               }
-
-               m_job = MediaItem::SaverBuilder().
-                               setItem(m_media).
-                               build(WEAK_DELEGATE(ViewerPage::onJobComplete, asWeak(*this)));
-               if (!m_job) {
-                       LOG_RETURN_VOID(RES_FAIL,
-                                       "MediaItem::SaverBuilder::build() failed!");
-               }
-
-               m_processing = ProcessingPresenter::Builder().
-                               setProcessingText(STR_SAVING).
-                               build(*m_content);
-       }
-
-       void ViewerPage::onJobComplete()
-       {
-               if (m_processing) {
-                       if (isGood(m_job->getResult())) {
-                               m_processing->complete(STR_SAVED,
-                                               ProcessingPresenter::IconType::CHECK);
-                       } else {
-                               m_processing->complete(STR_FAILED);
-                       }
-                       m_processing.reset();
-               }
-
-               m_job.reset();
-       }
-}
diff --git a/src/presenters/common.h b/src/presenters/common.h
deleted file mode 100644 (file)
index a769b95..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_COMMON_H__
-#define __GALLERY_PRESENTERS_COMMON_H__
-
-#include "helpers.h"
-
-#include "../view/common.h"
-
-#endif // __GALLERY_PRESENTERS_COMMON_H__
diff --git a/src/presenters/helpers.cpp b/src/presenters/helpers.cpp
deleted file mode 100644 (file)
index c325932..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "helpers.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr EoDataKey INSTANCE_PTR {"gallery,instance,data,ptr"};
-}}}
-
-namespace gallery {
-
-       using ucl::Window;
-
-       void setInstancePaused(Window &win, const bool value)
-       {
-               win.setData(impl::INSTANCE_PTR, reinterpret_cast<void *>(value));
-               win.callEvent((value ? INSTANCE_PAUSED : INSTANCE_RESUMED), nullptr);
-       }
-
-       bool isInstancePaused(const Window &win)
-       {
-               return (reinterpret_cast<intptr_t>(
-                               win.getData(impl::INSTANCE_PTR)) != 0);
-       }
-}
diff --git a/src/presenters/helpers.h b/src/presenters/helpers.h
deleted file mode 100644 (file)
index 0540406..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_PRESENTERS_HELPERS_H__
-#define __GALLERY_PRESENTERS_HELPERS_H__
-
-#include "ucl/gui/Window.h"
-
-namespace gallery {
-
-       constexpr ucl::SmartEvent INSTANCE_PAUSED {"gallery,instance,paused"};
-       constexpr ucl::SmartEvent INSTANCE_RESUMED {"gallery,instance,resumed"};
-
-       void setInstancePaused(ucl::Window &win, bool value);
-       bool isInstancePaused(const ucl::Window &win);
-}
-
-#endif // __GALLERY_PRESENTERS_HELPERS_H__
diff --git a/src/resources.cpp b/src/resources.cpp
deleted file mode 100644 (file)
index 256ccef..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/resources.h"
-
-namespace gallery {
-
-       using ucl::TString;
-
-       // TODO replace with IDS in the future
-
-       const TString STR_APP_NAME {"Gallery"};
-       const TString STR_NO_PHOTOS {"No photos"};
-       const TString STR_SELECT_ALL {"Select all"};
-       const TString STR_DESELECT_ALL {"Deselect all"};
-       const TString STR_DELETE {"Delete"};
-       const TString STR_DELETE_CAPS {"DELETE"};
-       const TString STR_DELETE_1_PHOTO {"Delete 1 photo?"};
-       const TString STR_DELETE_N_PHOTO {"Delete %d photo?"};
-       const TString STR_DELETING {"Deleting..."};
-       const TString STR_DELETED {"Deleted."};
-       const TString STR_FAILED {"Failed."};
-       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/src/view/ImageGrid.cpp b/src/view/ImageGrid.cpp
deleted file mode 100644 (file)
index 4d7c10c..0000000
+++ /dev/null
@@ -1,1807 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/view/ImageGrid.h"
-
-#include <array>
-#include <vector>
-
-#include "ucl/gui/Layout.h"
-#include "ucl/gui/Window.h"
-
-#include "gallery/view/TouchParser.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       // Related to ImageGrid //
-       const TString SLOT_PART_FMT {"swallow.cell_%d"};
-
-       const TString SIGNAL_SELECT_ITEM_FMT {"gallery,select,%d"};
-       const TString SIGNAL_UNSELECT_ITEM_FMT {"gallery,unselect,%d"};
-
-       constexpr EdjeDataKey DATA_IMAGE_MIN_LOAD_SIZE {"image_min_load_size"};
-
-       constexpr EdjeSignal SIGNAL_FORCE_SELECT_MODE
-                       {"gallery,force,select,mode"};
-       constexpr EdjeSignal SIGNAL_ENABLE_SELECT_MODE
-                       {"gallery,enable,select,mode"};
-       constexpr EdjeSignal SIGNAL_DISABLE_SELECT_MODE
-                       {"gallery,disable,select,mode"};
-       constexpr EdjeSignal SIGNAL_TRANSITION_FINISHED
-                       {"gallery,transition,finished"};
-
-       // Related to Button //
-       constexpr EdjePart BTN_PART_BG {"swallow.bg"};
-       constexpr EdjeSignal BTN_BLOCK_CLICKS {"gallery,block,clicks"};
-       constexpr EdjeSignal BTN_UNBLOCK_CLICKS {"gallery,unblock,clicks"};
-
-       // Other //
-       constexpr auto HCOMB_SCROLL_LIMIT = 1000;
-       constexpr auto SCROLL_HIGHLIGHT_TIMEOUT_SEC = 0.1;
-
-       bool getImageSize(const Widget &image, int &w, int &h)
-       {
-               int tmpW = 0;
-               int tmpH = 0;
-
-               evas_object_image_size_get(image, &tmpW, &tmpH);
-
-               if ((tmpW <= 0) || (tmpH <= 0)) {
-                       return false;
-               }
-
-               w = tmpW;
-               h = tmpH;
-
-               return true;
-       }
-}}}
-
-namespace gallery {
-
-       using ucl::Layout;
-
-       using ucl::Timeout;
-       using ucl::ceilDiv;
-
-       // ImageGrid::Builder //
-
-       ImageGrid::Builder::Builder() :
-               m_type(Type::HCOMB_3X3),
-               m_selectModeStartup(false)
-       {
-       }
-
-       ImageGrid::Builder &ImageGrid::Builder::setType(const Type value)
-       {
-               m_type = value;
-               return *this;
-       }
-
-       ImageGrid::Builder &ImageGrid::Builder::setListener(
-                       const IListenerWRef &value)
-       {
-               m_listener = value;
-               return *this;
-       }
-
-       ImageGrid::Builder &ImageGrid::Builder::setSelectModeStartup(
-                       const bool value)
-       {
-               m_selectModeStartup = value;
-               return *this;
-       }
-
-       ImageGridSRef ImageGrid::Builder::build(ElmWidget &parent) const
-       {
-               Evas_Object *const scrollerEo = elm_scroller_add(parent);
-               if (!scrollerEo) {
-                       ELOG("elm_scroller_add() failed!");
-                       return {};
-               }
-
-               auto result = makeShared<ImageGrid>(scrollerEo,
-                               m_type, m_selectModeStartup);
-
-               result->bindToEo();
-               result->setListener(m_listener);
-
-               return result;
-       }
-
-       // ImageGrid::Info //
-
-       struct ImageGrid::Info {
-               const std::array<LayoutTheme, 2> slotThemes;
-               const std::array<int, 2> slotLens;
-               const ElmStyle btnStyle;
-               const int scrollLimit;
-               const int slotsPerPage;
-               const bool isHorizontal;
-
-               virtual int calcItemIndexFromCell(
-                               const int slotIndex, const int itemOffset) const = 0;
-               virtual void calcCellFromItemIndex(const int itemIndex,
-                               int &slotIndex, int &itemOffset) const = 0;
-
-               virtual int calcMaxSlotCount(const int itemCount) const = 0;
-
-               virtual int calcExtraPaddingSize(const int slotSize) const
-               {
-                       return 0;
-               }
-
-               virtual int getHighlightScanRange() const
-               {
-                       return 1;
-               }
-
-               Info(const std::array<LayoutTheme, 2> &slotThemes,
-                               const std::array<int, 2> &slotLens,
-                               const ElmStyle btnStyle,
-                               const int scrollLimit, const int slotsPerPage,
-                               const bool isHorizontal) :
-                       slotThemes(slotThemes),
-                       slotLens(slotLens),
-                       btnStyle(btnStyle),
-                       scrollLimit(scrollLimit),
-                       slotsPerPage(slotsPerPage),
-                       isHorizontal(isHorizontal)
-               {
-               }
-
-               virtual ~Info() = default;
-       };
-
-       // ImageGrid::HcombInfo //
-
-       struct ImageGrid::HcombInfo : Info {
-               const int totalLength;
-
-               virtual int calcItemIndexFromCell(
-                               const int slotIndex, const int itemOffset) const final override
-               {
-                       return ((slotIndex / 2 * totalLength) +
-                                       (itemOffset * 2) + ((slotIndex ^ 1) & 1));
-               }
-
-               virtual void calcCellFromItemIndex(const int itemIndex,
-                               int &slotIndex, int &itemOffset) const final override
-               {
-                       slotIndex = (itemIndex / totalLength);
-                       itemOffset = (itemIndex % totalLength);
-                       slotIndex += (slotIndex + ((itemOffset ^ 1) & 1));
-                       itemOffset /= 2;
-               }
-
-               virtual int calcMaxSlotCount(const int itemCount) const final override
-               {
-                       return ((itemCount + (totalLength - 1)) / totalLength * 2);
-               }
-
-               virtual int calcExtraPaddingSize(
-                               const int slotSize) const final override
-               {
-                       return slotSize;
-               }
-
-               virtual int getHighlightScanRange() const final override
-               {
-                       return totalLength;
-               }
-
-               HcombInfo(const int totalLength,
-                               const std::array<LayoutTheme, 2> &slotThemes,
-                               const ElmStyle btnStyle) :
-                       Info(slotThemes, {{(totalLength / 2), ceilDiv<2>(totalLength)}},
-                               btnStyle, impl::HCOMB_SCROLL_LIMIT, 1, true),
-                       totalLength(totalLength)
-               {
-               }
-       };
-
-       // ImageGrid::LinearInfo //
-
-       struct ImageGrid::LinearInfo : Info {
-               virtual int calcItemIndexFromCell(
-                               const int slotIndex, const int itemOffset) const final override
-               {
-                       return (slotIndex / 2);
-               }
-
-               virtual void calcCellFromItemIndex(const int itemIndex,
-                               int &slotIndex, int &itemOffset) const final override
-               {
-                       slotIndex = (itemIndex * 2);
-                       itemOffset = 0;
-               }
-
-               virtual int calcMaxSlotCount(const int itemCount) const final override
-               {
-                       return (itemCount * 2);
-               }
-
-               LinearInfo(const LayoutTheme &slotTheme, const ElmStyle btnStyle,
-                               const bool isHorizontal) :
-                       Info({{slotTheme}}, {{1, 0}}, btnStyle, 1, 1, isHorizontal)
-               {
-               }
-       };
-
-       // ImageGrid::Slot //
-
-       class ImageGrid::Slot {
-       private:
-               class Item final : public RefCountAware {
-               public:
-                       friend class ReffedObj<Item>;
-                       Item(IRefCountObj &rc,
-                                       ImageGrid &imageGrid, ElmWidget &parent) :
-                               RefCountAware(&rc),
-                               m_imageGrid(imageGrid),
-                               m_btn(elm_button_add(parent)),
-                               m_image(evas_object_image_filled_add(m_btn.getEvas()))
-                       {
-                               m_btn.setFocusAlowed(false);
-                               m_btn.setStyle(imageGrid.m_info.btnStyle);
-                               show(m_btn);
-
-                               evas_object_image_load_orientation_set(m_image, EINA_TRUE);
-                               m_btn.setContent(m_image);
-                               show(m_image);
-
-                               m_image.addEventHandler(WidgetEvent::IMAGE_PRELOADED,
-                                               WEAK_DELEGATE(Item::onImagePreloaded, asWeak(*this)));
-
-                               m_btn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE(
-                                               Item::onClicked, asWeak(*this)));
-                               m_btn.addEventHandler(ATSPI_HIGHLIGHTED, WEAK_DELEGATE(
-                                               Item::onHighlighted, asWeak(*this)));
-                               m_btn.addEventHandler(ATSPI_UNHIGHLIGHTED, WEAK_DELEGATE(
-                                               Item::onUnhighlighted, asWeak(*this)));
-
-                               elm_atspi_accessible_gesture_cb_set(m_btn,
-                                               CALLBACK_A(Item::onAtspiGesture), this);
-
-                               m_touchParser = makeShared<TouchParser>(m_btn);
-                               m_touchParser->setDoubleTapHandler(
-                                               WEAK_DELEGATE(Item::onDoubleTap, asWeak(*this)));
-                               m_touchParser->setTapAndHoldHandler(
-                                               WEAK_DELEGATE(Item::onTapAndHold, asWeak(*this)));
-                       }
-
-                       ~Item()
-                       {
-                               elm_atspi_accessible_gesture_cb_set(m_btn, nullptr, nullptr);
-                       }
-
-                       Widget &getWidget()
-                       {
-                               return m_btn;
-                       }
-
-                       void setImageMinLoadSize(const int value)
-                       {
-                               m_imageMinLoadSize = std::max(value, 1);
-                       }
-
-                       bool isRealized() const
-                       {
-                               return (m_realizeIndex >= 0);
-                       }
-
-                       void getInfo(ItemInfo &info) const
-                       {
-                               int w = m_imageWidth;
-                               int h = m_imageHeight;
-                               if (!impl::getImageSize(m_image, w, h)) {
-                                       WLOG("Invalid image size!");
-                               }
-
-                               info.imageLoadSize = m_imageLoadSize;
-                               info.isImageLoadSizeFull = (
-                                               (w == m_imageWidth) && (h == m_imageHeight));
-                               info.isImageLoaded = m_isImageLoaded;
-                       }
-
-                       void realize(const int itemIndex)
-                       {
-                               if (isRealized()) {
-                                       return;
-                               }
-
-                               m_wasUpdated = false;
-
-                               if (itemIndex < m_imageGrid.m_itemCount) {
-                                       m_realizeIndex = itemIndex;
-
-                                       if (const auto listener = m_imageGrid.m_listener.lock()) {
-                                               listener->onItemRealized(itemIndex);
-                                       }
-                               }
-
-                               if (!m_wasUpdated) {
-                                       makeTransparent(m_btn);
-                               }
-                       }
-
-                       void unrealize()
-                       {
-                               if (!isRealized()) {
-                                       return;
-                               }
-
-                               if ((m_imageGrid.m_highlightID == m_realizeIndex) &&
-                                               m_imageGrid.m_highlightTimeout) {
-                                       m_imageGrid.m_isHighlightLocked = true;
-                                       elm_atspi_component_highlight_clear(m_btn);
-                               }
-
-                               const int itemIndex = m_realizeIndex;
-                               m_realizeIndex = -1;
-
-                               if (const auto listener = m_imageGrid.m_listener.lock()) {
-                                       listener->onItemUnrealized(itemIndex);
-                               }
-                       }
-
-                       bool setSelected(const bool selected)
-                       {
-                               if (selected == m_isSelected) {
-                                       return false;
-                               }
-                               if (selected && !m_imageGrid.m_isInSelectMode) {
-                                       return false;
-                               }
-                               m_isSelected = selected;
-                               return true;
-                       }
-
-                       bool update(const ItemParams &params)
-                       {
-                               if (!isRealized()) {
-                                       return false;
-                               }
-
-                               updateClicksBlock(params);
-                               updateImage(params);
-                               updateBgImage(params);
-
-                               makeWhite(m_btn);
-
-                               m_wasUpdated = true;
-
-                               return true;
-                       }
-
-               private:
-                       void updateClicksBlock(const ItemParams &params)
-                       {
-                               if (params.flags & UF_BLOCK_CLICKS) {
-                                       if (!m_isClicksBlocked) {
-                                               m_isClicksBlocked = true;
-                                               m_btn.emit(impl::BTN_BLOCK_CLICKS);
-                                       }
-                               } else if (m_isClicksBlocked) {
-                                       m_isClicksBlocked = false;
-                                       m_btn.emit(impl::BTN_UNBLOCK_CLICKS);
-                               }
-                       }
-
-                       void updateImage(const ItemParams &params)
-                       {
-                               if (isEmpty(params.imagePath)) {
-                                       if (!m_wasUpdated || (params.flags & UF_LOSE_IMAGE)) {
-                                               makeTransparent(m_image);
-                                               m_isImageEmpty = true;
-                                               m_isImageLoaded = false;
-                                       }
-                                       return;
-                               }
-
-                               makeTransparent(m_image);
-                               m_isImageEmpty = false;
-                               m_isImageLoaded = false;
-
-                               m_imageWidth = std::max(params.imageWidth, 1);
-                               m_imageHeight = std::max(params.imageHeight, 1);
-
-                               evas_object_image_file_set(m_image,
-                                               params.imagePath.c_str(), NULL);
-
-                               updateImageLoadSize();
-
-                               evas_object_image_preload(m_image, EINA_FALSE);
-                       }
-
-                       void updateImageLoadSize()
-                       {
-                               const int newLoadSize = ((m_imageWidth > m_imageHeight) ?
-                                               (m_imageMinLoadSize * m_imageWidth / m_imageHeight) :
-                                               (m_imageMinLoadSize * m_imageHeight / m_imageWidth));
-                               if (newLoadSize == m_imageLoadSize) {
-                                       return;
-                               }
-
-                               int w = m_imageWidth;
-                               int h = m_imageHeight;
-                               if (!impl::getImageSize(m_image, w, h)) {
-                                       WLOG("Invalid image size!");
-                               }
-
-                               if (isCurentLoadSizeSatisfying(w, h) ||
-                                               !isImageRespectsLoadSize(w, h)) {
-                                       return;
-                               }
-
-                               m_imageLoadSize = newLoadSize;
-                               evas_object_image_load_size_set(m_image,
-                                               newLoadSize, newLoadSize);
-                       }
-
-                       bool isCurentLoadSizeSatisfying(
-                                       const int curImgW, const int curImgH) const
-                       {
-                               const int kw = ((m_imageWidth > m_imageMinLoadSize) ?
-                                               (curImgW / m_imageMinLoadSize) : 1);
-                               const int kh = ((m_imageHeight > m_imageMinLoadSize) ?
-                                               (curImgH / m_imageMinLoadSize) : 1);
-                               return (((kw == 1) && (kh >= 1)) || ((kh == 1) && (kw >= 1)));
-                       }
-
-                       bool isImageRespectsLoadSize(
-                                       const int curImgW, const int curImgH) const
-                       {
-                               return ((m_imageLoadSize <= 0) ||
-                                               (curImgW != m_imageWidth) ||
-                                               (curImgH != m_imageHeight) || (
-                                                       ((curImgW / m_imageLoadSize) <= 1) &&
-                                                       ((curImgH / m_imageLoadSize) <= 1)
-                                               ));
-                       }
-
-                       void onImagePreloaded(Widget &widget, void *eventInfo)
-                       {
-                               if (m_isImageEmpty) {
-                                       return;
-                               }
-
-                               m_isImageLoaded = true;
-
-                               m_image.setARHint(WidgetARHint::NEITHER,
-                                               m_imageWidth, m_imageHeight);
-
-                               makeWhite(m_image);
-                       }
-
-                       void updateBgImage(const ItemParams &params)
-                       {
-                               if (isEmpty(params.bgImagePath)) {
-                                       if (m_bgImage && (!m_wasUpdated ||
-                                                       (params.flags & UF_LOSE_BG))) {
-                                               makeTransparent(*m_bgImage);
-                                       }
-                                       return;
-                               }
-
-                               if (!m_bgImage) {
-                                       m_bgImage = makeShared<Widget>(
-                                                       evas_object_image_filled_add(m_btn.getEvas()));
-                                       evas_object_image_load_orientation_set(*m_bgImage,
-                                                       EINA_TRUE);
-                                       m_btn.setContent(*m_bgImage, impl::BTN_PART_BG);
-                                       show(*m_bgImage);
-                               }
-
-                               evas_object_image_file_set(*m_bgImage,
-                                               params.bgImagePath.c_str(), NULL);
-
-                               m_bgImage->setARHint(WidgetARHint::NEITHER,
-                                               m_imageWidth, m_imageHeight);
-
-                               makeWhite(*m_bgImage);
-                       }
-
-                       void onClicked(Widget &widget, void *eventInfo)
-                       {
-                               if (!isRealized()) {
-                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
-                               }
-                               m_imageGrid.handleItemEvent(m_realizeIndex,
-                                               ItemEvent::CLICK, -1, -1);
-                       }
-
-                       void onDoubleTap(const int x, const int y)
-                       {
-                               if (!isRealized()) {
-                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
-                               }
-                               m_imageGrid.handleItemEvent(m_realizeIndex,
-                                               ItemEvent::DOUBLE_TAP, x, y);
-                       }
-
-                       void onTapAndHold(const int x, const int y)
-                       {
-                               if (!isRealized()) {
-                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
-                               }
-                               m_imageGrid.handleItemEvent(m_realizeIndex,
-                                               ItemEvent::TAP_AND_HOLD, x, y);
-                       }
-
-                       void onHighlighted(Widget &widget, void *eventInfo)
-                       {
-                               if (!isRealized()) {
-                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
-                               }
-                               m_imageGrid.onItemHighlighted(m_realizeIndex);
-                       }
-
-                       void onUnhighlighted(Widget &widget, void *eventInfo)
-                       {
-                               if (!isRealized()) {
-                                       LOG_RETURN_VOID(RES_ILLEGAL_STATE, "Item is not realized!");
-                               }
-                               m_imageGrid.onItemUnhighlighted(m_realizeIndex);
-                       }
-
-                       Eina_Bool onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
-                                       Evas_Object *obj)
-                       {
-                               if (!isRealized()) {
-                                       LOG_RETURN_VALUE(RES_ILLEGAL_STATE, EINA_FALSE,
-                                                       "Item is not realized!");
-                               }
-
-                               const Elm_Atspi_Relation_Type relation =
-                                               getFlowRelation(gestureInfo);
-                               if (relation == ELM_ATSPI_RELATION_NULL) {
-                                       return EINA_FALSE;
-                               }
-
-                               const int relationIndex =
-                                               ((relation == ELM_ATSPI_RELATION_FLOWS_TO) ?
-                                                       (m_realizeIndex + 1) :
-                                                       (m_realizeIndex - 1));
-
-                               auto relationObject = m_imageGrid.requestAtspi(relationIndex);
-                               if (!relationObject) {
-                                       relationObject = m_btn.getEo();
-                               }
-
-                               elm_atspi_accessible_relationships_clear(m_btn);
-                               elm_atspi_accessible_relationship_append(m_btn,
-                                               relation, relationObject);
-
-                               return EINA_FALSE;
-                       }
-
-               private:
-                       ImageGrid &m_imageGrid;
-                       StyledWidget m_btn;
-                       StyledWidget m_image;
-                       WidgetSRef m_bgImage;
-                       TouchParserSRef m_touchParser;
-                       int m_realizeIndex = -1;
-                       int m_imageLoadSize = 0;
-                       int m_imageMinLoadSize = 1;
-                       int m_imageWidth = 1;
-                       int m_imageHeight = 1;
-                       bool m_wasUpdated = false;
-                       bool m_isImageEmpty = false;
-                       bool m_isImageLoaded = false;
-                       bool m_isClicksBlocked = false;
-                       bool m_isSelected = false;
-               };
-
-       public:
-               Slot(ImageGrid &imageGrid, const bool isOdd) :
-                       m_info(imageGrid.m_info),
-                       m_layout(elm_layout_add(imageGrid.m_box), true),
-                       m_isRealized(false)
-               {
-                       int imageMinLoadSize = 0;
-
-                       if (isValid(m_info.slotThemes[isOdd])) {
-                               if (!m_layout.setTheme(m_info.slotThemes[isOdd])) {
-                                       ELOG("setTheme() failed!");
-                               } else if (imageGrid.m_isInSelectMode) {
-                                       m_layout.emit(impl::SIGNAL_FORCE_SELECT_MODE);
-                                       edje_object_message_signal_process(
-                                                       elm_layout_edje_get(m_layout));
-                               }
-                               imageMinLoadSize = ELM_SCALE_SIZE(m_layout.getData(
-                                               impl::DATA_IMAGE_MIN_LOAD_SIZE).asInt());
-                       }
-                       fill(m_layout);
-                       show(m_layout);
-
-                       const int length = m_info.slotLens[isOdd];
-                       for (int i = 0; i < length; ++i) {
-                               m_items.emplace_back(makeShared<Item>(imageGrid, m_layout));
-
-                               const auto partName = impl::SLOT_PART_FMT.format(i);
-                               m_layout.setContent(m_items.back()->getWidget(),
-                                               EdjePart(partName.c_str()));
-
-                               m_items.back()->setImageMinLoadSize(imageMinLoadSize);
-                       }
-               }
-
-               Layout &getLayout()
-               {
-                       return m_layout;
-               }
-
-               int getSize()
-               {
-                       int w = 0;
-                       int h = 0;
-                       m_layout.getMin(&w, &h);
-                       return std::max((m_info.isHorizontal ? w : h), 1);
-               }
-
-               void unrealize()
-               {
-                       if (!m_isRealized) {
-                               return;
-                       }
-                       m_isRealized = false;
-
-                       for (auto &item: m_items) {
-                               item->unrealize();
-                       }
-               }
-
-               void realize(const int slotIndex)
-               {
-                       if (m_isRealized) {
-                               return;
-                       }
-                       m_isRealized = true;
-
-                       for (UInt i = 0; i < m_items.size(); ++i) {
-                               m_items[i]->realize(
-                                               m_info.calcItemIndexFromCell(slotIndex, i));
-                       }
-               }
-
-               void unselect()
-               {
-                       for (UInt i = 0; i < m_items.size(); ++i) {
-                               setSelected(i, false);
-                       }
-               }
-
-               bool updateItem(const int itemOffset, const ItemParams &params)
-               {
-                       setSelected(itemOffset, (params.flags & UF_SELECTED));
-                       return m_items[itemOffset]->update(params);
-               }
-
-               bool isItemRealized(const int itemOffset) const
-               {
-                       return m_items[itemOffset]->isRealized();
-               }
-
-               void getItemInfo(const int itemOffset, ItemInfo &info) const
-               {
-                       m_items[itemOffset]->getInfo(info);
-               }
-
-               Elm_Interface_Atspi_Accessible *getItemAtspi(const int itemOffset)
-               {
-                       return m_items[itemOffset]->getWidget().getEo();
-               }
-
-       private:
-               void setSelected(const int itemOffset, const bool selected)
-               {
-                       if (!m_items[itemOffset]->setSelected(selected)) {
-                               return;
-                       }
-                       const auto signalName = (selected ?
-                                       impl::SIGNAL_SELECT_ITEM_FMT.format(itemOffset) :
-                                       impl::SIGNAL_UNSELECT_ITEM_FMT.format(itemOffset));
-                       m_layout.emit(EdjeSignal(signalName.c_str()));
-               }
-
-       private:
-               const Info &m_info;
-               std::vector<SharedRef<Item>> m_items;
-               Layout m_layout;
-               bool m_isRealized;
-       };
-
-       // ImageGrid::Unrealizer //
-
-       ImageGrid::Unrealizer::Unrealizer(ImageGrid &imageGrid) :
-               m_imageGrid(imageGrid)
-       {
-               m_imageGrid.addUnrealizeLock();
-       }
-
-       ImageGrid::Unrealizer::~Unrealizer()
-       {
-               m_imageGrid.removeUnrealizeLock();
-       }
-
-       // ImageGrid //
-
-       ImageGrid::ImageGrid(IRefCountObj *const rc, Evas_Object *const scroller,
-                       const Type type, const bool selectModeStartup) :
-               ElmWidget(rc, scroller),
-               m_info(getInfo(type)),
-
-               m_scroller(makeShared<StyledWidget>(scroller, false).get()),
-               m_box(elm_box_add(*m_scroller)),
-               m_rect1(evas_object_rectangle_add(m_box.getEvas())),
-               m_rect2(evas_object_rectangle_add(m_box.getEvas())),
-               m_circleScroller(nullptr),
-
-               m_itemCount(0),
-
-               m_slotCount(0), // Must be even >= 2
-               m_optimalSlotCount(2), // Must be even >= 2
-               m_maxSlotCount(2), // Must be even >= 2
-
-               m_beginSlotIndex(0),
-               m_maxBeginSlotIndex(0),
-
-               m_scrollBias(0),
-               m_padSize1(0),
-               m_padSize2(0),
-
-               m_slotSize(0), // Must not be 0
-               m_scrollerSize(1), // Must not be 0
-               m_scrollOffset(0),
-
-               m_unrealizeLock(0),
-               m_eventsLock(0),
-
-               m_animator(nullptr),
-               m_scrollLockIndex(0),
-               m_isInSelectMode(selectModeStartup),
-               m_isRotaryActive(false),
-
-               m_highlightID(-1),
-               m_isHighlightLocked(false)
-       {
-               prepare();
-
-               ++m_eventsLock;
-
-               updateSlotCount();
-
-               updatePadSizes();
-               updateScrollBias();
-               updateRectMins();
-
-               --m_eventsLock;
-       }
-
-       ImageGrid::~ImageGrid()
-       {
-               if (m_animator) {
-                       finalizeTransition();
-               }
-       }
-
-       const ImageGrid::Info &ImageGrid::getInfo(const Type type)
-       {
-               switch (type) {
-               case Type::HCOMB_3X3: {
-                               static HcombInfo info{3, {{
-                                               {"layout", "gallery_image_grid", "hcomb_3x3_even"},
-                                               {"layout", "gallery_image_grid", "hcomb_3x3_odd"}}},
-                                               ElmStyle{"gallery_image_thumb"}};
-                               return info;
-                       }
-               case Type::LINEAR:
-               default: {
-                               static LinearInfo info{
-                                               {"layout", "gallery_image_grid", "linear"},
-                                               ElmStyle{"gallery_image_full"}, true};
-                               return info;
-                       }
-               }
-       }
-
-       void ImageGrid::prepare()
-       {
-               fill(m_rect1);
-               elm_box_pack_end(m_box, m_rect1);
-               makeTransparent(m_rect1);
-               show(m_rect1);
-
-               expandAndFill(m_rect2);
-               elm_box_pack_end(m_box, m_rect2);
-               makeTransparent(m_rect2);
-               show(m_rect2);
-
-               m_scroller->setContent(m_box);
-               elm_box_horizontal_set(m_box, toEina(m_info.isHorizontal));
-               show(m_box);
-
-               m_scroller->setStyle(SCROLLER_STYLE);
-               expandAndFill(*m_scroller);
-               if (m_info.isHorizontal) {
-                       elm_scroller_page_scroll_limit_set(
-                                       *m_scroller, m_info.scrollLimit, 0);
-                       elm_scroller_bounce_set(*m_scroller, EINA_TRUE, EINA_FALSE);
-               } else {
-                       elm_scroller_page_scroll_limit_set(
-                                       *m_scroller, 0, m_info.scrollLimit);
-                       elm_scroller_bounce_set(*m_scroller, EINA_FALSE, EINA_TRUE);
-               }
-               show(*m_scroller);
-
-               createCircleScroller();
-
-               createHighlighKeeper();
-
-               m_scroller->addEventHandler(WidgetEvent::RESIZE,
-                               WEAK_DELEGATE(ImageGrid::onScrollerResize, asWeak(*this)));
-
-               m_scroller->addEventHandler(WidgetEvent::MOVE,
-                               WEAK_DELEGATE(ImageGrid::onScrollerMove, asWeak(*this)));
-
-               m_box.addEventHandler(WidgetEvent::MOVE,
-                               WEAK_DELEGATE(ImageGrid::onBoxMove, asWeak(*this)));
-       }
-
-       void ImageGrid::createCircleScroller()
-       {
-               const auto sfc = util::getCircleSurface(*m_scroller);
-               if (!sfc) {
-                       LOG_RETURN_VOID(RES_FAIL, "util::getCircleSurface() failed!");
-               }
-
-               m_circleScroller = eext_circle_object_scroller_add(*m_scroller, sfc);
-               if (!m_circleScroller) {
-                       LOG_RETURN_VOID(RES_FAIL,
-                                       "eext_circle_object_scroller_add() failed!");
-               }
-
-               if (m_info.isHorizontal) {
-                       eext_circle_object_scroller_policy_set(m_circleScroller,
-                                       ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
-               } else {
-                       eext_circle_object_scroller_policy_set(m_circleScroller,
-                                       ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
-               }
-       }
-
-       void ImageGrid::createHighlighKeeper()
-       {
-               m_highlighKeeper = util::createFakeAccessObject(*m_box.getWindow());
-               UCL_ASSERT(m_highlighKeeper, "m_highlighKeeper is NULL");
-
-               m_highlighKeeper->addEventHandler(ATSPI_UNHIGHLIGHTED,
-                               WEAK_DELEGATE(ImageGrid::onKeeperUnhighlighted, asWeak(*this)));
-       }
-
-       void ImageGrid::setListener(const IListenerWRef &listener)
-       {
-               m_listener = listener;
-       }
-
-       Result ImageGrid::setItemCount(const int count)
-       {
-               if (m_animator) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
-               }
-
-               if (m_itemCount == count) {
-                       return RES_FALSE;
-               }
-
-               ++m_eventsLock;
-
-               unrealizeSlots(0, m_slotCount);
-
-               m_itemCount = count;
-
-               if (updateMaxSlotCount()) {
-                       updateSlotCount();
-                       if (updateMaxBeginSlotIndex()) {
-                               updateBeginSlotIndex();
-                       }
-               }
-
-               realizeSlots();
-               updateRectMins();
-
-               --m_eventsLock;
-
-               return RES_OK;
-       }
-
-       Result ImageGrid::setSelectModeEnabled(const bool enabled)
-       {
-               if (m_animator) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
-               }
-
-               if (enabled == m_isInSelectMode) {
-                       return RES_FALSE;
-               }
-
-               if ((m_scrollOffset % m_slotSize) > 0) {
-                       DLOG("Can't handle it right now!");
-                       return RES_FAIL;
-               }
-
-               m_scrollLockIndex = std::min(
-                               (m_scrollOffset / m_slotSize), (m_itemCount - 1));
-
-               m_isInSelectMode = enabled;
-
-               elm_object_scroll_freeze_push(*m_scroller);
-               evas_object_freeze_events_set(*m_scroller, EINA_TRUE);
-               eext_rotary_object_event_activated_set(m_circleScroller, EINA_FALSE);
-
-               for (auto &slot: m_slots) {
-                       slot->unselect();
-               }
-
-               const auto aSignal = (enabled ?
-                               impl::SIGNAL_ENABLE_SELECT_MODE :
-                               impl::SIGNAL_DISABLE_SELECT_MODE);
-               for (auto &slot: m_slots) {
-                       slot->getLayout().emit(aSignal);
-               }
-
-               m_animator = ecore_animator_add(
-                               CALLBACK_A(ImageGrid::onAnimationFrame), this);
-
-               evas_object_event_callback_priority_add(m_box,
-                                       EVAS_CALLBACK_RESIZE, EO_CALLBACK_PRIORITY_AFTER,
-                                       CALLBACK_A(ImageGrid::onBoxResize), this);
-
-               auto &slotlayout = m_slots[m_beginSlotIndex & 1]->getLayout();
-
-               slotlayout.addEventHandler(WidgetEvent::CHANGED_SIZE_HINTS,
-                               WEAK_DELEGATE(ImageGrid::onSlotResize, asWeak(*this)));
-
-               elm_object_signal_callback_add(slotlayout,
-                               impl::SIGNAL_TRANSITION_FINISHED.name, "",
-                               CALLBACK_A(ImageGrid::onTransitonFinished), this);
-
-               return RES_OK;
-       }
-
-       bool ImageGrid::isInSelectMode() const
-       {
-               return m_isInSelectMode;
-       }
-
-       bool ImageGrid::isInTransition() const
-       {
-               return !!m_animator;
-       }
-
-       void ImageGrid::onTransitonFinished(Evas_Object *obj,
-                       const char *emission, const char *source)
-       {
-               evalSlotSizes();
-
-               finalizeTransition();
-
-               elm_object_scroll_freeze_pop(*m_scroller);
-               evas_object_freeze_events_set(*m_scroller, EINA_FALSE);
-               if (m_isRotaryActive) {
-                       eext_rotary_object_event_activated_set(m_circleScroller, EINA_TRUE);
-               }
-
-               if (const auto listener = m_listener.lock()) {
-                       listener->onTransitionFinished();
-               }
-       }
-
-       void ImageGrid::finalizeTransition()
-       {
-               if (m_animator) {
-                       ecore_animator_del(m_animator);
-                       m_animator = nullptr;
-               }
-
-               evas_object_event_callback_del_full(m_box, EVAS_CALLBACK_RESIZE,
-                               CALLBACK_A(ImageGrid::onBoxResize), this);
-
-               auto &slotlayout = m_slots[m_beginSlotIndex & 1]->getLayout();
-
-               slotlayout.delEventHandler(WidgetEvent::CHANGED_SIZE_HINTS,
-                               WEAK_DELEGATE(ImageGrid::onSlotResize, asWeak(*this)));
-
-               elm_object_signal_callback_del(slotlayout,
-                               "gallery,transition,finished", "",
-                               CALLBACK_A(ImageGrid::onTransitonFinished));
-       }
-
-       Eina_Bool ImageGrid::onAnimationFrame()
-       {
-               evalSlotSizes();
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       void ImageGrid::evalSlotSizes()
-       {
-               for (auto &slot: m_slots) {
-                       elm_layout_sizing_eval(slot->getLayout());
-               }
-       }
-
-       void ImageGrid::onSlotResize(Widget &widget, void *eventInfo)
-       {
-               if (updateSlotSize()) {
-                       updatePadSizes();
-                       updateScrollBias();
-                       updateRectMins();
-               }
-       }
-
-       void ImageGrid::onBoxResize(Evas *e, Evas_Object *obj, void *eventInfo)
-       {
-               m_scrollOffset = (m_scrollLockIndex * m_slotSize);
-               if (m_info.isHorizontal) {
-                       elm_scroller_region_show(*m_scroller,
-                                       m_scrollOffset, 0, m_scrollerSize, 1);
-               } else {
-                       elm_scroller_region_show(*m_scroller,
-                                       0, m_scrollOffset, 1, m_scrollerSize);
-               }
-       }
-
-       void ImageGrid::update()
-       {
-               Unrealizer(*this);
-       }
-
-       Result ImageGrid::updateItem(const int itemIndex, const ItemParams &params)
-       {
-               if (m_animator) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
-               }
-               return doWithItem(itemIndex,
-                       [&params](Slot &slot, const int itemOffset)
-                       {
-                               return (slot.updateItem(itemOffset, params) ?
-                                               RES_OK : RES_FALSE);
-                       });
-       }
-
-       Result ImageGrid::isItemRealized(const int itemIndex) const
-       {
-               return doWithItem(itemIndex,
-                       [](Slot &slot, const int itemOffset)
-                       {
-                               return (slot.isItemRealized(itemOffset) ? RES_OK : RES_FALSE);
-                       });
-       }
-
-       Result ImageGrid::getItemInfo(const int itemIndex, ItemInfo &info) const
-       {
-               return doWithItem(itemIndex,
-                       [&info](Slot &slot, const int itemOffset)
-                       {
-                               slot.getItemInfo(itemOffset, info);
-                               return RES_OK;
-                       });
-       }
-
-       Elm_Interface_Atspi_Accessible *ImageGrid::getAccessObject(
-                       const bool isFlowsTo)
-       {
-               return getItemAtspi(isFlowsTo ? 0 : (m_itemCount - 1));
-       }
-
-       template <class FUNC>
-       Result ImageGrid::doWithItem(const int itemIndex, FUNC &&func) const
-       {
-               return doWithCell(itemIndex,
-                       [this, &func](const int slotIndex, const int itemOffset)
-                       {
-                               const int slotOffset = (slotIndex - m_beginSlotIndex);
-                               if ((slotOffset < 0) || (slotOffset >= m_slotCount)) {
-                                       return RES_FALSE;
-                               }
-                               return func(*m_slots[slotOffset], itemOffset);
-                       });
-       }
-
-       template <class FUNC>
-       Result ImageGrid::doWithCell(const int itemIndex, FUNC &&func) const
-       {
-               if ((itemIndex < 0) || (itemIndex >= m_itemCount)) {
-                       LOG_RETURN(RES_INVALID_ARGUMENTS,
-                                       "Item index out of range: %d", itemIndex);
-               }
-
-               int slotIndex = 0;
-               int itemOffset = 0;
-               m_info.calcCellFromItemIndex(itemIndex, slotIndex, itemOffset);
-
-               return func(slotIndex, itemOffset);
-       }
-
-       int ImageGrid::getScrolledToItemIndex() const
-       {
-               const int evenSlotIndex = (std::lround(1.0 * m_scrollOffset /
-                               m_slotSize) * 2);
-               return std::min((m_itemCount - 1), std::min(
-                       m_info.calcItemIndexFromCell(evenSlotIndex, 0),
-                       m_info.calcItemIndexFromCell((evenSlotIndex + 1), 0)));
-       }
-
-       Result ImageGrid::scrollToItem(const int itemIndex)
-       {
-               if (m_animator) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
-               }
-               forceBoxSizeCalculate();
-               return showItem(itemIndex, elm_scroller_region_show);
-       }
-
-       Result ImageGrid::bringInItem(int itemIndex)
-       {
-               if (m_animator) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "Transition is in progress.");
-               }
-               return showItem(itemIndex, elm_scroller_region_bring_in);
-       }
-
-       template <class SHOW_FUNC>
-       Result ImageGrid::showItem(const int itemIndex, SHOW_FUNC &&showFunc)
-       {
-               return doWithCell(itemIndex,
-                       [this, &showFunc](const int slotIndex, const int itemOffset)
-                       {
-                               int minVisibleOffset = 0;
-                               int maxVisibleOffset = 0;
-                               if (isItemFullyVisible(slotIndex, itemOffset,
-                                               minVisibleOffset, maxVisibleOffset)) {
-                                       return RES_OK;
-                               }
-
-                               const int scrollOffset = ((m_scrollOffset > maxVisibleOffset) ?
-                                               maxVisibleOffset : minVisibleOffset);
-                               if (m_info.isHorizontal) {
-                                       showFunc(*m_scroller, scrollOffset, 0, m_scrollerSize, 1);
-                               } else {
-                                       showFunc(*m_scroller, 0, scrollOffset, 1, m_scrollerSize);
-                               }
-
-                               return RES_OK;
-                       });
-       }
-
-       bool ImageGrid::isItemFullyVisible(int itemIndex)
-       {
-               int minVisibleOffset = 0;
-               int maxVisibleOffset = 0;
-               return isItemFullyVisible(itemIndex,
-                               minVisibleOffset, maxVisibleOffset);
-       }
-
-       bool ImageGrid::isItemFullyVisible(const int itemIndex,
-                       int &minVisibleOffset, int &maxVisibleOffset) const
-       {
-               return (doWithCell(itemIndex,
-                               [this, &minVisibleOffset, &maxVisibleOffset](
-                                               const int slotIndex, const int itemOffset)
-                               {
-                                       return (isItemFullyVisible(slotIndex, itemOffset,
-                                                       minVisibleOffset, maxVisibleOffset) ?
-                                                               RES_OK : RES_FALSE);
-                               }
-                       ) == RES_OK);
-       }
-
-       bool ImageGrid::isItemFullyVisible(
-                       const int slotIndex, const int itemOffset,
-                       int &minVisibleOffset, int &maxVisibleOffset) const
-       {
-               const int extraPadding = ((slotIndex & 1) ?
-                               m_info.calcExtraPaddingSize(m_slotSize) : 0);
-
-               maxVisibleOffset = ((slotIndex / 2) * m_slotSize);
-               minVisibleOffset = (maxVisibleOffset + extraPadding -
-                               ((m_scrollerSize / m_slotSize) - 1) * m_slotSize);
-
-               if ((m_scrollOffset >= minVisibleOffset) &&
-                               (m_scrollOffset <= maxVisibleOffset)) {
-                       return true;
-               }
-
-               return false;
-       }
-
-       void ImageGrid::forceBoxSizeCalculate()
-       {
-               for (int i = 0; i < m_slotCount; ++i) {
-                       if (((m_beginSlotIndex + i) & 1) == 0) {
-                               m_slots[i]->getLayout().calculate();
-                       }
-               }
-               m_box.calculate();
-       }
-
-       void ImageGrid::activateRotary()
-       {
-               m_isRotaryActive = true;
-               if (!m_animator) {
-                       eext_rotary_object_event_activated_set(m_circleScroller, EINA_TRUE);
-               }
-       }
-
-       void ImageGrid::deactivateRotary()
-       {
-               m_isRotaryActive = false;
-               eext_rotary_object_event_activated_set(m_circleScroller, EINA_FALSE);
-       }
-
-       void ImageGrid::addUnrealizeLock()
-       {
-               if (m_animator) {
-                       ELOG("Transition is in progress.");
-               } else {
-                       unrealizeSlots(0, m_slotCount);
-               }
-               ++m_unrealizeLock;
-       }
-
-       void ImageGrid::removeUnrealizeLock()
-       {
-               if (m_unrealizeLock > 0) {
-                       --m_unrealizeLock;
-                       if (m_animator) {
-                               ELOG("Transition is in progress.");
-                       } else {
-                               realizeSlots();
-                       }
-               } else {
-                       WLOG("m_unrealizeLock = 0!");
-               }
-       }
-
-       void ImageGrid::handleItemEvent(const int itemIndex,
-                       const ItemEvent event, const int x, const int y) const
-       {
-               if (const auto listener = m_listener.lock()) {
-                       listener->onItemEvent(itemIndex, event, x, y);
-               }
-       }
-
-       void ImageGrid::onItemHighlighted(const int itemIndex)
-       {
-               m_highlightID = itemIndex;
-               m_highlightTimeout.reset();
-       }
-
-       void ImageGrid::onItemUnhighlighted(const int itemIndex)
-       {
-               if (m_highlightID == itemIndex) {
-                       m_highlightID = (-1 - itemIndex);
-                       if (m_isHighlightLocked) {
-                               elm_atspi_component_highlight_grab(*m_highlighKeeper);
-                       } else {
-                               m_highlightTimeout.reset();
-                       }
-               }
-       }
-
-       void ImageGrid::onKeeperUnhighlighted(Widget &sender, void *eventInfo)
-       {
-               m_isHighlightLocked = false;
-               m_highlightTimeout.reset();
-       }
-
-       void ImageGrid::updateHighlightTimeout()
-       {
-               if (m_highlightID >= 0) {
-                       if (isItemFullyVisible(m_highlightID)) {
-                               m_highlightTimeout.reset();
-                               return;
-                       }
-               } else if (!m_isHighlightLocked) {
-                       return;
-               }
-
-               m_highlightTimeout = Timeout::create(
-                               impl::SCROLL_HIGHLIGHT_TIMEOUT_SEC, WEAK_DELEGATE(
-                                       ImageGrid::onHighlightTimeout, asWeak(*this)));
-       }
-
-       void ImageGrid::onHighlightTimeout(Timeout *sender)
-       {
-               m_highlightTimeout.reset();
-
-               int itemIndex = ((m_highlightID >= 0) ?
-                               m_highlightID : (-1 - m_highlightID));
-               bool found = false;
-
-               for (int i = m_info.getHighlightScanRange(); ((i >= 0) &&
-                               (itemIndex >= 0) && (itemIndex < m_itemCount)); --i) {
-                       int minVisibleOffset = 0;
-                       int maxVisibleOffset = 0;
-                       if (isItemFullyVisible(itemIndex,
-                                       minVisibleOffset, maxVisibleOffset)) {
-                               found = true;
-                       } else if (m_scrollOffset > maxVisibleOffset) {
-                               ++itemIndex;
-                       } else {
-                               --itemIndex;
-                       }
-               }
-
-               if (!found) {
-                       itemIndex = getScrolledToItemIndex();
-               }
-
-               FAIL_RETURN_VOID(doWithItem(itemIndex,
-                       [](Slot &slot, const int itemOffset)
-                       {
-                               elm_atspi_component_highlight_grab(
-                                               slot.getItemAtspi(itemOffset));
-                               return RES_OK;
-                       }), "Failed to Grab item highlight!");
-       }
-
-       Elm_Interface_Atspi_Accessible *ImageGrid::requestAtspi(const int itemIndex)
-       {
-               if ((itemIndex < 0) || (itemIndex >= m_itemCount)) {
-                       if (const auto listener = m_listener.lock()) {
-                               return listener->onAccessObjectRequest(
-                                               (itemIndex >= m_itemCount));
-                       }
-                       return nullptr;
-               }
-
-               const int oldHighlightID = m_highlightID;
-               m_highlightID = itemIndex; // To prevent autohighlight timer to start
-
-               const auto result = getItemAtspi(itemIndex);
-               if (!result) {
-                       m_highlightID = oldHighlightID;
-                       return nullptr;
-               }
-
-               m_highlightTimeout.reset();
-
-               return result;
-       }
-
-       Elm_Interface_Atspi_Accessible *ImageGrid::getItemAtspi(
-                       const int itemIndex)
-       {
-               FAIL_RETURN_VALUE(scrollToItem(itemIndex), nullptr,
-                               "scrollToItem() failed!");
-
-               Elm_Interface_Atspi_Accessible *result = nullptr;
-
-               FAIL_RETURN_VALUE(doWithItem(itemIndex,
-                       [&result](Slot &slot, const int itemOffset)
-                       {
-                               result = slot.getItemAtspi(itemOffset);
-                               return RES_OK;
-                       }), nullptr, "Failed to get item Atspi!");
-
-               return result;
-       }
-
-       bool ImageGrid::updateSlotCount()
-       {
-               const int newSlotCount = calcSlotCount();
-
-               if (newSlotCount != m_slotCount) {
-                       DLOG("newSlotCount: %d; m_slotCount: %d;",
-                                       newSlotCount, m_slotCount);
-                       setSlotCount(newSlotCount);
-                       return true;
-               }
-
-               return false;
-       }
-
-       int ImageGrid::calcSlotCount()
-       {
-               return std::min(m_optimalSlotCount, m_maxSlotCount);
-       }
-
-       void ImageGrid::setSlotCount(const int newSlotCount)
-       {
-               for (int i = m_slotCount; i < newSlotCount; ++i) {
-                       const bool isOdd = ((m_beginSlotIndex + i) & 1);
-
-                       auto slot = util::makeUnique(new Slot(*this, isOdd));
-
-                       if (m_slotSize == 0) {
-                               UCL_ASSERT(!isOdd, "Must be even!");
-                               slot->getLayout().calculate();
-                               setSlotSize(slot->getSize());
-                       }
-
-                       elm_box_pack_before(m_box, slot->getLayout(), m_rect2);
-
-                       m_slots.emplace_back(std::move(slot));
-               }
-
-               unrealizeSlots(newSlotCount, m_slotCount);
-
-               m_slots.resize(newSlotCount);
-               m_slotCount = newSlotCount;
-       }
-
-       bool ImageGrid::updateOptimalSlotCount()
-       {
-               const int newOptimalSlotCount = calcOptimalSlotCount();
-
-               if (newOptimalSlotCount != m_optimalSlotCount) {
-                       DLOG("newOptimalSlotCount: %d; m_optimalSlotCount: %d;",
-                                       newOptimalSlotCount, m_optimalSlotCount);
-                       m_optimalSlotCount = newOptimalSlotCount;
-                       return true;
-               }
-
-               return false;
-       }
-
-       int ImageGrid::calcOptimalSlotCount()
-       {
-               return (((m_scrollerSize / m_slotSize) + 3) * 2);
-       }
-
-       bool ImageGrid::updateMaxSlotCount()
-       {
-               const int newMaxSlotCount = calcMaxSlotCount();
-
-               if (newMaxSlotCount != m_maxSlotCount) {
-                       DLOG("newMaxSlotCount: %d; m_maxSlotCount: %d;",
-                                       newMaxSlotCount, m_maxSlotCount);
-                       m_maxSlotCount = newMaxSlotCount;
-                       return true;
-               }
-
-               return false;
-       }
-
-       int ImageGrid::calcMaxSlotCount()
-       {
-               return std::max(m_info.calcMaxSlotCount(m_itemCount), 2);
-       }
-
-       bool ImageGrid::updateBeginSlotIndex()
-       {
-               const int newBeginSlotIndex = calcBeginSlotIndex();
-
-               if (newBeginSlotIndex != m_beginSlotIndex) {
-                       DLOG("newBeginSlotIndex: %d; m_beginSlotIndex: %d;",
-                                       newBeginSlotIndex, m_beginSlotIndex);
-                       setBeginSlotIndex(newBeginSlotIndex);
-                       return true;
-               }
-
-               return false;
-       }
-
-       int ImageGrid::calcBeginSlotIndex()
-       {
-               const int evenScrolledSize = (m_scrollOffset - m_scrollBias);
-               const int oddScrolledSize = (evenScrolledSize - m_slotSize / 2);
-
-               const int beginEvenSlotIndex = (evenScrolledSize / m_slotSize);
-               const int beginOddSlotIndex = (oddScrolledSize / m_slotSize);
-
-               int beginSlotIndex = ((beginEvenSlotIndex <= beginOddSlotIndex) ?
-                               (beginEvenSlotIndex * 2) : (beginOddSlotIndex * 2 + 1));
-
-               if (beginSlotIndex < 0) {
-                       beginSlotIndex = 0;
-               } else if (beginSlotIndex > m_maxBeginSlotIndex) {
-                       beginSlotIndex = m_maxBeginSlotIndex;
-               }
-
-               return beginSlotIndex;
-       }
-
-       void ImageGrid::setBeginSlotIndex(const int newBeginSlotIndex)
-       {
-               const int beginSlotIndex = m_beginSlotIndex;
-               const int endSlotIndex = (beginSlotIndex + m_slotCount);
-               const int newEndSlotIndex = (newBeginSlotIndex + m_slotCount);
-
-               if ((newEndSlotIndex <= beginSlotIndex) ||
-                               (endSlotIndex <= newBeginSlotIndex)) {
-
-                       unrealizeSlots(0, m_slotCount);
-
-                       if ((beginSlotIndex ^ newBeginSlotIndex) & 1) {
-                               rotateSlotsRight(1);
-                       }
-
-               } else if (newBeginSlotIndex < beginSlotIndex) {
-                       const int goodSlots = (newEndSlotIndex - beginSlotIndex);
-                       const int badSlots = (m_slotCount - goodSlots);
-
-                       unrealizeSlots(goodSlots, m_slotCount);
-
-                       if (goodSlots > badSlots) {
-                               rotateSlotsRight(badSlots);
-                       } else {
-                               rotateSlotsLeft(goodSlots);
-                       }
-               } else {
-                       const int goodSlots = (endSlotIndex - newBeginSlotIndex);
-                       const int badSlots = (m_slotCount - goodSlots);
-
-                       unrealizeSlots(0, badSlots);
-
-                       if (goodSlots > badSlots) {
-                               rotateSlotsLeft(badSlots);
-                       } else {
-                               rotateSlotsRight(goodSlots);
-                       }
-               }
-
-               m_beginSlotIndex = newBeginSlotIndex;
-       }
-
-       bool ImageGrid::updateMaxBeginSlotIndex()
-       {
-               const int newMaxBeginSlotIndex = calcMaxBeginSlotIndex();
-
-               if (newMaxBeginSlotIndex != m_maxBeginSlotIndex) {
-                       DLOG("newMaxBeginSlotIndex: %d; m_maxBeginSlotIndex: %d;",
-                                       newMaxBeginSlotIndex, m_maxBeginSlotIndex);
-                       m_maxBeginSlotIndex = newMaxBeginSlotIndex;
-                       return true;
-               }
-
-               return false;
-       }
-
-       int ImageGrid::calcMaxBeginSlotIndex()
-       {
-               return (m_maxSlotCount - m_slotCount);
-       }
-
-       void ImageGrid::updatePadSizes()
-       {
-               const int spaceSize = (m_scrollerSize -
-                               (std::max((m_scrollerSize / m_slotSize), 1) * m_slotSize));
-
-               m_padSize1 = std::lround(spaceSize / 2.0);
-               m_padSize2 = (spaceSize - m_padSize1 +
-                               m_info.calcExtraPaddingSize(m_slotSize));
-       }
-
-       void ImageGrid::updateScrollBias()
-       {
-               m_scrollBias = (((m_optimalSlotCount / 2 - 1) * m_slotSize -
-                               m_scrollerSize) / 2 + m_padSize1);
-       }
-
-       void ImageGrid::updateRectMins()
-       {
-               const int beginEvenCols = ((m_beginSlotIndex + 1) / 2);
-               const int sideEvenCols = ((m_maxSlotCount - m_slotCount) / 2);
-               const int endEvenCols = (sideEvenCols - beginEvenCols);
-
-               const int rectMin1 = (m_padSize1 + (beginEvenCols * m_slotSize));
-               const int rectMin2 = (m_padSize2 + (endEvenCols * m_slotSize));
-
-               if (m_info.isHorizontal) {
-                       m_rect1.setMin(rectMin1, 0);
-                       m_rect2.setMin(rectMin2, 0);
-               } else {
-                       m_rect1.setMin(0, rectMin1);
-                       m_rect2.setMin(0, rectMin2);
-               }
-       }
-
-       bool ImageGrid::updateSlotSize()
-       {
-               const int newSlotSize = m_slots[m_beginSlotIndex & 1]->getSize();
-
-               if (newSlotSize != m_slotSize) {
-                       DLOG("newSlotSize: %d; m_slotSize: %d;",
-                                       newSlotSize, m_slotSize);
-                       setSlotSize(newSlotSize);
-                       return true;
-               }
-
-               return false;
-       }
-
-       void ImageGrid::setSlotSize(const int newSlotSize)
-       {
-               m_slotSize = newSlotSize;
-               const int pageSize = (m_slotSize * m_info.slotsPerPage);
-               if (m_info.isHorizontal) {
-                       elm_scroller_page_size_set(*m_scroller, pageSize, 0);
-               } else {
-                       elm_scroller_page_size_set(*m_scroller, 0, pageSize);
-               }
-       }
-
-       int ImageGrid::calcScrollerSize()
-       {
-               int scrollerW = 0;
-               int scrollerH = 0;
-               getSize(*m_scroller, &scrollerW, &scrollerH);
-
-               return std::max((m_info.isHorizontal ? scrollerW : scrollerH), 1);
-       }
-
-       bool ImageGrid::updateScrollerSize()
-       {
-               const int newScrollerSize = calcScrollerSize();
-
-               if (newScrollerSize != m_scrollerSize) {
-                       DLOG("newScrollerSize: %d; m_scrollerSize: %d;",
-                                       newScrollerSize, m_scrollerSize);
-                       m_scrollerSize = newScrollerSize;
-                       return true;
-               }
-
-               return false;
-       }
-
-       int ImageGrid::calcScrollOffset()
-       {
-               int scrollOffsetX = 0;
-               int scrollOffsetY = 0;
-               elm_scroller_region_get(*m_scroller, &scrollOffsetX, &scrollOffsetY,
-                               nullptr, nullptr);
-
-               return (m_info.isHorizontal ? scrollOffsetX : scrollOffsetY);
-       }
-
-       bool ImageGrid::updateScrollOffset()
-       {
-               const int newScrollOffset = calcScrollOffset();
-
-               if (newScrollOffset != m_scrollOffset) {
-                       DLOG("newScrollOffset: %d; m_scrollOffset: %d;",
-                                       newScrollOffset, m_scrollOffset);
-                       m_scrollOffset = newScrollOffset;
-                       return true;
-               }
-
-               return false;
-       }
-
-       void ImageGrid::rotateSlotsRight(const int count)
-       {
-               DLOG("count: %d", count);
-               for (int i = 0; i < count; ++i) {
-                       SlotUPtr slot = std::move(m_slots.back());
-                       m_slots.pop_back();
-                       elm_box_unpack(m_box, slot->getLayout());
-                       elm_box_pack_after(m_box, slot->getLayout(), m_rect1);
-                       m_slots.emplace_front(std::move(slot));
-               }
-       }
-
-       void ImageGrid::rotateSlotsLeft(const int count)
-       {
-               DLOG("count: %d", count);
-               for (int i = 0; i < count; ++i) {
-                       SlotUPtr slot = std::move(m_slots.front());
-                       m_slots.pop_front();
-                       elm_box_unpack(m_box, slot->getLayout());
-                       elm_box_pack_before(m_box, slot->getLayout(), m_rect2);
-                       m_slots.emplace_back(std::move(slot));
-               }
-       }
-
-       void ImageGrid::realizeSlots()
-       {
-               if (m_unrealizeLock == 0) {
-                       for (int i = 0; i < m_slotCount; ++i) {
-                               m_slots[i]->realize(m_beginSlotIndex + i);
-                       }
-               }
-       }
-
-       void ImageGrid::unrealizeSlots(
-                       const int beginSlotOffset, const int endSlotOffset)
-       {
-               if (m_unrealizeLock == 0) {
-                       for (int i = beginSlotOffset; i < endSlotOffset; ++i) {
-                               m_slots[i]->unrealize();
-                       }
-               }
-       }
-
-       void ImageGrid::handleScrolling()
-       {
-               if (m_animator) {
-                       return;
-               }
-
-               if (m_eventsLock > 0) {
-                       WLOG("Event handling was blocked!");
-                       return;
-               }
-               ++m_eventsLock;
-
-               if (updateScrollOffset()) {
-                       updateHighlightTimeout();
-                       if (updateBeginSlotIndex()) {
-                               realizeSlots();
-                               updateRectMins();
-                       }
-               }
-
-               --m_eventsLock;
-       }
-
-       void ImageGrid::handleResize()
-       {
-               if (m_animator) {
-                       return;
-               }
-
-               if (m_eventsLock > 0) {
-                       WLOG("Event handling was blocked!");
-                       return;
-               }
-               ++m_eventsLock;
-
-               if (updateScrollerSize()) {
-                       bool needRealize = false;
-
-                       updatePadSizes();
-
-                       if (updateOptimalSlotCount() && updateSlotCount()) {
-                               updateMaxBeginSlotIndex();
-                               needRealize = true;
-                       }
-
-                       updateScrollBias();
-
-                       if (updateBeginSlotIndex()) {
-                               needRealize = true;
-                       }
-
-                       if (needRealize) {
-                               realizeSlots();
-                       }
-                       updateRectMins();
-               }
-
-               --m_eventsLock;
-       }
-
-       void ImageGrid::onScrollerResize(Widget &sender, void *eventInfo)
-       {
-               handleResize();
-       }
-
-       void ImageGrid::onScrollerMove(Widget &sender, void *eventInfo)
-       {
-               handleScrolling();
-       }
-
-       void ImageGrid::onBoxMove(Widget &sender, void *eventInfo)
-       {
-               handleScrolling();
-       }
-}
diff --git a/src/view/ImageViewer.cpp b/src/view/ImageViewer.cpp
deleted file mode 100644 (file)
index da3a0c2..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/view/ImageViewer.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr auto ANIMATION_START_TIMEOUT_SEC = (1.0 / 30.0);
-       constexpr auto ANIMATION_RUNTIME_SEC = (300.0 / 1000.0);
-       constexpr auto ANIMATION_STOP_POS = 0.999999;
-}}}
-
-namespace gallery {
-
-       using ucl::LAYOUT_DEFAULT;
-
-       // ImageViewer::Builder //
-
-       ImageViewer::Builder::Builder() :
-               m_loadSize(0),
-               m_forceLoad(false)
-       {
-       }
-
-       ImageViewer::Builder &ImageViewer::Builder::
-                       setHighResImagePath(std::string path)
-       {
-               m_highResPath = std::move(path);
-               return *this;
-       }
-
-       ImageViewer::Builder &ImageViewer::Builder::setLoadSize(const int value)
-       {
-               m_loadSize = value;
-               return *this;
-       }
-
-       ImageViewer::Builder &ImageViewer::Builder::setForceLoad(const bool value)
-       {
-               m_forceLoad = value;
-               return *this;
-       }
-
-       ImageViewerSRef ImageViewer::Builder::build(ElmWidget &parent) const
-       {
-               if (isEmpty(m_highResPath)) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "m_highResPath is empty!");
-               }
-
-               auto scroller = elm_scroller_add(parent);
-               if (!scroller) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "elm_scroller_add() failed!");
-               }
-
-               return makeShared<ImageViewer>(scroller, m_highResPath,
-                               m_loadSize, m_forceLoad);
-       }
-
-       // ImageViewer //
-
-       ImageViewer::ImageViewer(IRefCountObj &rc, Evas_Object *const scroller,
-                       const std::string &highResPath, const int loadSize,
-                       const bool forceLoad) :
-               ElmWidget(&rc, scroller),
-
-               m_scroller(makeShared<StyledWidget>(scroller, false).get()),
-               m_layout(elm_layout_add(*m_scroller)),
-               m_grid(evas_object_grid_add(m_layout.getEvas())),
-               m_lowResImage(evas_object_image_filled_add(m_grid.getEvas())),
-               m_highResImage(evas_object_image_filled_add(m_grid.getEvas())),
-
-               m_imageW(0),
-               m_imageH(0),
-
-               m_scrollerW(0),
-               m_scrollerH(0),
-               m_gridW(0),
-               m_gridH(0),
-               m_scale0(0),
-               m_scale1(0),
-
-               m_xf1(0.5),
-               m_yf1(0.5),
-               m_xf2(0.5),
-               m_yf2(0.5),
-               m_zoom(0.0),
-
-               m_animationStartTimer(nullptr),
-               m_animator(nullptr),
-               m_state(State::ZOOMED_OUT)
-       {
-               prepare(highResPath, loadSize, forceLoad);
-       }
-
-       ImageViewer::~ImageViewer()
-       {
-               if (m_animationStartTimer) {
-                       ecore_timer_del(m_animationStartTimer);
-               }
-               if (m_animator) {
-                       ecore_animator_del(m_animator);
-               }
-       }
-
-       void ImageViewer::prepare(const std::string &highResPath,
-                       const int loadSize, const bool forceLoad)
-       {
-               expandAndFill(*m_scroller);
-               m_scroller->setStyle(SCROLLER_STYLE);
-               elm_scroller_bounce_set(*m_scroller, EINA_TRUE, EINA_TRUE);
-               elm_scroller_policy_set(*m_scroller,
-                               ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
-               elm_scroller_single_direction_set(*m_scroller,
-                               ELM_SCROLLER_SINGLE_DIRECTION_NONE);
-               show(*m_scroller);
-
-               expandAndFill(m_layout);
-               m_layout.setTheme(LAYOUT_DEFAULT);
-               m_scroller->setContent(m_layout);
-               show(m_layout);
-
-               evas_object_grid_size_set(m_grid, 1, 1);
-               m_layout.setContent(m_grid);
-               show(m_grid);
-
-               evas_object_image_load_orientation_set(m_lowResImage, EINA_TRUE);
-               evas_object_grid_pack(m_grid, m_lowResImage, 0, 0, 1, 1);
-               if (loadSize > 0) {
-                       evas_object_image_load_size_set(m_lowResImage, loadSize, loadSize);
-               }
-               show(m_lowResImage);
-               makeTransparent(m_lowResImage);
-
-               evas_object_image_load_orientation_set(m_highResImage, EINA_TRUE);
-               evas_object_grid_pack(m_grid, m_highResImage, 0, 0, 1, 1);
-               if (forceLoad) {
-                       if (loadSize > 0) {
-                               evas_object_image_load_size_set(m_highResImage,
-                                               loadSize, loadSize);
-                       }
-                       evas_object_image_file_set(m_highResImage,
-                                       highResPath.c_str(), nullptr);
-                       show(m_highResImage);
-               } else {
-                       hide(m_highResImage);
-                       m_highResImage.addEventHandler(WidgetEvent::IMAGE_PRELOADED,
-                                       WEAK_DELEGATE(ImageViewer::onImagePreloaded,
-                                               asWeak(*this)));
-                       evas_object_image_file_set(m_highResImage,
-                                       highResPath.c_str(), nullptr);
-                       evas_object_image_preload(m_highResImage, EINA_FALSE);
-               }
-
-               evas_object_image_size_get(m_highResImage, &m_imageW, &m_imageH);
-               if ((m_imageW == 0) || (m_imageH == 0)) {
-                       WLOG("Invalid image size!");
-                       m_imageW = 1;
-                       m_imageH = 1;
-               }
-
-               m_scroller->addEventHandler(WidgetEvent::RESIZE,
-                               WEAK_DELEGATE(ImageViewer::onScrollerResize, asWeak(*this)));
-       }
-
-       void ImageViewer::onScrollerResize(Widget &widget, void *eventInfo)
-       {
-               if (updateScrollerSize()) {
-                       updateScales();
-                       updateGridSize();
-                       updateScrollOffset();
-               }
-       }
-
-       bool ImageViewer::updateScrollerSize()
-       {
-               int scrollerW = 0;
-               int scrollerH = 0;
-               getSize(*m_scroller, &scrollerW, &scrollerH);
-
-               if ((scrollerW == 0) || (scrollerH == 0)) {
-                       DLOG("Scroller has 0 size. Skip.");
-                       return false;
-               }
-
-               if ((scrollerW != m_scrollerW) || (scrollerH != m_scrollerH)) {
-                       m_scrollerW = scrollerW;
-                       m_scrollerH = scrollerH;
-                       return true;
-               }
-
-               return false;
-       }
-
-       void ImageViewer::updateScales()
-       {
-               const double sx = (1.0 * m_scrollerW / m_imageW);
-               const double sy = (1.0 * m_scrollerH / m_imageH);
-
-               m_scale0 = ((sx > sy) ? sx : sy);
-               m_scale1 = 1.0;
-       }
-
-       void ImageViewer::updateGridSize()
-       {
-               const double scale = (m_scale0 + m_zoom * (m_scale1 - m_scale0));
-
-               m_gridW = std::lround(scale * m_imageW);
-               m_gridH = std::lround(scale * m_imageH);
-
-               m_grid.setMin(m_gridW, m_gridH);
-               m_grid.setMax(m_gridW, m_gridH);
-
-               m_layout.calculate();
-       }
-
-       void ImageViewer::updateScrollOffset()
-       {
-               const double xf2 = (m_xf2 + m_zoom * (0.5 - m_xf2));
-               const double yf2 = (m_yf2 + m_zoom * (0.5 - m_yf2));
-
-               const int sx = std::lround((m_xf1 * m_gridW) - (xf2 * m_scrollerW));
-               const int sy = std::lround((m_yf1 * m_gridH) - (yf2 * m_scrollerH));
-
-               elm_scroller_region_show(*m_scroller, sx, sy, m_scrollerW, m_scrollerH);
-       }
-
-       void ImageViewer::setLowResImagePath(const std::string &path)
-       {
-               evas_object_image_file_set(m_lowResImage, path.c_str(), nullptr);
-               makeWhite(m_lowResImage);
-       }
-
-       void ImageViewer::onImagePreloaded(Widget &widget, void *eventInfo)
-       {
-               show(widget);
-       }
-
-       bool ImageViewer::zoomIn(const int originX, const int originY)
-       {
-               if (m_state != State::ZOOMED_OUT) {
-                       WLOG("Can't zoom in!");
-                       return false;
-               }
-
-               m_state = State::ZOOMING_IN;
-
-               calcZoomInFactors(originX, originY);
-               startAnimation();
-
-               return true;
-       }
-
-       bool ImageViewer::zoomOut()
-       {
-               if (m_state != State::ZOOMED_IN) {
-                       WLOG("Can't zoom out!");
-                       return false;
-               }
-
-               m_state = State::ZOOMING_OUT;
-
-               calcZoomOutFactors();
-               startAnimation();
-
-               return true;
-       }
-
-       bool ImageViewer::isZooming() const
-       {
-               return ((m_state == State::ZOOMING_IN) ||
-                               (m_state == State::ZOOMING_OUT));
-       }
-
-       bool ImageViewer::isZoomedIn() const
-       {
-               return (m_state == State::ZOOMED_IN);
-       }
-
-       bool ImageViewer::isZoomedOut() const
-       {
-               return (m_state == State::ZOOMED_OUT);
-       }
-
-       void ImageViewer::calcZoomInFactors(const int originX, const int originY)
-       {
-               if (m_scale0 > m_scale1) {
-                       m_xf1 = 0.5;
-                       m_yf1 = 0.5;
-                       m_xf2 = 0.5;
-                       m_yf2 = 0.5;
-                       return;
-               }
-
-               int x = 0;
-               int y = 0;
-               getPosition(*m_scroller, &x, &y);
-
-               const int newOriginX = (originX - x);
-               const int newOriginY = (originY - x);
-
-               int sx = 0;
-               int sy = 0;
-               elm_scroller_region_get(*m_scroller, &sx, &sy, nullptr, nullptr);
-
-               m_xf1 = (1.0 * (sx + newOriginX) / m_gridW);
-               m_yf1 = (1.0 * (sy + newOriginY) / m_gridH);
-               m_xf2 = (1.0 * newOriginX / m_scrollerW);
-               m_yf2 = (1.0 * newOriginY / m_scrollerH);
-       }
-
-       void ImageViewer::calcZoomOutFactors()
-       {
-               int sx = 0;
-               int sy = 0;
-               elm_scroller_region_get(*m_scroller, &sx, &sy, nullptr, nullptr);
-
-               if (m_gridW < m_scrollerW) {
-                       sx = (0.5 * (m_gridW - m_scrollerW));
-               }
-               if (m_gridH < m_scrollerH) {
-                       sy = (0.5 * (m_gridH - m_scrollerH));
-               }
-
-               m_xf1 = ((sx + 0.5 * m_scrollerW) / m_gridW);
-               m_yf1 = ((sy + 0.5 * m_scrollerH) / m_gridH);
-               m_xf2 = (m_scale0 * m_imageW * (m_xf1 - 0.5) / m_scrollerW + 0.5);
-               m_yf2 = (m_scale0 * m_imageH * (m_yf1 - 0.5) / m_scrollerH + 0.5);
-       }
-
-       void ImageViewer::startAnimation()
-       {
-               if (m_animationStartTimer) {
-                       WLOG("Timer is running!");
-                       ecore_timer_del(m_animationStartTimer);
-               }
-
-               m_animationStartTimer = ecore_timer_add(
-                               impl::ANIMATION_START_TIMEOUT_SEC,
-                               CALLBACK_A(ImageViewer::onAnimationStartTimer), this);
-       }
-
-       Eina_Bool ImageViewer::onAnimationStartTimer()
-       {
-               m_animationStartTimer = nullptr;
-
-               if (m_animator) {
-                       WLOG("Animator is running!");
-                       ecore_animator_del(m_animator);
-               }
-               m_animator = ecore_animator_timeline_add(
-                               impl::ANIMATION_RUNTIME_SEC,
-                               CALLBACK_A(ImageViewer::onAnimationFrame), this);
-
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       Eina_Bool ImageViewer::onAnimationFrame(const double pos)
-       {
-               const double t = ecore_animator_pos_map(
-                               pos, ECORE_POS_MAP_DECELERATE, 0.0, 0.0);
-
-               m_zoom = ((m_state == State::ZOOMING_IN) ? t : (1.0 - t));
-
-               updateGridSize();
-               updateScrollOffset();
-
-               if (pos >= impl::ANIMATION_STOP_POS) {
-                       m_animator = nullptr;
-                       m_state = ((m_state == State::ZOOMING_IN) ?
-                                       State::ZOOMED_IN : State::ZOOMED_OUT);
-                       callEvent(IMAGE_VIEWER_ZOOM_END, nullptr);
-                       return ECORE_CALLBACK_CANCEL;
-               }
-
-               return ECORE_CALLBACK_RENEW;
-       }
-}
diff --git a/src/view/PageContent.cpp b/src/view/PageContent.cpp
deleted file mode 100644 (file)
index 1ef0005..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/view/PageContent.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr LayoutTheme LAYOUT_MORE_OPTIONS
-                       {"layout", "gallery", "more_options"};
-
-       constexpr LayoutTheme LAYOUT_SELECT_MODE
-                       {"layout", "select_mode", "default"};
-
-       constexpr LayoutTheme LAYOUT_BOTTOM_BUTTON
-                       {"layout", "bottom_button", "default"};
-
-       constexpr EdjePart PART_MORE_OPTIONS {"gallery.swallow.more_options"};
-       constexpr EdjePart PART_OVERLAY {"gallery.swallow.overlay"};
-
-       constexpr EdjeSignal SIGNAL_SHOW_SELECT_BUTTON {"select_mode,button,show"};
-       constexpr EdjeSignal SIGNAL_HIDE_SELECT_BUTTON {"select_mode,button,hide"};
-
-       constexpr EdjeSignal SIGNAL_SHOW_MORE_OPTIONS {"cue,show"};
-       constexpr EdjeSignal SIGNAL_HIDE_MORE_OPTIONS {"cue,hide"};
-       constexpr EdjeSignalSrc SIGNAL_SRC_EXT {"ext"};
-
-       template <class OBJ, class FUNC, class ...ARGS>
-       Result callSafe(OBJ *obj, FUNC &&func, ARGS &&...args)
-       {
-               if (!obj) {
-                       FAIL_RETURN(RES_FAIL, "obj is NULL!");
-               }
-               func(*obj, std::forward<ARGS>(args)...);
-               return RES_OK;
-       }
-}}}
-
-namespace gallery {
-
-       using ucl::Layout;
-       using ucl::LayoutSRef;
-
-       using ucl::PART_BUTTON;
-       using ucl::PART_CONTENT;
-       using ucl::PART_ICON;
-
-       // PageContent::Builder //
-
-       PageContent::Builder::Builder() :
-               m_flags(0)
-       {
-       }
-
-       PageContent::Builder &PageContent::Builder::setFlags(const int flags)
-       {
-               m_flags = flags;
-               return *this;
-       }
-
-       PageContentSRef PageContent::Builder::build(ElmWidget &parent) const
-       {
-               auto layout = Layout::Builder().
-                               setTheme(impl::LAYOUT_MORE_OPTIONS).
-                               build(parent);
-               if (!layout) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
-               }
-
-               auto result = makeShared<PageContent>(layout, m_flags);
-
-               result->bindToEo();
-
-               return result;
-       }
-
-       // PageContent //
-
-       PageContent::PageContent(IRefCountObj &rc,
-                       const LayoutSRef &layout, const int flags) :
-               ElmWidget(&rc, *layout),
-               m_mainLayout(layout.get())
-       {
-               prepare(flags);
-       }
-
-       PageContent::~PageContent()
-       {
-       }
-
-       void PageContent::prepare(const int flags)
-       {
-               m_mainLayout->setIsOwner(false);
-
-               Layout *parent = m_mainLayout;
-
-               if (flags & FLAG_SELECT_BUTTON) {
-                       m_selectMode = Layout::Builder().
-                               setTheme(impl::LAYOUT_SELECT_MODE).
-                               build(*parent);
-                       if (m_selectMode) {
-                               parent->setContent(*m_selectMode);
-                               parent = m_selectMode.get();
-                       }
-               }
-
-               if (flags & FLAG_BOTTOM_BUTTON) {
-                       m_bottomButton = Layout::Builder().
-                               setTheme(impl::LAYOUT_BOTTOM_BUTTON).
-                               build(*parent);
-                       if (m_bottomButton) {
-                               parent->setContent(*m_bottomButton);
-                               parent = m_bottomButton.get();
-                       }
-               }
-       }
-
-       Result PageContent::set(Evas_Object *const eo, const Part part)
-       {
-               return doWithPart(part,
-                       [eo](Layout &layout, const EdjePart part)
-                       {
-                               layout.setContent(eo, part);
-                       });
-       }
-
-       Evas_Object *PageContent::unset(const Part part)
-       {
-               Evas_Object *result = {};
-               doWithPart(part,
-                       [&result](Layout &layout, const EdjePart part)
-                       {
-                               result = layout.unsetContent(part);
-                       });
-               return result;
-       }
-
-       Evas_Object *PageContent::get(const Part part) const
-       {
-               Evas_Object *result = {};
-               doWithPart(part,
-                       [&result](Layout &layout, const EdjePart part)
-                       {
-                               result = layout.getContent(part);
-                       });
-               return result;
-       }
-
-       Result PageContent::setSelectButtonVisible(const bool visible)
-       {
-               if (!m_selectMode) {
-                       LOG_RETURN(RES_FAIL, "Select button is not supported!");
-               }
-               m_selectMode->emit(visible ? impl::SIGNAL_SHOW_SELECT_BUTTON :
-                               impl::SIGNAL_HIDE_SELECT_BUTTON);
-               return RES_OK;
-       }
-
-       Result PageContent::setMoreOptionsVisible(const bool visible)
-       {
-               const auto content = m_mainLayout->getContent(impl::PART_MORE_OPTIONS);
-               if (!content) {
-                       LOG_RETURN(RES_FAIL, "More option is not created!");
-               }
-               elm_layout_signal_emit(content, (visible ?
-                               impl::SIGNAL_SHOW_MORE_OPTIONS :
-                               impl::SIGNAL_HIDE_MORE_OPTIONS),
-                               impl::SIGNAL_SRC_EXT);
-               return RES_OK;
-       }
-
-       template <class FUNC>
-       Result PageContent::doWithPart(const Part part, FUNC &&func) const
-       {
-               switch (part) {
-               case Part::DEFAULT:
-                       return impl::callSafe(getTopLayout(), func, PART_CONTENT);
-               case Part::OVERLAY:
-                       func(*m_mainLayout, impl::PART_OVERLAY);
-                       return RES_OK;
-               case Part::MORE_OPTIONS:
-                       func(*m_mainLayout, impl::PART_MORE_OPTIONS);
-                       return RES_OK;
-               case Part::SELECT_BUTTON:
-                       return impl::callSafe(m_selectMode.get(), func, PART_ICON);
-               case Part::BOTTOM_BUTTON:
-                       return impl::callSafe(m_bottomButton.get(), func, PART_BUTTON);
-               }
-               LOG_RETURN(RES_FATAL, "Should not be here!");
-       }
-
-       Layout *PageContent::getTopLayout() const
-       {
-               if (m_bottomButton) {
-                       return m_bottomButton.get();
-               }
-               if (m_selectMode) {
-                       return m_selectMode.get();
-               }
-               return m_mainLayout;
-       }
-}
diff --git a/src/view/TouchParser.cpp b/src/view/TouchParser.cpp
deleted file mode 100644 (file)
index 8678bdb..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/view/TouchParser.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr auto TAP_MOVE_THRESHOLD = 30;
-       constexpr auto FAST_TAP_DISTANCE = 60;
-       constexpr auto FAST_TAP_DELAY_MS = 300;
-       constexpr auto TAP_AND_HOLD_DELAY_SEC = (500.0 / 1000.0);
-}}}
-
-namespace gallery {
-
-       TouchParser::TouchParser(IRefCountObj &rc, Widget &eventSource) :
-               RefCountAware(&rc),
-               m_holdTimer(nullptr),
-               m_downTime(0),
-               m_downX(0),
-               m_downY(0),
-               m_tapCounter(0),
-               m_isMouseDown(false),
-               m_isTapPossible(false)
-       {
-               eventSource.addEventHandler(WidgetEvent::MOUSE_DOWN,
-                               WEAK_DELEGATE(TouchParser::onMouseDown, asWeak(*this)));
-
-               eventSource.addEventHandler(WidgetEvent::MOUSE_UP,
-                               WEAK_DELEGATE(TouchParser::onMouseUp, asWeak(*this)));
-
-               eventSource.addEventHandler(WidgetEvent::MOUSE_MOVE,
-                               WEAK_DELEGATE(TouchParser::onMouseMove, asWeak(*this)));
-       }
-
-       TouchParser::~TouchParser()
-       {
-               stopHoldTimer();
-       }
-
-       void TouchParser::setTapHandler(const TapHandler &handler)
-       {
-               m_tapHandler = handler;
-       }
-
-       void TouchParser::setDoubleTapHandler(const TapHandler &handler)
-       {
-               m_doubleTapHandler = handler;
-       }
-
-       void TouchParser::setTapAndHoldHandler(const TapHandler &handler)
-       {
-               m_tapAndHoldHandler = handler;
-       }
-
-       void TouchParser::onMouseDown(Widget &widget, void *eventInfo)
-       {
-               if (m_isMouseDown) {
-                       return;
-               }
-               m_isMouseDown = true;
-
-               const auto e = static_cast<Evas_Event_Mouse_Down *>(eventInfo);
-
-               if (!isFastTap(e->timestamp, e->canvas.x, e->canvas.y)) {
-                       m_tapCounter = 0;
-                       restartHoldTimer();
-               } else if (m_doubleTapHandler && (m_tapCounter == 1)) {
-                       m_doubleTapHandler(m_downX, m_downY);
-               }
-
-               m_downTime = e->timestamp;
-               m_downX = e->canvas.x;
-               m_downY = e->canvas.y;
-               m_isTapPossible = true;
-       }
-
-       void TouchParser::onMouseUp(Widget &widget, void *eventInfo)
-       {
-               if (!m_isMouseDown) {
-                       return;
-               }
-               m_isMouseDown = false;
-
-               const auto e = static_cast<Evas_Event_Mouse_Up *>(eventInfo);
-
-               stopHoldTimer();
-               updateIsTapPossible(e->event_flags, e->canvas.x, e->canvas.y);
-
-               if (!m_isTapPossible) {
-                       m_tapCounter = 0;
-                       return;
-               }
-
-               ++m_tapCounter;
-
-               if (m_tapHandler) {
-                       m_tapHandler(e->canvas.x, e->canvas.y);
-               }
-       }
-
-       void TouchParser::onMouseMove(Widget &widget, void *eventInfo)
-       {
-               if (!m_isMouseDown || !m_isTapPossible) {
-                       return;
-               }
-
-               const auto e = static_cast<Evas_Event_Mouse_Move *>(eventInfo);
-
-               updateIsTapPossible(e->event_flags, e->cur.canvas.x, e->cur.canvas.y);
-
-               if (!m_isTapPossible) {
-                       stopHoldTimer();
-               }
-       }
-
-       void TouchParser::updateIsTapPossible(const int flags,
-                       const int curX, const int curY)
-       {
-               if (!m_isTapPossible) {
-                       return;
-               }
-               if ((flags & EVAS_EVENT_FLAG_ON_HOLD) || (calcDownDistance(curX, curY) >
-                               ELM_SCALE_SIZE(impl::TAP_MOVE_THRESHOLD))) {
-                       m_isTapPossible = false;
-               }
-       }
-
-       bool TouchParser::isFastTap(const UInt curTime,
-                       const int curX, const int curY) const
-       {
-               return (((curTime - m_downTime) <= impl::FAST_TAP_DELAY_MS) &&
-                               (calcDownDistance(curX, curY) <=
-                                               ELM_SCALE_SIZE(impl::FAST_TAP_DISTANCE)));
-       }
-
-       double TouchParser::calcDownDistance(int curX, int curY) const
-       {
-               const auto dx = (curX - m_downX);
-               const auto dy = (curY - m_downY);
-
-               return sqrt(1.0 * dx * dx + 1.0 * dy * dy);
-       }
-
-       void TouchParser::restartHoldTimer()
-       {
-               stopHoldTimer();
-               m_holdTimer = ecore_timer_add(impl::TAP_AND_HOLD_DELAY_SEC,
-                               CALLBACK_A(TouchParser::onHoldTimer), this);
-       }
-
-       void TouchParser::stopHoldTimer()
-       {
-               if (m_holdTimer) {
-                       ecore_timer_del(m_holdTimer);
-                       m_holdTimer = nullptr;
-               }
-       }
-
-       Eina_Bool TouchParser::onHoldTimer()
-       {
-               m_holdTimer = nullptr;
-               if (m_tapAndHoldHandler) {
-                       m_tapAndHoldHandler(m_downX, m_downY);
-               }
-               return ECORE_CALLBACK_CANCEL;
-       }
-}
diff --git a/src/view/common.h b/src/view/common.h
deleted file mode 100644 (file)
index e72c13b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_VIEW_COMMON_H__
-#define __GALLERY_VIEW_COMMON_H__
-
-#include "ucl/gui/StyledWidget.h"
-#include "ucl/gui/stdTheme.h"
-#include "ucl/gui/helpers.h"
-
-#include "gallery/view/helpers.h"
-
-#include "../common.h"
-
-namespace gallery {
-
-       using ucl::EdjePart;
-       using ucl::EdjeDataKey;
-       using ucl::EdjeSignal;
-       using ucl::EdjeSignalSrc;
-       using ucl::ElmStyle;
-       using ucl::SmartEvent;
-       using ucl::EoDataKey;
-       using ucl::LayoutTheme;
-       using ucl::WidgetEvent;
-       using ucl::WidgetARHint;
-
-       using ucl::TString;
-
-       UCL_USING_REF_ALIASES(ucl::Widget);
-       UCL_USING_REF_ALIASES(ucl::ElmWidget);
-       UCL_USING_REF_ALIASES(ucl::EdjeWidget);
-       UCL_USING_REF_ALIASES(ucl::StyledWidget);
-
-       constexpr ucl::SmartEvent BTN_CLICKED {"clicked"};
-       constexpr ucl::SmartEvent POPUP_DISMISSED {"dismissed"};
-
-       constexpr ucl::SmartEvent ATSPI_HIGHLIGHTED {"atspi,highlighted"};
-       constexpr ucl::SmartEvent ATSPI_UNHIGHLIGHTED {"atspi,unhighlighted"};
-
-       constexpr ucl::ElmStyle SCROLLER_STYLE {"effect"};
-
-       constexpr ucl::ElmStyle NAVIFRAME_NO_CLIP {"gallery_no_clip"};
-}
-
-#endif // __GALLERY_VIEW_COMMON_H__
diff --git a/src/view/helpers.cpp b/src/view/helpers.cpp
deleted file mode 100644 (file)
index 393e3de..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "gallery/view/helpers.h"
-
-#include <vector>
-
-#include "ucl/gui/Window.h"
-#include "ucl/gui/Layout.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr EoDataKey CIRCLE_SURFACE {"gallery,eext,circle,surface"};
-
-       constexpr LayoutTheme LAYOUT_FAKE_ACCESS_OBJECT
-                       {"layout", "gallery", "fake_access_object"};
-}}}
-
-namespace gallery { namespace util {
-
-       using ucl::Layout;
-       using ucl::Naviframe;
-
-       Result createCircleSurface(Naviframe &navi)
-       {
-               const auto win = navi.getWindow();
-               if (!win) {
-                       LOG_RETURN(RES_FAIL, "Failed to get Window from Naviframe!");
-               }
-
-               if (win->getData(impl::CIRCLE_SURFACE)) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "Circle Surface data already set!");
-               }
-
-               const auto sfc = eext_circle_surface_naviframe_add(navi);
-               if (!sfc) {
-                       LOG_RETURN(RES_FAIL,
-                                       "eext_circle_surface_conformant_add() failed!");
-               }
-
-               win->setData(impl::CIRCLE_SURFACE, sfc);
-
-               return RES_OK;
-       }
-
-       Eext_Circle_Surface *getCircleSurface(const ElmWidget &widget)
-       {
-               const auto win = widget.getWindow();
-               if (!win) {
-                       LOG_RETURN_VALUE(RES_FAIL, nullptr,
-                                       "Failed to get Window from widget!");
-               }
-
-               const auto sfc = static_cast<Eext_Circle_Surface *>(
-                               win->getData(impl::CIRCLE_SURFACE));
-               if (!sfc) {
-                       LOG_RETURN_VALUE(RES_FAIL, nullptr,
-                                       "Failed to get Eext_Circle_Surface from window!");
-               }
-
-               return sfc;
-       }
-
-       ElmWidgetSRef createFakeAccessObject(ElmWidget &parent)
-       {
-               const auto result = Layout::Builder().
-                               setTheme(impl::LAYOUT_FAKE_ACCESS_OBJECT).
-                               setNeedBindToEo(true).
-                               build(parent);
-               if (!result) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
-               }
-
-               result->setGeometry(0, 0, 1, 1);
-               show(*result);
-
-               elm_atspi_accessible_reading_info_type_set(*result, 0);
-
-               elm_atspi_accessible_gesture_cb_set(*result,
-                       [](void *, Elm_Atspi_Gesture_Info, Evas_Object *) -> Eina_Bool
-                       {
-                               return EINA_TRUE;
-                       },
-                       nullptr);
-
-               return result;
-       }
-}}
-
-namespace gallery {
-
-       void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
-       {
-               eext_rotary_event_handler_add(func, data);
-       }
-
-       void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
-       {
-               std::vector<void *> backup;
-               while (true) {
-                       void *const oldData = eext_rotary_event_handler_del(func);
-                       if (!oldData || (oldData == data)) {
-                               return;
-                       }
-                       backup.push_back(oldData);
-               }
-               for (auto i = backup.size(); i-- > 0; ) {
-                       eext_rotary_event_handler_add(func, backup[i]);
-               }
-       }
-
-       LayoutTheme getImageTheme(const char *const fileName)
-       {
-               return {"layout", "gallery_image", fileName};
-       }
-
-       Elm_Atspi_Relation_Type getFlowRelation(Elm_Atspi_Gesture_Info gestureInfo)
-       {
-               switch (gestureInfo.type) {
-               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_RIGHT:
-               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_DOWN:
-                       return ELM_ATSPI_RELATION_FLOWS_TO;
-               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_LEFT:
-               case ELM_ATSPI_GESTURE_ONE_FINGER_FLICK_UP:
-                       return ELM_ATSPI_RELATION_FLOWS_FROM;
-               default:
-                       break;
-               }
-               return ELM_ATSPI_RELATION_NULL;
-       }
-}
index e80b6c8d9e37a96ab96c10f69f4e8f0761c2b2a2..78ed1c9fb9f56fbc45d7f3c518cc18bfe8c25194 100644 (file)
@@ -1,22 +1,22 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="org.tizen.w-gallery" version="1.0.0">
-       <profile name="wearable"/>
-       <ui-application appid="org.tizen.w-gallery" exec="gallery" hw-acceleration="on" launch_mode="caller" multiple="false" nodisplay="false" taskmanage="true" type="capp">
-               <label>Gallery</label>
-               <icon>org.tizen.gallery.png</icon>
-               <app-control>
-                       <operation name="http://tizen.org/appcontrol/operation/view"/>
-                       <mime name="image/*"/>
-               </app-control>
-               <app-control>
-                       <operation name="http://tizen.org/appcontrol/operation/view"/>
-                       <mime name="video/*"/>
-               </app-control>
-       </ui-application>
-       <privileges>
-               <privilege>http://tizen.org/privilege/mediastorage</privilege>
-               <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
-               <privilege>http://tizen.org/privilege/externalstorage</privilege>
-               <privilege>http://tizen.org/privilege/content.write</privilege>
-       </privileges>
-</manifest>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="org.tizen.w-gallery" version="1.0.0">\r
+       <profile name="wearable"/>\r
+       <ui-application appid="org.tizen.w-gallery" exec="w-gallery" hw-acceleration="on" launch_mode="caller" multiple="false" nodisplay="false" taskmanage="true" type="capp">\r
+               <label>Gallery</label>\r
+               <icon>org.tizen.gallery.png</icon>\r
+               <app-control>\r
+                       <operation name="http://tizen.org/appcontrol/operation/view"/>\r
+                       <mime name="image/*"/>\r
+               </app-control>\r
+               <app-control>\r
+                       <operation name="http://tizen.org/appcontrol/operation/view"/>\r
+                       <mime name="video/*"/>\r
+               </app-control>\r
+       </ui-application>\r
+       <privileges>\r
+               <privilege>http://tizen.org/privilege/mediastorage</privilege>\r
+               <privilege>http://tizen.org/privilege/appmanager.launch</privilege>\r
+               <privilege>http://tizen.org/privilege/externalstorage</privilege>\r
+               <privilege>http://tizen.org/privilege/content.write</privilege>\r
+       </privileges>\r
+</manifest>\r
diff --git a/ucl/inc/ucl/appfw/IInstance.h b/ucl/inc/ucl/appfw/IInstance.h
deleted file mode 100644 (file)
index bf09205..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_I_INSTANCE_H__
-#define __UCL_APPFW_I_INSTANCE_H__
-
-#include "IInstanceContext.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(IInstance);
-
-       class IInstance : public Polymorphic {
-       public:
-               virtual Result onCreate(IInstanceContext *context) = 0;
-               virtual void onPause() = 0;
-               virtual void onResume() = 0;
-       };
-}
-
-#endif // __UCL_APPFW_I_INSTANCE_H__
diff --git a/ucl/inc/ucl/appfw/IInstanceAppControlExt.h b/ucl/inc/ucl/appfw/IInstanceAppControlExt.h
deleted file mode 100644 (file)
index 6799a84..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_I_INSTANCE_APP_CONTROL_EXT_H__
-#define __UCL_APPFW_I_INSTANCE_APP_CONTROL_EXT_H__
-
-#include "types.h"
-
-namespace ucl {
-
-       class IInstanceAppControlExt : public Polymorphic {
-       public:
-               virtual void onAppControl(app_control_h appControl) = 0;
-       };
-}
-
-#endif // __UCL_APPFW_I_INSTANCE_APP_CONTROL_EXT_H__
diff --git a/ucl/inc/ucl/appfw/IInstanceContext.h b/ucl/inc/ucl/appfw/IInstanceContext.h
deleted file mode 100644 (file)
index b06c177..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_I_INSTANCE_CONTEXT_H__
-#define __UCL_APPFW_I_INSTANCE_CONTEXT_H__
-
-#include "types.h"
-
-#include "ucl/gui/Window.h"
-
-namespace ucl {
-
-       class IInstanceContext : public Polymorphic {
-       public:
-               virtual AppType getAppType() const = 0;
-               virtual WindowSRef getWindow() = 0;
-               virtual void exitApp() = 0;
-       };
-}
-
-#endif // __UCL_APPFW_I_INSTANCE_CONTEXT_H__
diff --git a/ucl/inc/ucl/appfw/InstanceManagerBase.h b/ucl/inc/ucl/appfw/InstanceManagerBase.h
deleted file mode 100644 (file)
index 0fdde8c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_INSTANCE_MANAGER_BASE_H__
-#define __UCL_APPFW_INSTANCE_MANAGER_BASE_H__
-
-#include "IInstance.h"
-#include "SysEventProvider.h"
-
-namespace ucl {
-
-       class InstanceManagerBase : public Polymorphic {
-       public:
-               InstanceManagerBase(AppParams appParams);
-               virtual ~InstanceManagerBase();
-
-               const AppParams &getAppParams() const;
-
-               void setSysEventProvider(SysEventProviderUPtr provider);
-
-               virtual IInstanceSRef newInstance() const = 0;
-
-       protected:
-               SysEventProvider &getSysEventProvider() const;
-
-       private:
-               const AppParams m_appParams;
-               SysEventProviderUPtr m_sysEventProvider;
-       };
-}
-
-#endif // __UCL_APPFW_INSTANCE_MANAGER_BASE_H__
diff --git a/ucl/inc/ucl/appfw/SysEventProvider.h b/ucl/inc/ucl/appfw/SysEventProvider.h
deleted file mode 100644 (file)
index 8a72758..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_SYS_EVENT_PROVIDER_H__
-#define __UCL_APPFW_SYS_EVENT_PROVIDER_H__
-
-#include <list>
-
-#include "types.h"
-
-namespace ucl {
-
-       class SysEventProvider;
-       using SysEventProviderUPtr = std::unique_ptr<SysEventProvider>;
-
-       class SysEventProvider final : public NonCopyable {
-       public:
-               using EventHandlerAddFunc = int (*)(app_event_handler_h *,
-                               app_event_type_e, app_event_cb, void *);
-               using EventHandlerDelFunc = int (*)(app_event_handler_h);
-
-       public:
-               SysEventProvider(EventHandlerAddFunc addFunc,
-                               EventHandlerDelFunc delFunc);
-               ~SysEventProvider();
-
-               void addEventHandler(const SysEventHandler &handler);
-               void delEventHandler(const SysEventHandler &handler);
-
-       private:
-               int addEventHandler(app_event_handler_h *handler,
-                               app_event_type_e appEvent, app_event_cb cb, void *data);
-               int delEventHandler(app_event_handler_h handler);
-
-               void dispatch(SysEvent sysEvent);
-
-       private:
-               class EventProxy;
-               using EventProxies = std::list<EventProxy>;
-
-       private:
-               const EventHandlerAddFunc m_addFunc;
-               const EventHandlerDelFunc m_delFunc;
-               EventProxies m_eventProxies;
-               Event<SysEventHandler> m_event;
-       };
-}
-
-#include "SysEventProvider.hpp"
-
-#endif // __UCL_APPFW_SYS_EVENT_PROVIDER_H__
diff --git a/ucl/inc/ucl/appfw/SysEventProvider.hpp b/ucl/inc/ucl/appfw/SysEventProvider.hpp
deleted file mode 100644 (file)
index 1d52394..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline void SysEventProvider::addEventHandler(
-                       const SysEventHandler &handler)
-       {
-               m_event += handler;
-       }
-
-       inline void SysEventProvider::delEventHandler(
-                       const SysEventHandler &handler)
-       {
-               m_event -= handler;
-       }
-}
diff --git a/ucl/inc/ucl/appfw/UIApp.h b/ucl/inc/ucl/appfw/UIApp.h
deleted file mode 100644 (file)
index a8b4dbc..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_UI_APP_H__
-#define __UCL_APPFW_UI_APP_H__
-
-#include "IInstanceContext.h"
-
-#include "InstanceManagerBase.h"
-
-namespace ucl {
-
-       class UIApp final : private IInstanceContext {
-       public:
-               UIApp(InstanceManagerBase &instanceMgr);
-               virtual ~UIApp();
-
-               int run(int argc, char *argv[]);
-
-       private:
-               bool onCreate();
-               void onTerminate();
-               void onPause();
-               void onResume();
-               void onAppControl(app_control_h appControl);
-
-               Result configParams();
-               Result createWindow();
-
-               void initSysEventManager();
-               Result createInstance();
-
-               // IInstanceContext //
-
-               virtual AppType getAppType() const final override;
-               virtual WindowSRef getWindow() final override;
-               virtual void exitApp() final override;
-
-       private:
-               InstanceManagerBase &m_instanceMgr;
-               WindowSRef m_window;
-               IInstanceSRef m_instance;
-       };
-}
-
-#endif // __UCL_APPFW_UI_APP_H__
diff --git a/ucl/inc/ucl/appfw/helpers.h b/ucl/inc/ucl/appfw/helpers.h
deleted file mode 100644 (file)
index fe598d9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_HELPERS_H__
-#define __UCL_APPFW_HELPERS_H__
-
-#include "types.h"
-
-namespace ucl {
-
-       std::string getResPath(const char *relativePath);
-}
-
-#endif // __UCL_APPFW_HELPERS_H__
diff --git a/ucl/inc/ucl/appfw/types.h b/ucl/inc/ucl/appfw/types.h
deleted file mode 100644 (file)
index 48f8adc..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_TYPES_H__
-#define __UCL_APPFW_TYPES_H__
-
-#include <app_common.h>
-#include <app_control.h>
-
-#include "ucl/util/types.h"
-#include "ucl/util/delegation.h"
-#include "ucl/util/smartDelegation.h"
-
-#include "ucl/misc/HashMap.h"
-#include "ucl/misc/Event.h"
-#include "ucl/misc/AutoHandle.h"
-
-namespace ucl {
-
-       enum class AppType {
-               UI,
-               WIDGET,
-               WATCH
-       };
-
-       enum class AppParam {
-               BASE_SCALE,
-               ACCELERATION_PREFERENECE,
-               WINDOW_TYPE,
-               WINDOW_NAME
-       };
-
-       using AppParams = HashMap<AppParam, Variant>;
-
-       enum class SysEvent {
-               LANGUAGE_CHANGED,
-               REGION_FMT_CHANGED,
-               LOW_MEMORY,
-               LOW_BATTERY,
-               ORIENTATION_CHANGED,
-               SUSPEND_STATE_CHANGED,
-               UPDATE_REQUESTED
-       };
-
-       using SysEventHandler = WeakDelegate<void(SysEvent)>;
-
-       using AutoAppCtrl = AutoHandle<app_control_h, int, app_control_destroy>;
-}
-
-#endif // __UCL_APPFW_TYPES_H__
diff --git a/ucl/inc/ucl/config.h b/ucl/inc/ucl/config.h
deleted file mode 100644 (file)
index 584596c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_CONFIG_H__
-#define __UCL_CONFIG_H__
-
-#ifdef _DEBUG
-#define UCL_DEBUG
-#endif
-
-#define UCL_DEFINE_GET_UCL_RESULT_DATA 1
-
-#define UCL_LOG_LEVEL_VERBOSE 6
-#define UCL_LOG_LEVEL_DEBUG   5
-#define UCL_LOG_LEVEL_INFO    4
-#define UCL_LOG_LEVEL_WARNING 3
-#define UCL_LOG_LEVEL_ERROR   2
-#define UCL_LOG_LEVEL_FATAL   1
-
-#ifdef UCL_DEBUG
-#define UCL_MAX_LOG_LEVEL UCL_LOG_LEVEL_VERBOSE
-#else
-#define UCL_MAX_LOG_LEVEL UCL_LOG_LEVEL_INFO
-#endif
-
-#define UCL_DEFAULT_LOG_TAG "GALLERY_UCL"
-
-#define UCL_INCLUDE_DELEGATION_SHORT_MACRO_H 1
-#define UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H 1
-
-#endif // __UCL_CONFIG_H__
diff --git a/ucl/inc/ucl/gui/EdjeWidget.h b/ucl/inc/ucl/gui/EdjeWidget.h
deleted file mode 100644 (file)
index 8d045c4..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_EDJE_WIDGET_H__
-#define __UCL_GUI_EDJE_WIDGET_H__
-
-#include "ElmWidget.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(EdjeWidget);
-
-       class EdjeWidget : public ElmWidget {
-       public:
-               void setText(const TString &value);
-               void setText(const TString &value, EdjePart part);
-
-               TString getText() const;
-               TString getText(EdjePart part) const;
-
-               void setContent(Evas_Object *content);
-               void setContent(Evas_Object *content, EdjePart part);
-               Evas_Object *unsetContent();
-               Evas_Object *unsetContent(EdjePart part);
-
-               Evas_Object *getContent() const;
-               Evas_Object *getContent(EdjePart part) const;
-
-               void emit(EdjeSignal signal, EdjeSignalSrc source =
-                               EdjeSignalSrc(""));
-
-       protected:
-               EdjeWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
-       };
-}
-
-#include "EdjeWidget.hpp"
-
-#endif // __UCL_GUI_EDJE_WIDGET_H__
diff --git a/ucl/inc/ucl/gui/EdjeWidget.hpp b/ucl/inc/ucl/gui/EdjeWidget.hpp
deleted file mode 100644 (file)
index 3f989c7..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline EdjeWidget::EdjeWidget(IRefCountObj *const rc,
-                       Evas_Object *const eo, const bool isOwner) :
-               ElmWidget(rc, eo, isOwner)
-       {
-       }
-
-       inline TString EdjeWidget::getText() const
-       {
-               return elm_object_text_get(getEo());
-       }
-
-       inline TString EdjeWidget::getText(const EdjePart part) const
-       {
-               return elm_object_part_text_get(getEo(), part.name);
-       }
-
-       inline void EdjeWidget::setContent(Evas_Object *const content)
-       {
-               elm_object_content_set(getEo(), content);
-       }
-
-       inline void EdjeWidget::setContent(Evas_Object *const content,
-                       const EdjePart part)
-       {
-               elm_object_part_content_set(getEo(), part.name, content);
-       }
-
-       inline Evas_Object *EdjeWidget::unsetContent()
-       {
-               return elm_object_content_unset(getEo());
-       }
-
-       inline Evas_Object *EdjeWidget::unsetContent(const EdjePart part)
-       {
-               return elm_object_part_content_unset(getEo(), part.name);
-       }
-
-       inline Evas_Object *EdjeWidget::getContent() const
-       {
-               return elm_object_content_get(getEo());
-       }
-
-       inline Evas_Object *EdjeWidget::getContent(const EdjePart part) const
-       {
-               return elm_object_part_content_get(getEo(), part.name);
-       }
-
-       inline void EdjeWidget::emit(const EdjeSignal signal,
-                       const EdjeSignalSrc source)
-       {
-               elm_object_signal_emit(getEo(), signal.name, source.name);
-       }
-}
diff --git a/ucl/inc/ucl/gui/ElmWidget.h b/ucl/inc/ucl/gui/ElmWidget.h
deleted file mode 100644 (file)
index f967cc3..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_ELM_WIDGET_H__
-#define __UCL_GUI_ELM_WIDGET_H__
-
-#include "Widget.h"
-
-#define UCL_SMART_FWD_ATSPI UCL_SMART_FWD "atspi,"
-
-namespace ucl {
-
-       constexpr SmartEvent ATSPI_ON_GESTURE {UCL_SMART_FWD_ATSPI "gesture"};
-
-       class Window;
-
-       UCL_DECLARE_REF_ALIASES(ElmWidget);
-
-       class ElmWidget : public Widget {
-       public:
-               explicit ElmWidget(Evas_Object *eo, bool isOwner = true);
-               virtual ~ElmWidget();
-
-               void setEnabled(bool value);
-               bool isEnabled() const;
-
-               void setFocusAlowed(bool value);
-               bool isFocusAlowed() const;
-
-               void setTheme(Elm_Theme *th);
-               Elm_Theme *getTheme();
-
-               Evas_Object *getTopWidget() const;
-               Window *getWindow() const;
-
-       protected:
-               friend class ReffedObj<ElmWidget>;
-               ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
-
-               virtual void setFocusedImpl(bool value) final override;
-               virtual bool isFocusedImpl() const final override;
-               virtual bool ensureFwdEvent(SmartEvent fwdEvent) override;
-
-       private:
-               Eina_Bool onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
-                                       Evas_Object *obj);
-
-       private:
-               bool m_isAtspiGestureCbSet;
-       };
-
-       // Non-member functions //
-
-       void enable(ElmWidget &widget);
-       void disable(ElmWidget &widget);
-}
-
-#include "ElmWidget.hpp"
-
-#endif // __UCL_GUI_ELM_WIDGET_H__
diff --git a/ucl/inc/ucl/gui/ElmWidget.hpp b/ucl/inc/ucl/gui/ElmWidget.hpp
deleted file mode 100644 (file)
index 0673a57..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline ElmWidget::ElmWidget(Evas_Object *const eo, const bool isOwner) :
-               ElmWidget(nullptr, eo, isOwner)
-       {
-       }
-
-       inline void ElmWidget::setEnabled(const bool value)
-       {
-               elm_object_disabled_set(getEo(), toEina(!value));
-       }
-
-       inline bool ElmWidget::isEnabled() const
-       {
-               return !elm_object_disabled_get(getEo());
-       }
-
-       inline void ElmWidget::setFocusAlowed(const bool value)
-       {
-               elm_object_focus_allow_set(getEo(), toEina(value));
-       }
-
-       inline bool ElmWidget::isFocusAlowed() const
-       {
-               return elm_object_focus_allow_get(getEo());
-       }
-
-       inline void ElmWidget::setTheme(Elm_Theme *th)
-       {
-               elm_object_theme_set(getEo(), th);
-       }
-
-       inline Elm_Theme *ElmWidget::getTheme()
-       {
-               return elm_object_theme_get(getEo());
-       }
-
-       inline Evas_Object *ElmWidget::getTopWidget() const
-       {
-               return elm_object_top_widget_get(getEo());
-       }
-
-       // Non-member functions //
-
-       inline void enable(ElmWidget &widget)
-       {
-               widget.setEnabled(true);
-       }
-
-       inline void disable(ElmWidget &widget)
-       {
-               widget.setEnabled(false);
-       }
-}
diff --git a/ucl/inc/ucl/gui/Genlist.h b/ucl/inc/ucl/gui/Genlist.h
deleted file mode 100644 (file)
index 366eccf..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_GENLIST_H__
-#define __UCL_GUI_GENLIST_H__
-
-#include "StyledWidget.h"
-#include "GenlistItem.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(Genlist);
-
-       class Genlist final : public StyledWidget {
-       public:
-               enum class Mode {
-                       COMPRESS = ELM_LIST_COMPRESS,
-                       SCROLL = ELM_LIST_SCROLL,
-                       LIMIT = ELM_LIST_LIMIT,
-                       EXPAND = ELM_LIST_EXPAND
-               };
-
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setStyle(ElmStyle style);
-                       Builder &setMode(Mode mode);
-                       Builder &setHomogeneous(bool value);
-                       Builder &setIsOwner(bool value);
-                       Builder &setNeedBindToEo(bool value);
-                       GenlistSRef build(ElmWidget &parent) const;
-               private:
-                       ElmStyle m_style;
-                       Mode m_mode;
-                       bool m_isHomogeneous;
-                       bool m_isOwner;
-                       bool m_needBindToEo;
-               };
-
-       public:
-               friend class ReffedObj<Genlist>;
-               using StyledWidget::StyledWidget;
-
-               void setMode(Mode mode);
-               Mode getMode() const;
-
-               void setHomogeneous(bool isHomogeneous);
-               bool isHomogeneous() const;
-
-               void updateRealizedItems();
-               void clear();
-
-               GenlistItem append(const Elm_Genlist_Item_Class *itc,
-                               const void *data, SmartCbHandler onSelect = nullptr,
-                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
-                               GenlistItem parent = nullptr);
-
-               GenlistItem prepend(const Elm_Genlist_Item_Class *itc,
-                               const void *data, SmartCbHandler onSelect = nullptr,
-                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
-                               GenlistItem parent = nullptr);
-
-               GenlistItem insertAfter(GenlistItem after,
-                               const Elm_Genlist_Item_Class *itc, const void *data,
-                               SmartCbHandler onSelect = nullptr,
-                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
-                               GenlistItem parent = nullptr);
-
-               GenlistItem insertBefore(GenlistItem before,
-                               const Elm_Genlist_Item_Class *itc, const void *data,
-                               SmartCbHandler onSelect = nullptr,
-                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
-                               GenlistItem parent = nullptr);
-       };
-}
-
-#include "Genlist.hpp"
-
-#endif // __UCL_GUI_GENLIST_H__
diff --git a/ucl/inc/ucl/gui/Genlist.hpp b/ucl/inc/ucl/gui/Genlist.hpp
deleted file mode 100644 (file)
index 3c93031..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       // Genlist::Builder //
-
-       inline Genlist::Builder::Builder() :
-               m_mode(Mode::COMPRESS),
-               m_isHomogeneous(true),
-               m_isOwner(true),
-               m_needBindToEo(false)
-       {
-       }
-
-       inline Genlist::Builder &Genlist::Builder::setStyle(const ElmStyle style)
-       {
-               m_style = style;
-               return *this;
-       }
-
-       inline Genlist::Builder &Genlist::Builder::setMode(const Mode mode)
-       {
-               m_mode = mode;
-               return *this;
-       }
-
-       inline Genlist::Builder &Genlist::Builder::setHomogeneous(const bool value)
-       {
-               m_isHomogeneous = value;
-               return *this;
-       }
-
-       inline Genlist::Builder &Genlist::Builder::setIsOwner(const bool value)
-       {
-               m_isOwner = value;
-               return *this;
-       }
-
-       inline Genlist::Builder &Genlist::Builder::setNeedBindToEo(const bool value)
-       {
-               m_needBindToEo = value;
-               return *this;
-       }
-
-       // Genlist //
-
-       inline void Genlist::setMode(const Mode mode)
-       {
-               elm_genlist_mode_set(getEo(), static_cast<Elm_List_Mode>(mode));
-       }
-
-       inline Genlist::Mode Genlist::getMode() const
-       {
-               return static_cast<Mode>(elm_genlist_mode_get(getEo()));
-       }
-
-       inline void Genlist::setHomogeneous(const bool isHomogeneous)
-       {
-               elm_genlist_homogeneous_set(getEo(), toEina(isHomogeneous));
-       }
-
-       inline bool Genlist::isHomogeneous() const
-       {
-               return elm_genlist_homogeneous_get(getEo());
-       }
-
-       inline void Genlist::updateRealizedItems()
-       {
-               elm_genlist_realized_items_update(getEo());
-       }
-
-       inline void Genlist::clear()
-       {
-               elm_genlist_clear(getEo());
-       }
-
-       inline GenlistItem Genlist::append(const Elm_Genlist_Item_Class *const itc,
-                       const void *const data, const SmartCbHandler onSelect,
-                       const GenlistItem::Type type, const GenlistItem parent)
-       {
-               return GenlistItem(elm_genlist_item_append(
-                               getEo(), itc, data, parent,
-                               static_cast<Elm_Genlist_Item_Type>(type),
-                               onSelect.getStubA(), onSelect.getData()));
-       }
-
-       inline GenlistItem Genlist::prepend(const Elm_Genlist_Item_Class *const itc,
-                       const void *const data, SmartCbHandler onSelect,
-                       const GenlistItem::Type type, const GenlistItem parent)
-       {
-               return GenlistItem(elm_genlist_item_prepend(
-                               getEo(), itc, data, parent,
-                               static_cast<Elm_Genlist_Item_Type>(type),
-                               onSelect.getStubA(), onSelect.getData()));
-       }
-
-       inline GenlistItem Genlist::insertAfter(const GenlistItem after,
-                       const Elm_Genlist_Item_Class *const itc, const void *const data,
-                       const SmartCbHandler onSelect, const GenlistItem::Type type,
-                       const GenlistItem parent)
-       {
-               return GenlistItem(elm_genlist_item_insert_after(
-                               getEo(), itc, data, parent, after,
-                               static_cast<Elm_Genlist_Item_Type>(type),
-                               onSelect.getStubA(), onSelect.getData()));
-       }
-
-       inline GenlistItem Genlist::insertBefore(const GenlistItem before,
-                       const Elm_Genlist_Item_Class *itc, const void *data,
-                       const SmartCbHandler onSelect, const GenlistItem::Type type,
-                       const GenlistItem parent)
-       {
-               return GenlistItem(elm_genlist_item_insert_before(
-                               getEo(), itc, data, parent, before,
-                               static_cast<Elm_Genlist_Item_Type>(type),
-                               onSelect.getStubA(), onSelect.getData()));
-       }
-}
diff --git a/ucl/inc/ucl/gui/GenlistItem.h b/ucl/inc/ucl/gui/GenlistItem.h
deleted file mode 100644 (file)
index 2c96b9c..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_GENLIST_ITEM_H__
-#define __UCL_GUI_GENLIST_ITEM_H__
-
-#include "WidgetItem.h"
-
-namespace ucl {
-
-       class GenlistItem final : public WidgetItem {
-       public:
-               enum class Type {
-                       SIMPLE = ELM_GENLIST_ITEM_NONE,
-                       TREE = ELM_GENLIST_ITEM_TREE,
-                       GROUP = ELM_GENLIST_ITEM_GROUP
-               };
-
-               enum class SelectMode {
-                       DEFAULT = ELM_OBJECT_SELECT_MODE_DEFAULT,
-                       ALWAYS = ELM_OBJECT_SELECT_MODE_ALWAYS,
-                       NONE = ELM_OBJECT_SELECT_MODE_NONE,
-                       DISPLAY_ONLY = ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY
-               };
-
-               enum {
-                       FIELD_ALL = ELM_GENLIST_ITEM_FIELD_ALL,
-                       FIELD_TEXT = ELM_GENLIST_ITEM_FIELD_TEXT,
-                       FIELD_CONTENT = ELM_GENLIST_ITEM_FIELD_CONTENT,
-                       FIELD_STATE = ELM_GENLIST_ITEM_FIELD_STATE,
-               };
-
-       public:
-               using WidgetItem::WidgetItem;
-
-               void setSelectMode(SelectMode mode) const;
-               SelectMode getSelectMode() const;
-
-               void setSelected(bool isSelected) const;
-               bool isSelected() const;
-
-               void update() const;
-               void update(const Elm_Genlist_Item_Class *newItc) const;
-               void update(const char *parts, int fields = FIELD_ALL) const;
-       };
-}
-
-#include "GenlistItem.hpp"
-
-#endif // __UCL_GUI_GENLIST_ITEM_H__
diff --git a/ucl/inc/ucl/gui/GenlistItem.hpp b/ucl/inc/ucl/gui/GenlistItem.hpp
deleted file mode 100644 (file)
index 6920a88..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline void GenlistItem::setSelectMode(const SelectMode mode) const
-       {
-               elm_genlist_item_select_mode_set(getIt(),
-                               static_cast<Elm_Object_Select_Mode>(mode));
-       }
-
-       inline GenlistItem::SelectMode GenlistItem::getSelectMode() const
-       {
-               return static_cast<GenlistItem::SelectMode>(
-                               elm_genlist_item_select_mode_get(getIt()));
-       }
-
-       inline void GenlistItem::setSelected(const bool isSelected) const
-       {
-               elm_genlist_item_selected_set(getIt(), toEina(isSelected));
-       }
-
-       inline bool GenlistItem::isSelected() const
-       {
-               return elm_genlist_item_selected_get(getIt());
-       }
-
-       inline void GenlistItem::update() const
-       {
-               elm_genlist_item_update(getIt());
-       }
-
-       inline void GenlistItem::update(
-                       const Elm_Genlist_Item_Class *const newItc) const
-       {
-               elm_genlist_item_item_class_update(getIt(), newItc);
-       }
-
-       inline void GenlistItem::update(
-                       const char *const parts, const int fields) const
-       {
-               elm_genlist_item_fields_update(getIt(), parts,
-                               static_cast<Elm_Genlist_Item_Field_Type>(fields));
-       }
-}
diff --git a/ucl/inc/ucl/gui/Layout.h b/ucl/inc/ucl/gui/Layout.h
deleted file mode 100644 (file)
index d349f92..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_LAYOUT_H__
-#define __UCL_GUI_LAYOUT_H__
-
-#include "EdjeWidget.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(Layout);
-
-       class Layout : public EdjeWidget {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setTheme(const LayoutTheme &value);
-                       Builder &setEdjeFile(std::string filePath, EdjeGroup group);
-                       Builder &setIsOwner(bool value);
-                       Builder &setNeedBindToEo(bool value);
-                       LayoutSRef build(ElmWidget &parent) const;
-               private:
-                       LayoutTheme m_theme;
-                       std::string m_edjeFilePath;
-                       EdjeGroup m_edjeGroup;
-                       bool m_isOwner;
-                       bool m_needBindToEo;
-               };
-
-       public:
-               friend class ReffedObj<Layout>;
-               using EdjeWidget::EdjeWidget;
-               explicit Layout(Evas_Object *eo, bool isOwner = true);
-
-               bool setTheme(const LayoutTheme &theme);
-               bool setEdjeFile(const std::string &filePath, EdjeGroup group);
-
-               Variant getData(EdjeDataKey key);
-       };
-}
-
-#include "Layout.hpp"
-
-#endif // __UCL_GUI_LAYOUT_H__
diff --git a/ucl/inc/ucl/gui/Layout.hpp b/ucl/inc/ucl/gui/Layout.hpp
deleted file mode 100644 (file)
index d6d18a3..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       // Layout::Builder //
-
-       inline Layout::Builder::Builder() :
-               m_isOwner(true),
-               m_needBindToEo(false)
-       {
-       }
-
-       inline Layout::Builder &Layout::Builder::setTheme(const LayoutTheme &theme)
-       {
-               m_theme = theme;
-               return *this;
-       }
-
-       inline Layout::Builder &Layout::Builder::setEdjeFile(
-                       std::string filePath, const EdjeGroup group)
-       {
-               m_edjeFilePath = std::move(filePath);
-               m_edjeGroup = group;
-               return *this;
-       }
-
-       inline Layout::Builder &Layout::Builder::setIsOwner(const bool value)
-       {
-               m_isOwner = value;
-               return *this;
-       }
-
-       inline Layout::Builder &Layout::Builder::setNeedBindToEo(const bool value)
-       {
-               m_needBindToEo = value;
-               return *this;
-       }
-
-       // Layout //
-
-       inline Layout::Layout(Evas_Object *const eo, const bool isOwner) :
-               EdjeWidget(nullptr, eo, isOwner)
-       {
-       }
-
-       inline bool Layout::setTheme(const LayoutTheme &theme)
-       {
-               return elm_layout_theme_set(getEo(),
-                               theme.klass, theme.group, theme.style);
-       }
-
-       inline bool Layout::setEdjeFile(const std::string &filePath,
-                       const EdjeGroup group)
-       {
-               return elm_layout_file_set(getEo(), filePath.c_str(), group.name);
-       }
-
-       inline Variant Layout::getData(EdjeDataKey key)
-       {
-               return elm_layout_data_get(getEo(), key);
-       }
-}
diff --git a/ucl/inc/ucl/gui/NaviItem.h b/ucl/inc/ucl/gui/NaviItem.h
deleted file mode 100644 (file)
index 1161847..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_NAVI_ITEM_H__
-#define __UCL_GUI_NAVI_ITEM_H__
-
-#include "WidgetItem.h"
-
-namespace ucl {
-
-       class NaviItem final : public WidgetItem {
-       public:
-               using PopHandler = Delegate<Eina_Bool(Elm_Object_Item *)>;
-
-       public:
-               using WidgetItem::WidgetItem;
-
-               void setPopHandler(const PopHandler &handler) const;
-
-               void popTo() const;
-               void promote() const;
-
-               void setTitleEnabled(bool value, bool useTransition = false) const;
-               bool isTitleEnabled() const;
-
-               void setTitle(const TString &title) const;
-       };
-}
-
-#include "NaviItem.hpp"
-
-#endif // __UCL_GUI_NAVI_ITEM_H__
diff --git a/ucl/inc/ucl/gui/NaviItem.hpp b/ucl/inc/ucl/gui/NaviItem.hpp
deleted file mode 100644 (file)
index 6b33fe4..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline void NaviItem::setPopHandler(const PopHandler &handler) const
-       {
-               elm_naviframe_item_pop_cb_set(getIt(),
-                               handler.getStubA(), handler.getData());
-       }
-
-       inline void NaviItem::setTitleEnabled(
-                       const bool value, const bool useTransition) const
-       {
-               elm_naviframe_item_title_enabled_set(getIt(),
-                               toEina(value), toEina(useTransition));
-       }
-
-       inline bool NaviItem::isTitleEnabled() const
-       {
-               return elm_naviframe_item_title_enabled_get(getIt());
-       }
-
-       inline void NaviItem::setTitle(const TString &title) const
-       {
-               if (isEmpty(title)) {
-                       setTitleEnabled(false);
-               } else {
-                       setText(title);
-                       setTitleEnabled(true);
-               }
-       }
-}
diff --git a/ucl/inc/ucl/gui/Naviframe.h b/ucl/inc/ucl/gui/Naviframe.h
deleted file mode 100644 (file)
index 66693f2..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_NAVIFRAME_H__
-#define __UCL_GUI_NAVIFRAME_H__
-
-#include <vector>
-
-#include "StyledWidget.h"
-#include "NaviItem.h"
-
-namespace ucl {
-
-       constexpr SmartEvent NAVI_TRANSITION_STARTED {"ucl,transition,started"};
-       constexpr SmartEvent NAVI_TRANSITION_FINISHED {"transition,finished"};
-
-       UCL_DECLARE_REF_ALIASES(Naviframe);
-
-       class Naviframe final : public StyledWidget {
-       public:
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setStyle(ElmStyle value);
-                       Builder &setNeedBindToEo(bool value);
-                       NaviframeSRef build(ElmWidget &parent) const;
-               private:
-                       ElmStyle m_style;
-                       bool m_needBindToEo;
-               };
-
-       public:
-               void setInTransition(bool inTransition);
-               bool isInTransition() const;
-
-               void setAutoBackBtn(bool value);
-               bool isAutoBackBtn() const;
-
-               void setPreservePop(bool value);
-               bool isPreservePop() const;
-
-               void setEventsEnabledOnTransition(bool value);
-               bool isEventsEnabledOnTransition() const;
-
-               Evas_Object *pop();
-
-               NaviItem push(const TString &title,
-                               Evas_Object *backBtn, Evas_Object *moreBtn,
-                               Evas_Object *content, ElmStyle style = nullptr);
-               NaviItem push(const TString &title,
-                               Evas_Object *content, ElmStyle style = nullptr);
-               NaviItem push(Evas_Object *content, ElmStyle style = nullptr);
-
-               NaviItem insertAfter(NaviItem after, const TString &title,
-                               Evas_Object *backBtn, Evas_Object *moreBtn,
-                               Evas_Object *content, ElmStyle style = nullptr);
-               NaviItem insertAfter(NaviItem after, const TString &title,
-                               Evas_Object *content, ElmStyle style = nullptr);
-               NaviItem insertAfter(NaviItem after,
-                               Evas_Object *content, ElmStyle style = nullptr);
-
-               NaviItem insertBefore(NaviItem before, const TString &title,
-                               Evas_Object *backBtn, Evas_Object *moreBtn,
-                               Evas_Object *content, ElmStyle style = nullptr);
-               NaviItem insertBefore(NaviItem before, const TString &title,
-                               Evas_Object *content, ElmStyle style = nullptr);
-               NaviItem insertBefore(NaviItem before,
-                               Evas_Object *content, ElmStyle style = nullptr);
-
-               NaviItem getTopItem()const;
-               NaviItem getBottomItem() const;
-               std::vector<NaviItem> getItems() const;
-
-       private:
-               friend class ReffedObj<Naviframe>;
-               Naviframe(IRefCountObj &rc, Evas_Object *eo);
-
-               void onTransitionFinished(Widget &widget, void *eventInfo);
-
-       private:
-               bool m_isInTransition;
-       };
-}
-
-#include "Naviframe.hpp"
-
-#endif // __UCL_GUI_NAVIFRAME_H__
diff --git a/ucl/inc/ucl/gui/Naviframe.hpp b/ucl/inc/ucl/gui/Naviframe.hpp
deleted file mode 100644 (file)
index e8fdc19..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       // Naviframe::Builder //
-
-       inline Naviframe::Builder::Builder() :
-               m_needBindToEo(true)
-       {
-       }
-
-       inline Naviframe::Builder &Naviframe::Builder::setStyle(
-                       const ElmStyle value)
-       {
-               m_style = value;
-               return *this;
-       }
-
-       inline Naviframe::Builder &Naviframe::Builder::setNeedBindToEo(
-                       const bool value)
-       {
-               m_needBindToEo = value;
-               return *this;
-       }
-
-       // Naviframe //
-
-       inline bool Naviframe::isInTransition() const
-       {
-               return m_isInTransition;
-       }
-
-       inline void Naviframe::setAutoBackBtn(const bool value)
-       {
-               elm_naviframe_prev_btn_auto_pushed_set(getEo(), toEina(value));
-       }
-
-       inline bool Naviframe::isAutoBackBtn() const
-       {
-               return elm_naviframe_prev_btn_auto_pushed_get(getEo());
-       }
-
-       inline void Naviframe::setPreservePop(const bool value)
-       {
-               elm_naviframe_content_preserve_on_pop_set(getEo(), toEina(value));
-       }
-
-       inline bool Naviframe::isPreservePop() const
-       {
-               return elm_naviframe_content_preserve_on_pop_get(getEo());
-       }
-
-       inline void Naviframe::setEventsEnabledOnTransition(const bool value)
-       {
-               elm_naviframe_event_enabled_set(getEo(), toEina(value));
-       }
-
-       inline bool Naviframe::isEventsEnabledOnTransition() const
-       {
-               return elm_naviframe_event_enabled_get(getEo());
-       }
-
-       inline Evas_Object *Naviframe::pop()
-       {
-               auto result = elm_naviframe_item_pop(getEo());
-               if (getBottomItem()) {
-                       setInTransition(true);
-               }
-               return result;
-       }
-
-       inline NaviItem Naviframe::push(const TString &title,
-                       Evas_Object *const backBtn, Evas_Object *const moreBtn,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               auto result = NaviItem(elm_naviframe_item_push(getEo(),
-                               nullptr, backBtn, moreBtn, content, style.name));
-               result.setTitle(title);
-               if (result != getBottomItem()) {
-                       setInTransition(true);
-               }
-               return result;
-       }
-
-       inline NaviItem Naviframe::push(const TString &title,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               return push(title, nullptr, nullptr, content, style);
-       }
-
-       inline NaviItem Naviframe::push(
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               return push(nullptr, nullptr, nullptr, content, style);
-       }
-
-       inline NaviItem Naviframe::insertAfter(NaviItem after,
-                       const TString &title,
-                       Evas_Object *const backBtn, Evas_Object *const moreBtn,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               auto result = NaviItem(elm_naviframe_item_insert_after(getEo(),
-                               after, nullptr, backBtn, moreBtn, content, style.name));
-               result.setTitle(title);
-               return result;
-       }
-
-       inline NaviItem Naviframe::insertAfter(NaviItem after,
-                       const TString &title,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               return insertAfter(after, title, nullptr, nullptr, content, style);
-       }
-
-       inline NaviItem Naviframe::insertAfter(NaviItem after,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               return insertAfter(after, nullptr, nullptr, nullptr, content, style);
-       }
-
-       inline NaviItem Naviframe::insertBefore(NaviItem before,
-                       const TString &title,
-                       Evas_Object *const backBtn, Evas_Object *const moreBtn,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               auto result = NaviItem(elm_naviframe_item_insert_before(getEo(),
-                               before, nullptr, backBtn, moreBtn, content, style.name));
-               result.setTitle(title);
-               return result;
-       }
-
-       inline NaviItem Naviframe::insertBefore(NaviItem before,
-                       const TString &title,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               return insertAfter(before, title, nullptr, nullptr, content, style);
-       }
-
-       inline NaviItem Naviframe::insertBefore(NaviItem before,
-                       Evas_Object *const content, const ElmStyle style)
-       {
-               return insertAfter(before, nullptr, nullptr, nullptr, content, style);
-       }
-
-       inline NaviItem Naviframe::getTopItem()const
-       {
-               return NaviItem(elm_naviframe_top_item_get(getEo()));
-       }
-
-       inline NaviItem Naviframe::getBottomItem() const
-       {
-               return NaviItem(elm_naviframe_bottom_item_get(getEo()));
-       }
-
-       inline std::vector<NaviItem> Naviframe::getItems() const
-       {
-               std::vector<NaviItem> result;
-
-               Eina_List *const items = elm_naviframe_items_get(getEo());
-               Eina_List *l = nullptr;
-               void *data = nullptr;
-
-               EINA_LIST_FOREACH(items, l, data) {
-                       result.emplace_back(static_cast<Elm_Object_Item *>(data));
-               }
-
-               eina_list_free(items);
-
-               return result;
-       }
-}
diff --git a/ucl/inc/ucl/gui/StyledWidget.h b/ucl/inc/ucl/gui/StyledWidget.h
deleted file mode 100644 (file)
index 223a293..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_STYLED_WIDGET_H__
-#define __UCL_GUI_STYLED_WIDGET_H__
-
-#include "EdjeWidget.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(StyledWidget);
-
-       class StyledWidget : public EdjeWidget {
-       public:
-               friend class ReffedObj<StyledWidget>;
-               using EdjeWidget::EdjeWidget;
-               explicit StyledWidget(Evas_Object *eo, bool isOwner = true);
-
-               void setStyle(ElmStyle style);
-       };
-}
-
-#include "StyledWidget.hpp"
-
-#endif // __UCL_GUI_STYLED_WIDGET_H__
diff --git a/ucl/inc/ucl/gui/StyledWidget.hpp b/ucl/inc/ucl/gui/StyledWidget.hpp
deleted file mode 100644 (file)
index cb32329..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline StyledWidget::StyledWidget(
-                       Evas_Object *const eo, const bool isOwner) :
-               EdjeWidget(nullptr, eo, isOwner)
-       {
-       }
-
-       inline void StyledWidget::setStyle(const ElmStyle style)
-       {
-               elm_object_style_set(getEo(), style.name);
-       }
-}
diff --git a/ucl/inc/ucl/gui/Theme.h b/ucl/inc/ucl/gui/Theme.h
deleted file mode 100644 (file)
index d8b5b31..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_THEME_H__
-#define __UCL_GUI_THEME_H__
-
-#include "types.h"
-
-namespace ucl {
-
-       class Theme final : NonCopyable {
-       public:
-               static Theme create();
-
-               friend void swap(Theme &x, Theme &y);
-
-       public:
-               Theme();
-               Theme(std::nullptr_t);
-               explicit Theme(Elm_Theme *th, bool isOwner = false);
-               Theme(Theme &&tmp);
-               Theme &operator=(Theme &&tmp);
-               ~Theme();
-
-               Elm_Theme *getTh();
-               const Elm_Theme *getTh() const;
-
-               operator Elm_Theme *();
-               operator const Elm_Theme *() const;
-
-               void addExtension(const std::string edjePath);
-               void addOverlay(const std::string edjePath);
-
-       private:
-               Elm_Theme *m_th;
-               bool m_isOwner;
-       };
-
-       // Non-member functions //
-
-       bool isValid(const Theme &item);
-}
-
-#include "Theme.hpp"
-
-#endif // __UCL_GUI_THEME_H__
diff --git a/ucl/inc/ucl/gui/Theme.hpp b/ucl/inc/ucl/gui/Theme.hpp
deleted file mode 100644 (file)
index 65910df..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline Theme Theme::create()
-       {
-               Elm_Theme *const th = elm_theme_new();
-               if (th) {
-                       elm_theme_ref_set(th, nullptr);
-               }
-               return Theme(th, true);
-       }
-
-       inline Theme::Theme() :
-               m_th(nullptr),
-               m_isOwner(false)
-       {
-       }
-
-       inline Theme::Theme(std::nullptr_t) :
-               Theme()
-       {
-       }
-
-       inline Theme::Theme(Elm_Theme *const th, const bool isOwner) :
-               m_th(th),
-               m_isOwner(isOwner)
-       {
-       }
-
-       inline Theme::Theme(Theme &&tmp)
-       {
-               m_th = tmp.m_th;
-               tmp.m_th = nullptr;
-       }
-
-       inline Theme &Theme::operator=(Theme &&tmp)
-       {
-               swap(*this, tmp);
-               return *this;
-       }
-
-       inline Theme::~Theme()
-       {
-               if (m_isOwner && m_th) {
-                       elm_theme_free(m_th);
-               }
-       }
-
-       inline Elm_Theme *Theme::getTh()
-       {
-               return m_th;
-       }
-
-       inline const Elm_Theme *Theme::getTh() const
-       {
-               return m_th;
-       }
-
-       inline Theme::operator Elm_Theme *()
-       {
-               return getTh();
-       }
-
-       inline Theme::operator const Elm_Theme *() const
-       {
-               return getTh();
-       }
-
-       inline void Theme::addExtension(const std::string edjePath)
-       {
-               elm_theme_extension_add(getTh(), edjePath.c_str());
-       }
-
-       inline void Theme::addOverlay(const std::string edjePath)
-       {
-               elm_theme_overlay_add(getTh(), edjePath.c_str());
-       }
-
-       // Non-member functions //
-
-       inline bool isValid(const Theme &item)
-       {
-               return !!item.getTh();
-       }
-
-       inline void swap(Theme &x, Theme &y)
-       {
-               std::swap(x.m_th, y.m_th);
-               std::swap(x.m_isOwner, y.m_isOwner);
-       }
-}
diff --git a/ucl/inc/ucl/gui/Widget.h b/ucl/inc/ucl/gui/Widget.h
deleted file mode 100644 (file)
index ac47866..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_WIDGET_H__
-#define __UCL_GUI_WIDGET_H__
-
-#include <list>
-
-#include "types.h"
-
-#include "ucl/misc/RefCountAware.h"
-
-#define UCL_SMART_FWD "ucl,fwd,"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(Widget);
-
-       class Widget : public RefCountAware {
-       public:
-               static constexpr auto EXPAND = EVAS_HINT_EXPAND;
-               static constexpr auto FILL = EVAS_HINT_FILL;
-
-       public:
-               explicit Widget(Evas_Object *eo, bool isOwner = true);
-               virtual ~Widget();
-
-               void bindToEo();
-               void unbindFromEo();
-
-               void setIsOwner(bool value);
-
-               Evas_Object *getEo();
-               const Evas_Object *getEo() const;
-
-               operator Evas_Object *();
-               operator const Evas_Object *() const;
-
-               Evas *getEvas() const;
-
-               void setData(EoDataKey key, void *data);
-               void delData(EoDataKey key);
-               void *getData(EoDataKey key) const;
-
-               void addEventHandler(WidgetEvent event, WidgetEventHandler handler);
-               void addEventHandler(SmartEvent event, WidgetEventHandler handler);
-
-               void delEventHandler(WidgetEvent event, WidgetEventHandler handler);
-               void delEventHandler(SmartEvent event, WidgetEventHandler handler);
-
-               void callEvent(SmartEvent event, void *eventInfo = nullptr);
-
-               void markForDeletion();
-
-               void setVisible(bool value);
-               bool isVisible() const;
-
-               void setColor(int r, int g, int b, int a = 255);
-               void setColor(int l, int a = 255);
-               void getColor(int &r, int &g, int &b, int &a) const;
-
-               void calculate();
-
-               void setGeometry(int x, int y, int w, int h);
-               void move(int x, int y);
-               void resize(int w, int h);
-
-               void getGeometry(int *x, int *y, int *w, int *h) const;
-
-               void setWeight(double w, double h);
-               void setAlign(double w, double h);
-               void setMin(int w, int h);
-               void setMax(int w, int h);
-
-               void getWeight(double *w, double *h) const;
-               void getAlign(double *w, double *h) const;
-               void getMin(int *w, int *h) const;
-               void getMax(int *w, int *h) const;
-
-               void setARHint(WidgetARHint arControl, int w, int h);
-               void getARHint(WidgetARHint &arControl, int &w, int &h);
-
-               void setFocused(bool value);
-               bool isFocused() const;
-
-       protected:
-               friend class ReffedObj<Widget>;
-               Widget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
-
-               virtual void setFocusedImpl(bool value);
-               virtual bool isFocusedImpl() const;
-               virtual bool ensureFwdEvent(SmartEvent fwdEvent);
-
-       private:
-               class EventProxy;
-               using EventProxies = std::list<EventProxy>;
-               using EventProxiesIt = EventProxies::iterator;
-
-       private:
-               void updateRefs();
-
-               void updateEoRef();
-               bool needKeepEoRef() const;
-               void updateSelfRef();
-               bool needKeepSelfRef() const;
-
-               void setSelfRefUnique(const bool value);
-
-               void onEoDel(Evas *e, Evas_Object *obj, void *event_info);
-
-               void delEventProxy(const EventProxiesIt it);
-
-       public:
-               // This section MUST be public!
-               // Signal to RefCountObj<T, C> to call onUniqueChanged()
-               enum { _ENABLE_ON_UNIQUE_CHANGED_DISPATCH };
-
-       protected:
-               // This section MAY be protected
-               void onUniqueChanged(bool isUnique);
-
-       private:
-               Evas_Object *m_eo;
-               EventProxies m_eventProxies;
-               WidgetSRef m_selfRef;
-               bool m_isOwner;
-               bool m_isBoundToEo;
-               bool m_isEoRefKept;
-               bool m_isSelfRefUnique;
-       };
-
-       // Non-member functions //
-
-       void getPosition(const Widget &widget, int *x, int *y);
-       void getSize(const Widget &widget, int *w, int *h);
-
-       void show(Widget &widget);
-       void hide(Widget &widget);
-
-       void makeTransparent(Widget &widget);
-       void makeWhite(Widget &widget);
-
-       void focus(Widget &widget);
-       void unfocus(Widget &widget);
-
-       void expand(Widget &widget);
-       void fill(Widget &widget);
-       void expandAndFill(Widget &widget);
-
-       bool operator==(const Widget &lhs, const Widget &rhs);
-       bool operator!=(const Widget &lhs, const Widget &rhs);
-}
-
-#include "Widget.hpp"
-
-#endif // __UCL_GUI_WIDGET_H__
diff --git a/ucl/inc/ucl/gui/Widget.hpp b/ucl/inc/ucl/gui/Widget.hpp
deleted file mode 100644 (file)
index 95da66a..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl { namespace { namespace impl {
-
-       constexpr auto WIDGET_DATA_NAME = "__WIDGET_DATA_NAME__";
-}}}
-
-namespace ucl {
-
-       inline Widget::Widget(Evas_Object *const eo, const bool isOwner) :
-               Widget(nullptr, eo, isOwner)
-       {
-       }
-
-       inline void Widget::setIsOwner(const bool value)
-       {
-               if (value != m_isOwner) {
-                       m_isOwner = value;
-                       updateRefs();
-               }
-       }
-
-       inline Evas_Object *Widget::getEo()
-       {
-               return m_eo;
-       }
-
-       inline const Evas_Object *Widget::getEo() const
-       {
-               return m_eo;
-       }
-
-       inline Widget::operator Evas_Object *()
-       {
-               return getEo();
-       }
-
-       inline Widget::operator const Evas_Object *() const
-       {
-               return getEo();
-       }
-
-       inline Evas *Widget::getEvas() const
-       {
-               return evas_object_evas_get(getEo());
-       }
-
-       inline void Widget::setData(const EoDataKey key, void *const data)
-       {
-               evas_object_data_set(getEo(), key.name, data);
-       }
-
-       inline void Widget::delData(const EoDataKey key)
-       {
-               evas_object_data_del(getEo(), key.name);
-       }
-
-       inline void *Widget::getData(const EoDataKey key) const
-       {
-               return evas_object_data_get(getEo(), key.name);
-       }
-
-       inline void Widget::callEvent(SmartEvent event, void *eventInfo)
-       {
-               evas_object_smart_callback_call(getEo(), event, eventInfo);
-       }
-
-       inline void Widget::markForDeletion()
-       {
-               evas_object_del(getEo());
-       }
-
-       inline void Widget::setVisible(bool value)
-       {
-               if (value) {
-                       evas_object_show(getEo());
-               } else {
-                       evas_object_hide(getEo());
-               }
-       }
-
-       inline bool Widget::isVisible() const
-       {
-               return evas_object_visible_get(getEo());
-       }
-
-       inline void Widget::setColor(const int r, const int g,
-                       const int b, const int a)
-       {
-               evas_object_color_set(getEo(), r, g, b, a);
-       }
-
-       inline void Widget::setColor(const int l, const int a)
-       {
-               evas_object_color_set(getEo(), l, l, l, a);
-       }
-
-       inline void Widget::getColor(int &r, int &g, int &b, int &a) const
-       {
-               evas_object_color_get(getEo(), &r, &g, &b, &a);
-       }
-
-       inline void Widget::calculate()
-       {
-               evas_object_smart_calculate(getEo());
-       }
-
-       inline void Widget::setGeometry(const int x, const int y,
-                       const int w, const int h)
-       {
-               evas_object_geometry_set(getEo(), x, y, w, h);
-       }
-
-       inline void Widget::move(const int x, const int y)
-       {
-               evas_object_move(getEo(), x, y);
-       }
-
-       inline void Widget::resize(const int w, const int h)
-       {
-               evas_object_resize(getEo(), w, h);
-       }
-
-       inline void Widget::getGeometry(int *const x, int *const y,
-                       int *const w, int *const h) const
-       {
-               evas_object_geometry_get(getEo(), x, y, w, h);
-       }
-
-       inline void Widget::setWeight(const double w, const double h)
-       {
-               evas_object_size_hint_weight_set(getEo(), w, h);
-       }
-
-       inline void Widget::setAlign(const double w, const double h)
-       {
-               evas_object_size_hint_align_set(getEo(), w, h);
-       }
-
-       inline void Widget::setMin(const int w, const int h)
-       {
-               evas_object_size_hint_min_set(getEo(), w, h);
-       }
-
-       inline void Widget::setMax(const int w, const int h)
-       {
-               evas_object_size_hint_max_set(getEo(), w, h);
-       }
-
-       inline void Widget::getWeight(double *const w, double *const h) const
-       {
-               evas_object_size_hint_weight_get(getEo(), w, h);
-       }
-
-       inline void Widget::getAlign(double *const w, double *const h) const
-       {
-               evas_object_size_hint_align_get(getEo(), w, h);
-       }
-
-       inline void Widget::getMin(int *const w, int *const h) const
-       {
-               evas_object_size_hint_min_get(getEo(), w, h);
-       }
-
-       inline void Widget::getMax(int *const w, int *const h) const
-       {
-               evas_object_size_hint_max_get(getEo(), w, h);
-       }
-
-       inline void Widget::setARHint(WidgetARHint arControl, int w, int h)
-       {
-               evas_object_size_hint_aspect_set(getEo(),
-                               static_cast<Evas_Aspect_Control>(arControl), w, h);
-       }
-
-       inline void Widget::getARHint(WidgetARHint &arControl, int &w, int &h)
-       {
-               Evas_Aspect_Control tmp = EVAS_ASPECT_CONTROL_NEITHER;
-               evas_object_size_hint_aspect_get(getEo(), &tmp, &w, &h);
-               arControl = static_cast<WidgetARHint>(tmp);
-       }
-
-       inline void Widget::setFocused(const bool value)
-       {
-               setFocusedImpl(value);
-       }
-
-       inline bool Widget::isFocused() const
-       {
-               return isFocusedImpl();
-       }
-
-       // Non-member functions //
-
-       inline void getPosition(const Widget &widget, int *x, int *y)
-       {
-               widget.getGeometry(x, y, nullptr, nullptr);
-       }
-
-       inline void getSize(const Widget &widget, int *w, int *h)
-       {
-               widget.getGeometry(nullptr, nullptr, w, h);
-       }
-
-       inline void show(Widget &widget)
-       {
-               widget.setVisible(true);
-       }
-
-       inline void hide(Widget &widget)
-       {
-               widget.setVisible(false);
-       }
-
-       inline void makeTransparent(Widget &widget)
-       {
-               widget.setColor(0, 0);
-       }
-
-       inline void makeWhite(Widget &widget)
-       {
-               widget.setColor(255);
-       }
-
-       inline void focus(Widget &widget)
-       {
-               widget.setFocused(true);
-       }
-
-       inline void unfocus(Widget &widget)
-       {
-               widget.setFocused(false);
-       }
-
-       inline void expand(Widget &widget)
-       {
-               widget.setWeight(Widget::EXPAND, Widget::EXPAND);
-       }
-
-       inline void fill(Widget &widget)
-       {
-               widget.setAlign(Widget::FILL, Widget::FILL);
-       }
-
-       inline void expandAndFill(Widget &widget)
-       {
-               expand(widget);
-               fill(widget);
-       }
-
-       inline bool operator==(const Widget &lhs, const Widget &rhs)
-       {
-               return (lhs.getEo() == rhs.getEo());
-       }
-
-       inline bool operator!=(const Widget &lhs, const Widget &rhs)
-       {
-               return (lhs.getEo() != rhs.getEo());
-       }
-}
diff --git a/ucl/inc/ucl/gui/WidgetItem.h b/ucl/inc/ucl/gui/WidgetItem.h
deleted file mode 100644 (file)
index 7794444..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_WIDGET_ITEM_H__
-#define __UCL_GUI_WIDGET_ITEM_H__
-
-#include "Widget.h"
-
-namespace ucl {
-
-       class WidgetItem {
-       public:
-               constexpr WidgetItem();
-               constexpr WidgetItem(std::nullptr_t);
-               explicit WidgetItem(Elm_Object_Item *it);
-
-               Elm_Object_Item *getIt() const;
-
-               operator Elm_Object_Item *() const;
-               operator bool() const;
-
-               Evas_Object *getWidget() const;
-
-               void setDelCallback(Evas_Smart_Cb cb) const;
-
-               void del();
-
-               void setData(void *data) const;
-               void *getData() const;
-
-               void setEnabled(bool value) const;
-               bool isEnabled() const;
-
-               void setStyle(ElmStyle style) const;
-
-               void setText(const TString &value) const;
-               void setText(const TString &value, EdjePart part) const;
-
-               TString getText() const;
-               TString getText(EdjePart part) const;
-
-               void setContent(Evas_Object *content) const;
-               void setContent(Evas_Object *content, EdjePart part) const;
-               Evas_Object *unsetContent() const;
-               Evas_Object *unsetContent(EdjePart part) const;
-
-               Evas_Object *getContent() const;
-               Evas_Object *getContent(EdjePart part) const;
-
-               void emit(EdjeSignal signal,EdjeSignalSrc source =
-                               EdjeSignalSrc("")) const;
-
-       private:
-               Elm_Object_Item *m_it;
-       };
-
-       // Non-member functions //
-
-       void enable(WidgetItem item);
-       void disable(WidgetItem item);
-
-       bool operator==(WidgetItem lhs, WidgetItem rhs);
-       bool operator!=(WidgetItem lhs, WidgetItem rhs);
-}
-
-#include "WidgetItem.hpp"
-
-#endif // __UCL_GUI_WIDGET_ITEM_H__
diff --git a/ucl/inc/ucl/gui/WidgetItem.hpp b/ucl/inc/ucl/gui/WidgetItem.hpp
deleted file mode 100644 (file)
index 26b6cbd..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       constexpr WidgetItem::WidgetItem() :
-               m_it(nullptr)
-       {
-       }
-
-       constexpr WidgetItem::WidgetItem(std::nullptr_t) :
-               WidgetItem()
-       {
-       }
-
-       inline WidgetItem::WidgetItem(Elm_Object_Item *const it) :
-               m_it(it)
-       {
-       }
-
-       inline Elm_Object_Item *WidgetItem::getIt() const
-       {
-               return m_it;
-       }
-
-       inline WidgetItem::operator Elm_Object_Item *() const
-       {
-               return m_it;
-       }
-
-       inline WidgetItem::operator bool() const
-       {
-               return !!m_it;
-       }
-
-       inline Evas_Object *WidgetItem::getWidget() const
-       {
-               return elm_object_item_widget_get(getIt());
-       }
-
-       inline void WidgetItem::setDelCallback(const Evas_Smart_Cb cb) const
-       {
-               elm_object_item_del_cb_set(getIt(), cb);
-       }
-
-       inline void WidgetItem::del()
-       {
-               elm_object_item_del(m_it);
-               m_it = nullptr;
-       }
-
-       inline void WidgetItem::setData(void *const data) const
-       {
-               elm_object_item_data_set(getIt(), data);
-       }
-
-       inline void *WidgetItem::getData() const
-       {
-               return elm_object_item_data_get(getIt());
-       }
-
-       inline void WidgetItem::setEnabled(const bool value) const
-       {
-               elm_object_item_disabled_set(getIt(), toEina(!value));
-       }
-
-       inline bool WidgetItem::isEnabled() const
-       {
-               return (elm_object_item_disabled_get(getIt()) ? false : true);
-       }
-
-       inline void WidgetItem::setStyle(const ElmStyle style) const
-       {
-               elm_object_item_style_set(getIt(), style.name);
-       }
-
-       inline TString WidgetItem::getText() const
-       {
-               return elm_object_item_text_get(getIt());
-       }
-
-       inline TString WidgetItem::getText(const EdjePart part) const
-       {
-               return elm_object_item_part_text_get(getIt(), part.name);
-       }
-
-       inline void WidgetItem::setContent(Evas_Object *const content) const
-       {
-               elm_object_item_content_set(getIt(), content);
-       }
-
-       inline void WidgetItem::setContent(Evas_Object *const content,
-                       const EdjePart part) const
-       {
-               elm_object_item_part_content_set(getIt(), part.name, content);
-       }
-
-       inline Evas_Object *WidgetItem::unsetContent() const
-       {
-               return elm_object_item_content_unset(getIt());
-       }
-
-       inline Evas_Object *WidgetItem::unsetContent(const EdjePart part) const
-       {
-               return elm_object_item_part_content_unset(getIt(), part.name);
-       }
-
-       inline Evas_Object *WidgetItem::getContent() const
-       {
-               return elm_object_item_content_get(getIt());
-       }
-
-       inline Evas_Object *WidgetItem::getContent(const EdjePart part) const
-       {
-               return elm_object_item_part_content_get(getIt(), part.name);
-       }
-
-       inline void WidgetItem::emit(const EdjeSignal signal,
-                       const EdjeSignalSrc source) const
-       {
-               elm_object_item_signal_emit(getIt(), signal.name, source.name);
-       }
-
-       // Non-member functions //
-
-       inline void enable(const WidgetItem item)
-       {
-               item.setEnabled(true);
-       }
-
-       inline void disable(const WidgetItem item)
-       {
-               item.setEnabled(false);
-       }
-
-       inline bool operator==(const WidgetItem lhs, const WidgetItem rhs)
-       {
-               return (lhs.getIt() == rhs.getIt());
-       }
-
-       inline bool operator!=(const WidgetItem lhs, const WidgetItem rhs)
-       {
-               return (lhs.getIt() != rhs.getIt());
-       }
-}
diff --git a/ucl/inc/ucl/gui/Window.h b/ucl/inc/ucl/gui/Window.h
deleted file mode 100644 (file)
index 9aa598d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_WINDOW_H__
-#define __UCL_GUI_WINDOW_H__
-
-#include <vector>
-
-#include "StyledWidget.h"
-
-namespace ucl {
-
-       constexpr SmartEvent WIN_ROTATION_CHANGED {"wm,rotation,changed"};
-
-       UCL_DECLARE_REF_ALIASES(Window);
-
-       class Window final : public ElmWidget {
-       public:
-               enum class Type {
-                       BASIC = ELM_WIN_BASIC
-               };
-
-               class Builder final {
-               public:
-                       Builder();
-
-                       Builder &setWinEo(Evas_Object *value);
-
-                       Builder &setType(Type type);
-                       Builder &setName(std::string value);
-
-                       Builder &setTitle(std::string value);
-                       Builder &setSetIndicatorVisible(bool value);
-                       Builder &setRotations(std::vector<int> value);
-
-                       Builder &setIsOwner(bool value);
-                       Builder &setNeedBindToEo(bool value);
-
-                       WindowSRef build() const;
-               private:
-                       std::string m_name;
-                       std::string m_title;
-                       std::vector<int> m_rotations;
-                       Evas_Object *m_winEo;
-                       Type m_type;
-                       bool m_isIndicatorVisible;
-                       bool m_isOwner;
-                       bool m_isOwnerWasSet;
-                       bool m_needBindToEo;
-               };
-
-       public:
-               StyledWidget &getConformant();
-               const StyledWidget &getConformant() const;
-
-               void getScreenSize(int *w, int *h) const;
-
-               void setTitle(const std::string &title);
-               std::string getTitle() const;
-
-               void setIndicatorVisible(bool value);
-               bool isIndicatorVisible() const;
-
-               bool isRotationsSupported() const;
-               void setRotations(const std::vector<int> &value);
-
-               void lower();
-
-       private:
-               friend class ReffedObj<Window>;
-               Window(IRefCountObj *rc, Evas_Object *eo,
-                               bool isOwner, Evas_Object *conform);
-
-       private:
-               StyledWidget m_conform;
-       };
-
-       // Non-member functions //
-
-       // Window //
-
-       void showIndicator(Window &win);
-       void hideIndicator(Window &win);
-
-       // Window::Type //
-
-       bool isValid(Window::Type winType);
-}
-
-#include "Window.hpp"
-
-#endif // __UCL_GUI_WINDOW_H__
diff --git a/ucl/inc/ucl/gui/Window.hpp b/ucl/inc/ucl/gui/Window.hpp
deleted file mode 100644 (file)
index d5b1828..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <algorithm>
-
-namespace ucl {
-
-       // Window::Builder //
-
-       inline Window::Builder::Builder() :
-               m_rotations({0}),
-               m_winEo(nullptr),
-               m_type(Type::BASIC),
-               m_isIndicatorVisible(false),
-               m_isOwner(false),
-               m_isOwnerWasSet(false),
-               m_needBindToEo(true)
-       {
-       }
-
-       inline Window::Builder &Window::Builder::setWinEo(Evas_Object *const value)
-       {
-               m_winEo = value;
-               return *this;
-       }
-
-       inline Window::Builder &Window::Builder::setType(const Type type)
-       {
-               m_type = type;
-               return *this;
-       }
-
-       inline Window::Builder &Window::Builder::setName(std::string value)
-       {
-               m_name = std::move(value);
-               return *this;
-       }
-
-       inline Window::Builder &Window::Builder::setTitle(std::string value)
-       {
-               m_title = std::move(value);
-               return *this;
-       }
-
-       inline Window::Builder &Window::Builder::setSetIndicatorVisible(
-                       const bool value)
-       {
-               m_isIndicatorVisible = value;
-               return *this;
-       }
-
-       inline Window::Builder &Window::Builder::setRotations(
-                       std::vector<int> value)
-       {
-               m_rotations = std::move(value);
-               return *this;
-       }
-
-       inline Window::Builder &Window::Builder::setIsOwner(const bool value)
-       {
-               m_isOwner = value;
-               m_isOwnerWasSet = true;
-               return *this;
-       }
-
-       inline Window::Builder &Window::Builder::setNeedBindToEo(const bool value)
-       {
-               m_needBindToEo = value;
-               return *this;
-       }
-
-       // Window //
-
-       inline Window::Window(IRefCountObj *const rc, Evas_Object *const eo,
-                       const bool isOwner, Evas_Object *const conform) :
-               ElmWidget(rc, eo, isOwner),
-               m_conform(conform)
-       {
-       }
-
-       inline StyledWidget &Window::getConformant()
-       {
-               return m_conform;
-       }
-
-       inline const StyledWidget &Window::getConformant() const
-       {
-               return m_conform;
-       }
-
-       inline void Window::getScreenSize(int *const w, int *const h) const
-       {
-               elm_win_screen_size_get(getEo(), nullptr, nullptr, w, h);
-       }
-
-       inline void Window::setTitle(const std::string &title)
-       {
-               elm_win_title_set(getEo(), title.c_str());
-       }
-
-       inline std::string Window::getTitle() const
-       {
-               return nz(elm_win_title_get(getEo()));
-       }
-
-       inline void Window::setIndicatorVisible(bool value)
-       {
-               if (value) {
-                       elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_SHOW);
-               } else {
-                       elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_HIDE);
-               }
-       }
-
-       inline bool Window::isIndicatorVisible() const
-       {
-               return (elm_win_indicator_mode_get(getEo()) == ELM_WIN_INDICATOR_SHOW);
-       }
-
-       inline bool Window::isRotationsSupported() const
-       {
-               return elm_win_wm_rotation_supported_get(getEo());
-       }
-
-       inline void Window::setRotations(const std::vector<int> &value)
-       {
-               elm_win_wm_rotation_available_rotations_set(getEo(),
-                               value.data(), value.size());
-       }
-
-       inline void Window::lower()
-       {
-               elm_win_lower(getEo());
-       }
-
-       // Non-member functions //
-
-       // Window //
-
-       inline void showIndicator(Window &win)
-       {
-               win.setIndicatorVisible(true);
-       }
-
-       inline void hideIndicator(Window &win)
-       {
-               win.setIndicatorVisible(false);
-       }
-
-       // Window::Type //
-
-       inline bool isValid(Window::Type winType)
-       {
-               switch (winType) {
-               case Window::Type::BASIC:
-                       return true;
-               }
-               return false;
-       }
-}
diff --git a/ucl/inc/ucl/gui/helpers.h b/ucl/inc/ucl/gui/helpers.h
deleted file mode 100644 (file)
index d42eccb..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_HELPERS_H__
-#define __UCL_GUI_HELPERS_H__
-
-#include "Widget.h"
-
-namespace ucl {
-
-       // Converts Evas_Object to Widget pointer //
-
-       Widget *asWidget(Evas_Object *eo);
-       const Widget *asWidget(const Evas_Object *eo);
-
-       // Widget casting functions from Evas_Object //
-
-       template <class WIDGET_TYPE>
-       inline auto staticWidgetCast(Evas_Object *eo) ->
-                       decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
-       {
-               return static_cast<WIDGET_TYPE *>(asWidget(eo));
-       }
-
-       template <class WIDGET_TYPE>
-       inline auto staticWidgetCast(const Evas_Object *eo) ->
-                       decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
-       {
-               return static_cast<WIDGET_TYPE *>(asWidget(eo));
-       }
-
-       template <class WIDGET_TYPE>
-       inline auto dynamicWidgetCast(Evas_Object *eo) ->
-                       decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
-       {
-               return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
-       }
-
-       template <class WIDGET_TYPE>
-       inline auto dynamicWidgetCast(const Evas_Object *eo) ->
-                       decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
-       {
-               return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
-       }
-
-       template <class WIDGET_TYPE>
-       inline auto staticWidgetRefCast(Evas_Object *eo) ->
-                       decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
-       {
-               return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
-       }
-
-       template <class WIDGET_TYPE>
-       inline auto staticWidgetRefCast(const Evas_Object *eo) ->
-                       decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
-       {
-               return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
-       }
-
-       template <class WIDGET_TYPE>
-       inline auto dynamicWidgetRefCast(Evas_Object *eo) ->
-                       decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
-       {
-               return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
-       }
-
-       template <class WIDGET_TYPE>
-       inline auto dynamicWidgetRefCast(const Evas_Object *eo) ->
-                       decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
-       {
-               return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
-       }
-}
-
-#include "helpers.hpp"
-
-#endif // __UCL_GUI_HELPERS_H__
diff --git a/ucl/inc/ucl/gui/helpers.hpp b/ucl/inc/ucl/gui/helpers.hpp
deleted file mode 100644 (file)
index 29df283..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline Widget *asWidget(Evas_Object *eo)
-       {
-               return static_cast<Widget *>(
-                               evas_object_data_get(eo, impl::WIDGET_DATA_NAME));
-
-       }
-
-       inline const Widget *asWidget(const Evas_Object *eo)
-       {
-               return static_cast<const Widget *>(
-                               evas_object_data_get(eo, impl::WIDGET_DATA_NAME));
-       }
-}
diff --git a/ucl/inc/ucl/gui/stdTheme.h b/ucl/inc/ucl/gui/stdTheme.h
deleted file mode 100644 (file)
index 13202cc..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_STD_THEME_H__
-#define __UCL_GUI_STD_THEME_H__
-
-#include "stdTheme/common.h"
-#include "stdTheme/layout.h"
-#include "stdTheme/naviframe.h"
-
-#endif // __UCL_GUI_STD_THEME_H__
diff --git a/ucl/inc/ucl/gui/stdTheme/common.h b/ucl/inc/ucl/gui/stdTheme/common.h
deleted file mode 100644 (file)
index 7ec81b9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_STD_THEME_COMMON_H__
-#define __UCL_GUI_STD_THEME_COMMON_H__
-
-#include "ucl/gui/types.h"
-
-namespace ucl {
-
-       // Styles //
-
-       constexpr ElmStyle STYLE_DEFAULT {"default"};
-
-       // Parts //
-
-       constexpr EdjePart PART_TEXT  {"elm.text"};
-       constexpr EdjePart PART_TITLE {"elm.text.title"};
-
-       constexpr EdjePart PART_CONTENT {"elm.swallow.content"};
-       constexpr EdjePart PART_ICON    {"elm.swallow.icon"};
-       constexpr EdjePart PART_BUTTON  {"elm.swallow.button"};
-}
-
-#endif // __UCL_GUI_STD_THEME_COMMON_H__
diff --git a/ucl/inc/ucl/gui/stdTheme/layout.h b/ucl/inc/ucl/gui/stdTheme/layout.h
deleted file mode 100644 (file)
index 79ff426..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_STD_THEME_LAYOUT_H__
-#define __UCL_GUI_STD_THEME_LAYOUT_H__
-
-#include "common.h"
-
-namespace ucl {
-
-       constexpr LayoutTheme LAYOUT_DEFAULT {"layout", "application", "default"};
-
-       constexpr LayoutTheme LAYOUT_NO_CONTENTS
-                       {"layout", "nocontents", "default"};
-}
-
-#endif // __UCL_GUI_STD_THEME_LAYOUT_H__
diff --git a/ucl/inc/ucl/gui/stdTheme/naviframe.h b/ucl/inc/ucl/gui/stdTheme/naviframe.h
deleted file mode 100644 (file)
index fd99fdc..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_STD_THEME_NAVIFRAME_H__
-#define __UCL_GUI_STD_THEME_NAVIFRAME_H__
-
-#include "common.h"
-
-namespace ucl {
-
-       constexpr ElmStyle NAVIFRAME_EMPTY {"empty"};
-}
-
-#endif // __UCL_GUI_STD_THEME_NAVIFRAME_H__
diff --git a/ucl/inc/ucl/gui/types.h b/ucl/inc/ucl/gui/types.h
deleted file mode 100644 (file)
index 6d43d76..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_TYPES_H__
-#define __UCL_GUI_TYPES_H__
-
-#include <Elementary.h>
-
-#include "ucl/util/types.h"
-#include "ucl/util/memory.h"
-#include "ucl/util/delegation.h"
-#include "ucl/util/smartDelegation.h"
-
-#include "ucl/misc/Aspect.h"
-#include "ucl/misc/TString.h"
-#include "ucl/misc/ConstCString.h"
-#include "ucl/misc/Variant.h"
-
-namespace ucl {
-
-       // Aspects //
-
-       struct EdjePart : Aspect<EdjePart> { using Aspect::Aspect; };
-       struct EdjeGroup : Aspect<EdjeGroup> { using Aspect::Aspect; };
-       struct EdjeDataKey : Aspect<EdjeDataKey> { using Aspect::Aspect; };
-
-       struct EdjeSignal : Aspect<EdjeSignal> { using Aspect::Aspect; };
-       struct EdjeSignalSrc : Aspect<EdjeSignalSrc> { using Aspect::Aspect; };
-
-       struct ElmStyle : Aspect<ElmStyle> { using Aspect::Aspect; };
-
-       struct SmartEvent : Aspect<SmartEvent> { using Aspect::Aspect; };
-
-       struct EoDataKey : Aspect<EoDataKey> { using Aspect::Aspect; };
-
-       // Delegates //
-
-       using SmartCbHandler = Delegate<void(Evas_Object *obj, void *eventInfo)>;
-
-       // WidgetEventHandler //
-
-       class Widget;
-
-       using WidgetEventHandler =
-                       WeakDelegate<void(Widget &widget, void *eventInfo)>;
-
-       // WidgetEvent //
-
-       enum class WidgetEvent {
-               DEL  = EVAS_CALLBACK_DEL,
-
-               MOUSE_IN    = EVAS_CALLBACK_MOUSE_IN,
-               MOUSE_OUT   = EVAS_CALLBACK_MOUSE_OUT,
-               MOUSE_DOWN  = EVAS_CALLBACK_MOUSE_DOWN,
-               MOUSE_UP    = EVAS_CALLBACK_MOUSE_UP,
-               MOUSE_MOVE  = EVAS_CALLBACK_MOUSE_MOVE,
-               MOUSE_WHEEL = EVAS_CALLBACK_MOUSE_WHEEL,
-
-               MULTI_DOWN = EVAS_CALLBACK_MULTI_DOWN,
-               MULTI_UP   = EVAS_CALLBACK_MULTI_UP,
-               MULTI_MOVE = EVAS_CALLBACK_MULTI_MOVE,
-
-               MOVE    = EVAS_CALLBACK_MOVE,
-               RESIZE  = EVAS_CALLBACK_RESIZE,
-               RESTACK = EVAS_CALLBACK_RESTACK,
-
-               CHANGED_SIZE_HINTS = EVAS_CALLBACK_CHANGED_SIZE_HINTS,
-
-               KEY_DOWN  = EVAS_CALLBACK_KEY_DOWN,
-               KEY_UP    = EVAS_CALLBACK_KEY_UP,
-               FOCUS_IN  = EVAS_CALLBACK_FOCUS_IN,
-               FOCUS_OUT = EVAS_CALLBACK_FOCUS_OUT,
-
-               SHOW = EVAS_CALLBACK_SHOW,
-               HIDE = EVAS_CALLBACK_HIDE,
-
-               HOLD = EVAS_CALLBACK_HOLD,
-
-               IMAGE_PRELOADED = EVAS_CALLBACK_IMAGE_PRELOADED
-       };
-
-       // AtspiGestureEventInfo //
-
-       struct AtspiGestureEventInfo final {
-               Elm_Atspi_Gesture_Info gestureInfo;
-               bool preventDefault;
-               bool stopPropagation;
-       };
-
-       // WidgetARHint //
-
-       enum class WidgetARHint
-       {
-               NEITHER = EVAS_ASPECT_CONTROL_NEITHER,
-               HORIZONTAL = EVAS_ASPECT_CONTROL_HORIZONTAL,
-               VERTICAL = EVAS_ASPECT_CONTROL_VERTICAL,
-               BOTH = EVAS_ASPECT_CONTROL_BOTH
-       };
-
-       // LayoutTheme //
-
-       struct LayoutTheme final {
-               const char *klass;
-               const char *group;
-               const char *style;
-
-               constexpr LayoutTheme();
-               constexpr LayoutTheme(std::nullptr_t);
-               constexpr LayoutTheme(const char *klass,
-                               const char *group, const char *style);
-       };
-
-       // LayoutTheme non-member functions //
-
-       constexpr bool isValid(const LayoutTheme &value);
-}
-
-#include "types.hpp"
-
-#endif // __UCL_GUI_TYPES_H__
diff --git a/ucl/inc/ucl/gui/types.hpp b/ucl/inc/ucl/gui/types.hpp
deleted file mode 100644 (file)
index 7f128c8..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/helpers.h"
-
-namespace ucl {
-
-       // LayoutTheme //
-
-       constexpr LayoutTheme::LayoutTheme() :
-               klass(nullptr),
-               group(nullptr),
-               style(nullptr)
-       {
-       }
-
-       constexpr LayoutTheme::LayoutTheme(std::nullptr_t) :
-               LayoutTheme()
-       {
-       }
-
-       constexpr LayoutTheme::LayoutTheme(const char *klass,
-                       const char *group, const char *style) :
-               klass(klass),
-               group(group),
-               style(style)
-       {
-       }
-
-       // LayoutTheme non-member functions //
-
-       constexpr bool isValid(const LayoutTheme &value)
-       {
-               return (isNotEmpty(value.klass) && isNotEmpty(value.group) &&
-                                       isNotEmpty(value.style));
-       }
-}
diff --git a/ucl/inc/ucl/misc/Aspect.h b/ucl/inc/ucl/misc/Aspect.h
deleted file mode 100644 (file)
index 0c55bf6..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_ASPECT_H__
-#define __UCL_MISC_ASPECT_H__
-
-#include "ucl/util/types.h"
-
-namespace ucl {
-
-       template <class CHILD>
-       struct Aspect {
-               const char *name;
-
-               constexpr Aspect();
-               constexpr Aspect(std::nullptr_t);
-               explicit constexpr Aspect(const char *name);
-
-               constexpr operator const char *() const;
-
-               struct Hash final {
-                       size_t operator()(const Aspect &key) const;
-               };
-       };
-
-       // Non-member functions //
-
-       template <class CHILD>
-       constexpr bool isValid(Aspect<CHILD> aspect);
-
-       template <class CHILD>
-       constexpr bool operator==(Aspect<CHILD> lhs, Aspect<CHILD> rhs);
-       template <class CHILD>
-       constexpr bool operator!=(Aspect<CHILD> lhs, Aspect<CHILD> rhs);
-}
-
-#include "Aspect.hpp"
-
-#endif // __UCL_MISC_ASPECT_H__
diff --git a/ucl/inc/ucl/misc/Aspect.hpp b/ucl/inc/ucl/misc/Aspect.hpp
deleted file mode 100644 (file)
index 9894681..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cstring>
-
-#include "ucl/util/helpers.h"
-
-namespace ucl {
-
-       // Aspect<CHILD>::Hash //
-
-       template <class CHILD>
-       size_t Aspect<CHILD>::Hash::operator()(const Aspect<CHILD> &key) const
-       {
-               constexpr size_t PRIME = 31;
-               size_t result = 0;
-               for (size_t i = 0; (key.name[i] != '\0'); ++i) {
-                       result *= PRIME;
-                       result += key.name[i];
-               }
-               return result;
-       }
-
-       // Aspect<CHILD> //
-
-       template <class CHILD>
-       constexpr Aspect<CHILD>::Aspect() :
-               name(nullptr)
-       {
-       }
-
-       template <class CHILD>
-       constexpr Aspect<CHILD>::Aspect(std::nullptr_t) :
-               Aspect()
-       {
-       }
-
-       template <class CHILD>
-       constexpr Aspect<CHILD>::Aspect(const char *name) :
-               name(name)
-       {
-       }
-
-       template <class CHILD>
-       constexpr Aspect<CHILD>::operator const char *() const
-       {
-               return name;
-       }
-
-       // Non-member functions //
-
-       template <class CHILD>
-       constexpr bool isValid(const Aspect<CHILD> aspect)
-       {
-               return isNotEmpty(aspect);
-       }
-
-       template <class CHILD>
-       constexpr bool operator==(Aspect<CHILD> lhs, Aspect<CHILD> rhs)
-       {
-               return (strCmpSafe(lhs.name, rhs.name) == 0);
-       }
-
-       template <class CHILD>
-       constexpr bool operator!=(Aspect<CHILD> lhs, Aspect<CHILD> rhs)
-       {
-               return (strCmpSafe(lhs.name, rhs.name) != 0);
-       }
-}
diff --git a/ucl/inc/ucl/misc/AutoHandle.h b/ucl/inc/ucl/misc/AutoHandle.h
deleted file mode 100644 (file)
index 27c19f4..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_AUTO_HANDLE_H__
-#define __UCL_MISC_AUTO_HANDLE_H__
-
-#include "ucl/util/types.h"
-
-namespace ucl {
-
-       template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
-       struct AutoHandle final : ucl::NonCopyable {
-               using Handle = HANDLE;
-
-               HANDLE value;
-
-               AutoHandle() :
-                       value()
-               {
-               }
-
-               AutoHandle(std::nullptr_t) :
-                       AutoHandle()
-               {
-               }
-
-               AutoHandle(HANDLE value) :
-                       value(value)
-               {
-               }
-
-               ~AutoHandle()
-               {
-                       if (value) {
-                               DEL_FUNC(value);
-                       }
-               }
-
-               AutoHandle(AutoHandle &&src) :
-                       value(src.value)
-               {
-                       src.value = nullptr;
-               }
-
-               AutoHandle &operator=(AutoHandle src)
-               {
-                       swap(*this, src);
-                       return *this;
-               }
-
-               AutoHandle &operator=(HANDLE value)
-               {
-                       AutoHandle src{value};
-                       swap(*this, src);
-                       return *this;
-               }
-
-               HANDLE *operator&()
-               {
-                       return &value;
-               }
-
-               operator HANDLE()
-               {
-                       return value;
-               }
-       };
-
-       // Non-member functions //
-
-       template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
-       inline void swap(AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &x,
-                       AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &y) noexcept
-       {
-               std::swap(x.value, y.value);
-       }
-}
-
-#endif // __UCL_MISC_AUTO_HANDLE_H__
diff --git a/ucl/inc/ucl/misc/CString.h b/ucl/inc/ucl/misc/CString.h
deleted file mode 100644 (file)
index 396f37d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_CSTRING_H__
-#define __UCL_MISC_CSTRING_H__
-
-#include "ucl/util/types.h"
-
-namespace ucl {
-
-       class CString final : public NonCopyable {
-       public:
-               friend void swap(CString &x, CString &y) noexcept;
-
-               static CString dup(const char *ptr);
-               static CString takeover(char *ptr) noexcept;
-
-               CString() noexcept;
-               CString(std::nullptr_t) noexcept;
-               CString(CString &&s) noexcept;
-               CString(const std::string &s);
-               ~CString() noexcept;
-
-               CString &operator=(CString s) noexcept;
-
-               bool isEmpty() const;
-
-               char *release() noexcept;
-
-               char *get() const noexcept;
-
-       private:
-               explicit CString(char *ptr) noexcept;
-
-       private:
-               char *m_ptr;
-       };
-}
-
-#include "CString.hpp"
-
-#endif // __UCL_MISC_CSTRING_H__
diff --git a/ucl/inc/ucl/misc/CString.hpp b/ucl/inc/ucl/misc/CString.hpp
deleted file mode 100644 (file)
index 086b3c2..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/helpers.h"
-
-namespace ucl {
-
-       // CString //
-
-       inline CString CString::dup(const char *const ptr)
-       {
-               return CString(strDupSafe(ptr));
-       }
-
-       inline CString CString::takeover(char *const ptr) noexcept
-       {
-               return CString(ptr);
-       }
-
-       inline CString::CString(char *const ptr) noexcept :
-               m_ptr(ptr)
-       {
-       }
-
-       inline CString::CString() noexcept :
-               m_ptr(nullptr)
-       {
-       }
-
-       inline CString::CString(std::nullptr_t) noexcept :
-               CString()
-       {
-       }
-
-       inline CString::CString(CString &&s) noexcept :
-               m_ptr(s.m_ptr)
-       {
-               s.m_ptr = nullptr;
-       }
-
-       inline CString::CString(const std::string &s) :
-               m_ptr(s.empty() ? nullptr : strdup(s.c_str()))
-       {
-       }
-
-       inline CString::~CString() noexcept
-       {
-               free(m_ptr);
-       }
-
-       inline CString &CString::operator=(CString s) noexcept
-       {
-               swap(*this, s);
-               return *this;
-       }
-
-       inline bool CString::isEmpty() const
-       {
-               return !m_ptr;
-       }
-
-       inline char *CString::release() noexcept
-       {
-               char *const result = m_ptr;
-               m_ptr = nullptr;
-               return result;
-       }
-
-       inline char *CString::get() const noexcept
-       {
-               return m_ptr;
-       }
-
-       // Non-member functions //
-
-       inline void swap(CString &x, CString &y) noexcept
-       {
-               std::swap(x.m_ptr, y.m_ptr);
-       }
-}
diff --git a/ucl/inc/ucl/misc/ConstCString.h b/ucl/inc/ucl/misc/ConstCString.h
deleted file mode 100644 (file)
index 7f600f0..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_CONST_CSTRING_H__
-#define __UCL_MISC_CONST_CSTRING_H__
-
-#include "CString.h"
-
-namespace ucl {
-
-       class ConstCString final : public NonCopyable {
-       public:
-               friend void swap(ConstCString &x, ConstCString &y) noexcept;
-
-               static ConstCString wrap(const char *ptr) noexcept;
-
-               ConstCString() noexcept;
-               ConstCString(std::nullptr_t) noexcept;
-               ConstCString(ConstCString &&s) noexcept;
-               ConstCString(CString &&s) noexcept;
-               ~ConstCString() noexcept;
-
-               ConstCString &operator=(ConstCString s) noexcept;
-
-               bool isEmpty() const;
-
-               const char *get() const noexcept;
-
-       private:
-               explicit ConstCString(const char *ptr) noexcept;
-
-       private:
-               const char *m_ptr;
-               bool m_isOwner;
-       };
-}
-
-#include "ConstCString.hpp"
-
-#endif // __UCL_MISC_CONST_CSTRING_H__
diff --git a/ucl/inc/ucl/misc/ConstCString.hpp b/ucl/inc/ucl/misc/ConstCString.hpp
deleted file mode 100644 (file)
index 50df605..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       // ConstCString //
-
-       inline ConstCString ConstCString::wrap(const char *ptr) noexcept
-       {
-               return ConstCString(ptr);
-       }
-
-       inline ConstCString::ConstCString(const char *ptr) noexcept :
-               m_ptr(ptr),
-               m_isOwner(false)
-       {
-       }
-
-       inline ConstCString::ConstCString() noexcept :
-               m_ptr(nullptr),
-               m_isOwner(false)
-       {
-       }
-
-       inline ConstCString::ConstCString(std::nullptr_t) noexcept :
-               ConstCString()
-       {
-       }
-
-       inline ConstCString::ConstCString(ConstCString &&s) noexcept :
-               m_ptr(s.m_ptr),
-               m_isOwner(s.m_isOwner)
-       {
-               s.m_isOwner = false;
-       }
-
-       inline ConstCString::ConstCString(CString &&s) noexcept :
-               m_ptr(s.release()),
-               m_isOwner(true)
-       {
-       }
-
-       inline ConstCString::~ConstCString() noexcept
-       {
-               if (m_isOwner) {
-                       free(const_cast<char *>(m_ptr));
-               }
-       }
-
-       inline ConstCString &ConstCString::operator=(ConstCString s) noexcept
-       {
-               swap(*this, s);
-               return *this;
-       }
-
-       inline bool ConstCString::isEmpty() const
-       {
-               return !m_ptr;
-       }
-
-       inline const char *ConstCString::get() const noexcept
-       {
-               return m_ptr;
-       }
-
-       // Non-member functions //
-
-       inline void swap(ConstCString &x, ConstCString &y) noexcept
-       {
-               std::swap(x.m_ptr, y.m_ptr);
-               std::swap(x.m_isOwner, y.m_isOwner);
-       }
-}
diff --git a/ucl/inc/ucl/misc/Event.h b/ucl/inc/ucl/misc/Event.h
deleted file mode 100644 (file)
index cd27f29..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_EVENT_H__
-#define __UCL_MISC_EVENT_H__
-
-#include <vector>
-
-#include "ucl/util/types.h"
-
-namespace ucl {
-
-       template <class DELEGATE>
-       class Event final {
-       public:
-               Event();
-
-               template <class DELEGATE2>
-               void operator+=(DELEGATE2 &&delegate);
-               template <class DELEGATE2>
-               void operator-=(const DELEGATE2 &delegate);
-
-               bool isEmpty() const;
-
-               template <class ...ARGS>
-               void dispatch(ARGS &&...args);
-               template <class PREDICATE, class ...ARGS>
-               void dispatchPred(PREDICATE &&pred, ARGS &&...args);
-
-       private:
-               template <class DO_INVOKE, class ...ARGS>
-               void dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args);
-
-               void lock();
-               void unlock();
-               bool isLocked() const;
-
-               void defrag();
-
-       private:
-               std::vector<DELEGATE> m_delegates;
-               int m_lockCount;
-               bool m_isFragmented;
-       };
-}
-
-#include "Event.hpp"
-
-#endif // __UCL_MISC_EVENT_H__
diff --git a/ucl/inc/ucl/misc/Event.hpp b/ucl/inc/ucl/misc/Event.hpp
deleted file mode 100644 (file)
index ed4e402..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <algorithm>
-
-namespace ucl { namespace { namespace impl {
-
-       template <class PREDICATE, class DELEGATE, class ...ARGS>
-       auto doInvokePred(PREDICATE &&pred,
-                       const DELEGATE &delegate, ARGS &&...args) ->
-                               decltype(pred(delegate(std::forward<ARGS>(args)...)))
-       {
-               return pred(delegate(std::forward<ARGS>(args)...));
-       }
-
-       template <class DELEGATE, class PREDICATE, class ...ARGS>
-       auto doInvokePred(PREDICATE &&pred,
-                       const DELEGATE &delegate, ARGS &&...args) -> decltype(pred())
-       {
-               delegate(std::forward<ARGS>(args)...);
-               return pred();
-       }
-}}}
-
-namespace ucl {
-
-       template <class DELEGATE>
-       Event<DELEGATE>::Event() :
-               m_lockCount(0),
-               m_isFragmented(false)
-       {
-       }
-
-       template <class DELEGATE>
-       template <class DELEGATE2>
-       void Event<DELEGATE>::operator+=(DELEGATE2 &&delegate)
-       {
-               m_delegates.emplace_back(std::forward<DELEGATE2>(delegate));
-       }
-
-       template <class DELEGATE>
-       template <class DELEGATE2>
-       void Event<DELEGATE>::operator-=(const DELEGATE2 &delegate)
-       {
-               const auto it = std::find(
-                               m_delegates.begin(), m_delegates.end(), delegate);
-               if (it != m_delegates.end()) {
-                       if (isLocked()) {
-                               *it = {};
-                               m_isFragmented = true;
-                       } else {
-                               m_delegates.erase(it);
-                       }
-               }
-       }
-
-       template <class DELEGATE>
-       bool Event<DELEGATE>::isEmpty() const
-       {
-               return m_delegates.empty();
-       }
-
-       template <class DELEGATE>
-       template <class ...ARGS>
-       void Event<DELEGATE>::dispatch(ARGS &&...args)
-       {
-               dispatchImpl(
-                       [](const DELEGATE &delegate, ARGS &&...args)
-                       {
-                               delegate(std::forward<ARGS>(args)...);
-                               return true;
-                       },
-                       std::forward<ARGS>(args)...);
-       }
-
-       template <class DELEGATE>
-       template <class PREDICATE, class ...ARGS>
-       void Event<DELEGATE>::dispatchPred(PREDICATE &&pred, ARGS &&...args)
-       {
-               dispatchImpl(
-                       [&pred](const DELEGATE &delegate, ARGS &&...args)
-                       {
-                               return impl::doInvokePred(std::forward<PREDICATE>(pred),
-                                               delegate, std::forward<ARGS>(args)...);
-                       },
-                       std::forward<ARGS>(args)...);
-       }
-
-       template <class DELEGATE>
-       template <class DO_INVOKE, class ...ARGS>
-       void Event<DELEGATE>::dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args)
-       {
-               lock();
-               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)...)) {
-                                       break;
-                               }
-                       } else {
-                               m_isFragmented = true;
-                       }
-               }
-               unlock();
-               defrag();
-       }
-
-       template <class DELEGATE>
-       void Event<DELEGATE>::lock()
-       {
-               ++m_lockCount;
-       }
-
-       template <class DELEGATE>
-       void Event<DELEGATE>::unlock()
-       {
-               --m_lockCount;
-       }
-
-       template <class DELEGATE>
-       bool Event<DELEGATE>::isLocked() const
-       {
-               return (m_lockCount > 0);
-       }
-
-       template <class DELEGATE>
-       void Event<DELEGATE>::defrag()
-       {
-               if (m_isFragmented) {
-                       m_isFragmented = false;
-                       m_delegates.erase(
-                               std::remove_if(m_delegates.begin(), m_delegates.end(),
-                                       [](const DELEGATE &delegate) -> bool
-                                       {
-                                               return !delegate;
-                                       }),
-                               m_delegates.end());
-               }
-       }
-}
diff --git a/ucl/inc/ucl/misc/HashMap.h b/ucl/inc/ucl/misc/HashMap.h
deleted file mode 100644 (file)
index 8470fed..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_HASH_MAP_H__
-#define __UCL_MISC_HASH_MAP_H__
-
-#include <unordered_map>
-
-#include "Variant.h"
-
-namespace ucl {
-
-       template <class KEY, class VALUE>
-       class HashMap;
-
-       template <class VALUE>
-       using Dict = HashMap<std::string, VALUE>;
-
-       using VarDict = Dict<Variant>;
-
-       template <class KEY, class VALUE>
-       class HashMap final {
-       public:
-               template <class VALUE2>
-               HashMap &set(const KEY &key, VALUE2 &&value);
-               HashMap &unset(const KEY &key);
-
-               template <class VALUE2>
-               bool get(const KEY &key, VALUE2 &value) const;
-               VALUE get(const KEY &key) const;
-
-               void clear();
-
-       private:
-               template <class ENUM_CLASS>
-               struct EnumClassHash final {
-                       size_t operator()(ENUM_CLASS key) const {
-                               return static_cast<size_t>(key);
-                       }
-               };
-
-               template <class KEY2, class = void>
-               struct GetHash final {
-                       using Type = std::hash<KEY2>;
-               };
-
-               template <class KEY2>
-               struct GetHash<KEY2, typename std::enable_if<
-                               std::is_enum<KEY2>::value>::type> {
-                       using Type = EnumClassHash<KEY2>;
-               };
-
-               template <class KEY2>
-               struct GetHash<KEY2, typename std::enable_if<
-                               std::is_class<typename KEY2::Hash>::value>::type> {
-                       using Type = typename KEY2::Hash;
-               };
-
-               using Hash = typename GetHash<KEY>::Type;
-
-       private:
-               std::unordered_map<KEY, VALUE, Hash> m_map;
-       };
-}
-
-#include "HashMap.hpp"
-
-#endif // __UCL_MISC_HASH_MAP_H__
diff --git a/ucl/inc/ucl/misc/HashMap.hpp b/ucl/inc/ucl/misc/HashMap.hpp
deleted file mode 100644 (file)
index 2ba4ffd..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class KEY, class VALUE>
-       template <class VALUE2>
-       inline HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
-                       set(const KEY &key, VALUE2 &&value)
-       {
-               m_map.emplace(key, std::forward<VALUE2>(value));
-               return *this;
-       }
-
-       template <class KEY, class VALUE>
-       inline HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
-                       unset(const KEY &key)
-       {
-               m_map.erase(key);
-               return *this;
-       }
-
-       template <class KEY, class VALUE>
-       template <class VALUE2>
-       inline bool HashMap<KEY, VALUE>::
-                       get(const KEY &key, VALUE2 &value) const
-       {
-               const auto it = m_map.find(key);
-               if (it == m_map.end()) {
-                       return false;
-               }
-               value = it->second;
-               return true;
-       }
-
-       template <class KEY, class VALUE>
-       inline VALUE HashMap<KEY, VALUE>::
-                       get(const KEY &key) const
-       {
-               const auto it = m_map.find(key);
-               if (it == m_map.end()) {
-                       return {};
-               }
-               return it->second;
-       }
-
-       template <class KEY, class VALUE>
-       inline void HashMap<KEY, VALUE>::clear()
-       {
-               m_map.clear();
-       }
-}
diff --git a/ucl/inc/ucl/misc/RefCountAware.h b/ucl/inc/ucl/misc/RefCountAware.h
deleted file mode 100644 (file)
index 6ea5ee9..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_REF_COUNT_AWARE_H__
-#define __UCL_MISC_REF_COUNT_AWARE_H__
-
-#include "ucl/util/types.h"
-#include "ucl/util/memory.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(RefCountAware);
-
-       class RefCountAware : public Polymorphic {
-       public:
-               bool isShared() const;
-               UInt getUseCount() const;
-               const void *getObjPtr() const;
-
-               template <class T>
-               SharedRef<T> asSharedThis(T *thisAlias) const;
-
-               template <class T>
-               WeakRef<T> asWeakThis(T *thisAlias) const;
-
-       protected:
-               RefCountAware(IRefCountObj *rc);
-               virtual ~RefCountAware() = default;
-
-       public:
-               // This section MUST be public!
-               // Signal to RefCountObj<T, C> to pass IRefCountObj to constructor
-               enum { _IS_REF_COUNT_AWARE };
-
-       private:
-               IRefCountObj *const m_rc;
-       };
-
-       // Non-member functions //
-
-       template <class T>
-       SharedRef<T> asShared(T &obj);
-       template <class T>
-       SharedRef<T> asShared(T *obj);
-
-       template <class T>
-       WeakRef<T> asWeak(T &obj);
-       template <class T>
-       WeakRef<T> asWeak(T *obj);
-
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, U>::value>::type>
-       SharedRef<T> asShared(U &obj);
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, U>::value>::type>
-       SharedRef<T> asShared(U *obj);
-
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, U>::value>::type>
-       WeakRef<T> asWeak(U &obj);
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, U>::value>::type>
-       WeakRef<T> asWeak(U *obj);
-
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, const U>::value>::type>
-       SharedRef<const T> asShared(const U &obj);
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, const U>::value>::type>
-       SharedRef<const T> asShared(const U *obj);
-
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, const U>::value>::type>
-       WeakRef<const T> asWeak(const U &obj);
-       template <class T, class U, class = typename
-                       std::enable_if<!std::is_same<T, const U>::value>::type>
-       WeakRef<const T> asWeak(const U *obj);
-}
-
-#include "RefCountAware.hpp"
-
-#endif // __UCL_MISC_REF_COUNT_AWARE_H__
diff --git a/ucl/inc/ucl/misc/RefCountAware.hpp b/ucl/inc/ucl/misc/RefCountAware.hpp
deleted file mode 100644 (file)
index 8fb3812..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/logging.h"
-
-namespace ucl {
-
-       inline RefCountAware::RefCountAware(IRefCountObj *const rc) :
-               m_rc(rc)
-       {
-       }
-
-       inline bool RefCountAware::isShared() const
-       {
-               return !!m_rc;
-       }
-
-       inline UInt RefCountAware::getUseCount() const
-       {
-               if (!isShared()) {
-                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
-                       return 0;
-               }
-               return m_rc->getUseCount();
-       }
-
-       inline const void *RefCountAware::getObjPtr() const
-       {
-               if (!isShared()) {
-                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
-                       return nullptr;
-               }
-               return m_rc->getObjPtr();
-       }
-
-       template <class T>
-       inline SharedRef<T> RefCountAware::asSharedThis(T *const thisAlias) const
-       {
-               if (!isShared()) {
-                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
-                       return {};
-               }
-               return {m_rc, thisAlias};
-       }
-
-       template <class T>
-       inline WeakRef<T> RefCountAware::asWeakThis(T *const thisAlias) const
-       {
-               if (!isShared()) {
-                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
-                       return {};
-               }
-               return {m_rc, thisAlias};
-       }
-
-       // Non-member functions //
-
-       template <class T>
-       inline SharedRef<T> asShared(T &obj)
-       {
-               return obj.template asSharedThis<T>(&obj);
-       }
-
-       template <class T>
-       inline SharedRef<T> asShared(T *obj)
-       {
-               if (!obj) return {};
-               return obj->template asSharedThis<T>(obj);
-       }
-
-       template <class T>
-       inline WeakRef<T> asWeak(T &obj)
-       {
-               return obj.template asWeakThis<T>(&obj);
-       }
-
-       template <class T>
-       inline WeakRef<T> asWeak(T *obj)
-       {
-               if (!obj) return {};
-               return obj->template asWeakThis<T>(obj);
-       }
-
-       template <class T, class U, class>
-       inline SharedRef<T> asShared(U &obj)
-       {
-               return obj.template asSharedThis<T>(&obj);
-       }
-
-       template <class T, class U, class>
-       inline SharedRef<T> asShared(U *obj)
-       {
-               if (!obj) return {};
-               return obj->template asSharedThis<T>(obj);
-       }
-
-       template <class T, class U, class>
-       inline WeakRef<T> asWeak(U &obj)
-       {
-               return obj.template asWeakThis<T>(&obj);
-       }
-
-       template <class T, class U, class>
-       inline WeakRef<T> asWeak(U *obj)
-       {
-               if (!obj) return {};
-               return obj->template asWeakThis<T>(obj);
-       }
-
-       template <class T, class U, class>
-       inline SharedRef<const T> asShared(const U &obj)
-       {
-               return obj.template asSharedThis<const T>(&obj);
-       }
-
-       template <class T, class U, class>
-       inline SharedRef<const T> asShared(const U *obj)
-       {
-               if (!obj) return {};
-               return obj->template asSharedThis<const T>(obj);
-       }
-
-       template <class T, class U, class>
-       inline WeakRef<const T> asWeak(const U &obj)
-       {
-               return obj.template asWeakThis<const T>(&obj);
-       }
-
-       template <class T, class U, class>
-       inline WeakRef<const T> asWeak(const U *obj)
-       {
-               if (!obj) return {};
-               return obj->template asWeakThis<const T>(obj);
-       }
-}
diff --git a/ucl/inc/ucl/misc/TString.h b/ucl/inc/ucl/misc/TString.h
deleted file mode 100644 (file)
index 71ca2d9..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_T_STRING_H__
-#define __UCL_MISC_T_STRING_H__
-
-#include "ucl/util/types.h"
-
-namespace ucl {
-
-       class TString final {
-       public:
-               TString();
-
-               /**
-                * Constructs TString from std::string and domain
-                *
-                * @param str     Text string or string id if translatable.
-                * @param domain  Valid domain name or "" for default domain,
-                *                nullptr - if string is not translatable
-                */
-               TString(const std::string &str, const char *domain);
-               TString(const std::string &str, bool translatable = false);
-
-               TString(std::string &&str, const char *domain);
-               TString(std::string &&str, bool translatable = false);
-
-               TString(const char *str, const char *domain);
-               TString(const char *str, bool translatable = false);
-
-               bool isEmpty() const;
-
-               bool isTranslatable() const;
-               bool hasDomain() const;
-               const char *getDomain() const;
-
-               const std::string &getStr() const;
-               operator const std::string &() const;
-
-               const char *getCStr() const;
-               operator const char *() const;
-
-               const char *translate() const;
-
-               template <typename ...ARGS>
-               std::string format(ARGS ...args) const;
-
-       private:
-               const char *doTranslate(const char *strId) const;
-
-       private:
-               std::string m_str;
-               const char *m_domain;
-       };
-}
-
-#include "TString.hpp"
-
-#endif // __UCL_MISC_T_STRING_H__
diff --git a/ucl/inc/ucl/misc/TString.hpp b/ucl/inc/ucl/misc/TString.hpp
deleted file mode 100644 (file)
index 01c1327..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <libintl.h>
-#include <app_i18n.h>
-
-#include "ucl/util/helpers.h"
-
-namespace ucl {
-
-       inline TString::TString() :
-               m_domain(nullptr)
-       {
-       }
-
-       inline TString::TString(const std::string &str, const char *const domain) :
-               m_str(str),
-               m_domain(m_str.empty() ? nullptr : domain)
-       {
-       }
-
-       inline TString::TString(const std::string &str, const bool translatable) :
-               TString(str, (translatable ? "" : nullptr))
-       {
-       }
-
-       inline TString::TString(std::string &&str, const char *const domain) :
-               m_str(std::move(str)),
-               m_domain(m_str.empty() ? nullptr : domain)
-       {
-       }
-
-       inline TString::TString(std::string &&str, const bool translatable) :
-               TString(std::move(str), (translatable ? "" : nullptr))
-       {
-       }
-
-       inline TString::TString(const char *const str, const char *const domain) :
-               TString(std::string(nz(str)), domain)
-       {
-       }
-
-       inline TString::TString(const char *const str, const bool translatable) :
-               TString(std::string(nz(str)), (translatable ? "" : nullptr))
-       {
-       }
-
-       inline bool TString::isEmpty() const
-       {
-               return m_str.empty();
-       }
-
-       inline const std::string &TString::getStr() const
-       {
-               return m_str;
-       }
-
-       inline TString::operator const std::string &() const
-       {
-               return m_str;
-       }
-
-       inline const char *TString::getCStr() const
-       {
-               return m_str.c_str();
-       }
-
-       inline TString::operator const char *() const
-       {
-               return m_str.c_str();
-       }
-
-       inline bool TString::isTranslatable() const
-       {
-               return (m_domain != nullptr);
-       }
-
-       inline bool TString::hasDomain() const
-       {
-               return isNotEmpty(m_domain);
-       }
-
-       inline const char *TString::getDomain() const
-       {
-               return m_domain;
-       }
-
-       inline const char *TString::translate() const
-       {
-               if (!m_domain) {
-                       return getCStr();
-               }
-               return doTranslate(getCStr());
-       }
-
-       inline const char *TString::doTranslate(const char *const strId) const
-       {
-               if (m_domain[0] == '\0') {
-                       return i18n_get_text(strId);
-               }
-               return dgettext(m_domain, strId);
-       }
-
-       template <typename ...ARGS>
-       inline std::string TString::format(ARGS ...args) const
-       {
-               constexpr auto STR_LEN_ADJUST = 1.7f;
-
-               const char *fmt = m_str.c_str();
-               size_t fmtLen = m_str.length();
-
-               if (m_domain) {
-                       fmt = doTranslate(fmt);
-                       fmtLen = strlen(fmt);
-               }
-
-               size_t strLen = static_cast<size_t>(fmtLen * STR_LEN_ADJUST);
-
-               std::string result;
-
-               while (1) {
-                       result.resize(strLen);
-                       const size_t n = snprintf(&result[0], strLen, fmt, args...);
-                       if (n < strLen) {
-                               result.resize(n);
-                               break;
-                       }
-                       strLen = n + 1;
-               }
-
-               return result;
-       }
-}
diff --git a/ucl/inc/ucl/misc/Timeout.h b/ucl/inc/ucl/misc/Timeout.h
deleted file mode 100644 (file)
index 165265c..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_TIMEOUT_H__
-#define __UCL_MISC_TIMEOUT_H__
-
-#include <Ecore.h>
-
-#include "ucl/util/types.h"
-#include "ucl/util/smartDelegation.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(Timeout);
-
-       class Timeout final : public NonCopyable {
-       public:
-               using TimeoutHandler = WeakDelegate<void(Timeout *sender)>;
-
-       public:
-               static TimeoutSRef create(double timeoutSec,
-                               const TimeoutHandler &handler);
-
-               bool isExpired() const;
-
-       private:
-               friend class ReffedObj<Timeout>;
-               Timeout(const TimeoutHandler &handler);
-               ~Timeout();
-
-               Result prepare(double timeoutSec);
-
-               Eina_Bool onTimer();
-
-       private:
-               Ecore_Timer *m_timer;
-               TimeoutHandler m_handler;
-       };
-}
-
-#endif // __UCL_MISC_TIMEOUT_H__
diff --git a/ucl/inc/ucl/misc/Variant.h b/ucl/inc/ucl/misc/Variant.h
deleted file mode 100644 (file)
index 6542358..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_VARIANT_H__
-#define __UCL_MISC_VARIANT_H__
-
-#include <array>
-#include <vector>
-#include <initializer_list>
-
-#include "ConstCString.h"
-
-namespace ucl {
-
-       class Variant;
-
-       using VarVector = std::vector<Variant>;
-
-       template <size_t N>
-       using VarArray = std::array<Variant, N>;
-
-       struct VarInitList final {
-               VarInitList(const std::initializer_list<Variant> &il) : il(il) {}
-               const std::initializer_list<Variant> &il;
-       };
-
-       class Variant final {
-       public:
-               enum Type {
-                       TYPE_NIL,
-                       TYPE_BOOLEAN,
-                       TYPE_INTEGER,
-                       TYPE_FLOAT,
-                       TYPE_DOUBLE,
-                       TYPE_STRING,
-                       TYPE_ARRAY
-               };
-
-       public:
-               friend void swap(Variant &x, Variant &y) noexcept;
-
-               friend bool operator==(const Variant &lhs, const Variant &rhs) noexcept;
-               friend bool operator!=(const Variant &lhs, const Variant &rhs) noexcept;
-
-       public:
-               Variant() noexcept;
-               Variant(std::nullptr_t) noexcept;
-
-               Variant(bool aBool) noexcept;
-               Variant(int anInt) noexcept;
-               Variant(float aFloat) noexcept;
-               Variant(double aDouble) noexcept;
-
-               Variant(const char *aString);
-               Variant(const char *aString, int length);
-               Variant(const std::string &aString);
-
-               Variant(std::nullptr_t, int arrayLength);
-               Variant(const Variant *anArray, int length);
-               Variant(const VarVector &anArray);
-               template <size_t N>
-               Variant(const VarArray<N> &anArray);
-               Variant(const VarInitList &anArray);
-
-               ~Variant();
-
-               Variant(const Variant &v);
-               Variant(Variant &&v) noexcept;
-
-               Variant &operator=(Variant v);
-
-               Type getType() const noexcept;
-               int getLength() const noexcept;
-               bool isEmpty() const noexcept;
-
-               bool asBool() const noexcept;
-               int asInt() const noexcept;
-               float asFloat() const noexcept;
-               double asDouble() const noexcept;
-
-               ConstCString asString() const noexcept;
-
-               Variant *asArray() noexcept;
-               const Variant *asArray() const noexcept;
-
-               Variant *begin() noexcept;
-               Variant *end() noexcept;
-               const Variant *begin() const noexcept;
-               const Variant *end() const noexcept;
-
-               Variant &operator[](int index) noexcept;
-               const Variant &operator[](int index) const noexcept;
-
-               explicit operator bool() const noexcept;
-               explicit operator int() const noexcept;
-               explicit operator float() const noexcept;
-               explicit operator double() const noexcept;
-
-               bool operator==(Variant::Type rhs) const noexcept;
-               bool operator!=(Variant::Type rhs) const noexcept;
-
-       private:
-               const char *getStr() const noexcept;
-
-       public:
-               union {
-                       uint8_t m_type;
-                       struct {
-                               uint64_t qw1;
-                               uint64_t qw2;
-                       } m_raw;
-                       struct { uint8_t type; bool value; } m_aBool;
-                       struct { uint8_t type; int value; } m_anInt;
-                       struct { uint8_t type; float value; } m_aFloat;
-                       struct { uint8_t type; double value; } m_aDouble;
-                       struct {
-                               uint8_t type;
-                               char buffer[sizeof(m_raw) - 1];
-                       } m_aSmallStr;
-                       struct {
-                               uint8_t type;
-                               int length;
-                               char *data;
-                       } m_aString;
-                       struct {
-                               uint8_t type;
-                               int length;
-                               Variant *data;
-                       } m_anArray;
-               };
-       };
-}
-
-#include "Variant.hpp"
-
-#endif // __UCL_MISC_VARIANT_H__
diff --git a/ucl/inc/ucl/misc/Variant.hpp b/ucl/inc/ucl/misc/Variant.hpp
deleted file mode 100644 (file)
index fe6d977..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cstring>
-
-namespace ucl { namespace { namespace impl {
-
-       constexpr auto TYPE_MASK = 0x0F;
-
-       constexpr auto FLAG_SMALL_STR = 0x80;
-       constexpr auto TYPE_SMALL_STR = (Variant::TYPE_STRING | FLAG_SMALL_STR);
-
-       constexpr auto TMP_STR_BUFF_SIZE = 32;
-}}}
-
-namespace ucl {
-
-       // Variant //
-
-       inline Variant::Variant() noexcept :
-               m_type(TYPE_NIL)
-       {
-       }
-
-       inline Variant::Variant(std::nullptr_t) noexcept :
-               Variant()
-       {
-       }
-
-       inline Variant::Variant(const bool aBool) noexcept :
-               m_type(TYPE_BOOLEAN)
-       {
-               m_aBool.value = aBool;
-       }
-
-       inline Variant::Variant(const int anInt) noexcept :
-               m_type(TYPE_INTEGER)
-       {
-               m_anInt.value = anInt;
-       }
-
-       inline Variant::Variant(const float aFloat) noexcept :
-               m_type(TYPE_FLOAT)
-       {
-               m_aFloat.value = aFloat;
-       }
-
-       inline Variant::Variant(const double aDouble) noexcept :
-               m_type(TYPE_DOUBLE)
-       {
-               m_aDouble.value = aDouble;
-       }
-
-       inline Variant::Variant(const char *const aString) :
-               Variant(aString, -1)
-       {
-       }
-
-       inline Variant::Variant(const std::string &aString) :
-               Variant(aString.c_str(), aString.size())
-       {
-       }
-
-       inline Variant::Variant(const VarVector &anArray) :
-               Variant(anArray.data(), anArray.size())
-       {
-       }
-
-       template <size_t N>
-       inline Variant::Variant(const VarArray<N> &anArray) :
-               Variant(anArray.data(), anArray.size())
-       {
-       }
-
-       inline Variant::Variant(const VarInitList &anArray) :
-               Variant(anArray.il.begin(), anArray.il.size())
-       {
-       }
-
-       inline Variant::~Variant()
-       {
-               switch (m_type) {
-               case TYPE_STRING:
-                       free(m_aString.data);
-                       break;
-               case TYPE_ARRAY:
-                       delete[] m_anArray.data;
-                       break;
-               }
-       }
-
-       inline Variant::Variant(Variant &&v) noexcept :
-               m_type(v.m_type)
-       {
-               switch (m_type) {
-               case TYPE_NIL:
-                       break;
-               case TYPE_STRING:
-                       m_aString.data = v.m_aString.data;
-                       m_aString.length = v.m_aString.length;
-                       v.m_type = TYPE_NIL;
-                       break;
-               case TYPE_ARRAY:
-                       m_anArray.data = v.m_anArray.data;
-                       m_anArray.length = v.m_anArray.length;
-                       v.m_type = TYPE_NIL;
-                       break;
-               default:
-                       m_raw = v.m_raw;
-                       break;
-               }
-       }
-
-       inline Variant &Variant::operator=(Variant v)
-       {
-               swap(*this, v);
-               return *this;
-       }
-
-       inline Variant::Type Variant::getType() const noexcept
-       {
-               return Type(m_type & impl::TYPE_MASK);
-       }
-
-       inline int Variant::getLength() const noexcept
-       {
-               switch (m_type) {
-               case TYPE_NIL:
-                       return 0;
-               case TYPE_STRING:
-                       return m_aString.length;
-               case TYPE_ARRAY:
-                       return m_anArray.length;
-               case impl::TYPE_SMALL_STR:
-                       return strlen(m_aSmallStr.buffer);
-               }
-               return 1;
-       }
-
-       inline bool Variant::isEmpty() const noexcept
-       {
-               return (getLength() == 0);
-       }
-
-       inline const char *Variant::getStr() const noexcept
-       {
-               return ((m_type == TYPE_STRING) ? m_aString.data : m_aSmallStr.buffer);
-       }
-
-       inline Variant *Variant::asArray() noexcept
-       {
-               return begin();
-       }
-
-       inline const Variant *Variant::asArray() const noexcept
-       {
-               return begin();
-       }
-
-       inline Variant *Variant::begin() noexcept
-       {
-               return ((m_type == TYPE_ARRAY) ? m_anArray.data : this);
-       }
-
-       inline Variant *Variant::end() noexcept
-       {
-               return ((m_type == TYPE_ARRAY) ?
-                               (m_anArray.data + m_anArray.length) : (this + 1));
-       }
-
-       inline const Variant *Variant::begin() const noexcept
-       {
-               return const_cast<Variant *>(this)->begin();
-       }
-
-       inline const Variant *Variant::end() const noexcept
-       {
-               return const_cast<Variant *>(this)->end();
-       }
-
-       inline Variant &Variant::operator[](int index) noexcept
-       {
-               return asArray()[index];
-       }
-
-       inline const Variant &Variant::operator[](int index) const noexcept
-       {
-               return asArray()[index];
-       }
-
-       inline Variant::operator bool() const noexcept
-       {
-               return asBool();
-       }
-
-       inline Variant::operator int() const noexcept
-       {
-               return asInt();
-       }
-
-       inline Variant::operator float() const noexcept
-       {
-               return asFloat();
-       }
-
-       inline Variant::operator double() const noexcept
-       {
-               return asDouble();
-       }
-
-       inline bool Variant::operator==(const Variant::Type rhs) const noexcept
-       {
-               return (m_type == rhs);
-       }
-
-       inline bool Variant::operator!=(const Variant::Type rhs) const noexcept
-       {
-               return (m_type != rhs);
-       }
-
-       // Non-member functions //
-
-       inline void swap(Variant &x, Variant &y) noexcept
-       {
-               static_assert(sizeof(Variant) == sizeof(Variant::m_raw),
-                               "Invalid Variant data structure!");
-               static_assert(std::is_standard_layout<Variant>::value,
-                               "Variant has not standard layout!");
-               std::swap(x.m_raw, y.m_raw);
-       }
-
-       inline bool operator!=(const Variant &lhs, const Variant &rhs) noexcept
-       {
-               return !(lhs == rhs);
-       }
-}
diff --git a/ucl/inc/ucl/mvp/GuiPresenter.h b/ucl/inc/ucl/mvp/GuiPresenter.h
deleted file mode 100644 (file)
index 5a94af4..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MVP_GUI_PRESENTER_H__
-#define __UCL_MVP_GUI_PRESENTER_H__
-
-#include <unordered_set>
-
-#include "ucl/gui/Window.h"
-
-#include "types.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(GuiPresenter);
-
-       class GuiPresenter : public RefCountAware {
-       public:
-               struct DeactivatorInfo final {
-                       const void *deactivator;
-                       bool isBroadcast;
-               };
-
-       public:
-               bool isActive() const;
-               bool isDeactivatedBy(const void *deactivator) const;
-
-               void activateBy(const void *deactivator);
-               void deactivateBy(const void *deactivator);
-
-               void addDeactivatorSource(Widget &source);
-               void delDeactivatorSource(Widget &source);
-
-       protected:
-               enum {
-                       PF_ADD_DEACTIVATOR_SOURCES = 1,
-                       PF_ADD_SELF_EXCEPT = 2,
-
-                       PF_PASSIVE = 0,
-                       PF_DEACTIVATOR = (PF_ADD_DEACTIVATOR_SOURCES | PF_ADD_SELF_EXCEPT),
-                       PF_DEFAULT = PF_ADD_DEACTIVATOR_SOURCES
-               };
-
-       protected:
-               GuiPresenter(IRefCountObj &rc);
-               virtual ~GuiPresenter();
-
-               Result prepare(ElmWidget &widget, int flags = PF_DEFAULT);
-               Result prepare(GuiPresenter &parent, int flags = PF_DEFAULT);
-
-               Window &getWindow();
-               bool isWindowReady() const;
-
-               void addDeactivatorException(const void *deactivator);
-               void setDeactivatorSink(const WidgetSRef &sink);
-
-               void sendActivate(Widget &sender);
-               void sendDeactivate(Widget &sender);
-
-               void broadcastActivate();
-               void broadcastDeactivate();
-
-               virtual void onActivate();
-               virtual void onDeactivate();
-               virtual void onActivateBy(const DeactivatorInfo &info);
-               virtual void onDeactivateBy(const DeactivatorInfo &info);
-
-       private:
-               void sendDeactivator(Widget &sender,
-                               SmartEvent event, const void *deactivator);
-               void broadcastDeactivator(SmartEvent event,
-                               const void *deactivator);
-
-               void sendDeactivatorInfo(Widget &sender, SmartEvent event,
-                               const DeactivatorInfo &info);
-
-               void activateByImpl(const DeactivatorInfo &info);
-               void deactivateByImpl(const DeactivatorInfo &info);
-
-               void onActivateBySmart(Widget &widget, void *eventInfo);
-               void onDeactivateBySmart(Widget &widget, void *eventInfo);
-
-       private:
-               std::unordered_set<const void *> m_deactivatorExceptions;
-               std::unordered_set<const void *> m_deactivators;
-               WindowSRef m_window;
-               WidgetSRef m_sink;
-               WidgetWRef m_parentSink;
-               bool m_hasBuildInSources;
-               bool m_isChild;
-               bool m_isPrepared;
-       };
-}
-
-#endif // __UCL_MVP_GUI_PRESENTER_H__
diff --git a/ucl/inc/ucl/mvp/ListItemPresenter.h b/ucl/inc/ucl/mvp/ListItemPresenter.h
deleted file mode 100644 (file)
index 46d2fb4..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MVP_LIST_ITEM_PRESENTER_H__
-#define __UCL_MVP_LIST_ITEM_PRESENTER_H__
-
-#include "ucl/gui/GenlistItem.h"
-#include "ucl/gui/ElmWidget.h"
-
-#include "ucl/misc/HashMap.h"
-
-#include "types.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(ListItemPresenter);
-
-       class ListItemPresenter : public RefCountAware,
-                       public IDisposable {
-       public:
-               // IDisposable //
-
-               virtual void dispose() final override;
-               virtual bool isDisposed() const final override;
-
-       protected:
-               friend class ListPresenter;
-
-               UCL_DECLARE_REF_ALIASES(ItemClass);
-               UCL_DECLARE_REF_ALIASES(ItemClassCache);
-
-               // Flags
-               enum {
-                       PF_AUTO_UNSELECT = 1
-               };
-
-               struct ItemInsertionParams {
-                       ElmStyle itemStyle;
-                       GenlistItem::Type itemType;
-
-                       ItemInsertionParams(ElmStyle itemStyle,
-                                       GenlistItem::Type itemType = GenlistItem::Type::SIMPLE) :
-                               itemStyle(itemStyle), itemType(itemType) {}
-               };
-
-               class ItemClass final : public NonCopyable {
-               public:
-                       static ItemClassSRef newInstance(ElmStyle itemStyle);
-               public:
-                       Elm_Genlist_Item_Class *get();
-               private:
-                       friend class ReffedObj<ItemClass>;
-                       ItemClass(ElmStyle itemStyle);
-                       ~ItemClass();
-               private:
-                       Elm_Genlist_Item_Class *const m_itc;
-               };
-
-               class ItemClassCache final : public NonCopyable {
-               public:
-                       ItemClassSRef getItemClass(ElmStyle itemStyle);
-                       void purge();
-               private:
-                       HashMap<ElmStyle, ItemClassSRef> m_itcMap;
-               };
-
-       protected:
-               ListItemPresenter(IRefCountObj &rc);
-               virtual ~ListItemPresenter();
-
-               void setFlags(int flags);
-               int getFlags() const;
-
-               bool isActive() const;
-
-               GenlistItem getItem();
-               ItemClassCache *getItemClassCache();
-
-               Result updateItemStyle(ElmStyle newItemStyle);
-
-               virtual ItemInsertionParams getItemInsertionParams() = 0;
-
-               virtual void onItemAttached();
-               virtual void onItemDetached();
-
-               virtual CString getItemPartText(EdjePart part);
-               virtual WidgetSRef getItemPartContent(EdjePart part, ElmWidget &parent);
-               virtual bool getItemPartState(EdjePart part);
-
-               virtual void onItemSelected();
-               virtual void onItemRealized();
-               virtual void onItemUnrealized();
-               virtual void onItemHighlighted();
-               virtual void onItemUnhighlighted();
-
-       private:
-               void attachItem(GenlistItem item,
-                               ElmWidgetSRef &&parent,
-                               const ItemClassCacheSRef &itcCache,
-                               const SharedRef<bool> &isActiveRef);
-
-               void deleteDetachedItem(bool silent = false);
-               void detachItem(bool silent = false);
-
-               void onItemSelectedHook();
-               void onItemDel(Evas_Object *obj, void *eventInfo);
-
-       private:
-               ListItemPresenterSRef m_selfRef;
-               GenlistItem m_item;
-               ItemClassCacheSRef m_itcCache;
-               SharedRef<bool> m_isActiveRef;
-               ElmWidgetSRef m_parent;
-               int m_flags;
-       };
-}
-
-#endif // __UCL_MVP_LIST_ITEM_PRESENTER_H__
diff --git a/ucl/inc/ucl/mvp/ListPresenter.h b/ucl/inc/ucl/mvp/ListPresenter.h
deleted file mode 100644 (file)
index 1d62e41..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MVP_LIST_PRESENTER_H__
-#define __UCL_MVP_LIST_PRESENTER_H__
-
-#include "ucl/gui/Genlist.h"
-
-#include "GuiPresenter.h"
-#include "ListItemPresenter.h"
-
-namespace ucl {
-
-       UCL_DECLARE_REF_ALIASES(ListPresenter);
-
-       class ListPresenter final : public GuiPresenter {
-       public:
-               enum {
-                       FLAG_HOMOGENEOUS = (1 << 0),
-                       FLAG_CALC_X_MIN = (1 << 1),
-                       FLAG_CALC_Y_MIN = (1 << 2),
-
-                       FLAG_NOTIFY_REALIZED = (1 << 8),
-                       FLAG_NOTIFY_UNREALIZED = (1 << 9),
-                       FLAG_NOTIFY_HIGHLIGHTED = (1 << 10),
-                       FLAG_NOTIFY_UNHIGHLIGHTED = (1 << 11),
-               };
-
-               class Builder final {
-               public:
-                       Builder();
-                       Builder &setStyle(ElmStyle style);
-                       Builder &setFlags(int flags);
-                       Builder &setParentWidget(const ElmWidgetSRef &parentWidget);
-                       ListPresenterSRef build(GuiPresenter &parent) const;
-               private:
-                       ucl::ElmWidgetSRef m_parentWidget;
-                       ElmStyle m_style;
-                       int m_flags;
-               };
-
-       public:
-               Genlist &getWidget();
-
-               void clear();
-
-               Result append(ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent = nullptr);
-
-               Result prepend(ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent = nullptr);
-
-               Result insertAfter(const ListItemPresenter &after,
-                               ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent = nullptr);
-
-               Result insertBefore(const ListItemPresenter &before,
-                               ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent = nullptr);
-
-       private:
-               friend class ReffedObj<ListPresenter>;
-               ListPresenter(IRefCountObj &rc);
-               virtual ~ListPresenter();
-
-               Result prepare(GuiPresenter &parent, ElmWidget &parentWidget,
-                               ElmStyle style, int flags);
-
-               template <class INSERT_FUNC>
-               Result insert(ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent,
-                               INSERT_FUNC &&insertFunc);
-
-               template <class INSERT_FUNC>
-               Result insertRelative(const ListItemPresenter &relative,
-                               ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent, INSERT_FUNC &&insertFunc);
-
-               void setIsActiveRef(bool value);
-
-               void onItemSelected(Widget &widget, void *eventInfo);
-
-               void onItemRealized(Widget &widget, void *eventInfo);
-               void onItemUnrealized(Widget &widget, void *eventInfo);
-               void onItemHighlighted(Widget &widget, void *eventInfo);
-               void onItemUnhighlighted(Widget &widget, void *eventInfo);
-
-               // GuiPresenter //
-
-               virtual void onActivate() final override;
-               virtual void onDeactivate() final override;
-
-       private:
-               GenlistSRef m_genlist;
-               ListItemPresenter::ItemClassCacheSRef m_itcCache;
-               SharedRef<bool> m_isActiveRef;
-       };
-}
-
-#endif // __UCL_MVP_LIST_PRESENTER_H__
diff --git a/ucl/inc/ucl/mvp/types.h b/ucl/inc/ucl/mvp/types.h
deleted file mode 100644 (file)
index 6c263e2..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MVP_TYPES_H__
-#define __UCL_MVP_TYPES_H__
-
-#include "ucl/gui/types.h"
-
-#endif // __UCL_MVP_TYPES_H__
diff --git a/ucl/inc/ucl/util/delegation.h b/ucl/inc/ucl/util/delegation.h
deleted file mode 100644 (file)
index a624c08..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_H__
-#define __UCL_UTIL_DELEGATION_H__
-
-#include "delegation/Callback.h"
-
-#include "delegation/BaseDelegate.h"
-#include "delegation/BaseDelegate2.h"
-
-#include "delegation/Delegate.h"
-#include "delegation/Delegate2.h"
-
-#include "delegation/helpers.h"
-#include "delegation/macro.h"
-
-#if (UCL_INCLUDE_DELEGATION_SHORT_MACRO_H)
-#include "delegation/shortMacro.h"
-#endif
-
-#endif // __UCL_UTIL_DELEGATION_H__
diff --git a/ucl/inc/ucl/util/delegation/BaseDelegate.h b/ucl/inc/ucl/util/delegation/BaseDelegate.h
deleted file mode 100644 (file)
index 62b92ff..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_BASE_DELEGATE_H__
-#define __UCL_UTIL_DELEGATION_BASE_DELEGATE_H__
-
-#include "Callback.h"
-
-namespace ucl {
-
-       template <class FUNC_SIG, class DATA>
-       class BaseDelegate;
-
-       template <class FUNC_SIG, class DATA>
-       class BaseDelegate2;
-
-       template <class R, class ...ARGS, class DATA>
-       class BaseDelegate<R(ARGS...), DATA> {
-       public:
-               using Cb = Callback<R(ARGS...)>;
-               using StubA = typename Cb::StubA;
-
-       public:
-               constexpr BaseDelegate() noexcept;
-               constexpr BaseDelegate(std::nullptr_t) noexcept;
-
-               template <class FUNC_SIG>
-               BaseDelegate(const BaseDelegate2<FUNC_SIG, DATA> &d) noexcept;
-               template <class FUNC_SIG>
-               BaseDelegate(BaseDelegate2<FUNC_SIG, DATA> &&d) noexcept;
-
-               void reset() noexcept;
-
-               const DATA &getData() const noexcept;
-               StubA getStubA() const noexcept;
-               operator bool() const noexcept;
-
-       protected:
-               BaseDelegate(const DATA &data, StubA stubA) noexcept;
-
-       protected:
-               DATA m_data;
-               StubA m_stubA;
-       };
-}
-
-#include "BaseDelegate.hpp"
-
-#endif // __UCL_UTIL_DELEGATION_BASE_DELEGATE_H__
diff --git a/ucl/inc/ucl/util/delegation/BaseDelegate.hpp b/ucl/inc/ucl/util/delegation/BaseDelegate.hpp
deleted file mode 100644 (file)
index f25c0a7..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class R, class ...ARGS, class DATA>
-       constexpr BaseDelegate<R(ARGS...), DATA>::BaseDelegate() noexcept :
-               m_data(nullptr),
-               m_stubA(nullptr)
-       {
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       constexpr BaseDelegate<R(ARGS...), DATA>::
-                       BaseDelegate(std::nullptr_t) noexcept :
-               BaseDelegate()
-       {
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       inline BaseDelegate<R(ARGS...), DATA>::
-                       BaseDelegate(const DATA &data, StubA stubA) noexcept :
-               m_data(data),
-               m_stubA(stubA)
-       {
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       template <class FUNC_SIG>
-       inline BaseDelegate<R(ARGS...), DATA>::
-                       BaseDelegate(const BaseDelegate2<FUNC_SIG, DATA> &d) noexcept :
-               m_data(d.m_data),
-               m_stubA(d.m_stubA)
-       {
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       template <class FUNC_SIG>
-       inline BaseDelegate<R(ARGS...), DATA>::
-                       BaseDelegate(BaseDelegate2<FUNC_SIG, DATA> &&d) noexcept :
-               m_data(std::move(d.m_data)),
-               m_stubA(d.m_stubA)
-       {
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       inline void BaseDelegate<R(ARGS...), DATA>::reset() noexcept
-       {
-               *this = {};
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       inline const DATA &BaseDelegate<R(ARGS...), DATA>::getData() const noexcept
-       {
-               return m_data;
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       inline typename BaseDelegate<R(ARGS...), DATA>::StubA
-                       BaseDelegate<R(ARGS...), DATA>::getStubA() const noexcept
-       {
-               return m_stubA;
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       inline BaseDelegate<R(ARGS...), DATA>::operator bool() const noexcept
-       {
-               return !!m_data;
-       }
-}
diff --git a/ucl/inc/ucl/util/delegation/BaseDelegate2.h b/ucl/inc/ucl/util/delegation/BaseDelegate2.h
deleted file mode 100644 (file)
index ff3b635..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_BASE_DELEGATE2_H__
-#define __UCL_UTIL_DELEGATION_BASE_DELEGATE2_H__
-
-#include "BaseDelegate.h"
-
-namespace ucl {
-
-       template <class FUNC_SIG, class DATA>
-       class BaseDelegate2;
-
-       template <class R, class ...ARGS, class DATA>
-       class BaseDelegate2<R(ARGS...), DATA> :
-                       public BaseDelegate<R(ARGS...), DATA> {
-       public:
-               using Cb = typename BaseDelegate2::Cb;
-               using StubA = typename Cb::StubA;
-               using StubB = typename Cb::StubB;
-
-       public:
-               using BaseDelegate<R(ARGS...), DATA>::BaseDelegate;
-
-               StubB getStubB() const noexcept;
-
-       protected:
-               BaseDelegate2(const DATA &data, StubA stubA, StubB stubB) noexcept;
-
-       private:
-               StubB m_stubB;
-       };
-}
-
-#include "BaseDelegate2.hpp"
-
-#endif // __UCL_UTIL_DELEGATION_BASE_DELEGATE2_H__
diff --git a/ucl/inc/ucl/util/delegation/BaseDelegate2.hpp b/ucl/inc/ucl/util/delegation/BaseDelegate2.hpp
deleted file mode 100644 (file)
index 6d8efa7..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class R, class ...ARGS, class DATA>
-       inline BaseDelegate2<R(ARGS...), DATA>::
-                       BaseDelegate2(const DATA &data, StubA stubA, StubB stubB) noexcept :
-               BaseDelegate<R(ARGS...), DATA>(data, stubA),
-               m_stubB(stubB)
-       {
-       }
-
-       template <class R, class ...ARGS, class DATA>
-       inline typename BaseDelegate2<R(ARGS...), DATA>::StubB
-                       BaseDelegate2<R(ARGS...), DATA>::getStubB() const noexcept
-       {
-               return m_stubB;
-       }
-}
diff --git a/ucl/inc/ucl/util/delegation/Callback.h b/ucl/inc/ucl/util/delegation/Callback.h
deleted file mode 100644 (file)
index 69724be..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_CALLBACK_H__
-#define __UCL_UTIL_DELEGATION_CALLBACK_H__
-
-#include "ucl/util/types/baseTypes.h"
-
-namespace ucl {
-
-       template <class FUNC_SIG>
-       class Callback;
-
-       template <class R, class ...ARGS>
-       class Callback<R(ARGS...)> {
-       public:
-               using StubA = R(*)(void *, ARGS...);
-               using StubB = R(*)(ARGS..., void *);
-
-       public:
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-               static R stubA(void *data, ARGS ...args);
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-               static R stubB(ARGS ...args, void *data);
-
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-               static R stubA(void *data, ARGS ...args);
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-               static R stubB(ARGS ...args, void *data);
-
-               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-               static R stubA2A(void *data, ARGS ...args);
-               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-               static R stubB2A(ARGS ...args, void *data);
-
-               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-               static R stubA2B(void *data, ARGS ...args);
-               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-               static R stubB2B(ARGS ...args, void *data);
-
-               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-               static R stubA2A(void *data, ARGS ...args);
-               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-               static R stubB2A(ARGS ...args, void *data);
-
-               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-               static R stubA2B(void *data, ARGS ...args);
-               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-               static R stubB2B(ARGS ...args, void *data);
-
-               template <R(*FUNC)(ARGS...)>
-               static R stubA2V(void *data, ARGS ...args);
-               template <R(*FUNC)(ARGS...)>
-               static R stubB2V(ARGS ...args, void *data);
-       };
-}
-
-#include "Callback.hpp"
-
-#endif // __UCL_UTIL_DELEGATION_CALLBACK_H__
diff --git a/ucl/inc/ucl/util/delegation/Callback.hpp b/ucl/inc/ucl/util/delegation/Callback.hpp
deleted file mode 100644 (file)
index 28d2145..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-       inline R Callback<R(ARGS...)>::stubA(void *data, ARGS ...args)
-       {
-               return (static_cast<CLASS *>(data)->*METHOD)(
-                               std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-       inline R Callback<R(ARGS...)>::stubB(ARGS ...args, void *data)
-       {
-               return (static_cast<CLASS *>(data)->*METHOD)(
-                               std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-       inline R Callback<R(ARGS...)>::stubA(void *data, ARGS ...args)
-       {
-               return (static_cast<const CLASS *>(data)->*METHOD)(
-                               std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-       inline R Callback<R(ARGS...)>::stubB(ARGS ...args, void *data)
-       {
-               return (static_cast<const CLASS *>(data)->*METHOD)(
-                               std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-       inline R Callback<R(ARGS...)>::stubA2A(void *data, ARGS ...args)
-       {
-               return FUNC(*static_cast<CLASS *>(data), std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-       inline R Callback<R(ARGS...)>::stubB2A(ARGS ...args, void *data)
-       {
-               return FUNC(*static_cast<CLASS *>(data), std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-       inline R Callback<R(ARGS...)>::stubA2B(void *data, ARGS ...args)
-       {
-               return FUNC(std::forward<ARGS>(args)..., *static_cast<CLASS *>(data));
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-       inline R Callback<R(ARGS...)>::stubB2B(ARGS ...args, void *data)
-       {
-               return FUNC(std::forward<ARGS>(args)..., *static_cast<CLASS *>(data));
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-       inline R Callback<R(ARGS...)>::stubA2A(void *data, ARGS ...args)
-       {
-               return FUNC(static_cast<HANDLE>(data), std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-       inline R Callback<R(ARGS...)>::stubB2A(ARGS ...args, void *data)
-       {
-               return FUNC(static_cast<HANDLE>(data), std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-       inline R Callback<R(ARGS...)>::stubA2B(void *data, ARGS ...args)
-       {
-               return FUNC(std::forward<ARGS>(args)..., static_cast<HANDLE>(data));
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-       inline R Callback<R(ARGS...)>::stubB2B(ARGS ...args, void *data)
-       {
-               return FUNC(std::forward<ARGS>(args)..., static_cast<HANDLE>(data));
-       }
-
-       template <class R, class ...ARGS>
-       template <R(*FUNC)(ARGS...)>
-       inline R Callback<R(ARGS...)>::stubA2V(void *data, ARGS ...args)
-       {
-               return FUNC(std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <R(*FUNC)(ARGS...)>
-       inline R Callback<R(ARGS...)>::stubB2V(ARGS ...args, void *data)
-       {
-               return FUNC(std::forward<ARGS>(args)...);
-       }
-}
diff --git a/ucl/inc/ucl/util/delegation/Delegate.h b/ucl/inc/ucl/util/delegation/Delegate.h
deleted file mode 100644 (file)
index e1e7416..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_DELEGATE_H__
-#define __UCL_UTIL_DELEGATION_DELEGATE_H__
-
-#include "BaseDelegate.h"
-
-namespace ucl {
-
-       template <class FUNC_SIG>
-       class Delegate;
-
-       template <class R, class ...ARGS>
-       class Delegate<R(ARGS...)> : public BaseDelegate<R(ARGS...), void *> {
-       public:
-               using BaseDelegate<R(ARGS...), void *>::BaseDelegate;
-
-               R operator()(ARGS ...args) const;
-
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-               static Delegate make(CLASS *data) noexcept;
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-               static Delegate make(const CLASS *data) noexcept;
-
-               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-               static Delegate makeA(CLASS &data) noexcept;
-               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-               static Delegate makeB(CLASS &data) noexcept;
-
-               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-               static Delegate makeA(HANDLE data) noexcept;
-               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-               static Delegate makeB(HANDLE data) noexcept;
-
-               template <R(*FUNC)(ARGS...)>
-               static Delegate make() noexcept;
-       };
-}
-
-#include "Delegate.hpp"
-
-#endif // __UCL_UTIL_DELEGATION_DELEGATE_H__
diff --git a/ucl/inc/ucl/util/delegation/Delegate.hpp b/ucl/inc/ucl/util/delegation/Delegate.hpp
deleted file mode 100644 (file)
index 632ec24..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class R, class ...ARGS>
-       inline R Delegate<R(ARGS...)>::operator()(ARGS ...args) const
-       {
-               return this->m_stubA(this->m_data, std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-       inline Delegate<R(ARGS...)>
-                       Delegate<R(ARGS...)>::make(CLASS *const data) noexcept
-       {
-               return {static_cast<void *>(data),
-                               Delegate::Cb::template stubA<CLASS, METHOD>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-       inline Delegate<R(ARGS...)>
-                       Delegate<R(ARGS...)>::make(const CLASS *const data) noexcept
-       {
-               return {static_cast<void *>(const_cast<CLASS *>(data)),
-                               Delegate::Cb::template stubA<CLASS, METHOD>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-       inline Delegate<R(ARGS...)>
-                       Delegate<R(ARGS...)>::makeA(CLASS &data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(&data)),
-                               Delegate::Cb::template stubA2A<CLASS, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-       inline Delegate<R(ARGS...)>
-                       Delegate<R(ARGS...)>::makeB(CLASS &data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(&data)),
-                               Delegate::Cb::template stubA2B<CLASS, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-       inline Delegate<R(ARGS...)>
-                       Delegate<R(ARGS...)>::makeA(const HANDLE data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(data)),
-                               Delegate::Cb::template stubA2A<HANDLE, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-       inline Delegate<R(ARGS...)>
-                       Delegate<R(ARGS...)>::makeB(const HANDLE data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(data)),
-                               Delegate::Cb::template stubA2B<HANDLE, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <R(*FUNC)(ARGS...)>
-       inline Delegate<R(ARGS...)>
-                       Delegate<R(ARGS...)>::make() noexcept
-       {
-               return {nullptr, Delegate::Cb::template stubA2V<FUNC>};
-       }
-}
diff --git a/ucl/inc/ucl/util/delegation/Delegate2.h b/ucl/inc/ucl/util/delegation/Delegate2.h
deleted file mode 100644 (file)
index 56ff3fb..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_DELEGATE2_H__
-#define __UCL_UTIL_DELEGATION_DELEGATE2_H__
-
-#include "BaseDelegate2.h"
-
-namespace ucl {
-
-       template <class FUNC_SIG>
-       class Delegate2;
-
-       template <class R, class ...ARGS>
-       class Delegate2<R(ARGS...)> : public BaseDelegate2<R(ARGS...), void *> {
-       public:
-               using BaseDelegate2<R(ARGS...), void *>::BaseDelegate2;
-
-               R operator()(ARGS ...args) const;
-
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-               static Delegate2 make(CLASS *data) noexcept;
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-               static Delegate2 make(const CLASS *data) noexcept;
-
-               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-               static Delegate2 makeA(CLASS &data) noexcept;
-               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-               static Delegate2 makeB(CLASS &data) noexcept;
-
-               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-               static Delegate2 makeA(HANDLE data) noexcept;
-               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-               static Delegate2 makeB(HANDLE data) noexcept;
-
-               template <R(*FUNC)(ARGS...)>
-               static Delegate2 make() noexcept;
-       };
-}
-
-#include "Delegate2.hpp"
-
-#endif // __UCL_UTIL_DELEGATION_DELEGATE2_H__
diff --git a/ucl/inc/ucl/util/delegation/Delegate2.hpp b/ucl/inc/ucl/util/delegation/Delegate2.hpp
deleted file mode 100644 (file)
index 085ba46..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class R, class ...ARGS>
-       inline R Delegate2<R(ARGS...)>::operator()(ARGS ...args) const
-       {
-               return this->m_stubA(this->m_data, std::forward<ARGS>(args)...);
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-       inline Delegate2<R(ARGS...)>
-                       Delegate2<R(ARGS...)>::make(CLASS *const data) noexcept
-       {
-               return {static_cast<void *>(data),
-                               Delegate2::Cb::template stubA<CLASS, METHOD>,
-                               Delegate2::Cb::template stubB<CLASS, METHOD>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-       inline Delegate2<R(ARGS...)>
-                       Delegate2<R(ARGS...)>::make(const CLASS *const data) noexcept
-       {
-               return {static_cast<void *>(const_cast<CLASS *>(data)),
-                               Delegate2::Cb::template stubA<CLASS, METHOD>,
-                               Delegate2::Cb::template stubB<CLASS, METHOD>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
-       inline Delegate2<R(ARGS...)>
-                       Delegate2<R(ARGS...)>::makeA(CLASS &data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(&data)),
-                               Delegate2::Cb::template stubA2A<CLASS, FUNC>,
-                               Delegate2::Cb::template stubB2A<CLASS, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
-       inline Delegate2<R(ARGS...)>
-                       Delegate2<R(ARGS...)>::makeB(CLASS &data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(&data)),
-                               Delegate2::Cb::template stubA2B<CLASS, FUNC>,
-                               Delegate2::Cb::template stubB2B<CLASS, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
-       inline Delegate2<R(ARGS...)>
-                       Delegate2<R(ARGS...)>::makeA(const HANDLE data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(data)),
-                               Delegate2::Cb::template stubA2A<HANDLE, FUNC>,
-                               Delegate2::Cb::template stubB2A<HANDLE, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
-       inline Delegate2<R(ARGS...)>
-                       Delegate2<R(ARGS...)>::makeB(const HANDLE data) noexcept
-       {
-               return {const_cast<void *>(static_cast<const void *>(data)),
-                               Delegate2::Cb::template stubA2B<HANDLE, FUNC>,
-                               Delegate2::Cb::template stubB2B<HANDLE, FUNC>};
-       }
-
-       template <class R, class ...ARGS>
-       template <R(*FUNC)(ARGS...)>
-       inline Delegate2<R(ARGS...)>
-                       Delegate2<R(ARGS...)>::make() noexcept
-       {
-               return {nullptr,
-                               Delegate2::Cb::template stubA2V<FUNC>,
-                               Delegate2::Cb::template stubB2V<FUNC>};
-       }
-}
diff --git a/ucl/inc/ucl/util/delegation/helpers.h b/ucl/inc/ucl/util/delegation/helpers.h
deleted file mode 100644 (file)
index 54ebb99..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_HELPERS_H__
-#define __UCL_UTIL_DELEGATION_HELPERS_H__
-
-namespace ucl {
-
-       // Automatic function signature detection for a specific type //
-
-       template <template <typename ...> class T, class TAG, class FUNC>
-       struct AutoFuncSig;
-
-       template <template <typename ...> class T,
-                        class R, class CLASS, class ...ARGS>
-       struct AutoFuncSig<T, void *, R(CLASS::*)(ARGS...)> {
-               using Data = CLASS;
-               using Type = T<R(ARGS...)>;
-       };
-
-       template <template <typename ...> class T,
-                       class CLASS, class R, class ...ARGS>
-       struct AutoFuncSig<T, void *, R(CLASS::*)(ARGS...) const> {
-               using Data = CLASS;
-               using Type = T<R(ARGS...)>;
-       };
-
-       template <template <typename ...> class T,
-                       class CLASS, class R, class ...ARGS>
-       struct AutoFuncSig<T, void *, R(*)(CLASS &, ARGS...)> {
-               using Data = CLASS;
-               using Type = T<R(ARGS...)>;
-       };
-
-       template <template <typename ...> class T,
-                       class HANDLE, class R, class ...ARGS>
-       struct AutoFuncSig<T, void *, R(*)(HANDLE, ARGS...)> {
-               using Data = HANDLE;
-               using Type = T<R(ARGS...)>;
-       };
-
-       template <template <typename ...> class T,
-                       class R, class ...ARGS>
-       struct AutoFuncSig<T, void, R(*)(ARGS...)> {
-               using Type = T<R(ARGS...)>;
-       };
-
-       // Relation operators //
-
-       template <class R, class ...ARGS, class DATA1, class DATA2>
-       inline bool operator==(const BaseDelegate<R(ARGS...), DATA1> &lhs,
-                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
-       {
-               return ((lhs.getStubA() == rhs.getStubA()) && (
-                               lhs.getData() == rhs.getData()));
-       }
-
-       template <class R, class ...ARGS, class DATA1, class DATA2>
-       inline bool operator!=(const BaseDelegate<R(ARGS...), DATA1> &lhs,
-                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
-       {
-               return ((lhs.getStubA() != rhs.getStubA()) || (
-                               lhs.getData() != rhs.getData()));
-       }
-
-       template <class R, class ...ARGS, class DATA1, class DATA2>
-       inline bool operator<(const BaseDelegate<R(ARGS...), DATA1> &lhs,
-                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
-       {
-               return ((lhs.getStubA() < rhs.getStubA()) ||
-                               ((lhs.getStubA() == rhs.getStubA()) && (
-                                       lhs.getData() < rhs.getData())));
-       }
-
-       template <class R, class ...ARGS, class DATA1, class DATA2>
-       inline bool operator<=(const BaseDelegate<R(ARGS...), DATA1> &lhs,
-                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
-       {
-               return ((lhs.getStubA() < rhs.getStubA()) ||
-                               ((lhs.getStubA() == rhs.getStubA()) && (
-                                       lhs.getData() <= rhs.getData())));
-       }
-
-       template <class R, class ...ARGS, class DATA1, class DATA2>
-       inline bool operator>(const BaseDelegate<R(ARGS...), DATA1> &lhs,
-                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
-       {
-               return ((lhs.getStubA() > rhs.getStubA()) ||
-                               ((lhs.getStubA() == rhs.getStubA()) && (
-                                       lhs.getData() > rhs.getData())));
-       }
-
-       template <class R, class ...ARGS, class DATA1, class DATA2>
-       inline bool operator>=(const BaseDelegate<R(ARGS...), DATA1> &lhs,
-                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
-       {
-               return ((lhs.getStubA() > rhs.getStubA()) ||
-                               ((lhs.getStubA() == rhs.getStubA()) && (
-                                       lhs.getData() >= rhs.getData())));
-       }
-}
-
-#endif // __UCL_UTIL_DELEGATION_HELPERS_H__
diff --git a/ucl/inc/ucl/util/delegation/macro.h b/ucl/inc/ucl/util/delegation/macro.h
deleted file mode 100644 (file)
index 62bf88f..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_MACRO_H__
-#define __UCL_UTIL_DELEGATION_MACRO_H__
-
-// Helper macro to simplify use of AutoFuncSig template
-
-#define _UCL_AFS(DELEGATE, FUNC) \
-               ::ucl::AutoFuncSig<DELEGATE, void *, decltype(&FUNC)>
-
-// Helper macro to automatically generate different delegate objects //
-
-#define _UCL_DELEGATE(DELEGATE, FUNC, DATA) (_UCL_AFS(DELEGATE, FUNC):: \
-               Type::make<_UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA))
-
-#define _UCL_DELEGATE_A(DELEGATE, FUNC, DATA) (_UCL_AFS(DELEGATE, FUNC):: \
-               Type::makeA<_UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA))
-
-#define _UCL_DELEGATE_V(DELEGATE, FUNC) \
-               (::ucl::AutoFuncSig<DELEGATE, void, decltype(&FUNC)>::\
-                       Type::make<&FUNC>())
-
-// Helper macro to automatically generate Delegate objects //
-
-#define UCL_DELEGATE(FUNC, DATA) _UCL_DELEGATE(::ucl::Delegate, FUNC, DATA)
-#define UCL_DELEGATE_A(FUNC, DATA) _UCL_DELEGATE_A(::ucl::Delegate, FUNC, DATA)
-#define UCL_DELEGATE_V(FUNC) _UCL_DELEGATE_V(::ucl::Delegate, FUNC)
-
-// Helper macro to automatically generate Delegate2 objects //
-
-#define UCL_DELEGATE2(FUNC, DATA) _UCL_DELEGATE(::ucl::Delegate2, FUNC, DATA)
-#define UCL_DELEGATE2_A(FUNC, DATA) \
-               _UCL_DELEGATE_A(::ucl::Delegate2, FUNC, DATA)
-#define UCL_DELEGATE2_V(FUNC) _UCL_DELEGATE_V(::ucl::Delegate2, FUNC)
-
-// Helper macro to automatically generate Callback stubs //
-
-#define UCL_CALLBACK_A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC):: \
-               Type::stubA<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
-#define UCL_CALLBACK_B(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC):: \
-               Type::stubB<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
-
-#define UCL_CALLBACK_A2A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
-               stubA2A<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
-#define UCL_CALLBACK_B2A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
-               stubB2A<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
-
-#define UCL_CALLBACK_A2V(FUNC) (&::ucl::AutoFuncSig<::ucl::Callback, void, \
-               decltype(&FUNC)>::Type::stubA2V<&FUNC>)
-#define UCL_CALLBACK_B2V(FUNC) (&::ucl::AutoFuncSig<::ucl::Callback, void, \
-               decltype(&FUNC)>::Type::stubB2V<&FUNC>)
-
-#endif // __UCL_UTIL_DELEGATION_MACRO_H__
diff --git a/ucl/inc/ucl/util/delegation/shortMacro.h b/ucl/inc/ucl/util/delegation/shortMacro.h
deleted file mode 100644 (file)
index 3837977..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_DELEGATION_SHORT_MACRO_H__
-#define __UCL_UTIL_DELEGATION_SHORT_MACRO_H__
-
-// Helper macro to automatically generate Delegate objects //
-
-#define DELEGATE(FUNC, DATA)    UCL_DELEGATE(FUNC, DATA)
-#define DELEGATE_A(FUNC, DATA)  UCL_DELEGATE_A(FUNC, DATA)
-#define DELEGATE_V(FUNC)        UCL_DELEGATE_V(FUNC)
-
-// Helper macro to automatically generate Delegate2 objects //
-
-#define DELEGATE2(FUNC, DATA)    UCL_DELEGATE2(FUNC, DATA)
-#define DELEGATE2_A(FUNC, DATA)  UCL_DELEGATE2_A(FUNC, DATA)
-#define DELEGATE2_V(FUNC)        UCL_DELEGATE2_V(FUNC)
-
-// Helper macro to automatically generate Callback stubs //
-
-#define CALLBACK_A(FUNC)  UCL_CALLBACK_A(FUNC)
-#define CALLBACK_B(FUNC)  UCL_CALLBACK_B(FUNC)
-
-#define CALLBACK_A2A(FUNC)  UCL_CALLBACK_A2A(FUNC)
-#define CALLBACK_B2A(FUNC)  UCL_CALLBACK_B2A(FUNC)
-
-#define CALLBACK_A2V(FUNC)  UCL_CALLBACK_A2V(FUNC)
-#define CALLBACK_B2V(FUNC)  UCL_CALLBACK_B2V(FUNC)
-
-#endif // __UCL_UTIL_DELEGATION_SHORT_MACRO_H__
diff --git a/ucl/inc/ucl/util/helpers.h b/ucl/inc/ucl/util/helpers.h
deleted file mode 100644 (file)
index 117d3de..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_HELPERS_H__
-#define __UCL_UTIL_HELPERS_H__
-
-#include "types/baseTypes.h"
-#include "types/classTypes.h"
-
-namespace ucl {
-
-       constexpr Eina_Bool toEina(bool value);
-
-       // "nz()" - "Not Zero" functions
-       // return "zValue" if "!value" is true
-       constexpr const char *nz(const char *value, const char *zValue = "");
-
-       // "ne()" - "Not Empty" functions
-       // return "eValue" if "isEmpty(value)" is true
-       constexpr const char *ne(const char *value, const char *eValue = nullptr);
-
-       constexpr bool isEmpty(const char *value);
-
-       template <class T>
-       constexpr auto isEmpty(const T &value) -> decltype(value.empty())
-       {
-               return value.empty();
-       }
-
-       template <class T>
-       constexpr auto isEmpty(const T &value) -> decltype(value.isEmpty())
-       {
-               return value.isEmpty();
-       }
-
-       template <class T>
-       constexpr auto isEmpty(const T &value) -> decltype(isEmpty(*value))
-       {
-               return (!value || isEmpty(*value));
-       }
-
-       template <class T>
-       constexpr bool isNotEmpty(T &&value);
-
-       template <class T>
-       constexpr bool isNotValid(T &&value);
-
-       char *strDupSafe(const char *value);
-       int strCmpSafe(const char *lhs, const char *rhs);
-
-       template <class T1, class T2>
-       inline auto dynamicCast(T2 &&src) -> decltype(
-                       dynamic_cast<T1>(std::forward<T2>(src)))
-       {
-               return dynamic_cast<T1>(std::forward<T2>(src));
-       }
-
-       template <class T1, class T2>
-       inline auto constCast(T2 &&src) -> decltype(
-                       const_cast<T1>(std::forward<T2>(src)))
-       {
-               return const_cast<T1>(std::forward<T2>(src));
-       }
-
-       template <class T>
-       constexpr const T &min(const T &a, const T &b);
-
-       template <class T>
-       constexpr const T &max(const T &a, const T &b);
-
-       template <class T>
-       constexpr bool isPot(T value)
-       {
-               return (((value - 1) & value) == 0);
-       }
-
-       template <uint MULTIPLE, class T>
-       constexpr T ceilDiv(T value);
-
-       template <uint MULTIPLE, class T>
-       constexpr typename std::enable_if<isPot(MULTIPLE), T>::type
-                       roundUp(T value)
-       {
-               return ((value + (MULTIPLE - 1)) & ~static_cast<T>(MULTIPLE - 1));
-       }
-
-       template <uint MULTIPLE, class T>
-       constexpr typename std::enable_if<!isPot(MULTIPLE), T>::type
-                       roundUp(T value)
-       {
-               return (ceilDiv<MULTIPLE>(value) * MULTIPLE);
-       }
-}
-
-namespace ucl { namespace util {
-
-       template <class T>
-       std::unique_ptr<T> makeUnique(T *p);
-
-       template <class T, class = typename std::enable_if<
-                       std::is_convertible<T *, IDisposable *>::value>::type>
-       inline void dispose(T *&p) noexcept
-       {
-               if (p) {
-                       p->dispose();
-                       p = nullptr;
-               }
-       }
-}}
-
-#include "helpers.hpp"
-
-#endif // __UCL_UTIL_HELPERS_H__
diff --git a/ucl/inc/ucl/util/helpers.hpp b/ucl/inc/ucl/util/helpers.hpp
deleted file mode 100644 (file)
index a7606f8..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       constexpr Eina_Bool toEina(const bool value)
-       {
-               return (value ? EINA_TRUE : EINA_FALSE);
-       }
-
-       constexpr const char *nz(const char *const value, const char *const zValue)
-       {
-               return (value ? value : zValue);
-       }
-
-       template <class T>
-       constexpr bool isNotEmpty(T &&value)
-       {
-               return !isEmpty(std::forward<T>(value));
-       }
-
-       constexpr const char *ne(const char *const value, const char *const eValue)
-       {
-               return (isNotEmpty(value) ? value : eValue);
-       }
-
-       constexpr bool isEmpty(const char *const value)
-       {
-               return (!value || (value[0] == '\0'));
-       }
-
-       template <class T>
-       constexpr bool isNotValid(T &&value)
-       {
-               return !isValid(std::forward<T>(value));
-       }
-
-       inline char *strDupSafe(const char *const value)
-       {
-               return (value ? strdup(value) : nullptr);
-       }
-
-       inline int strCmpSafe(const char *lhs, const char *rhs)
-       {
-               return strcmp(nz(lhs), nz(rhs));
-       }
-
-       template <class T>
-       constexpr const T &min(const T &a, const T &b)
-       {
-               return ((a < b) ? a : b);
-       }
-
-       template <class T>
-       constexpr const T &max(const T &a, const T &b)
-       {
-               return ((a > b) ? a : b);
-       }
-
-       template <uint MULTIPLE, class T>
-       constexpr T ceilDiv(T value)
-       {
-               return ((value + (MULTIPLE - 1)) / MULTIPLE);
-       }
-}
-
-namespace ucl { namespace util {
-
-       template <class T>
-       inline std::unique_ptr<T> makeUnique(T *const p)
-       {
-               return std::unique_ptr<T>(p);
-       }
-}}
diff --git a/ucl/inc/ucl/util/logging.h b/ucl/inc/ucl/util/logging.h
deleted file mode 100644 (file)
index 804a513..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_LOGGING_H__
-#define __UCL_UTIL_LOGGING_H__
-
-#include <assert.h>
-
-#include <dlog.h>
-
-#include "types/Result.h"
-
-::ucl::ResultData getUCLResultData(::ucl::Result result);
-
-#ifndef UCL_LOG_LEVEL
-#define UCL_LOG_LEVEL UCL_MAX_LOG_LEVEL
-#elif UCL_LOG_LEVEL > UCL_MAX_LOG_LEVEL
-#undef UCL_LOG_LEVEL
-#define UCL_LOG_LEVEL UCL_MAX_LOG_LEVEL
-#endif
-
-#ifndef UCL_LOG_TAG
-#define UCL_LOG_TAG UCL_DEFAULT_LOG_TAG
-#endif
-
-#ifndef __MODULE__
-#define __MODULE__ (strrchr(__FILE__, '/') ? \
-               strrchr(__FILE__, '/') + 1 : __FILE__)
-#endif
-
-// Base macros for writing logs without result code
-#define UCL_ULOG(prio, fmt, ...) dlog_print( \
-       (log_priority)prio, UCL_LOG_TAG, "%s: %s(%d) > " fmt, \
-       __MODULE__, __func__, __LINE__, ##__VA_ARGS__)
-
-// Base macros for writing logs WITH result code
-#define UCL_URESDATALOG(prio, resdata, fmt, ...) dlog_print( \
-       (log_priority)prio, UCL_LOG_TAG, "%s: %s(%d) > " fmt " {%s}", \
-       __MODULE__, __func__, __LINE__, ##__VA_ARGS__, resdata.name)
-
-#define UCL_URESLOG(prio, result, fmt, ...) do { \
-       const ::ucl::ResultData &resdata = ::getUCLResultData(result); \
-       UCL_URESDATALOG(prio, resdata, fmt, ##__VA_ARGS__);} while (false)
-
-#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_VERBOSE
-#define UCL_VLOG(msg, ...) UCL_ULOG(DLOG_VERBOSE, msg, ##__VA_ARGS__)
-#define UCL_VRESLOG(result, msg, ...) \
-               UCL_URESLOG(DLOG_VERBOSE, result, msg, ##__VA_ARGS__)
-#else
-#define UCL_VLOG(msg, ...) do {} while (false)
-#define UCL_VRESLOG(result, msg, ...) do {} while (false)
-#endif
-
-#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_DEBUG
-#define UCL_DLOG(msg, ...) UCL_ULOG(DLOG_DEBUG, msg, ##__VA_ARGS__)
-#define UCL_DRESLOG(result, msg, ...) \
-               UCL_URESLOG(DLOG_DEBUG, result, msg, ##__VA_ARGS__)
-#else
-#define UCL_DLOG(msg, ...) do {} while (false)
-#define UCL_DRESLOG(result, msg, ...) do {} while (false)
-#endif
-
-#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_INFO
-#define UCL_ILOG(msg, ...) UCL_ULOG(DLOG_INFO, msg, ##__VA_ARGS__)
-#define UCL_IRESLOG(result, msg, ...) \
-               UCL_URESLOG(DLOG_INFO, result, msg, ##__VA_ARGS__)
-#else
-#define UCL_ILOG(msg, ...) do {} while (false)
-#define UCL_IRESLOG(result, msg, ...) do {} while (false)
-#endif
-
-#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_WARNING
-#define UCL_WLOG(msg, ...) UCL_ULOG(DLOG_WARN, msg, ##__VA_ARGS__)
-#define UCL_WRESLOG(result, msg, ...) \
-               UCL_URESLOG(DLOG_WARN, result, msg, ##__VA_ARGS__)
-#else
-#define UCL_WLOG(msg, ...) do {} while (false)
-#define UCL_WRESLOG(result, msg, ...) do {} while (false)
-#endif
-
-#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_ERROR
-#define UCL_ELOG(msg, ...) UCL_ULOG(DLOG_ERROR, msg, ##__VA_ARGS__)
-#define UCL_ERESLOG(result, msg, ...) \
-               UCL_URESLOG(DLOG_ERROR, result, msg, ##__VA_ARGS__)
-#else
-#define UCL_ELOG(msg, ...) do {} while (false)
-#define UCL_ERESLOG(result, msg, ...) do {} while (false)
-#endif
-
-#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_FATAL
-#define UCL_FLOG(msg, ...) UCL_ULOG(DLOG_FATAL, msg, ##__VA_ARGS__)
-#define UCL_FRESLOG(result, msg, ...) UCL_URESLOG( \
-       DLOG_FATAL, result, msg, ##__VA_ARGS__)
-#else
-#define UCL_FLOG(msg, ...) do {} while (false)
-#define UCL_FRESLOG(result, msg, ...) do {} while (false)
-#endif
-
-#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_ERROR
-
-// Simple macros for writing logs WITH result
-// code and automatic log priority determination
-#define UCL_RESLOG(result, msg, ...) { \
-       const ::ucl::ResultData &resdata = ::getUCLResultData(result); \
-       UCL_URESDATALOG(resdata.logPrio, \
-                       resdata, msg, ##__VA_ARGS__);} while (false)
-
-#else
-#define UCL_RESLOG(result, msg, ...) do {} while (false)
-#endif
-
-#define UCL_ASSERT(expr, msg, ...) \
-       do { \
-               if (!(expr)) { \
-                       UCL_FLOG(msg, ##__VA_ARGS__); \
-                       assert(false); \
-               } \
-       } while (false)
-
-#define UCL_FAIL_RETURN(result, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               if (isBad(__RESULT__)) { \
-                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-                       return __RESULT__; \
-               } \
-       } while (false)
-
-#define UCL_FAIL_RETURN_VALUE(result, value, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               if (isBad(__RESULT__)) { \
-                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-                       return value; \
-               } \
-       } while (false)
-
-#define UCL_FAIL_RETURN_VOID(result, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               if (isBad(__RESULT__)) { \
-                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-                       return; \
-               } \
-       } while (false)
-
-#define UCL_LOG_RETURN(result, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-               return __RESULT__; \
-       } while (false)
-
-#define UCL_LOG_RETURN_VALUE(result, value, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-               return value; \
-       } while (false)
-
-#define UCL_LOG_RETURN_VOID(result, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-               return; \
-       } while (false)
-
-#define UCL_FAIL_BREAK(result, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               if (isBad(__RESULT__)) { \
-                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-                       break; \
-               } \
-       } while (false)
-
-#define UCL_LOG_BREAK(result, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-               break; \
-       } while (false)
-
-#define UCL_FAIL_LOG(result, msg, ...) \
-       do { \
-               const ::ucl::Result __RESULT__ = (result); \
-               if (isBad(__RESULT__)) { \
-                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-               } \
-       } while (false)
-
-#endif // __UCL_UTIL_LOGGING_H__
diff --git a/ucl/inc/ucl/util/memory.h b/ucl/inc/ucl/util/memory.h
deleted file mode 100644 (file)
index cc33960..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_H__
-#define __UCL_UTIL_MEMORY_H__
-
-#include "memory/RefCountObj.h"
-
-#include "memory/BaseRef.h"
-#include "memory/SharedRef.h"
-#include "memory/WeakRef.h"
-
-#include "memory/helpers.h"
-#include "memory/macro.h"
-
-#endif // __UCL_UTIL_MEMORY_H__
diff --git a/ucl/inc/ucl/util/memory/BaseRef.h b/ucl/inc/ucl/util/memory/BaseRef.h
deleted file mode 100644 (file)
index 8146eae..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_BASE_REF_H__
-#define __UCL_UTIL_MEMORY_BASE_REF_H__
-
-#include "IRefCountObj.h"
-
-namespace ucl {
-
-       template <class T>
-       class BaseRef {
-       public:
-               using Type = T;
-
-               template <class U>
-               friend class BaseRef;
-               template <class U>
-               friend class SharedRef;
-               template <class U>
-               friend class WeakRef;
-
-       public:
-               UInt getUseCount() const noexcept;
-
-       protected:
-               constexpr BaseRef() noexcept;
-               BaseRef(IRefCountObj *rc, T *ptr) noexcept;
-               BaseRef(BaseRef<T> &&r) noexcept;
-               template <class U>
-               BaseRef(BaseRef<U> &&r) noexcept;
-
-       protected:
-               IRefCountObj *m_rc;
-               T *m_ptr;
-       };
-}
-
-#include "BaseRef.hpp"
-
-#endif // __UCL_UTIL_MEMORY_BASE_REF_H__
diff --git a/ucl/inc/ucl/util/memory/BaseRef.hpp b/ucl/inc/ucl/util/memory/BaseRef.hpp
deleted file mode 100644 (file)
index 312c38e..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class T>
-       constexpr BaseRef<T>::BaseRef() noexcept :
-               m_rc(nullptr),
-               m_ptr(nullptr)
-       {
-       }
-
-       template <class T>
-       inline BaseRef<T>::BaseRef(
-                       IRefCountObj *const rc, T *const ptr) noexcept :
-               m_rc(rc),
-               m_ptr(ptr)
-       {
-       }
-
-       template <class T>
-       inline BaseRef<T>::BaseRef(BaseRef<T> &&r) noexcept :
-               m_rc(r.m_rc),
-               m_ptr(r.m_ptr)
-       {
-               r.m_rc = nullptr;
-               r.m_ptr = nullptr;
-       }
-
-       template <class T>
-       template <class U>
-       inline BaseRef<T>::BaseRef(BaseRef<U> &&r) noexcept :
-               m_rc(r.m_rc),
-               m_ptr(r.m_ptr)
-       {
-               r.m_rc = nullptr;
-               r.m_ptr = nullptr;
-       }
-
-       template <class T>
-       inline UInt BaseRef<T>::getUseCount() const noexcept
-       {
-               return (m_rc ? m_rc->getUseCount() : 0);
-       }
-}
diff --git a/ucl/inc/ucl/util/memory/IRefCountObj.h b/ucl/inc/ucl/util/memory/IRefCountObj.h
deleted file mode 100644 (file)
index 69d6a1c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
-#define __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
-
-#include "ucl/util/types/classTypes.h"
-
-namespace ucl {
-
-       class IRefCountObj : public Polymorphic {
-       public:
-               virtual void ref() noexcept = 0;
-               virtual void unref() noexcept = 0;
-               virtual bool refNz() noexcept = 0;
-               virtual void refWeak() noexcept = 0;
-               virtual void unrefWeak() noexcept = 0;
-               virtual UInt getUseCount() const noexcept = 0;
-               virtual const void *getObjPtr() const noexcept = 0;
-       protected:
-               virtual ~IRefCountObj() = default;
-       };
-}
-
-#endif // __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
diff --git a/ucl/inc/ucl/util/memory/RefCountObj.h b/ucl/inc/ucl/util/memory/RefCountObj.h
deleted file mode 100644 (file)
index 7237aa4..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_REF_COUNT_OBJ_H__
-#define __UCL_UTIL_MEMORY_REF_COUNT_OBJ_H__
-
-#include "IRefCountObj.h"
-#include "ReffedObj.h"
-
-namespace ucl {
-
-       template <class T, class C>
-       class RefCountObj final : public IRefCountObj {
-       public:
-               template <class ...ARGS>
-               RefCountObj(ARGS &&...args);
-
-               T *getObj() noexcept;
-
-               // IRefCountObj //
-
-               virtual void ref() noexcept final override;
-               virtual void unref() noexcept final override;
-               virtual bool refNz() noexcept final override;
-               virtual void refWeak() noexcept final override;
-               virtual void unrefWeak() noexcept final override;
-               virtual UInt getUseCount() const noexcept final override;
-               virtual const void *getObjPtr() const noexcept final override;
-
-       private:
-               template <class T2, class = char[1]>
-               struct IsRefCountAware : std::false_type {};
-               template <class T2>
-               struct IsRefCountAware<T2, char[T2::_IS_REF_COUNT_AWARE * 0 + 1]> :
-                               std::true_type {};
-
-               template <class T2, class = char[1]>
-               struct IsOnUniqueAware : std::false_type {};
-               template <class T2>
-               struct IsOnUniqueAware<T2,
-                               char[T2::_ENABLE_ON_UNIQUE_CHANGED_DISPATCH * 0 + 1]> :
-                               std::true_type {};
-
-       private:
-               virtual ~RefCountObj() = default;
-
-               template <class T2, class ...ARGS, class =
-                               typename std::enable_if<!IsRefCountAware<T2>::value>::type>
-               void createObj(const P<0> &, ARGS &&...args)
-               {
-                       m_obj.create(std::forward<ARGS>(args)...);
-               }
-
-               template <class T2, class ...ARGS, class =
-                               typename std::enable_if<IsRefCountAware<T2>::value>::type>
-               auto createObj(const P<1> &, ARGS &&...args) -> decltype(
-                               ReffedObj<T>::template check<T2>(
-                                               (IRefCountObj *)0, std::forward<ARGS>(args)...))
-               {
-                       m_obj.create(static_cast<IRefCountObj *>(this),
-                                       std::forward<ARGS>(args)...);
-               }
-
-               template <class T2, class ...ARGS, class =
-                               typename std::enable_if<IsRefCountAware<T2>::value>::type>
-               auto createObj(const P<2> &, ARGS &&...args) -> decltype(
-                               ReffedObj<T>::template check<T2>(
-                                               *(IRefCountObj *)0, std::forward<ARGS>(args)...))
-               {
-                       m_obj.create(*static_cast<IRefCountObj *>(this),
-                                       std::forward<ARGS>(args)...);
-               }
-
-               void dispatchOnUniqueChanged(const bool isUnique)
-               {
-                       dispatchOnUniqueChanged<T>(P<1>(), isUnique);
-               }
-
-               template <class T2>
-               void dispatchOnUniqueChanged(...)
-               {
-               }
-
-               template <class T2, class =
-                               typename std::enable_if<IsOnUniqueAware<T2>::value>::type>
-               void dispatchOnUniqueChanged(const P<1> &, const bool isUnique)
-               {
-                       m_obj.template dispatchOnUniqueChanged<T>(isUnique);
-               }
-
-       private:
-               ReffedObj<T> m_obj;
-               C m_useCounter;
-               C m_weakCounter;
-       };
-}
-
-#include "RefCountObj.hpp"
-
-#endif // __UCL_UTIL_MEMORY_REF_COUNT_OBJ_H__
diff --git a/ucl/inc/ucl/util/memory/RefCountObj.hpp b/ucl/inc/ucl/util/memory/RefCountObj.hpp
deleted file mode 100644 (file)
index 8a2c065..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class T, class C>
-       template <class ...ARGS>
-       inline RefCountObj<T, C>::RefCountObj(ARGS &&...args) :
-               m_useCounter(1),
-               m_weakCounter(1)
-       {
-               createObj<T>(P<2>(), std::forward<ARGS>(args)...);
-       }
-
-       template <class T, class C>
-       inline T *RefCountObj<T, C>::getObj() noexcept
-       {
-               return m_obj.get();
-       }
-
-       template <class T, class C>
-       inline void RefCountObj<T, C>::ref() noexcept
-       {
-               if (m_useCounter.ref() == 2) {
-                       dispatchOnUniqueChanged(false);
-               }
-       }
-
-       template <class T, class C>
-       inline void RefCountObj<T, C>::unref() noexcept
-       {
-               const auto newCount = m_useCounter.unref();
-               if (newCount == 0) {
-                       m_obj.destroy();
-                       unrefWeak();
-               } else if (newCount == 1) {
-                       dispatchOnUniqueChanged(true);
-               }
-       }
-
-       template <class T, class C>
-       inline bool RefCountObj<T, C>::refNz() noexcept
-       {
-               const auto newCount = m_useCounter.refNz();
-               if (newCount == 0) {
-                       return false;
-               }
-               if (newCount == 2) {
-                       dispatchOnUniqueChanged(false);
-               }
-               return true;
-       }
-
-       template <class T, class C>
-       inline void RefCountObj<T, C>::refWeak() noexcept
-       {
-               m_weakCounter.ref();
-       }
-
-       template <class T, class C>
-       inline void RefCountObj<T, C>::unrefWeak() noexcept
-       {
-               if (m_weakCounter.unref() == 0) {
-                       delete this;
-               }
-       }
-
-       template <class T, class C>
-       inline UInt RefCountObj<T, C>::getUseCount() const noexcept
-       {
-               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/RefCounterMT.h b/ucl/inc/ucl/util/memory/RefCounterMT.h
deleted file mode 100644 (file)
index 1d2fb95..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_REF_COUNTER_MT_H__
-#define __UCL_UTIL_MEMORY_REF_COUNTER_MT_H__
-
-#include "ucl/util/types/baseTypes.h"
-
-namespace ucl {
-
-       class RefCounterMT final {
-       public:
-               explicit RefCounterMT(const UInt count = 0) noexcept;
-
-               UInt ref() noexcept;
-               UInt unref() noexcept;
-               UInt refNz() noexcept;
-
-               UInt get() const noexcept;
-
-       private:
-               std::atomic<UInt> m_counter;
-       };
-}
-
-#include "RefCounterMT.hpp"
-
-#endif // __UCL_UTIL_MEMORY_REF_COUNTER_MT_H__
diff --git a/ucl/inc/ucl/util/memory/RefCounterMT.hpp b/ucl/inc/ucl/util/memory/RefCounterMT.hpp
deleted file mode 100644 (file)
index 1ff459b..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline RefCounterMT::RefCounterMT(const UInt count) noexcept :
-               m_counter(count)
-       {
-       }
-
-       inline UInt RefCounterMT::ref() noexcept
-       {
-               return (m_counter.fetch_add(1, std::memory_order_acq_rel) + 1);
-       }
-
-       inline UInt RefCounterMT::unref() noexcept
-       {
-               return (m_counter.fetch_sub(1, std::memory_order_acq_rel) - 1);
-       }
-
-       inline UInt RefCounterMT::refNz() noexcept
-       {
-               auto curCount = m_counter.load(std::memory_order_relaxed);
-               for (;;) {
-                       if (curCount == 0) {
-                               return 0;
-                       }
-                       const auto newCount = (curCount + 1);
-                       if (m_counter.compare_exchange_weak(curCount, newCount,
-                                       std::memory_order_acq_rel, std::memory_order_relaxed)) {
-                               return newCount;
-                       }
-               }
-       }
-
-       inline UInt RefCounterMT::get() const noexcept
-       {
-               return m_counter.load(std::memory_order_relaxed);
-       }
-}
diff --git a/ucl/inc/ucl/util/memory/RefCounterST.h b/ucl/inc/ucl/util/memory/RefCounterST.h
deleted file mode 100644 (file)
index 30e5e35..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_REF_COUNTER_ST_H__
-#define __UCL_UTIL_MEMORY_REF_COUNTER_ST_H__
-
-#include "ucl/util/types/baseTypes.h"
-
-namespace ucl {
-
-       class RefCounterST final {
-       public:
-               explicit RefCounterST(const UInt count = 0) noexcept;
-
-               UInt ref() noexcept;
-               UInt unref() noexcept;
-               UInt refNz() noexcept;
-
-               UInt get() const noexcept;
-
-       private:
-               UInt m_counter;
-       };
-}
-
-#include "RefCounterST.hpp"
-
-#endif // __UCL_UTIL_MEMORY_REF_COUNTER_ST_H__
diff --git a/ucl/inc/ucl/util/memory/RefCounterST.hpp b/ucl/inc/ucl/util/memory/RefCounterST.hpp
deleted file mode 100644 (file)
index 45781c7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline RefCounterST::RefCounterST(const UInt count) noexcept :
-               m_counter(count)
-       {
-       }
-
-       inline UInt RefCounterST::ref() noexcept
-       {
-               return (++m_counter);
-       }
-
-       inline UInt RefCounterST::unref() noexcept
-       {
-               return (--m_counter);
-       }
-
-       inline UInt RefCounterST::refNz() noexcept
-       {
-               if (m_counter == 0) {
-                       return 0;
-               }
-               return ref();
-       }
-
-       inline UInt RefCounterST::get() const noexcept
-       {
-               return m_counter;
-       }
-}
diff --git a/ucl/inc/ucl/util/memory/ReffedObj.h b/ucl/inc/ucl/util/memory/ReffedObj.h
deleted file mode 100644 (file)
index c521544..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_REFFED_OBJ_H__
-#define __UCL_UTIL_MEMORY_REFFED_OBJ_H__
-
-#include "RefCounterST.h"
-#include "RefCounterMT.h"
-
-namespace ucl {
-
-       template <class T, class C>
-       class RefCountObj;
-
-       template <class T>
-       class ReffedObj final {
-       private:
-               friend class RefCountObj<T, RefCounterST>;
-               friend class RefCountObj<T, RefCounterMT>;
-
-               template <class ...ARGS>
-               void create(ARGS &&...args);
-               void destroy() noexcept;
-
-               T *get() noexcept;
-               const T *get() const noexcept;
-
-               template <class T2>
-               void dispatchOnUniqueChanged(bool isUnique);
-
-       private:
-               template <class T2, class ...ARGS>
-               static constexpr auto check(ARGS &&...args) -> decltype(
-                               (void)(new T2(std::forward<ARGS>(args)...)))
-               {
-                       return;
-               }
-
-       private:
-               typename std::aligned_storage<sizeof(T), alignof(T)>::type m_obj;
-       };
-}
-
-#include "ReffedObj.hpp"
-
-#endif // __UCL_UTIL_MEMORY_REFFED_OBJ_H__
diff --git a/ucl/inc/ucl/util/memory/ReffedObj.hpp b/ucl/inc/ucl/util/memory/ReffedObj.hpp
deleted file mode 100644 (file)
index cfc1e84..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class T>
-       template <class ...ARGS>
-       inline void ReffedObj<T>::create(ARGS &&...args)
-       {
-               new (get()) T(std::forward<ARGS>(args)...);
-       }
-
-       template <class T>
-       inline void ReffedObj<T>::destroy() noexcept
-       {
-               get()->~T();
-       }
-
-       template <class T>
-       inline T *ReffedObj<T>::get() noexcept
-       {
-               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)
-       {
-               get()->onUniqueChanged(isUnique);
-       }
-}
diff --git a/ucl/inc/ucl/util/memory/SharedRef.h b/ucl/inc/ucl/util/memory/SharedRef.h
deleted file mode 100644 (file)
index 396d176..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_SHARED_REF_H__
-#define __UCL_UTIL_MEMORY_SHARED_REF_H__
-
-#include "BaseRef.h"
-
-namespace ucl {
-
-       template <class T>
-       class SharedRef final : public BaseRef<T> {
-       public:
-               template <class U>
-               friend void swap(SharedRef<U> &x, SharedRef<U> &y) noexcept;
-
-               template <class T2, class U>
-               friend SharedRef<T2> staticRefCast(const SharedRef<U> &r) noexcept;
-               template <class T2, class U>
-               friend SharedRef<T2> dynamicRefCast(const SharedRef<U> &r) noexcept;
-
-       public:
-               constexpr SharedRef() noexcept;
-               constexpr SharedRef(std::nullptr_t) noexcept;
-
-               SharedRef(IRefCountObj *rc, T *ptr) noexcept;
-               SharedRef(IRefCountObj *rc, T *ptr, bool noRef) noexcept;
-
-               SharedRef(const SharedRef<T> &r) noexcept;
-               template <class U>
-               SharedRef(const SharedRef<U> &r) noexcept;
-
-               SharedRef(SharedRef<T> &&r) noexcept;
-               template <class U>
-               SharedRef(SharedRef<U> &&r) noexcept;
-
-               ~SharedRef();
-
-               SharedRef<T> &operator=(SharedRef<T> r) noexcept;
-
-               void reset() noexcept;
-
-               T *get() const noexcept;
-               operator bool() const noexcept;
-
-               T *operator->() const noexcept;
-               typename std::add_lvalue_reference<T>::type operator*() const noexcept;
-
-               template <class U, class = typename std::enable_if<
-                       std::is_convertible<T *, U *>::value && (
-                               std::is_same<typename std::remove_cv<U>::type, void>::value ||
-                               std::is_same<typename std::remove_cv<U>::type,
-                                       typename std::remove_cv<T>::type>::value)>::type>
-               operator const SharedRef<U> &() const noexcept
-               {
-                       return reinterpret_cast<const SharedRef<U> &>(*this);
-               }
-       };
-
-       // Non-member functions //
-
-       template <class T, class ...ARGS>
-       SharedRef<T> makeShared(ARGS &&...args);
-       template <class T, class ...ARGS>
-       SharedRef<T> makeSharedMT(ARGS &&...args);
-
-       template <class T, class U>
-       const SharedRef<T> &constRefCast(const SharedRef<U> &r) noexcept;
-       template <class T, class U>
-       SharedRef<T> &&constRefCast(SharedRef<U> &&r) noexcept;
-}
-
-#include "SharedRef.hpp"
-
-#endif // __UCL_UTIL_MEMORY_SHARED_REF_H__
diff --git a/ucl/inc/ucl/util/memory/SharedRef.hpp b/ucl/inc/ucl/util/memory/SharedRef.hpp
deleted file mode 100644 (file)
index f085b9c..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class T>
-       constexpr SharedRef<T>::SharedRef() noexcept
-       {
-       }
-
-       template <class T>
-       constexpr SharedRef<T>::SharedRef(std::nullptr_t) noexcept
-       {
-       }
-
-       template <class T>
-       inline SharedRef<T>::SharedRef(
-                       IRefCountObj *const rc, T *const ptr) noexcept :
-               BaseRef<T>(rc, ptr)
-       {
-               this->m_rc->ref();
-       }
-
-       template <class T>
-       inline SharedRef<T>::SharedRef(
-                       IRefCountObj *const rc, T *const ptr, bool noRef) noexcept :
-               BaseRef<T>(rc, ptr)
-       {
-       }
-
-       template <class T>
-       inline SharedRef<T>::SharedRef(const SharedRef<T> &r) noexcept :
-               BaseRef<T>(r.m_rc, r.m_ptr)
-       {
-               if (this->m_rc) {
-                       this->m_rc->ref();
-               }
-       }
-
-       template <class T>
-       template <class U>
-       inline SharedRef<T>::SharedRef(const SharedRef<U> &r) noexcept :
-               BaseRef<T>(r.m_rc, r.m_ptr)
-       {
-               if (this->m_rc) {
-                       this->m_rc->ref();
-               }
-       }
-
-       template <class T>
-       inline SharedRef<T>::SharedRef(SharedRef<T> &&r) noexcept :
-               BaseRef<T>(std::move(r))
-       {
-       }
-
-       template <class T>
-       template <class U>
-       inline SharedRef<T>::SharedRef(SharedRef<U> &&r) noexcept :
-               BaseRef<T>(std::move(r))
-       {
-       }
-
-       template <class T>
-       inline SharedRef<T>::~SharedRef()
-       {
-               if (this->m_rc) {
-                       this->m_rc->unref();
-               }
-       }
-
-       template <class T>
-       inline SharedRef<T> &SharedRef<T>::operator=(SharedRef<T> r) noexcept
-       {
-               swap(*this, r);
-               return *this;
-       }
-
-       template <class T>
-       inline void SharedRef<T>::reset() noexcept
-       {
-               *this = {};
-       }
-
-       template <class T>
-       inline T *SharedRef<T>::get() const noexcept
-       {
-               return this->m_ptr;
-       }
-
-       template <class T>
-       inline SharedRef<T>::operator bool() const noexcept
-       {
-               return !!this->m_ptr;
-       }
-
-       template <class T>
-       inline T *SharedRef<T>::operator->() const noexcept
-       {
-               return this->m_ptr;
-       }
-
-       template <class T>
-       inline typename std::add_lvalue_reference<T>::type
-                       SharedRef<T>::operator*() const noexcept
-       {
-               return *this->m_ptr;
-       }
-
-       // Non-member functions //
-
-       template <class T, class ...ARGS>
-       SharedRef<T> makeShared(ARGS &&...args)
-       {
-               const auto rc = new RefCountObj<T, RefCounterST>(
-                               std::forward<ARGS>(args)...);
-               return {rc, rc->getObj(), true};
-       }
-
-       template <class T, class ...ARGS>
-       SharedRef<T> makeSharedMT(ARGS &&...args)
-       {
-               const auto rc = new RefCountObj<T, RefCounterMT>(
-                               std::forward<ARGS>(args)...);
-               return {rc, rc->getObj(), true};
-       }
-
-       template <class T>
-       inline void swap(SharedRef<T> &x, SharedRef<T> &y) noexcept
-       {
-               std::swap(x.m_rc, y.m_rc);
-               std::swap(x.m_ptr, y.m_ptr);
-       }
-
-       template <class T, class U>
-       inline SharedRef<T> staticRefCast(const SharedRef<U> &r) noexcept
-       {
-               return {r.m_rc, static_cast<T *>(r.get())};
-       }
-
-       template <class T, class U>
-       inline SharedRef<T> dynamicRefCast(const SharedRef<U> &r) noexcept
-       {
-               const auto ptr = dynamic_cast<T *>(r.get());
-               if (!ptr) {
-                       return {};
-               }
-               return {r.m_rc, ptr};
-       }
-
-       template <class T, class U>
-       inline const SharedRef<T> &constRefCast(const SharedRef<U> &r) noexcept
-       {
-               (void)const_cast<T *>((U *)nullptr);
-               return reinterpret_cast<const SharedRef<T> &>(r);
-       }
-
-       template <class T, class U>
-       inline SharedRef<T> &&constRefCast(SharedRef<U> &&r) noexcept
-       {
-               (void)const_cast<T *>((U *)nullptr);
-               return reinterpret_cast<SharedRef<T> &&>(r);
-       }
-}
diff --git a/ucl/inc/ucl/util/memory/WeakRef.h b/ucl/inc/ucl/util/memory/WeakRef.h
deleted file mode 100644 (file)
index 4cccbe6..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_WEAK_REF_H__
-#define __UCL_UTIL_MEMORY_WEAK_REF_H__
-
-#include "SharedRef.h"
-
-namespace ucl {
-
-       template <class T>
-       class WeakRef final : public BaseRef<T> {
-       public:
-               template <class U>
-               friend void swap(WeakRef<U> &x, WeakRef<U> &y) noexcept;
-
-               template <class T2, class U>
-               friend WeakRef<T2> staticRefCast(const WeakRef<U> &r) noexcept;
-               template <class T2, class U>
-               friend WeakRef<T2> dynamicRefCast(const WeakRef<U> &r) noexcept;
-
-       public:
-               constexpr WeakRef() noexcept;
-               constexpr WeakRef(std::nullptr_t) noexcept;
-
-               WeakRef(IRefCountObj *rc, T *ptr) noexcept;
-
-               WeakRef(const WeakRef<T> &r) noexcept;
-               template <class U>
-               WeakRef(const BaseRef<U> &r) noexcept;
-
-               WeakRef(WeakRef<T> &&r) noexcept;
-               template <class U>
-               WeakRef(WeakRef<U> &&r) noexcept;
-
-               ~WeakRef();
-
-               WeakRef<T> &operator=(WeakRef<T> r) noexcept;
-
-               void reset() noexcept;
-
-               SharedRef<T> lock() const noexcept;
-
-               T *getUnsafePtr() const noexcept;
-               operator bool() const noexcept;
-
-               template <class U, class = typename std::enable_if<
-                       std::is_convertible<T *, U *>::value && (
-                               std::is_same<typename std::remove_cv<U>::type, void>::value ||
-                               std::is_same<typename std::remove_cv<U>::type,
-                                       typename std::remove_cv<T>::type>::value)>::type>
-               operator const WeakRef<U> &() const noexcept
-               {
-                       return reinterpret_cast<const WeakRef<U> &>(*this);
-               }
-       };
-
-       // Non-member functions //
-
-       template <class T>
-       WeakRef<T> makeWeak(const SharedRef<T> &r) noexcept;
-
-       template <class T, class U>
-       const WeakRef<T> &constRefCast(const WeakRef<U> &r) noexcept;
-       template <class T, class U>
-       WeakRef<T> &&constRefCast(WeakRef<U> &&r) noexcept;
-}
-
-#include "WeakRef.hpp"
-
-#endif // __UCL_UTIL_MEMORY_WEAK_REF_H__
diff --git a/ucl/inc/ucl/util/memory/WeakRef.hpp b/ucl/inc/ucl/util/memory/WeakRef.hpp
deleted file mode 100644 (file)
index 6634f3c..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class T>
-       constexpr WeakRef<T>::WeakRef() noexcept
-       {
-       }
-
-       template <class T>
-       constexpr WeakRef<T>::WeakRef(std::nullptr_t) noexcept
-       {
-       }
-
-       template <class T>
-       inline WeakRef<T>::WeakRef(
-                       IRefCountObj *const rc, T *const ptr) noexcept :
-               BaseRef<T>(rc, ptr)
-       {
-               this->m_rc->refWeak();
-       }
-
-       template <class T>
-       inline WeakRef<T>::WeakRef(const WeakRef<T> &r) noexcept :
-               BaseRef<T>(r.m_rc, r.m_ptr)
-       {
-               if (this->m_rc) {
-                       this->m_rc->refWeak();
-               }
-       }
-
-       template <class T>
-       template <class U>
-       inline WeakRef<T>::WeakRef(const BaseRef<U> &r) noexcept :
-               BaseRef<T>(r.m_rc, r.m_ptr)
-       {
-               if (this->m_rc) {
-                       this->m_rc->refWeak();
-               }
-       }
-
-       template <class T>
-       inline WeakRef<T>::WeakRef(WeakRef<T> &&r) noexcept :
-               BaseRef<T>(std::move(r))
-       {
-       }
-
-       template <class T>
-       template <class U>
-       inline WeakRef<T>::WeakRef(WeakRef<U> &&r) noexcept :
-               BaseRef<T>(std::move(r))
-       {
-       }
-
-       template <class T>
-       inline WeakRef<T>::~WeakRef()
-       {
-               if (this->m_rc) {
-                       this->m_rc->unrefWeak();
-               }
-       }
-
-       template <class T>
-       inline WeakRef<T> &WeakRef<T>::operator=(WeakRef<T> r) noexcept
-       {
-               swap(*this, r);
-               return *this;
-       }
-
-       template <class T>
-       inline void WeakRef<T>::reset() noexcept
-       {
-               *this = {};
-       }
-
-       template <class T>
-       inline SharedRef<T> WeakRef<T>::lock() const noexcept
-       {
-               if (this->m_rc && this->m_rc->refNz()) {
-                       return {this->m_rc, this->m_ptr, true};
-               }
-               return {};
-       }
-
-       template <class T>
-       inline T *WeakRef<T>::getUnsafePtr() const noexcept
-       {
-               return (operator bool() ? this->m_ptr : nullptr);
-       }
-
-       template <class T>
-       inline WeakRef<T>::operator bool() const noexcept
-       {
-               return (this->m_rc && (this->m_rc->getUseCount() > 0));
-       }
-
-       // Non-member functions //
-
-       template <class T>
-       inline WeakRef<T> makeWeak(const SharedRef<T> &r) noexcept
-       {
-               return r;
-       }
-
-       template <class T>
-       inline void swap(WeakRef<T> &x, WeakRef<T> &y) noexcept
-       {
-               std::swap(x.m_rc, y.m_rc);
-               std::swap(x.m_ptr, y.m_ptr);
-       }
-
-       template <class T, class U>
-       inline WeakRef<T> staticRefCast(const WeakRef<U> &r) noexcept
-       {
-               return {r.m_rc, static_cast<T *>(r.getUnsafePtr())};
-       }
-
-       template <class T, class U>
-       inline WeakRef<T> dynamicRefCast(const WeakRef<U> &r) noexcept
-       {
-               const auto ptr = dynamic_cast<T *>(r.getUnsafePtr());
-               if (!ptr) {
-                       return {};
-               }
-               return {r.m_rc, ptr};
-       }
-
-       template <class T, class U>
-       inline const WeakRef<T> &constRefCast(const WeakRef<U> &r) noexcept
-       {
-               (void)const_cast<T *>((U *)nullptr);
-               return reinterpret_cast<const WeakRef<T> &>(r);
-       }
-
-       template <class T, class U>
-       inline WeakRef<T> &&constRefCast(WeakRef<U> &&r) noexcept
-       {
-               (void)const_cast<T *>((U *)nullptr);
-               return reinterpret_cast<WeakRef<T> &&>(r);
-       }
-}
diff --git a/ucl/inc/ucl/util/memory/helpers.h b/ucl/inc/ucl/util/memory/helpers.h
deleted file mode 100644 (file)
index 5ce25a3..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_HELPERS_H__
-#define __UCL_UTIL_MEMORY_HELPERS_H__
-
-namespace ucl {
-
-       // Misc //
-
-       namespace util {
-
-               template <class T, class = typename std::enable_if<
-                               std::is_convertible<T *, IDisposable *>::value>::type>
-               inline void dispose(SharedRef<T> &r) noexcept
-               {
-                       if (r) {
-                               r->dispose();
-                               r.reset();
-                       }
-               }
-
-               template <class T, class = typename std::enable_if<
-                               std::is_convertible<T *, IDisposable *>::value>::type>
-               inline void dispose(WeakRef<T> &r) noexcept
-               {
-                       if (const auto shared = r.lock()) {
-                               shared->dispose();
-                               r.reset();
-                       }
-               }
-       }
-
-       // Generic casting functions //
-
-       template <class T, class U>
-       inline auto dynamicCast(const U &src) noexcept -> decltype(
-                       dynamicRefCast<typename T::Type>(src))
-       {
-               return dynamicRefCast<typename T::Type>(src);
-       }
-
-       template <class T, class U>
-       inline auto constCast(U &&src) noexcept -> decltype(
-                       constRefCast<typename T::Type>(std::forward<U>(src)))
-       {
-               return constRefCast<typename T::Type>(std::forward<U>(src));
-       }
-
-       // Relation operators //
-
-       namespace himpl {
-
-               template <class T, class = typename std::enable_if<
-                       !std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
-               inline const T &getCmpPtr(const T &ptr) noexcept
-               {
-                       return ptr;
-               }
-
-               template <class T>
-               inline T *getCmpPtr(const SharedRef<T> &r) noexcept
-               {
-                       return r.get();
-               }
-
-               template <class T>
-               inline T *getCmpPtr(const WeakRef<T> &r) noexcept
-               {
-                       return r.getUnsafePtr();
-               }
-       }
-
-       template <class T, class U, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
-               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
-       inline bool operator==(const T &lhs, const U &rhs) noexcept
-       {
-               return (himpl::getCmpPtr(lhs) == himpl::getCmpPtr(rhs));
-       }
-
-       template <class T, class U, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
-               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
-       inline bool operator!=(const T &lhs, const U &rhs) noexcept
-       {
-               return (himpl::getCmpPtr(lhs) != himpl::getCmpPtr(rhs));
-       }
-
-       template <class T, class U, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
-               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
-       inline bool operator<(const T &lhs, const U &rhs) noexcept
-       {
-               return (himpl::getCmpPtr(lhs) < himpl::getCmpPtr(rhs));
-       }
-
-       template <class T, class U, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
-               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
-       inline bool operator<=(const T &lhs, const U &rhs) noexcept
-       {
-               return (himpl::getCmpPtr(lhs) <= himpl::getCmpPtr(rhs));
-       }
-
-       template <class T, class U, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
-               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
-       inline bool operator>(const T &lhs, const U &rhs) noexcept
-       {
-               return (himpl::getCmpPtr(lhs) > himpl::getCmpPtr(rhs));
-       }
-
-       template <class T, class U, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
-               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
-       inline bool operator>=(const T &lhs, const U &rhs) noexcept
-       {
-               return (himpl::getCmpPtr(lhs) >= himpl::getCmpPtr(rhs));
-       }
-
-       template <class T, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
-       inline bool operator==(const T &lhs, std::nullptr_t rhs) noexcept
-       {
-               return !lhs;
-       }
-
-       template <class T, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
-       bool operator==(std::nullptr_t lhs, const T &rhs) noexcept
-       {
-               return !rhs;
-       }
-
-       template <class T, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
-       bool operator!=(const T &lhs, std::nullptr_t rhs) noexcept
-       {
-               return lhs;
-       }
-
-       template <class T, class = typename std::enable_if<
-               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
-       bool operator!=(std::nullptr_t lhs, const T &rhs) noexcept
-       {
-               return rhs;
-       }
-}
-
-#endif // __UCL_UTIL_MEMORY_HELPERS_H__
diff --git a/ucl/inc/ucl/util/memory/macro.h b/ucl/inc/ucl/util/memory/macro.h
deleted file mode 100644 (file)
index b97175a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_MEMORY_MACRO_H__
-#define __UCL_UTIL_MEMORY_MACRO_H__
-
-#define UCL_DECLARE_REF_ALIASES(CLASS_NAME) \
-               class CLASS_NAME; \
-               using CLASS_NAME##SRef = ::ucl::SharedRef<CLASS_NAME>; \
-               using CLASS_NAME##WRef = ::ucl::WeakRef<CLASS_NAME>; \
-               using CLASS_NAME##SCRef = ::ucl::SharedRef<const CLASS_NAME>; \
-               using CLASS_NAME##WCRef = ::ucl::WeakRef<const CLASS_NAME>
-
-#define UCL_USING_REF_ALIASES(CLASS_NAME) \
-               using CLASS_NAME; \
-               using CLASS_NAME##SRef; \
-               using CLASS_NAME##WRef; \
-               using CLASS_NAME##SCRef; \
-               using CLASS_NAME##WCRef; \
-
-#endif // __UCL_UTIL_MEMORY_MACRO_H__
diff --git a/ucl/inc/ucl/util/shortLogs.h b/ucl/inc/ucl/util/shortLogs.h
deleted file mode 100644 (file)
index 02f8bbf..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_SHORT_LOGS_H__
-#define __UCL_UTIL_SHORT_LOGS_H__
-
-#undef ULOG
-#undef URESDATALOG
-#undef URESLOG
-
-#undef VLOG
-#undef DLOG
-#undef ILOG
-#undef WLOG
-#undef ELOG
-#undef FLOG
-
-#undef VRESLOG
-#undef DRESLOG
-#undef IRESLOG
-#undef WRESLOG
-#undef ERESLOG
-#undef FRESLOG
-
-#undef RESLOG
-
-#undef RETVM_IF
-#undef RETM_IF
-
-#undef FAIL_RETURN
-#undef FAIL_RETURN_VALUE
-#undef FAIL_RETURN_VOID
-#undef FAIL_BREAK
-#undef FAIL_LOG
-
-#undef LOG_RETURN
-#undef LOG_RETURN_VALUE
-#undef LOG_RETURN_VOID
-#undef LOG_BREAK
-
-#define ULOG         UCL_ULOG
-#define URESDATALOG  UCL_URESDATALOG
-#define URESLOG      UCL_URESLOG
-
-#define VLOG  UCL_VLOG
-#define DLOG  UCL_DLOG
-#define ILOG  UCL_ILOG
-#define WLOG  UCL_WLOG
-#define ELOG  UCL_ELOG
-#define FLOG  UCL_FLOG
-
-#define VRESLOG  UCL_VRESLOG
-#define DRESLOG  UCL_DRESLOG
-#define IRESLOG  UCL_IRESLOG
-#define WRESLOG  UCL_WRESLOG
-#define ERESLOG  UCL_ERESLOG
-#define FRESLOG  UCL_FRESLOG
-
-#define RESLOG  UCL_RESLOG
-
-#define FAIL_RETURN        UCL_FAIL_RETURN
-#define FAIL_RETURN_VALUE  UCL_FAIL_RETURN_VALUE
-#define FAIL_RETURN_VOID   UCL_FAIL_RETURN_VOID
-#define FAIL_BREAK         UCL_FAIL_BREAK
-#define FAIL_LOG           UCL_FAIL_LOG
-
-#define LOG_RETURN        UCL_LOG_RETURN
-#define LOG_RETURN_VALUE  UCL_LOG_RETURN_VALUE
-#define LOG_RETURN_VOID   UCL_LOG_RETURN_VOID
-#define LOG_BREAK         UCL_LOG_BREAK
-
-#endif // __UCL_UTIL_SHORT_LOGS_H__
diff --git a/ucl/inc/ucl/util/smartDelegation.h b/ucl/inc/ucl/util/smartDelegation.h
deleted file mode 100644 (file)
index 6714411..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_SMART_DELEGATION_H__
-#define __UCL_UTIL_SMART_DELEGATION_H__
-
-#include "smartDelegation/WeakDelegate.h"
-
-#include "smartDelegation/macro.h"
-
-#if (UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H)
-#include "smartDelegation/shortMacro.h"
-#endif
-
-#endif // __UCL_UTIL_SMART_DELEGATION_H__
diff --git a/ucl/inc/ucl/util/smartDelegation/WeakDelegate.h b/ucl/inc/ucl/util/smartDelegation/WeakDelegate.h
deleted file mode 100644 (file)
index 97e1ae8..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
-#define __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
-
-#include "ucl/util/delegation.h"
-#include "ucl/util/memory.h"
-
-namespace ucl {
-
-       template <class FUNC_SIG>
-       class WeakDelegate;
-
-       template <class R, class ...ARGS>
-       class WeakDelegate<R(ARGS...)> :
-                       public BaseDelegate<R(ARGS...), WeakRef<void>> {
-       public:
-               using BaseDelegate<R(ARGS...), WeakRef<void>>::BaseDelegate;
-
-               R operator()(ARGS ...args) const;
-
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-               static WeakDelegate make(const WeakRef<CLASS> &data) noexcept;
-
-               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-               static WeakDelegate make(const WeakRef<const CLASS> &data) noexcept;
-       };
-}
-
-#include "WeakDelegate.hpp"
-
-#endif // __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
diff --git a/ucl/inc/ucl/util/smartDelegation/WeakDelegate.hpp b/ucl/inc/ucl/util/smartDelegation/WeakDelegate.hpp
deleted file mode 100644 (file)
index fa7b3f8..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       template <class R, class ...ARGS>
-       inline R WeakDelegate<R(ARGS...)>::operator()(ARGS ...args) const
-       {
-               const auto tmp = this->m_data.lock();
-               if (tmp) {
-                       return this->m_stubA(tmp.get(), std::forward<ARGS>(args)...);
-               }
-               return R();
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
-       inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
-                       const WeakRef<CLASS> &data) noexcept
-       {
-               return {data, WeakDelegate::Cb::template stubA<CLASS, METHOD>};
-       }
-
-       template <class R, class ...ARGS>
-       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
-       inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
-                       const WeakRef<const CLASS> &data) noexcept
-       {
-               return {constRefCast<CLASS>(data),
-                               WeakDelegate::Cb::template stubA<CLASS, METHOD>};
-       }
-}
diff --git a/ucl/inc/ucl/util/smartDelegation/macro.h b/ucl/inc/ucl/util/smartDelegation/macro.h
deleted file mode 100644 (file)
index b117820..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_SMART_DELEGATION_MACRO_H__
-#define __UCL_UTIL_SMART_DELEGATION_MACRO_H__
-
-#define UCL_WEAK_DELEGATE(FUNC, DATA) \
-               _UCL_DELEGATE(::ucl::WeakDelegate, FUNC, DATA)
-
-#endif // __UCL_UTIL_SMART_DELEGATION_MACRO_H__
diff --git a/ucl/inc/ucl/util/smartDelegation/shortMacro.h b/ucl/inc/ucl/util/smartDelegation/shortMacro.h
deleted file mode 100644 (file)
index ddf5e35..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
-#define __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
-
-#define WEAK_DELEGATE(FUNC, DATA) UCL_WEAK_DELEGATE(FUNC, DATA)
-
-#endif // __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
diff --git a/ucl/inc/ucl/util/threading.h b/ucl/inc/ucl/util/threading.h
deleted file mode 100644 (file)
index 4595b1b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_THREADING_H__
-#define __UCL_UTIL_THREADING_H__
-
-#include "threading/Thread.h"
-#include "threading/Mutex.h"
-#include "threading/MutexLock.h"
-#include "threading/CondVar.h"
-
-#endif // __UCL_UTIL_THREADING_H__
diff --git a/ucl/inc/ucl/util/threading/CondVar.h b/ucl/inc/ucl/util/threading/CondVar.h
deleted file mode 100644 (file)
index e73a763..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_THREADING_COND_VAR_H__
-#define __UCL_UTIL_THREADING_COND_VAR_H__
-
-#include "MutexLock.h"
-
-namespace ucl {
-
-       class CondVar final : public NonCopyable {
-       public:
-               CondVar();
-               ~CondVar();
-               void wait(MutexLock &lock);
-               void notify();
-               void notifyAll();
-               pthread_cond_t *getHandle();
-       private:
-               pthread_cond_t m_cond;
-       };
-}
-
-#include "CondVar.hpp"
-
-#endif // __UCL_UTIL_THREADING_COND_VAR_H__
diff --git a/ucl/inc/ucl/util/threading/CondVar.hpp b/ucl/inc/ucl/util/threading/CondVar.hpp
deleted file mode 100644 (file)
index 09b0ae0..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline CondVar::CondVar() :
-               m_cond()
-       {
-               pthread_cond_init(&m_cond, NULL);
-       }
-
-       inline CondVar::~CondVar()
-       {
-               pthread_cond_destroy(&m_cond);
-       }
-
-       inline void CondVar::wait(MutexLock &lock)
-       {
-               pthread_cond_wait(&m_cond, lock.getMutex().getHandle());
-       }
-
-       inline void CondVar::notify()
-       {
-               pthread_cond_signal(&m_cond);
-       }
-
-       inline void CondVar::notifyAll()
-       {
-               pthread_cond_broadcast(&m_cond);
-       }
-
-       inline pthread_cond_t *CondVar::getHandle()
-       {
-               return &m_cond;
-       }
-}
diff --git a/ucl/inc/ucl/util/threading/Mutex.h b/ucl/inc/ucl/util/threading/Mutex.h
deleted file mode 100644 (file)
index eda90ff..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_THREADING_MUTEX_H__
-#define __UCL_UTIL_THREADING_MUTEX_H__
-
-// Use pthread because Tizen 3.0 officially not support C++ 11
-// And there were problems with threading in C++ 11 and Tizen 3.0
-#include <pthread.h>
-
-#include "ucl/util/types/classTypes.h"
-
-namespace ucl {
-
-       class Mutex final : public NonCopyable {
-       public:
-               Mutex(bool recursive = false);
-               ~Mutex();
-               void lock();
-               void unlock();
-               pthread_mutex_t *getHandle();
-       private:
-               pthread_mutex_t m_mutex;
-       };
-}
-
-#include "Mutex.hpp"
-
-#endif // __UCL_UTIL_THREADING_MUTEX_H__
diff --git a/ucl/inc/ucl/util/threading/Mutex.hpp b/ucl/inc/ucl/util/threading/Mutex.hpp
deleted file mode 100644 (file)
index c3b75be..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline Mutex::Mutex(const bool recursive) :
-               m_mutex()
-       {
-               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()
-       {
-               pthread_mutex_destroy(&m_mutex);
-       }
-
-       inline void Mutex::lock()
-       {
-               pthread_mutex_lock(&m_mutex);
-       }
-
-       inline void Mutex::unlock()
-       {
-               pthread_mutex_unlock(&m_mutex);
-       }
-
-       inline pthread_mutex_t *Mutex::getHandle()
-       {
-               return &m_mutex;
-       }
-}
diff --git a/ucl/inc/ucl/util/threading/MutexLock.h b/ucl/inc/ucl/util/threading/MutexLock.h
deleted file mode 100644 (file)
index 062837f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_THREADING_MUTEX_LOCK_H__
-#define __UCL_UTIL_THREADING_MUTEX_LOCK_H__
-
-#include "Mutex.h"
-
-namespace ucl {
-
-       class MutexLock final : public NonCopyable {
-       public:
-               MutexLock(Mutex &mutex);
-               ~MutexLock();
-               Mutex &getMutex();
-       private:
-               Mutex &m_mutex;
-       };
-}
-
-#include "MutexLock.hpp"
-
-#endif // __UCL_UTIL_THREADING_MUTEX_LOCK_H__
diff --git a/ucl/inc/ucl/util/threading/MutexLock.hpp b/ucl/inc/ucl/util/threading/MutexLock.hpp
deleted file mode 100644 (file)
index a30d995..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       inline MutexLock::MutexLock(Mutex &mutex) :
-               m_mutex(mutex)
-       {
-               mutex.lock();
-       }
-
-       inline MutexLock::~MutexLock()
-       {
-               m_mutex.unlock();
-       }
-
-       inline Mutex &MutexLock::getMutex()
-       {
-               return m_mutex;
-       }
-}
diff --git a/ucl/inc/ucl/util/threading/Thread.h b/ucl/inc/ucl/util/threading/Thread.h
deleted file mode 100644 (file)
index 0839921..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_THREADING_THREAD_H__
-#define __UCL_UTIL_THREADING_THREAD_H__
-
-// Use pthread because Tizen 3.0 officially not support C++ 11
-// And there were problems with threading in C++ 11 and Tizen 3.0
-#include <pthread.h>
-
-#include "ucl/util/types/classTypes.h"
-
-namespace ucl {
-
-       class Thread final : public NonCopyable {
-       public:
-               Thread();
-               template <class FUNC>
-               explicit Thread(FUNC &&func);
-               ~Thread();
-
-               bool wasStarted() const;
-               bool wasJoinded() const;
-
-               template <class FUNC>
-               bool start(FUNC &&func);
-               void join();
-
-               pthread_t *getHandle();
-
-       private:
-               std::function<void()> m_func;
-               pthread_t m_thread;
-               bool m_wasStarted;
-               bool m_wasJoined;
-       };
-}
-
-#include "Thread.hpp"
-
-#endif // __UCL_UTIL_THREADING_THREAD_H__
diff --git a/ucl/inc/ucl/util/threading/Thread.hpp b/ucl/inc/ucl/util/threading/Thread.hpp
deleted file mode 100644 (file)
index 74259c1..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/logging.h"
-
-namespace ucl {
-
-       inline Thread::Thread() :
-               m_thread(),
-               m_wasStarted(false),
-               m_wasJoined(false)
-       {
-       }
-
-       template <class FUNC>
-       inline Thread::Thread(FUNC &&func) :
-               Thread()
-       {
-               start(func);
-       }
-
-       inline Thread::~Thread()
-       {
-               if (!m_wasJoined) {
-                       join();
-               }
-       }
-
-       inline bool Thread::wasStarted() const
-       {
-               return m_wasStarted;
-       }
-
-       inline bool Thread::wasJoinded() const
-       {
-               return m_wasJoined;
-       }
-
-       template <class FUNC>
-       inline bool Thread::start(FUNC &&func)
-       {
-               if (m_wasStarted) {
-                       UCL_WLOG("Already started!");
-                       return false;
-               }
-               m_func = std::forward<FUNC>(func);
-               const int res = pthread_create(&m_thread, NULL,
-                       [](void *data) -> void *
-                       {
-                               static_cast<Thread *>(data)->m_func();
-                               return nullptr;
-                       },
-                       this);
-               if (res != 0) {
-                       UCL_ELOG("pthread_create() failed: %d", res);
-                       m_func = {};
-                       return false;
-               }
-               m_wasStarted = true;
-               return true;
-       }
-
-       inline void Thread::join()
-       {
-               if (!m_wasStarted) {
-                       UCL_WLOG("Not stared started!");
-                       return;
-               }
-               if (m_wasJoined) {
-                       UCL_WLOG("Already joined!");
-                       return;
-               }
-               m_wasJoined = true;
-               pthread_join(m_thread, NULL);
-               m_func = {};
-       }
-
-       inline pthread_t *Thread::getHandle()
-       {
-               return ((m_wasStarted && !m_wasJoined) ? &m_thread : NULL);
-       }
-}
diff --git a/ucl/inc/ucl/util/types.h b/ucl/inc/ucl/util/types.h
deleted file mode 100644 (file)
index 70a33d3..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_TYPES_H__
-#define __UCL_UTIL_TYPES_H__
-
-#include "types/baseTypes.h"
-#include "types/classTypes.h"
-#include "types/Result.h"
-
-#endif // __UCL_UTIL_TYPES_H__
diff --git a/ucl/inc/ucl/util/types/Result.h b/ucl/inc/ucl/util/types/Result.h
deleted file mode 100644 (file)
index 099223f..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_TYPES_RESULT_H__
-#define __UCL_UTIL_TYPES_RESULT_H__
-
-#include "baseTypes.h"
-
-namespace ucl {
-
-       // ResultData declaration //
-
-       struct ResultData final {
-               const char *name;
-               int logPrio;
-       };
-
-       // Result declaration //
-
-       struct Result final {
-               int value;
-
-               Result() = default;
-
-               template <class VALUE, class = char(*)[VALUE::_UCL_RESULT * 0 + 1]>
-               constexpr Result(const VALUE &v) : value(v) {}
-       };
-
-       // Result non-member functions //
-
-       const ResultData &getResultData(Result result);
-
-       constexpr bool isGood(Result result);
-       constexpr bool isBad(Result result);
-
-       constexpr bool operator==(Result lhs, Result rhs);
-       constexpr bool operator!=(Result lhs, Result rhs);
-
-       // Basic Result values //
-
-       enum {
-               _UCL_RESULT,
-
-               RES_OK    = 0,
-               RES_FALSE = 1,
-               _RES_END,
-
-               RES_FAIL              = -1,
-               RES_INVALID_ARGUMENTS = -2,
-               RES_ILLEGAL_STATE     = -3,
-               RES_OUT_OF_MEMORY     = -4,
-               RES_IO_ERROR          = -5,
-               RES_NOT_SUPPORTED     = -6,
-               RES_INVALID_DATA      = -7,
-               RES_FATAL             = -8,
-               // TODO MUST match previous item!
-               _RES_BEGIN            = RES_FATAL
-       };
-}
-
-#include "Result.hpp"
-
-#endif // __UCL_UTIL_TYPES_RESULT_H__
diff --git a/ucl/inc/ucl/util/types/Result.hpp b/ucl/inc/ucl/util/types/Result.hpp
deleted file mode 100644 (file)
index c83db4c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace ucl {
-
-       constexpr bool isGood(const Result result)
-       {
-               return (result.value >= RES_OK);
-       }
-
-       constexpr bool isBad(const Result result)
-       {
-               return !isGood(result);
-       }
-
-       constexpr bool operator==(const Result lhs, const Result rhs)
-       {
-               return (lhs.value == rhs.value);
-       }
-
-       constexpr bool operator!=(const Result lhs, const Result rhs)
-       {
-               return (lhs.value != rhs.value);
-       }
-}
diff --git a/ucl/inc/ucl/util/types/baseTypes.h b/ucl/inc/ucl/util/types/baseTypes.h
deleted file mode 100644 (file)
index c5062db..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_TYPES_BASE_TYPES_H__
-#define __UCL_UTIL_TYPES_BASE_TYPES_H__
-
-#include <cstddef>
-#include <cstdlib>
-#include <cstdint>
-
-#include <string>
-#include <memory>
-#include <atomic>
-#include <functional>
-#include <type_traits>
-#include <utility>
-
-#include <Eina.h>
-
-#include "ucl/config.h"
-
-namespace ucl {
-       using UInt = unsigned int;
-}
-
-#endif // __UCL_UTIL_TYPES_BASE_TYPES_H__
diff --git a/ucl/inc/ucl/util/types/classTypes.h b/ucl/inc/ucl/util/types/classTypes.h
deleted file mode 100644 (file)
index 5c708d2..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_UTIL_TYPES_CLASS_TYPES_H__
-#define __UCL_UTIL_TYPES_CLASS_TYPES_H__
-
-#include "baseTypes.h"
-
-namespace ucl {
-
-       class NonCopyable {
-       public:
-               NonCopyable(const NonCopyable &) = delete;
-               NonCopyable &operator=(const NonCopyable &) = delete;
-       protected:
-               NonCopyable() = default;
-               ~NonCopyable() = default;
-       };
-
-       class Polymorphic : public NonCopyable {
-       protected:
-               Polymorphic() = default;
-               virtual ~Polymorphic() = default;
-       };
-
-       class IDisposable : public Polymorphic {
-       public:
-               virtual void dispose() = 0;
-               virtual bool isDisposed() const = 0;
-       protected:
-               virtual ~IDisposable() = default;
-       };
-
-       template <class IPRODUCT>
-       class IFactory : public Polymorphic {
-       public:
-               using IProduct = IPRODUCT;
-       public:
-               virtual IPRODUCT *newInstance() const = 0;
-       protected:
-               virtual ~IFactory() = default;
-       };
-
-       template <class PRODUCT, class IPRODUCT>
-       class Factory final : public IFactory<IPRODUCT> {
-       public:
-               using Product = PRODUCT;
-       public:
-               virtual IPRODUCT *newInstance() const final override
-               {
-                       return new PRODUCT();
-               }
-       };
-
-       // Priority selector for SFINAE functions
-       template <int N>
-       struct P : P<N - 1> {};
-       template <>
-       struct P<0> {};
-}
-
-#endif // __UCL_UTIL_TYPES_CLASS_TYPES_H__
diff --git a/ucl/include/ucl/appfw/IInstance.h b/ucl/include/ucl/appfw/IInstance.h
new file mode 100644 (file)
index 0000000..bf09205
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_I_INSTANCE_H__
+#define __UCL_APPFW_I_INSTANCE_H__
+
+#include "IInstanceContext.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(IInstance);
+
+       class IInstance : public Polymorphic {
+       public:
+               virtual Result onCreate(IInstanceContext *context) = 0;
+               virtual void onPause() = 0;
+               virtual void onResume() = 0;
+       };
+}
+
+#endif // __UCL_APPFW_I_INSTANCE_H__
diff --git a/ucl/include/ucl/appfw/IInstanceAppControlExt.h b/ucl/include/ucl/appfw/IInstanceAppControlExt.h
new file mode 100644 (file)
index 0000000..6799a84
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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_I_INSTANCE_APP_CONTROL_EXT_H__
+#define __UCL_APPFW_I_INSTANCE_APP_CONTROL_EXT_H__
+
+#include "types.h"
+
+namespace ucl {
+
+       class IInstanceAppControlExt : public Polymorphic {
+       public:
+               virtual void onAppControl(app_control_h appControl) = 0;
+       };
+}
+
+#endif // __UCL_APPFW_I_INSTANCE_APP_CONTROL_EXT_H__
diff --git a/ucl/include/ucl/appfw/IInstanceContext.h b/ucl/include/ucl/appfw/IInstanceContext.h
new file mode 100644 (file)
index 0000000..b06c177
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_I_INSTANCE_CONTEXT_H__
+#define __UCL_APPFW_I_INSTANCE_CONTEXT_H__
+
+#include "types.h"
+
+#include "ucl/gui/Window.h"
+
+namespace ucl {
+
+       class IInstanceContext : public Polymorphic {
+       public:
+               virtual AppType getAppType() const = 0;
+               virtual WindowSRef getWindow() = 0;
+               virtual void exitApp() = 0;
+       };
+}
+
+#endif // __UCL_APPFW_I_INSTANCE_CONTEXT_H__
diff --git a/ucl/include/ucl/appfw/InstanceManagerBase.h b/ucl/include/ucl/appfw/InstanceManagerBase.h
new file mode 100644 (file)
index 0000000..0fdde8c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_INSTANCE_MANAGER_BASE_H__
+#define __UCL_APPFW_INSTANCE_MANAGER_BASE_H__
+
+#include "IInstance.h"
+#include "SysEventProvider.h"
+
+namespace ucl {
+
+       class InstanceManagerBase : public Polymorphic {
+       public:
+               InstanceManagerBase(AppParams appParams);
+               virtual ~InstanceManagerBase();
+
+               const AppParams &getAppParams() const;
+
+               void setSysEventProvider(SysEventProviderUPtr provider);
+
+               virtual IInstanceSRef newInstance() const = 0;
+
+       protected:
+               SysEventProvider &getSysEventProvider() const;
+
+       private:
+               const AppParams m_appParams;
+               SysEventProviderUPtr m_sysEventProvider;
+       };
+}
+
+#endif // __UCL_APPFW_INSTANCE_MANAGER_BASE_H__
diff --git a/ucl/include/ucl/appfw/SysEventProvider.h b/ucl/include/ucl/appfw/SysEventProvider.h
new file mode 100644 (file)
index 0000000..8a72758
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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_SYS_EVENT_PROVIDER_H__
+#define __UCL_APPFW_SYS_EVENT_PROVIDER_H__
+
+#include <list>
+
+#include "types.h"
+
+namespace ucl {
+
+       class SysEventProvider;
+       using SysEventProviderUPtr = std::unique_ptr<SysEventProvider>;
+
+       class SysEventProvider final : public NonCopyable {
+       public:
+               using EventHandlerAddFunc = int (*)(app_event_handler_h *,
+                               app_event_type_e, app_event_cb, void *);
+               using EventHandlerDelFunc = int (*)(app_event_handler_h);
+
+       public:
+               SysEventProvider(EventHandlerAddFunc addFunc,
+                               EventHandlerDelFunc delFunc);
+               ~SysEventProvider();
+
+               void addEventHandler(const SysEventHandler &handler);
+               void delEventHandler(const SysEventHandler &handler);
+
+       private:
+               int addEventHandler(app_event_handler_h *handler,
+                               app_event_type_e appEvent, app_event_cb cb, void *data);
+               int delEventHandler(app_event_handler_h handler);
+
+               void dispatch(SysEvent sysEvent);
+
+       private:
+               class EventProxy;
+               using EventProxies = std::list<EventProxy>;
+
+       private:
+               const EventHandlerAddFunc m_addFunc;
+               const EventHandlerDelFunc m_delFunc;
+               EventProxies m_eventProxies;
+               Event<SysEventHandler> m_event;
+       };
+}
+
+#include "SysEventProvider.hpp"
+
+#endif // __UCL_APPFW_SYS_EVENT_PROVIDER_H__
diff --git a/ucl/include/ucl/appfw/SysEventProvider.hpp b/ucl/include/ucl/appfw/SysEventProvider.hpp
new file mode 100644 (file)
index 0000000..1d52394
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline void SysEventProvider::addEventHandler(
+                       const SysEventHandler &handler)
+       {
+               m_event += handler;
+       }
+
+       inline void SysEventProvider::delEventHandler(
+                       const SysEventHandler &handler)
+       {
+               m_event -= handler;
+       }
+}
diff --git a/ucl/include/ucl/appfw/UIApp.h b/ucl/include/ucl/appfw/UIApp.h
new file mode 100644 (file)
index 0000000..a8b4dbc
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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_UI_APP_H__
+#define __UCL_APPFW_UI_APP_H__
+
+#include "IInstanceContext.h"
+
+#include "InstanceManagerBase.h"
+
+namespace ucl {
+
+       class UIApp final : private IInstanceContext {
+       public:
+               UIApp(InstanceManagerBase &instanceMgr);
+               virtual ~UIApp();
+
+               int run(int argc, char *argv[]);
+
+       private:
+               bool onCreate();
+               void onTerminate();
+               void onPause();
+               void onResume();
+               void onAppControl(app_control_h appControl);
+
+               Result configParams();
+               Result createWindow();
+
+               void initSysEventManager();
+               Result createInstance();
+
+               // IInstanceContext //
+
+               virtual AppType getAppType() const final override;
+               virtual WindowSRef getWindow() final override;
+               virtual void exitApp() final override;
+
+       private:
+               InstanceManagerBase &m_instanceMgr;
+               WindowSRef m_window;
+               IInstanceSRef m_instance;
+       };
+}
+
+#endif // __UCL_APPFW_UI_APP_H__
diff --git a/ucl/include/ucl/appfw/helpers.h b/ucl/include/ucl/appfw/helpers.h
new file mode 100644 (file)
index 0000000..fe598d9
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_HELPERS_H__
+#define __UCL_APPFW_HELPERS_H__
+
+#include "types.h"
+
+namespace ucl {
+
+       std::string getResPath(const char *relativePath);
+}
+
+#endif // __UCL_APPFW_HELPERS_H__
diff --git a/ucl/include/ucl/appfw/types.h b/ucl/include/ucl/appfw/types.h
new file mode 100644 (file)
index 0000000..48f8adc
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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_TYPES_H__
+#define __UCL_APPFW_TYPES_H__
+
+#include <app_common.h>
+#include <app_control.h>
+
+#include "ucl/util/types.h"
+#include "ucl/util/delegation.h"
+#include "ucl/util/smartDelegation.h"
+
+#include "ucl/misc/HashMap.h"
+#include "ucl/misc/Event.h"
+#include "ucl/misc/AutoHandle.h"
+
+namespace ucl {
+
+       enum class AppType {
+               UI,
+               WIDGET,
+               WATCH
+       };
+
+       enum class AppParam {
+               BASE_SCALE,
+               ACCELERATION_PREFERENECE,
+               WINDOW_TYPE,
+               WINDOW_NAME
+       };
+
+       using AppParams = HashMap<AppParam, Variant>;
+
+       enum class SysEvent {
+               LANGUAGE_CHANGED,
+               REGION_FMT_CHANGED,
+               LOW_MEMORY,
+               LOW_BATTERY,
+               ORIENTATION_CHANGED,
+               SUSPEND_STATE_CHANGED,
+               UPDATE_REQUESTED
+       };
+
+       using SysEventHandler = WeakDelegate<void(SysEvent)>;
+
+       using AutoAppCtrl = AutoHandle<app_control_h, int, app_control_destroy>;
+}
+
+#endif // __UCL_APPFW_TYPES_H__
diff --git a/ucl/include/ucl/config.h b/ucl/include/ucl/config.h
new file mode 100644 (file)
index 0000000..584596c
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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_CONFIG_H__
+#define __UCL_CONFIG_H__
+
+#ifdef _DEBUG
+#define UCL_DEBUG
+#endif
+
+#define UCL_DEFINE_GET_UCL_RESULT_DATA 1
+
+#define UCL_LOG_LEVEL_VERBOSE 6
+#define UCL_LOG_LEVEL_DEBUG   5
+#define UCL_LOG_LEVEL_INFO    4
+#define UCL_LOG_LEVEL_WARNING 3
+#define UCL_LOG_LEVEL_ERROR   2
+#define UCL_LOG_LEVEL_FATAL   1
+
+#ifdef UCL_DEBUG
+#define UCL_MAX_LOG_LEVEL UCL_LOG_LEVEL_VERBOSE
+#else
+#define UCL_MAX_LOG_LEVEL UCL_LOG_LEVEL_INFO
+#endif
+
+#define UCL_DEFAULT_LOG_TAG "GALLERY_UCL"
+
+#define UCL_INCLUDE_DELEGATION_SHORT_MACRO_H 1
+#define UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H 1
+
+#endif // __UCL_CONFIG_H__
diff --git a/ucl/include/ucl/gui/EdjeWidget.h b/ucl/include/ucl/gui/EdjeWidget.h
new file mode 100644 (file)
index 0000000..8d045c4
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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_EDJE_WIDGET_H__
+#define __UCL_GUI_EDJE_WIDGET_H__
+
+#include "ElmWidget.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(EdjeWidget);
+
+       class EdjeWidget : public ElmWidget {
+       public:
+               void setText(const TString &value);
+               void setText(const TString &value, EdjePart part);
+
+               TString getText() const;
+               TString getText(EdjePart part) const;
+
+               void setContent(Evas_Object *content);
+               void setContent(Evas_Object *content, EdjePart part);
+               Evas_Object *unsetContent();
+               Evas_Object *unsetContent(EdjePart part);
+
+               Evas_Object *getContent() const;
+               Evas_Object *getContent(EdjePart part) const;
+
+               void emit(EdjeSignal signal, EdjeSignalSrc source =
+                               EdjeSignalSrc(""));
+
+       protected:
+               EdjeWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
+       };
+}
+
+#include "EdjeWidget.hpp"
+
+#endif // __UCL_GUI_EDJE_WIDGET_H__
diff --git a/ucl/include/ucl/gui/EdjeWidget.hpp b/ucl/include/ucl/gui/EdjeWidget.hpp
new file mode 100644 (file)
index 0000000..3f989c7
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline EdjeWidget::EdjeWidget(IRefCountObj *const rc,
+                       Evas_Object *const eo, const bool isOwner) :
+               ElmWidget(rc, eo, isOwner)
+       {
+       }
+
+       inline TString EdjeWidget::getText() const
+       {
+               return elm_object_text_get(getEo());
+       }
+
+       inline TString EdjeWidget::getText(const EdjePart part) const
+       {
+               return elm_object_part_text_get(getEo(), part.name);
+       }
+
+       inline void EdjeWidget::setContent(Evas_Object *const content)
+       {
+               elm_object_content_set(getEo(), content);
+       }
+
+       inline void EdjeWidget::setContent(Evas_Object *const content,
+                       const EdjePart part)
+       {
+               elm_object_part_content_set(getEo(), part.name, content);
+       }
+
+       inline Evas_Object *EdjeWidget::unsetContent()
+       {
+               return elm_object_content_unset(getEo());
+       }
+
+       inline Evas_Object *EdjeWidget::unsetContent(const EdjePart part)
+       {
+               return elm_object_part_content_unset(getEo(), part.name);
+       }
+
+       inline Evas_Object *EdjeWidget::getContent() const
+       {
+               return elm_object_content_get(getEo());
+       }
+
+       inline Evas_Object *EdjeWidget::getContent(const EdjePart part) const
+       {
+               return elm_object_part_content_get(getEo(), part.name);
+       }
+
+       inline void EdjeWidget::emit(const EdjeSignal signal,
+                       const EdjeSignalSrc source)
+       {
+               elm_object_signal_emit(getEo(), signal.name, source.name);
+       }
+}
diff --git a/ucl/include/ucl/gui/ElmWidget.h b/ucl/include/ucl/gui/ElmWidget.h
new file mode 100644 (file)
index 0000000..f967cc3
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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_ELM_WIDGET_H__
+#define __UCL_GUI_ELM_WIDGET_H__
+
+#include "Widget.h"
+
+#define UCL_SMART_FWD_ATSPI UCL_SMART_FWD "atspi,"
+
+namespace ucl {
+
+       constexpr SmartEvent ATSPI_ON_GESTURE {UCL_SMART_FWD_ATSPI "gesture"};
+
+       class Window;
+
+       UCL_DECLARE_REF_ALIASES(ElmWidget);
+
+       class ElmWidget : public Widget {
+       public:
+               explicit ElmWidget(Evas_Object *eo, bool isOwner = true);
+               virtual ~ElmWidget();
+
+               void setEnabled(bool value);
+               bool isEnabled() const;
+
+               void setFocusAlowed(bool value);
+               bool isFocusAlowed() const;
+
+               void setTheme(Elm_Theme *th);
+               Elm_Theme *getTheme();
+
+               Evas_Object *getTopWidget() const;
+               Window *getWindow() const;
+
+       protected:
+               friend class ReffedObj<ElmWidget>;
+               ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
+
+               virtual void setFocusedImpl(bool value) final override;
+               virtual bool isFocusedImpl() const final override;
+               virtual bool ensureFwdEvent(SmartEvent fwdEvent) override;
+
+       private:
+               Eina_Bool onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
+                                       Evas_Object *obj);
+
+       private:
+               bool m_isAtspiGestureCbSet;
+       };
+
+       // Non-member functions //
+
+       void enable(ElmWidget &widget);
+       void disable(ElmWidget &widget);
+}
+
+#include "ElmWidget.hpp"
+
+#endif // __UCL_GUI_ELM_WIDGET_H__
diff --git a/ucl/include/ucl/gui/ElmWidget.hpp b/ucl/include/ucl/gui/ElmWidget.hpp
new file mode 100644 (file)
index 0000000..0673a57
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline ElmWidget::ElmWidget(Evas_Object *const eo, const bool isOwner) :
+               ElmWidget(nullptr, eo, isOwner)
+       {
+       }
+
+       inline void ElmWidget::setEnabled(const bool value)
+       {
+               elm_object_disabled_set(getEo(), toEina(!value));
+       }
+
+       inline bool ElmWidget::isEnabled() const
+       {
+               return !elm_object_disabled_get(getEo());
+       }
+
+       inline void ElmWidget::setFocusAlowed(const bool value)
+       {
+               elm_object_focus_allow_set(getEo(), toEina(value));
+       }
+
+       inline bool ElmWidget::isFocusAlowed() const
+       {
+               return elm_object_focus_allow_get(getEo());
+       }
+
+       inline void ElmWidget::setTheme(Elm_Theme *th)
+       {
+               elm_object_theme_set(getEo(), th);
+       }
+
+       inline Elm_Theme *ElmWidget::getTheme()
+       {
+               return elm_object_theme_get(getEo());
+       }
+
+       inline Evas_Object *ElmWidget::getTopWidget() const
+       {
+               return elm_object_top_widget_get(getEo());
+       }
+
+       // Non-member functions //
+
+       inline void enable(ElmWidget &widget)
+       {
+               widget.setEnabled(true);
+       }
+
+       inline void disable(ElmWidget &widget)
+       {
+               widget.setEnabled(false);
+       }
+}
diff --git a/ucl/include/ucl/gui/Genlist.h b/ucl/include/ucl/gui/Genlist.h
new file mode 100644 (file)
index 0000000..366eccf
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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_GENLIST_H__
+#define __UCL_GUI_GENLIST_H__
+
+#include "StyledWidget.h"
+#include "GenlistItem.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(Genlist);
+
+       class Genlist final : public StyledWidget {
+       public:
+               enum class Mode {
+                       COMPRESS = ELM_LIST_COMPRESS,
+                       SCROLL = ELM_LIST_SCROLL,
+                       LIMIT = ELM_LIST_LIMIT,
+                       EXPAND = ELM_LIST_EXPAND
+               };
+
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setStyle(ElmStyle style);
+                       Builder &setMode(Mode mode);
+                       Builder &setHomogeneous(bool value);
+                       Builder &setIsOwner(bool value);
+                       Builder &setNeedBindToEo(bool value);
+                       GenlistSRef build(ElmWidget &parent) const;
+               private:
+                       ElmStyle m_style;
+                       Mode m_mode;
+                       bool m_isHomogeneous;
+                       bool m_isOwner;
+                       bool m_needBindToEo;
+               };
+
+       public:
+               friend class ReffedObj<Genlist>;
+               using StyledWidget::StyledWidget;
+
+               void setMode(Mode mode);
+               Mode getMode() const;
+
+               void setHomogeneous(bool isHomogeneous);
+               bool isHomogeneous() const;
+
+               void updateRealizedItems();
+               void clear();
+
+               GenlistItem append(const Elm_Genlist_Item_Class *itc,
+                               const void *data, SmartCbHandler onSelect = nullptr,
+                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+                               GenlistItem parent = nullptr);
+
+               GenlistItem prepend(const Elm_Genlist_Item_Class *itc,
+                               const void *data, SmartCbHandler onSelect = nullptr,
+                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+                               GenlistItem parent = nullptr);
+
+               GenlistItem insertAfter(GenlistItem after,
+                               const Elm_Genlist_Item_Class *itc, const void *data,
+                               SmartCbHandler onSelect = nullptr,
+                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+                               GenlistItem parent = nullptr);
+
+               GenlistItem insertBefore(GenlistItem before,
+                               const Elm_Genlist_Item_Class *itc, const void *data,
+                               SmartCbHandler onSelect = nullptr,
+                               GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+                               GenlistItem parent = nullptr);
+       };
+}
+
+#include "Genlist.hpp"
+
+#endif // __UCL_GUI_GENLIST_H__
diff --git a/ucl/include/ucl/gui/Genlist.hpp b/ucl/include/ucl/gui/Genlist.hpp
new file mode 100644 (file)
index 0000000..3c93031
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       // Genlist::Builder //
+
+       inline Genlist::Builder::Builder() :
+               m_mode(Mode::COMPRESS),
+               m_isHomogeneous(true),
+               m_isOwner(true),
+               m_needBindToEo(false)
+       {
+       }
+
+       inline Genlist::Builder &Genlist::Builder::setStyle(const ElmStyle style)
+       {
+               m_style = style;
+               return *this;
+       }
+
+       inline Genlist::Builder &Genlist::Builder::setMode(const Mode mode)
+       {
+               m_mode = mode;
+               return *this;
+       }
+
+       inline Genlist::Builder &Genlist::Builder::setHomogeneous(const bool value)
+       {
+               m_isHomogeneous = value;
+               return *this;
+       }
+
+       inline Genlist::Builder &Genlist::Builder::setIsOwner(const bool value)
+       {
+               m_isOwner = value;
+               return *this;
+       }
+
+       inline Genlist::Builder &Genlist::Builder::setNeedBindToEo(const bool value)
+       {
+               m_needBindToEo = value;
+               return *this;
+       }
+
+       // Genlist //
+
+       inline void Genlist::setMode(const Mode mode)
+       {
+               elm_genlist_mode_set(getEo(), static_cast<Elm_List_Mode>(mode));
+       }
+
+       inline Genlist::Mode Genlist::getMode() const
+       {
+               return static_cast<Mode>(elm_genlist_mode_get(getEo()));
+       }
+
+       inline void Genlist::setHomogeneous(const bool isHomogeneous)
+       {
+               elm_genlist_homogeneous_set(getEo(), toEina(isHomogeneous));
+       }
+
+       inline bool Genlist::isHomogeneous() const
+       {
+               return elm_genlist_homogeneous_get(getEo());
+       }
+
+       inline void Genlist::updateRealizedItems()
+       {
+               elm_genlist_realized_items_update(getEo());
+       }
+
+       inline void Genlist::clear()
+       {
+               elm_genlist_clear(getEo());
+       }
+
+       inline GenlistItem Genlist::append(const Elm_Genlist_Item_Class *const itc,
+                       const void *const data, const SmartCbHandler onSelect,
+                       const GenlistItem::Type type, const GenlistItem parent)
+       {
+               return GenlistItem(elm_genlist_item_append(
+                               getEo(), itc, data, parent,
+                               static_cast<Elm_Genlist_Item_Type>(type),
+                               onSelect.getStubA(), onSelect.getData()));
+       }
+
+       inline GenlistItem Genlist::prepend(const Elm_Genlist_Item_Class *const itc,
+                       const void *const data, SmartCbHandler onSelect,
+                       const GenlistItem::Type type, const GenlistItem parent)
+       {
+               return GenlistItem(elm_genlist_item_prepend(
+                               getEo(), itc, data, parent,
+                               static_cast<Elm_Genlist_Item_Type>(type),
+                               onSelect.getStubA(), onSelect.getData()));
+       }
+
+       inline GenlistItem Genlist::insertAfter(const GenlistItem after,
+                       const Elm_Genlist_Item_Class *const itc, const void *const data,
+                       const SmartCbHandler onSelect, const GenlistItem::Type type,
+                       const GenlistItem parent)
+       {
+               return GenlistItem(elm_genlist_item_insert_after(
+                               getEo(), itc, data, parent, after,
+                               static_cast<Elm_Genlist_Item_Type>(type),
+                               onSelect.getStubA(), onSelect.getData()));
+       }
+
+       inline GenlistItem Genlist::insertBefore(const GenlistItem before,
+                       const Elm_Genlist_Item_Class *itc, const void *data,
+                       const SmartCbHandler onSelect, const GenlistItem::Type type,
+                       const GenlistItem parent)
+       {
+               return GenlistItem(elm_genlist_item_insert_before(
+                               getEo(), itc, data, parent, before,
+                               static_cast<Elm_Genlist_Item_Type>(type),
+                               onSelect.getStubA(), onSelect.getData()));
+       }
+}
diff --git a/ucl/include/ucl/gui/GenlistItem.h b/ucl/include/ucl/gui/GenlistItem.h
new file mode 100644 (file)
index 0000000..2c96b9c
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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_GENLIST_ITEM_H__
+#define __UCL_GUI_GENLIST_ITEM_H__
+
+#include "WidgetItem.h"
+
+namespace ucl {
+
+       class GenlistItem final : public WidgetItem {
+       public:
+               enum class Type {
+                       SIMPLE = ELM_GENLIST_ITEM_NONE,
+                       TREE = ELM_GENLIST_ITEM_TREE,
+                       GROUP = ELM_GENLIST_ITEM_GROUP
+               };
+
+               enum class SelectMode {
+                       DEFAULT = ELM_OBJECT_SELECT_MODE_DEFAULT,
+                       ALWAYS = ELM_OBJECT_SELECT_MODE_ALWAYS,
+                       NONE = ELM_OBJECT_SELECT_MODE_NONE,
+                       DISPLAY_ONLY = ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY
+               };
+
+               enum {
+                       FIELD_ALL = ELM_GENLIST_ITEM_FIELD_ALL,
+                       FIELD_TEXT = ELM_GENLIST_ITEM_FIELD_TEXT,
+                       FIELD_CONTENT = ELM_GENLIST_ITEM_FIELD_CONTENT,
+                       FIELD_STATE = ELM_GENLIST_ITEM_FIELD_STATE,
+               };
+
+       public:
+               using WidgetItem::WidgetItem;
+
+               void setSelectMode(SelectMode mode) const;
+               SelectMode getSelectMode() const;
+
+               void setSelected(bool isSelected) const;
+               bool isSelected() const;
+
+               void update() const;
+               void update(const Elm_Genlist_Item_Class *newItc) const;
+               void update(const char *parts, int fields = FIELD_ALL) const;
+       };
+}
+
+#include "GenlistItem.hpp"
+
+#endif // __UCL_GUI_GENLIST_ITEM_H__
diff --git a/ucl/include/ucl/gui/GenlistItem.hpp b/ucl/include/ucl/gui/GenlistItem.hpp
new file mode 100644 (file)
index 0000000..6920a88
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline void GenlistItem::setSelectMode(const SelectMode mode) const
+       {
+               elm_genlist_item_select_mode_set(getIt(),
+                               static_cast<Elm_Object_Select_Mode>(mode));
+       }
+
+       inline GenlistItem::SelectMode GenlistItem::getSelectMode() const
+       {
+               return static_cast<GenlistItem::SelectMode>(
+                               elm_genlist_item_select_mode_get(getIt()));
+       }
+
+       inline void GenlistItem::setSelected(const bool isSelected) const
+       {
+               elm_genlist_item_selected_set(getIt(), toEina(isSelected));
+       }
+
+       inline bool GenlistItem::isSelected() const
+       {
+               return elm_genlist_item_selected_get(getIt());
+       }
+
+       inline void GenlistItem::update() const
+       {
+               elm_genlist_item_update(getIt());
+       }
+
+       inline void GenlistItem::update(
+                       const Elm_Genlist_Item_Class *const newItc) const
+       {
+               elm_genlist_item_item_class_update(getIt(), newItc);
+       }
+
+       inline void GenlistItem::update(
+                       const char *const parts, const int fields) const
+       {
+               elm_genlist_item_fields_update(getIt(), parts,
+                               static_cast<Elm_Genlist_Item_Field_Type>(fields));
+       }
+}
diff --git a/ucl/include/ucl/gui/Layout.h b/ucl/include/ucl/gui/Layout.h
new file mode 100644 (file)
index 0000000..d349f92
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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_LAYOUT_H__
+#define __UCL_GUI_LAYOUT_H__
+
+#include "EdjeWidget.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(Layout);
+
+       class Layout : public EdjeWidget {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setTheme(const LayoutTheme &value);
+                       Builder &setEdjeFile(std::string filePath, EdjeGroup group);
+                       Builder &setIsOwner(bool value);
+                       Builder &setNeedBindToEo(bool value);
+                       LayoutSRef build(ElmWidget &parent) const;
+               private:
+                       LayoutTheme m_theme;
+                       std::string m_edjeFilePath;
+                       EdjeGroup m_edjeGroup;
+                       bool m_isOwner;
+                       bool m_needBindToEo;
+               };
+
+       public:
+               friend class ReffedObj<Layout>;
+               using EdjeWidget::EdjeWidget;
+               explicit Layout(Evas_Object *eo, bool isOwner = true);
+
+               bool setTheme(const LayoutTheme &theme);
+               bool setEdjeFile(const std::string &filePath, EdjeGroup group);
+
+               Variant getData(EdjeDataKey key);
+       };
+}
+
+#include "Layout.hpp"
+
+#endif // __UCL_GUI_LAYOUT_H__
diff --git a/ucl/include/ucl/gui/Layout.hpp b/ucl/include/ucl/gui/Layout.hpp
new file mode 100644 (file)
index 0000000..d6d18a3
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       // Layout::Builder //
+
+       inline Layout::Builder::Builder() :
+               m_isOwner(true),
+               m_needBindToEo(false)
+       {
+       }
+
+       inline Layout::Builder &Layout::Builder::setTheme(const LayoutTheme &theme)
+       {
+               m_theme = theme;
+               return *this;
+       }
+
+       inline Layout::Builder &Layout::Builder::setEdjeFile(
+                       std::string filePath, const EdjeGroup group)
+       {
+               m_edjeFilePath = std::move(filePath);
+               m_edjeGroup = group;
+               return *this;
+       }
+
+       inline Layout::Builder &Layout::Builder::setIsOwner(const bool value)
+       {
+               m_isOwner = value;
+               return *this;
+       }
+
+       inline Layout::Builder &Layout::Builder::setNeedBindToEo(const bool value)
+       {
+               m_needBindToEo = value;
+               return *this;
+       }
+
+       // Layout //
+
+       inline Layout::Layout(Evas_Object *const eo, const bool isOwner) :
+               EdjeWidget(nullptr, eo, isOwner)
+       {
+       }
+
+       inline bool Layout::setTheme(const LayoutTheme &theme)
+       {
+               return elm_layout_theme_set(getEo(),
+                               theme.klass, theme.group, theme.style);
+       }
+
+       inline bool Layout::setEdjeFile(const std::string &filePath,
+                       const EdjeGroup group)
+       {
+               return elm_layout_file_set(getEo(), filePath.c_str(), group.name);
+       }
+
+       inline Variant Layout::getData(EdjeDataKey key)
+       {
+               return elm_layout_data_get(getEo(), key);
+       }
+}
diff --git a/ucl/include/ucl/gui/NaviItem.h b/ucl/include/ucl/gui/NaviItem.h
new file mode 100644 (file)
index 0000000..1161847
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_NAVI_ITEM_H__
+#define __UCL_GUI_NAVI_ITEM_H__
+
+#include "WidgetItem.h"
+
+namespace ucl {
+
+       class NaviItem final : public WidgetItem {
+       public:
+               using PopHandler = Delegate<Eina_Bool(Elm_Object_Item *)>;
+
+       public:
+               using WidgetItem::WidgetItem;
+
+               void setPopHandler(const PopHandler &handler) const;
+
+               void popTo() const;
+               void promote() const;
+
+               void setTitleEnabled(bool value, bool useTransition = false) const;
+               bool isTitleEnabled() const;
+
+               void setTitle(const TString &title) const;
+       };
+}
+
+#include "NaviItem.hpp"
+
+#endif // __UCL_GUI_NAVI_ITEM_H__
diff --git a/ucl/include/ucl/gui/NaviItem.hpp b/ucl/include/ucl/gui/NaviItem.hpp
new file mode 100644 (file)
index 0000000..6b33fe4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline void NaviItem::setPopHandler(const PopHandler &handler) const
+       {
+               elm_naviframe_item_pop_cb_set(getIt(),
+                               handler.getStubA(), handler.getData());
+       }
+
+       inline void NaviItem::setTitleEnabled(
+                       const bool value, const bool useTransition) const
+       {
+               elm_naviframe_item_title_enabled_set(getIt(),
+                               toEina(value), toEina(useTransition));
+       }
+
+       inline bool NaviItem::isTitleEnabled() const
+       {
+               return elm_naviframe_item_title_enabled_get(getIt());
+       }
+
+       inline void NaviItem::setTitle(const TString &title) const
+       {
+               if (isEmpty(title)) {
+                       setTitleEnabled(false);
+               } else {
+                       setText(title);
+                       setTitleEnabled(true);
+               }
+       }
+}
diff --git a/ucl/include/ucl/gui/Naviframe.h b/ucl/include/ucl/gui/Naviframe.h
new file mode 100644 (file)
index 0000000..66693f2
--- /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.
+ */
+
+#ifndef __UCL_GUI_NAVIFRAME_H__
+#define __UCL_GUI_NAVIFRAME_H__
+
+#include <vector>
+
+#include "StyledWidget.h"
+#include "NaviItem.h"
+
+namespace ucl {
+
+       constexpr SmartEvent NAVI_TRANSITION_STARTED {"ucl,transition,started"};
+       constexpr SmartEvent NAVI_TRANSITION_FINISHED {"transition,finished"};
+
+       UCL_DECLARE_REF_ALIASES(Naviframe);
+
+       class Naviframe final : public StyledWidget {
+       public:
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setStyle(ElmStyle value);
+                       Builder &setNeedBindToEo(bool value);
+                       NaviframeSRef build(ElmWidget &parent) const;
+               private:
+                       ElmStyle m_style;
+                       bool m_needBindToEo;
+               };
+
+       public:
+               void setInTransition(bool inTransition);
+               bool isInTransition() const;
+
+               void setAutoBackBtn(bool value);
+               bool isAutoBackBtn() const;
+
+               void setPreservePop(bool value);
+               bool isPreservePop() const;
+
+               void setEventsEnabledOnTransition(bool value);
+               bool isEventsEnabledOnTransition() const;
+
+               Evas_Object *pop();
+
+               NaviItem push(const TString &title,
+                               Evas_Object *backBtn, Evas_Object *moreBtn,
+                               Evas_Object *content, ElmStyle style = nullptr);
+               NaviItem push(const TString &title,
+                               Evas_Object *content, ElmStyle style = nullptr);
+               NaviItem push(Evas_Object *content, ElmStyle style = nullptr);
+
+               NaviItem insertAfter(NaviItem after, const TString &title,
+                               Evas_Object *backBtn, Evas_Object *moreBtn,
+                               Evas_Object *content, ElmStyle style = nullptr);
+               NaviItem insertAfter(NaviItem after, const TString &title,
+                               Evas_Object *content, ElmStyle style = nullptr);
+               NaviItem insertAfter(NaviItem after,
+                               Evas_Object *content, ElmStyle style = nullptr);
+
+               NaviItem insertBefore(NaviItem before, const TString &title,
+                               Evas_Object *backBtn, Evas_Object *moreBtn,
+                               Evas_Object *content, ElmStyle style = nullptr);
+               NaviItem insertBefore(NaviItem before, const TString &title,
+                               Evas_Object *content, ElmStyle style = nullptr);
+               NaviItem insertBefore(NaviItem before,
+                               Evas_Object *content, ElmStyle style = nullptr);
+
+               NaviItem getTopItem()const;
+               NaviItem getBottomItem() const;
+               std::vector<NaviItem> getItems() const;
+
+       private:
+               friend class ReffedObj<Naviframe>;
+               Naviframe(IRefCountObj &rc, Evas_Object *eo);
+
+               void onTransitionFinished(Widget &widget, void *eventInfo);
+
+       private:
+               bool m_isInTransition;
+       };
+}
+
+#include "Naviframe.hpp"
+
+#endif // __UCL_GUI_NAVIFRAME_H__
diff --git a/ucl/include/ucl/gui/Naviframe.hpp b/ucl/include/ucl/gui/Naviframe.hpp
new file mode 100644 (file)
index 0000000..e8fdc19
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       // Naviframe::Builder //
+
+       inline Naviframe::Builder::Builder() :
+               m_needBindToEo(true)
+       {
+       }
+
+       inline Naviframe::Builder &Naviframe::Builder::setStyle(
+                       const ElmStyle value)
+       {
+               m_style = value;
+               return *this;
+       }
+
+       inline Naviframe::Builder &Naviframe::Builder::setNeedBindToEo(
+                       const bool value)
+       {
+               m_needBindToEo = value;
+               return *this;
+       }
+
+       // Naviframe //
+
+       inline bool Naviframe::isInTransition() const
+       {
+               return m_isInTransition;
+       }
+
+       inline void Naviframe::setAutoBackBtn(const bool value)
+       {
+               elm_naviframe_prev_btn_auto_pushed_set(getEo(), toEina(value));
+       }
+
+       inline bool Naviframe::isAutoBackBtn() const
+       {
+               return elm_naviframe_prev_btn_auto_pushed_get(getEo());
+       }
+
+       inline void Naviframe::setPreservePop(const bool value)
+       {
+               elm_naviframe_content_preserve_on_pop_set(getEo(), toEina(value));
+       }
+
+       inline bool Naviframe::isPreservePop() const
+       {
+               return elm_naviframe_content_preserve_on_pop_get(getEo());
+       }
+
+       inline void Naviframe::setEventsEnabledOnTransition(const bool value)
+       {
+               elm_naviframe_event_enabled_set(getEo(), toEina(value));
+       }
+
+       inline bool Naviframe::isEventsEnabledOnTransition() const
+       {
+               return elm_naviframe_event_enabled_get(getEo());
+       }
+
+       inline Evas_Object *Naviframe::pop()
+       {
+               auto result = elm_naviframe_item_pop(getEo());
+               if (getBottomItem()) {
+                       setInTransition(true);
+               }
+               return result;
+       }
+
+       inline NaviItem Naviframe::push(const TString &title,
+                       Evas_Object *const backBtn, Evas_Object *const moreBtn,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               auto result = NaviItem(elm_naviframe_item_push(getEo(),
+                               nullptr, backBtn, moreBtn, content, style.name));
+               result.setTitle(title);
+               if (result != getBottomItem()) {
+                       setInTransition(true);
+               }
+               return result;
+       }
+
+       inline NaviItem Naviframe::push(const TString &title,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               return push(title, nullptr, nullptr, content, style);
+       }
+
+       inline NaviItem Naviframe::push(
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               return push(nullptr, nullptr, nullptr, content, style);
+       }
+
+       inline NaviItem Naviframe::insertAfter(NaviItem after,
+                       const TString &title,
+                       Evas_Object *const backBtn, Evas_Object *const moreBtn,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               auto result = NaviItem(elm_naviframe_item_insert_after(getEo(),
+                               after, nullptr, backBtn, moreBtn, content, style.name));
+               result.setTitle(title);
+               return result;
+       }
+
+       inline NaviItem Naviframe::insertAfter(NaviItem after,
+                       const TString &title,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               return insertAfter(after, title, nullptr, nullptr, content, style);
+       }
+
+       inline NaviItem Naviframe::insertAfter(NaviItem after,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               return insertAfter(after, nullptr, nullptr, nullptr, content, style);
+       }
+
+       inline NaviItem Naviframe::insertBefore(NaviItem before,
+                       const TString &title,
+                       Evas_Object *const backBtn, Evas_Object *const moreBtn,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               auto result = NaviItem(elm_naviframe_item_insert_before(getEo(),
+                               before, nullptr, backBtn, moreBtn, content, style.name));
+               result.setTitle(title);
+               return result;
+       }
+
+       inline NaviItem Naviframe::insertBefore(NaviItem before,
+                       const TString &title,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               return insertAfter(before, title, nullptr, nullptr, content, style);
+       }
+
+       inline NaviItem Naviframe::insertBefore(NaviItem before,
+                       Evas_Object *const content, const ElmStyle style)
+       {
+               return insertAfter(before, nullptr, nullptr, nullptr, content, style);
+       }
+
+       inline NaviItem Naviframe::getTopItem()const
+       {
+               return NaviItem(elm_naviframe_top_item_get(getEo()));
+       }
+
+       inline NaviItem Naviframe::getBottomItem() const
+       {
+               return NaviItem(elm_naviframe_bottom_item_get(getEo()));
+       }
+
+       inline std::vector<NaviItem> Naviframe::getItems() const
+       {
+               std::vector<NaviItem> result;
+
+               Eina_List *const items = elm_naviframe_items_get(getEo());
+               Eina_List *l = nullptr;
+               void *data = nullptr;
+
+               EINA_LIST_FOREACH(items, l, data) {
+                       result.emplace_back(static_cast<Elm_Object_Item *>(data));
+               }
+
+               eina_list_free(items);
+
+               return result;
+       }
+}
diff --git a/ucl/include/ucl/gui/StyledWidget.h b/ucl/include/ucl/gui/StyledWidget.h
new file mode 100644 (file)
index 0000000..223a293
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_GUI_STYLED_WIDGET_H__
+#define __UCL_GUI_STYLED_WIDGET_H__
+
+#include "EdjeWidget.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(StyledWidget);
+
+       class StyledWidget : public EdjeWidget {
+       public:
+               friend class ReffedObj<StyledWidget>;
+               using EdjeWidget::EdjeWidget;
+               explicit StyledWidget(Evas_Object *eo, bool isOwner = true);
+
+               void setStyle(ElmStyle style);
+       };
+}
+
+#include "StyledWidget.hpp"
+
+#endif // __UCL_GUI_STYLED_WIDGET_H__
diff --git a/ucl/include/ucl/gui/StyledWidget.hpp b/ucl/include/ucl/gui/StyledWidget.hpp
new file mode 100644 (file)
index 0000000..cb32329
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline StyledWidget::StyledWidget(
+                       Evas_Object *const eo, const bool isOwner) :
+               EdjeWidget(nullptr, eo, isOwner)
+       {
+       }
+
+       inline void StyledWidget::setStyle(const ElmStyle style)
+       {
+               elm_object_style_set(getEo(), style.name);
+       }
+}
diff --git a/ucl/include/ucl/gui/Theme.h b/ucl/include/ucl/gui/Theme.h
new file mode 100644 (file)
index 0000000..d8b5b31
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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_THEME_H__
+#define __UCL_GUI_THEME_H__
+
+#include "types.h"
+
+namespace ucl {
+
+       class Theme final : NonCopyable {
+       public:
+               static Theme create();
+
+               friend void swap(Theme &x, Theme &y);
+
+       public:
+               Theme();
+               Theme(std::nullptr_t);
+               explicit Theme(Elm_Theme *th, bool isOwner = false);
+               Theme(Theme &&tmp);
+               Theme &operator=(Theme &&tmp);
+               ~Theme();
+
+               Elm_Theme *getTh();
+               const Elm_Theme *getTh() const;
+
+               operator Elm_Theme *();
+               operator const Elm_Theme *() const;
+
+               void addExtension(const std::string edjePath);
+               void addOverlay(const std::string edjePath);
+
+       private:
+               Elm_Theme *m_th;
+               bool m_isOwner;
+       };
+
+       // Non-member functions //
+
+       bool isValid(const Theme &item);
+}
+
+#include "Theme.hpp"
+
+#endif // __UCL_GUI_THEME_H__
diff --git a/ucl/include/ucl/gui/Theme.hpp b/ucl/include/ucl/gui/Theme.hpp
new file mode 100644 (file)
index 0000000..65910df
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline Theme Theme::create()
+       {
+               Elm_Theme *const th = elm_theme_new();
+               if (th) {
+                       elm_theme_ref_set(th, nullptr);
+               }
+               return Theme(th, true);
+       }
+
+       inline Theme::Theme() :
+               m_th(nullptr),
+               m_isOwner(false)
+       {
+       }
+
+       inline Theme::Theme(std::nullptr_t) :
+               Theme()
+       {
+       }
+
+       inline Theme::Theme(Elm_Theme *const th, const bool isOwner) :
+               m_th(th),
+               m_isOwner(isOwner)
+       {
+       }
+
+       inline Theme::Theme(Theme &&tmp)
+       {
+               m_th = tmp.m_th;
+               tmp.m_th = nullptr;
+       }
+
+       inline Theme &Theme::operator=(Theme &&tmp)
+       {
+               swap(*this, tmp);
+               return *this;
+       }
+
+       inline Theme::~Theme()
+       {
+               if (m_isOwner && m_th) {
+                       elm_theme_free(m_th);
+               }
+       }
+
+       inline Elm_Theme *Theme::getTh()
+       {
+               return m_th;
+       }
+
+       inline const Elm_Theme *Theme::getTh() const
+       {
+               return m_th;
+       }
+
+       inline Theme::operator Elm_Theme *()
+       {
+               return getTh();
+       }
+
+       inline Theme::operator const Elm_Theme *() const
+       {
+               return getTh();
+       }
+
+       inline void Theme::addExtension(const std::string edjePath)
+       {
+               elm_theme_extension_add(getTh(), edjePath.c_str());
+       }
+
+       inline void Theme::addOverlay(const std::string edjePath)
+       {
+               elm_theme_overlay_add(getTh(), edjePath.c_str());
+       }
+
+       // Non-member functions //
+
+       inline bool isValid(const Theme &item)
+       {
+               return !!item.getTh();
+       }
+
+       inline void swap(Theme &x, Theme &y)
+       {
+               std::swap(x.m_th, y.m_th);
+               std::swap(x.m_isOwner, y.m_isOwner);
+       }
+}
diff --git a/ucl/include/ucl/gui/Widget.h b/ucl/include/ucl/gui/Widget.h
new file mode 100644 (file)
index 0000000..ac47866
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * 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_WIDGET_H__
+#define __UCL_GUI_WIDGET_H__
+
+#include <list>
+
+#include "types.h"
+
+#include "ucl/misc/RefCountAware.h"
+
+#define UCL_SMART_FWD "ucl,fwd,"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(Widget);
+
+       class Widget : public RefCountAware {
+       public:
+               static constexpr auto EXPAND = EVAS_HINT_EXPAND;
+               static constexpr auto FILL = EVAS_HINT_FILL;
+
+       public:
+               explicit Widget(Evas_Object *eo, bool isOwner = true);
+               virtual ~Widget();
+
+               void bindToEo();
+               void unbindFromEo();
+
+               void setIsOwner(bool value);
+
+               Evas_Object *getEo();
+               const Evas_Object *getEo() const;
+
+               operator Evas_Object *();
+               operator const Evas_Object *() const;
+
+               Evas *getEvas() const;
+
+               void setData(EoDataKey key, void *data);
+               void delData(EoDataKey key);
+               void *getData(EoDataKey key) const;
+
+               void addEventHandler(WidgetEvent event, WidgetEventHandler handler);
+               void addEventHandler(SmartEvent event, WidgetEventHandler handler);
+
+               void delEventHandler(WidgetEvent event, WidgetEventHandler handler);
+               void delEventHandler(SmartEvent event, WidgetEventHandler handler);
+
+               void callEvent(SmartEvent event, void *eventInfo = nullptr);
+
+               void markForDeletion();
+
+               void setVisible(bool value);
+               bool isVisible() const;
+
+               void setColor(int r, int g, int b, int a = 255);
+               void setColor(int l, int a = 255);
+               void getColor(int &r, int &g, int &b, int &a) const;
+
+               void calculate();
+
+               void setGeometry(int x, int y, int w, int h);
+               void move(int x, int y);
+               void resize(int w, int h);
+
+               void getGeometry(int *x, int *y, int *w, int *h) const;
+
+               void setWeight(double w, double h);
+               void setAlign(double w, double h);
+               void setMin(int w, int h);
+               void setMax(int w, int h);
+
+               void getWeight(double *w, double *h) const;
+               void getAlign(double *w, double *h) const;
+               void getMin(int *w, int *h) const;
+               void getMax(int *w, int *h) const;
+
+               void setARHint(WidgetARHint arControl, int w, int h);
+               void getARHint(WidgetARHint &arControl, int &w, int &h);
+
+               void setFocused(bool value);
+               bool isFocused() const;
+
+       protected:
+               friend class ReffedObj<Widget>;
+               Widget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
+
+               virtual void setFocusedImpl(bool value);
+               virtual bool isFocusedImpl() const;
+               virtual bool ensureFwdEvent(SmartEvent fwdEvent);
+
+       private:
+               class EventProxy;
+               using EventProxies = std::list<EventProxy>;
+               using EventProxiesIt = EventProxies::iterator;
+
+       private:
+               void updateRefs();
+
+               void updateEoRef();
+               bool needKeepEoRef() const;
+               void updateSelfRef();
+               bool needKeepSelfRef() const;
+
+               void setSelfRefUnique(const bool value);
+
+               void onEoDel(Evas *e, Evas_Object *obj, void *event_info);
+
+               void delEventProxy(const EventProxiesIt it);
+
+       public:
+               // This section MUST be public!
+               // Signal to RefCountObj<T, C> to call onUniqueChanged()
+               enum { _ENABLE_ON_UNIQUE_CHANGED_DISPATCH };
+
+       protected:
+               // This section MAY be protected
+               void onUniqueChanged(bool isUnique);
+
+       private:
+               Evas_Object *m_eo;
+               EventProxies m_eventProxies;
+               WidgetSRef m_selfRef;
+               bool m_isOwner;
+               bool m_isBoundToEo;
+               bool m_isEoRefKept;
+               bool m_isSelfRefUnique;
+       };
+
+       // Non-member functions //
+
+       void getPosition(const Widget &widget, int *x, int *y);
+       void getSize(const Widget &widget, int *w, int *h);
+
+       void show(Widget &widget);
+       void hide(Widget &widget);
+
+       void makeTransparent(Widget &widget);
+       void makeWhite(Widget &widget);
+
+       void focus(Widget &widget);
+       void unfocus(Widget &widget);
+
+       void expand(Widget &widget);
+       void fill(Widget &widget);
+       void expandAndFill(Widget &widget);
+
+       bool operator==(const Widget &lhs, const Widget &rhs);
+       bool operator!=(const Widget &lhs, const Widget &rhs);
+}
+
+#include "Widget.hpp"
+
+#endif // __UCL_GUI_WIDGET_H__
diff --git a/ucl/include/ucl/gui/Widget.hpp b/ucl/include/ucl/gui/Widget.hpp
new file mode 100644 (file)
index 0000000..95da66a
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ */
+
+namespace ucl { namespace { namespace impl {
+
+       constexpr auto WIDGET_DATA_NAME = "__WIDGET_DATA_NAME__";
+}}}
+
+namespace ucl {
+
+       inline Widget::Widget(Evas_Object *const eo, const bool isOwner) :
+               Widget(nullptr, eo, isOwner)
+       {
+       }
+
+       inline void Widget::setIsOwner(const bool value)
+       {
+               if (value != m_isOwner) {
+                       m_isOwner = value;
+                       updateRefs();
+               }
+       }
+
+       inline Evas_Object *Widget::getEo()
+       {
+               return m_eo;
+       }
+
+       inline const Evas_Object *Widget::getEo() const
+       {
+               return m_eo;
+       }
+
+       inline Widget::operator Evas_Object *()
+       {
+               return getEo();
+       }
+
+       inline Widget::operator const Evas_Object *() const
+       {
+               return getEo();
+       }
+
+       inline Evas *Widget::getEvas() const
+       {
+               return evas_object_evas_get(getEo());
+       }
+
+       inline void Widget::setData(const EoDataKey key, void *const data)
+       {
+               evas_object_data_set(getEo(), key.name, data);
+       }
+
+       inline void Widget::delData(const EoDataKey key)
+       {
+               evas_object_data_del(getEo(), key.name);
+       }
+
+       inline void *Widget::getData(const EoDataKey key) const
+       {
+               return evas_object_data_get(getEo(), key.name);
+       }
+
+       inline void Widget::callEvent(SmartEvent event, void *eventInfo)
+       {
+               evas_object_smart_callback_call(getEo(), event, eventInfo);
+       }
+
+       inline void Widget::markForDeletion()
+       {
+               evas_object_del(getEo());
+       }
+
+       inline void Widget::setVisible(bool value)
+       {
+               if (value) {
+                       evas_object_show(getEo());
+               } else {
+                       evas_object_hide(getEo());
+               }
+       }
+
+       inline bool Widget::isVisible() const
+       {
+               return evas_object_visible_get(getEo());
+       }
+
+       inline void Widget::setColor(const int r, const int g,
+                       const int b, const int a)
+       {
+               evas_object_color_set(getEo(), r, g, b, a);
+       }
+
+       inline void Widget::setColor(const int l, const int a)
+       {
+               evas_object_color_set(getEo(), l, l, l, a);
+       }
+
+       inline void Widget::getColor(int &r, int &g, int &b, int &a) const
+       {
+               evas_object_color_get(getEo(), &r, &g, &b, &a);
+       }
+
+       inline void Widget::calculate()
+       {
+               evas_object_smart_calculate(getEo());
+       }
+
+       inline void Widget::setGeometry(const int x, const int y,
+                       const int w, const int h)
+       {
+               evas_object_geometry_set(getEo(), x, y, w, h);
+       }
+
+       inline void Widget::move(const int x, const int y)
+       {
+               evas_object_move(getEo(), x, y);
+       }
+
+       inline void Widget::resize(const int w, const int h)
+       {
+               evas_object_resize(getEo(), w, h);
+       }
+
+       inline void Widget::getGeometry(int *const x, int *const y,
+                       int *const w, int *const h) const
+       {
+               evas_object_geometry_get(getEo(), x, y, w, h);
+       }
+
+       inline void Widget::setWeight(const double w, const double h)
+       {
+               evas_object_size_hint_weight_set(getEo(), w, h);
+       }
+
+       inline void Widget::setAlign(const double w, const double h)
+       {
+               evas_object_size_hint_align_set(getEo(), w, h);
+       }
+
+       inline void Widget::setMin(const int w, const int h)
+       {
+               evas_object_size_hint_min_set(getEo(), w, h);
+       }
+
+       inline void Widget::setMax(const int w, const int h)
+       {
+               evas_object_size_hint_max_set(getEo(), w, h);
+       }
+
+       inline void Widget::getWeight(double *const w, double *const h) const
+       {
+               evas_object_size_hint_weight_get(getEo(), w, h);
+       }
+
+       inline void Widget::getAlign(double *const w, double *const h) const
+       {
+               evas_object_size_hint_align_get(getEo(), w, h);
+       }
+
+       inline void Widget::getMin(int *const w, int *const h) const
+       {
+               evas_object_size_hint_min_get(getEo(), w, h);
+       }
+
+       inline void Widget::getMax(int *const w, int *const h) const
+       {
+               evas_object_size_hint_max_get(getEo(), w, h);
+       }
+
+       inline void Widget::setARHint(WidgetARHint arControl, int w, int h)
+       {
+               evas_object_size_hint_aspect_set(getEo(),
+                               static_cast<Evas_Aspect_Control>(arControl), w, h);
+       }
+
+       inline void Widget::getARHint(WidgetARHint &arControl, int &w, int &h)
+       {
+               Evas_Aspect_Control tmp = EVAS_ASPECT_CONTROL_NEITHER;
+               evas_object_size_hint_aspect_get(getEo(), &tmp, &w, &h);
+               arControl = static_cast<WidgetARHint>(tmp);
+       }
+
+       inline void Widget::setFocused(const bool value)
+       {
+               setFocusedImpl(value);
+       }
+
+       inline bool Widget::isFocused() const
+       {
+               return isFocusedImpl();
+       }
+
+       // Non-member functions //
+
+       inline void getPosition(const Widget &widget, int *x, int *y)
+       {
+               widget.getGeometry(x, y, nullptr, nullptr);
+       }
+
+       inline void getSize(const Widget &widget, int *w, int *h)
+       {
+               widget.getGeometry(nullptr, nullptr, w, h);
+       }
+
+       inline void show(Widget &widget)
+       {
+               widget.setVisible(true);
+       }
+
+       inline void hide(Widget &widget)
+       {
+               widget.setVisible(false);
+       }
+
+       inline void makeTransparent(Widget &widget)
+       {
+               widget.setColor(0, 0);
+       }
+
+       inline void makeWhite(Widget &widget)
+       {
+               widget.setColor(255);
+       }
+
+       inline void focus(Widget &widget)
+       {
+               widget.setFocused(true);
+       }
+
+       inline void unfocus(Widget &widget)
+       {
+               widget.setFocused(false);
+       }
+
+       inline void expand(Widget &widget)
+       {
+               widget.setWeight(Widget::EXPAND, Widget::EXPAND);
+       }
+
+       inline void fill(Widget &widget)
+       {
+               widget.setAlign(Widget::FILL, Widget::FILL);
+       }
+
+       inline void expandAndFill(Widget &widget)
+       {
+               expand(widget);
+               fill(widget);
+       }
+
+       inline bool operator==(const Widget &lhs, const Widget &rhs)
+       {
+               return (lhs.getEo() == rhs.getEo());
+       }
+
+       inline bool operator!=(const Widget &lhs, const Widget &rhs)
+       {
+               return (lhs.getEo() != rhs.getEo());
+       }
+}
diff --git a/ucl/include/ucl/gui/WidgetItem.h b/ucl/include/ucl/gui/WidgetItem.h
new file mode 100644 (file)
index 0000000..7794444
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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_WIDGET_ITEM_H__
+#define __UCL_GUI_WIDGET_ITEM_H__
+
+#include "Widget.h"
+
+namespace ucl {
+
+       class WidgetItem {
+       public:
+               constexpr WidgetItem();
+               constexpr WidgetItem(std::nullptr_t);
+               explicit WidgetItem(Elm_Object_Item *it);
+
+               Elm_Object_Item *getIt() const;
+
+               operator Elm_Object_Item *() const;
+               operator bool() const;
+
+               Evas_Object *getWidget() const;
+
+               void setDelCallback(Evas_Smart_Cb cb) const;
+
+               void del();
+
+               void setData(void *data) const;
+               void *getData() const;
+
+               void setEnabled(bool value) const;
+               bool isEnabled() const;
+
+               void setStyle(ElmStyle style) const;
+
+               void setText(const TString &value) const;
+               void setText(const TString &value, EdjePart part) const;
+
+               TString getText() const;
+               TString getText(EdjePart part) const;
+
+               void setContent(Evas_Object *content) const;
+               void setContent(Evas_Object *content, EdjePart part) const;
+               Evas_Object *unsetContent() const;
+               Evas_Object *unsetContent(EdjePart part) const;
+
+               Evas_Object *getContent() const;
+               Evas_Object *getContent(EdjePart part) const;
+
+               void emit(EdjeSignal signal,EdjeSignalSrc source =
+                               EdjeSignalSrc("")) const;
+
+       private:
+               Elm_Object_Item *m_it;
+       };
+
+       // Non-member functions //
+
+       void enable(WidgetItem item);
+       void disable(WidgetItem item);
+
+       bool operator==(WidgetItem lhs, WidgetItem rhs);
+       bool operator!=(WidgetItem lhs, WidgetItem rhs);
+}
+
+#include "WidgetItem.hpp"
+
+#endif // __UCL_GUI_WIDGET_ITEM_H__
diff --git a/ucl/include/ucl/gui/WidgetItem.hpp b/ucl/include/ucl/gui/WidgetItem.hpp
new file mode 100644 (file)
index 0000000..26b6cbd
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       constexpr WidgetItem::WidgetItem() :
+               m_it(nullptr)
+       {
+       }
+
+       constexpr WidgetItem::WidgetItem(std::nullptr_t) :
+               WidgetItem()
+       {
+       }
+
+       inline WidgetItem::WidgetItem(Elm_Object_Item *const it) :
+               m_it(it)
+       {
+       }
+
+       inline Elm_Object_Item *WidgetItem::getIt() const
+       {
+               return m_it;
+       }
+
+       inline WidgetItem::operator Elm_Object_Item *() const
+       {
+               return m_it;
+       }
+
+       inline WidgetItem::operator bool() const
+       {
+               return !!m_it;
+       }
+
+       inline Evas_Object *WidgetItem::getWidget() const
+       {
+               return elm_object_item_widget_get(getIt());
+       }
+
+       inline void WidgetItem::setDelCallback(const Evas_Smart_Cb cb) const
+       {
+               elm_object_item_del_cb_set(getIt(), cb);
+       }
+
+       inline void WidgetItem::del()
+       {
+               elm_object_item_del(m_it);
+               m_it = nullptr;
+       }
+
+       inline void WidgetItem::setData(void *const data) const
+       {
+               elm_object_item_data_set(getIt(), data);
+       }
+
+       inline void *WidgetItem::getData() const
+       {
+               return elm_object_item_data_get(getIt());
+       }
+
+       inline void WidgetItem::setEnabled(const bool value) const
+       {
+               elm_object_item_disabled_set(getIt(), toEina(!value));
+       }
+
+       inline bool WidgetItem::isEnabled() const
+       {
+               return (elm_object_item_disabled_get(getIt()) ? false : true);
+       }
+
+       inline void WidgetItem::setStyle(const ElmStyle style) const
+       {
+               elm_object_item_style_set(getIt(), style.name);
+       }
+
+       inline TString WidgetItem::getText() const
+       {
+               return elm_object_item_text_get(getIt());
+       }
+
+       inline TString WidgetItem::getText(const EdjePart part) const
+       {
+               return elm_object_item_part_text_get(getIt(), part.name);
+       }
+
+       inline void WidgetItem::setContent(Evas_Object *const content) const
+       {
+               elm_object_item_content_set(getIt(), content);
+       }
+
+       inline void WidgetItem::setContent(Evas_Object *const content,
+                       const EdjePart part) const
+       {
+               elm_object_item_part_content_set(getIt(), part.name, content);
+       }
+
+       inline Evas_Object *WidgetItem::unsetContent() const
+       {
+               return elm_object_item_content_unset(getIt());
+       }
+
+       inline Evas_Object *WidgetItem::unsetContent(const EdjePart part) const
+       {
+               return elm_object_item_part_content_unset(getIt(), part.name);
+       }
+
+       inline Evas_Object *WidgetItem::getContent() const
+       {
+               return elm_object_item_content_get(getIt());
+       }
+
+       inline Evas_Object *WidgetItem::getContent(const EdjePart part) const
+       {
+               return elm_object_item_part_content_get(getIt(), part.name);
+       }
+
+       inline void WidgetItem::emit(const EdjeSignal signal,
+                       const EdjeSignalSrc source) const
+       {
+               elm_object_item_signal_emit(getIt(), signal.name, source.name);
+       }
+
+       // Non-member functions //
+
+       inline void enable(const WidgetItem item)
+       {
+               item.setEnabled(true);
+       }
+
+       inline void disable(const WidgetItem item)
+       {
+               item.setEnabled(false);
+       }
+
+       inline bool operator==(const WidgetItem lhs, const WidgetItem rhs)
+       {
+               return (lhs.getIt() == rhs.getIt());
+       }
+
+       inline bool operator!=(const WidgetItem lhs, const WidgetItem rhs)
+       {
+               return (lhs.getIt() != rhs.getIt());
+       }
+}
diff --git a/ucl/include/ucl/gui/Window.h b/ucl/include/ucl/gui/Window.h
new file mode 100644 (file)
index 0000000..9aa598d
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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_WINDOW_H__
+#define __UCL_GUI_WINDOW_H__
+
+#include <vector>
+
+#include "StyledWidget.h"
+
+namespace ucl {
+
+       constexpr SmartEvent WIN_ROTATION_CHANGED {"wm,rotation,changed"};
+
+       UCL_DECLARE_REF_ALIASES(Window);
+
+       class Window final : public ElmWidget {
+       public:
+               enum class Type {
+                       BASIC = ELM_WIN_BASIC
+               };
+
+               class Builder final {
+               public:
+                       Builder();
+
+                       Builder &setWinEo(Evas_Object *value);
+
+                       Builder &setType(Type type);
+                       Builder &setName(std::string value);
+
+                       Builder &setTitle(std::string value);
+                       Builder &setSetIndicatorVisible(bool value);
+                       Builder &setRotations(std::vector<int> value);
+
+                       Builder &setIsOwner(bool value);
+                       Builder &setNeedBindToEo(bool value);
+
+                       WindowSRef build() const;
+               private:
+                       std::string m_name;
+                       std::string m_title;
+                       std::vector<int> m_rotations;
+                       Evas_Object *m_winEo;
+                       Type m_type;
+                       bool m_isIndicatorVisible;
+                       bool m_isOwner;
+                       bool m_isOwnerWasSet;
+                       bool m_needBindToEo;
+               };
+
+       public:
+               StyledWidget &getConformant();
+               const StyledWidget &getConformant() const;
+
+               void getScreenSize(int *w, int *h) const;
+
+               void setTitle(const std::string &title);
+               std::string getTitle() const;
+
+               void setIndicatorVisible(bool value);
+               bool isIndicatorVisible() const;
+
+               bool isRotationsSupported() const;
+               void setRotations(const std::vector<int> &value);
+
+               void lower();
+
+       private:
+               friend class ReffedObj<Window>;
+               Window(IRefCountObj *rc, Evas_Object *eo,
+                               bool isOwner, Evas_Object *conform);
+
+       private:
+               StyledWidget m_conform;
+       };
+
+       // Non-member functions //
+
+       // Window //
+
+       void showIndicator(Window &win);
+       void hideIndicator(Window &win);
+
+       // Window::Type //
+
+       bool isValid(Window::Type winType);
+}
+
+#include "Window.hpp"
+
+#endif // __UCL_GUI_WINDOW_H__
diff --git a/ucl/include/ucl/gui/Window.hpp b/ucl/include/ucl/gui/Window.hpp
new file mode 100644 (file)
index 0000000..d5b1828
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * 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 <algorithm>
+
+namespace ucl {
+
+       // Window::Builder //
+
+       inline Window::Builder::Builder() :
+               m_rotations({0}),
+               m_winEo(nullptr),
+               m_type(Type::BASIC),
+               m_isIndicatorVisible(false),
+               m_isOwner(false),
+               m_isOwnerWasSet(false),
+               m_needBindToEo(true)
+       {
+       }
+
+       inline Window::Builder &Window::Builder::setWinEo(Evas_Object *const value)
+       {
+               m_winEo = value;
+               return *this;
+       }
+
+       inline Window::Builder &Window::Builder::setType(const Type type)
+       {
+               m_type = type;
+               return *this;
+       }
+
+       inline Window::Builder &Window::Builder::setName(std::string value)
+       {
+               m_name = std::move(value);
+               return *this;
+       }
+
+       inline Window::Builder &Window::Builder::setTitle(std::string value)
+       {
+               m_title = std::move(value);
+               return *this;
+       }
+
+       inline Window::Builder &Window::Builder::setSetIndicatorVisible(
+                       const bool value)
+       {
+               m_isIndicatorVisible = value;
+               return *this;
+       }
+
+       inline Window::Builder &Window::Builder::setRotations(
+                       std::vector<int> value)
+       {
+               m_rotations = std::move(value);
+               return *this;
+       }
+
+       inline Window::Builder &Window::Builder::setIsOwner(const bool value)
+       {
+               m_isOwner = value;
+               m_isOwnerWasSet = true;
+               return *this;
+       }
+
+       inline Window::Builder &Window::Builder::setNeedBindToEo(const bool value)
+       {
+               m_needBindToEo = value;
+               return *this;
+       }
+
+       // Window //
+
+       inline Window::Window(IRefCountObj *const rc, Evas_Object *const eo,
+                       const bool isOwner, Evas_Object *const conform) :
+               ElmWidget(rc, eo, isOwner),
+               m_conform(conform)
+       {
+       }
+
+       inline StyledWidget &Window::getConformant()
+       {
+               return m_conform;
+       }
+
+       inline const StyledWidget &Window::getConformant() const
+       {
+               return m_conform;
+       }
+
+       inline void Window::getScreenSize(int *const w, int *const h) const
+       {
+               elm_win_screen_size_get(getEo(), nullptr, nullptr, w, h);
+       }
+
+       inline void Window::setTitle(const std::string &title)
+       {
+               elm_win_title_set(getEo(), title.c_str());
+       }
+
+       inline std::string Window::getTitle() const
+       {
+               return nz(elm_win_title_get(getEo()));
+       }
+
+       inline void Window::setIndicatorVisible(bool value)
+       {
+               if (value) {
+                       elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_SHOW);
+               } else {
+                       elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_HIDE);
+               }
+       }
+
+       inline bool Window::isIndicatorVisible() const
+       {
+               return (elm_win_indicator_mode_get(getEo()) == ELM_WIN_INDICATOR_SHOW);
+       }
+
+       inline bool Window::isRotationsSupported() const
+       {
+               return elm_win_wm_rotation_supported_get(getEo());
+       }
+
+       inline void Window::setRotations(const std::vector<int> &value)
+       {
+               elm_win_wm_rotation_available_rotations_set(getEo(),
+                               value.data(), value.size());
+       }
+
+       inline void Window::lower()
+       {
+               elm_win_lower(getEo());
+       }
+
+       // Non-member functions //
+
+       // Window //
+
+       inline void showIndicator(Window &win)
+       {
+               win.setIndicatorVisible(true);
+       }
+
+       inline void hideIndicator(Window &win)
+       {
+               win.setIndicatorVisible(false);
+       }
+
+       // Window::Type //
+
+       inline bool isValid(Window::Type winType)
+       {
+               switch (winType) {
+               case Window::Type::BASIC:
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/ucl/include/ucl/gui/helpers.h b/ucl/include/ucl/gui/helpers.h
new file mode 100644 (file)
index 0000000..d42eccb
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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_HELPERS_H__
+#define __UCL_GUI_HELPERS_H__
+
+#include "Widget.h"
+
+namespace ucl {
+
+       // Converts Evas_Object to Widget pointer //
+
+       Widget *asWidget(Evas_Object *eo);
+       const Widget *asWidget(const Evas_Object *eo);
+
+       // Widget casting functions from Evas_Object //
+
+       template <class WIDGET_TYPE>
+       inline auto staticWidgetCast(Evas_Object *eo) ->
+                       decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
+       {
+               return static_cast<WIDGET_TYPE *>(asWidget(eo));
+       }
+
+       template <class WIDGET_TYPE>
+       inline auto staticWidgetCast(const Evas_Object *eo) ->
+                       decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
+       {
+               return static_cast<WIDGET_TYPE *>(asWidget(eo));
+       }
+
+       template <class WIDGET_TYPE>
+       inline auto dynamicWidgetCast(Evas_Object *eo) ->
+                       decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
+       {
+               return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
+       }
+
+       template <class WIDGET_TYPE>
+       inline auto dynamicWidgetCast(const Evas_Object *eo) ->
+                       decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
+       {
+               return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
+       }
+
+       template <class WIDGET_TYPE>
+       inline auto staticWidgetRefCast(Evas_Object *eo) ->
+                       decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
+       {
+               return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
+       }
+
+       template <class WIDGET_TYPE>
+       inline auto staticWidgetRefCast(const Evas_Object *eo) ->
+                       decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
+       {
+               return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
+       }
+
+       template <class WIDGET_TYPE>
+       inline auto dynamicWidgetRefCast(Evas_Object *eo) ->
+                       decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
+       {
+               return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
+       }
+
+       template <class WIDGET_TYPE>
+       inline auto dynamicWidgetRefCast(const Evas_Object *eo) ->
+                       decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
+       {
+               return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
+       }
+}
+
+#include "helpers.hpp"
+
+#endif // __UCL_GUI_HELPERS_H__
diff --git a/ucl/include/ucl/gui/helpers.hpp b/ucl/include/ucl/gui/helpers.hpp
new file mode 100644 (file)
index 0000000..29df283
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline Widget *asWidget(Evas_Object *eo)
+       {
+               return static_cast<Widget *>(
+                               evas_object_data_get(eo, impl::WIDGET_DATA_NAME));
+
+       }
+
+       inline const Widget *asWidget(const Evas_Object *eo)
+       {
+               return static_cast<const Widget *>(
+                               evas_object_data_get(eo, impl::WIDGET_DATA_NAME));
+       }
+}
diff --git a/ucl/include/ucl/gui/stdTheme.h b/ucl/include/ucl/gui/stdTheme.h
new file mode 100644 (file)
index 0000000..13202cc
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_STD_THEME_H__
+#define __UCL_GUI_STD_THEME_H__
+
+#include "stdTheme/common.h"
+#include "stdTheme/layout.h"
+#include "stdTheme/naviframe.h"
+
+#endif // __UCL_GUI_STD_THEME_H__
diff --git a/ucl/include/ucl/gui/stdTheme/common.h b/ucl/include/ucl/gui/stdTheme/common.h
new file mode 100644 (file)
index 0000000..7ec81b9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_GUI_STD_THEME_COMMON_H__
+#define __UCL_GUI_STD_THEME_COMMON_H__
+
+#include "ucl/gui/types.h"
+
+namespace ucl {
+
+       // Styles //
+
+       constexpr ElmStyle STYLE_DEFAULT {"default"};
+
+       // Parts //
+
+       constexpr EdjePart PART_TEXT  {"elm.text"};
+       constexpr EdjePart PART_TITLE {"elm.text.title"};
+
+       constexpr EdjePart PART_CONTENT {"elm.swallow.content"};
+       constexpr EdjePart PART_ICON    {"elm.swallow.icon"};
+       constexpr EdjePart PART_BUTTON  {"elm.swallow.button"};
+}
+
+#endif // __UCL_GUI_STD_THEME_COMMON_H__
diff --git a/ucl/include/ucl/gui/stdTheme/layout.h b/ucl/include/ucl/gui/stdTheme/layout.h
new file mode 100644 (file)
index 0000000..79ff426
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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_STD_THEME_LAYOUT_H__
+#define __UCL_GUI_STD_THEME_LAYOUT_H__
+
+#include "common.h"
+
+namespace ucl {
+
+       constexpr LayoutTheme LAYOUT_DEFAULT {"layout", "application", "default"};
+
+       constexpr LayoutTheme LAYOUT_NO_CONTENTS
+                       {"layout", "nocontents", "default"};
+}
+
+#endif // __UCL_GUI_STD_THEME_LAYOUT_H__
diff --git a/ucl/include/ucl/gui/stdTheme/naviframe.h b/ucl/include/ucl/gui/stdTheme/naviframe.h
new file mode 100644 (file)
index 0000000..fd99fdc
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_STD_THEME_NAVIFRAME_H__
+#define __UCL_GUI_STD_THEME_NAVIFRAME_H__
+
+#include "common.h"
+
+namespace ucl {
+
+       constexpr ElmStyle NAVIFRAME_EMPTY {"empty"};
+}
+
+#endif // __UCL_GUI_STD_THEME_NAVIFRAME_H__
diff --git a/ucl/include/ucl/gui/types.h b/ucl/include/ucl/gui/types.h
new file mode 100644 (file)
index 0000000..6d43d76
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * 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_TYPES_H__
+#define __UCL_GUI_TYPES_H__
+
+#include <Elementary.h>
+
+#include "ucl/util/types.h"
+#include "ucl/util/memory.h"
+#include "ucl/util/delegation.h"
+#include "ucl/util/smartDelegation.h"
+
+#include "ucl/misc/Aspect.h"
+#include "ucl/misc/TString.h"
+#include "ucl/misc/ConstCString.h"
+#include "ucl/misc/Variant.h"
+
+namespace ucl {
+
+       // Aspects //
+
+       struct EdjePart : Aspect<EdjePart> { using Aspect::Aspect; };
+       struct EdjeGroup : Aspect<EdjeGroup> { using Aspect::Aspect; };
+       struct EdjeDataKey : Aspect<EdjeDataKey> { using Aspect::Aspect; };
+
+       struct EdjeSignal : Aspect<EdjeSignal> { using Aspect::Aspect; };
+       struct EdjeSignalSrc : Aspect<EdjeSignalSrc> { using Aspect::Aspect; };
+
+       struct ElmStyle : Aspect<ElmStyle> { using Aspect::Aspect; };
+
+       struct SmartEvent : Aspect<SmartEvent> { using Aspect::Aspect; };
+
+       struct EoDataKey : Aspect<EoDataKey> { using Aspect::Aspect; };
+
+       // Delegates //
+
+       using SmartCbHandler = Delegate<void(Evas_Object *obj, void *eventInfo)>;
+
+       // WidgetEventHandler //
+
+       class Widget;
+
+       using WidgetEventHandler =
+                       WeakDelegate<void(Widget &widget, void *eventInfo)>;
+
+       // WidgetEvent //
+
+       enum class WidgetEvent {
+               DEL  = EVAS_CALLBACK_DEL,
+
+               MOUSE_IN    = EVAS_CALLBACK_MOUSE_IN,
+               MOUSE_OUT   = EVAS_CALLBACK_MOUSE_OUT,
+               MOUSE_DOWN  = EVAS_CALLBACK_MOUSE_DOWN,
+               MOUSE_UP    = EVAS_CALLBACK_MOUSE_UP,
+               MOUSE_MOVE  = EVAS_CALLBACK_MOUSE_MOVE,
+               MOUSE_WHEEL = EVAS_CALLBACK_MOUSE_WHEEL,
+
+               MULTI_DOWN = EVAS_CALLBACK_MULTI_DOWN,
+               MULTI_UP   = EVAS_CALLBACK_MULTI_UP,
+               MULTI_MOVE = EVAS_CALLBACK_MULTI_MOVE,
+
+               MOVE    = EVAS_CALLBACK_MOVE,
+               RESIZE  = EVAS_CALLBACK_RESIZE,
+               RESTACK = EVAS_CALLBACK_RESTACK,
+
+               CHANGED_SIZE_HINTS = EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+
+               KEY_DOWN  = EVAS_CALLBACK_KEY_DOWN,
+               KEY_UP    = EVAS_CALLBACK_KEY_UP,
+               FOCUS_IN  = EVAS_CALLBACK_FOCUS_IN,
+               FOCUS_OUT = EVAS_CALLBACK_FOCUS_OUT,
+
+               SHOW = EVAS_CALLBACK_SHOW,
+               HIDE = EVAS_CALLBACK_HIDE,
+
+               HOLD = EVAS_CALLBACK_HOLD,
+
+               IMAGE_PRELOADED = EVAS_CALLBACK_IMAGE_PRELOADED
+       };
+
+       // AtspiGestureEventInfo //
+
+       struct AtspiGestureEventInfo final {
+               Elm_Atspi_Gesture_Info gestureInfo;
+               bool preventDefault;
+               bool stopPropagation;
+       };
+
+       // WidgetARHint //
+
+       enum class WidgetARHint
+       {
+               NEITHER = EVAS_ASPECT_CONTROL_NEITHER,
+               HORIZONTAL = EVAS_ASPECT_CONTROL_HORIZONTAL,
+               VERTICAL = EVAS_ASPECT_CONTROL_VERTICAL,
+               BOTH = EVAS_ASPECT_CONTROL_BOTH
+       };
+
+       // LayoutTheme //
+
+       struct LayoutTheme final {
+               const char *klass;
+               const char *group;
+               const char *style;
+
+               constexpr LayoutTheme();
+               constexpr LayoutTheme(std::nullptr_t);
+               constexpr LayoutTheme(const char *klass,
+                               const char *group, const char *style);
+       };
+
+       // LayoutTheme non-member functions //
+
+       constexpr bool isValid(const LayoutTheme &value);
+}
+
+#include "types.hpp"
+
+#endif // __UCL_GUI_TYPES_H__
diff --git a/ucl/include/ucl/gui/types.hpp b/ucl/include/ucl/gui/types.hpp
new file mode 100644 (file)
index 0000000..7f128c8
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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/helpers.h"
+
+namespace ucl {
+
+       // LayoutTheme //
+
+       constexpr LayoutTheme::LayoutTheme() :
+               klass(nullptr),
+               group(nullptr),
+               style(nullptr)
+       {
+       }
+
+       constexpr LayoutTheme::LayoutTheme(std::nullptr_t) :
+               LayoutTheme()
+       {
+       }
+
+       constexpr LayoutTheme::LayoutTheme(const char *klass,
+                       const char *group, const char *style) :
+               klass(klass),
+               group(group),
+               style(style)
+       {
+       }
+
+       // LayoutTheme non-member functions //
+
+       constexpr bool isValid(const LayoutTheme &value)
+       {
+               return (isNotEmpty(value.klass) && isNotEmpty(value.group) &&
+                                       isNotEmpty(value.style));
+       }
+}
diff --git a/ucl/include/ucl/misc/Aspect.h b/ucl/include/ucl/misc/Aspect.h
new file mode 100644 (file)
index 0000000..0c55bf6
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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_ASPECT_H__
+#define __UCL_MISC_ASPECT_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+       template <class CHILD>
+       struct Aspect {
+               const char *name;
+
+               constexpr Aspect();
+               constexpr Aspect(std::nullptr_t);
+               explicit constexpr Aspect(const char *name);
+
+               constexpr operator const char *() const;
+
+               struct Hash final {
+                       size_t operator()(const Aspect &key) const;
+               };
+       };
+
+       // Non-member functions //
+
+       template <class CHILD>
+       constexpr bool isValid(Aspect<CHILD> aspect);
+
+       template <class CHILD>
+       constexpr bool operator==(Aspect<CHILD> lhs, Aspect<CHILD> rhs);
+       template <class CHILD>
+       constexpr bool operator!=(Aspect<CHILD> lhs, Aspect<CHILD> rhs);
+}
+
+#include "Aspect.hpp"
+
+#endif // __UCL_MISC_ASPECT_H__
diff --git a/ucl/include/ucl/misc/Aspect.hpp b/ucl/include/ucl/misc/Aspect.hpp
new file mode 100644 (file)
index 0000000..9894681
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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 <cstring>
+
+#include "ucl/util/helpers.h"
+
+namespace ucl {
+
+       // Aspect<CHILD>::Hash //
+
+       template <class CHILD>
+       size_t Aspect<CHILD>::Hash::operator()(const Aspect<CHILD> &key) const
+       {
+               constexpr size_t PRIME = 31;
+               size_t result = 0;
+               for (size_t i = 0; (key.name[i] != '\0'); ++i) {
+                       result *= PRIME;
+                       result += key.name[i];
+               }
+               return result;
+       }
+
+       // Aspect<CHILD> //
+
+       template <class CHILD>
+       constexpr Aspect<CHILD>::Aspect() :
+               name(nullptr)
+       {
+       }
+
+       template <class CHILD>
+       constexpr Aspect<CHILD>::Aspect(std::nullptr_t) :
+               Aspect()
+       {
+       }
+
+       template <class CHILD>
+       constexpr Aspect<CHILD>::Aspect(const char *name) :
+               name(name)
+       {
+       }
+
+       template <class CHILD>
+       constexpr Aspect<CHILD>::operator const char *() const
+       {
+               return name;
+       }
+
+       // Non-member functions //
+
+       template <class CHILD>
+       constexpr bool isValid(const Aspect<CHILD> aspect)
+       {
+               return isNotEmpty(aspect);
+       }
+
+       template <class CHILD>
+       constexpr bool operator==(Aspect<CHILD> lhs, Aspect<CHILD> rhs)
+       {
+               return (strCmpSafe(lhs.name, rhs.name) == 0);
+       }
+
+       template <class CHILD>
+       constexpr bool operator!=(Aspect<CHILD> lhs, Aspect<CHILD> rhs)
+       {
+               return (strCmpSafe(lhs.name, rhs.name) != 0);
+       }
+}
diff --git a/ucl/include/ucl/misc/AutoHandle.h b/ucl/include/ucl/misc/AutoHandle.h
new file mode 100644 (file)
index 0000000..27c19f4
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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_AUTO_HANDLE_H__
+#define __UCL_MISC_AUTO_HANDLE_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+       template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
+       struct AutoHandle final : ucl::NonCopyable {
+               using Handle = HANDLE;
+
+               HANDLE value;
+
+               AutoHandle() :
+                       value()
+               {
+               }
+
+               AutoHandle(std::nullptr_t) :
+                       AutoHandle()
+               {
+               }
+
+               AutoHandle(HANDLE value) :
+                       value(value)
+               {
+               }
+
+               ~AutoHandle()
+               {
+                       if (value) {
+                               DEL_FUNC(value);
+                       }
+               }
+
+               AutoHandle(AutoHandle &&src) :
+                       value(src.value)
+               {
+                       src.value = nullptr;
+               }
+
+               AutoHandle &operator=(AutoHandle src)
+               {
+                       swap(*this, src);
+                       return *this;
+               }
+
+               AutoHandle &operator=(HANDLE value)
+               {
+                       AutoHandle src{value};
+                       swap(*this, src);
+                       return *this;
+               }
+
+               HANDLE *operator&()
+               {
+                       return &value;
+               }
+
+               operator HANDLE()
+               {
+                       return value;
+               }
+       };
+
+       // Non-member functions //
+
+       template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
+       inline void swap(AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &x,
+                       AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &y) noexcept
+       {
+               std::swap(x.value, y.value);
+       }
+}
+
+#endif // __UCL_MISC_AUTO_HANDLE_H__
diff --git a/ucl/include/ucl/misc/CString.h b/ucl/include/ucl/misc/CString.h
new file mode 100644 (file)
index 0000000..396f37d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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_CSTRING_H__
+#define __UCL_MISC_CSTRING_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+       class CString final : public NonCopyable {
+       public:
+               friend void swap(CString &x, CString &y) noexcept;
+
+               static CString dup(const char *ptr);
+               static CString takeover(char *ptr) noexcept;
+
+               CString() noexcept;
+               CString(std::nullptr_t) noexcept;
+               CString(CString &&s) noexcept;
+               CString(const std::string &s);
+               ~CString() noexcept;
+
+               CString &operator=(CString s) noexcept;
+
+               bool isEmpty() const;
+
+               char *release() noexcept;
+
+               char *get() const noexcept;
+
+       private:
+               explicit CString(char *ptr) noexcept;
+
+       private:
+               char *m_ptr;
+       };
+}
+
+#include "CString.hpp"
+
+#endif // __UCL_MISC_CSTRING_H__
diff --git a/ucl/include/ucl/misc/CString.hpp b/ucl/include/ucl/misc/CString.hpp
new file mode 100644 (file)
index 0000000..086b3c2
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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/helpers.h"
+
+namespace ucl {
+
+       // CString //
+
+       inline CString CString::dup(const char *const ptr)
+       {
+               return CString(strDupSafe(ptr));
+       }
+
+       inline CString CString::takeover(char *const ptr) noexcept
+       {
+               return CString(ptr);
+       }
+
+       inline CString::CString(char *const ptr) noexcept :
+               m_ptr(ptr)
+       {
+       }
+
+       inline CString::CString() noexcept :
+               m_ptr(nullptr)
+       {
+       }
+
+       inline CString::CString(std::nullptr_t) noexcept :
+               CString()
+       {
+       }
+
+       inline CString::CString(CString &&s) noexcept :
+               m_ptr(s.m_ptr)
+       {
+               s.m_ptr = nullptr;
+       }
+
+       inline CString::CString(const std::string &s) :
+               m_ptr(s.empty() ? nullptr : strdup(s.c_str()))
+       {
+       }
+
+       inline CString::~CString() noexcept
+       {
+               free(m_ptr);
+       }
+
+       inline CString &CString::operator=(CString s) noexcept
+       {
+               swap(*this, s);
+               return *this;
+       }
+
+       inline bool CString::isEmpty() const
+       {
+               return !m_ptr;
+       }
+
+       inline char *CString::release() noexcept
+       {
+               char *const result = m_ptr;
+               m_ptr = nullptr;
+               return result;
+       }
+
+       inline char *CString::get() const noexcept
+       {
+               return m_ptr;
+       }
+
+       // Non-member functions //
+
+       inline void swap(CString &x, CString &y) noexcept
+       {
+               std::swap(x.m_ptr, y.m_ptr);
+       }
+}
diff --git a/ucl/include/ucl/misc/ConstCString.h b/ucl/include/ucl/misc/ConstCString.h
new file mode 100644 (file)
index 0000000..7f600f0
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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_CONST_CSTRING_H__
+#define __UCL_MISC_CONST_CSTRING_H__
+
+#include "CString.h"
+
+namespace ucl {
+
+       class ConstCString final : public NonCopyable {
+       public:
+               friend void swap(ConstCString &x, ConstCString &y) noexcept;
+
+               static ConstCString wrap(const char *ptr) noexcept;
+
+               ConstCString() noexcept;
+               ConstCString(std::nullptr_t) noexcept;
+               ConstCString(ConstCString &&s) noexcept;
+               ConstCString(CString &&s) noexcept;
+               ~ConstCString() noexcept;
+
+               ConstCString &operator=(ConstCString s) noexcept;
+
+               bool isEmpty() const;
+
+               const char *get() const noexcept;
+
+       private:
+               explicit ConstCString(const char *ptr) noexcept;
+
+       private:
+               const char *m_ptr;
+               bool m_isOwner;
+       };
+}
+
+#include "ConstCString.hpp"
+
+#endif // __UCL_MISC_CONST_CSTRING_H__
diff --git a/ucl/include/ucl/misc/ConstCString.hpp b/ucl/include/ucl/misc/ConstCString.hpp
new file mode 100644 (file)
index 0000000..50df605
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       // ConstCString //
+
+       inline ConstCString ConstCString::wrap(const char *ptr) noexcept
+       {
+               return ConstCString(ptr);
+       }
+
+       inline ConstCString::ConstCString(const char *ptr) noexcept :
+               m_ptr(ptr),
+               m_isOwner(false)
+       {
+       }
+
+       inline ConstCString::ConstCString() noexcept :
+               m_ptr(nullptr),
+               m_isOwner(false)
+       {
+       }
+
+       inline ConstCString::ConstCString(std::nullptr_t) noexcept :
+               ConstCString()
+       {
+       }
+
+       inline ConstCString::ConstCString(ConstCString &&s) noexcept :
+               m_ptr(s.m_ptr),
+               m_isOwner(s.m_isOwner)
+       {
+               s.m_isOwner = false;
+       }
+
+       inline ConstCString::ConstCString(CString &&s) noexcept :
+               m_ptr(s.release()),
+               m_isOwner(true)
+       {
+       }
+
+       inline ConstCString::~ConstCString() noexcept
+       {
+               if (m_isOwner) {
+                       free(const_cast<char *>(m_ptr));
+               }
+       }
+
+       inline ConstCString &ConstCString::operator=(ConstCString s) noexcept
+       {
+               swap(*this, s);
+               return *this;
+       }
+
+       inline bool ConstCString::isEmpty() const
+       {
+               return !m_ptr;
+       }
+
+       inline const char *ConstCString::get() const noexcept
+       {
+               return m_ptr;
+       }
+
+       // Non-member functions //
+
+       inline void swap(ConstCString &x, ConstCString &y) noexcept
+       {
+               std::swap(x.m_ptr, y.m_ptr);
+               std::swap(x.m_isOwner, y.m_isOwner);
+       }
+}
diff --git a/ucl/include/ucl/misc/Event.h b/ucl/include/ucl/misc/Event.h
new file mode 100644 (file)
index 0000000..cd27f29
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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_EVENT_H__
+#define __UCL_MISC_EVENT_H__
+
+#include <vector>
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+       template <class DELEGATE>
+       class Event final {
+       public:
+               Event();
+
+               template <class DELEGATE2>
+               void operator+=(DELEGATE2 &&delegate);
+               template <class DELEGATE2>
+               void operator-=(const DELEGATE2 &delegate);
+
+               bool isEmpty() const;
+
+               template <class ...ARGS>
+               void dispatch(ARGS &&...args);
+               template <class PREDICATE, class ...ARGS>
+               void dispatchPred(PREDICATE &&pred, ARGS &&...args);
+
+       private:
+               template <class DO_INVOKE, class ...ARGS>
+               void dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args);
+
+               void lock();
+               void unlock();
+               bool isLocked() const;
+
+               void defrag();
+
+       private:
+               std::vector<DELEGATE> m_delegates;
+               int m_lockCount;
+               bool m_isFragmented;
+       };
+}
+
+#include "Event.hpp"
+
+#endif // __UCL_MISC_EVENT_H__
diff --git a/ucl/include/ucl/misc/Event.hpp b/ucl/include/ucl/misc/Event.hpp
new file mode 100644 (file)
index 0000000..ed4e402
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * 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 <algorithm>
+
+namespace ucl { namespace { namespace impl {
+
+       template <class PREDICATE, class DELEGATE, class ...ARGS>
+       auto doInvokePred(PREDICATE &&pred,
+                       const DELEGATE &delegate, ARGS &&...args) ->
+                               decltype(pred(delegate(std::forward<ARGS>(args)...)))
+       {
+               return pred(delegate(std::forward<ARGS>(args)...));
+       }
+
+       template <class DELEGATE, class PREDICATE, class ...ARGS>
+       auto doInvokePred(PREDICATE &&pred,
+                       const DELEGATE &delegate, ARGS &&...args) -> decltype(pred())
+       {
+               delegate(std::forward<ARGS>(args)...);
+               return pred();
+       }
+}}}
+
+namespace ucl {
+
+       template <class DELEGATE>
+       Event<DELEGATE>::Event() :
+               m_lockCount(0),
+               m_isFragmented(false)
+       {
+       }
+
+       template <class DELEGATE>
+       template <class DELEGATE2>
+       void Event<DELEGATE>::operator+=(DELEGATE2 &&delegate)
+       {
+               m_delegates.emplace_back(std::forward<DELEGATE2>(delegate));
+       }
+
+       template <class DELEGATE>
+       template <class DELEGATE2>
+       void Event<DELEGATE>::operator-=(const DELEGATE2 &delegate)
+       {
+               const auto it = std::find(
+                               m_delegates.begin(), m_delegates.end(), delegate);
+               if (it != m_delegates.end()) {
+                       if (isLocked()) {
+                               *it = {};
+                               m_isFragmented = true;
+                       } else {
+                               m_delegates.erase(it);
+                       }
+               }
+       }
+
+       template <class DELEGATE>
+       bool Event<DELEGATE>::isEmpty() const
+       {
+               return m_delegates.empty();
+       }
+
+       template <class DELEGATE>
+       template <class ...ARGS>
+       void Event<DELEGATE>::dispatch(ARGS &&...args)
+       {
+               dispatchImpl(
+                       [](const DELEGATE &delegate, ARGS &&...args)
+                       {
+                               delegate(std::forward<ARGS>(args)...);
+                               return true;
+                       },
+                       std::forward<ARGS>(args)...);
+       }
+
+       template <class DELEGATE>
+       template <class PREDICATE, class ...ARGS>
+       void Event<DELEGATE>::dispatchPred(PREDICATE &&pred, ARGS &&...args)
+       {
+               dispatchImpl(
+                       [&pred](const DELEGATE &delegate, ARGS &&...args)
+                       {
+                               return impl::doInvokePred(std::forward<PREDICATE>(pred),
+                                               delegate, std::forward<ARGS>(args)...);
+                       },
+                       std::forward<ARGS>(args)...);
+       }
+
+       template <class DELEGATE>
+       template <class DO_INVOKE, class ...ARGS>
+       void Event<DELEGATE>::dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args)
+       {
+               lock();
+               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)...)) {
+                                       break;
+                               }
+                       } else {
+                               m_isFragmented = true;
+                       }
+               }
+               unlock();
+               defrag();
+       }
+
+       template <class DELEGATE>
+       void Event<DELEGATE>::lock()
+       {
+               ++m_lockCount;
+       }
+
+       template <class DELEGATE>
+       void Event<DELEGATE>::unlock()
+       {
+               --m_lockCount;
+       }
+
+       template <class DELEGATE>
+       bool Event<DELEGATE>::isLocked() const
+       {
+               return (m_lockCount > 0);
+       }
+
+       template <class DELEGATE>
+       void Event<DELEGATE>::defrag()
+       {
+               if (m_isFragmented) {
+                       m_isFragmented = false;
+                       m_delegates.erase(
+                               std::remove_if(m_delegates.begin(), m_delegates.end(),
+                                       [](const DELEGATE &delegate) -> bool
+                                       {
+                                               return !delegate;
+                                       }),
+                               m_delegates.end());
+               }
+       }
+}
diff --git a/ucl/include/ucl/misc/HashMap.h b/ucl/include/ucl/misc/HashMap.h
new file mode 100644 (file)
index 0000000..8470fed
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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_HASH_MAP_H__
+#define __UCL_MISC_HASH_MAP_H__
+
+#include <unordered_map>
+
+#include "Variant.h"
+
+namespace ucl {
+
+       template <class KEY, class VALUE>
+       class HashMap;
+
+       template <class VALUE>
+       using Dict = HashMap<std::string, VALUE>;
+
+       using VarDict = Dict<Variant>;
+
+       template <class KEY, class VALUE>
+       class HashMap final {
+       public:
+               template <class VALUE2>
+               HashMap &set(const KEY &key, VALUE2 &&value);
+               HashMap &unset(const KEY &key);
+
+               template <class VALUE2>
+               bool get(const KEY &key, VALUE2 &value) const;
+               VALUE get(const KEY &key) const;
+
+               void clear();
+
+       private:
+               template <class ENUM_CLASS>
+               struct EnumClassHash final {
+                       size_t operator()(ENUM_CLASS key) const {
+                               return static_cast<size_t>(key);
+                       }
+               };
+
+               template <class KEY2, class = void>
+               struct GetHash final {
+                       using Type = std::hash<KEY2>;
+               };
+
+               template <class KEY2>
+               struct GetHash<KEY2, typename std::enable_if<
+                               std::is_enum<KEY2>::value>::type> {
+                       using Type = EnumClassHash<KEY2>;
+               };
+
+               template <class KEY2>
+               struct GetHash<KEY2, typename std::enable_if<
+                               std::is_class<typename KEY2::Hash>::value>::type> {
+                       using Type = typename KEY2::Hash;
+               };
+
+               using Hash = typename GetHash<KEY>::Type;
+
+       private:
+               std::unordered_map<KEY, VALUE, Hash> m_map;
+       };
+}
+
+#include "HashMap.hpp"
+
+#endif // __UCL_MISC_HASH_MAP_H__
diff --git a/ucl/include/ucl/misc/HashMap.hpp b/ucl/include/ucl/misc/HashMap.hpp
new file mode 100644 (file)
index 0000000..2ba4ffd
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class KEY, class VALUE>
+       template <class VALUE2>
+       inline HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
+                       set(const KEY &key, VALUE2 &&value)
+       {
+               m_map.emplace(key, std::forward<VALUE2>(value));
+               return *this;
+       }
+
+       template <class KEY, class VALUE>
+       inline HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
+                       unset(const KEY &key)
+       {
+               m_map.erase(key);
+               return *this;
+       }
+
+       template <class KEY, class VALUE>
+       template <class VALUE2>
+       inline bool HashMap<KEY, VALUE>::
+                       get(const KEY &key, VALUE2 &value) const
+       {
+               const auto it = m_map.find(key);
+               if (it == m_map.end()) {
+                       return false;
+               }
+               value = it->second;
+               return true;
+       }
+
+       template <class KEY, class VALUE>
+       inline VALUE HashMap<KEY, VALUE>::
+                       get(const KEY &key) const
+       {
+               const auto it = m_map.find(key);
+               if (it == m_map.end()) {
+                       return {};
+               }
+               return it->second;
+       }
+
+       template <class KEY, class VALUE>
+       inline void HashMap<KEY, VALUE>::clear()
+       {
+               m_map.clear();
+       }
+}
diff --git a/ucl/include/ucl/misc/RefCountAware.h b/ucl/include/ucl/misc/RefCountAware.h
new file mode 100644 (file)
index 0000000..6ea5ee9
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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_REF_COUNT_AWARE_H__
+#define __UCL_MISC_REF_COUNT_AWARE_H__
+
+#include "ucl/util/types.h"
+#include "ucl/util/memory.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(RefCountAware);
+
+       class RefCountAware : public Polymorphic {
+       public:
+               bool isShared() const;
+               UInt getUseCount() const;
+               const void *getObjPtr() const;
+
+               template <class T>
+               SharedRef<T> asSharedThis(T *thisAlias) const;
+
+               template <class T>
+               WeakRef<T> asWeakThis(T *thisAlias) const;
+
+       protected:
+               RefCountAware(IRefCountObj *rc);
+               virtual ~RefCountAware() = default;
+
+       public:
+               // This section MUST be public!
+               // Signal to RefCountObj<T, C> to pass IRefCountObj to constructor
+               enum { _IS_REF_COUNT_AWARE };
+
+       private:
+               IRefCountObj *const m_rc;
+       };
+
+       // Non-member functions //
+
+       template <class T>
+       SharedRef<T> asShared(T &obj);
+       template <class T>
+       SharedRef<T> asShared(T *obj);
+
+       template <class T>
+       WeakRef<T> asWeak(T &obj);
+       template <class T>
+       WeakRef<T> asWeak(T *obj);
+
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, U>::value>::type>
+       SharedRef<T> asShared(U &obj);
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, U>::value>::type>
+       SharedRef<T> asShared(U *obj);
+
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, U>::value>::type>
+       WeakRef<T> asWeak(U &obj);
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, U>::value>::type>
+       WeakRef<T> asWeak(U *obj);
+
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, const U>::value>::type>
+       SharedRef<const T> asShared(const U &obj);
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, const U>::value>::type>
+       SharedRef<const T> asShared(const U *obj);
+
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, const U>::value>::type>
+       WeakRef<const T> asWeak(const U &obj);
+       template <class T, class U, class = typename
+                       std::enable_if<!std::is_same<T, const U>::value>::type>
+       WeakRef<const T> asWeak(const U *obj);
+}
+
+#include "RefCountAware.hpp"
+
+#endif // __UCL_MISC_REF_COUNT_AWARE_H__
diff --git a/ucl/include/ucl/misc/RefCountAware.hpp b/ucl/include/ucl/misc/RefCountAware.hpp
new file mode 100644 (file)
index 0000000..8fb3812
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * 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 ucl {
+
+       inline RefCountAware::RefCountAware(IRefCountObj *const rc) :
+               m_rc(rc)
+       {
+       }
+
+       inline bool RefCountAware::isShared() const
+       {
+               return !!m_rc;
+       }
+
+       inline UInt RefCountAware::getUseCount() const
+       {
+               if (!isShared()) {
+                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+                       return 0;
+               }
+               return m_rc->getUseCount();
+       }
+
+       inline const void *RefCountAware::getObjPtr() const
+       {
+               if (!isShared()) {
+                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+                       return nullptr;
+               }
+               return m_rc->getObjPtr();
+       }
+
+       template <class T>
+       inline SharedRef<T> RefCountAware::asSharedThis(T *const thisAlias) const
+       {
+               if (!isShared()) {
+                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+                       return {};
+               }
+               return {m_rc, thisAlias};
+       }
+
+       template <class T>
+       inline WeakRef<T> RefCountAware::asWeakThis(T *const thisAlias) const
+       {
+               if (!isShared()) {
+                       UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+                       return {};
+               }
+               return {m_rc, thisAlias};
+       }
+
+       // Non-member functions //
+
+       template <class T>
+       inline SharedRef<T> asShared(T &obj)
+       {
+               return obj.template asSharedThis<T>(&obj);
+       }
+
+       template <class T>
+       inline SharedRef<T> asShared(T *obj)
+       {
+               if (!obj) return {};
+               return obj->template asSharedThis<T>(obj);
+       }
+
+       template <class T>
+       inline WeakRef<T> asWeak(T &obj)
+       {
+               return obj.template asWeakThis<T>(&obj);
+       }
+
+       template <class T>
+       inline WeakRef<T> asWeak(T *obj)
+       {
+               if (!obj) return {};
+               return obj->template asWeakThis<T>(obj);
+       }
+
+       template <class T, class U, class>
+       inline SharedRef<T> asShared(U &obj)
+       {
+               return obj.template asSharedThis<T>(&obj);
+       }
+
+       template <class T, class U, class>
+       inline SharedRef<T> asShared(U *obj)
+       {
+               if (!obj) return {};
+               return obj->template asSharedThis<T>(obj);
+       }
+
+       template <class T, class U, class>
+       inline WeakRef<T> asWeak(U &obj)
+       {
+               return obj.template asWeakThis<T>(&obj);
+       }
+
+       template <class T, class U, class>
+       inline WeakRef<T> asWeak(U *obj)
+       {
+               if (!obj) return {};
+               return obj->template asWeakThis<T>(obj);
+       }
+
+       template <class T, class U, class>
+       inline SharedRef<const T> asShared(const U &obj)
+       {
+               return obj.template asSharedThis<const T>(&obj);
+       }
+
+       template <class T, class U, class>
+       inline SharedRef<const T> asShared(const U *obj)
+       {
+               if (!obj) return {};
+               return obj->template asSharedThis<const T>(obj);
+       }
+
+       template <class T, class U, class>
+       inline WeakRef<const T> asWeak(const U &obj)
+       {
+               return obj.template asWeakThis<const T>(&obj);
+       }
+
+       template <class T, class U, class>
+       inline WeakRef<const T> asWeak(const U *obj)
+       {
+               if (!obj) return {};
+               return obj->template asWeakThis<const T>(obj);
+       }
+}
diff --git a/ucl/include/ucl/misc/TString.h b/ucl/include/ucl/misc/TString.h
new file mode 100644 (file)
index 0000000..71ca2d9
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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_T_STRING_H__
+#define __UCL_MISC_T_STRING_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+       class TString final {
+       public:
+               TString();
+
+               /**
+                * Constructs TString from std::string and domain
+                *
+                * @param str     Text string or string id if translatable.
+                * @param domain  Valid domain name or "" for default domain,
+                *                nullptr - if string is not translatable
+                */
+               TString(const std::string &str, const char *domain);
+               TString(const std::string &str, bool translatable = false);
+
+               TString(std::string &&str, const char *domain);
+               TString(std::string &&str, bool translatable = false);
+
+               TString(const char *str, const char *domain);
+               TString(const char *str, bool translatable = false);
+
+               bool isEmpty() const;
+
+               bool isTranslatable() const;
+               bool hasDomain() const;
+               const char *getDomain() const;
+
+               const std::string &getStr() const;
+               operator const std::string &() const;
+
+               const char *getCStr() const;
+               operator const char *() const;
+
+               const char *translate() const;
+
+               template <typename ...ARGS>
+               std::string format(ARGS ...args) const;
+
+       private:
+               const char *doTranslate(const char *strId) const;
+
+       private:
+               std::string m_str;
+               const char *m_domain;
+       };
+}
+
+#include "TString.hpp"
+
+#endif // __UCL_MISC_T_STRING_H__
diff --git a/ucl/include/ucl/misc/TString.hpp b/ucl/include/ucl/misc/TString.hpp
new file mode 100644 (file)
index 0000000..01c1327
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * 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 <libintl.h>
+#include <app_i18n.h>
+
+#include "ucl/util/helpers.h"
+
+namespace ucl {
+
+       inline TString::TString() :
+               m_domain(nullptr)
+       {
+       }
+
+       inline TString::TString(const std::string &str, const char *const domain) :
+               m_str(str),
+               m_domain(m_str.empty() ? nullptr : domain)
+       {
+       }
+
+       inline TString::TString(const std::string &str, const bool translatable) :
+               TString(str, (translatable ? "" : nullptr))
+       {
+       }
+
+       inline TString::TString(std::string &&str, const char *const domain) :
+               m_str(std::move(str)),
+               m_domain(m_str.empty() ? nullptr : domain)
+       {
+       }
+
+       inline TString::TString(std::string &&str, const bool translatable) :
+               TString(std::move(str), (translatable ? "" : nullptr))
+       {
+       }
+
+       inline TString::TString(const char *const str, const char *const domain) :
+               TString(std::string(nz(str)), domain)
+       {
+       }
+
+       inline TString::TString(const char *const str, const bool translatable) :
+               TString(std::string(nz(str)), (translatable ? "" : nullptr))
+       {
+       }
+
+       inline bool TString::isEmpty() const
+       {
+               return m_str.empty();
+       }
+
+       inline const std::string &TString::getStr() const
+       {
+               return m_str;
+       }
+
+       inline TString::operator const std::string &() const
+       {
+               return m_str;
+       }
+
+       inline const char *TString::getCStr() const
+       {
+               return m_str.c_str();
+       }
+
+       inline TString::operator const char *() const
+       {
+               return m_str.c_str();
+       }
+
+       inline bool TString::isTranslatable() const
+       {
+               return (m_domain != nullptr);
+       }
+
+       inline bool TString::hasDomain() const
+       {
+               return isNotEmpty(m_domain);
+       }
+
+       inline const char *TString::getDomain() const
+       {
+               return m_domain;
+       }
+
+       inline const char *TString::translate() const
+       {
+               if (!m_domain) {
+                       return getCStr();
+               }
+               return doTranslate(getCStr());
+       }
+
+       inline const char *TString::doTranslate(const char *const strId) const
+       {
+               if (m_domain[0] == '\0') {
+                       return i18n_get_text(strId);
+               }
+               return dgettext(m_domain, strId);
+       }
+
+       template <typename ...ARGS>
+       inline std::string TString::format(ARGS ...args) const
+       {
+               constexpr auto STR_LEN_ADJUST = 1.7f;
+
+               const char *fmt = m_str.c_str();
+               size_t fmtLen = m_str.length();
+
+               if (m_domain) {
+                       fmt = doTranslate(fmt);
+                       fmtLen = strlen(fmt);
+               }
+
+               size_t strLen = static_cast<size_t>(fmtLen * STR_LEN_ADJUST);
+
+               std::string result;
+
+               while (1) {
+                       result.resize(strLen);
+                       const size_t n = snprintf(&result[0], strLen, fmt, args...);
+                       if (n < strLen) {
+                               result.resize(n);
+                               break;
+                       }
+                       strLen = n + 1;
+               }
+
+               return result;
+       }
+}
diff --git a/ucl/include/ucl/misc/Timeout.h b/ucl/include/ucl/misc/Timeout.h
new file mode 100644 (file)
index 0000000..165265c
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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_TIMEOUT_H__
+#define __UCL_MISC_TIMEOUT_H__
+
+#include <Ecore.h>
+
+#include "ucl/util/types.h"
+#include "ucl/util/smartDelegation.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(Timeout);
+
+       class Timeout final : public NonCopyable {
+       public:
+               using TimeoutHandler = WeakDelegate<void(Timeout *sender)>;
+
+       public:
+               static TimeoutSRef create(double timeoutSec,
+                               const TimeoutHandler &handler);
+
+               bool isExpired() const;
+
+       private:
+               friend class ReffedObj<Timeout>;
+               Timeout(const TimeoutHandler &handler);
+               ~Timeout();
+
+               Result prepare(double timeoutSec);
+
+               Eina_Bool onTimer();
+
+       private:
+               Ecore_Timer *m_timer;
+               TimeoutHandler m_handler;
+       };
+}
+
+#endif // __UCL_MISC_TIMEOUT_H__
diff --git a/ucl/include/ucl/misc/Variant.h b/ucl/include/ucl/misc/Variant.h
new file mode 100644 (file)
index 0000000..6542358
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * 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_VARIANT_H__
+#define __UCL_MISC_VARIANT_H__
+
+#include <array>
+#include <vector>
+#include <initializer_list>
+
+#include "ConstCString.h"
+
+namespace ucl {
+
+       class Variant;
+
+       using VarVector = std::vector<Variant>;
+
+       template <size_t N>
+       using VarArray = std::array<Variant, N>;
+
+       struct VarInitList final {
+               VarInitList(const std::initializer_list<Variant> &il) : il(il) {}
+               const std::initializer_list<Variant> &il;
+       };
+
+       class Variant final {
+       public:
+               enum Type {
+                       TYPE_NIL,
+                       TYPE_BOOLEAN,
+                       TYPE_INTEGER,
+                       TYPE_FLOAT,
+                       TYPE_DOUBLE,
+                       TYPE_STRING,
+                       TYPE_ARRAY
+               };
+
+       public:
+               friend void swap(Variant &x, Variant &y) noexcept;
+
+               friend bool operator==(const Variant &lhs, const Variant &rhs) noexcept;
+               friend bool operator!=(const Variant &lhs, const Variant &rhs) noexcept;
+
+       public:
+               Variant() noexcept;
+               Variant(std::nullptr_t) noexcept;
+
+               Variant(bool aBool) noexcept;
+               Variant(int anInt) noexcept;
+               Variant(float aFloat) noexcept;
+               Variant(double aDouble) noexcept;
+
+               Variant(const char *aString);
+               Variant(const char *aString, int length);
+               Variant(const std::string &aString);
+
+               Variant(std::nullptr_t, int arrayLength);
+               Variant(const Variant *anArray, int length);
+               Variant(const VarVector &anArray);
+               template <size_t N>
+               Variant(const VarArray<N> &anArray);
+               Variant(const VarInitList &anArray);
+
+               ~Variant();
+
+               Variant(const Variant &v);
+               Variant(Variant &&v) noexcept;
+
+               Variant &operator=(Variant v);
+
+               Type getType() const noexcept;
+               int getLength() const noexcept;
+               bool isEmpty() const noexcept;
+
+               bool asBool() const noexcept;
+               int asInt() const noexcept;
+               float asFloat() const noexcept;
+               double asDouble() const noexcept;
+
+               ConstCString asString() const noexcept;
+
+               Variant *asArray() noexcept;
+               const Variant *asArray() const noexcept;
+
+               Variant *begin() noexcept;
+               Variant *end() noexcept;
+               const Variant *begin() const noexcept;
+               const Variant *end() const noexcept;
+
+               Variant &operator[](int index) noexcept;
+               const Variant &operator[](int index) const noexcept;
+
+               explicit operator bool() const noexcept;
+               explicit operator int() const noexcept;
+               explicit operator float() const noexcept;
+               explicit operator double() const noexcept;
+
+               bool operator==(Variant::Type rhs) const noexcept;
+               bool operator!=(Variant::Type rhs) const noexcept;
+
+       private:
+               const char *getStr() const noexcept;
+
+       public:
+               union {
+                       uint8_t m_type;
+                       struct {
+                               uint64_t qw1;
+                               uint64_t qw2;
+                       } m_raw;
+                       struct { uint8_t type; bool value; } m_aBool;
+                       struct { uint8_t type; int value; } m_anInt;
+                       struct { uint8_t type; float value; } m_aFloat;
+                       struct { uint8_t type; double value; } m_aDouble;
+                       struct {
+                               uint8_t type;
+                               char buffer[sizeof(m_raw) - 1];
+                       } m_aSmallStr;
+                       struct {
+                               uint8_t type;
+                               int length;
+                               char *data;
+                       } m_aString;
+                       struct {
+                               uint8_t type;
+                               int length;
+                               Variant *data;
+                       } m_anArray;
+               };
+       };
+}
+
+#include "Variant.hpp"
+
+#endif // __UCL_MISC_VARIANT_H__
diff --git a/ucl/include/ucl/misc/Variant.hpp b/ucl/include/ucl/misc/Variant.hpp
new file mode 100644 (file)
index 0000000..fe6d977
--- /dev/null
@@ -0,0 +1,249 @@
+/*
+ * 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 <cstring>
+
+namespace ucl { namespace { namespace impl {
+
+       constexpr auto TYPE_MASK = 0x0F;
+
+       constexpr auto FLAG_SMALL_STR = 0x80;
+       constexpr auto TYPE_SMALL_STR = (Variant::TYPE_STRING | FLAG_SMALL_STR);
+
+       constexpr auto TMP_STR_BUFF_SIZE = 32;
+}}}
+
+namespace ucl {
+
+       // Variant //
+
+       inline Variant::Variant() noexcept :
+               m_type(TYPE_NIL)
+       {
+       }
+
+       inline Variant::Variant(std::nullptr_t) noexcept :
+               Variant()
+       {
+       }
+
+       inline Variant::Variant(const bool aBool) noexcept :
+               m_type(TYPE_BOOLEAN)
+       {
+               m_aBool.value = aBool;
+       }
+
+       inline Variant::Variant(const int anInt) noexcept :
+               m_type(TYPE_INTEGER)
+       {
+               m_anInt.value = anInt;
+       }
+
+       inline Variant::Variant(const float aFloat) noexcept :
+               m_type(TYPE_FLOAT)
+       {
+               m_aFloat.value = aFloat;
+       }
+
+       inline Variant::Variant(const double aDouble) noexcept :
+               m_type(TYPE_DOUBLE)
+       {
+               m_aDouble.value = aDouble;
+       }
+
+       inline Variant::Variant(const char *const aString) :
+               Variant(aString, -1)
+       {
+       }
+
+       inline Variant::Variant(const std::string &aString) :
+               Variant(aString.c_str(), aString.size())
+       {
+       }
+
+       inline Variant::Variant(const VarVector &anArray) :
+               Variant(anArray.data(), anArray.size())
+       {
+       }
+
+       template <size_t N>
+       inline Variant::Variant(const VarArray<N> &anArray) :
+               Variant(anArray.data(), anArray.size())
+       {
+       }
+
+       inline Variant::Variant(const VarInitList &anArray) :
+               Variant(anArray.il.begin(), anArray.il.size())
+       {
+       }
+
+       inline Variant::~Variant()
+       {
+               switch (m_type) {
+               case TYPE_STRING:
+                       free(m_aString.data);
+                       break;
+               case TYPE_ARRAY:
+                       delete[] m_anArray.data;
+                       break;
+               }
+       }
+
+       inline Variant::Variant(Variant &&v) noexcept :
+               m_type(v.m_type)
+       {
+               switch (m_type) {
+               case TYPE_NIL:
+                       break;
+               case TYPE_STRING:
+                       m_aString.data = v.m_aString.data;
+                       m_aString.length = v.m_aString.length;
+                       v.m_type = TYPE_NIL;
+                       break;
+               case TYPE_ARRAY:
+                       m_anArray.data = v.m_anArray.data;
+                       m_anArray.length = v.m_anArray.length;
+                       v.m_type = TYPE_NIL;
+                       break;
+               default:
+                       m_raw = v.m_raw;
+                       break;
+               }
+       }
+
+       inline Variant &Variant::operator=(Variant v)
+       {
+               swap(*this, v);
+               return *this;
+       }
+
+       inline Variant::Type Variant::getType() const noexcept
+       {
+               return Type(m_type & impl::TYPE_MASK);
+       }
+
+       inline int Variant::getLength() const noexcept
+       {
+               switch (m_type) {
+               case TYPE_NIL:
+                       return 0;
+               case TYPE_STRING:
+                       return m_aString.length;
+               case TYPE_ARRAY:
+                       return m_anArray.length;
+               case impl::TYPE_SMALL_STR:
+                       return strlen(m_aSmallStr.buffer);
+               }
+               return 1;
+       }
+
+       inline bool Variant::isEmpty() const noexcept
+       {
+               return (getLength() == 0);
+       }
+
+       inline const char *Variant::getStr() const noexcept
+       {
+               return ((m_type == TYPE_STRING) ? m_aString.data : m_aSmallStr.buffer);
+       }
+
+       inline Variant *Variant::asArray() noexcept
+       {
+               return begin();
+       }
+
+       inline const Variant *Variant::asArray() const noexcept
+       {
+               return begin();
+       }
+
+       inline Variant *Variant::begin() noexcept
+       {
+               return ((m_type == TYPE_ARRAY) ? m_anArray.data : this);
+       }
+
+       inline Variant *Variant::end() noexcept
+       {
+               return ((m_type == TYPE_ARRAY) ?
+                               (m_anArray.data + m_anArray.length) : (this + 1));
+       }
+
+       inline const Variant *Variant::begin() const noexcept
+       {
+               return const_cast<Variant *>(this)->begin();
+       }
+
+       inline const Variant *Variant::end() const noexcept
+       {
+               return const_cast<Variant *>(this)->end();
+       }
+
+       inline Variant &Variant::operator[](int index) noexcept
+       {
+               return asArray()[index];
+       }
+
+       inline const Variant &Variant::operator[](int index) const noexcept
+       {
+               return asArray()[index];
+       }
+
+       inline Variant::operator bool() const noexcept
+       {
+               return asBool();
+       }
+
+       inline Variant::operator int() const noexcept
+       {
+               return asInt();
+       }
+
+       inline Variant::operator float() const noexcept
+       {
+               return asFloat();
+       }
+
+       inline Variant::operator double() const noexcept
+       {
+               return asDouble();
+       }
+
+       inline bool Variant::operator==(const Variant::Type rhs) const noexcept
+       {
+               return (m_type == rhs);
+       }
+
+       inline bool Variant::operator!=(const Variant::Type rhs) const noexcept
+       {
+               return (m_type != rhs);
+       }
+
+       // Non-member functions //
+
+       inline void swap(Variant &x, Variant &y) noexcept
+       {
+               static_assert(sizeof(Variant) == sizeof(Variant::m_raw),
+                               "Invalid Variant data structure!");
+               static_assert(std::is_standard_layout<Variant>::value,
+                               "Variant has not standard layout!");
+               std::swap(x.m_raw, y.m_raw);
+       }
+
+       inline bool operator!=(const Variant &lhs, const Variant &rhs) noexcept
+       {
+               return !(lhs == rhs);
+       }
+}
diff --git a/ucl/include/ucl/mvp/GuiPresenter.h b/ucl/include/ucl/mvp/GuiPresenter.h
new file mode 100644 (file)
index 0000000..5a94af4
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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_MVP_GUI_PRESENTER_H__
+#define __UCL_MVP_GUI_PRESENTER_H__
+
+#include <unordered_set>
+
+#include "ucl/gui/Window.h"
+
+#include "types.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(GuiPresenter);
+
+       class GuiPresenter : public RefCountAware {
+       public:
+               struct DeactivatorInfo final {
+                       const void *deactivator;
+                       bool isBroadcast;
+               };
+
+       public:
+               bool isActive() const;
+               bool isDeactivatedBy(const void *deactivator) const;
+
+               void activateBy(const void *deactivator);
+               void deactivateBy(const void *deactivator);
+
+               void addDeactivatorSource(Widget &source);
+               void delDeactivatorSource(Widget &source);
+
+       protected:
+               enum {
+                       PF_ADD_DEACTIVATOR_SOURCES = 1,
+                       PF_ADD_SELF_EXCEPT = 2,
+
+                       PF_PASSIVE = 0,
+                       PF_DEACTIVATOR = (PF_ADD_DEACTIVATOR_SOURCES | PF_ADD_SELF_EXCEPT),
+                       PF_DEFAULT = PF_ADD_DEACTIVATOR_SOURCES
+               };
+
+       protected:
+               GuiPresenter(IRefCountObj &rc);
+               virtual ~GuiPresenter();
+
+               Result prepare(ElmWidget &widget, int flags = PF_DEFAULT);
+               Result prepare(GuiPresenter &parent, int flags = PF_DEFAULT);
+
+               Window &getWindow();
+               bool isWindowReady() const;
+
+               void addDeactivatorException(const void *deactivator);
+               void setDeactivatorSink(const WidgetSRef &sink);
+
+               void sendActivate(Widget &sender);
+               void sendDeactivate(Widget &sender);
+
+               void broadcastActivate();
+               void broadcastDeactivate();
+
+               virtual void onActivate();
+               virtual void onDeactivate();
+               virtual void onActivateBy(const DeactivatorInfo &info);
+               virtual void onDeactivateBy(const DeactivatorInfo &info);
+
+       private:
+               void sendDeactivator(Widget &sender,
+                               SmartEvent event, const void *deactivator);
+               void broadcastDeactivator(SmartEvent event,
+                               const void *deactivator);
+
+               void sendDeactivatorInfo(Widget &sender, SmartEvent event,
+                               const DeactivatorInfo &info);
+
+               void activateByImpl(const DeactivatorInfo &info);
+               void deactivateByImpl(const DeactivatorInfo &info);
+
+               void onActivateBySmart(Widget &widget, void *eventInfo);
+               void onDeactivateBySmart(Widget &widget, void *eventInfo);
+
+       private:
+               std::unordered_set<const void *> m_deactivatorExceptions;
+               std::unordered_set<const void *> m_deactivators;
+               WindowSRef m_window;
+               WidgetSRef m_sink;
+               WidgetWRef m_parentSink;
+               bool m_hasBuildInSources;
+               bool m_isChild;
+               bool m_isPrepared;
+       };
+}
+
+#endif // __UCL_MVP_GUI_PRESENTER_H__
diff --git a/ucl/include/ucl/mvp/ListItemPresenter.h b/ucl/include/ucl/mvp/ListItemPresenter.h
new file mode 100644 (file)
index 0000000..46d2fb4
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * 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_MVP_LIST_ITEM_PRESENTER_H__
+#define __UCL_MVP_LIST_ITEM_PRESENTER_H__
+
+#include "ucl/gui/GenlistItem.h"
+#include "ucl/gui/ElmWidget.h"
+
+#include "ucl/misc/HashMap.h"
+
+#include "types.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(ListItemPresenter);
+
+       class ListItemPresenter : public RefCountAware,
+                       public IDisposable {
+       public:
+               // IDisposable //
+
+               virtual void dispose() final override;
+               virtual bool isDisposed() const final override;
+
+       protected:
+               friend class ListPresenter;
+
+               UCL_DECLARE_REF_ALIASES(ItemClass);
+               UCL_DECLARE_REF_ALIASES(ItemClassCache);
+
+               // Flags
+               enum {
+                       PF_AUTO_UNSELECT = 1
+               };
+
+               struct ItemInsertionParams {
+                       ElmStyle itemStyle;
+                       GenlistItem::Type itemType;
+
+                       ItemInsertionParams(ElmStyle itemStyle,
+                                       GenlistItem::Type itemType = GenlistItem::Type::SIMPLE) :
+                               itemStyle(itemStyle), itemType(itemType) {}
+               };
+
+               class ItemClass final : public NonCopyable {
+               public:
+                       static ItemClassSRef newInstance(ElmStyle itemStyle);
+               public:
+                       Elm_Genlist_Item_Class *get();
+               private:
+                       friend class ReffedObj<ItemClass>;
+                       ItemClass(ElmStyle itemStyle);
+                       ~ItemClass();
+               private:
+                       Elm_Genlist_Item_Class *const m_itc;
+               };
+
+               class ItemClassCache final : public NonCopyable {
+               public:
+                       ItemClassSRef getItemClass(ElmStyle itemStyle);
+                       void purge();
+               private:
+                       HashMap<ElmStyle, ItemClassSRef> m_itcMap;
+               };
+
+       protected:
+               ListItemPresenter(IRefCountObj &rc);
+               virtual ~ListItemPresenter();
+
+               void setFlags(int flags);
+               int getFlags() const;
+
+               bool isActive() const;
+
+               GenlistItem getItem();
+               ItemClassCache *getItemClassCache();
+
+               Result updateItemStyle(ElmStyle newItemStyle);
+
+               virtual ItemInsertionParams getItemInsertionParams() = 0;
+
+               virtual void onItemAttached();
+               virtual void onItemDetached();
+
+               virtual CString getItemPartText(EdjePart part);
+               virtual WidgetSRef getItemPartContent(EdjePart part, ElmWidget &parent);
+               virtual bool getItemPartState(EdjePart part);
+
+               virtual void onItemSelected();
+               virtual void onItemRealized();
+               virtual void onItemUnrealized();
+               virtual void onItemHighlighted();
+               virtual void onItemUnhighlighted();
+
+       private:
+               void attachItem(GenlistItem item,
+                               ElmWidgetSRef &&parent,
+                               const ItemClassCacheSRef &itcCache,
+                               const SharedRef<bool> &isActiveRef);
+
+               void deleteDetachedItem(bool silent = false);
+               void detachItem(bool silent = false);
+
+               void onItemSelectedHook();
+               void onItemDel(Evas_Object *obj, void *eventInfo);
+
+       private:
+               ListItemPresenterSRef m_selfRef;
+               GenlistItem m_item;
+               ItemClassCacheSRef m_itcCache;
+               SharedRef<bool> m_isActiveRef;
+               ElmWidgetSRef m_parent;
+               int m_flags;
+       };
+}
+
+#endif // __UCL_MVP_LIST_ITEM_PRESENTER_H__
diff --git a/ucl/include/ucl/mvp/ListPresenter.h b/ucl/include/ucl/mvp/ListPresenter.h
new file mode 100644 (file)
index 0000000..1d62e41
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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_MVP_LIST_PRESENTER_H__
+#define __UCL_MVP_LIST_PRESENTER_H__
+
+#include "ucl/gui/Genlist.h"
+
+#include "GuiPresenter.h"
+#include "ListItemPresenter.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(ListPresenter);
+
+       class ListPresenter final : public GuiPresenter {
+       public:
+               enum {
+                       FLAG_HOMOGENEOUS = (1 << 0),
+                       FLAG_CALC_X_MIN = (1 << 1),
+                       FLAG_CALC_Y_MIN = (1 << 2),
+
+                       FLAG_NOTIFY_REALIZED = (1 << 8),
+                       FLAG_NOTIFY_UNREALIZED = (1 << 9),
+                       FLAG_NOTIFY_HIGHLIGHTED = (1 << 10),
+                       FLAG_NOTIFY_UNHIGHLIGHTED = (1 << 11),
+               };
+
+               class Builder final {
+               public:
+                       Builder();
+                       Builder &setStyle(ElmStyle style);
+                       Builder &setFlags(int flags);
+                       Builder &setParentWidget(const ElmWidgetSRef &parentWidget);
+                       ListPresenterSRef build(GuiPresenter &parent) const;
+               private:
+                       ucl::ElmWidgetSRef m_parentWidget;
+                       ElmStyle m_style;
+                       int m_flags;
+               };
+
+       public:
+               Genlist &getWidget();
+
+               void clear();
+
+               Result append(ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent = nullptr);
+
+               Result prepend(ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent = nullptr);
+
+               Result insertAfter(const ListItemPresenter &after,
+                               ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent = nullptr);
+
+               Result insertBefore(const ListItemPresenter &before,
+                               ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent = nullptr);
+
+       private:
+               friend class ReffedObj<ListPresenter>;
+               ListPresenter(IRefCountObj &rc);
+               virtual ~ListPresenter();
+
+               Result prepare(GuiPresenter &parent, ElmWidget &parentWidget,
+                               ElmStyle style, int flags);
+
+               template <class INSERT_FUNC>
+               Result insert(ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent,
+                               INSERT_FUNC &&insertFunc);
+
+               template <class INSERT_FUNC>
+               Result insertRelative(const ListItemPresenter &relative,
+                               ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent, INSERT_FUNC &&insertFunc);
+
+               void setIsActiveRef(bool value);
+
+               void onItemSelected(Widget &widget, void *eventInfo);
+
+               void onItemRealized(Widget &widget, void *eventInfo);
+               void onItemUnrealized(Widget &widget, void *eventInfo);
+               void onItemHighlighted(Widget &widget, void *eventInfo);
+               void onItemUnhighlighted(Widget &widget, void *eventInfo);
+
+               // GuiPresenter //
+
+               virtual void onActivate() final override;
+               virtual void onDeactivate() final override;
+
+       private:
+               GenlistSRef m_genlist;
+               ListItemPresenter::ItemClassCacheSRef m_itcCache;
+               SharedRef<bool> m_isActiveRef;
+       };
+}
+
+#endif // __UCL_MVP_LIST_PRESENTER_H__
diff --git a/ucl/include/ucl/mvp/types.h b/ucl/include/ucl/mvp/types.h
new file mode 100644 (file)
index 0000000..6c263e2
--- /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_MVP_TYPES_H__
+#define __UCL_MVP_TYPES_H__
+
+#include "ucl/gui/types.h"
+
+#endif // __UCL_MVP_TYPES_H__
diff --git a/ucl/include/ucl/util/delegation.h b/ucl/include/ucl/util/delegation.h
new file mode 100644 (file)
index 0000000..a624c08
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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_UTIL_DELEGATION_H__
+#define __UCL_UTIL_DELEGATION_H__
+
+#include "delegation/Callback.h"
+
+#include "delegation/BaseDelegate.h"
+#include "delegation/BaseDelegate2.h"
+
+#include "delegation/Delegate.h"
+#include "delegation/Delegate2.h"
+
+#include "delegation/helpers.h"
+#include "delegation/macro.h"
+
+#if (UCL_INCLUDE_DELEGATION_SHORT_MACRO_H)
+#include "delegation/shortMacro.h"
+#endif
+
+#endif // __UCL_UTIL_DELEGATION_H__
diff --git a/ucl/include/ucl/util/delegation/BaseDelegate.h b/ucl/include/ucl/util/delegation/BaseDelegate.h
new file mode 100644 (file)
index 0000000..62b92ff
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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_UTIL_DELEGATION_BASE_DELEGATE_H__
+#define __UCL_UTIL_DELEGATION_BASE_DELEGATE_H__
+
+#include "Callback.h"
+
+namespace ucl {
+
+       template <class FUNC_SIG, class DATA>
+       class BaseDelegate;
+
+       template <class FUNC_SIG, class DATA>
+       class BaseDelegate2;
+
+       template <class R, class ...ARGS, class DATA>
+       class BaseDelegate<R(ARGS...), DATA> {
+       public:
+               using Cb = Callback<R(ARGS...)>;
+               using StubA = typename Cb::StubA;
+
+       public:
+               constexpr BaseDelegate() noexcept;
+               constexpr BaseDelegate(std::nullptr_t) noexcept;
+
+               template <class FUNC_SIG>
+               BaseDelegate(const BaseDelegate2<FUNC_SIG, DATA> &d) noexcept;
+               template <class FUNC_SIG>
+               BaseDelegate(BaseDelegate2<FUNC_SIG, DATA> &&d) noexcept;
+
+               void reset() noexcept;
+
+               const DATA &getData() const noexcept;
+               StubA getStubA() const noexcept;
+               operator bool() const noexcept;
+
+       protected:
+               BaseDelegate(const DATA &data, StubA stubA) noexcept;
+
+       protected:
+               DATA m_data;
+               StubA m_stubA;
+       };
+}
+
+#include "BaseDelegate.hpp"
+
+#endif // __UCL_UTIL_DELEGATION_BASE_DELEGATE_H__
diff --git a/ucl/include/ucl/util/delegation/BaseDelegate.hpp b/ucl/include/ucl/util/delegation/BaseDelegate.hpp
new file mode 100644 (file)
index 0000000..f25c0a7
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class R, class ...ARGS, class DATA>
+       constexpr BaseDelegate<R(ARGS...), DATA>::BaseDelegate() noexcept :
+               m_data(nullptr),
+               m_stubA(nullptr)
+       {
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       constexpr BaseDelegate<R(ARGS...), DATA>::
+                       BaseDelegate(std::nullptr_t) noexcept :
+               BaseDelegate()
+       {
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       inline BaseDelegate<R(ARGS...), DATA>::
+                       BaseDelegate(const DATA &data, StubA stubA) noexcept :
+               m_data(data),
+               m_stubA(stubA)
+       {
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       template <class FUNC_SIG>
+       inline BaseDelegate<R(ARGS...), DATA>::
+                       BaseDelegate(const BaseDelegate2<FUNC_SIG, DATA> &d) noexcept :
+               m_data(d.m_data),
+               m_stubA(d.m_stubA)
+       {
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       template <class FUNC_SIG>
+       inline BaseDelegate<R(ARGS...), DATA>::
+                       BaseDelegate(BaseDelegate2<FUNC_SIG, DATA> &&d) noexcept :
+               m_data(std::move(d.m_data)),
+               m_stubA(d.m_stubA)
+       {
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       inline void BaseDelegate<R(ARGS...), DATA>::reset() noexcept
+       {
+               *this = {};
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       inline const DATA &BaseDelegate<R(ARGS...), DATA>::getData() const noexcept
+       {
+               return m_data;
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       inline typename BaseDelegate<R(ARGS...), DATA>::StubA
+                       BaseDelegate<R(ARGS...), DATA>::getStubA() const noexcept
+       {
+               return m_stubA;
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       inline BaseDelegate<R(ARGS...), DATA>::operator bool() const noexcept
+       {
+               return !!m_data;
+       }
+}
diff --git a/ucl/include/ucl/util/delegation/BaseDelegate2.h b/ucl/include/ucl/util/delegation/BaseDelegate2.h
new file mode 100644 (file)
index 0000000..ff3b635
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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_UTIL_DELEGATION_BASE_DELEGATE2_H__
+#define __UCL_UTIL_DELEGATION_BASE_DELEGATE2_H__
+
+#include "BaseDelegate.h"
+
+namespace ucl {
+
+       template <class FUNC_SIG, class DATA>
+       class BaseDelegate2;
+
+       template <class R, class ...ARGS, class DATA>
+       class BaseDelegate2<R(ARGS...), DATA> :
+                       public BaseDelegate<R(ARGS...), DATA> {
+       public:
+               using Cb = typename BaseDelegate2::Cb;
+               using StubA = typename Cb::StubA;
+               using StubB = typename Cb::StubB;
+
+       public:
+               using BaseDelegate<R(ARGS...), DATA>::BaseDelegate;
+
+               StubB getStubB() const noexcept;
+
+       protected:
+               BaseDelegate2(const DATA &data, StubA stubA, StubB stubB) noexcept;
+
+       private:
+               StubB m_stubB;
+       };
+}
+
+#include "BaseDelegate2.hpp"
+
+#endif // __UCL_UTIL_DELEGATION_BASE_DELEGATE2_H__
diff --git a/ucl/include/ucl/util/delegation/BaseDelegate2.hpp b/ucl/include/ucl/util/delegation/BaseDelegate2.hpp
new file mode 100644 (file)
index 0000000..6d8efa7
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class R, class ...ARGS, class DATA>
+       inline BaseDelegate2<R(ARGS...), DATA>::
+                       BaseDelegate2(const DATA &data, StubA stubA, StubB stubB) noexcept :
+               BaseDelegate<R(ARGS...), DATA>(data, stubA),
+               m_stubB(stubB)
+       {
+       }
+
+       template <class R, class ...ARGS, class DATA>
+       inline typename BaseDelegate2<R(ARGS...), DATA>::StubB
+                       BaseDelegate2<R(ARGS...), DATA>::getStubB() const noexcept
+       {
+               return m_stubB;
+       }
+}
diff --git a/ucl/include/ucl/util/delegation/Callback.h b/ucl/include/ucl/util/delegation/Callback.h
new file mode 100644 (file)
index 0000000..69724be
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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_UTIL_DELEGATION_CALLBACK_H__
+#define __UCL_UTIL_DELEGATION_CALLBACK_H__
+
+#include "ucl/util/types/baseTypes.h"
+
+namespace ucl {
+
+       template <class FUNC_SIG>
+       class Callback;
+
+       template <class R, class ...ARGS>
+       class Callback<R(ARGS...)> {
+       public:
+               using StubA = R(*)(void *, ARGS...);
+               using StubB = R(*)(ARGS..., void *);
+
+       public:
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+               static R stubA(void *data, ARGS ...args);
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+               static R stubB(ARGS ...args, void *data);
+
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+               static R stubA(void *data, ARGS ...args);
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+               static R stubB(ARGS ...args, void *data);
+
+               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+               static R stubA2A(void *data, ARGS ...args);
+               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+               static R stubB2A(ARGS ...args, void *data);
+
+               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+               static R stubA2B(void *data, ARGS ...args);
+               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+               static R stubB2B(ARGS ...args, void *data);
+
+               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+               static R stubA2A(void *data, ARGS ...args);
+               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+               static R stubB2A(ARGS ...args, void *data);
+
+               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+               static R stubA2B(void *data, ARGS ...args);
+               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+               static R stubB2B(ARGS ...args, void *data);
+
+               template <R(*FUNC)(ARGS...)>
+               static R stubA2V(void *data, ARGS ...args);
+               template <R(*FUNC)(ARGS...)>
+               static R stubB2V(ARGS ...args, void *data);
+       };
+}
+
+#include "Callback.hpp"
+
+#endif // __UCL_UTIL_DELEGATION_CALLBACK_H__
diff --git a/ucl/include/ucl/util/delegation/Callback.hpp b/ucl/include/ucl/util/delegation/Callback.hpp
new file mode 100644 (file)
index 0000000..28d2145
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+       inline R Callback<R(ARGS...)>::stubA(void *data, ARGS ...args)
+       {
+               return (static_cast<CLASS *>(data)->*METHOD)(
+                               std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+       inline R Callback<R(ARGS...)>::stubB(ARGS ...args, void *data)
+       {
+               return (static_cast<CLASS *>(data)->*METHOD)(
+                               std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+       inline R Callback<R(ARGS...)>::stubA(void *data, ARGS ...args)
+       {
+               return (static_cast<const CLASS *>(data)->*METHOD)(
+                               std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+       inline R Callback<R(ARGS...)>::stubB(ARGS ...args, void *data)
+       {
+               return (static_cast<const CLASS *>(data)->*METHOD)(
+                               std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+       inline R Callback<R(ARGS...)>::stubA2A(void *data, ARGS ...args)
+       {
+               return FUNC(*static_cast<CLASS *>(data), std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+       inline R Callback<R(ARGS...)>::stubB2A(ARGS ...args, void *data)
+       {
+               return FUNC(*static_cast<CLASS *>(data), std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+       inline R Callback<R(ARGS...)>::stubA2B(void *data, ARGS ...args)
+       {
+               return FUNC(std::forward<ARGS>(args)..., *static_cast<CLASS *>(data));
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+       inline R Callback<R(ARGS...)>::stubB2B(ARGS ...args, void *data)
+       {
+               return FUNC(std::forward<ARGS>(args)..., *static_cast<CLASS *>(data));
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+       inline R Callback<R(ARGS...)>::stubA2A(void *data, ARGS ...args)
+       {
+               return FUNC(static_cast<HANDLE>(data), std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+       inline R Callback<R(ARGS...)>::stubB2A(ARGS ...args, void *data)
+       {
+               return FUNC(static_cast<HANDLE>(data), std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+       inline R Callback<R(ARGS...)>::stubA2B(void *data, ARGS ...args)
+       {
+               return FUNC(std::forward<ARGS>(args)..., static_cast<HANDLE>(data));
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+       inline R Callback<R(ARGS...)>::stubB2B(ARGS ...args, void *data)
+       {
+               return FUNC(std::forward<ARGS>(args)..., static_cast<HANDLE>(data));
+       }
+
+       template <class R, class ...ARGS>
+       template <R(*FUNC)(ARGS...)>
+       inline R Callback<R(ARGS...)>::stubA2V(void *data, ARGS ...args)
+       {
+               return FUNC(std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <R(*FUNC)(ARGS...)>
+       inline R Callback<R(ARGS...)>::stubB2V(ARGS ...args, void *data)
+       {
+               return FUNC(std::forward<ARGS>(args)...);
+       }
+}
diff --git a/ucl/include/ucl/util/delegation/Delegate.h b/ucl/include/ucl/util/delegation/Delegate.h
new file mode 100644 (file)
index 0000000..e1e7416
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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_UTIL_DELEGATION_DELEGATE_H__
+#define __UCL_UTIL_DELEGATION_DELEGATE_H__
+
+#include "BaseDelegate.h"
+
+namespace ucl {
+
+       template <class FUNC_SIG>
+       class Delegate;
+
+       template <class R, class ...ARGS>
+       class Delegate<R(ARGS...)> : public BaseDelegate<R(ARGS...), void *> {
+       public:
+               using BaseDelegate<R(ARGS...), void *>::BaseDelegate;
+
+               R operator()(ARGS ...args) const;
+
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+               static Delegate make(CLASS *data) noexcept;
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+               static Delegate make(const CLASS *data) noexcept;
+
+               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+               static Delegate makeA(CLASS &data) noexcept;
+               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+               static Delegate makeB(CLASS &data) noexcept;
+
+               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+               static Delegate makeA(HANDLE data) noexcept;
+               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+               static Delegate makeB(HANDLE data) noexcept;
+
+               template <R(*FUNC)(ARGS...)>
+               static Delegate make() noexcept;
+       };
+}
+
+#include "Delegate.hpp"
+
+#endif // __UCL_UTIL_DELEGATION_DELEGATE_H__
diff --git a/ucl/include/ucl/util/delegation/Delegate.hpp b/ucl/include/ucl/util/delegation/Delegate.hpp
new file mode 100644 (file)
index 0000000..632ec24
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class R, class ...ARGS>
+       inline R Delegate<R(ARGS...)>::operator()(ARGS ...args) const
+       {
+               return this->m_stubA(this->m_data, std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+       inline Delegate<R(ARGS...)>
+                       Delegate<R(ARGS...)>::make(CLASS *const data) noexcept
+       {
+               return {static_cast<void *>(data),
+                               Delegate::Cb::template stubA<CLASS, METHOD>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+       inline Delegate<R(ARGS...)>
+                       Delegate<R(ARGS...)>::make(const CLASS *const data) noexcept
+       {
+               return {static_cast<void *>(const_cast<CLASS *>(data)),
+                               Delegate::Cb::template stubA<CLASS, METHOD>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+       inline Delegate<R(ARGS...)>
+                       Delegate<R(ARGS...)>::makeA(CLASS &data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(&data)),
+                               Delegate::Cb::template stubA2A<CLASS, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+       inline Delegate<R(ARGS...)>
+                       Delegate<R(ARGS...)>::makeB(CLASS &data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(&data)),
+                               Delegate::Cb::template stubA2B<CLASS, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+       inline Delegate<R(ARGS...)>
+                       Delegate<R(ARGS...)>::makeA(const HANDLE data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(data)),
+                               Delegate::Cb::template stubA2A<HANDLE, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+       inline Delegate<R(ARGS...)>
+                       Delegate<R(ARGS...)>::makeB(const HANDLE data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(data)),
+                               Delegate::Cb::template stubA2B<HANDLE, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <R(*FUNC)(ARGS...)>
+       inline Delegate<R(ARGS...)>
+                       Delegate<R(ARGS...)>::make() noexcept
+       {
+               return {nullptr, Delegate::Cb::template stubA2V<FUNC>};
+       }
+}
diff --git a/ucl/include/ucl/util/delegation/Delegate2.h b/ucl/include/ucl/util/delegation/Delegate2.h
new file mode 100644 (file)
index 0000000..56ff3fb
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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_UTIL_DELEGATION_DELEGATE2_H__
+#define __UCL_UTIL_DELEGATION_DELEGATE2_H__
+
+#include "BaseDelegate2.h"
+
+namespace ucl {
+
+       template <class FUNC_SIG>
+       class Delegate2;
+
+       template <class R, class ...ARGS>
+       class Delegate2<R(ARGS...)> : public BaseDelegate2<R(ARGS...), void *> {
+       public:
+               using BaseDelegate2<R(ARGS...), void *>::BaseDelegate2;
+
+               R operator()(ARGS ...args) const;
+
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+               static Delegate2 make(CLASS *data) noexcept;
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+               static Delegate2 make(const CLASS *data) noexcept;
+
+               template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+               static Delegate2 makeA(CLASS &data) noexcept;
+               template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+               static Delegate2 makeB(CLASS &data) noexcept;
+
+               template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+               static Delegate2 makeA(HANDLE data) noexcept;
+               template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+               static Delegate2 makeB(HANDLE data) noexcept;
+
+               template <R(*FUNC)(ARGS...)>
+               static Delegate2 make() noexcept;
+       };
+}
+
+#include "Delegate2.hpp"
+
+#endif // __UCL_UTIL_DELEGATION_DELEGATE2_H__
diff --git a/ucl/include/ucl/util/delegation/Delegate2.hpp b/ucl/include/ucl/util/delegation/Delegate2.hpp
new file mode 100644 (file)
index 0000000..085ba46
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class R, class ...ARGS>
+       inline R Delegate2<R(ARGS...)>::operator()(ARGS ...args) const
+       {
+               return this->m_stubA(this->m_data, std::forward<ARGS>(args)...);
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+       inline Delegate2<R(ARGS...)>
+                       Delegate2<R(ARGS...)>::make(CLASS *const data) noexcept
+       {
+               return {static_cast<void *>(data),
+                               Delegate2::Cb::template stubA<CLASS, METHOD>,
+                               Delegate2::Cb::template stubB<CLASS, METHOD>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+       inline Delegate2<R(ARGS...)>
+                       Delegate2<R(ARGS...)>::make(const CLASS *const data) noexcept
+       {
+               return {static_cast<void *>(const_cast<CLASS *>(data)),
+                               Delegate2::Cb::template stubA<CLASS, METHOD>,
+                               Delegate2::Cb::template stubB<CLASS, METHOD>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(CLASS &, ARGS...)>
+       inline Delegate2<R(ARGS...)>
+                       Delegate2<R(ARGS...)>::makeA(CLASS &data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(&data)),
+                               Delegate2::Cb::template stubA2A<CLASS, FUNC>,
+                               Delegate2::Cb::template stubB2A<CLASS, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(*FUNC)(ARGS..., CLASS &)>
+       inline Delegate2<R(ARGS...)>
+                       Delegate2<R(ARGS...)>::makeB(CLASS &data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(&data)),
+                               Delegate2::Cb::template stubA2B<CLASS, FUNC>,
+                               Delegate2::Cb::template stubB2B<CLASS, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(HANDLE, ARGS...)>
+       inline Delegate2<R(ARGS...)>
+                       Delegate2<R(ARGS...)>::makeA(const HANDLE data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(data)),
+                               Delegate2::Cb::template stubA2A<HANDLE, FUNC>,
+                               Delegate2::Cb::template stubB2A<HANDLE, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class HANDLE, R(*FUNC)(ARGS..., HANDLE)>
+       inline Delegate2<R(ARGS...)>
+                       Delegate2<R(ARGS...)>::makeB(const HANDLE data) noexcept
+       {
+               return {const_cast<void *>(static_cast<const void *>(data)),
+                               Delegate2::Cb::template stubA2B<HANDLE, FUNC>,
+                               Delegate2::Cb::template stubB2B<HANDLE, FUNC>};
+       }
+
+       template <class R, class ...ARGS>
+       template <R(*FUNC)(ARGS...)>
+       inline Delegate2<R(ARGS...)>
+                       Delegate2<R(ARGS...)>::make() noexcept
+       {
+               return {nullptr,
+                               Delegate2::Cb::template stubA2V<FUNC>,
+                               Delegate2::Cb::template stubB2V<FUNC>};
+       }
+}
diff --git a/ucl/include/ucl/util/delegation/helpers.h b/ucl/include/ucl/util/delegation/helpers.h
new file mode 100644 (file)
index 0000000..54ebb99
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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_UTIL_DELEGATION_HELPERS_H__
+#define __UCL_UTIL_DELEGATION_HELPERS_H__
+
+namespace ucl {
+
+       // Automatic function signature detection for a specific type //
+
+       template <template <typename ...> class T, class TAG, class FUNC>
+       struct AutoFuncSig;
+
+       template <template <typename ...> class T,
+                        class R, class CLASS, class ...ARGS>
+       struct AutoFuncSig<T, void *, R(CLASS::*)(ARGS...)> {
+               using Data = CLASS;
+               using Type = T<R(ARGS...)>;
+       };
+
+       template <template <typename ...> class T,
+                       class CLASS, class R, class ...ARGS>
+       struct AutoFuncSig<T, void *, R(CLASS::*)(ARGS...) const> {
+               using Data = CLASS;
+               using Type = T<R(ARGS...)>;
+       };
+
+       template <template <typename ...> class T,
+                       class CLASS, class R, class ...ARGS>
+       struct AutoFuncSig<T, void *, R(*)(CLASS &, ARGS...)> {
+               using Data = CLASS;
+               using Type = T<R(ARGS...)>;
+       };
+
+       template <template <typename ...> class T,
+                       class HANDLE, class R, class ...ARGS>
+       struct AutoFuncSig<T, void *, R(*)(HANDLE, ARGS...)> {
+               using Data = HANDLE;
+               using Type = T<R(ARGS...)>;
+       };
+
+       template <template <typename ...> class T,
+                       class R, class ...ARGS>
+       struct AutoFuncSig<T, void, R(*)(ARGS...)> {
+               using Type = T<R(ARGS...)>;
+       };
+
+       // Relation operators //
+
+       template <class R, class ...ARGS, class DATA1, class DATA2>
+       inline bool operator==(const BaseDelegate<R(ARGS...), DATA1> &lhs,
+                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
+       {
+               return ((lhs.getStubA() == rhs.getStubA()) && (
+                               lhs.getData() == rhs.getData()));
+       }
+
+       template <class R, class ...ARGS, class DATA1, class DATA2>
+       inline bool operator!=(const BaseDelegate<R(ARGS...), DATA1> &lhs,
+                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
+       {
+               return ((lhs.getStubA() != rhs.getStubA()) || (
+                               lhs.getData() != rhs.getData()));
+       }
+
+       template <class R, class ...ARGS, class DATA1, class DATA2>
+       inline bool operator<(const BaseDelegate<R(ARGS...), DATA1> &lhs,
+                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
+       {
+               return ((lhs.getStubA() < rhs.getStubA()) ||
+                               ((lhs.getStubA() == rhs.getStubA()) && (
+                                       lhs.getData() < rhs.getData())));
+       }
+
+       template <class R, class ...ARGS, class DATA1, class DATA2>
+       inline bool operator<=(const BaseDelegate<R(ARGS...), DATA1> &lhs,
+                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
+       {
+               return ((lhs.getStubA() < rhs.getStubA()) ||
+                               ((lhs.getStubA() == rhs.getStubA()) && (
+                                       lhs.getData() <= rhs.getData())));
+       }
+
+       template <class R, class ...ARGS, class DATA1, class DATA2>
+       inline bool operator>(const BaseDelegate<R(ARGS...), DATA1> &lhs,
+                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
+       {
+               return ((lhs.getStubA() > rhs.getStubA()) ||
+                               ((lhs.getStubA() == rhs.getStubA()) && (
+                                       lhs.getData() > rhs.getData())));
+       }
+
+       template <class R, class ...ARGS, class DATA1, class DATA2>
+       inline bool operator>=(const BaseDelegate<R(ARGS...), DATA1> &lhs,
+                       const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
+       {
+               return ((lhs.getStubA() > rhs.getStubA()) ||
+                               ((lhs.getStubA() == rhs.getStubA()) && (
+                                       lhs.getData() >= rhs.getData())));
+       }
+}
+
+#endif // __UCL_UTIL_DELEGATION_HELPERS_H__
diff --git a/ucl/include/ucl/util/delegation/macro.h b/ucl/include/ucl/util/delegation/macro.h
new file mode 100644 (file)
index 0000000..62bf88f
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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_UTIL_DELEGATION_MACRO_H__
+#define __UCL_UTIL_DELEGATION_MACRO_H__
+
+// Helper macro to simplify use of AutoFuncSig template
+
+#define _UCL_AFS(DELEGATE, FUNC) \
+               ::ucl::AutoFuncSig<DELEGATE, void *, decltype(&FUNC)>
+
+// Helper macro to automatically generate different delegate objects //
+
+#define _UCL_DELEGATE(DELEGATE, FUNC, DATA) (_UCL_AFS(DELEGATE, FUNC):: \
+               Type::make<_UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA))
+
+#define _UCL_DELEGATE_A(DELEGATE, FUNC, DATA) (_UCL_AFS(DELEGATE, FUNC):: \
+               Type::makeA<_UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA))
+
+#define _UCL_DELEGATE_V(DELEGATE, FUNC) \
+               (::ucl::AutoFuncSig<DELEGATE, void, decltype(&FUNC)>::\
+                       Type::make<&FUNC>())
+
+// Helper macro to automatically generate Delegate objects //
+
+#define UCL_DELEGATE(FUNC, DATA) _UCL_DELEGATE(::ucl::Delegate, FUNC, DATA)
+#define UCL_DELEGATE_A(FUNC, DATA) _UCL_DELEGATE_A(::ucl::Delegate, FUNC, DATA)
+#define UCL_DELEGATE_V(FUNC) _UCL_DELEGATE_V(::ucl::Delegate, FUNC)
+
+// Helper macro to automatically generate Delegate2 objects //
+
+#define UCL_DELEGATE2(FUNC, DATA) _UCL_DELEGATE(::ucl::Delegate2, FUNC, DATA)
+#define UCL_DELEGATE2_A(FUNC, DATA) \
+               _UCL_DELEGATE_A(::ucl::Delegate2, FUNC, DATA)
+#define UCL_DELEGATE2_V(FUNC) _UCL_DELEGATE_V(::ucl::Delegate2, FUNC)
+
+// Helper macro to automatically generate Callback stubs //
+
+#define UCL_CALLBACK_A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC):: \
+               Type::stubA<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
+#define UCL_CALLBACK_B(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC):: \
+               Type::stubB<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
+
+#define UCL_CALLBACK_A2A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
+               stubA2A<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
+#define UCL_CALLBACK_B2A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
+               stubB2A<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
+
+#define UCL_CALLBACK_A2V(FUNC) (&::ucl::AutoFuncSig<::ucl::Callback, void, \
+               decltype(&FUNC)>::Type::stubA2V<&FUNC>)
+#define UCL_CALLBACK_B2V(FUNC) (&::ucl::AutoFuncSig<::ucl::Callback, void, \
+               decltype(&FUNC)>::Type::stubB2V<&FUNC>)
+
+#endif // __UCL_UTIL_DELEGATION_MACRO_H__
diff --git a/ucl/include/ucl/util/delegation/shortMacro.h b/ucl/include/ucl/util/delegation/shortMacro.h
new file mode 100644 (file)
index 0000000..3837977
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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_UTIL_DELEGATION_SHORT_MACRO_H__
+#define __UCL_UTIL_DELEGATION_SHORT_MACRO_H__
+
+// Helper macro to automatically generate Delegate objects //
+
+#define DELEGATE(FUNC, DATA)    UCL_DELEGATE(FUNC, DATA)
+#define DELEGATE_A(FUNC, DATA)  UCL_DELEGATE_A(FUNC, DATA)
+#define DELEGATE_V(FUNC)        UCL_DELEGATE_V(FUNC)
+
+// Helper macro to automatically generate Delegate2 objects //
+
+#define DELEGATE2(FUNC, DATA)    UCL_DELEGATE2(FUNC, DATA)
+#define DELEGATE2_A(FUNC, DATA)  UCL_DELEGATE2_A(FUNC, DATA)
+#define DELEGATE2_V(FUNC)        UCL_DELEGATE2_V(FUNC)
+
+// Helper macro to automatically generate Callback stubs //
+
+#define CALLBACK_A(FUNC)  UCL_CALLBACK_A(FUNC)
+#define CALLBACK_B(FUNC)  UCL_CALLBACK_B(FUNC)
+
+#define CALLBACK_A2A(FUNC)  UCL_CALLBACK_A2A(FUNC)
+#define CALLBACK_B2A(FUNC)  UCL_CALLBACK_B2A(FUNC)
+
+#define CALLBACK_A2V(FUNC)  UCL_CALLBACK_A2V(FUNC)
+#define CALLBACK_B2V(FUNC)  UCL_CALLBACK_B2V(FUNC)
+
+#endif // __UCL_UTIL_DELEGATION_SHORT_MACRO_H__
diff --git a/ucl/include/ucl/util/helpers.h b/ucl/include/ucl/util/helpers.h
new file mode 100644 (file)
index 0000000..117d3de
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * 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_UTIL_HELPERS_H__
+#define __UCL_UTIL_HELPERS_H__
+
+#include "types/baseTypes.h"
+#include "types/classTypes.h"
+
+namespace ucl {
+
+       constexpr Eina_Bool toEina(bool value);
+
+       // "nz()" - "Not Zero" functions
+       // return "zValue" if "!value" is true
+       constexpr const char *nz(const char *value, const char *zValue = "");
+
+       // "ne()" - "Not Empty" functions
+       // return "eValue" if "isEmpty(value)" is true
+       constexpr const char *ne(const char *value, const char *eValue = nullptr);
+
+       constexpr bool isEmpty(const char *value);
+
+       template <class T>
+       constexpr auto isEmpty(const T &value) -> decltype(value.empty())
+       {
+               return value.empty();
+       }
+
+       template <class T>
+       constexpr auto isEmpty(const T &value) -> decltype(value.isEmpty())
+       {
+               return value.isEmpty();
+       }
+
+       template <class T>
+       constexpr auto isEmpty(const T &value) -> decltype(isEmpty(*value))
+       {
+               return (!value || isEmpty(*value));
+       }
+
+       template <class T>
+       constexpr bool isNotEmpty(T &&value);
+
+       template <class T>
+       constexpr bool isNotValid(T &&value);
+
+       char *strDupSafe(const char *value);
+       int strCmpSafe(const char *lhs, const char *rhs);
+
+       template <class T1, class T2>
+       inline auto dynamicCast(T2 &&src) -> decltype(
+                       dynamic_cast<T1>(std::forward<T2>(src)))
+       {
+               return dynamic_cast<T1>(std::forward<T2>(src));
+       }
+
+       template <class T1, class T2>
+       inline auto constCast(T2 &&src) -> decltype(
+                       const_cast<T1>(std::forward<T2>(src)))
+       {
+               return const_cast<T1>(std::forward<T2>(src));
+       }
+
+       template <class T>
+       constexpr const T &min(const T &a, const T &b);
+
+       template <class T>
+       constexpr const T &max(const T &a, const T &b);
+
+       template <class T>
+       constexpr bool isPot(T value)
+       {
+               return (((value - 1) & value) == 0);
+       }
+
+       template <uint MULTIPLE, class T>
+       constexpr T ceilDiv(T value);
+
+       template <uint MULTIPLE, class T>
+       constexpr typename std::enable_if<isPot(MULTIPLE), T>::type
+                       roundUp(T value)
+       {
+               return ((value + (MULTIPLE - 1)) & ~static_cast<T>(MULTIPLE - 1));
+       }
+
+       template <uint MULTIPLE, class T>
+       constexpr typename std::enable_if<!isPot(MULTIPLE), T>::type
+                       roundUp(T value)
+       {
+               return (ceilDiv<MULTIPLE>(value) * MULTIPLE);
+       }
+}
+
+namespace ucl { namespace util {
+
+       template <class T>
+       std::unique_ptr<T> makeUnique(T *p);
+
+       template <class T, class = typename std::enable_if<
+                       std::is_convertible<T *, IDisposable *>::value>::type>
+       inline void dispose(T *&p) noexcept
+       {
+               if (p) {
+                       p->dispose();
+                       p = nullptr;
+               }
+       }
+}}
+
+#include "helpers.hpp"
+
+#endif // __UCL_UTIL_HELPERS_H__
diff --git a/ucl/include/ucl/util/helpers.hpp b/ucl/include/ucl/util/helpers.hpp
new file mode 100644 (file)
index 0000000..a7606f8
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       constexpr Eina_Bool toEina(const bool value)
+       {
+               return (value ? EINA_TRUE : EINA_FALSE);
+       }
+
+       constexpr const char *nz(const char *const value, const char *const zValue)
+       {
+               return (value ? value : zValue);
+       }
+
+       template <class T>
+       constexpr bool isNotEmpty(T &&value)
+       {
+               return !isEmpty(std::forward<T>(value));
+       }
+
+       constexpr const char *ne(const char *const value, const char *const eValue)
+       {
+               return (isNotEmpty(value) ? value : eValue);
+       }
+
+       constexpr bool isEmpty(const char *const value)
+       {
+               return (!value || (value[0] == '\0'));
+       }
+
+       template <class T>
+       constexpr bool isNotValid(T &&value)
+       {
+               return !isValid(std::forward<T>(value));
+       }
+
+       inline char *strDupSafe(const char *const value)
+       {
+               return (value ? strdup(value) : nullptr);
+       }
+
+       inline int strCmpSafe(const char *lhs, const char *rhs)
+       {
+               return strcmp(nz(lhs), nz(rhs));
+       }
+
+       template <class T>
+       constexpr const T &min(const T &a, const T &b)
+       {
+               return ((a < b) ? a : b);
+       }
+
+       template <class T>
+       constexpr const T &max(const T &a, const T &b)
+       {
+               return ((a > b) ? a : b);
+       }
+
+       template <uint MULTIPLE, class T>
+       constexpr T ceilDiv(T value)
+       {
+               return ((value + (MULTIPLE - 1)) / MULTIPLE);
+       }
+}
+
+namespace ucl { namespace util {
+
+       template <class T>
+       inline std::unique_ptr<T> makeUnique(T *const p)
+       {
+               return std::unique_ptr<T>(p);
+       }
+}}
diff --git a/ucl/include/ucl/util/logging.h b/ucl/include/ucl/util/logging.h
new file mode 100644 (file)
index 0000000..804a513
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * 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_UTIL_LOGGING_H__
+#define __UCL_UTIL_LOGGING_H__
+
+#include <assert.h>
+
+#include <dlog.h>
+
+#include "types/Result.h"
+
+::ucl::ResultData getUCLResultData(::ucl::Result result);
+
+#ifndef UCL_LOG_LEVEL
+#define UCL_LOG_LEVEL UCL_MAX_LOG_LEVEL
+#elif UCL_LOG_LEVEL > UCL_MAX_LOG_LEVEL
+#undef UCL_LOG_LEVEL
+#define UCL_LOG_LEVEL UCL_MAX_LOG_LEVEL
+#endif
+
+#ifndef UCL_LOG_TAG
+#define UCL_LOG_TAG UCL_DEFAULT_LOG_TAG
+#endif
+
+#ifndef __MODULE__
+#define __MODULE__ (strrchr(__FILE__, '/') ? \
+               strrchr(__FILE__, '/') + 1 : __FILE__)
+#endif
+
+// Base macros for writing logs without result code
+#define UCL_ULOG(prio, fmt, ...) dlog_print( \
+       (log_priority)prio, UCL_LOG_TAG, "%s: %s(%d) > " fmt, \
+       __MODULE__, __func__, __LINE__, ##__VA_ARGS__)
+
+// Base macros for writing logs WITH result code
+#define UCL_URESDATALOG(prio, resdata, fmt, ...) dlog_print( \
+       (log_priority)prio, UCL_LOG_TAG, "%s: %s(%d) > " fmt " {%s}", \
+       __MODULE__, __func__, __LINE__, ##__VA_ARGS__, resdata.name)
+
+#define UCL_URESLOG(prio, result, fmt, ...) do { \
+       const ::ucl::ResultData &resdata = ::getUCLResultData(result); \
+       UCL_URESDATALOG(prio, resdata, fmt, ##__VA_ARGS__);} while (false)
+
+#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_VERBOSE
+#define UCL_VLOG(msg, ...) UCL_ULOG(DLOG_VERBOSE, msg, ##__VA_ARGS__)
+#define UCL_VRESLOG(result, msg, ...) \
+               UCL_URESLOG(DLOG_VERBOSE, result, msg, ##__VA_ARGS__)
+#else
+#define UCL_VLOG(msg, ...) do {} while (false)
+#define UCL_VRESLOG(result, msg, ...) do {} while (false)
+#endif
+
+#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_DEBUG
+#define UCL_DLOG(msg, ...) UCL_ULOG(DLOG_DEBUG, msg, ##__VA_ARGS__)
+#define UCL_DRESLOG(result, msg, ...) \
+               UCL_URESLOG(DLOG_DEBUG, result, msg, ##__VA_ARGS__)
+#else
+#define UCL_DLOG(msg, ...) do {} while (false)
+#define UCL_DRESLOG(result, msg, ...) do {} while (false)
+#endif
+
+#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_INFO
+#define UCL_ILOG(msg, ...) UCL_ULOG(DLOG_INFO, msg, ##__VA_ARGS__)
+#define UCL_IRESLOG(result, msg, ...) \
+               UCL_URESLOG(DLOG_INFO, result, msg, ##__VA_ARGS__)
+#else
+#define UCL_ILOG(msg, ...) do {} while (false)
+#define UCL_IRESLOG(result, msg, ...) do {} while (false)
+#endif
+
+#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_WARNING
+#define UCL_WLOG(msg, ...) UCL_ULOG(DLOG_WARN, msg, ##__VA_ARGS__)
+#define UCL_WRESLOG(result, msg, ...) \
+               UCL_URESLOG(DLOG_WARN, result, msg, ##__VA_ARGS__)
+#else
+#define UCL_WLOG(msg, ...) do {} while (false)
+#define UCL_WRESLOG(result, msg, ...) do {} while (false)
+#endif
+
+#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_ERROR
+#define UCL_ELOG(msg, ...) UCL_ULOG(DLOG_ERROR, msg, ##__VA_ARGS__)
+#define UCL_ERESLOG(result, msg, ...) \
+               UCL_URESLOG(DLOG_ERROR, result, msg, ##__VA_ARGS__)
+#else
+#define UCL_ELOG(msg, ...) do {} while (false)
+#define UCL_ERESLOG(result, msg, ...) do {} while (false)
+#endif
+
+#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_FATAL
+#define UCL_FLOG(msg, ...) UCL_ULOG(DLOG_FATAL, msg, ##__VA_ARGS__)
+#define UCL_FRESLOG(result, msg, ...) UCL_URESLOG( \
+       DLOG_FATAL, result, msg, ##__VA_ARGS__)
+#else
+#define UCL_FLOG(msg, ...) do {} while (false)
+#define UCL_FRESLOG(result, msg, ...) do {} while (false)
+#endif
+
+#if UCL_LOG_LEVEL >= UCL_LOG_LEVEL_ERROR
+
+// Simple macros for writing logs WITH result
+// code and automatic log priority determination
+#define UCL_RESLOG(result, msg, ...) { \
+       const ::ucl::ResultData &resdata = ::getUCLResultData(result); \
+       UCL_URESDATALOG(resdata.logPrio, \
+                       resdata, msg, ##__VA_ARGS__);} while (false)
+
+#else
+#define UCL_RESLOG(result, msg, ...) do {} while (false)
+#endif
+
+#define UCL_ASSERT(expr, msg, ...) \
+       do { \
+               if (!(expr)) { \
+                       UCL_FLOG(msg, ##__VA_ARGS__); \
+                       assert(false); \
+               } \
+       } while (false)
+
+#define UCL_FAIL_RETURN(result, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               if (isBad(__RESULT__)) { \
+                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+                       return __RESULT__; \
+               } \
+       } while (false)
+
+#define UCL_FAIL_RETURN_VALUE(result, value, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               if (isBad(__RESULT__)) { \
+                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+                       return value; \
+               } \
+       } while (false)
+
+#define UCL_FAIL_RETURN_VOID(result, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               if (isBad(__RESULT__)) { \
+                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+                       return; \
+               } \
+       } while (false)
+
+#define UCL_LOG_RETURN(result, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+               return __RESULT__; \
+       } while (false)
+
+#define UCL_LOG_RETURN_VALUE(result, value, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+               return value; \
+       } while (false)
+
+#define UCL_LOG_RETURN_VOID(result, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+               return; \
+       } while (false)
+
+#define UCL_FAIL_BREAK(result, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               if (isBad(__RESULT__)) { \
+                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+                       break; \
+               } \
+       } while (false)
+
+#define UCL_LOG_BREAK(result, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+               break; \
+       } while (false)
+
+#define UCL_FAIL_LOG(result, msg, ...) \
+       do { \
+               const ::ucl::Result __RESULT__ = (result); \
+               if (isBad(__RESULT__)) { \
+                       UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
+               } \
+       } while (false)
+
+#endif // __UCL_UTIL_LOGGING_H__
diff --git a/ucl/include/ucl/util/memory.h b/ucl/include/ucl/util/memory.h
new file mode 100644 (file)
index 0000000..cc33960
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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_UTIL_MEMORY_H__
+#define __UCL_UTIL_MEMORY_H__
+
+#include "memory/RefCountObj.h"
+
+#include "memory/BaseRef.h"
+#include "memory/SharedRef.h"
+#include "memory/WeakRef.h"
+
+#include "memory/helpers.h"
+#include "memory/macro.h"
+
+#endif // __UCL_UTIL_MEMORY_H__
diff --git a/ucl/include/ucl/util/memory/BaseRef.h b/ucl/include/ucl/util/memory/BaseRef.h
new file mode 100644 (file)
index 0000000..8146eae
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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_UTIL_MEMORY_BASE_REF_H__
+#define __UCL_UTIL_MEMORY_BASE_REF_H__
+
+#include "IRefCountObj.h"
+
+namespace ucl {
+
+       template <class T>
+       class BaseRef {
+       public:
+               using Type = T;
+
+               template <class U>
+               friend class BaseRef;
+               template <class U>
+               friend class SharedRef;
+               template <class U>
+               friend class WeakRef;
+
+       public:
+               UInt getUseCount() const noexcept;
+
+       protected:
+               constexpr BaseRef() noexcept;
+               BaseRef(IRefCountObj *rc, T *ptr) noexcept;
+               BaseRef(BaseRef<T> &&r) noexcept;
+               template <class U>
+               BaseRef(BaseRef<U> &&r) noexcept;
+
+       protected:
+               IRefCountObj *m_rc;
+               T *m_ptr;
+       };
+}
+
+#include "BaseRef.hpp"
+
+#endif // __UCL_UTIL_MEMORY_BASE_REF_H__
diff --git a/ucl/include/ucl/util/memory/BaseRef.hpp b/ucl/include/ucl/util/memory/BaseRef.hpp
new file mode 100644 (file)
index 0000000..312c38e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class T>
+       constexpr BaseRef<T>::BaseRef() noexcept :
+               m_rc(nullptr),
+               m_ptr(nullptr)
+       {
+       }
+
+       template <class T>
+       inline BaseRef<T>::BaseRef(
+                       IRefCountObj *const rc, T *const ptr) noexcept :
+               m_rc(rc),
+               m_ptr(ptr)
+       {
+       }
+
+       template <class T>
+       inline BaseRef<T>::BaseRef(BaseRef<T> &&r) noexcept :
+               m_rc(r.m_rc),
+               m_ptr(r.m_ptr)
+       {
+               r.m_rc = nullptr;
+               r.m_ptr = nullptr;
+       }
+
+       template <class T>
+       template <class U>
+       inline BaseRef<T>::BaseRef(BaseRef<U> &&r) noexcept :
+               m_rc(r.m_rc),
+               m_ptr(r.m_ptr)
+       {
+               r.m_rc = nullptr;
+               r.m_ptr = nullptr;
+       }
+
+       template <class T>
+       inline UInt BaseRef<T>::getUseCount() const noexcept
+       {
+               return (m_rc ? m_rc->getUseCount() : 0);
+       }
+}
diff --git a/ucl/include/ucl/util/memory/IRefCountObj.h b/ucl/include/ucl/util/memory/IRefCountObj.h
new file mode 100644 (file)
index 0000000..69d6a1c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
+#define __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
+
+#include "ucl/util/types/classTypes.h"
+
+namespace ucl {
+
+       class IRefCountObj : public Polymorphic {
+       public:
+               virtual void ref() noexcept = 0;
+               virtual void unref() noexcept = 0;
+               virtual bool refNz() noexcept = 0;
+               virtual void refWeak() noexcept = 0;
+               virtual void unrefWeak() noexcept = 0;
+               virtual UInt getUseCount() const noexcept = 0;
+               virtual const void *getObjPtr() const noexcept = 0;
+       protected:
+               virtual ~IRefCountObj() = default;
+       };
+}
+
+#endif // __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
diff --git a/ucl/include/ucl/util/memory/RefCountObj.h b/ucl/include/ucl/util/memory/RefCountObj.h
new file mode 100644 (file)
index 0000000..7237aa4
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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_UTIL_MEMORY_REF_COUNT_OBJ_H__
+#define __UCL_UTIL_MEMORY_REF_COUNT_OBJ_H__
+
+#include "IRefCountObj.h"
+#include "ReffedObj.h"
+
+namespace ucl {
+
+       template <class T, class C>
+       class RefCountObj final : public IRefCountObj {
+       public:
+               template <class ...ARGS>
+               RefCountObj(ARGS &&...args);
+
+               T *getObj() noexcept;
+
+               // IRefCountObj //
+
+               virtual void ref() noexcept final override;
+               virtual void unref() noexcept final override;
+               virtual bool refNz() noexcept final override;
+               virtual void refWeak() noexcept final override;
+               virtual void unrefWeak() noexcept final override;
+               virtual UInt getUseCount() const noexcept final override;
+               virtual const void *getObjPtr() const noexcept final override;
+
+       private:
+               template <class T2, class = char[1]>
+               struct IsRefCountAware : std::false_type {};
+               template <class T2>
+               struct IsRefCountAware<T2, char[T2::_IS_REF_COUNT_AWARE * 0 + 1]> :
+                               std::true_type {};
+
+               template <class T2, class = char[1]>
+               struct IsOnUniqueAware : std::false_type {};
+               template <class T2>
+               struct IsOnUniqueAware<T2,
+                               char[T2::_ENABLE_ON_UNIQUE_CHANGED_DISPATCH * 0 + 1]> :
+                               std::true_type {};
+
+       private:
+               virtual ~RefCountObj() = default;
+
+               template <class T2, class ...ARGS, class =
+                               typename std::enable_if<!IsRefCountAware<T2>::value>::type>
+               void createObj(const P<0> &, ARGS &&...args)
+               {
+                       m_obj.create(std::forward<ARGS>(args)...);
+               }
+
+               template <class T2, class ...ARGS, class =
+                               typename std::enable_if<IsRefCountAware<T2>::value>::type>
+               auto createObj(const P<1> &, ARGS &&...args) -> decltype(
+                               ReffedObj<T>::template check<T2>(
+                                               (IRefCountObj *)0, std::forward<ARGS>(args)...))
+               {
+                       m_obj.create(static_cast<IRefCountObj *>(this),
+                                       std::forward<ARGS>(args)...);
+               }
+
+               template <class T2, class ...ARGS, class =
+                               typename std::enable_if<IsRefCountAware<T2>::value>::type>
+               auto createObj(const P<2> &, ARGS &&...args) -> decltype(
+                               ReffedObj<T>::template check<T2>(
+                                               *(IRefCountObj *)0, std::forward<ARGS>(args)...))
+               {
+                       m_obj.create(*static_cast<IRefCountObj *>(this),
+                                       std::forward<ARGS>(args)...);
+               }
+
+               void dispatchOnUniqueChanged(const bool isUnique)
+               {
+                       dispatchOnUniqueChanged<T>(P<1>(), isUnique);
+               }
+
+               template <class T2>
+               void dispatchOnUniqueChanged(...)
+               {
+               }
+
+               template <class T2, class =
+                               typename std::enable_if<IsOnUniqueAware<T2>::value>::type>
+               void dispatchOnUniqueChanged(const P<1> &, const bool isUnique)
+               {
+                       m_obj.template dispatchOnUniqueChanged<T>(isUnique);
+               }
+
+       private:
+               ReffedObj<T> m_obj;
+               C m_useCounter;
+               C m_weakCounter;
+       };
+}
+
+#include "RefCountObj.hpp"
+
+#endif // __UCL_UTIL_MEMORY_REF_COUNT_OBJ_H__
diff --git a/ucl/include/ucl/util/memory/RefCountObj.hpp b/ucl/include/ucl/util/memory/RefCountObj.hpp
new file mode 100644 (file)
index 0000000..8a2c065
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class T, class C>
+       template <class ...ARGS>
+       inline RefCountObj<T, C>::RefCountObj(ARGS &&...args) :
+               m_useCounter(1),
+               m_weakCounter(1)
+       {
+               createObj<T>(P<2>(), std::forward<ARGS>(args)...);
+       }
+
+       template <class T, class C>
+       inline T *RefCountObj<T, C>::getObj() noexcept
+       {
+               return m_obj.get();
+       }
+
+       template <class T, class C>
+       inline void RefCountObj<T, C>::ref() noexcept
+       {
+               if (m_useCounter.ref() == 2) {
+                       dispatchOnUniqueChanged(false);
+               }
+       }
+
+       template <class T, class C>
+       inline void RefCountObj<T, C>::unref() noexcept
+       {
+               const auto newCount = m_useCounter.unref();
+               if (newCount == 0) {
+                       m_obj.destroy();
+                       unrefWeak();
+               } else if (newCount == 1) {
+                       dispatchOnUniqueChanged(true);
+               }
+       }
+
+       template <class T, class C>
+       inline bool RefCountObj<T, C>::refNz() noexcept
+       {
+               const auto newCount = m_useCounter.refNz();
+               if (newCount == 0) {
+                       return false;
+               }
+               if (newCount == 2) {
+                       dispatchOnUniqueChanged(false);
+               }
+               return true;
+       }
+
+       template <class T, class C>
+       inline void RefCountObj<T, C>::refWeak() noexcept
+       {
+               m_weakCounter.ref();
+       }
+
+       template <class T, class C>
+       inline void RefCountObj<T, C>::unrefWeak() noexcept
+       {
+               if (m_weakCounter.unref() == 0) {
+                       delete this;
+               }
+       }
+
+       template <class T, class C>
+       inline UInt RefCountObj<T, C>::getUseCount() const noexcept
+       {
+               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/include/ucl/util/memory/RefCounterMT.h b/ucl/include/ucl/util/memory/RefCounterMT.h
new file mode 100644 (file)
index 0000000..1d2fb95
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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_UTIL_MEMORY_REF_COUNTER_MT_H__
+#define __UCL_UTIL_MEMORY_REF_COUNTER_MT_H__
+
+#include "ucl/util/types/baseTypes.h"
+
+namespace ucl {
+
+       class RefCounterMT final {
+       public:
+               explicit RefCounterMT(const UInt count = 0) noexcept;
+
+               UInt ref() noexcept;
+               UInt unref() noexcept;
+               UInt refNz() noexcept;
+
+               UInt get() const noexcept;
+
+       private:
+               std::atomic<UInt> m_counter;
+       };
+}
+
+#include "RefCounterMT.hpp"
+
+#endif // __UCL_UTIL_MEMORY_REF_COUNTER_MT_H__
diff --git a/ucl/include/ucl/util/memory/RefCounterMT.hpp b/ucl/include/ucl/util/memory/RefCounterMT.hpp
new file mode 100644 (file)
index 0000000..1ff459b
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline RefCounterMT::RefCounterMT(const UInt count) noexcept :
+               m_counter(count)
+       {
+       }
+
+       inline UInt RefCounterMT::ref() noexcept
+       {
+               return (m_counter.fetch_add(1, std::memory_order_acq_rel) + 1);
+       }
+
+       inline UInt RefCounterMT::unref() noexcept
+       {
+               return (m_counter.fetch_sub(1, std::memory_order_acq_rel) - 1);
+       }
+
+       inline UInt RefCounterMT::refNz() noexcept
+       {
+               auto curCount = m_counter.load(std::memory_order_relaxed);
+               for (;;) {
+                       if (curCount == 0) {
+                               return 0;
+                       }
+                       const auto newCount = (curCount + 1);
+                       if (m_counter.compare_exchange_weak(curCount, newCount,
+                                       std::memory_order_acq_rel, std::memory_order_relaxed)) {
+                               return newCount;
+                       }
+               }
+       }
+
+       inline UInt RefCounterMT::get() const noexcept
+       {
+               return m_counter.load(std::memory_order_relaxed);
+       }
+}
diff --git a/ucl/include/ucl/util/memory/RefCounterST.h b/ucl/include/ucl/util/memory/RefCounterST.h
new file mode 100644 (file)
index 0000000..30e5e35
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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_UTIL_MEMORY_REF_COUNTER_ST_H__
+#define __UCL_UTIL_MEMORY_REF_COUNTER_ST_H__
+
+#include "ucl/util/types/baseTypes.h"
+
+namespace ucl {
+
+       class RefCounterST final {
+       public:
+               explicit RefCounterST(const UInt count = 0) noexcept;
+
+               UInt ref() noexcept;
+               UInt unref() noexcept;
+               UInt refNz() noexcept;
+
+               UInt get() const noexcept;
+
+       private:
+               UInt m_counter;
+       };
+}
+
+#include "RefCounterST.hpp"
+
+#endif // __UCL_UTIL_MEMORY_REF_COUNTER_ST_H__
diff --git a/ucl/include/ucl/util/memory/RefCounterST.hpp b/ucl/include/ucl/util/memory/RefCounterST.hpp
new file mode 100644 (file)
index 0000000..45781c7
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline RefCounterST::RefCounterST(const UInt count) noexcept :
+               m_counter(count)
+       {
+       }
+
+       inline UInt RefCounterST::ref() noexcept
+       {
+               return (++m_counter);
+       }
+
+       inline UInt RefCounterST::unref() noexcept
+       {
+               return (--m_counter);
+       }
+
+       inline UInt RefCounterST::refNz() noexcept
+       {
+               if (m_counter == 0) {
+                       return 0;
+               }
+               return ref();
+       }
+
+       inline UInt RefCounterST::get() const noexcept
+       {
+               return m_counter;
+       }
+}
diff --git a/ucl/include/ucl/util/memory/ReffedObj.h b/ucl/include/ucl/util/memory/ReffedObj.h
new file mode 100644 (file)
index 0000000..c521544
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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_UTIL_MEMORY_REFFED_OBJ_H__
+#define __UCL_UTIL_MEMORY_REFFED_OBJ_H__
+
+#include "RefCounterST.h"
+#include "RefCounterMT.h"
+
+namespace ucl {
+
+       template <class T, class C>
+       class RefCountObj;
+
+       template <class T>
+       class ReffedObj final {
+       private:
+               friend class RefCountObj<T, RefCounterST>;
+               friend class RefCountObj<T, RefCounterMT>;
+
+               template <class ...ARGS>
+               void create(ARGS &&...args);
+               void destroy() noexcept;
+
+               T *get() noexcept;
+               const T *get() const noexcept;
+
+               template <class T2>
+               void dispatchOnUniqueChanged(bool isUnique);
+
+       private:
+               template <class T2, class ...ARGS>
+               static constexpr auto check(ARGS &&...args) -> decltype(
+                               (void)(new T2(std::forward<ARGS>(args)...)))
+               {
+                       return;
+               }
+
+       private:
+               typename std::aligned_storage<sizeof(T), alignof(T)>::type m_obj;
+       };
+}
+
+#include "ReffedObj.hpp"
+
+#endif // __UCL_UTIL_MEMORY_REFFED_OBJ_H__
diff --git a/ucl/include/ucl/util/memory/ReffedObj.hpp b/ucl/include/ucl/util/memory/ReffedObj.hpp
new file mode 100644 (file)
index 0000000..cfc1e84
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class T>
+       template <class ...ARGS>
+       inline void ReffedObj<T>::create(ARGS &&...args)
+       {
+               new (get()) T(std::forward<ARGS>(args)...);
+       }
+
+       template <class T>
+       inline void ReffedObj<T>::destroy() noexcept
+       {
+               get()->~T();
+       }
+
+       template <class T>
+       inline T *ReffedObj<T>::get() noexcept
+       {
+               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)
+       {
+               get()->onUniqueChanged(isUnique);
+       }
+}
diff --git a/ucl/include/ucl/util/memory/SharedRef.h b/ucl/include/ucl/util/memory/SharedRef.h
new file mode 100644 (file)
index 0000000..396d176
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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_UTIL_MEMORY_SHARED_REF_H__
+#define __UCL_UTIL_MEMORY_SHARED_REF_H__
+
+#include "BaseRef.h"
+
+namespace ucl {
+
+       template <class T>
+       class SharedRef final : public BaseRef<T> {
+       public:
+               template <class U>
+               friend void swap(SharedRef<U> &x, SharedRef<U> &y) noexcept;
+
+               template <class T2, class U>
+               friend SharedRef<T2> staticRefCast(const SharedRef<U> &r) noexcept;
+               template <class T2, class U>
+               friend SharedRef<T2> dynamicRefCast(const SharedRef<U> &r) noexcept;
+
+       public:
+               constexpr SharedRef() noexcept;
+               constexpr SharedRef(std::nullptr_t) noexcept;
+
+               SharedRef(IRefCountObj *rc, T *ptr) noexcept;
+               SharedRef(IRefCountObj *rc, T *ptr, bool noRef) noexcept;
+
+               SharedRef(const SharedRef<T> &r) noexcept;
+               template <class U>
+               SharedRef(const SharedRef<U> &r) noexcept;
+
+               SharedRef(SharedRef<T> &&r) noexcept;
+               template <class U>
+               SharedRef(SharedRef<U> &&r) noexcept;
+
+               ~SharedRef();
+
+               SharedRef<T> &operator=(SharedRef<T> r) noexcept;
+
+               void reset() noexcept;
+
+               T *get() const noexcept;
+               operator bool() const noexcept;
+
+               T *operator->() const noexcept;
+               typename std::add_lvalue_reference<T>::type operator*() const noexcept;
+
+               template <class U, class = typename std::enable_if<
+                       std::is_convertible<T *, U *>::value && (
+                               std::is_same<typename std::remove_cv<U>::type, void>::value ||
+                               std::is_same<typename std::remove_cv<U>::type,
+                                       typename std::remove_cv<T>::type>::value)>::type>
+               operator const SharedRef<U> &() const noexcept
+               {
+                       return reinterpret_cast<const SharedRef<U> &>(*this);
+               }
+       };
+
+       // Non-member functions //
+
+       template <class T, class ...ARGS>
+       SharedRef<T> makeShared(ARGS &&...args);
+       template <class T, class ...ARGS>
+       SharedRef<T> makeSharedMT(ARGS &&...args);
+
+       template <class T, class U>
+       const SharedRef<T> &constRefCast(const SharedRef<U> &r) noexcept;
+       template <class T, class U>
+       SharedRef<T> &&constRefCast(SharedRef<U> &&r) noexcept;
+}
+
+#include "SharedRef.hpp"
+
+#endif // __UCL_UTIL_MEMORY_SHARED_REF_H__
diff --git a/ucl/include/ucl/util/memory/SharedRef.hpp b/ucl/include/ucl/util/memory/SharedRef.hpp
new file mode 100644 (file)
index 0000000..f085b9c
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class T>
+       constexpr SharedRef<T>::SharedRef() noexcept
+       {
+       }
+
+       template <class T>
+       constexpr SharedRef<T>::SharedRef(std::nullptr_t) noexcept
+       {
+       }
+
+       template <class T>
+       inline SharedRef<T>::SharedRef(
+                       IRefCountObj *const rc, T *const ptr) noexcept :
+               BaseRef<T>(rc, ptr)
+       {
+               this->m_rc->ref();
+       }
+
+       template <class T>
+       inline SharedRef<T>::SharedRef(
+                       IRefCountObj *const rc, T *const ptr, bool noRef) noexcept :
+               BaseRef<T>(rc, ptr)
+       {
+       }
+
+       template <class T>
+       inline SharedRef<T>::SharedRef(const SharedRef<T> &r) noexcept :
+               BaseRef<T>(r.m_rc, r.m_ptr)
+       {
+               if (this->m_rc) {
+                       this->m_rc->ref();
+               }
+       }
+
+       template <class T>
+       template <class U>
+       inline SharedRef<T>::SharedRef(const SharedRef<U> &r) noexcept :
+               BaseRef<T>(r.m_rc, r.m_ptr)
+       {
+               if (this->m_rc) {
+                       this->m_rc->ref();
+               }
+       }
+
+       template <class T>
+       inline SharedRef<T>::SharedRef(SharedRef<T> &&r) noexcept :
+               BaseRef<T>(std::move(r))
+       {
+       }
+
+       template <class T>
+       template <class U>
+       inline SharedRef<T>::SharedRef(SharedRef<U> &&r) noexcept :
+               BaseRef<T>(std::move(r))
+       {
+       }
+
+       template <class T>
+       inline SharedRef<T>::~SharedRef()
+       {
+               if (this->m_rc) {
+                       this->m_rc->unref();
+               }
+       }
+
+       template <class T>
+       inline SharedRef<T> &SharedRef<T>::operator=(SharedRef<T> r) noexcept
+       {
+               swap(*this, r);
+               return *this;
+       }
+
+       template <class T>
+       inline void SharedRef<T>::reset() noexcept
+       {
+               *this = {};
+       }
+
+       template <class T>
+       inline T *SharedRef<T>::get() const noexcept
+       {
+               return this->m_ptr;
+       }
+
+       template <class T>
+       inline SharedRef<T>::operator bool() const noexcept
+       {
+               return !!this->m_ptr;
+       }
+
+       template <class T>
+       inline T *SharedRef<T>::operator->() const noexcept
+       {
+               return this->m_ptr;
+       }
+
+       template <class T>
+       inline typename std::add_lvalue_reference<T>::type
+                       SharedRef<T>::operator*() const noexcept
+       {
+               return *this->m_ptr;
+       }
+
+       // Non-member functions //
+
+       template <class T, class ...ARGS>
+       SharedRef<T> makeShared(ARGS &&...args)
+       {
+               const auto rc = new RefCountObj<T, RefCounterST>(
+                               std::forward<ARGS>(args)...);
+               return {rc, rc->getObj(), true};
+       }
+
+       template <class T, class ...ARGS>
+       SharedRef<T> makeSharedMT(ARGS &&...args)
+       {
+               const auto rc = new RefCountObj<T, RefCounterMT>(
+                               std::forward<ARGS>(args)...);
+               return {rc, rc->getObj(), true};
+       }
+
+       template <class T>
+       inline void swap(SharedRef<T> &x, SharedRef<T> &y) noexcept
+       {
+               std::swap(x.m_rc, y.m_rc);
+               std::swap(x.m_ptr, y.m_ptr);
+       }
+
+       template <class T, class U>
+       inline SharedRef<T> staticRefCast(const SharedRef<U> &r) noexcept
+       {
+               return {r.m_rc, static_cast<T *>(r.get())};
+       }
+
+       template <class T, class U>
+       inline SharedRef<T> dynamicRefCast(const SharedRef<U> &r) noexcept
+       {
+               const auto ptr = dynamic_cast<T *>(r.get());
+               if (!ptr) {
+                       return {};
+               }
+               return {r.m_rc, ptr};
+       }
+
+       template <class T, class U>
+       inline const SharedRef<T> &constRefCast(const SharedRef<U> &r) noexcept
+       {
+               (void)const_cast<T *>((U *)nullptr);
+               return reinterpret_cast<const SharedRef<T> &>(r);
+       }
+
+       template <class T, class U>
+       inline SharedRef<T> &&constRefCast(SharedRef<U> &&r) noexcept
+       {
+               (void)const_cast<T *>((U *)nullptr);
+               return reinterpret_cast<SharedRef<T> &&>(r);
+       }
+}
diff --git a/ucl/include/ucl/util/memory/WeakRef.h b/ucl/include/ucl/util/memory/WeakRef.h
new file mode 100644 (file)
index 0000000..4cccbe6
--- /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 __UCL_UTIL_MEMORY_WEAK_REF_H__
+#define __UCL_UTIL_MEMORY_WEAK_REF_H__
+
+#include "SharedRef.h"
+
+namespace ucl {
+
+       template <class T>
+       class WeakRef final : public BaseRef<T> {
+       public:
+               template <class U>
+               friend void swap(WeakRef<U> &x, WeakRef<U> &y) noexcept;
+
+               template <class T2, class U>
+               friend WeakRef<T2> staticRefCast(const WeakRef<U> &r) noexcept;
+               template <class T2, class U>
+               friend WeakRef<T2> dynamicRefCast(const WeakRef<U> &r) noexcept;
+
+       public:
+               constexpr WeakRef() noexcept;
+               constexpr WeakRef(std::nullptr_t) noexcept;
+
+               WeakRef(IRefCountObj *rc, T *ptr) noexcept;
+
+               WeakRef(const WeakRef<T> &r) noexcept;
+               template <class U>
+               WeakRef(const BaseRef<U> &r) noexcept;
+
+               WeakRef(WeakRef<T> &&r) noexcept;
+               template <class U>
+               WeakRef(WeakRef<U> &&r) noexcept;
+
+               ~WeakRef();
+
+               WeakRef<T> &operator=(WeakRef<T> r) noexcept;
+
+               void reset() noexcept;
+
+               SharedRef<T> lock() const noexcept;
+
+               T *getUnsafePtr() const noexcept;
+               operator bool() const noexcept;
+
+               template <class U, class = typename std::enable_if<
+                       std::is_convertible<T *, U *>::value && (
+                               std::is_same<typename std::remove_cv<U>::type, void>::value ||
+                               std::is_same<typename std::remove_cv<U>::type,
+                                       typename std::remove_cv<T>::type>::value)>::type>
+               operator const WeakRef<U> &() const noexcept
+               {
+                       return reinterpret_cast<const WeakRef<U> &>(*this);
+               }
+       };
+
+       // Non-member functions //
+
+       template <class T>
+       WeakRef<T> makeWeak(const SharedRef<T> &r) noexcept;
+
+       template <class T, class U>
+       const WeakRef<T> &constRefCast(const WeakRef<U> &r) noexcept;
+       template <class T, class U>
+       WeakRef<T> &&constRefCast(WeakRef<U> &&r) noexcept;
+}
+
+#include "WeakRef.hpp"
+
+#endif // __UCL_UTIL_MEMORY_WEAK_REF_H__
diff --git a/ucl/include/ucl/util/memory/WeakRef.hpp b/ucl/include/ucl/util/memory/WeakRef.hpp
new file mode 100644 (file)
index 0000000..6634f3c
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class T>
+       constexpr WeakRef<T>::WeakRef() noexcept
+       {
+       }
+
+       template <class T>
+       constexpr WeakRef<T>::WeakRef(std::nullptr_t) noexcept
+       {
+       }
+
+       template <class T>
+       inline WeakRef<T>::WeakRef(
+                       IRefCountObj *const rc, T *const ptr) noexcept :
+               BaseRef<T>(rc, ptr)
+       {
+               this->m_rc->refWeak();
+       }
+
+       template <class T>
+       inline WeakRef<T>::WeakRef(const WeakRef<T> &r) noexcept :
+               BaseRef<T>(r.m_rc, r.m_ptr)
+       {
+               if (this->m_rc) {
+                       this->m_rc->refWeak();
+               }
+       }
+
+       template <class T>
+       template <class U>
+       inline WeakRef<T>::WeakRef(const BaseRef<U> &r) noexcept :
+               BaseRef<T>(r.m_rc, r.m_ptr)
+       {
+               if (this->m_rc) {
+                       this->m_rc->refWeak();
+               }
+       }
+
+       template <class T>
+       inline WeakRef<T>::WeakRef(WeakRef<T> &&r) noexcept :
+               BaseRef<T>(std::move(r))
+       {
+       }
+
+       template <class T>
+       template <class U>
+       inline WeakRef<T>::WeakRef(WeakRef<U> &&r) noexcept :
+               BaseRef<T>(std::move(r))
+       {
+       }
+
+       template <class T>
+       inline WeakRef<T>::~WeakRef()
+       {
+               if (this->m_rc) {
+                       this->m_rc->unrefWeak();
+               }
+       }
+
+       template <class T>
+       inline WeakRef<T> &WeakRef<T>::operator=(WeakRef<T> r) noexcept
+       {
+               swap(*this, r);
+               return *this;
+       }
+
+       template <class T>
+       inline void WeakRef<T>::reset() noexcept
+       {
+               *this = {};
+       }
+
+       template <class T>
+       inline SharedRef<T> WeakRef<T>::lock() const noexcept
+       {
+               if (this->m_rc && this->m_rc->refNz()) {
+                       return {this->m_rc, this->m_ptr, true};
+               }
+               return {};
+       }
+
+       template <class T>
+       inline T *WeakRef<T>::getUnsafePtr() const noexcept
+       {
+               return (operator bool() ? this->m_ptr : nullptr);
+       }
+
+       template <class T>
+       inline WeakRef<T>::operator bool() const noexcept
+       {
+               return (this->m_rc && (this->m_rc->getUseCount() > 0));
+       }
+
+       // Non-member functions //
+
+       template <class T>
+       inline WeakRef<T> makeWeak(const SharedRef<T> &r) noexcept
+       {
+               return r;
+       }
+
+       template <class T>
+       inline void swap(WeakRef<T> &x, WeakRef<T> &y) noexcept
+       {
+               std::swap(x.m_rc, y.m_rc);
+               std::swap(x.m_ptr, y.m_ptr);
+       }
+
+       template <class T, class U>
+       inline WeakRef<T> staticRefCast(const WeakRef<U> &r) noexcept
+       {
+               return {r.m_rc, static_cast<T *>(r.getUnsafePtr())};
+       }
+
+       template <class T, class U>
+       inline WeakRef<T> dynamicRefCast(const WeakRef<U> &r) noexcept
+       {
+               const auto ptr = dynamic_cast<T *>(r.getUnsafePtr());
+               if (!ptr) {
+                       return {};
+               }
+               return {r.m_rc, ptr};
+       }
+
+       template <class T, class U>
+       inline const WeakRef<T> &constRefCast(const WeakRef<U> &r) noexcept
+       {
+               (void)const_cast<T *>((U *)nullptr);
+               return reinterpret_cast<const WeakRef<T> &>(r);
+       }
+
+       template <class T, class U>
+       inline WeakRef<T> &&constRefCast(WeakRef<U> &&r) noexcept
+       {
+               (void)const_cast<T *>((U *)nullptr);
+               return reinterpret_cast<WeakRef<T> &&>(r);
+       }
+}
diff --git a/ucl/include/ucl/util/memory/helpers.h b/ucl/include/ucl/util/memory/helpers.h
new file mode 100644 (file)
index 0000000..5ce25a3
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * 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_UTIL_MEMORY_HELPERS_H__
+#define __UCL_UTIL_MEMORY_HELPERS_H__
+
+namespace ucl {
+
+       // Misc //
+
+       namespace util {
+
+               template <class T, class = typename std::enable_if<
+                               std::is_convertible<T *, IDisposable *>::value>::type>
+               inline void dispose(SharedRef<T> &r) noexcept
+               {
+                       if (r) {
+                               r->dispose();
+                               r.reset();
+                       }
+               }
+
+               template <class T, class = typename std::enable_if<
+                               std::is_convertible<T *, IDisposable *>::value>::type>
+               inline void dispose(WeakRef<T> &r) noexcept
+               {
+                       if (const auto shared = r.lock()) {
+                               shared->dispose();
+                               r.reset();
+                       }
+               }
+       }
+
+       // Generic casting functions //
+
+       template <class T, class U>
+       inline auto dynamicCast(const U &src) noexcept -> decltype(
+                       dynamicRefCast<typename T::Type>(src))
+       {
+               return dynamicRefCast<typename T::Type>(src);
+       }
+
+       template <class T, class U>
+       inline auto constCast(U &&src) noexcept -> decltype(
+                       constRefCast<typename T::Type>(std::forward<U>(src)))
+       {
+               return constRefCast<typename T::Type>(std::forward<U>(src));
+       }
+
+       // Relation operators //
+
+       namespace himpl {
+
+               template <class T, class = typename std::enable_if<
+                       !std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
+               inline const T &getCmpPtr(const T &ptr) noexcept
+               {
+                       return ptr;
+               }
+
+               template <class T>
+               inline T *getCmpPtr(const SharedRef<T> &r) noexcept
+               {
+                       return r.get();
+               }
+
+               template <class T>
+               inline T *getCmpPtr(const WeakRef<T> &r) noexcept
+               {
+                       return r.getUnsafePtr();
+               }
+       }
+
+       template <class T, class U, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
+               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
+       inline bool operator==(const T &lhs, const U &rhs) noexcept
+       {
+               return (himpl::getCmpPtr(lhs) == himpl::getCmpPtr(rhs));
+       }
+
+       template <class T, class U, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
+               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
+       inline bool operator!=(const T &lhs, const U &rhs) noexcept
+       {
+               return (himpl::getCmpPtr(lhs) != himpl::getCmpPtr(rhs));
+       }
+
+       template <class T, class U, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
+               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
+       inline bool operator<(const T &lhs, const U &rhs) noexcept
+       {
+               return (himpl::getCmpPtr(lhs) < himpl::getCmpPtr(rhs));
+       }
+
+       template <class T, class U, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
+               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
+       inline bool operator<=(const T &lhs, const U &rhs) noexcept
+       {
+               return (himpl::getCmpPtr(lhs) <= himpl::getCmpPtr(rhs));
+       }
+
+       template <class T, class U, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
+               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
+       inline bool operator>(const T &lhs, const U &rhs) noexcept
+       {
+               return (himpl::getCmpPtr(lhs) > himpl::getCmpPtr(rhs));
+       }
+
+       template <class T, class U, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value ||
+               std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
+       inline bool operator>=(const T &lhs, const U &rhs) noexcept
+       {
+               return (himpl::getCmpPtr(lhs) >= himpl::getCmpPtr(rhs));
+       }
+
+       template <class T, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
+       inline bool operator==(const T &lhs, std::nullptr_t rhs) noexcept
+       {
+               return !lhs;
+       }
+
+       template <class T, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
+       bool operator==(std::nullptr_t lhs, const T &rhs) noexcept
+       {
+               return !rhs;
+       }
+
+       template <class T, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
+       bool operator!=(const T &lhs, std::nullptr_t rhs) noexcept
+       {
+               return lhs;
+       }
+
+       template <class T, class = typename std::enable_if<
+               std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
+       bool operator!=(std::nullptr_t lhs, const T &rhs) noexcept
+       {
+               return rhs;
+       }
+}
+
+#endif // __UCL_UTIL_MEMORY_HELPERS_H__
diff --git a/ucl/include/ucl/util/memory/macro.h b/ucl/include/ucl/util/memory/macro.h
new file mode 100644 (file)
index 0000000..b97175a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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_UTIL_MEMORY_MACRO_H__
+#define __UCL_UTIL_MEMORY_MACRO_H__
+
+#define UCL_DECLARE_REF_ALIASES(CLASS_NAME) \
+               class CLASS_NAME; \
+               using CLASS_NAME##SRef = ::ucl::SharedRef<CLASS_NAME>; \
+               using CLASS_NAME##WRef = ::ucl::WeakRef<CLASS_NAME>; \
+               using CLASS_NAME##SCRef = ::ucl::SharedRef<const CLASS_NAME>; \
+               using CLASS_NAME##WCRef = ::ucl::WeakRef<const CLASS_NAME>
+
+#define UCL_USING_REF_ALIASES(CLASS_NAME) \
+               using CLASS_NAME; \
+               using CLASS_NAME##SRef; \
+               using CLASS_NAME##WRef; \
+               using CLASS_NAME##SCRef; \
+               using CLASS_NAME##WCRef; \
+
+#endif // __UCL_UTIL_MEMORY_MACRO_H__
diff --git a/ucl/include/ucl/util/shortLogs.h b/ucl/include/ucl/util/shortLogs.h
new file mode 100644 (file)
index 0000000..02f8bbf
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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_UTIL_SHORT_LOGS_H__
+#define __UCL_UTIL_SHORT_LOGS_H__
+
+#undef ULOG
+#undef URESDATALOG
+#undef URESLOG
+
+#undef VLOG
+#undef DLOG
+#undef ILOG
+#undef WLOG
+#undef ELOG
+#undef FLOG
+
+#undef VRESLOG
+#undef DRESLOG
+#undef IRESLOG
+#undef WRESLOG
+#undef ERESLOG
+#undef FRESLOG
+
+#undef RESLOG
+
+#undef RETVM_IF
+#undef RETM_IF
+
+#undef FAIL_RETURN
+#undef FAIL_RETURN_VALUE
+#undef FAIL_RETURN_VOID
+#undef FAIL_BREAK
+#undef FAIL_LOG
+
+#undef LOG_RETURN
+#undef LOG_RETURN_VALUE
+#undef LOG_RETURN_VOID
+#undef LOG_BREAK
+
+#define ULOG         UCL_ULOG
+#define URESDATALOG  UCL_URESDATALOG
+#define URESLOG      UCL_URESLOG
+
+#define VLOG  UCL_VLOG
+#define DLOG  UCL_DLOG
+#define ILOG  UCL_ILOG
+#define WLOG  UCL_WLOG
+#define ELOG  UCL_ELOG
+#define FLOG  UCL_FLOG
+
+#define VRESLOG  UCL_VRESLOG
+#define DRESLOG  UCL_DRESLOG
+#define IRESLOG  UCL_IRESLOG
+#define WRESLOG  UCL_WRESLOG
+#define ERESLOG  UCL_ERESLOG
+#define FRESLOG  UCL_FRESLOG
+
+#define RESLOG  UCL_RESLOG
+
+#define FAIL_RETURN        UCL_FAIL_RETURN
+#define FAIL_RETURN_VALUE  UCL_FAIL_RETURN_VALUE
+#define FAIL_RETURN_VOID   UCL_FAIL_RETURN_VOID
+#define FAIL_BREAK         UCL_FAIL_BREAK
+#define FAIL_LOG           UCL_FAIL_LOG
+
+#define LOG_RETURN        UCL_LOG_RETURN
+#define LOG_RETURN_VALUE  UCL_LOG_RETURN_VALUE
+#define LOG_RETURN_VOID   UCL_LOG_RETURN_VOID
+#define LOG_BREAK         UCL_LOG_BREAK
+
+#endif // __UCL_UTIL_SHORT_LOGS_H__
diff --git a/ucl/include/ucl/util/smartDelegation.h b/ucl/include/ucl/util/smartDelegation.h
new file mode 100644 (file)
index 0000000..6714411
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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_UTIL_SMART_DELEGATION_H__
+#define __UCL_UTIL_SMART_DELEGATION_H__
+
+#include "smartDelegation/WeakDelegate.h"
+
+#include "smartDelegation/macro.h"
+
+#if (UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H)
+#include "smartDelegation/shortMacro.h"
+#endif
+
+#endif // __UCL_UTIL_SMART_DELEGATION_H__
diff --git a/ucl/include/ucl/util/smartDelegation/WeakDelegate.h b/ucl/include/ucl/util/smartDelegation/WeakDelegate.h
new file mode 100644 (file)
index 0000000..97e1ae8
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
+#define __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
+
+#include "ucl/util/delegation.h"
+#include "ucl/util/memory.h"
+
+namespace ucl {
+
+       template <class FUNC_SIG>
+       class WeakDelegate;
+
+       template <class R, class ...ARGS>
+       class WeakDelegate<R(ARGS...)> :
+                       public BaseDelegate<R(ARGS...), WeakRef<void>> {
+       public:
+               using BaseDelegate<R(ARGS...), WeakRef<void>>::BaseDelegate;
+
+               R operator()(ARGS ...args) const;
+
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+               static WeakDelegate make(const WeakRef<CLASS> &data) noexcept;
+
+               template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+               static WeakDelegate make(const WeakRef<const CLASS> &data) noexcept;
+       };
+}
+
+#include "WeakDelegate.hpp"
+
+#endif // __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
diff --git a/ucl/include/ucl/util/smartDelegation/WeakDelegate.hpp b/ucl/include/ucl/util/smartDelegation/WeakDelegate.hpp
new file mode 100644 (file)
index 0000000..fa7b3f8
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       template <class R, class ...ARGS>
+       inline R WeakDelegate<R(ARGS...)>::operator()(ARGS ...args) const
+       {
+               const auto tmp = this->m_data.lock();
+               if (tmp) {
+                       return this->m_stubA(tmp.get(), std::forward<ARGS>(args)...);
+               }
+               return R();
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+       inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
+                       const WeakRef<CLASS> &data) noexcept
+       {
+               return {data, WeakDelegate::Cb::template stubA<CLASS, METHOD>};
+       }
+
+       template <class R, class ...ARGS>
+       template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+       inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
+                       const WeakRef<const CLASS> &data) noexcept
+       {
+               return {constRefCast<CLASS>(data),
+                               WeakDelegate::Cb::template stubA<CLASS, METHOD>};
+       }
+}
diff --git a/ucl/include/ucl/util/smartDelegation/macro.h b/ucl/include/ucl/util/smartDelegation/macro.h
new file mode 100644 (file)
index 0000000..b117820
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_UTIL_SMART_DELEGATION_MACRO_H__
+#define __UCL_UTIL_SMART_DELEGATION_MACRO_H__
+
+#define UCL_WEAK_DELEGATE(FUNC, DATA) \
+               _UCL_DELEGATE(::ucl::WeakDelegate, FUNC, DATA)
+
+#endif // __UCL_UTIL_SMART_DELEGATION_MACRO_H__
diff --git a/ucl/include/ucl/util/smartDelegation/shortMacro.h b/ucl/include/ucl/util/smartDelegation/shortMacro.h
new file mode 100644 (file)
index 0000000..ddf5e35
--- /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_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
+#define __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
+
+#define WEAK_DELEGATE(FUNC, DATA) UCL_WEAK_DELEGATE(FUNC, DATA)
+
+#endif // __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
diff --git a/ucl/include/ucl/util/threading.h b/ucl/include/ucl/util/threading.h
new file mode 100644 (file)
index 0000000..4595b1b
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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_UTIL_THREADING_H__
+#define __UCL_UTIL_THREADING_H__
+
+#include "threading/Thread.h"
+#include "threading/Mutex.h"
+#include "threading/MutexLock.h"
+#include "threading/CondVar.h"
+
+#endif // __UCL_UTIL_THREADING_H__
diff --git a/ucl/include/ucl/util/threading/CondVar.h b/ucl/include/ucl/util/threading/CondVar.h
new file mode 100644 (file)
index 0000000..e73a763
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_UTIL_THREADING_COND_VAR_H__
+#define __UCL_UTIL_THREADING_COND_VAR_H__
+
+#include "MutexLock.h"
+
+namespace ucl {
+
+       class CondVar final : public NonCopyable {
+       public:
+               CondVar();
+               ~CondVar();
+               void wait(MutexLock &lock);
+               void notify();
+               void notifyAll();
+               pthread_cond_t *getHandle();
+       private:
+               pthread_cond_t m_cond;
+       };
+}
+
+#include "CondVar.hpp"
+
+#endif // __UCL_UTIL_THREADING_COND_VAR_H__
diff --git a/ucl/include/ucl/util/threading/CondVar.hpp b/ucl/include/ucl/util/threading/CondVar.hpp
new file mode 100644 (file)
index 0000000..09b0ae0
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline CondVar::CondVar() :
+               m_cond()
+       {
+               pthread_cond_init(&m_cond, NULL);
+       }
+
+       inline CondVar::~CondVar()
+       {
+               pthread_cond_destroy(&m_cond);
+       }
+
+       inline void CondVar::wait(MutexLock &lock)
+       {
+               pthread_cond_wait(&m_cond, lock.getMutex().getHandle());
+       }
+
+       inline void CondVar::notify()
+       {
+               pthread_cond_signal(&m_cond);
+       }
+
+       inline void CondVar::notifyAll()
+       {
+               pthread_cond_broadcast(&m_cond);
+       }
+
+       inline pthread_cond_t *CondVar::getHandle()
+       {
+               return &m_cond;
+       }
+}
diff --git a/ucl/include/ucl/util/threading/Mutex.h b/ucl/include/ucl/util/threading/Mutex.h
new file mode 100644 (file)
index 0000000..eda90ff
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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_UTIL_THREADING_MUTEX_H__
+#define __UCL_UTIL_THREADING_MUTEX_H__
+
+// Use pthread because Tizen 3.0 officially not support C++ 11
+// And there were problems with threading in C++ 11 and Tizen 3.0
+#include <pthread.h>
+
+#include "ucl/util/types/classTypes.h"
+
+namespace ucl {
+
+       class Mutex final : public NonCopyable {
+       public:
+               Mutex(bool recursive = false);
+               ~Mutex();
+               void lock();
+               void unlock();
+               pthread_mutex_t *getHandle();
+       private:
+               pthread_mutex_t m_mutex;
+       };
+}
+
+#include "Mutex.hpp"
+
+#endif // __UCL_UTIL_THREADING_MUTEX_H__
diff --git a/ucl/include/ucl/util/threading/Mutex.hpp b/ucl/include/ucl/util/threading/Mutex.hpp
new file mode 100644 (file)
index 0000000..c3b75be
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline Mutex::Mutex(const bool recursive) :
+               m_mutex()
+       {
+               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()
+       {
+               pthread_mutex_destroy(&m_mutex);
+       }
+
+       inline void Mutex::lock()
+       {
+               pthread_mutex_lock(&m_mutex);
+       }
+
+       inline void Mutex::unlock()
+       {
+               pthread_mutex_unlock(&m_mutex);
+       }
+
+       inline pthread_mutex_t *Mutex::getHandle()
+       {
+               return &m_mutex;
+       }
+}
diff --git a/ucl/include/ucl/util/threading/MutexLock.h b/ucl/include/ucl/util/threading/MutexLock.h
new file mode 100644 (file)
index 0000000..062837f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_UTIL_THREADING_MUTEX_LOCK_H__
+#define __UCL_UTIL_THREADING_MUTEX_LOCK_H__
+
+#include "Mutex.h"
+
+namespace ucl {
+
+       class MutexLock final : public NonCopyable {
+       public:
+               MutexLock(Mutex &mutex);
+               ~MutexLock();
+               Mutex &getMutex();
+       private:
+               Mutex &m_mutex;
+       };
+}
+
+#include "MutexLock.hpp"
+
+#endif // __UCL_UTIL_THREADING_MUTEX_LOCK_H__
diff --git a/ucl/include/ucl/util/threading/MutexLock.hpp b/ucl/include/ucl/util/threading/MutexLock.hpp
new file mode 100644 (file)
index 0000000..a30d995
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+namespace ucl {
+
+       inline MutexLock::MutexLock(Mutex &mutex) :
+               m_mutex(mutex)
+       {
+               mutex.lock();
+       }
+
+       inline MutexLock::~MutexLock()
+       {
+               m_mutex.unlock();
+       }
+
+       inline Mutex &MutexLock::getMutex()
+       {
+               return m_mutex;
+       }
+}
diff --git a/ucl/include/ucl/util/threading/Thread.h b/ucl/include/ucl/util/threading/Thread.h
new file mode 100644 (file)
index 0000000..0839921
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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_UTIL_THREADING_THREAD_H__
+#define __UCL_UTIL_THREADING_THREAD_H__
+
+// Use pthread because Tizen 3.0 officially not support C++ 11
+// And there were problems with threading in C++ 11 and Tizen 3.0
+#include <pthread.h>
+
+#include "ucl/util/types/classTypes.h"
+
+namespace ucl {
+
+       class Thread final : public NonCopyable {
+       public:
+               Thread();
+               template <class FUNC>
+               explicit Thread(FUNC &&func);
+               ~Thread();
+
+               bool wasStarted() const;
+               bool wasJoinded() const;
+
+               template <class FUNC>
+               bool start(FUNC &&func);
+               void join();
+
+               pthread_t *getHandle();
+
+       private:
+               std::function<void()> m_func;
+               pthread_t m_thread;
+               bool m_wasStarted;
+               bool m_wasJoined;
+       };
+}
+
+#include "Thread.hpp"
+
+#endif // __UCL_UTIL_THREADING_THREAD_H__
diff --git a/ucl/include/ucl/util/threading/Thread.hpp b/ucl/include/ucl/util/threading/Thread.hpp
new file mode 100644 (file)
index 0000000..74259c1
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * 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 ucl {
+
+       inline Thread::Thread() :
+               m_thread(),
+               m_wasStarted(false),
+               m_wasJoined(false)
+       {
+       }
+
+       template <class FUNC>
+       inline Thread::Thread(FUNC &&func) :
+               Thread()
+       {
+               start(func);
+       }
+
+       inline Thread::~Thread()
+       {
+               if (!m_wasJoined) {
+                       join();
+               }
+       }
+
+       inline bool Thread::wasStarted() const
+       {
+               return m_wasStarted;
+       }
+
+       inline bool Thread::wasJoinded() const
+       {
+               return m_wasJoined;
+       }
+
+       template <class FUNC>
+       inline bool Thread::start(FUNC &&func)
+       {
+               if (m_wasStarted) {
+                       UCL_WLOG("Already started!");
+                       return false;
+               }
+               m_func = std::forward<FUNC>(func);
+               const int res = pthread_create(&m_thread, NULL,
+                       [](void *data) -> void *
+                       {
+                               static_cast<Thread *>(data)->m_func();
+                               return nullptr;
+                       },
+                       this);
+               if (res != 0) {
+                       UCL_ELOG("pthread_create() failed: %d", res);
+                       m_func = {};
+                       return false;
+               }
+               m_wasStarted = true;
+               return true;
+       }
+
+       inline void Thread::join()
+       {
+               if (!m_wasStarted) {
+                       UCL_WLOG("Not stared started!");
+                       return;
+               }
+               if (m_wasJoined) {
+                       UCL_WLOG("Already joined!");
+                       return;
+               }
+               m_wasJoined = true;
+               pthread_join(m_thread, NULL);
+               m_func = {};
+       }
+
+       inline pthread_t *Thread::getHandle()
+       {
+               return ((m_wasStarted && !m_wasJoined) ? &m_thread : NULL);
+       }
+}
diff --git a/ucl/include/ucl/util/types.h b/ucl/include/ucl/util/types.h
new file mode 100644 (file)
index 0000000..70a33d3
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_UTIL_TYPES_H__
+#define __UCL_UTIL_TYPES_H__
+
+#include "types/baseTypes.h"
+#include "types/classTypes.h"
+#include "types/Result.h"
+
+#endif // __UCL_UTIL_TYPES_H__
diff --git a/ucl/include/ucl/util/types/Result.h b/ucl/include/ucl/util/types/Result.h
new file mode 100644 (file)
index 0000000..099223f
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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_UTIL_TYPES_RESULT_H__
+#define __UCL_UTIL_TYPES_RESULT_H__
+
+#include "baseTypes.h"
+
+namespace ucl {
+
+       // ResultData declaration //
+
+       struct ResultData final {
+               const char *name;
+               int logPrio;
+       };
+
+       // Result declaration //
+
+       struct Result final {
+               int value;
+
+               Result() = default;
+
+               template <class VALUE, class = char(*)[VALUE::_UCL_RESULT * 0 + 1]>
+               constexpr Result(const VALUE &v) : value(v) {}
+       };
+
+       // Result non-member functions //
+
+       const ResultData &getResultData(Result result);
+
+       constexpr bool isGood(Result result);
+       constexpr bool isBad(Result result);
+
+       constexpr bool operator==(Result lhs, Result rhs);
+       constexpr bool operator!=(Result lhs, Result rhs);
+
+       // Basic Result values //
+
+       enum {
+               _UCL_RESULT,
+
+               RES_OK    = 0,
+               RES_FALSE = 1,
+               _RES_END,
+
+               RES_FAIL              = -1,
+               RES_INVALID_ARGUMENTS = -2,
+               RES_ILLEGAL_STATE     = -3,
+               RES_OUT_OF_MEMORY     = -4,
+               RES_IO_ERROR          = -5,
+               RES_NOT_SUPPORTED     = -6,
+               RES_INVALID_DATA      = -7,
+               RES_FATAL             = -8,
+               // TODO MUST match previous item!
+               _RES_BEGIN            = RES_FATAL
+       };
+}
+
+#include "Result.hpp"
+
+#endif // __UCL_UTIL_TYPES_RESULT_H__
diff --git a/ucl/include/ucl/util/types/Result.hpp b/ucl/include/ucl/util/types/Result.hpp
new file mode 100644 (file)
index 0000000..c83db4c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace ucl {
+
+       constexpr bool isGood(const Result result)
+       {
+               return (result.value >= RES_OK);
+       }
+
+       constexpr bool isBad(const Result result)
+       {
+               return !isGood(result);
+       }
+
+       constexpr bool operator==(const Result lhs, const Result rhs)
+       {
+               return (lhs.value == rhs.value);
+       }
+
+       constexpr bool operator!=(const Result lhs, const Result rhs)
+       {
+               return (lhs.value != rhs.value);
+       }
+}
diff --git a/ucl/include/ucl/util/types/baseTypes.h b/ucl/include/ucl/util/types/baseTypes.h
new file mode 100644 (file)
index 0000000..c5062db
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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_UTIL_TYPES_BASE_TYPES_H__
+#define __UCL_UTIL_TYPES_BASE_TYPES_H__
+
+#include <cstddef>
+#include <cstdlib>
+#include <cstdint>
+
+#include <string>
+#include <memory>
+#include <atomic>
+#include <functional>
+#include <type_traits>
+#include <utility>
+
+#include <Eina.h>
+
+#include "ucl/config.h"
+
+namespace ucl {
+       using UInt = unsigned int;
+}
+
+#endif // __UCL_UTIL_TYPES_BASE_TYPES_H__
diff --git a/ucl/include/ucl/util/types/classTypes.h b/ucl/include/ucl/util/types/classTypes.h
new file mode 100644 (file)
index 0000000..5c708d2
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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_UTIL_TYPES_CLASS_TYPES_H__
+#define __UCL_UTIL_TYPES_CLASS_TYPES_H__
+
+#include "baseTypes.h"
+
+namespace ucl {
+
+       class NonCopyable {
+       public:
+               NonCopyable(const NonCopyable &) = delete;
+               NonCopyable &operator=(const NonCopyable &) = delete;
+       protected:
+               NonCopyable() = default;
+               ~NonCopyable() = default;
+       };
+
+       class Polymorphic : public NonCopyable {
+       protected:
+               Polymorphic() = default;
+               virtual ~Polymorphic() = default;
+       };
+
+       class IDisposable : public Polymorphic {
+       public:
+               virtual void dispose() = 0;
+               virtual bool isDisposed() const = 0;
+       protected:
+               virtual ~IDisposable() = default;
+       };
+
+       template <class IPRODUCT>
+       class IFactory : public Polymorphic {
+       public:
+               using IProduct = IPRODUCT;
+       public:
+               virtual IPRODUCT *newInstance() const = 0;
+       protected:
+               virtual ~IFactory() = default;
+       };
+
+       template <class PRODUCT, class IPRODUCT>
+       class Factory final : public IFactory<IPRODUCT> {
+       public:
+               using Product = PRODUCT;
+       public:
+               virtual IPRODUCT *newInstance() const final override
+               {
+                       return new PRODUCT();
+               }
+       };
+
+       // Priority selector for SFINAE functions
+       template <int N>
+       struct P : P<N - 1> {};
+       template <>
+       struct P<0> {};
+}
+
+#endif // __UCL_UTIL_TYPES_CLASS_TYPES_H__
diff --git a/ucl/source/appfw/InstanceManagerBase.cpp b/ucl/source/appfw/InstanceManagerBase.cpp
new file mode 100644 (file)
index 0000000..2e90b24
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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/appfw/InstanceManagerBase.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       InstanceManagerBase::InstanceManagerBase(AppParams appParams) :
+               m_appParams(std::move(appParams))
+       {
+       }
+
+       InstanceManagerBase::~InstanceManagerBase()
+       {
+       }
+
+       const AppParams &InstanceManagerBase::getAppParams() const
+       {
+               return m_appParams;
+       }
+
+       void InstanceManagerBase::setSysEventProvider(SysEventProviderUPtr provider)
+       {
+               m_sysEventProvider = std::move(provider);
+       }
+
+       SysEventProvider &InstanceManagerBase::getSysEventProvider() const
+       {
+               UCL_ASSERT(m_sysEventProvider, "m_sysEventProvider is NULL!");
+               return *m_sysEventProvider;
+       }
+}
diff --git a/ucl/source/appfw/SysEventProvider.cpp b/ucl/source/appfw/SysEventProvider.cpp
new file mode 100644 (file)
index 0000000..8958aaf
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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/appfw/SysEventProvider.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       // SysEventProvider::EventProxy //
+
+       class SysEventProvider::EventProxy : public NonCopyable {
+       public:
+               EventProxy(SysEventProvider &provider,
+                               const SysEvent sysEvent,
+                               const app_event_type_e appEvent):
+                       m_provider(provider),
+                       m_sysEvent(sysEvent)
+               {
+                       const int res = m_provider.addEventHandler(&m_eventHandler,
+                                       appEvent, CALLBACK_B(EventProxy::onAppEvent), this);
+                       if (res != APP_ERROR_NONE) {
+                               if (res != APP_ERROR_INVALID_PARAMETER) {
+                                       ELOG("addEventHandler() failed! %d", res);
+                               }
+                               m_eventHandler = nullptr;
+                       }
+               }
+
+               ~EventProxy()
+               {
+                       if (m_eventHandler) {
+                               const int res = m_provider.delEventHandler(m_eventHandler);
+                               if (res != APP_ERROR_NONE) {
+                                       WLOG("delEventHandler() failed! %d", res);
+                               }
+                       }
+               }
+
+       private:
+               void onAppEvent(app_event_info_h event)
+               {
+                       m_provider.dispatch(m_sysEvent);
+               }
+
+       private:
+               SysEventProvider &m_provider;
+               app_event_handler_h m_eventHandler;
+               SysEvent m_sysEvent;
+       };
+
+       // SysEventProvider //
+
+       SysEventProvider::SysEventProvider(EventHandlerAddFunc addFunc,
+                       EventHandlerDelFunc delFunc):
+               m_addFunc(addFunc),
+               m_delFunc(delFunc)
+       {
+               m_eventProxies.emplace_back(*this, SysEvent::LANGUAGE_CHANGED,
+                               APP_EVENT_LANGUAGE_CHANGED);
+
+               m_eventProxies.emplace_back(*this, SysEvent::REGION_FMT_CHANGED,
+                               APP_EVENT_REGION_FORMAT_CHANGED);
+
+               m_eventProxies.emplace_back(*this, SysEvent::LOW_MEMORY,
+                               APP_EVENT_LOW_MEMORY);
+
+               m_eventProxies.emplace_back(*this, SysEvent::LOW_BATTERY,
+                               APP_EVENT_LOW_BATTERY);
+
+               m_eventProxies.emplace_back(*this, SysEvent::ORIENTATION_CHANGED,
+                               APP_EVENT_DEVICE_ORIENTATION_CHANGED);
+
+               m_eventProxies.emplace_back(*this, SysEvent::SUSPEND_STATE_CHANGED,
+                               APP_EVENT_SUSPENDED_STATE_CHANGED);
+
+               m_eventProxies.emplace_back(*this, SysEvent::UPDATE_REQUESTED,
+                               APP_EVENT_UPDATE_REQUESTED);
+       }
+
+       SysEventProvider::~SysEventProvider()
+       {
+       }
+
+       int SysEventProvider::addEventHandler(app_event_handler_h *handler,
+                       app_event_type_e appEvent, app_event_cb cb, void *data)
+       {
+               return m_addFunc(handler, appEvent, cb, data);
+       }
+
+       int SysEventProvider::delEventHandler(app_event_handler_h handler)
+       {
+               return m_delFunc(handler);
+       }
+
+       void SysEventProvider::dispatch(SysEvent sysEvent)
+       {
+               m_event.dispatch(sysEvent);
+       }
+}
diff --git a/ucl/source/appfw/UIApp.cpp b/ucl/source/appfw/UIApp.cpp
new file mode 100644 (file)
index 0000000..6f49c2b
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * 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/appfw/UIApp.h"
+
+#include <app.h>
+
+#include "ucl/appfw/IInstanceAppControlExt.h"
+#include "common.h"
+
+namespace ucl {
+
+       UIApp::UIApp(InstanceManagerBase &instanceMgr) :
+               m_instanceMgr(instanceMgr)
+       {
+       }
+
+       UIApp::~UIApp()
+       {
+       }
+
+       int UIApp::run(int argc, char *argv[])
+       {
+               ui_app_lifecycle_callback_s alcc = {};
+               alcc.create = CALLBACK_B(UIApp::onCreate);
+               alcc.terminate = CALLBACK_B(UIApp::onTerminate);
+               alcc.pause = CALLBACK_B(UIApp::onPause);
+               alcc.resume = CALLBACK_B(UIApp::onResume);
+               alcc.app_control = CALLBACK_B(UIApp::onAppControl);
+
+               const int ret = ui_app_main(argc, argv, &alcc, this);
+               if (ret != APP_ERROR_NONE) {
+                       LOG_RETURN_VALUE(RES_FAIL, ret, "ui_app_main() failed! %d", ret);
+               }
+
+               return 0;
+       }
+
+       AppType UIApp::getAppType() const
+       {
+               return AppType::UI;
+       }
+
+       WindowSRef UIApp::getWindow()
+       {
+               return m_window;
+       }
+
+       void UIApp::exitApp()
+       {
+               ui_app_exit();
+       }
+
+       bool UIApp::onCreate()
+       {
+               FAIL_RETURN_VALUE(configParams(), false, "configParams() failed!");
+
+               FAIL_RETURN_VALUE(createWindow(), false, "createWindow() failed!");
+
+               initSysEventManager();
+
+               FAIL_RETURN_VALUE(createInstance(), false, "createInstance() failed!");
+
+               return true;
+       }
+
+       void UIApp::onTerminate()
+       {
+               m_instance.reset();
+               m_instanceMgr.setSysEventProvider(nullptr);
+               m_window.reset();
+       }
+
+       void UIApp::onPause()
+       {
+               if (m_instance) {
+                       m_instance->onPause();
+               }
+       }
+
+       void UIApp::onResume()
+       {
+               if (m_instance) {
+                       m_instance->onResume();
+               }
+       }
+
+       void UIApp::onAppControl(app_control_h appControl)
+       {
+               auto instance = dynamic_cast<
+                               IInstanceAppControlExt *>(m_instance.get());
+               if (instance) {
+                       instance->onAppControl(appControl);
+               }
+       }
+
+       Result UIApp::configParams()
+       {
+               auto &&appParams = m_instanceMgr.getAppParams();
+
+               Variant paramValue;
+
+               if (appParams.get(AppParam::BASE_SCALE, paramValue)) {
+                       const double baseScale = paramValue.asDouble();
+                       if (baseScale <= 0.0) {
+                               LOG_RETURN(RES_INVALID_DATA,
+                                               "Invalid parameter BASE_SCALE: %f", baseScale);
+                       }
+                       elm_app_base_scale_set(baseScale);
+               }
+
+               if (appParams.get(AppParam::ACCELERATION_PREFERENECE, paramValue)) {
+                       const auto accelPreference = paramValue.asString();
+                       if (isEmpty(accelPreference)) {
+                               LOG_RETURN(RES_INVALID_DATA,
+                                               "Invalid parameter ACCELERATION_PREFERENECE: %s",
+                                               accelPreference.get());
+                       }
+                       elm_config_accel_preference_set(accelPreference.get());
+               }
+
+               return RES_OK;
+       }
+
+       Result UIApp::createWindow()
+       {
+               auto &&appParams = m_instanceMgr.getAppParams();
+
+               Variant paramValue;
+
+               auto winType = Window::Type::BASIC;
+               if (appParams.get(AppParam::WINDOW_TYPE, paramValue)) {
+                       winType = static_cast<Window::Type>(paramValue.asInt());
+                       if (isNotValid(winType)) {
+                               LOG_RETURN(RES_INVALID_DATA,
+                                               "Invalid parameter WINDOW_TYPE: %d", winType);
+                       }
+               }
+
+               paramValue = appParams.get(AppParam::WINDOW_NAME);
+               if (isEmpty(paramValue)) {
+                       LOG_RETURN(RES_INVALID_DATA, "WINDOW_NAME must not be empty!");
+               }
+
+               m_window = Window::Builder().
+                               setType(winType).
+                               setName(paramValue.asString().get()).
+                               build();
+               if (!m_window) {
+                       LOG_RETURN(RES_FAIL, "Window::Builder().build() Failed!");
+               }
+
+               return RES_OK;
+       }
+
+       void UIApp::initSysEventManager()
+       {
+               m_instanceMgr.setSysEventProvider(
+                               util::makeUnique(new SysEventProvider(
+                                       &ui_app_add_event_handler,
+                                       &ui_app_remove_event_handler)));
+       }
+
+       Result UIApp::createInstance()
+       {
+               auto instance = m_instanceMgr.newInstance();
+               if (!instance) {
+                       LOG_RETURN(RES_FAIL, "m_instanceMgr.newInstance() failed!");
+               }
+
+               const auto res = instance->onCreate(this);
+               if (isBad(res)) {
+                       LOG_RETURN(res, "instance->onCreate() failed!");
+               }
+
+               m_instance = std::move(instance);
+
+               return RES_OK;
+       }
+}
diff --git a/ucl/source/appfw/common.h b/ucl/source/appfw/common.h
new file mode 100644 (file)
index 0000000..402bb6e
--- /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_SOURCE_APPFW_COMMON_H__
+#define __UCL_SOURCE_APPFW_COMMON_H__
+
+#include "ucl/source/common.h"
+
+#endif // __UCL_SOURCE_APPFW_COMMON_H__
diff --git a/ucl/source/appfw/helpers.cpp b/ucl/source/appfw/helpers.cpp
new file mode 100644 (file)
index 0000000..c547dce
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ucl/appfw/helpers.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       std::string getResPath(const char *const relativePath)
+       {
+               std::string result;
+               char *const resDir = app_get_resource_path();
+               if (resDir) {
+                       result = resDir;
+                       free(resDir);
+               } else {
+                       ELOG("app_get_resource_path() failed!");
+               }
+               result += relativePath;
+               return result;
+       }
+}
diff --git a/ucl/source/common.h b/ucl/source/common.h
new file mode 100644 (file)
index 0000000..3312380
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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_SOURCE_COMMON_H__
+#define __UCL_SOURCE_COMMON_H__
+
+#include <cmath>
+#include <cstring>
+
+#include <algorithm>
+
+#include <Ecore.h>
+
+#include "ucl/util/types.h"
+#include "ucl/util/helpers.h"
+#include "ucl/util/logging.h"
+#include "ucl/util/shortLogs.h"
+
+#include "ucl/util/delegation/shortMacro.h"
+#include "ucl/util/smartDelegation/shortMacro.h"
+
+#endif // __UCL_SOURCE_COMMON_H__
diff --git a/ucl/source/gui/EdjeWidget.cpp b/ucl/source/gui/EdjeWidget.cpp
new file mode 100644 (file)
index 0000000..8d67596
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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/gui/EdjeWidget.h"
+
+namespace ucl {
+
+       void EdjeWidget::setText(const TString &value)
+       {
+               if (value.isTranslatable()) {
+                       if (value.hasDomain()) {
+                               elm_object_domain_translatable_text_set(
+                                               getEo(), value.getDomain(), value);
+                       } else {
+                               elm_object_translatable_text_set(getEo(), value);
+                       }
+               } else {
+                       elm_object_domain_text_translatable_set(getEo(),
+                                       nullptr, EINA_FALSE);
+                       elm_object_text_set(getEo(), value);
+               }
+       }
+
+       void EdjeWidget::setText(const TString &value, const EdjePart part)
+       {
+               if (value.isTranslatable()) {
+                       if (value.hasDomain()) {
+                               elm_object_domain_translatable_part_text_set(
+                                               getEo(), part.name, value.getDomain(), value);
+                       } else {
+                               elm_object_translatable_part_text_set(
+                                               getEo(), part.name, value);
+                       }
+               } else {
+                       elm_object_part_text_translatable_set(getEo(),
+                                       part.name, EINA_FALSE);
+                       elm_object_part_text_set(getEo(), part.name, value);
+               }
+       }
+}
diff --git a/ucl/source/gui/ElmWidget.cpp b/ucl/source/gui/ElmWidget.cpp
new file mode 100644 (file)
index 0000000..b7d227e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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/gui/ElmWidget.h"
+
+#include "ucl/gui/Window.h"
+#include "ucl/gui/helpers.h"
+
+namespace ucl {
+
+       ElmWidget::ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner) :
+               Widget(rc, eo, isOwner),
+               m_isAtspiGestureCbSet(false)
+       {
+       }
+
+       ElmWidget::~ElmWidget()
+       {
+               if (m_isAtspiGestureCbSet) {
+                       elm_atspi_accessible_gesture_cb_set(getEo(), nullptr, nullptr);
+               }
+       }
+
+       void ElmWidget::setFocusedImpl(const bool value)
+       {
+               elm_object_focus_set(getEo(), toEina(value));
+       }
+
+       bool ElmWidget::isFocusedImpl() const
+       {
+               return elm_object_focus_get(getEo());
+       }
+
+       bool ElmWidget::ensureFwdEvent(const SmartEvent fwdEvent)
+       {
+               if (Widget::ensureFwdEvent(fwdEvent)) {
+                       return true;
+               }
+               if (fwdEvent == ATSPI_ON_GESTURE) {
+                       if (!m_isAtspiGestureCbSet) {
+                               m_isAtspiGestureCbSet = true;
+                               elm_atspi_accessible_gesture_cb_set(getEo(),
+                                               CALLBACK_A(ElmWidget::onAtspiGesture), this);
+                       }
+                       return true;
+               }
+               return false;
+       }
+
+       Eina_Bool ElmWidget::onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
+                                       Evas_Object *obj)
+       {
+               AtspiGestureEventInfo eventInfo{gestureInfo};
+               callEvent(ATSPI_ON_GESTURE, &eventInfo);
+               return toEina(eventInfo.preventDefault);
+       }
+
+       Window *ElmWidget::getWindow() const
+       {
+               return dynamicWidgetCast<Window>(getTopWidget());
+       }
+}
diff --git a/ucl/source/gui/Genlist.cpp b/ucl/source/gui/Genlist.cpp
new file mode 100644 (file)
index 0000000..b0e31a5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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/gui/Genlist.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       // Genlist::Builder //
+
+       GenlistSRef Genlist::Builder::build(ElmWidget &parent) const
+       {
+               Evas_Object *const eo = elm_genlist_add(parent);
+               if (!eo) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "elm_genlist_add() failed!");
+               }
+
+               auto result = makeShared<Genlist>(eo, m_isOwner);
+
+               if (m_needBindToEo) {
+                       result->bindToEo();
+               }
+
+               if (isValid(m_style)) {
+                       result->setStyle(m_style);
+               }
+
+               result->setMode(m_mode);
+               result->setHomogeneous(m_isHomogeneous);
+
+               show(*result);
+
+               return result;
+       }
+}
diff --git a/ucl/source/gui/Layout.cpp b/ucl/source/gui/Layout.cpp
new file mode 100644 (file)
index 0000000..1509fc5
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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/gui/Layout.h"
+
+#include "ucl/gui/stdTheme/layout.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       // Layout::Builder //
+
+       LayoutSRef Layout::Builder::build(ElmWidget &parent) const
+       {
+               Evas_Object *const eo = elm_layout_add(parent);
+               if (!eo) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "elm_layout_add() failed!");
+               }
+
+               auto result = makeShared<Layout>(eo, m_isOwner);
+
+               if (m_needBindToEo) {
+                       result->bindToEo();
+               }
+
+               bool isOk = true;
+
+               if (isNotEmpty(m_edjeFilePath) && isValid(m_edjeGroup)) {
+                       isOk = result->setEdjeFile(m_edjeFilePath, m_edjeGroup);
+               } else if (isValid(m_theme)) {
+                       isOk = result->setTheme(m_theme);
+               }
+
+               if (!isOk) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "Layout init failed!");
+               }
+
+               show(*result);
+
+               return result;
+       }
+}
diff --git a/ucl/source/gui/NaviItem.cpp b/ucl/source/gui/NaviItem.cpp
new file mode 100644 (file)
index 0000000..02f5da2
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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/gui/NaviItem.h"
+
+#include "ucl/gui/Naviframe.h"
+#include "ucl/gui/helpers.h"
+
+namespace ucl {
+
+       void NaviItem::popTo() const
+       {
+               const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
+               const bool needStartTransition =
+                               (navi && (navi->getTopItem() != *this));
+
+               elm_naviframe_item_pop_to(getIt());
+
+               if (needStartTransition) {
+                       navi->setInTransition(true);
+               }
+       }
+
+       void NaviItem::promote() const
+       {
+               const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
+               const bool needStartTransition =
+                               (navi && (navi->getTopItem() != *this));
+
+               elm_naviframe_item_promote(getIt());
+
+               if (needStartTransition) {
+                       navi->setInTransition(true);
+               }
+       }
+}
diff --git a/ucl/source/gui/Naviframe.cpp b/ucl/source/gui/Naviframe.cpp
new file mode 100644 (file)
index 0000000..717940b
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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/gui/Naviframe.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       // Naviframe::Builder //
+
+       NaviframeSRef Naviframe::Builder::build(ElmWidget &parent) const
+       {
+               Evas_Object *const eo = elm_naviframe_add(parent);
+               if (!eo) {
+                       ELOG("elm_naviframe_add() failed!");
+                       return {};
+               }
+
+               auto result = makeShared<Naviframe>(eo);
+
+               if (m_needBindToEo) {
+                       result->bindToEo();
+               }
+
+               if (isValid(m_style)) {
+                       result->setStyle(m_style);
+               }
+
+               show(*result);
+
+               return result;
+       }
+
+       // Naviframe //
+
+       Naviframe::Naviframe(IRefCountObj &rc, Evas_Object *eo) :
+               StyledWidget(&rc, eo),
+               m_isInTransition(false)
+       {
+               addEventHandler(NAVI_TRANSITION_FINISHED, WEAK_DELEGATE(
+                               Naviframe::onTransitionFinished, asWeak(*this)));
+       }
+
+       void Naviframe::setInTransition(const bool inTransition)
+       {
+               if (inTransition != m_isInTransition) {
+                       m_isInTransition = inTransition;
+                       if (inTransition) {
+                               callEvent(NAVI_TRANSITION_STARTED);
+                       } else {
+                               callEvent(NAVI_TRANSITION_FINISHED);
+                       }
+               }
+       }
+
+       void Naviframe::onTransitionFinished(Widget &widget, void *eventInfo)
+       {
+               m_isInTransition = false;
+       }
+}
diff --git a/ucl/source/gui/Widget.cpp b/ucl/source/gui/Widget.cpp
new file mode 100644 (file)
index 0000000..096c6e1
--- /dev/null
@@ -0,0 +1,300 @@
+/*
+ * 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/gui/Widget.h"
+
+#include "common.h"
+
+namespace ucl { namespace { namespace impl {
+
+       constexpr auto WIDGET_EVENT_SMART = EVAS_CALLBACK_LAST;
+}}}
+
+namespace ucl {
+
+       // Widget::EventProxy //
+
+       class Widget::EventProxy : public NonCopyable {
+       public:
+               EventProxy(Widget &widget, const WidgetEvent event,
+                               const WidgetEventHandler handler) :
+                       m_widget(widget),
+                       m_handler(handler),
+                       m_type(static_cast<Evas_Callback_Type>(event))
+               {
+                       evas_object_event_callback_add(m_widget.getEo(),
+                                       m_type, event_cb, this);
+               }
+
+               EventProxy(Widget &widget, const SmartEvent event,
+                               const WidgetEventHandler handler) :
+                       m_widget(widget),
+                       m_smartEvent(event),
+                       m_handler(handler),
+                       m_type(impl::WIDGET_EVENT_SMART)
+               {
+                       evas_object_smart_callback_add(m_widget.getEo(),
+                                       m_smartEvent.c_str(), smart_cb, this);
+               }
+
+               ~EventProxy()
+               {
+                       if (m_type == impl::WIDGET_EVENT_SMART) {
+                               evas_object_smart_callback_del_full(m_widget.getEo(),
+                                               m_smartEvent.c_str(), smart_cb, this);
+                       } else {
+                               evas_object_event_callback_del_full(m_widget.getEo(),
+                                               m_type, event_cb, this);
+                       }
+               }
+
+               void setSelfIt(const Widget::EventProxiesIt it)
+               {
+                       m_selfIt = it;
+               }
+
+               bool operator==(const std::pair<WidgetEvent, WidgetEventHandler> &rhs)
+               {
+                       return ((m_type == static_cast<Evas_Callback_Type>(rhs.first)) &&
+                                       (m_handler == rhs.second));
+               }
+
+               bool operator==(const std::pair<SmartEvent, WidgetEventHandler> &rhs)
+               {
+                       return ((m_type == impl::WIDGET_EVENT_SMART) &&
+                                       (m_handler == rhs.second) &&
+                                       (m_smartEvent.compare(rhs.first) == 0));
+               }
+
+       private:
+               static void event_cb(void *data, Evas *e,
+                               Evas_Object *obj, void *event_info)
+               {
+                       static_cast<EventProxy *>(data)->dispatchEvent(event_info);
+               }
+
+               static void smart_cb(void *data, Evas_Object *obj, void *event_info)
+               {
+                       static_cast<EventProxy *>(data)->dispatchEvent(event_info);
+               }
+
+               void dispatchEvent(void *const event_info)
+               {
+                       if (m_handler) {
+                               m_handler(m_widget, event_info);
+                       } else {
+                               m_widget.delEventProxy(m_selfIt);
+                       }
+               }
+
+       private:
+               Widget &m_widget;
+               const std::string m_smartEvent;
+               const WidgetEventHandler m_handler;
+               const Evas_Callback_Type m_type;
+               Widget::EventProxiesIt m_selfIt;
+       };
+
+       // Widget //
+
+       Widget::Widget(IRefCountObj *const rc, Evas_Object *const eo,
+                       const bool isOwner) :
+               RefCountAware(rc),
+               m_eo(eo),
+               m_isOwner(isOwner),
+               m_isBoundToEo(false),
+               m_isEoRefKept(false),
+               m_isSelfRefUnique(false)
+       {
+               UCL_ASSERT(m_eo, "m_eo is NULL!");
+
+               if (isShared()) {
+                       evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_DEL,
+                                       EO_CALLBACK_PRIORITY_AFTER,
+                                       CALLBACK_A(Widget::onEoDel), this);
+               }
+
+               updateRefs();
+       }
+
+       Widget::~Widget()
+       {
+               m_eventProxies.clear();
+
+               if (m_isBoundToEo) {
+                       unbindFromEo();
+               }
+
+               if (isShared()) {
+                       evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_DEL,
+                                       CALLBACK_A(Widget::onEoDel), this);
+               }
+
+               if (m_isOwner) {
+                       evas_object_del(m_eo);
+               }
+
+               if (m_isEoRefKept) {
+                       evas_object_unref(m_eo);
+               }
+       }
+
+       void Widget::bindToEo()
+       {
+               if (!evas_object_data_get(m_eo, impl::WIDGET_DATA_NAME)) {
+                       evas_object_data_set(m_eo, impl::WIDGET_DATA_NAME, this);
+                       m_isBoundToEo = true;
+               } else {
+                       WLOG("Other Widget is already bound to this Eo!");
+               }
+       }
+
+       void Widget::unbindFromEo()
+       {
+               if (evas_object_data_get(m_eo, impl::WIDGET_DATA_NAME) == this) {
+                       evas_object_data_del(m_eo, impl::WIDGET_DATA_NAME);
+                       m_isBoundToEo = false;
+               } else {
+                       WLOG("Widget does not bound to its Eo!");
+               }
+       }
+
+       void Widget::updateRefs()
+       {
+               updateEoRef();
+
+               if (isShared()) {
+                       updateSelfRef();
+               }
+       }
+
+       void Widget::updateEoRef()
+       {
+               if (needKeepEoRef()) {
+                       if (!m_isEoRefKept) {
+                               m_isEoRefKept = true;
+                               evas_object_ref(m_eo);
+                       }
+               } else if (m_isEoRefKept) {
+                       m_isEoRefKept = false;
+                       evas_object_unref(m_eo);
+               }
+       }
+
+       bool Widget::needKeepEoRef() const
+       {
+               return (!m_isSelfRefUnique || !needKeepSelfRef());
+       }
+
+       void Widget::updateSelfRef()
+       {
+               if (!needKeepSelfRef()) {
+                       m_selfRef.reset();
+               } else if (!m_selfRef) {
+                       m_selfRef = asShared(*this);
+               }
+       }
+
+       bool Widget::needKeepSelfRef() const
+       {
+               return (!m_isOwner && m_eo);
+       }
+
+       void Widget::setSelfRefUnique(const bool value)
+       {
+               if (value != m_isSelfRefUnique) {
+                       m_isSelfRefUnique = value;
+                       updateEoRef();
+               }
+       }
+
+       void Widget::onEoDel(Evas *e, Evas_Object *obj, void *event_info)
+       {
+               if (!m_selfRef) {
+                       FLOG("UNEXPECTED! m_selfRef is NULL!");
+                       m_eo = nullptr;
+                       return;
+               }
+               if (m_isOwner || m_isEoRefKept || !m_isSelfRefUnique) {
+                       ELOG("UNEXPECTED! m_isOwner: %d; m_isEoRefKept: %d; "
+                                       "m_isSelfRefUnique: %d;",
+                                       m_isOwner, m_isEoRefKept, m_isSelfRefUnique);
+                       m_eo = nullptr;
+               }
+               m_selfRef.reset();
+       }
+
+       void Widget::onUniqueChanged(bool isUnique)
+       {
+               setSelfRefUnique(isUnique);
+       }
+
+       void Widget::delEventProxy(const EventProxiesIt it)
+       {
+               if (it != m_eventProxies.end()) {
+                       m_eventProxies.erase(it);
+               }
+       }
+
+       void Widget::addEventHandler(const WidgetEvent event,
+                       const WidgetEventHandler handler)
+       {
+               m_eventProxies.emplace_front(*this, event, handler);
+               m_eventProxies.front().setSelfIt(m_eventProxies.begin());
+       }
+
+       void Widget::addEventHandler(const SmartEvent event,
+                       const WidgetEventHandler handler)
+       {
+               if (strncmp(event.name, UCL_SMART_FWD, strlen(UCL_SMART_FWD)) == 0) {
+                       if (!ensureFwdEvent(event)) {
+                               LOG_RETURN_VOID(RES_NOT_SUPPORTED,
+                                               "Event is not supported: %s;", event.name);
+                       }
+               }
+               m_eventProxies.emplace_front(*this, event, handler);
+               m_eventProxies.front().setSelfIt(m_eventProxies.begin());
+       }
+
+       void Widget::delEventHandler(const WidgetEvent event,
+                       const WidgetEventHandler handler)
+       {
+               delEventProxy(std::find(m_eventProxies.begin(), m_eventProxies.end(),
+                               std::make_pair(event, handler)));
+       }
+
+       void Widget::delEventHandler(const SmartEvent event,
+                       const WidgetEventHandler handler)
+       {
+               delEventProxy(std::find(m_eventProxies.begin(), m_eventProxies.end(),
+                               std::make_pair(event, handler)));
+       }
+
+       void Widget::setFocusedImpl(const bool value)
+       {
+               evas_object_focus_set(getEo(), toEina(value));
+       }
+
+       bool Widget::isFocusedImpl() const
+       {
+               return evas_object_focus_get(getEo());
+       }
+
+       bool Widget::ensureFwdEvent(const SmartEvent fwdEvent)
+       {
+               return false;
+       }
+}
diff --git a/ucl/source/gui/WidgetItem.cpp b/ucl/source/gui/WidgetItem.cpp
new file mode 100644 (file)
index 0000000..04d1fca
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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/gui/WidgetItem.h"
+
+namespace ucl {
+
+       void WidgetItem::setText(const TString &value) const
+       {
+               if (value.isTranslatable()) {
+                       if (value.hasDomain()) {
+                               elm_object_item_domain_translatable_text_set(
+                                               getIt(), value.getDomain(), value);
+                       } else {
+                               elm_object_item_translatable_text_set(getIt(), value);
+                       }
+               } else {
+                       elm_object_item_text_translatable_set(getIt(), EINA_FALSE);
+                       elm_object_item_text_set(getIt(), value);
+               }
+       }
+
+       void WidgetItem::setText(const TString &value,
+                       const EdjePart part) const
+       {
+               if (value.isTranslatable()) {
+                       if (value.hasDomain()) {
+                               elm_object_item_domain_translatable_part_text_set(
+                                               getIt(), part.name, value.getDomain(), value);
+                       } else {
+                               elm_object_item_translatable_part_text_set(
+                                               getIt(), part.name, value);
+                       }
+               } else {
+                       elm_object_item_part_text_translatable_set(getIt(),
+                                       part.name, EINA_FALSE);
+                       elm_object_item_part_text_set(getIt(), part.name, value);
+               }
+       }
+}
diff --git a/ucl/source/gui/Window.cpp b/ucl/source/gui/Window.cpp
new file mode 100644 (file)
index 0000000..3f74e9e
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ucl/gui/Window.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       // Window::Builder //
+
+       WindowSRef Window::Builder::build() const
+       {
+               if (!m_winEo && isEmpty(m_name) && isEmpty(m_title)) {
+                       ELOG("Wrong built parameters!");
+                       return {};
+               }
+
+               Evas_Object *winEo = m_winEo;
+               bool isOwner = m_isOwner;
+
+               if (!winEo) {
+                       winEo = elm_win_add(nullptr,
+                                       (m_name.empty() ? m_title : m_name).c_str(),
+                                       static_cast<Elm_Win_Type>(m_type));
+                       if (!winEo) {
+                               ELOG("elm_win_add() failed!");
+                               return {};
+                       }
+                       if (!m_isOwnerWasSet) {
+                               isOwner = true;
+                       }
+               }
+
+               StyledWidget bg(elm_bg_add(winEo));
+               expand(bg);
+               show(bg);
+
+               StyledWidget conform(elm_conformant_add(winEo));
+               expand(conform);
+               show(conform);
+
+               elm_win_resize_object_add(winEo, bg);
+               elm_win_resize_object_add(winEo, conform);
+
+               elm_win_indicator_opacity_set(winEo, ELM_WIN_INDICATOR_OPAQUE);
+               elm_win_conformant_set(winEo, EINA_TRUE);
+
+               auto result = makeShared<Window>(winEo, isOwner, conform);
+
+               if (m_needBindToEo) {
+                       result->bindToEo();
+               }
+
+               result->setTitle(m_title.empty() ? m_name : m_title);
+
+               if (result->isRotationsSupported()) {
+                       result->setRotations(m_rotations);
+               }
+
+               result->setIndicatorVisible(m_isIndicatorVisible);
+
+               return result;
+       }
+}
diff --git a/ucl/source/gui/common.h b/ucl/source/gui/common.h
new file mode 100644 (file)
index 0000000..b8a0028
--- /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_SOURCE_GUI_COMMON_H__
+#define __UCL_SOURCE_GUI_COMMON_H__
+
+#include "ucl/source/common.h"
+
+#endif // __UCL_SOURCE_GUI_COMMON_H__
diff --git a/ucl/source/misc/Timeout.cpp b/ucl/source/misc/Timeout.cpp
new file mode 100644 (file)
index 0000000..41a3d3f
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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/misc/Timeout.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       TimeoutSRef Timeout::create(double timeoutSec,
+                       const TimeoutHandler &handler)
+       {
+               auto result = makeShared<Timeout>(handler);
+
+               FAIL_RETURN_VALUE(result->prepare(timeoutSec), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       Timeout::Timeout(const TimeoutHandler &handler) :
+               m_timer(nullptr),
+               m_handler(handler)
+       {
+       }
+
+       Timeout::~Timeout()
+       {
+               if (m_timer) {
+                       ecore_timer_del(m_timer);
+               }
+       }
+
+       Result Timeout::prepare(const double timeoutSec)
+       {
+               m_timer = ecore_timer_add(timeoutSec,
+                       [](void *data) -> Eina_Bool
+                       {
+                               const auto self = static_cast<Timeout *>(data);
+                               self->m_timer = nullptr;
+                               if (self->m_handler) {
+                                       self->m_handler(self);
+                               }
+                               return ECORE_CALLBACK_CANCEL;
+                       },
+                       this);
+
+               if (!m_timer) {
+                       FAIL_RETURN(RES_FAIL, "ecore_timer_add() failed!");
+               }
+
+               return RES_OK;
+       }
+
+       bool Timeout::isExpired() const
+       {
+               return !m_timer;
+       }
+}
diff --git a/ucl/source/misc/Variant.cpp b/ucl/source/misc/Variant.cpp
new file mode 100644 (file)
index 0000000..8be8708
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * 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/misc/Variant.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       // Variant //
+
+       Variant::Variant(const char *const aString, const int length) :
+               m_type(aString ? TYPE_STRING : TYPE_NIL)
+       {
+               if (aString) {
+                       const size_t realLength = ((length < 0) ? strlen(aString) : length);
+                       if (realLength < sizeof(m_aSmallStr.buffer)) {
+                               strncpy(m_aSmallStr.buffer, aString, realLength);
+                               m_aSmallStr.buffer[realLength] = '\0';
+                               m_type |= impl::FLAG_SMALL_STR;
+                       } else {
+                               m_aString.data = strndup(aString, realLength);
+                               m_aString.length = realLength;
+                       }
+               }
+       }
+
+       Variant::Variant(std::nullptr_t, const int arrayLength) :
+               m_type(static_cast<int>((arrayLength > 0) ? TYPE_ARRAY : TYPE_NIL))
+       {
+               if (arrayLength > 0) {
+                       m_anArray.data = new Variant[arrayLength];
+                       m_anArray.length = arrayLength;
+               }
+       }
+
+       Variant::Variant(const Variant *const anArray, const int length) :
+               Variant(nullptr, length)
+       {
+               if (length > 0) {
+                       std::copy(anArray, (anArray + length), m_anArray.data);
+               }
+       }
+
+       Variant::Variant(const Variant &v) :
+               m_type(v.m_type)
+       {
+               switch (m_type) {
+               case TYPE_NIL:
+                       break;
+               case TYPE_STRING:
+                       m_aString.data = strndup(v.m_aString.data, v.m_aString.length);
+                       m_aString.length = v.m_aString.length;
+                       break;
+               case TYPE_ARRAY:
+                       m_anArray.data = new Variant[v.m_anArray.length];
+                       std::copy(v.m_anArray.data, (v.m_anArray.data + v.m_anArray.length),
+                                       m_anArray.data);
+                       m_anArray.length = v.m_anArray.length;
+                       break;
+               default:
+                       m_raw = v.m_raw;
+                       break;
+               }
+       }
+
+       bool Variant::asBool() const noexcept
+       {
+               switch (m_type) {
+               case TYPE_BOOLEAN:
+                       return m_aBool.value;
+               case TYPE_INTEGER:
+                       return (m_anInt.value != 0);
+               case TYPE_FLOAT:
+                       return (m_aFloat.value != 0.0f);
+               case TYPE_DOUBLE:
+                       return (m_aDouble.value != 0.0);
+               case TYPE_STRING:
+               case impl::TYPE_SMALL_STR:
+                       {
+                               const auto str = getStr();
+                               return (strcasecmp(str, "true") == 0)
+                                       || (strcasecmp(str, "yes") == 0)
+                                       || (strcasecmp(str, "ok") == 0)
+                                       || (strcasecmp(str, "on") == 0)
+                                       || (strcasecmp(str, "1") == 0);
+                       }
+               case TYPE_ARRAY:
+                       return (m_anArray.length != 0);
+               }
+               return false;
+       }
+
+       int Variant::asInt() const noexcept
+       {
+               switch (m_type) {
+               case TYPE_BOOLEAN:
+                       return static_cast<int>(m_aBool.value);
+               case TYPE_INTEGER:
+                       return m_anInt.value;
+               case TYPE_FLOAT:
+                       return static_cast<int>(m_aFloat.value);
+               case TYPE_DOUBLE:
+                       return static_cast<int>(m_aDouble.value);
+               case TYPE_STRING:
+               case impl::TYPE_SMALL_STR:
+                       return std::atoi(getStr());
+               case TYPE_ARRAY:
+                       return m_anArray.length;
+               }
+               return 0;
+       }
+
+       float Variant::asFloat() const noexcept
+       {
+               switch (m_type) {
+               case TYPE_BOOLEAN:
+                       return static_cast<float>(m_aBool.value);
+               case TYPE_INTEGER:
+                       return static_cast<float>(m_anInt.value);
+               case TYPE_FLOAT:
+                       return m_aFloat.value;
+               case TYPE_DOUBLE:
+                       return static_cast<float>(m_aDouble.value);
+               case TYPE_STRING:
+               case impl::TYPE_SMALL_STR:
+                       return static_cast<float>(std::atof(getStr()));
+               case TYPE_ARRAY:
+                       return static_cast<float>(m_anArray.length);
+               }
+               return 0.0f;
+       }
+
+       double Variant::asDouble() const noexcept
+       {
+               switch (m_type) {
+               case TYPE_BOOLEAN:
+                       return static_cast<double>(m_aBool.value);
+               case TYPE_INTEGER:
+                       return static_cast<double>(m_anInt.value);
+               case TYPE_FLOAT:
+                       return static_cast<double>(m_aFloat.value);
+               case TYPE_DOUBLE:
+                       return m_aDouble.value;
+               case TYPE_STRING:
+               case impl::TYPE_SMALL_STR:
+                       return std::atof(getStr());
+               case TYPE_ARRAY:
+                       return static_cast<double>(m_anArray.length);
+               }
+               return 0.0;
+       }
+
+       ConstCString Variant::asString() const noexcept
+       {
+               char strBuff[impl::TMP_STR_BUFF_SIZE] = {};
+               switch (m_type) {
+               case TYPE_NIL:
+                       return ConstCString::wrap("");
+               case TYPE_BOOLEAN:
+                       return ConstCString::wrap(m_aBool.value ? "true" : "false");
+               case TYPE_INTEGER:
+                       snprintf(strBuff, sizeof(strBuff), "%d", m_anInt.value);
+                       break;
+               case TYPE_FLOAT:
+                       snprintf(strBuff, sizeof(strBuff), "%f",
+                                       static_cast<double>(m_aFloat.value));
+                       break;
+               case TYPE_DOUBLE:
+                       snprintf(strBuff, sizeof(strBuff), "%f", m_aDouble.value);
+                       break;
+               case impl::TYPE_SMALL_STR:
+                       return ConstCString::wrap(m_aSmallStr.buffer);
+               case TYPE_STRING:
+                       return ConstCString::wrap(m_aString.data);
+               case TYPE_ARRAY:
+                       snprintf(strBuff, sizeof(strBuff), "%d", m_anArray.length);
+                       break;
+               }
+               return CString::dup(strBuff);
+       }
+
+       // Non-member functions //
+
+       bool operator==(const Variant &lhs, const Variant &rhs) noexcept
+       {
+               if (lhs.m_type != rhs.m_type) {
+                       return false;
+               }
+               switch (lhs.m_type) {
+               case Variant::TYPE_BOOLEAN:
+                       return (lhs.m_aBool.value == rhs.m_aBool.value);
+               case Variant::TYPE_INTEGER:
+                       return (lhs.m_anInt.value == rhs.m_anInt.value);
+               case Variant::TYPE_FLOAT:
+                       return (lhs.m_aFloat.value == rhs.m_aFloat.value);
+               case Variant::TYPE_DOUBLE:
+                       return (lhs.m_aDouble.value == rhs.m_aDouble.value);
+               case Variant::TYPE_STRING:
+               case impl::TYPE_SMALL_STR:
+                       return (strcmp(lhs.getStr(), rhs.getStr()) == 0);
+               case Variant::TYPE_ARRAY:
+                       if (lhs.m_anArray.length != rhs.m_anArray.length) {
+                               return false;
+                       }
+                       for (int i = 0; i < lhs.m_anArray.length; ++i) {
+                               if (lhs.m_anArray.data[i] != rhs.m_anArray.data[i]) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+               return true;
+       }
+}
diff --git a/ucl/source/misc/common.h b/ucl/source/misc/common.h
new file mode 100644 (file)
index 0000000..fd9d17e
--- /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_SOURCE_MISC_COMMON_H__
+#define __UCL_SOURCE_MISC_COMMON_H__
+
+#include "ucl/source/common.h"
+
+#endif // __UCL_SOURCE_MISC_COMMON_H__
diff --git a/ucl/source/mvp/GuiPresenter.cpp b/ucl/source/mvp/GuiPresenter.cpp
new file mode 100644 (file)
index 0000000..e23bc02
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * 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/mvp/GuiPresenter.h"
+
+#include "common.h"
+
+namespace ucl { namespace { namespace impl {
+
+       constexpr SmartEvent ACTIVATE_BY {"ucl,activate,by"};
+       constexpr SmartEvent DEACTIVATE_BY {"ucl,deactivate,by"};
+}}}
+
+namespace ucl {
+
+       GuiPresenter::GuiPresenter(IRefCountObj &rc) :
+               RefCountAware(&rc),
+               m_hasBuildInSources(false),
+               m_isChild(false),
+               m_isPrepared(false)
+       {
+       }
+
+       GuiPresenter::~GuiPresenter()
+       {
+               if (m_hasBuildInSources) {
+                       if (m_isChild) {
+                               if (const auto parentSink = m_parentSink.lock()) {
+                                       delDeactivatorSource(*parentSink);
+                               }
+                       } else if (m_window) {
+                               delDeactivatorSource(*m_window);
+                       }
+               }
+       }
+
+       Result GuiPresenter::prepare(ElmWidget &widget, const int flags)
+       {
+               m_window = asShared(widget.getWindow());
+               if (!m_window) {
+                       LOG_RETURN(RES_FAIL, "m_window is NULL!");
+               }
+
+               if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
+                       addDeactivatorSource(*m_window);
+                       m_hasBuildInSources = true;
+               }
+
+               if (flags & PF_ADD_SELF_EXCEPT) {
+                       addDeactivatorException(getObjPtr());
+               }
+
+               m_isPrepared = true;
+
+               return RES_OK;
+       }
+
+       Result GuiPresenter::prepare(GuiPresenter &parent, const int flags)
+       {
+               if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
+
+                       if (!parent.m_sink) {
+                               LOG_RETURN(RES_FAIL, "parent.m_sink is NULL!");
+                       }
+
+                       for (auto deactivator: parent.m_deactivators) {
+                               if (m_deactivatorExceptions.find(deactivator) ==
+                                               m_deactivatorExceptions.end()) {
+                                       m_deactivators.insert(deactivator);
+                               }
+                       }
+
+                       addDeactivatorSource(*parent.m_sink);
+                       m_parentSink = parent.m_sink;
+                       m_hasBuildInSources = true;
+               }
+
+               if (flags & PF_ADD_SELF_EXCEPT) {
+                       addDeactivatorException(getObjPtr());
+               }
+
+               m_window = parent.m_window;
+               m_isChild = true;
+               m_isPrepared = true;
+
+               return RES_OK;
+       }
+
+       Window &GuiPresenter::getWindow()
+       {
+               UCL_ASSERT(isWindowReady(), "m_window is NULL!");
+               return *m_window;
+       }
+
+       bool GuiPresenter::isWindowReady() const
+       {
+               return !!m_window;
+       }
+
+       void GuiPresenter::addDeactivatorException(const void *const deactivator)
+       {
+               const auto pair = m_deactivatorExceptions.insert(deactivator);
+               if (pair.second) {
+                       activateBy(deactivator);
+               }
+       }
+
+       void GuiPresenter::setDeactivatorSink(const WidgetSRef &sink)
+       {
+               m_sink = sink;
+       }
+
+       void GuiPresenter::sendActivate(Widget &sender)
+       {
+               sendDeactivator(sender, impl::ACTIVATE_BY, getObjPtr());
+       }
+
+       void GuiPresenter::sendDeactivate(Widget &sender)
+       {
+               sendDeactivator(sender, impl::DEACTIVATE_BY, getObjPtr());
+       }
+
+       void GuiPresenter::broadcastActivate()
+       {
+               broadcastDeactivator(impl::ACTIVATE_BY, getObjPtr());
+       }
+
+       void GuiPresenter::broadcastDeactivate()
+       {
+               broadcastDeactivator(impl::DEACTIVATE_BY, getObjPtr());
+       }
+
+       void GuiPresenter::sendDeactivator(Widget &sender,
+                       SmartEvent event, const void *deactivator)
+       {
+               sendDeactivatorInfo(sender, event, {deactivator, false});
+       }
+
+       void GuiPresenter::broadcastDeactivator(const SmartEvent event,
+                       const void *const deactivator)
+       {
+               sendDeactivatorInfo(*m_window, event, {deactivator, true});
+       }
+
+       void GuiPresenter::sendDeactivatorInfo(Widget &sender,
+                       const SmartEvent event, const DeactivatorInfo &info)
+       {
+               sender.callEvent(event, const_cast<DeactivatorInfo *>(&info));
+       }
+
+       bool GuiPresenter::isActive() const
+       {
+               return isEmpty(m_deactivators);
+       }
+
+       bool GuiPresenter::isDeactivatedBy(const void *const deactivator) const
+       {
+               return (m_deactivators.find(deactivator) != m_deactivators.end());
+       }
+
+       void GuiPresenter::activateBy(const void *const deactivator)
+       {
+               activateByImpl({deactivator, false});
+       }
+
+       void GuiPresenter::deactivateBy(const void *const deactivator)
+       {
+               deactivateByImpl({deactivator, false});
+       }
+
+       void GuiPresenter::addDeactivatorSource(Widget &source)
+       {
+               source.addEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onActivateBySmart, asWeak(*this)));
+               source.addEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onDeactivateBySmart, asWeak(*this)));
+       }
+
+       void GuiPresenter::delDeactivatorSource(Widget &source)
+       {
+               source.delEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onActivateBySmart, asWeak(*this)));
+               source.delEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onDeactivateBySmart, asWeak(*this)));
+       }
+
+       void GuiPresenter::activateByImpl(const DeactivatorInfo &info)
+       {
+               const auto count = m_deactivators.erase(info.deactivator);
+               if (m_isPrepared && (count > 0)) {
+                       if (m_sink) {
+                               sendDeactivatorInfo(*m_sink, impl::ACTIVATE_BY, info);
+                       }
+                       onActivateBy(info);
+                       if (m_deactivators.size() == 0) {
+                               onActivate();
+                       }
+               }
+       }
+
+       void GuiPresenter::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) {
+                       if (m_sink) {
+                               sendDeactivatorInfo(*m_sink, impl::DEACTIVATE_BY, info);
+                       }
+                       onDeactivateBy(info);
+                       if (m_deactivators.size() == 1) {
+                               onDeactivate();
+                       }
+               }
+       }
+
+       void GuiPresenter::onActivateBySmart(Widget &widget, void *eventInfo)
+       {
+               activateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
+       }
+
+       void GuiPresenter::onDeactivateBySmart(Widget &widget, void *eventInfo)
+       {
+               deactivateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
+       }
+
+       void GuiPresenter::onActivate()
+       {
+       }
+
+       void GuiPresenter::onDeactivate()
+       {
+       }
+
+       void GuiPresenter::onActivateBy(const DeactivatorInfo &info)
+       {
+       }
+
+       void GuiPresenter::onDeactivateBy(const DeactivatorInfo &info)
+       {
+       }
+}
diff --git a/ucl/source/mvp/ListItemPresenter.cpp b/ucl/source/mvp/ListItemPresenter.cpp
new file mode 100644 (file)
index 0000000..d27568b
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * 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/mvp/ListItemPresenter.h"
+
+#include "common.h"
+
+namespace ucl {
+
+       // ListItemPresenter::ItemClass //
+
+       ListItemPresenter::ItemClassSRef ListItemPresenter::ItemClass::
+                       newInstance(const ElmStyle itemStyle)
+       {
+               auto result = makeShared<ItemClass>(itemStyle);
+               if (!result->get()) {
+                       LOG_RETURN_VALUE(RES_FAIL, {}, "Failed to create ItemClass()!");
+               }
+               return result;
+       }
+
+       ListItemPresenter::ItemClass::ItemClass(const ElmStyle itemStyle) :
+               m_itc(elm_genlist_item_class_new())
+       {
+               if (!m_itc) {
+                       return;
+               }
+
+               m_itc->item_style = itemStyle.name;
+
+               m_itc->func.text_get =
+                       [](void *data, Evas_Object *obj, const char *part) -> char *
+                       {
+                               if (!data) {
+                                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
+                               }
+                               return static_cast<ListItemPresenter *>(data)->
+                                               getItemPartText(EdjePart(part)).release();
+                       };
+
+               m_itc->func.content_get =
+                       [](void *data, Evas_Object *obj, const char *part) -> Evas_Object *
+                       {
+                               if (!data) {
+                                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
+                               }
+                               auto &&item = *static_cast<ListItemPresenter *>(data);
+                               if (const auto widget = item.getItemPartContent(
+                                               EdjePart(part), *item.m_parent)) {
+                                       widget->setIsOwner(false);
+                                       return widget->getEo();
+                               }
+                               return nullptr;
+                       };
+
+               m_itc->func.state_get =
+                       [](void *data, Evas_Object *obj, const char *part) -> Eina_Bool
+                       {
+                               if (!data) {
+                                       LOG_RETURN_VALUE(RES_FATAL, false, "data is NULL");
+                               }
+                               return static_cast<ListItemPresenter *>(data)->
+                                               getItemPartState(EdjePart(part));
+                       };
+       }
+
+       ListItemPresenter::ItemClass::~ItemClass()
+       {
+               if (m_itc) {
+                       elm_genlist_item_class_free(m_itc);
+               }
+       }
+
+       Elm_Genlist_Item_Class *ListItemPresenter::ItemClass::get()
+       {
+               return m_itc;
+       }
+
+       // ListItemPresenter::ItemClassCache //
+
+       ListItemPresenter::ItemClassSRef ListItemPresenter::ItemClassCache::
+                       getItemClass(const ElmStyle itemStyle)
+       {
+               ItemClassSRef result;
+
+               if (!m_itcMap.get(itemStyle, result)) {
+                       result = ItemClass::newInstance(itemStyle);
+                       if (result) {
+                               m_itcMap.set(itemStyle, result);
+                       } else {
+                               ELOG("ItemClass::newInstance() failed!");
+                       }
+               }
+
+               return result;
+       }
+
+       void ListItemPresenter::ItemClassCache::purge()
+       {
+               m_itcMap.clear();
+       }
+
+       // ListItemPresenter //
+
+       ListItemPresenter::ListItemPresenter(IRefCountObj &rc) :
+               RefCountAware(&rc),
+               m_flags(PF_AUTO_UNSELECT)
+       {
+       }
+
+       ListItemPresenter::~ListItemPresenter()
+       {
+               if (m_item) {
+                       FLOG("m_item is still alive!");
+                       deleteDetachedItem(true);
+               }
+       }
+
+       void ListItemPresenter::attachItem(GenlistItem item, ElmWidgetSRef &&parent,
+                       const ItemClassCacheSRef &itcCache,
+                       const SharedRef<bool> &isActiveRef)
+       {
+               if (m_item) {
+                       deleteDetachedItem();
+               }
+
+               m_item = item;
+               m_item.setData(this);
+               m_item.setDelCallback(CALLBACK_A(ListItemPresenter::onItemDel));
+
+               m_parent = std::move(parent);
+
+               m_itcCache = itcCache;
+               m_isActiveRef = isActiveRef;
+
+               if (!m_selfRef) {
+                       m_selfRef = asShared(*this);
+               }
+
+               onItemAttached();
+       }
+
+       void ListItemPresenter::deleteDetachedItem(const bool silent)
+       {
+               auto item = m_item;
+               detachItem(silent);
+               item.del();
+       }
+
+       void ListItemPresenter::detachItem(const bool silent)
+       {
+               m_item.setData(nullptr);
+               m_item.setDelCallback(nullptr);
+               m_item = nullptr;
+
+               m_parent.reset();
+               m_itcCache.reset();
+               m_isActiveRef.reset();
+
+               if (!silent) {
+                       onItemDetached();
+               }
+       }
+
+       void ListItemPresenter::onItemDel(Evas_Object *obj, void *eventInfo)
+       {
+               if (m_item) {
+                       detachItem();
+               }
+               m_selfRef.reset();
+       }
+
+       void ListItemPresenter::setFlags(const int flags)
+       {
+               m_flags = flags;
+       }
+
+       int ListItemPresenter::getFlags() const
+       {
+               return m_flags;
+       }
+
+       bool ListItemPresenter::isActive() const
+       {
+               return (m_isActiveRef ? *m_isActiveRef : false);
+       }
+
+       GenlistItem ListItemPresenter::getItem()
+       {
+               return m_item;
+       }
+
+       ListItemPresenter::ItemClassCache *ListItemPresenter::getItemClassCache()
+       {
+               return m_itcCache.get();
+       }
+
+       Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle)
+       {
+               if (!m_item) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "m_item is NULL!");
+               }
+               if (!m_itcCache) {
+                       LOG_RETURN(RES_FATAL, "m_itcCache is NULL!");
+               }
+
+               const auto itc = m_itcCache->getItemClass(newItemStyle);
+               if (!itc) {
+                       LOG_RETURN(RES_FAIL, "m_itcCache->getItemClass() failed!");
+               }
+
+               m_item.update(itc->get());
+
+               return RES_OK;
+       }
+
+       void ListItemPresenter::dispose()
+       {
+               if (m_item) {
+                       deleteDetachedItem();
+                       m_selfRef.reset();
+               }
+       }
+
+       bool ListItemPresenter::isDisposed() const
+       {
+               return !m_item;
+       }
+
+       void ListItemPresenter::onItemAttached()
+       {
+       }
+
+       void ListItemPresenter::onItemDetached()
+       {
+       }
+
+       WidgetSRef ListItemPresenter::getItemPartContent(const EdjePart part,
+                       ElmWidget &parent)
+       {
+               return nullptr;
+       }
+
+       CString ListItemPresenter::getItemPartText(const EdjePart part)
+       {
+               return nullptr;
+       }
+
+       bool ListItemPresenter::getItemPartState(const EdjePart part)
+       {
+               return false;
+       }
+
+       void ListItemPresenter::onItemSelectedHook()
+       {
+               if (m_flags & PF_AUTO_UNSELECT) {
+                       m_item.setSelected(false);
+               }
+               onItemSelected();
+       }
+
+       void ListItemPresenter::onItemSelected()
+       {
+       }
+
+       void ListItemPresenter::onItemRealized()
+       {
+       }
+
+       void ListItemPresenter::onItemUnrealized()
+       {
+       }
+
+       void ListItemPresenter::onItemHighlighted()
+       {
+       }
+
+       void ListItemPresenter::onItemUnhighlighted()
+       {
+       }
+}
diff --git a/ucl/source/mvp/ListPresenter.cpp b/ucl/source/mvp/ListPresenter.cpp
new file mode 100644 (file)
index 0000000..2835697
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ * 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/mvp/ListPresenter.h"
+
+#include "common.h"
+
+namespace ucl { namespace { namespace impl {
+
+       constexpr SmartEvent ITEM_SELECTED {"selected"};
+
+       constexpr SmartEvent ITEM_REALIZED {"realized"};
+       constexpr SmartEvent ITEM_UNREALIZED {"unrealized"};
+       constexpr SmartEvent ITEM_HIGHLIGHTED {"highlighted"};
+       constexpr SmartEvent ITEM_UNHIGHLIGHTED {"unhighlighted"};
+
+       ListItemPresenter *toItemPresenter(void *eventInfo)
+       {
+               if (!eventInfo) {
+                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "eventInfo is NULL");
+               }
+
+               const GenlistItem item{static_cast<Elm_Object_Item *>(eventInfo)};
+               const auto data = item.getData();
+               if (!data) {
+                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
+               }
+
+               return static_cast<ListItemPresenter *>(data);
+       }
+}}}
+
+namespace ucl {
+
+       // ListPresenter::Builder //
+
+       ListPresenter::Builder::Builder() :
+               m_flags(FLAG_HOMOGENEOUS)
+       {
+       }
+
+       ListPresenter::Builder &ListPresenter::Builder::setStyle(
+                       const ElmStyle style)
+       {
+               m_style = style;
+               return *this;
+       }
+
+       ListPresenter::Builder &ListPresenter::Builder::setFlags(const int flags)
+       {
+               m_flags = flags;
+               return *this;
+       }
+
+       ListPresenter::Builder &ListPresenter::Builder::setParentWidget(
+                       const ElmWidgetSRef &parentWidget)
+       {
+               m_parentWidget = parentWidget;
+               return *this;
+       }
+
+       ListPresenterSRef ListPresenter::Builder::build(GuiPresenter &parent) const
+       {
+               if (!m_parentWidget) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+                                       "m_parentWidget is NULL!");
+               }
+
+               auto result = makeShared<ListPresenter>();
+
+               FAIL_RETURN_VALUE(result->prepare(
+                               parent, *m_parentWidget, m_style, m_flags),
+                               {}, "result->prepare() failed!");
+
+               return result;
+       }
+
+       // ListPresenter //
+
+       ListPresenter::ListPresenter(IRefCountObj &rc) :
+                       GuiPresenter(rc)
+       {
+       }
+
+       ListPresenter::~ListPresenter()
+       {
+               if (m_genlist) {
+                       m_genlist->clear();
+               }
+       }
+
+       Result ListPresenter::prepare(
+                       GuiPresenter &parent, ElmWidget &parentWidget,
+                       const ElmStyle style, const int flags)
+       {
+               FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+                               "GuiPresenter::prepare() failed!");
+
+               m_genlist = Genlist::Builder().
+                               setStyle(style).
+                               setMode(Genlist::Mode::COMPRESS).
+                               setHomogeneous(flags & FLAG_HOMOGENEOUS).
+                               setNeedBindToEo(true).
+                               build(parentWidget);
+               if (!m_genlist) {
+                       LOG_RETURN(RES_FAIL, "Genlist::build() failed!");
+               }
+
+               expandAndFill(*m_genlist);
+
+               // TODO Add Scroller widget.
+               elm_scroller_content_min_limit(*m_genlist,
+                               toEina((flags & FLAG_CALC_X_MIN) != 0),
+                               toEina((flags & FLAG_CALC_Y_MIN) != 0));
+
+               m_itcCache = makeShared<ListItemPresenter::ItemClassCache>();
+
+               m_isActiveRef = makeShared<bool>();
+               *m_isActiveRef = isActive();
+
+               m_genlist->addEventHandler(impl::ITEM_SELECTED, WEAK_DELEGATE(
+                               ListPresenter::onItemSelected, asWeak(*this)));
+
+               if (flags & FLAG_NOTIFY_REALIZED) {
+                       m_genlist->addEventHandler(impl::ITEM_REALIZED, WEAK_DELEGATE(
+                                       ListPresenter::onItemRealized, asWeak(*this)));
+               }
+               if (flags & FLAG_NOTIFY_UNREALIZED) {
+                       m_genlist->addEventHandler(impl::ITEM_UNREALIZED, WEAK_DELEGATE(
+                                       ListPresenter::onItemUnrealized, asWeak(*this)));
+               }
+               if (flags & FLAG_NOTIFY_HIGHLIGHTED) {
+                       m_genlist->addEventHandler(impl::ITEM_HIGHLIGHTED, WEAK_DELEGATE(
+                                       ListPresenter::onItemHighlighted, asWeak(*this)));
+               }
+               if (flags & FLAG_NOTIFY_UNHIGHLIGHTED) {
+                       m_genlist->addEventHandler(impl::ITEM_UNHIGHLIGHTED, WEAK_DELEGATE(
+                                       ListPresenter::onItemUnhighlighted, asWeak(*this)));
+               }
+
+               return RES_OK;
+       }
+
+       Genlist &ListPresenter::getWidget()
+       {
+               return *m_genlist;
+       }
+
+       void ListPresenter::clear()
+       {
+               m_genlist->clear();
+               m_itcCache->purge();
+       }
+
+       Result ListPresenter::append(ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent)
+       {
+               return insert(itemPresenter, parent,
+                       [this](const Elm_Genlist_Item_Class *itc, const void *data,
+                                       GenlistItem parent, GenlistItem::Type type)
+                       {
+                               return m_genlist->append(itc, data, nullptr, type, parent);
+                       });
+       }
+
+       Result ListPresenter::prepend(ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent)
+       {
+               return insert(itemPresenter, parent,
+                       [this](const Elm_Genlist_Item_Class *itc, const void *data,
+                                       GenlistItem parent, GenlistItem::Type type)
+                       {
+                               return m_genlist->prepend(itc, data, nullptr, type, parent);
+                       });
+       }
+
+       Result ListPresenter::insertAfter(const ListItemPresenter &after,
+                       ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent)
+       {
+               return insertRelative(after, itemPresenter, parent,
+                       [this](GenlistItem rel, const Elm_Genlist_Item_Class *itc,
+                               const void *data, GenlistItem parent, GenlistItem::Type type)
+                       {
+                               return m_genlist->insertAfter(
+                                               rel, itc, data, nullptr, type, parent);
+                       });
+       }
+
+       Result ListPresenter::insertBefore(const ListItemPresenter &before,
+                       ListItemPresenter &itemPresenter,
+                               ListItemPresenter *parent)
+       {
+               return insertRelative(before, itemPresenter, parent,
+                       [this](GenlistItem rel, const Elm_Genlist_Item_Class *itc,
+                               const void *data, GenlistItem parent, GenlistItem::Type type)
+                       {
+                               return m_genlist->insertBefore(
+                                               rel, itc, data, nullptr, type, parent);
+                       });
+       }
+
+       template <class INSERT_FUNC>
+       Result ListPresenter::insert(ListItemPresenter &itemPresenter,
+                       ListItemPresenter *parent, INSERT_FUNC &&insertFunc)
+       {
+               const auto params = itemPresenter.getItemInsertionParams();
+
+               const auto itc = m_itcCache->getItemClass(params.itemStyle);
+               if (!itc) {
+                       LOG_RETURN(RES_FAIL, "m_itcCache.getItemClass() failed!");
+               }
+
+               GenlistItem parentItem;
+               if (parent) {
+                       parentItem = parent->m_item;
+                       if (!parentItem) {
+                               ELOG("parentItem is NULL");
+                       }
+               }
+
+               const auto item = insertFunc(itc->get(),
+                               &itemPresenter, parentItem, params.itemType);
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "insertFunc() failed!");
+               }
+
+               itemPresenter.attachItem(item, m_genlist, m_itcCache, m_isActiveRef);
+
+               return RES_OK;
+       }
+
+       template <class INSERT_FUNC>
+       Result ListPresenter::insertRelative(const ListItemPresenter &relative,
+                       ListItemPresenter &itemPresenter, ListItemPresenter *parent,
+                       INSERT_FUNC &&insertFunc)
+       {
+               const auto relItem = relative.m_item;
+               if (!relItem) {
+                       LOG_RETURN(RES_FAIL, "relItem is NULL!");
+               }
+               if (relItem.getWidget() != m_genlist->getEo()) {
+                       LOG_RETURN(RES_FAIL, "relItem has wrong genlist!");
+               }
+               return insert(itemPresenter, parent,
+                       [relItem, &insertFunc](const Elm_Genlist_Item_Class *itc,
+                               const void *data, GenlistItem parent, GenlistItem::Type type)
+                       {
+                               return insertFunc(relItem, itc, data, parent, type);
+                       });
+       }
+
+       void ListPresenter::setIsActiveRef(const bool value)
+       {
+               if (!m_isActiveRef) {
+                       LOG_RETURN_VOID(RES_FATAL, "m_isActiveRef is NULL");
+               }
+               *m_isActiveRef = value;
+       }
+
+       void ListPresenter::onItemSelected(Widget &widget, void *eventInfo)
+       {
+               const auto itemPresenter = impl::toItemPresenter(eventInfo);
+               if (!itemPresenter) {
+                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+               }
+               itemPresenter->onItemSelectedHook();
+       }
+
+       void ListPresenter::onItemRealized(Widget &widget, void *eventInfo)
+       {
+               const auto itemPresenter = impl::toItemPresenter(eventInfo);
+               if (!itemPresenter) {
+                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+               }
+               itemPresenter->onItemRealized();
+       }
+
+       void ListPresenter::onItemUnrealized(Widget &widget, void *eventInfo)
+       {
+               const auto itemPresenter = impl::toItemPresenter(eventInfo);
+               if (!itemPresenter) {
+                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+               }
+               itemPresenter->onItemUnrealized();
+       }
+
+       void ListPresenter::onItemHighlighted(Widget &widget, void *eventInfo)
+       {
+               const auto itemPresenter = impl::toItemPresenter(eventInfo);
+               if (!itemPresenter) {
+                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+               }
+               itemPresenter->onItemHighlighted();
+       }
+
+       void ListPresenter::onItemUnhighlighted(Widget &widget, void *eventInfo)
+       {
+               const auto itemPresenter = impl::toItemPresenter(eventInfo);
+               if (!itemPresenter) {
+                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+               }
+               itemPresenter->onItemUnhighlighted();
+       }
+
+       void ListPresenter::onActivate()
+       {
+               setIsActiveRef(true);
+       }
+
+       void ListPresenter::onDeactivate()
+       {
+               setIsActiveRef(false);
+       }
+}
diff --git a/ucl/source/mvp/common.h b/ucl/source/mvp/common.h
new file mode 100644 (file)
index 0000000..11a4d84
--- /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_SOURCE_MVP_COMMON_H__
+#define __UCL_SOURCE_MVP_COMMON_H__
+
+#include "ucl/source/common.h"
+
+#endif // __UCL_SOURCE_MVP_COMMON_H__
diff --git a/ucl/source/util/logging.cpp b/ucl/source/util/logging.cpp
new file mode 100644 (file)
index 0000000..311f25b
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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"
+
+#if (UCL_DEFINE_GET_UCL_RESULT_DATA)
+#include "ucl/util/types/Result.h"
+
+ucl::ResultData getUCLResultData(const ucl::Result result)
+{
+       return ucl::getResultData(result);
+}
+#endif
diff --git a/ucl/source/util/types/Result.cpp b/ucl/source/util/types/Result.cpp
new file mode 100644 (file)
index 0000000..b42875e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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/types/Result.h"
+
+#include "ucl/util/logging.h"
+
+namespace ucl { namespace { namespace impl {
+
+       constexpr ResultData RESUT_DATA[] = {
+               {"RES_FATAL",             DLOG_FATAL},
+               {"RES_INVALID_DATA",      DLOG_ERROR},
+               {"RES_NOT_SUPPORTED",     DLOG_ERROR},
+               {"RES_IO_ERROR",          DLOG_ERROR},
+               {"RES_OUT_OF_MEMORY",     DLOG_ERROR},
+               {"RES_ILLEGAL_STATE",     DLOG_ERROR},
+               {"RES_INVALID_ARGUMENTS", DLOG_ERROR},
+               {"RES_FAIL",              DLOG_ERROR},
+               {"RES_OK",                DLOG_INFO},
+               {"RES_FALSE",             DLOG_INFO},
+               {"Unknown result value",  DLOG_ERROR},
+       };
+}}}
+
+namespace ucl {
+
+       const ResultData &getResultData(const Result result)
+       {
+               return impl::RESUT_DATA[
+                       ((result.value < _RES_BEGIN) || (result.value >= _RES_END)) ?
+                               _RES_END : (result.value - _RES_BEGIN)];
+       }
+}
diff --git a/ucl/src/appfw/InstanceManagerBase.cpp b/ucl/src/appfw/InstanceManagerBase.cpp
deleted file mode 100644 (file)
index 2e90b24..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/appfw/InstanceManagerBase.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       InstanceManagerBase::InstanceManagerBase(AppParams appParams) :
-               m_appParams(std::move(appParams))
-       {
-       }
-
-       InstanceManagerBase::~InstanceManagerBase()
-       {
-       }
-
-       const AppParams &InstanceManagerBase::getAppParams() const
-       {
-               return m_appParams;
-       }
-
-       void InstanceManagerBase::setSysEventProvider(SysEventProviderUPtr provider)
-       {
-               m_sysEventProvider = std::move(provider);
-       }
-
-       SysEventProvider &InstanceManagerBase::getSysEventProvider() const
-       {
-               UCL_ASSERT(m_sysEventProvider, "m_sysEventProvider is NULL!");
-               return *m_sysEventProvider;
-       }
-}
diff --git a/ucl/src/appfw/SysEventProvider.cpp b/ucl/src/appfw/SysEventProvider.cpp
deleted file mode 100644 (file)
index 8958aaf..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/appfw/SysEventProvider.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       // SysEventProvider::EventProxy //
-
-       class SysEventProvider::EventProxy : public NonCopyable {
-       public:
-               EventProxy(SysEventProvider &provider,
-                               const SysEvent sysEvent,
-                               const app_event_type_e appEvent):
-                       m_provider(provider),
-                       m_sysEvent(sysEvent)
-               {
-                       const int res = m_provider.addEventHandler(&m_eventHandler,
-                                       appEvent, CALLBACK_B(EventProxy::onAppEvent), this);
-                       if (res != APP_ERROR_NONE) {
-                               if (res != APP_ERROR_INVALID_PARAMETER) {
-                                       ELOG("addEventHandler() failed! %d", res);
-                               }
-                               m_eventHandler = nullptr;
-                       }
-               }
-
-               ~EventProxy()
-               {
-                       if (m_eventHandler) {
-                               const int res = m_provider.delEventHandler(m_eventHandler);
-                               if (res != APP_ERROR_NONE) {
-                                       WLOG("delEventHandler() failed! %d", res);
-                               }
-                       }
-               }
-
-       private:
-               void onAppEvent(app_event_info_h event)
-               {
-                       m_provider.dispatch(m_sysEvent);
-               }
-
-       private:
-               SysEventProvider &m_provider;
-               app_event_handler_h m_eventHandler;
-               SysEvent m_sysEvent;
-       };
-
-       // SysEventProvider //
-
-       SysEventProvider::SysEventProvider(EventHandlerAddFunc addFunc,
-                       EventHandlerDelFunc delFunc):
-               m_addFunc(addFunc),
-               m_delFunc(delFunc)
-       {
-               m_eventProxies.emplace_back(*this, SysEvent::LANGUAGE_CHANGED,
-                               APP_EVENT_LANGUAGE_CHANGED);
-
-               m_eventProxies.emplace_back(*this, SysEvent::REGION_FMT_CHANGED,
-                               APP_EVENT_REGION_FORMAT_CHANGED);
-
-               m_eventProxies.emplace_back(*this, SysEvent::LOW_MEMORY,
-                               APP_EVENT_LOW_MEMORY);
-
-               m_eventProxies.emplace_back(*this, SysEvent::LOW_BATTERY,
-                               APP_EVENT_LOW_BATTERY);
-
-               m_eventProxies.emplace_back(*this, SysEvent::ORIENTATION_CHANGED,
-                               APP_EVENT_DEVICE_ORIENTATION_CHANGED);
-
-               m_eventProxies.emplace_back(*this, SysEvent::SUSPEND_STATE_CHANGED,
-                               APP_EVENT_SUSPENDED_STATE_CHANGED);
-
-               m_eventProxies.emplace_back(*this, SysEvent::UPDATE_REQUESTED,
-                               APP_EVENT_UPDATE_REQUESTED);
-       }
-
-       SysEventProvider::~SysEventProvider()
-       {
-       }
-
-       int SysEventProvider::addEventHandler(app_event_handler_h *handler,
-                       app_event_type_e appEvent, app_event_cb cb, void *data)
-       {
-               return m_addFunc(handler, appEvent, cb, data);
-       }
-
-       int SysEventProvider::delEventHandler(app_event_handler_h handler)
-       {
-               return m_delFunc(handler);
-       }
-
-       void SysEventProvider::dispatch(SysEvent sysEvent)
-       {
-               m_event.dispatch(sysEvent);
-       }
-}
diff --git a/ucl/src/appfw/UIApp.cpp b/ucl/src/appfw/UIApp.cpp
deleted file mode 100644 (file)
index 6f49c2b..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/appfw/UIApp.h"
-
-#include <app.h>
-
-#include "ucl/appfw/IInstanceAppControlExt.h"
-#include "common.h"
-
-namespace ucl {
-
-       UIApp::UIApp(InstanceManagerBase &instanceMgr) :
-               m_instanceMgr(instanceMgr)
-       {
-       }
-
-       UIApp::~UIApp()
-       {
-       }
-
-       int UIApp::run(int argc, char *argv[])
-       {
-               ui_app_lifecycle_callback_s alcc = {};
-               alcc.create = CALLBACK_B(UIApp::onCreate);
-               alcc.terminate = CALLBACK_B(UIApp::onTerminate);
-               alcc.pause = CALLBACK_B(UIApp::onPause);
-               alcc.resume = CALLBACK_B(UIApp::onResume);
-               alcc.app_control = CALLBACK_B(UIApp::onAppControl);
-
-               const int ret = ui_app_main(argc, argv, &alcc, this);
-               if (ret != APP_ERROR_NONE) {
-                       LOG_RETURN_VALUE(RES_FAIL, ret, "ui_app_main() failed! %d", ret);
-               }
-
-               return 0;
-       }
-
-       AppType UIApp::getAppType() const
-       {
-               return AppType::UI;
-       }
-
-       WindowSRef UIApp::getWindow()
-       {
-               return m_window;
-       }
-
-       void UIApp::exitApp()
-       {
-               ui_app_exit();
-       }
-
-       bool UIApp::onCreate()
-       {
-               FAIL_RETURN_VALUE(configParams(), false, "configParams() failed!");
-
-               FAIL_RETURN_VALUE(createWindow(), false, "createWindow() failed!");
-
-               initSysEventManager();
-
-               FAIL_RETURN_VALUE(createInstance(), false, "createInstance() failed!");
-
-               return true;
-       }
-
-       void UIApp::onTerminate()
-       {
-               m_instance.reset();
-               m_instanceMgr.setSysEventProvider(nullptr);
-               m_window.reset();
-       }
-
-       void UIApp::onPause()
-       {
-               if (m_instance) {
-                       m_instance->onPause();
-               }
-       }
-
-       void UIApp::onResume()
-       {
-               if (m_instance) {
-                       m_instance->onResume();
-               }
-       }
-
-       void UIApp::onAppControl(app_control_h appControl)
-       {
-               auto instance = dynamic_cast<
-                               IInstanceAppControlExt *>(m_instance.get());
-               if (instance) {
-                       instance->onAppControl(appControl);
-               }
-       }
-
-       Result UIApp::configParams()
-       {
-               auto &&appParams = m_instanceMgr.getAppParams();
-
-               Variant paramValue;
-
-               if (appParams.get(AppParam::BASE_SCALE, paramValue)) {
-                       const double baseScale = paramValue.asDouble();
-                       if (baseScale <= 0.0) {
-                               LOG_RETURN(RES_INVALID_DATA,
-                                               "Invalid parameter BASE_SCALE: %f", baseScale);
-                       }
-                       elm_app_base_scale_set(baseScale);
-               }
-
-               if (appParams.get(AppParam::ACCELERATION_PREFERENECE, paramValue)) {
-                       const auto accelPreference = paramValue.asString();
-                       if (isEmpty(accelPreference)) {
-                               LOG_RETURN(RES_INVALID_DATA,
-                                               "Invalid parameter ACCELERATION_PREFERENECE: %s",
-                                               accelPreference.get());
-                       }
-                       elm_config_accel_preference_set(accelPreference.get());
-               }
-
-               return RES_OK;
-       }
-
-       Result UIApp::createWindow()
-       {
-               auto &&appParams = m_instanceMgr.getAppParams();
-
-               Variant paramValue;
-
-               auto winType = Window::Type::BASIC;
-               if (appParams.get(AppParam::WINDOW_TYPE, paramValue)) {
-                       winType = static_cast<Window::Type>(paramValue.asInt());
-                       if (isNotValid(winType)) {
-                               LOG_RETURN(RES_INVALID_DATA,
-                                               "Invalid parameter WINDOW_TYPE: %d", winType);
-                       }
-               }
-
-               paramValue = appParams.get(AppParam::WINDOW_NAME);
-               if (isEmpty(paramValue)) {
-                       LOG_RETURN(RES_INVALID_DATA, "WINDOW_NAME must not be empty!");
-               }
-
-               m_window = Window::Builder().
-                               setType(winType).
-                               setName(paramValue.asString().get()).
-                               build();
-               if (!m_window) {
-                       LOG_RETURN(RES_FAIL, "Window::Builder().build() Failed!");
-               }
-
-               return RES_OK;
-       }
-
-       void UIApp::initSysEventManager()
-       {
-               m_instanceMgr.setSysEventProvider(
-                               util::makeUnique(new SysEventProvider(
-                                       &ui_app_add_event_handler,
-                                       &ui_app_remove_event_handler)));
-       }
-
-       Result UIApp::createInstance()
-       {
-               auto instance = m_instanceMgr.newInstance();
-               if (!instance) {
-                       LOG_RETURN(RES_FAIL, "m_instanceMgr.newInstance() failed!");
-               }
-
-               const auto res = instance->onCreate(this);
-               if (isBad(res)) {
-                       LOG_RETURN(res, "instance->onCreate() failed!");
-               }
-
-               m_instance = std::move(instance);
-
-               return RES_OK;
-       }
-}
diff --git a/ucl/src/appfw/common.h b/ucl/src/appfw/common.h
deleted file mode 100644 (file)
index b612dfb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_APPFW_COMMON_H__
-#define __UCL_APPFW_COMMON_H__
-
-#include "../common.h"
-
-#endif // __UCL_APPFW_COMMON_H__
diff --git a/ucl/src/appfw/helpers.cpp b/ucl/src/appfw/helpers.cpp
deleted file mode 100644 (file)
index c547dce..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/appfw/helpers.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       std::string getResPath(const char *const relativePath)
-       {
-               std::string result;
-               char *const resDir = app_get_resource_path();
-               if (resDir) {
-                       result = resDir;
-                       free(resDir);
-               } else {
-                       ELOG("app_get_resource_path() failed!");
-               }
-               result += relativePath;
-               return result;
-       }
-}
diff --git a/ucl/src/common.h b/ucl/src/common.h
deleted file mode 100644 (file)
index f358669..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_COMMON_H__
-#define __UCL_COMMON_H__
-
-#include <cmath>
-#include <cstring>
-
-#include <algorithm>
-
-#include <Ecore.h>
-
-#include "ucl/util/types.h"
-#include "ucl/util/helpers.h"
-#include "ucl/util/logging.h"
-#include "ucl/util/shortLogs.h"
-
-#include "ucl/util/delegation/shortMacro.h"
-#include "ucl/util/smartDelegation/shortMacro.h"
-
-#endif // __UCL_COMMON_H__
diff --git a/ucl/src/gui/EdjeWidget.cpp b/ucl/src/gui/EdjeWidget.cpp
deleted file mode 100644 (file)
index 8d67596..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/EdjeWidget.h"
-
-namespace ucl {
-
-       void EdjeWidget::setText(const TString &value)
-       {
-               if (value.isTranslatable()) {
-                       if (value.hasDomain()) {
-                               elm_object_domain_translatable_text_set(
-                                               getEo(), value.getDomain(), value);
-                       } else {
-                               elm_object_translatable_text_set(getEo(), value);
-                       }
-               } else {
-                       elm_object_domain_text_translatable_set(getEo(),
-                                       nullptr, EINA_FALSE);
-                       elm_object_text_set(getEo(), value);
-               }
-       }
-
-       void EdjeWidget::setText(const TString &value, const EdjePart part)
-       {
-               if (value.isTranslatable()) {
-                       if (value.hasDomain()) {
-                               elm_object_domain_translatable_part_text_set(
-                                               getEo(), part.name, value.getDomain(), value);
-                       } else {
-                               elm_object_translatable_part_text_set(
-                                               getEo(), part.name, value);
-                       }
-               } else {
-                       elm_object_part_text_translatable_set(getEo(),
-                                       part.name, EINA_FALSE);
-                       elm_object_part_text_set(getEo(), part.name, value);
-               }
-       }
-}
diff --git a/ucl/src/gui/ElmWidget.cpp b/ucl/src/gui/ElmWidget.cpp
deleted file mode 100644 (file)
index b7d227e..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/ElmWidget.h"
-
-#include "ucl/gui/Window.h"
-#include "ucl/gui/helpers.h"
-
-namespace ucl {
-
-       ElmWidget::ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner) :
-               Widget(rc, eo, isOwner),
-               m_isAtspiGestureCbSet(false)
-       {
-       }
-
-       ElmWidget::~ElmWidget()
-       {
-               if (m_isAtspiGestureCbSet) {
-                       elm_atspi_accessible_gesture_cb_set(getEo(), nullptr, nullptr);
-               }
-       }
-
-       void ElmWidget::setFocusedImpl(const bool value)
-       {
-               elm_object_focus_set(getEo(), toEina(value));
-       }
-
-       bool ElmWidget::isFocusedImpl() const
-       {
-               return elm_object_focus_get(getEo());
-       }
-
-       bool ElmWidget::ensureFwdEvent(const SmartEvent fwdEvent)
-       {
-               if (Widget::ensureFwdEvent(fwdEvent)) {
-                       return true;
-               }
-               if (fwdEvent == ATSPI_ON_GESTURE) {
-                       if (!m_isAtspiGestureCbSet) {
-                               m_isAtspiGestureCbSet = true;
-                               elm_atspi_accessible_gesture_cb_set(getEo(),
-                                               CALLBACK_A(ElmWidget::onAtspiGesture), this);
-                       }
-                       return true;
-               }
-               return false;
-       }
-
-       Eina_Bool ElmWidget::onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
-                                       Evas_Object *obj)
-       {
-               AtspiGestureEventInfo eventInfo{gestureInfo};
-               callEvent(ATSPI_ON_GESTURE, &eventInfo);
-               return toEina(eventInfo.preventDefault);
-       }
-
-       Window *ElmWidget::getWindow() const
-       {
-               return dynamicWidgetCast<Window>(getTopWidget());
-       }
-}
diff --git a/ucl/src/gui/Genlist.cpp b/ucl/src/gui/Genlist.cpp
deleted file mode 100644 (file)
index b0e31a5..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "ucl/gui/Genlist.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       // Genlist::Builder //
-
-       GenlistSRef Genlist::Builder::build(ElmWidget &parent) const
-       {
-               Evas_Object *const eo = elm_genlist_add(parent);
-               if (!eo) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "elm_genlist_add() failed!");
-               }
-
-               auto result = makeShared<Genlist>(eo, m_isOwner);
-
-               if (m_needBindToEo) {
-                       result->bindToEo();
-               }
-
-               if (isValid(m_style)) {
-                       result->setStyle(m_style);
-               }
-
-               result->setMode(m_mode);
-               result->setHomogeneous(m_isHomogeneous);
-
-               show(*result);
-
-               return result;
-       }
-}
diff --git a/ucl/src/gui/Layout.cpp b/ucl/src/gui/Layout.cpp
deleted file mode 100644 (file)
index 1509fc5..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/Layout.h"
-
-#include "ucl/gui/stdTheme/layout.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       // Layout::Builder //
-
-       LayoutSRef Layout::Builder::build(ElmWidget &parent) const
-       {
-               Evas_Object *const eo = elm_layout_add(parent);
-               if (!eo) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "elm_layout_add() failed!");
-               }
-
-               auto result = makeShared<Layout>(eo, m_isOwner);
-
-               if (m_needBindToEo) {
-                       result->bindToEo();
-               }
-
-               bool isOk = true;
-
-               if (isNotEmpty(m_edjeFilePath) && isValid(m_edjeGroup)) {
-                       isOk = result->setEdjeFile(m_edjeFilePath, m_edjeGroup);
-               } else if (isValid(m_theme)) {
-                       isOk = result->setTheme(m_theme);
-               }
-
-               if (!isOk) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "Layout init failed!");
-               }
-
-               show(*result);
-
-               return result;
-       }
-}
diff --git a/ucl/src/gui/NaviItem.cpp b/ucl/src/gui/NaviItem.cpp
deleted file mode 100644 (file)
index 02f5da2..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/NaviItem.h"
-
-#include "ucl/gui/Naviframe.h"
-#include "ucl/gui/helpers.h"
-
-namespace ucl {
-
-       void NaviItem::popTo() const
-       {
-               const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
-               const bool needStartTransition =
-                               (navi && (navi->getTopItem() != *this));
-
-               elm_naviframe_item_pop_to(getIt());
-
-               if (needStartTransition) {
-                       navi->setInTransition(true);
-               }
-       }
-
-       void NaviItem::promote() const
-       {
-               const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
-               const bool needStartTransition =
-                               (navi && (navi->getTopItem() != *this));
-
-               elm_naviframe_item_promote(getIt());
-
-               if (needStartTransition) {
-                       navi->setInTransition(true);
-               }
-       }
-}
diff --git a/ucl/src/gui/Naviframe.cpp b/ucl/src/gui/Naviframe.cpp
deleted file mode 100644 (file)
index 717940b..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/Naviframe.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       // Naviframe::Builder //
-
-       NaviframeSRef Naviframe::Builder::build(ElmWidget &parent) const
-       {
-               Evas_Object *const eo = elm_naviframe_add(parent);
-               if (!eo) {
-                       ELOG("elm_naviframe_add() failed!");
-                       return {};
-               }
-
-               auto result = makeShared<Naviframe>(eo);
-
-               if (m_needBindToEo) {
-                       result->bindToEo();
-               }
-
-               if (isValid(m_style)) {
-                       result->setStyle(m_style);
-               }
-
-               show(*result);
-
-               return result;
-       }
-
-       // Naviframe //
-
-       Naviframe::Naviframe(IRefCountObj &rc, Evas_Object *eo) :
-               StyledWidget(&rc, eo),
-               m_isInTransition(false)
-       {
-               addEventHandler(NAVI_TRANSITION_FINISHED, WEAK_DELEGATE(
-                               Naviframe::onTransitionFinished, asWeak(*this)));
-       }
-
-       void Naviframe::setInTransition(const bool inTransition)
-       {
-               if (inTransition != m_isInTransition) {
-                       m_isInTransition = inTransition;
-                       if (inTransition) {
-                               callEvent(NAVI_TRANSITION_STARTED);
-                       } else {
-                               callEvent(NAVI_TRANSITION_FINISHED);
-                       }
-               }
-       }
-
-       void Naviframe::onTransitionFinished(Widget &widget, void *eventInfo)
-       {
-               m_isInTransition = false;
-       }
-}
diff --git a/ucl/src/gui/Widget.cpp b/ucl/src/gui/Widget.cpp
deleted file mode 100644 (file)
index 096c6e1..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/Widget.h"
-
-#include "common.h"
-
-namespace ucl { namespace { namespace impl {
-
-       constexpr auto WIDGET_EVENT_SMART = EVAS_CALLBACK_LAST;
-}}}
-
-namespace ucl {
-
-       // Widget::EventProxy //
-
-       class Widget::EventProxy : public NonCopyable {
-       public:
-               EventProxy(Widget &widget, const WidgetEvent event,
-                               const WidgetEventHandler handler) :
-                       m_widget(widget),
-                       m_handler(handler),
-                       m_type(static_cast<Evas_Callback_Type>(event))
-               {
-                       evas_object_event_callback_add(m_widget.getEo(),
-                                       m_type, event_cb, this);
-               }
-
-               EventProxy(Widget &widget, const SmartEvent event,
-                               const WidgetEventHandler handler) :
-                       m_widget(widget),
-                       m_smartEvent(event),
-                       m_handler(handler),
-                       m_type(impl::WIDGET_EVENT_SMART)
-               {
-                       evas_object_smart_callback_add(m_widget.getEo(),
-                                       m_smartEvent.c_str(), smart_cb, this);
-               }
-
-               ~EventProxy()
-               {
-                       if (m_type == impl::WIDGET_EVENT_SMART) {
-                               evas_object_smart_callback_del_full(m_widget.getEo(),
-                                               m_smartEvent.c_str(), smart_cb, this);
-                       } else {
-                               evas_object_event_callback_del_full(m_widget.getEo(),
-                                               m_type, event_cb, this);
-                       }
-               }
-
-               void setSelfIt(const Widget::EventProxiesIt it)
-               {
-                       m_selfIt = it;
-               }
-
-               bool operator==(const std::pair<WidgetEvent, WidgetEventHandler> &rhs)
-               {
-                       return ((m_type == static_cast<Evas_Callback_Type>(rhs.first)) &&
-                                       (m_handler == rhs.second));
-               }
-
-               bool operator==(const std::pair<SmartEvent, WidgetEventHandler> &rhs)
-               {
-                       return ((m_type == impl::WIDGET_EVENT_SMART) &&
-                                       (m_handler == rhs.second) &&
-                                       (m_smartEvent.compare(rhs.first) == 0));
-               }
-
-       private:
-               static void event_cb(void *data, Evas *e,
-                               Evas_Object *obj, void *event_info)
-               {
-                       static_cast<EventProxy *>(data)->dispatchEvent(event_info);
-               }
-
-               static void smart_cb(void *data, Evas_Object *obj, void *event_info)
-               {
-                       static_cast<EventProxy *>(data)->dispatchEvent(event_info);
-               }
-
-               void dispatchEvent(void *const event_info)
-               {
-                       if (m_handler) {
-                               m_handler(m_widget, event_info);
-                       } else {
-                               m_widget.delEventProxy(m_selfIt);
-                       }
-               }
-
-       private:
-               Widget &m_widget;
-               const std::string m_smartEvent;
-               const WidgetEventHandler m_handler;
-               const Evas_Callback_Type m_type;
-               Widget::EventProxiesIt m_selfIt;
-       };
-
-       // Widget //
-
-       Widget::Widget(IRefCountObj *const rc, Evas_Object *const eo,
-                       const bool isOwner) :
-               RefCountAware(rc),
-               m_eo(eo),
-               m_isOwner(isOwner),
-               m_isBoundToEo(false),
-               m_isEoRefKept(false),
-               m_isSelfRefUnique(false)
-       {
-               UCL_ASSERT(m_eo, "m_eo is NULL!");
-
-               if (isShared()) {
-                       evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_DEL,
-                                       EO_CALLBACK_PRIORITY_AFTER,
-                                       CALLBACK_A(Widget::onEoDel), this);
-               }
-
-               updateRefs();
-       }
-
-       Widget::~Widget()
-       {
-               m_eventProxies.clear();
-
-               if (m_isBoundToEo) {
-                       unbindFromEo();
-               }
-
-               if (isShared()) {
-                       evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_DEL,
-                                       CALLBACK_A(Widget::onEoDel), this);
-               }
-
-               if (m_isOwner) {
-                       evas_object_del(m_eo);
-               }
-
-               if (m_isEoRefKept) {
-                       evas_object_unref(m_eo);
-               }
-       }
-
-       void Widget::bindToEo()
-       {
-               if (!evas_object_data_get(m_eo, impl::WIDGET_DATA_NAME)) {
-                       evas_object_data_set(m_eo, impl::WIDGET_DATA_NAME, this);
-                       m_isBoundToEo = true;
-               } else {
-                       WLOG("Other Widget is already bound to this Eo!");
-               }
-       }
-
-       void Widget::unbindFromEo()
-       {
-               if (evas_object_data_get(m_eo, impl::WIDGET_DATA_NAME) == this) {
-                       evas_object_data_del(m_eo, impl::WIDGET_DATA_NAME);
-                       m_isBoundToEo = false;
-               } else {
-                       WLOG("Widget does not bound to its Eo!");
-               }
-       }
-
-       void Widget::updateRefs()
-       {
-               updateEoRef();
-
-               if (isShared()) {
-                       updateSelfRef();
-               }
-       }
-
-       void Widget::updateEoRef()
-       {
-               if (needKeepEoRef()) {
-                       if (!m_isEoRefKept) {
-                               m_isEoRefKept = true;
-                               evas_object_ref(m_eo);
-                       }
-               } else if (m_isEoRefKept) {
-                       m_isEoRefKept = false;
-                       evas_object_unref(m_eo);
-               }
-       }
-
-       bool Widget::needKeepEoRef() const
-       {
-               return (!m_isSelfRefUnique || !needKeepSelfRef());
-       }
-
-       void Widget::updateSelfRef()
-       {
-               if (!needKeepSelfRef()) {
-                       m_selfRef.reset();
-               } else if (!m_selfRef) {
-                       m_selfRef = asShared(*this);
-               }
-       }
-
-       bool Widget::needKeepSelfRef() const
-       {
-               return (!m_isOwner && m_eo);
-       }
-
-       void Widget::setSelfRefUnique(const bool value)
-       {
-               if (value != m_isSelfRefUnique) {
-                       m_isSelfRefUnique = value;
-                       updateEoRef();
-               }
-       }
-
-       void Widget::onEoDel(Evas *e, Evas_Object *obj, void *event_info)
-       {
-               if (!m_selfRef) {
-                       FLOG("UNEXPECTED! m_selfRef is NULL!");
-                       m_eo = nullptr;
-                       return;
-               }
-               if (m_isOwner || m_isEoRefKept || !m_isSelfRefUnique) {
-                       ELOG("UNEXPECTED! m_isOwner: %d; m_isEoRefKept: %d; "
-                                       "m_isSelfRefUnique: %d;",
-                                       m_isOwner, m_isEoRefKept, m_isSelfRefUnique);
-                       m_eo = nullptr;
-               }
-               m_selfRef.reset();
-       }
-
-       void Widget::onUniqueChanged(bool isUnique)
-       {
-               setSelfRefUnique(isUnique);
-       }
-
-       void Widget::delEventProxy(const EventProxiesIt it)
-       {
-               if (it != m_eventProxies.end()) {
-                       m_eventProxies.erase(it);
-               }
-       }
-
-       void Widget::addEventHandler(const WidgetEvent event,
-                       const WidgetEventHandler handler)
-       {
-               m_eventProxies.emplace_front(*this, event, handler);
-               m_eventProxies.front().setSelfIt(m_eventProxies.begin());
-       }
-
-       void Widget::addEventHandler(const SmartEvent event,
-                       const WidgetEventHandler handler)
-       {
-               if (strncmp(event.name, UCL_SMART_FWD, strlen(UCL_SMART_FWD)) == 0) {
-                       if (!ensureFwdEvent(event)) {
-                               LOG_RETURN_VOID(RES_NOT_SUPPORTED,
-                                               "Event is not supported: %s;", event.name);
-                       }
-               }
-               m_eventProxies.emplace_front(*this, event, handler);
-               m_eventProxies.front().setSelfIt(m_eventProxies.begin());
-       }
-
-       void Widget::delEventHandler(const WidgetEvent event,
-                       const WidgetEventHandler handler)
-       {
-               delEventProxy(std::find(m_eventProxies.begin(), m_eventProxies.end(),
-                               std::make_pair(event, handler)));
-       }
-
-       void Widget::delEventHandler(const SmartEvent event,
-                       const WidgetEventHandler handler)
-       {
-               delEventProxy(std::find(m_eventProxies.begin(), m_eventProxies.end(),
-                               std::make_pair(event, handler)));
-       }
-
-       void Widget::setFocusedImpl(const bool value)
-       {
-               evas_object_focus_set(getEo(), toEina(value));
-       }
-
-       bool Widget::isFocusedImpl() const
-       {
-               return evas_object_focus_get(getEo());
-       }
-
-       bool Widget::ensureFwdEvent(const SmartEvent fwdEvent)
-       {
-               return false;
-       }
-}
diff --git a/ucl/src/gui/WidgetItem.cpp b/ucl/src/gui/WidgetItem.cpp
deleted file mode 100644 (file)
index 04d1fca..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/WidgetItem.h"
-
-namespace ucl {
-
-       void WidgetItem::setText(const TString &value) const
-       {
-               if (value.isTranslatable()) {
-                       if (value.hasDomain()) {
-                               elm_object_item_domain_translatable_text_set(
-                                               getIt(), value.getDomain(), value);
-                       } else {
-                               elm_object_item_translatable_text_set(getIt(), value);
-                       }
-               } else {
-                       elm_object_item_text_translatable_set(getIt(), EINA_FALSE);
-                       elm_object_item_text_set(getIt(), value);
-               }
-       }
-
-       void WidgetItem::setText(const TString &value,
-                       const EdjePart part) const
-       {
-               if (value.isTranslatable()) {
-                       if (value.hasDomain()) {
-                               elm_object_item_domain_translatable_part_text_set(
-                                               getIt(), part.name, value.getDomain(), value);
-                       } else {
-                               elm_object_item_translatable_part_text_set(
-                                               getIt(), part.name, value);
-                       }
-               } else {
-                       elm_object_item_part_text_translatable_set(getIt(),
-                                       part.name, EINA_FALSE);
-                       elm_object_item_part_text_set(getIt(), part.name, value);
-               }
-       }
-}
diff --git a/ucl/src/gui/Window.cpp b/ucl/src/gui/Window.cpp
deleted file mode 100644 (file)
index 3f74e9e..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/gui/Window.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       // Window::Builder //
-
-       WindowSRef Window::Builder::build() const
-       {
-               if (!m_winEo && isEmpty(m_name) && isEmpty(m_title)) {
-                       ELOG("Wrong built parameters!");
-                       return {};
-               }
-
-               Evas_Object *winEo = m_winEo;
-               bool isOwner = m_isOwner;
-
-               if (!winEo) {
-                       winEo = elm_win_add(nullptr,
-                                       (m_name.empty() ? m_title : m_name).c_str(),
-                                       static_cast<Elm_Win_Type>(m_type));
-                       if (!winEo) {
-                               ELOG("elm_win_add() failed!");
-                               return {};
-                       }
-                       if (!m_isOwnerWasSet) {
-                               isOwner = true;
-                       }
-               }
-
-               StyledWidget bg(elm_bg_add(winEo));
-               expand(bg);
-               show(bg);
-
-               StyledWidget conform(elm_conformant_add(winEo));
-               expand(conform);
-               show(conform);
-
-               elm_win_resize_object_add(winEo, bg);
-               elm_win_resize_object_add(winEo, conform);
-
-               elm_win_indicator_opacity_set(winEo, ELM_WIN_INDICATOR_OPAQUE);
-               elm_win_conformant_set(winEo, EINA_TRUE);
-
-               auto result = makeShared<Window>(winEo, isOwner, conform);
-
-               if (m_needBindToEo) {
-                       result->bindToEo();
-               }
-
-               result->setTitle(m_title.empty() ? m_name : m_title);
-
-               if (result->isRotationsSupported()) {
-                       result->setRotations(m_rotations);
-               }
-
-               result->setIndicatorVisible(m_isIndicatorVisible);
-
-               return result;
-       }
-}
diff --git a/ucl/src/gui/common.h b/ucl/src/gui/common.h
deleted file mode 100644 (file)
index 6b543d3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_GUI_COMMON_H__
-#define __UCL_GUI_COMMON_H__
-
-#include "../common.h"
-
-#endif // __UCL_GUI_COMMON_H__
diff --git a/ucl/src/misc/Timeout.cpp b/ucl/src/misc/Timeout.cpp
deleted file mode 100644 (file)
index 41a3d3f..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/misc/Timeout.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       TimeoutSRef Timeout::create(double timeoutSec,
-                       const TimeoutHandler &handler)
-       {
-               auto result = makeShared<Timeout>(handler);
-
-               FAIL_RETURN_VALUE(result->prepare(timeoutSec), {},
-                               "result->prepare() failed!");
-
-               return result;
-       }
-
-       Timeout::Timeout(const TimeoutHandler &handler) :
-               m_timer(nullptr),
-               m_handler(handler)
-       {
-       }
-
-       Timeout::~Timeout()
-       {
-               if (m_timer) {
-                       ecore_timer_del(m_timer);
-               }
-       }
-
-       Result Timeout::prepare(const double timeoutSec)
-       {
-               m_timer = ecore_timer_add(timeoutSec,
-                       [](void *data) -> Eina_Bool
-                       {
-                               const auto self = static_cast<Timeout *>(data);
-                               self->m_timer = nullptr;
-                               if (self->m_handler) {
-                                       self->m_handler(self);
-                               }
-                               return ECORE_CALLBACK_CANCEL;
-                       },
-                       this);
-
-               if (!m_timer) {
-                       FAIL_RETURN(RES_FAIL, "ecore_timer_add() failed!");
-               }
-
-               return RES_OK;
-       }
-
-       bool Timeout::isExpired() const
-       {
-               return !m_timer;
-       }
-}
diff --git a/ucl/src/misc/Variant.cpp b/ucl/src/misc/Variant.cpp
deleted file mode 100644 (file)
index f723f34..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/misc/Variant.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       // Variant //
-
-       Variant::Variant(const char *const aString, const int length) :
-               m_type(aString ? TYPE_STRING : TYPE_NIL)
-       {
-               if (aString) {
-                       const int realLength = ((length < 0) ? strlen(aString) : length);
-                       if (realLength < sizeof(m_aSmallStr.buffer)) {
-                               strncpy(m_aSmallStr.buffer, aString, realLength);
-                               m_aSmallStr.buffer[realLength] = '\0';
-                               m_type |= impl::FLAG_SMALL_STR;
-                       } else {
-                               m_aString.data = strndup(aString, realLength);
-                               m_aString.length = realLength;
-                       }
-               }
-       }
-
-       Variant::Variant(std::nullptr_t, const int arrayLength) :
-               m_type(static_cast<int>((arrayLength > 0) ? TYPE_ARRAY : TYPE_NIL))
-       {
-               if (arrayLength > 0) {
-                       m_anArray.data = new Variant[arrayLength];
-                       m_anArray.length = arrayLength;
-               }
-       }
-
-       Variant::Variant(const Variant *const anArray, const int length) :
-               Variant(nullptr, length)
-       {
-               if (length > 0) {
-                       std::copy(anArray, (anArray + length), m_anArray.data);
-               }
-       }
-
-       Variant::Variant(const Variant &v) :
-               m_type(v.m_type)
-       {
-               switch (m_type) {
-               case TYPE_NIL:
-                       break;
-               case TYPE_STRING:
-                       m_aString.data = strndup(v.m_aString.data, v.m_aString.length);
-                       m_aString.length = v.m_aString.length;
-                       break;
-               case TYPE_ARRAY:
-                       m_anArray.data = new Variant[v.m_anArray.length];
-                       std::copy(v.m_anArray.data, (v.m_anArray.data + v.m_anArray.length),
-                                       m_anArray.data);
-                       m_anArray.length = v.m_anArray.length;
-                       break;
-               default:
-                       m_raw = v.m_raw;
-                       break;
-               }
-       }
-
-       bool Variant::asBool() const noexcept
-       {
-               switch (m_type) {
-               case TYPE_BOOLEAN:
-                       return m_aBool.value;
-               case TYPE_INTEGER:
-                       return (m_anInt.value != 0);
-               case TYPE_FLOAT:
-                       return (m_aFloat.value != 0.0f);
-               case TYPE_DOUBLE:
-                       return (m_aDouble.value != 0.0);
-               case TYPE_STRING:
-               case impl::TYPE_SMALL_STR:
-                       {
-                               const auto str = getStr();
-                               return (strcasecmp(str, "true") == 0)
-                                       || (strcasecmp(str, "yes") == 0)
-                                       || (strcasecmp(str, "ok") == 0)
-                                       || (strcasecmp(str, "on") == 0)
-                                       || (strcasecmp(str, "1") == 0);
-                       }
-               case TYPE_ARRAY:
-                       return (m_anArray.length != 0);
-               }
-               return false;
-       }
-
-       int Variant::asInt() const noexcept
-       {
-               switch (m_type) {
-               case TYPE_BOOLEAN:
-                       return static_cast<int>(m_aBool.value);
-               case TYPE_INTEGER:
-                       return m_anInt.value;
-               case TYPE_FLOAT:
-                       return static_cast<int>(m_aFloat.value);
-               case TYPE_DOUBLE:
-                       return static_cast<int>(m_aDouble.value);
-               case TYPE_STRING:
-               case impl::TYPE_SMALL_STR:
-                       return std::atoi(getStr());
-               case TYPE_ARRAY:
-                       return m_anArray.length;
-               }
-               return 0;
-       }
-
-       float Variant::asFloat() const noexcept
-       {
-               switch (m_type) {
-               case TYPE_BOOLEAN:
-                       return static_cast<float>(m_aBool.value);
-               case TYPE_INTEGER:
-                       return static_cast<float>(m_anInt.value);
-               case TYPE_FLOAT:
-                       return m_aFloat.value;
-               case TYPE_DOUBLE:
-                       return static_cast<float>(m_aDouble.value);
-               case TYPE_STRING:
-               case impl::TYPE_SMALL_STR:
-                       return static_cast<float>(std::atof(getStr()));
-               case TYPE_ARRAY:
-                       return static_cast<float>(m_anArray.length);
-               }
-               return 0.0f;
-       }
-
-       double Variant::asDouble() const noexcept
-       {
-               switch (m_type) {
-               case TYPE_BOOLEAN:
-                       return static_cast<double>(m_aBool.value);
-               case TYPE_INTEGER:
-                       return static_cast<double>(m_anInt.value);
-               case TYPE_FLOAT:
-                       return static_cast<double>(m_aFloat.value);
-               case TYPE_DOUBLE:
-                       return m_aDouble.value;
-               case TYPE_STRING:
-               case impl::TYPE_SMALL_STR:
-                       return std::atof(getStr());
-               case TYPE_ARRAY:
-                       return static_cast<double>(m_anArray.length);
-               }
-               return 0.0;
-       }
-
-       ConstCString Variant::asString() const noexcept
-       {
-               char strBuff[impl::TMP_STR_BUFF_SIZE] = {};
-               switch (m_type) {
-               case TYPE_NIL:
-                       return ConstCString::wrap("");
-               case TYPE_BOOLEAN:
-                       return ConstCString::wrap(m_aBool.value ? "true" : "false");
-               case TYPE_INTEGER:
-                       snprintf(strBuff, sizeof(strBuff), "%d", m_anInt.value);
-                       break;
-               case TYPE_FLOAT:
-                       snprintf(strBuff, sizeof(strBuff), "%f",
-                                       static_cast<double>(m_aFloat.value));
-                       break;
-               case TYPE_DOUBLE:
-                       snprintf(strBuff, sizeof(strBuff), "%f", m_aDouble.value);
-                       break;
-               case impl::TYPE_SMALL_STR:
-                       return ConstCString::wrap(m_aSmallStr.buffer);
-               case TYPE_STRING:
-                       return ConstCString::wrap(m_aString.data);
-               case TYPE_ARRAY:
-                       snprintf(strBuff, sizeof(strBuff), "%d", m_anArray.length);
-                       break;
-               }
-               return CString::dup(strBuff);
-       }
-
-       // Non-member functions //
-
-       bool operator==(const Variant &lhs, const Variant &rhs) noexcept
-       {
-               if (lhs.m_type != rhs.m_type) {
-                       return false;
-               }
-               switch (lhs.m_type) {
-               case Variant::TYPE_BOOLEAN:
-                       return (lhs.m_aBool.value == rhs.m_aBool.value);
-               case Variant::TYPE_INTEGER:
-                       return (lhs.m_anInt.value == rhs.m_anInt.value);
-               case Variant::TYPE_FLOAT:
-                       return (lhs.m_aFloat.value == rhs.m_aFloat.value);
-               case Variant::TYPE_DOUBLE:
-                       return (lhs.m_aDouble.value == rhs.m_aDouble.value);
-               case Variant::TYPE_STRING:
-               case impl::TYPE_SMALL_STR:
-                       return (strcmp(lhs.getStr(), rhs.getStr()) == 0);
-               case Variant::TYPE_ARRAY:
-                       if (lhs.m_anArray.length != rhs.m_anArray.length) {
-                               return false;
-                       }
-                       for (int i = 0; i < lhs.m_anArray.length; ++i) {
-                               if (lhs.m_anArray.data[i] != rhs.m_anArray.data[i]) {
-                                       return false;
-                               }
-                       }
-                       return true;
-               }
-               return true;
-       }
-}
diff --git a/ucl/src/misc/common.h b/ucl/src/misc/common.h
deleted file mode 100644 (file)
index 372ad4d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_COMMON_H__
-#define __UCL_MISC_COMMON_H__
-
-#include "../common.h"
-
-#endif // __UCL_MISC_COMMON_H__
diff --git a/ucl/src/mvp/GuiPresenter.cpp b/ucl/src/mvp/GuiPresenter.cpp
deleted file mode 100644 (file)
index e23bc02..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "common.h"
-
-namespace ucl { namespace { namespace impl {
-
-       constexpr SmartEvent ACTIVATE_BY {"ucl,activate,by"};
-       constexpr SmartEvent DEACTIVATE_BY {"ucl,deactivate,by"};
-}}}
-
-namespace ucl {
-
-       GuiPresenter::GuiPresenter(IRefCountObj &rc) :
-               RefCountAware(&rc),
-               m_hasBuildInSources(false),
-               m_isChild(false),
-               m_isPrepared(false)
-       {
-       }
-
-       GuiPresenter::~GuiPresenter()
-       {
-               if (m_hasBuildInSources) {
-                       if (m_isChild) {
-                               if (const auto parentSink = m_parentSink.lock()) {
-                                       delDeactivatorSource(*parentSink);
-                               }
-                       } else if (m_window) {
-                               delDeactivatorSource(*m_window);
-                       }
-               }
-       }
-
-       Result GuiPresenter::prepare(ElmWidget &widget, const int flags)
-       {
-               m_window = asShared(widget.getWindow());
-               if (!m_window) {
-                       LOG_RETURN(RES_FAIL, "m_window is NULL!");
-               }
-
-               if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
-                       addDeactivatorSource(*m_window);
-                       m_hasBuildInSources = true;
-               }
-
-               if (flags & PF_ADD_SELF_EXCEPT) {
-                       addDeactivatorException(getObjPtr());
-               }
-
-               m_isPrepared = true;
-
-               return RES_OK;
-       }
-
-       Result GuiPresenter::prepare(GuiPresenter &parent, const int flags)
-       {
-               if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
-
-                       if (!parent.m_sink) {
-                               LOG_RETURN(RES_FAIL, "parent.m_sink is NULL!");
-                       }
-
-                       for (auto deactivator: parent.m_deactivators) {
-                               if (m_deactivatorExceptions.find(deactivator) ==
-                                               m_deactivatorExceptions.end()) {
-                                       m_deactivators.insert(deactivator);
-                               }
-                       }
-
-                       addDeactivatorSource(*parent.m_sink);
-                       m_parentSink = parent.m_sink;
-                       m_hasBuildInSources = true;
-               }
-
-               if (flags & PF_ADD_SELF_EXCEPT) {
-                       addDeactivatorException(getObjPtr());
-               }
-
-               m_window = parent.m_window;
-               m_isChild = true;
-               m_isPrepared = true;
-
-               return RES_OK;
-       }
-
-       Window &GuiPresenter::getWindow()
-       {
-               UCL_ASSERT(isWindowReady(), "m_window is NULL!");
-               return *m_window;
-       }
-
-       bool GuiPresenter::isWindowReady() const
-       {
-               return !!m_window;
-       }
-
-       void GuiPresenter::addDeactivatorException(const void *const deactivator)
-       {
-               const auto pair = m_deactivatorExceptions.insert(deactivator);
-               if (pair.second) {
-                       activateBy(deactivator);
-               }
-       }
-
-       void GuiPresenter::setDeactivatorSink(const WidgetSRef &sink)
-       {
-               m_sink = sink;
-       }
-
-       void GuiPresenter::sendActivate(Widget &sender)
-       {
-               sendDeactivator(sender, impl::ACTIVATE_BY, getObjPtr());
-       }
-
-       void GuiPresenter::sendDeactivate(Widget &sender)
-       {
-               sendDeactivator(sender, impl::DEACTIVATE_BY, getObjPtr());
-       }
-
-       void GuiPresenter::broadcastActivate()
-       {
-               broadcastDeactivator(impl::ACTIVATE_BY, getObjPtr());
-       }
-
-       void GuiPresenter::broadcastDeactivate()
-       {
-               broadcastDeactivator(impl::DEACTIVATE_BY, getObjPtr());
-       }
-
-       void GuiPresenter::sendDeactivator(Widget &sender,
-                       SmartEvent event, const void *deactivator)
-       {
-               sendDeactivatorInfo(sender, event, {deactivator, false});
-       }
-
-       void GuiPresenter::broadcastDeactivator(const SmartEvent event,
-                       const void *const deactivator)
-       {
-               sendDeactivatorInfo(*m_window, event, {deactivator, true});
-       }
-
-       void GuiPresenter::sendDeactivatorInfo(Widget &sender,
-                       const SmartEvent event, const DeactivatorInfo &info)
-       {
-               sender.callEvent(event, const_cast<DeactivatorInfo *>(&info));
-       }
-
-       bool GuiPresenter::isActive() const
-       {
-               return isEmpty(m_deactivators);
-       }
-
-       bool GuiPresenter::isDeactivatedBy(const void *const deactivator) const
-       {
-               return (m_deactivators.find(deactivator) != m_deactivators.end());
-       }
-
-       void GuiPresenter::activateBy(const void *const deactivator)
-       {
-               activateByImpl({deactivator, false});
-       }
-
-       void GuiPresenter::deactivateBy(const void *const deactivator)
-       {
-               deactivateByImpl({deactivator, false});
-       }
-
-       void GuiPresenter::addDeactivatorSource(Widget &source)
-       {
-               source.addEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
-                               GuiPresenter::onActivateBySmart, asWeak(*this)));
-               source.addEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
-                               GuiPresenter::onDeactivateBySmart, asWeak(*this)));
-       }
-
-       void GuiPresenter::delDeactivatorSource(Widget &source)
-       {
-               source.delEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
-                               GuiPresenter::onActivateBySmart, asWeak(*this)));
-               source.delEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
-                               GuiPresenter::onDeactivateBySmart, asWeak(*this)));
-       }
-
-       void GuiPresenter::activateByImpl(const DeactivatorInfo &info)
-       {
-               const auto count = m_deactivators.erase(info.deactivator);
-               if (m_isPrepared && (count > 0)) {
-                       if (m_sink) {
-                               sendDeactivatorInfo(*m_sink, impl::ACTIVATE_BY, info);
-                       }
-                       onActivateBy(info);
-                       if (m_deactivators.size() == 0) {
-                               onActivate();
-                       }
-               }
-       }
-
-       void GuiPresenter::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) {
-                       if (m_sink) {
-                               sendDeactivatorInfo(*m_sink, impl::DEACTIVATE_BY, info);
-                       }
-                       onDeactivateBy(info);
-                       if (m_deactivators.size() == 1) {
-                               onDeactivate();
-                       }
-               }
-       }
-
-       void GuiPresenter::onActivateBySmart(Widget &widget, void *eventInfo)
-       {
-               activateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
-       }
-
-       void GuiPresenter::onDeactivateBySmart(Widget &widget, void *eventInfo)
-       {
-               deactivateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
-       }
-
-       void GuiPresenter::onActivate()
-       {
-       }
-
-       void GuiPresenter::onDeactivate()
-       {
-       }
-
-       void GuiPresenter::onActivateBy(const DeactivatorInfo &info)
-       {
-       }
-
-       void GuiPresenter::onDeactivateBy(const DeactivatorInfo &info)
-       {
-       }
-}
diff --git a/ucl/src/mvp/ListItemPresenter.cpp b/ucl/src/mvp/ListItemPresenter.cpp
deleted file mode 100644 (file)
index d27568b..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/mvp/ListItemPresenter.h"
-
-#include "common.h"
-
-namespace ucl {
-
-       // ListItemPresenter::ItemClass //
-
-       ListItemPresenter::ItemClassSRef ListItemPresenter::ItemClass::
-                       newInstance(const ElmStyle itemStyle)
-       {
-               auto result = makeShared<ItemClass>(itemStyle);
-               if (!result->get()) {
-                       LOG_RETURN_VALUE(RES_FAIL, {}, "Failed to create ItemClass()!");
-               }
-               return result;
-       }
-
-       ListItemPresenter::ItemClass::ItemClass(const ElmStyle itemStyle) :
-               m_itc(elm_genlist_item_class_new())
-       {
-               if (!m_itc) {
-                       return;
-               }
-
-               m_itc->item_style = itemStyle.name;
-
-               m_itc->func.text_get =
-                       [](void *data, Evas_Object *obj, const char *part) -> char *
-                       {
-                               if (!data) {
-                                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
-                               }
-                               return static_cast<ListItemPresenter *>(data)->
-                                               getItemPartText(EdjePart(part)).release();
-                       };
-
-               m_itc->func.content_get =
-                       [](void *data, Evas_Object *obj, const char *part) -> Evas_Object *
-                       {
-                               if (!data) {
-                                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
-                               }
-                               auto &&item = *static_cast<ListItemPresenter *>(data);
-                               if (const auto widget = item.getItemPartContent(
-                                               EdjePart(part), *item.m_parent)) {
-                                       widget->setIsOwner(false);
-                                       return widget->getEo();
-                               }
-                               return nullptr;
-                       };
-
-               m_itc->func.state_get =
-                       [](void *data, Evas_Object *obj, const char *part) -> Eina_Bool
-                       {
-                               if (!data) {
-                                       LOG_RETURN_VALUE(RES_FATAL, false, "data is NULL");
-                               }
-                               return static_cast<ListItemPresenter *>(data)->
-                                               getItemPartState(EdjePart(part));
-                       };
-       }
-
-       ListItemPresenter::ItemClass::~ItemClass()
-       {
-               if (m_itc) {
-                       elm_genlist_item_class_free(m_itc);
-               }
-       }
-
-       Elm_Genlist_Item_Class *ListItemPresenter::ItemClass::get()
-       {
-               return m_itc;
-       }
-
-       // ListItemPresenter::ItemClassCache //
-
-       ListItemPresenter::ItemClassSRef ListItemPresenter::ItemClassCache::
-                       getItemClass(const ElmStyle itemStyle)
-       {
-               ItemClassSRef result;
-
-               if (!m_itcMap.get(itemStyle, result)) {
-                       result = ItemClass::newInstance(itemStyle);
-                       if (result) {
-                               m_itcMap.set(itemStyle, result);
-                       } else {
-                               ELOG("ItemClass::newInstance() failed!");
-                       }
-               }
-
-               return result;
-       }
-
-       void ListItemPresenter::ItemClassCache::purge()
-       {
-               m_itcMap.clear();
-       }
-
-       // ListItemPresenter //
-
-       ListItemPresenter::ListItemPresenter(IRefCountObj &rc) :
-               RefCountAware(&rc),
-               m_flags(PF_AUTO_UNSELECT)
-       {
-       }
-
-       ListItemPresenter::~ListItemPresenter()
-       {
-               if (m_item) {
-                       FLOG("m_item is still alive!");
-                       deleteDetachedItem(true);
-               }
-       }
-
-       void ListItemPresenter::attachItem(GenlistItem item, ElmWidgetSRef &&parent,
-                       const ItemClassCacheSRef &itcCache,
-                       const SharedRef<bool> &isActiveRef)
-       {
-               if (m_item) {
-                       deleteDetachedItem();
-               }
-
-               m_item = item;
-               m_item.setData(this);
-               m_item.setDelCallback(CALLBACK_A(ListItemPresenter::onItemDel));
-
-               m_parent = std::move(parent);
-
-               m_itcCache = itcCache;
-               m_isActiveRef = isActiveRef;
-
-               if (!m_selfRef) {
-                       m_selfRef = asShared(*this);
-               }
-
-               onItemAttached();
-       }
-
-       void ListItemPresenter::deleteDetachedItem(const bool silent)
-       {
-               auto item = m_item;
-               detachItem(silent);
-               item.del();
-       }
-
-       void ListItemPresenter::detachItem(const bool silent)
-       {
-               m_item.setData(nullptr);
-               m_item.setDelCallback(nullptr);
-               m_item = nullptr;
-
-               m_parent.reset();
-               m_itcCache.reset();
-               m_isActiveRef.reset();
-
-               if (!silent) {
-                       onItemDetached();
-               }
-       }
-
-       void ListItemPresenter::onItemDel(Evas_Object *obj, void *eventInfo)
-       {
-               if (m_item) {
-                       detachItem();
-               }
-               m_selfRef.reset();
-       }
-
-       void ListItemPresenter::setFlags(const int flags)
-       {
-               m_flags = flags;
-       }
-
-       int ListItemPresenter::getFlags() const
-       {
-               return m_flags;
-       }
-
-       bool ListItemPresenter::isActive() const
-       {
-               return (m_isActiveRef ? *m_isActiveRef : false);
-       }
-
-       GenlistItem ListItemPresenter::getItem()
-       {
-               return m_item;
-       }
-
-       ListItemPresenter::ItemClassCache *ListItemPresenter::getItemClassCache()
-       {
-               return m_itcCache.get();
-       }
-
-       Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle)
-       {
-               if (!m_item) {
-                       LOG_RETURN(RES_ILLEGAL_STATE, "m_item is NULL!");
-               }
-               if (!m_itcCache) {
-                       LOG_RETURN(RES_FATAL, "m_itcCache is NULL!");
-               }
-
-               const auto itc = m_itcCache->getItemClass(newItemStyle);
-               if (!itc) {
-                       LOG_RETURN(RES_FAIL, "m_itcCache->getItemClass() failed!");
-               }
-
-               m_item.update(itc->get());
-
-               return RES_OK;
-       }
-
-       void ListItemPresenter::dispose()
-       {
-               if (m_item) {
-                       deleteDetachedItem();
-                       m_selfRef.reset();
-               }
-       }
-
-       bool ListItemPresenter::isDisposed() const
-       {
-               return !m_item;
-       }
-
-       void ListItemPresenter::onItemAttached()
-       {
-       }
-
-       void ListItemPresenter::onItemDetached()
-       {
-       }
-
-       WidgetSRef ListItemPresenter::getItemPartContent(const EdjePart part,
-                       ElmWidget &parent)
-       {
-               return nullptr;
-       }
-
-       CString ListItemPresenter::getItemPartText(const EdjePart part)
-       {
-               return nullptr;
-       }
-
-       bool ListItemPresenter::getItemPartState(const EdjePart part)
-       {
-               return false;
-       }
-
-       void ListItemPresenter::onItemSelectedHook()
-       {
-               if (m_flags & PF_AUTO_UNSELECT) {
-                       m_item.setSelected(false);
-               }
-               onItemSelected();
-       }
-
-       void ListItemPresenter::onItemSelected()
-       {
-       }
-
-       void ListItemPresenter::onItemRealized()
-       {
-       }
-
-       void ListItemPresenter::onItemUnrealized()
-       {
-       }
-
-       void ListItemPresenter::onItemHighlighted()
-       {
-       }
-
-       void ListItemPresenter::onItemUnhighlighted()
-       {
-       }
-}
diff --git a/ucl/src/mvp/ListPresenter.cpp b/ucl/src/mvp/ListPresenter.cpp
deleted file mode 100644 (file)
index 2835697..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/mvp/ListPresenter.h"
-
-#include "common.h"
-
-namespace ucl { namespace { namespace impl {
-
-       constexpr SmartEvent ITEM_SELECTED {"selected"};
-
-       constexpr SmartEvent ITEM_REALIZED {"realized"};
-       constexpr SmartEvent ITEM_UNREALIZED {"unrealized"};
-       constexpr SmartEvent ITEM_HIGHLIGHTED {"highlighted"};
-       constexpr SmartEvent ITEM_UNHIGHLIGHTED {"unhighlighted"};
-
-       ListItemPresenter *toItemPresenter(void *eventInfo)
-       {
-               if (!eventInfo) {
-                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "eventInfo is NULL");
-               }
-
-               const GenlistItem item{static_cast<Elm_Object_Item *>(eventInfo)};
-               const auto data = item.getData();
-               if (!data) {
-                       LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
-               }
-
-               return static_cast<ListItemPresenter *>(data);
-       }
-}}}
-
-namespace ucl {
-
-       // ListPresenter::Builder //
-
-       ListPresenter::Builder::Builder() :
-               m_flags(FLAG_HOMOGENEOUS)
-       {
-       }
-
-       ListPresenter::Builder &ListPresenter::Builder::setStyle(
-                       const ElmStyle style)
-       {
-               m_style = style;
-               return *this;
-       }
-
-       ListPresenter::Builder &ListPresenter::Builder::setFlags(const int flags)
-       {
-               m_flags = flags;
-               return *this;
-       }
-
-       ListPresenter::Builder &ListPresenter::Builder::setParentWidget(
-                       const ElmWidgetSRef &parentWidget)
-       {
-               m_parentWidget = parentWidget;
-               return *this;
-       }
-
-       ListPresenterSRef ListPresenter::Builder::build(GuiPresenter &parent) const
-       {
-               if (!m_parentWidget) {
-                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
-                                       "m_parentWidget is NULL!");
-               }
-
-               auto result = makeShared<ListPresenter>();
-
-               FAIL_RETURN_VALUE(result->prepare(
-                               parent, *m_parentWidget, m_style, m_flags),
-                               {}, "result->prepare() failed!");
-
-               return result;
-       }
-
-       // ListPresenter //
-
-       ListPresenter::ListPresenter(IRefCountObj &rc) :
-                       GuiPresenter(rc)
-       {
-       }
-
-       ListPresenter::~ListPresenter()
-       {
-               if (m_genlist) {
-                       m_genlist->clear();
-               }
-       }
-
-       Result ListPresenter::prepare(
-                       GuiPresenter &parent, ElmWidget &parentWidget,
-                       const ElmStyle style, const int flags)
-       {
-               FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
-                               "GuiPresenter::prepare() failed!");
-
-               m_genlist = Genlist::Builder().
-                               setStyle(style).
-                               setMode(Genlist::Mode::COMPRESS).
-                               setHomogeneous(flags & FLAG_HOMOGENEOUS).
-                               setNeedBindToEo(true).
-                               build(parentWidget);
-               if (!m_genlist) {
-                       LOG_RETURN(RES_FAIL, "Genlist::build() failed!");
-               }
-
-               expandAndFill(*m_genlist);
-
-               // TODO Add Scroller widget.
-               elm_scroller_content_min_limit(*m_genlist,
-                               toEina((flags & FLAG_CALC_X_MIN) != 0),
-                               toEina((flags & FLAG_CALC_Y_MIN) != 0));
-
-               m_itcCache = makeShared<ListItemPresenter::ItemClassCache>();
-
-               m_isActiveRef = makeShared<bool>();
-               *m_isActiveRef = isActive();
-
-               m_genlist->addEventHandler(impl::ITEM_SELECTED, WEAK_DELEGATE(
-                               ListPresenter::onItemSelected, asWeak(*this)));
-
-               if (flags & FLAG_NOTIFY_REALIZED) {
-                       m_genlist->addEventHandler(impl::ITEM_REALIZED, WEAK_DELEGATE(
-                                       ListPresenter::onItemRealized, asWeak(*this)));
-               }
-               if (flags & FLAG_NOTIFY_UNREALIZED) {
-                       m_genlist->addEventHandler(impl::ITEM_UNREALIZED, WEAK_DELEGATE(
-                                       ListPresenter::onItemUnrealized, asWeak(*this)));
-               }
-               if (flags & FLAG_NOTIFY_HIGHLIGHTED) {
-                       m_genlist->addEventHandler(impl::ITEM_HIGHLIGHTED, WEAK_DELEGATE(
-                                       ListPresenter::onItemHighlighted, asWeak(*this)));
-               }
-               if (flags & FLAG_NOTIFY_UNHIGHLIGHTED) {
-                       m_genlist->addEventHandler(impl::ITEM_UNHIGHLIGHTED, WEAK_DELEGATE(
-                                       ListPresenter::onItemUnhighlighted, asWeak(*this)));
-               }
-
-               return RES_OK;
-       }
-
-       Genlist &ListPresenter::getWidget()
-       {
-               return *m_genlist;
-       }
-
-       void ListPresenter::clear()
-       {
-               m_genlist->clear();
-               m_itcCache->purge();
-       }
-
-       Result ListPresenter::append(ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent)
-       {
-               return insert(itemPresenter, parent,
-                       [this](const Elm_Genlist_Item_Class *itc, const void *data,
-                                       GenlistItem parent, GenlistItem::Type type)
-                       {
-                               return m_genlist->append(itc, data, nullptr, type, parent);
-                       });
-       }
-
-       Result ListPresenter::prepend(ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent)
-       {
-               return insert(itemPresenter, parent,
-                       [this](const Elm_Genlist_Item_Class *itc, const void *data,
-                                       GenlistItem parent, GenlistItem::Type type)
-                       {
-                               return m_genlist->prepend(itc, data, nullptr, type, parent);
-                       });
-       }
-
-       Result ListPresenter::insertAfter(const ListItemPresenter &after,
-                       ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent)
-       {
-               return insertRelative(after, itemPresenter, parent,
-                       [this](GenlistItem rel, const Elm_Genlist_Item_Class *itc,
-                               const void *data, GenlistItem parent, GenlistItem::Type type)
-                       {
-                               return m_genlist->insertAfter(
-                                               rel, itc, data, nullptr, type, parent);
-                       });
-       }
-
-       Result ListPresenter::insertBefore(const ListItemPresenter &before,
-                       ListItemPresenter &itemPresenter,
-                               ListItemPresenter *parent)
-       {
-               return insertRelative(before, itemPresenter, parent,
-                       [this](GenlistItem rel, const Elm_Genlist_Item_Class *itc,
-                               const void *data, GenlistItem parent, GenlistItem::Type type)
-                       {
-                               return m_genlist->insertBefore(
-                                               rel, itc, data, nullptr, type, parent);
-                       });
-       }
-
-       template <class INSERT_FUNC>
-       Result ListPresenter::insert(ListItemPresenter &itemPresenter,
-                       ListItemPresenter *parent, INSERT_FUNC &&insertFunc)
-       {
-               const auto params = itemPresenter.getItemInsertionParams();
-
-               const auto itc = m_itcCache->getItemClass(params.itemStyle);
-               if (!itc) {
-                       LOG_RETURN(RES_FAIL, "m_itcCache.getItemClass() failed!");
-               }
-
-               GenlistItem parentItem;
-               if (parent) {
-                       parentItem = parent->m_item;
-                       if (!parentItem) {
-                               ELOG("parentItem is NULL");
-                       }
-               }
-
-               const auto item = insertFunc(itc->get(),
-                               &itemPresenter, parentItem, params.itemType);
-               if (!item) {
-                       LOG_RETURN(RES_FAIL, "insertFunc() failed!");
-               }
-
-               itemPresenter.attachItem(item, m_genlist, m_itcCache, m_isActiveRef);
-
-               return RES_OK;
-       }
-
-       template <class INSERT_FUNC>
-       Result ListPresenter::insertRelative(const ListItemPresenter &relative,
-                       ListItemPresenter &itemPresenter, ListItemPresenter *parent,
-                       INSERT_FUNC &&insertFunc)
-       {
-               const auto relItem = relative.m_item;
-               if (!relItem) {
-                       LOG_RETURN(RES_FAIL, "relItem is NULL!");
-               }
-               if (relItem.getWidget() != m_genlist->getEo()) {
-                       LOG_RETURN(RES_FAIL, "relItem has wrong genlist!");
-               }
-               return insert(itemPresenter, parent,
-                       [relItem, &insertFunc](const Elm_Genlist_Item_Class *itc,
-                               const void *data, GenlistItem parent, GenlistItem::Type type)
-                       {
-                               return insertFunc(relItem, itc, data, parent, type);
-                       });
-       }
-
-       void ListPresenter::setIsActiveRef(const bool value)
-       {
-               if (!m_isActiveRef) {
-                       LOG_RETURN_VOID(RES_FATAL, "m_isActiveRef is NULL");
-               }
-               *m_isActiveRef = value;
-       }
-
-       void ListPresenter::onItemSelected(Widget &widget, void *eventInfo)
-       {
-               const auto itemPresenter = impl::toItemPresenter(eventInfo);
-               if (!itemPresenter) {
-                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
-               }
-               itemPresenter->onItemSelectedHook();
-       }
-
-       void ListPresenter::onItemRealized(Widget &widget, void *eventInfo)
-       {
-               const auto itemPresenter = impl::toItemPresenter(eventInfo);
-               if (!itemPresenter) {
-                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
-               }
-               itemPresenter->onItemRealized();
-       }
-
-       void ListPresenter::onItemUnrealized(Widget &widget, void *eventInfo)
-       {
-               const auto itemPresenter = impl::toItemPresenter(eventInfo);
-               if (!itemPresenter) {
-                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
-               }
-               itemPresenter->onItemUnrealized();
-       }
-
-       void ListPresenter::onItemHighlighted(Widget &widget, void *eventInfo)
-       {
-               const auto itemPresenter = impl::toItemPresenter(eventInfo);
-               if (!itemPresenter) {
-                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
-               }
-               itemPresenter->onItemHighlighted();
-       }
-
-       void ListPresenter::onItemUnhighlighted(Widget &widget, void *eventInfo)
-       {
-               const auto itemPresenter = impl::toItemPresenter(eventInfo);
-               if (!itemPresenter) {
-                       LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
-               }
-               itemPresenter->onItemUnhighlighted();
-       }
-
-       void ListPresenter::onActivate()
-       {
-               setIsActiveRef(true);
-       }
-
-       void ListPresenter::onDeactivate()
-       {
-               setIsActiveRef(false);
-       }
-}
diff --git a/ucl/src/mvp/common.h b/ucl/src/mvp/common.h
deleted file mode 100644 (file)
index 2894a14..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MVP_COMMON_H__
-#define __UCL_MVP_COMMON_H__
-
-#include "../common.h"
-
-#endif // __UCL_MVP_COMMON_H__
diff --git a/ucl/src/util/logging.cpp b/ucl/src/util/logging.cpp
deleted file mode 100644 (file)
index 311f25b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/logging.h"
-
-#if (UCL_DEFINE_GET_UCL_RESULT_DATA)
-#include "ucl/util/types/Result.h"
-
-ucl::ResultData getUCLResultData(const ucl::Result result)
-{
-       return ucl::getResultData(result);
-}
-#endif
diff --git a/ucl/src/util/types/Result.cpp b/ucl/src/util/types/Result.cpp
deleted file mode 100644 (file)
index b42875e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/util/types/Result.h"
-
-#include "ucl/util/logging.h"
-
-namespace ucl { namespace { namespace impl {
-
-       constexpr ResultData RESUT_DATA[] = {
-               {"RES_FATAL",             DLOG_FATAL},
-               {"RES_INVALID_DATA",      DLOG_ERROR},
-               {"RES_NOT_SUPPORTED",     DLOG_ERROR},
-               {"RES_IO_ERROR",          DLOG_ERROR},
-               {"RES_OUT_OF_MEMORY",     DLOG_ERROR},
-               {"RES_ILLEGAL_STATE",     DLOG_ERROR},
-               {"RES_INVALID_ARGUMENTS", DLOG_ERROR},
-               {"RES_FAIL",              DLOG_ERROR},
-               {"RES_OK",                DLOG_INFO},
-               {"RES_FALSE",             DLOG_INFO},
-               {"Unknown result value",  DLOG_ERROR},
-       };
-}}}
-
-namespace ucl {
-
-       const ResultData &getResultData(const Result result)
-       {
-               return impl::RESUT_DATA[
-                       ((result.value < _RES_BEGIN) || (result.value >= _RES_END)) ?
-                               _RES_END : (result.value - _RES_BEGIN)];
-       }
-}