TizenRefApp-8211 [Gallery] Implement Model 36/120136/1
authorIgor Nazarov <i.nazarov@samsung.com>
Tue, 21 Mar 2017 15:14:48 +0000 (17:14 +0200)
committerIgor Nazarov <i.nazarov@samsung.com>
Tue, 21 Mar 2017 18:03:21 +0000 (20:03 +0200)
- Implemented Model functionality;
- Fixed LLVM build errors/warnings in UCL.

Change-Id: Ibfc3eb57d4955219991428db9947a50e49b8b742

21 files changed:
inc/model/Gallery.h
inc/model/IMediaAlbum.h
inc/model/MediaItem.h
inc/model/types.h
src/common.h
src/model/Gallery.cpp
src/model/GalleryAlbum.cpp [new file with mode: 0644]
src/model/GalleryAlbum.h [new file with mode: 0644]
src/model/MediaItem.cpp
src/model/common.h [new file with mode: 0644]
src/model/helpers.cpp [new file with mode: 0644]
src/model/helpers.h [new file with mode: 0644]
src/model/helpers.hpp [new file with mode: 0644]
src/view/ImageGrid.cpp
tizen-manifest.xml
ucl/inc/ucl/misc/RefCountAware.hpp
ucl/inc/ucl/util/helpers.h
ucl/inc/ucl/util/helpers.hpp
ucl/inc/ucl/util/logging.h
ucl/inc/ucl/util/types/Result.h
ucl/src/util/types/Result.cpp

index cc5f749d2878859488435e006e92837fb59fce69..e3f994d2a7247b9bc864bf108bf720bcfce988c9 100644 (file)
 #ifndef __GALLERY_MODEL_GALLERY_H__
 #define __GALLERY_MODEL_GALLERY_H__
 
-#include "IMediaAlbum.h"
+#include "types.h"
 
 namespace gallery {
 
        class Gallery final : public ucl::NonCopyable {
        public:
-               Gallery();
+               static GallerySRef newInstance();
                ~Gallery();
 
-               IMediaAlbum &getAlbum();
+               IMediaAlbumSRef getAlbum();
+
+       private:
+               friend class ucl::RefCountObj<Gallery>;
+               Gallery();
+
+               ucl::Result prepare();
+
+       private:
+               IMediaAlbumSRef m_album;
+               bool m_isMediaDbConnected;
        };
 }
 
index 40cba074b0294374d5f693b9921f5b2e25a06d36..b04771bcb6df90a560da51fba399018db31e9214 100644 (file)
@@ -23,7 +23,7 @@ namespace gallery {
 
        class IMediaAlbum : public ucl::Polymorphic {
        public:
-               using EachCb = ucl::Delegate<void(MediaItemUPtr item)>;
+               using EachCb = ucl::Delegate<bool(MediaItemUPtr media)>;
 
        public:
                virtual ucl::Result forEachMedia(EachCb cb) const = 0;
index 1ce85f8432e58250701ec164ae7e6027fdabe6e2..d0e1a7d3607bec1297b83099968a12e58a842872 100644 (file)
@@ -24,10 +24,10 @@ namespace gallery {
        class MediaItem : public ucl::Polymorphic {
        public:
                using ThumbnailPathGetCb =
-                               std::function<void(ucl::Result, const std::string &path)>;
+                               ucl::Delegate<void(ucl::Result, const std::string &path)>;
 
        public:
-               MediaItem(media_info_h info);
+               static MediaItemUPtr newInstance(media_info_h media);
                virtual ~MediaItem();
 
                bool isValid() const;
@@ -35,17 +35,38 @@ namespace gallery {
 
                const std::string &getFilePath() const;
 
-               ucl::Result getThumbnailPath(ThumbnailPathGetCb cb) const;
+               ucl::Result getThumbnailPath(const ThumbnailPathGetCb &cb) const;
                void cancelThumbnailPathGet() const;
 
                ucl::Result removeFile();
 
+       protected:
+               MediaItem(MediaType type);
+
+               ucl::Result prepare(media_info_h media);
+
+       private:
+               ucl::Result initThumbPath(media_info_h media) const;
+               void freeMediaInfo() const;
+
+       private:
+               // XXX This proxy is needed to deal with cases when
+               // media_thumbnail_completed_cb can't be cancelled
+               struct ThumbCbProxy {
+                       const MediaItem *item;
+                       ThumbnailPathGetCb callback;
+
+                       void completeCb(media_content_error_e error, const char *path);
+               };
+
        private:
                const MediaType m_type;
-               media_info_h m_info;
-               mutable ThumbnailPathGetCb m_thumbGetCb;
-               mutable std::string m_filePath;
+               std::string m_mediaId;
+               std::string m_filePath;
+               mutable media_info_h m_media;
                mutable std::string m_thumbPath;
+               mutable std::unique_ptr<ThumbCbProxy> m_thumbCbProxy;
+               bool m_isValid;
        };
 }
 
index a0f6103250d9a298d4662763fdac771c7a4635f0..129c901fde72a12f3b00132647ebb9aa073c29ed 100644 (file)
@@ -28,9 +28,13 @@ namespace gallery {
                VIDEO,
                SOUND,
                MUSIC,
-               OTHER
+               OTHERS
        };
 
+       UCL_DECLARE_REF_ALIASES(Gallery);
+
+       UCL_DECLARE_REF_ALIASES(IMediaAlbum);
+
        class MediaItem;
        using MediaItemUPtr = std::unique_ptr<MediaItem>;
 }
index 8780e89d001a35790f9c30713927d42df12b5e7a..3f4af9305f61948990e1ad31a1d228ce47015c39 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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__
 
index 34d6d60bbcbf62949c39603044cf79fdf75cfc6d..73c804d9b1a829852ffe00136a73d8e37218c34e 100644 (file)
 
 #include "model/Gallery.h"
 
-#include "../common.h"
+#include "GalleryAlbum.h"
+
+#include "common.h"
 
 namespace gallery {
 
        using namespace ucl;
 
-       Gallery::Gallery()
+       Gallery::Gallery() :
+               m_isMediaDbConnected(false)
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
        }
 
        Gallery::~Gallery()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               if (m_isMediaDbConnected) {
+                       const int ret = media_content_disconnect();
+                       if (ret != 0) {
+                               WLOG("media_content_disconnect() failed: %d", ret);
+                       }
+               }
+       }
+
+       GallerySRef Gallery::newInstance()
+       {
+               auto result = makeShared<Gallery>();
+               FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+               return result;
+       }
+
+       Result Gallery::prepare()
+       {
+               const int ret = media_content_connect();
+               if (ret != 0) {
+                       LOG_RETURN(RES_FAIL, "media_content_connect() failed: %d", ret);
+               }
+
+               m_isMediaDbConnected = true;
+
+               m_album = GalleryAlbum::newInstance();
+               if (!m_album) {
+                       LOG_RETURN(RES_FAIL, "GalleryAlbum::newInstance() failed!");
+               }
+
+               return RES_OK;
        }
 
-       IMediaAlbum &Gallery::getAlbum()
+       IMediaAlbumSRef Gallery::getAlbum()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_album;
        }
 }
diff --git a/src/model/GalleryAlbum.cpp b/src/model/GalleryAlbum.cpp
new file mode 100644 (file)
index 0000000..a612f1d
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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"
+
+#include "model/MediaItem.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       using namespace ucl;
+
+       const auto CONDITION = TString("%s=%d OR %s=%d").format(
+                       MEDIA_TYPE, MEDIA_CONTENT_TYPE_IMAGE,
+                       MEDIA_TYPE, MEDIA_CONTENT_TYPE_VIDEO);
+}}}
+
+namespace gallery {
+
+       using namespace ucl;
+
+       GalleryAlbum::GalleryAlbum() :
+               m_filter(nullptr)
+       {
+       }
+
+       GalleryAlbum::~GalleryAlbum()
+       {
+               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_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,
+                               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;
+               }
+
+               return RES_OK;
+       }
+
+       Result GalleryAlbum::forEachMedia(EachCb cb) const
+       {
+               const int ret = media_info_foreach_media_from_db(m_filter,
+                       [](media_info_h media, void *user_data)
+                       {
+                               auto item = MediaItem::newInstance(media);
+                               if (!item) {
+                                       ELOG("MediaItem::newInstance() failed! Skipping");
+                                       return true;
+                               }
+                               return (*static_cast<EachCb *>(user_data))(std::move(item));
+                       },
+                       &cb);
+
+               if (ret != 0) {
+                       ELOG("media_info_foreach_media_from_db() failed: %d", ret);
+                       return RES_FAIL;
+               }
+
+               return RES_OK;
+       }
+}
diff --git a/src/model/GalleryAlbum.h b/src/model/GalleryAlbum.h
new file mode 100644 (file)
index 0000000..2df5900
--- /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 __GALLERY_MODEL_GALLERY_ALBUM_H__
+#define __GALLERY_MODEL_GALLERY_ALBUM_H__
+
+#include "model/IMediaAlbum.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(GalleryAlbum);
+
+       class GalleryAlbum final : public IMediaAlbum {
+       public:
+               static GalleryAlbumSRef newInstance();
+               virtual ~GalleryAlbum();
+
+               // IMediaAlbum //
+
+               virtual ucl::Result forEachMedia(EachCb cb) const final override;
+
+       private:
+               friend class ucl::RefCountObj<GalleryAlbum>;
+               GalleryAlbum();
+
+               ucl::Result prepare();
+
+       private:
+               filter_h m_filter;
+       };
+}
+
+#endif // __GALLERY_MODEL_GALLERY_ALBUM_H__
index df68d7a348e2bf6c1fb8f366db7d48ce8f469486..2352623f76b61da6d62cdf118b7955206ccf30b9 100644 (file)
 
 #include "model/MediaItem.h"
 
-#include "../common.h"
+#include "common.h"
 
 namespace gallery {
 
        using namespace ucl;
 
-       MediaItem::MediaItem(media_info_h info) :
-               m_type(MediaType::OTHER)
+       MediaItem::MediaItem(const MediaType type) :
+               m_type(type),
+               m_media(nullptr),
+               m_isValid(false)
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
        }
 
        MediaItem::~MediaItem()
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               cancelThumbnailPathGet();
+               freeMediaInfo();
+       }
+
+       MediaItemUPtr MediaItem::newInstance(const media_info_h media)
+       {
+               media_content_type_e contentType = MEDIA_CONTENT_TYPE_OTHERS;
+               const int ret = media_info_get_media_type(media, &contentType);
+               if (ret != 0) {
+                       LOG_RETURN_VALUE(RES_FAIL, {},
+                                       "media_info_get_media_type() failed: %d", ret);
+               }
+
+               MediaItemUPtr result{new MediaItem(toMediaType(contentType))};
+
+               FAIL_RETURN_VALUE(result->prepare(media), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       Result MediaItem::prepare(const media_info_h media)
+       {
+               FAIL_RETURN(initThumbPath(media), "initThumbPath() failed!");
+
+               if (isEmpty(m_thumbPath)) {
+                       const int ret = media_info_clone(&m_media, media);
+                       if (ret != 0) {
+                               m_media = nullptr;
+                               LOG_RETURN(RES_FAIL, "media_info_clone() failed: %d", ret);
+                       }
+               }
+
+               if (!getProperty(media, media_info_get_media_id, m_mediaId)) {
+                       LOG_RETURN(RES_FAIL, "getProperty(media_id) failed!");
+               }
+
+               if (!getProperty(media, media_info_get_file_path, m_filePath)) {
+                       LOG_RETURN(RES_FAIL, "getProperty(file_path) failed!");
+               }
+
+               m_isValid = true;
+
+               return RES_OK;
+       }
+
+       Result MediaItem::initThumbPath(media_info_h media) const
+       {
+               if (!getProperty(media, media_info_get_thumbnail_path,
+                               m_thumbPath, true)) {
+                       LOG_RETURN(RES_FAIL, "getProperty(thumbnail_path) failed!");
+               }
+               return RES_OK;
+       }
+
+       void MediaItem::freeMediaInfo() const
+       {
+               if (m_media) {
+                       const int ret = media_info_destroy(m_media);
+                       if (ret != 0) {
+                               WLOG("media_info_destroy() failed: %d", ret);
+                       }
+                       m_media = nullptr;
+               }
        }
 
        bool MediaItem::isValid() const
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_isValid;
        }
 
        MediaType MediaItem::getType() const
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_type;
        }
 
        const std::string &MediaItem::getFilePath() const
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               return m_filePath;
+       }
+
+       Result MediaItem::removeFile()
+       {
+               if (!ecore_file_can_write(m_filePath.c_str())) {
+                       LOG_RETURN(RES_FAIL, "File can't be removed!");
+               }
+
+               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);
+               }
+
+               freeMediaInfo();
+               m_isValid = false;
+
+               if (!ecore_file_remove(m_filePath.c_str())) {
+                       FLOG("ecore_file_remove() failed! Attemting to rescan....");
+                       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::getThumbnailPath(ThumbnailPathGetCb cb) const
+       Result MediaItem::getThumbnailPath(const ThumbnailPathGetCb &cb) const
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               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});
+
+               const int ret = media_info_create_thumbnail(m_media,
+                       CALLBACK_B(ThumbCbProxy::completeCb), cbProxy.get());
+               if (ret != 0) {
+                       LOG_RETURN(RES_FAIL, "media_info_clone() failed: %d", ret);
+               }
+
+               m_thumbCbProxy = std::move(cbProxy);
+
+               return RES_FALSE;
        }
 
        void MediaItem::cancelThumbnailPathGet() const
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               if (!m_thumbCbProxy) {
+                       return;
+               }
+
+               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();
        }
 
-       Result MediaItem::removeFile()
+       // ThumbCbProxy //
+
+       void MediaItem::ThumbCbProxy::completeCb(
+                       media_content_error_e error, const char *path)
        {
-               UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+               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->freeMediaInfo();
+               }
+
+               const auto proxy = std::move(*item->m_thumbCbProxy);
+
+               item->m_thumbCbProxy.reset();
+
+               proxy.callback(result, proxy.item->m_thumbPath);
        }
 }
diff --git a/src/model/common.h b/src/model/common.h
new file mode 100644 (file)
index 0000000..594f735
--- /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 "../common.h"
+
+#include "helpers.h"
+
+#endif // __GALLERY_MODEL_COMMON_H__
diff --git a/src/model/helpers.cpp b/src/model/helpers.cpp
new file mode 100644 (file)
index 0000000..c605e6a
--- /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.
+ */
+
+#include "helpers.h"
+
+#include "common.h"
+
+namespace gallery {
+
+       bool getProperty(media_info_h media,
+                       int (*get)(media_info_h media, char **value),
+                       std::string &result, const bool optional)
+       {
+               char *value = nullptr;
+               const int ret = get(media, &value);
+               if ((ret != 0) || (!optional && !value)) {
+                       ELOG("get() failed: %d", ret);
+                       return false;
+               }
+
+               if (value) {
+                       result = value;
+                       free(value);
+               } else {
+                       result.clear();
+               }
+
+               return true;
+       }
+}
+
diff --git a/src/model/helpers.h b/src/model/helpers.h
new file mode 100644 (file)
index 0000000..47f9724
--- /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_HELPERS_H__
+#define __GALLERY_MODEL_HELPERS_H__
+
+#include "model/types.h"
+
+namespace gallery {
+
+       MediaType toMediaType(media_content_type_e contentType);
+
+       bool getProperty(media_info_h media,
+                       int (*get)(media_info_h media, char **value),
+                       std::string &result, bool optional = false);
+}
+
+#include "helpers.hpp"
+
+#endif // __GALLERY_MODEL_HELPERS_H__
diff --git a/src/model/helpers.hpp b/src/model/helpers.hpp
new file mode 100644 (file)
index 0000000..be253bf
--- /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 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;
+       }
+}
index 5ed2def5e057931b875f96722e58bbdfbb0ebce4..30b1a23f79627d547d15e89d86cef3d85bf2eea6 100644 (file)
@@ -123,7 +123,7 @@ namespace gallery {
 
                HcombInfo(const int totalLength,
                                const std::array<LayoutTheme, 2> &slotThemes) :
-                       Info(slotThemes, {(totalLength / 2), ceilDiv<2>(totalLength)},
+                       Info(slotThemes, {{(totalLength / 2), ceilDiv<2>(totalLength)}},
                                (totalLength - 1), true),
                        totalLength(totalLength)
                {
@@ -356,11 +356,9 @@ namespace gallery {
                switch (type) {
                case Type::HCOMB_3X3:
                default: {
-                               static HcombInfo info{3, {
-                                       LayoutTheme(
-                                               "layout", "gallery_image_grid", "hcomb_3x3_even"),
-                                       LayoutTheme(
-                                               "layout", "gallery_image_grid", "hcomb_3x3_odd")}};
+                               static HcombInfo info{3, {{
+                                               {"layout", "gallery_image_grid", "hcomb_3x3_even"},
+                                               {"layout", "gallery_image_grid", "hcomb_3x3_odd"}}}};
                                return info;
                        }
                }
index 22bd3cb5e5946ee949c3e074e4731ad6cdb18dd9..90b78569ef46ad3f8ab04a92ab3c59798914ebc2 100644 (file)
@@ -1,8 +1,13 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.gallery" version="1.0.0">
-       <profile name="wearable"/>
-       <ui-application appid="org.tizen.gallery" exec="gallery" hw-acceleration="on" multiple="false" nodisplay="false" splash-screen-display="false" taskmanage="true" type="capp">
-               <label>gallery</label>
-               <icon>org.tizen.gallery.png</icon>
-       </ui-application>
-</manifest>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.gallery" version="1.0.0">\r
+       <profile name="wearable"/>\r
+       <ui-application appid="org.tizen.gallery" exec="gallery" hw-acceleration="on" multiple="false" nodisplay="false" splash-screen-display="false" taskmanage="true" type="capp">\r
+               <label>gallery</label>\r
+               <icon>org.tizen.gallery.png</icon>\r
+       </ui-application>\r
+       <privileges>\r
+               <privilege>http://tizen.org/privilege/mediastorage</privilege>\r
+               <privilege>http://tizen.org/privilege/externalstorage</privilege>\r
+               <privilege>http://tizen.org/privilege/content.write</privilege>\r
+       </privileges>\r
+</manifest>\r
index b332d8f392b37088b6d9ef2cc7cf80fbf8a37d6f..7969289871b703ac1c6472a821f1e8cd2a7a3378 100644 (file)
@@ -38,13 +38,13 @@ namespace ucl {
        template <class T>
        inline SharedRef<T> RefCountAware::asShared(T &obj)
        {
-               return obj.asShared<typename std::remove_cv<T>::type>();
+               return obj.template asShared<typename std::remove_cv<T>::type>();
        }
 
        template <class T>
        inline WeakRef<T> RefCountAware::asWeak(T &obj)
        {
-               return obj.asWeak<typename std::remove_cv<T>::type>();
+               return obj.template asWeak<typename std::remove_cv<T>::type>();
        }
 
        inline bool RefCountAware::isShared() const
index a9042811c75036a45524ed3468b68fedbb9688c6..8c059c0c8cd69e220a31c1f3a5ff3796eef3486d 100644 (file)
@@ -75,7 +75,10 @@ namespace ucl {
        constexpr const T &max(const T &a, const T &b);
 
        template <class T>
-       constexpr bool isPot(T value);
+       constexpr bool isPot(T value)
+       {
+               return (((value - 1) & value) == 0);
+       }
 
        template <uint MULTIPLE, class T>
        constexpr T ceilDiv(T value);
index a266c5d8d90513ed41786faf329dd05d30e433c8..a7606f81f8d9f207eeea023a04a92fe6b4375568 100644 (file)
@@ -26,6 +26,12 @@ namespace ucl {
                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);
@@ -36,12 +42,6 @@ namespace ucl {
                return (!value || (value[0] == '\0'));
        }
 
-       template <class T>
-       constexpr bool isNotEmpty(T &&value)
-       {
-               return !isEmpty(std::forward<T>(value));
-       }
-
        template <class T>
        constexpr bool isNotValid(T &&value)
        {
@@ -70,12 +70,6 @@ namespace ucl {
                return ((a > b) ? a : b);
        }
 
-       template <class T>
-       constexpr bool isPot(const T value)
-       {
-               return (((value - 1) & value) == 0);
-       }
-
        template <uint MULTIPLE, class T>
        constexpr T ceilDiv(T value)
        {
index f30d592be915042c54151758a6dfe0f4c16354d2..804a51301f78ca0a206afadae6e84a5ba6f6b63b 100644 (file)
                const ::ucl::Result __RESULT__ = (result); \
                if (isBad(__RESULT__)) { \
                        UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-                       return (value); \
+                       return value; \
                } \
        } while (false)
 
        do { \
                const ::ucl::Result __RESULT__ = (result); \
                UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
-               return (value); \
+               return value; \
        } while (false)
 
 #define UCL_LOG_RETURN_VOID(result, msg, ...) \
index 68280c04b18ef777b818c915249c93071c432104..69815a77e918a0ea52c6357311fd59884bb333cc 100644 (file)
@@ -65,8 +65,9 @@ namespace ucl {
                RES_IO_ERROR          = -5,
                RES_NOT_SUPPORTED     = -6,
                RES_INVALID_DATA      = -7,
+               RES_FATAL             = -8,
                // TODO MUST match previous item!
-               _RES_BEGIN            = RES_INVALID_DATA
+               _RES_BEGIN            = RES_FATAL
        };
 }
 
index 8f07ca43a35556d440e44cb9ad14fe901e01f963..b42875ed58ed7e65e93b21a30cf17abe47cf4387 100644 (file)
@@ -21,6 +21,7 @@
 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},