From ca1e20219b5d0b63b4f3145cc356cdda04279407 Mon Sep 17 00:00:00 2001 From: Igor Nazarov Date: Wed, 2 Aug 2017 20:53:31 +0300 Subject: TizenRefApp-9006 [Gallery] Implement helper function to create CustomMediaAlbum from app control file path array Change-Id: Ib0db737ffff86fd4c72fb236a29f4f1e04d7da02 --- gallery/model/helpers.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++ gallery/model/helpers.h | 28 ++++++++++++++++++++++++ project_def.prop | 2 +- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 gallery/model/helpers.cpp create mode 100644 gallery/model/helpers.h diff --git a/gallery/model/helpers.cpp b/gallery/model/helpers.cpp new file mode 100644 index 0000000..cf64994 --- /dev/null +++ b/gallery/model/helpers.cpp @@ -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 "helpers.h" + +#include "common.h" + +namespace gallery { namespace util { + + CustomMediaAlbumSRef makeMediaAlbum( + const char *const filePathArray[], const int count) + { + if (!filePathArray) { + FAIL_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, + "filePathArray is NULL"); + } + + auto result = makeShared(); + + for (int i = 0; i < count; ++i) { + + const auto filePath = filePathArray[i]; + if (!filePath) { + WLOG("filePath is NULL. Skipping..."); + continue; + } + + auto item = MediaItem::newInstance(filePath); + if (!item) { + WLOG("MediaItem::newInstance() failed. Skipping..."); + continue; + } + + result->addItem(std::move(item)); + } + + if (isEmpty(result)) { + FAIL_RETURN_VALUE(RES_FAIL, {}, "result is empty"); + } + + return result; + } +}} diff --git a/gallery/model/helpers.h b/gallery/model/helpers.h new file mode 100644 index 0000000..c578222 --- /dev/null +++ b/gallery/model/helpers.h @@ -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 __GALLERY_MODEL_HELPERS_H__ +#define __GALLERY_MODEL_HELPERS_H__ + +#include "CustomMediaAlbum.h" + +namespace gallery { namespace util { + + CustomMediaAlbumSRef makeMediaAlbum( + const char *const filePathArray[], int count); +}} + +#endif // __GALLERY_MODEL_HELPERS_H__ diff --git a/project_def.prop b/project_def.prop index 657acd9..d0f49b6 100644 --- a/project_def.prop +++ b/project_def.prop @@ -9,7 +9,7 @@ type = app profile = wearable-4.0 # C/CPP Sources -USER_SRCS = gallery/presenters/Instance.cpp ucl/source/mvp/GuiPresenter.cpp gallery/model/CustomMediaAlbum.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 +USER_SRCS = gallery/presenters/Instance.cpp ucl/source/mvp/GuiPresenter.cpp gallery/model/CustomMediaAlbum.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 gallery/model/helpers.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 # EDC Sources USER_EDCS = -- cgit v1.2.3