TizenRefApp-8616 [Gallery] Fix handling URI with "file:" format 38/132138/2
authorIgor Nazarov <i.nazarov@samsung.com>
Thu, 1 Jun 2017 07:44:50 +0000 (10:44 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Thu, 1 Jun 2017 10:44:16 +0000 (13:44 +0300)
Change-Id: I3a3da953c5d7b2612c62874ee36615f6f395e04f

.cproject
src/model/MediaItem.cpp
src/model/internal.h
src/model/internal.hpp
tizen-manifest.xml

index 9fc259ce111915a8bac3996d4ea8b23e89968472..6fb27a34da307f7e4035c0f5c2f839427317193f 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                                <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-3.0-device.core_llvm37.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm37.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="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/asp/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
                                                                <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-3.0-device.core_llvm37.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-4.0-device.core_llvm37.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="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/asp/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/badge&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/base&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/cairo&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.1093880398" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
-                                                                       <listOptionValue builtIn="false" value="$(TC_COMPILER_MISC)"/>
-                                                                       <listOptionValue builtIn="false" value="$(RS_COMPILER_MISC)"/>
+                                                                       <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
+                                                                       <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
-                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;$(SBI_SYSROOT)&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&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">
                                                                <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">
-                                                                       <listOptionValue builtIn="false" value="$(TC_LINKER_MISC)"/>
-                                                                       <listOptionValue builtIn="false" value="$(RS_LINKER_MISC)"/>
+                                                                       <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
+                                                                       <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value="-pie -lpthread "/>
-                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;$(SBI_SYSROOT)&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;$(PROJ_PATH)/.exportMap&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-L&quot;$(SBI_SYSROOT)/usr/lib&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
                                                                        <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
                                                                </option>
                                                                <option id="gnu.cpp.link.option.paths.1681339654" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths"/>
index db7b222afdbada206c9cfbb11e570c3b1e686920..e0895153b42d37d1cba43a0bbdd8217d4cc6889f 100644 (file)
@@ -30,6 +30,7 @@ namespace gallery { namespace { namespace impl {
 
        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>;
 
@@ -208,6 +209,8 @@ namespace gallery {
 
        MediaItemSRef MediaItem::newInstance(std::string filePath)
        {
+               util::removePrefix(filePath, impl::URI_PREFIX_FILE);
+
                auto result = makeShared<MediaItem>(FLAGS_SIMPLE_FILE,
                                impl::getFileMediaType(filePath));
 
index 415a58c3e7df5ee8038163dba2886180ef0a3161..788e2ddec878cbace2c861fe47b5f7af6e37ba39 100644 (file)
@@ -45,7 +45,10 @@ namespace gallery { namespace util {
        std::string makeUniqueFilePath(const std::string &srcPath,
                        const std::string &dstDir);
 
-       bool beginsWith(const std::string &container, const std::string &str);
+       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 "internal.hpp"
index 90b8751dfeeeaf7845c517b52a0718849a676cd5..56efe642811d7a180d52f59f3889d5129f97964e 100644 (file)
@@ -32,8 +32,22 @@ namespace gallery {
 
 namespace gallery { namespace util {
 
-       inline bool beginsWith(const std::string &container, const std::string &str)
+       inline bool beginsWith(const std::string &str, const std::string &prefix,
+                       bool caseSensitive)
        {
-               return (container.compare(0, str.size(), str) == 0);
+               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;
        }
 }}
index 816fce797e51681d7236831db68eb35953694767..4003e6e89046023b5afd2af938b0597043c61aad 100644 (file)
@@ -1,19 +1,22 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
-<manifest xmlns="http://tizen.org/ns/packages" api-version="4.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" 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
-                       <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
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="org.tizen.gallery" version="1.0.0">
+       <profile name="wearable"/>
+       <ui-application appid="org.tizen.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>