update test for wrt-commons_0.2.67 submit/security-server/20121025.101816
authorSoyoung Kim <sy037.kim@samsung.com>
Thu, 25 Oct 2012 10:17:48 +0000 (19:17 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Thu, 25 Oct 2012 10:17:48 +0000 (19:17 +0900)
debian/changelog
etc/wrt_commons_create_clean_db.sh
modules/localization/config.cmake
modules/localization/include/dpl/localization/localization_utils.h
modules/localization/src/w3c_file_localization.cpp
modules/utils/config.cmake
modules/utils/include/dpl/utils/wrt_utility.h
modules/utils/src/folder_size.cpp
modules/utils/src/wrt_utility.cpp
packaging/wrt-commons.spec

index e1c3083cd63914a09156f056001867b6282c121d..face727012e2a698a30cc230bac8cf1ea8d962eb 100644 (file)
@@ -1,3 +1,18 @@
+wrt-commons (0.2.67) unstable; urgency=low
+
+  * Localization cleaning from unused API (restore)
+  * Removing old, unused _WrtUtil* functions
+  * Database reset affects security-server
+  * Removing FileUtils
+  * Replacing recursive opendir with fts
+
+  * Release wrt-commons_0.2.67
+
+  * Git : framework/web/wrt-commons
+  * Tag : wrt-commons_0.2.67
+
+ -- Soyoung Kim <sy037.kim@samsung.com>  Wed, 24 Oct 2012 17:02:50 +0900
+
 wrt-commons (0.2.66) unstable; urgency=low
 
   * Release wrt-commons_0.2.66
index b5275a29b2fb1b91808466ba4276d41fc43fe5ea..a9d9dc65b36e61286033231dd3fa51f2ab38ef5e 100755 (executable)
@@ -27,6 +27,7 @@ do
     chown 0:6026 /opt/dbspace/.$name.db-journal
     chmod 660 /opt/dbspace/.$name.db
     chmod 660 /opt/dbspace/.$name.db-journal
+    pkill -9 security-serv
 done
 
 
index 218cb712e9bb574f0ec255297b924e95e256c2a4..80f77c4950dd78aef7cba7c93e9fb3a6029cb77b 100644 (file)
@@ -20,7 +20,6 @@
 #
 
 SET(DPL_LOCALIZATION_SOURCES
-    ${PROJECT_SOURCE_DIR}/modules/localization/src/localization_utils.cpp
     ${PROJECT_SOURCE_DIR}/modules/localization/src/w3c_file_localization.cpp
     ${PROJECT_SOURCE_DIR}/modules/localization/src/LanguageTagsProvider.cpp
     PARENT_SCOPE
index ed72233c8769d88ac3165f102ebdd1e43183f256..f971f93ee97c912ab739bfe62d5fa26419754d70 100644 (file)
@@ -75,10 +75,4 @@ struct WidgetStartFileInfo
 typedef DPL::Optional<WidgetIcon> OptionalWidgetIcon;
 typedef DPL::Optional<WidgetStartFileInfo> OptionalWidgetStartFileInfo;
 
-namespace LocalizationUtils {
-/* Function below is deprecated - please use static functions of LanguageTagsProvider:
- * BCP47LanguageTagToLocale() and LocaleToBCP47LanguageTag() */
-DPL::String BCP47LanguageTagToLocale(const DPL::String&) __attribute__((deprecated));
-
-}
 #endif //LOCALIZATION_UTILS_H
index 8e91255ea55d94288a294118d75ec9ec967a82d6..c0ddc0155ce25753d610813560e90bd7043435f9 100644 (file)
@@ -48,7 +48,6 @@ DPL::Optional<std::string> GetFilePathInWidgetPackageInternal(
         std::string filePath)
 {
     LogDebug("Looking for file: " << filePath << "  in: " << basePath);
-    using namespace LocalizationUtils;
 
     const LanguageTags& ltags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
 
@@ -162,8 +161,6 @@ DPL::OptionalString getStartFile(const WrtDB::DbWidgetHandle handle)
 
 DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao)
 {
-    using namespace LocalizationUtils;
-
     WidgetDAOReadOnly::LocalizedStartFileList locList = dao->getLocalizedStartFileList();
     WidgetDAOReadOnly::WidgetStartFileList list = dao->getStartFileList();
     LanguageTags tagsList = LanguageTagsProviderSingleton::Instance().getLanguageTags();
@@ -193,7 +190,6 @@ DPL::OptionalString getStartFile(WrtDB::WidgetDAOReadOnlyPtr dao)
 
 OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle)
 {
-    using namespace LocalizationUtils;
     WidgetDAOReadOnly dao(widgetHandle);
 
     WidgetDAOReadOnly::WidgetLocalizedIconList locList = dao.getLocalizedIconList();
@@ -230,7 +226,6 @@ OptionalWidgetIcon getIcon(const WrtDB::DbWidgetHandle widgetHandle)
 WidgetIconList getValidIconsList(
         WrtDB::DbWidgetHandle widgetHandle)
 {
-    using namespace LocalizationUtils;
     WidgetDAOReadOnly dao(widgetHandle);
     WidgetDAOReadOnly::WidgetIconList list = dao.getIconList();
 
@@ -255,8 +250,6 @@ WidgetIconList getValidIconsList(
 OptionalWidgetStartFileInfo getStartFileInfo(
         WrtDB::DbWidgetHandle widgetHandle)
 {
-    using namespace LocalizationUtils;
-
     WidgetStartFileInfo info;
 
     WidgetDAOReadOnly dao(widgetHandle);
index ac46c1e138a0852897b1f91043e257604ab7d184..2b0beca797aa0a6f0e3ce4d09e9aa22cabd802c0 100644 (file)
@@ -21,7 +21,6 @@
 
 SET(DPL_UTILS_SOURCES
     ${PROJECT_SOURCE_DIR}/modules/utils/src/bash_utils.cpp
-    ${PROJECT_SOURCE_DIR}/modules/utils/src/file_utils.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/folder_size.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/mime_type_utils.cpp
     ${PROJECT_SOURCE_DIR}/modules/utils/src/warp_iri.cpp
@@ -34,7 +33,6 @@ SET(DPL_UTILS_SOURCES
 
 SET(DPL_UTILS_HEADERS
     ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/bash_utils.h
-    ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/file_utils.h
     ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/folder_size.h
     ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/mime_type_utils.h
     ${PROJECT_SOURCE_DIR}/modules/utils/include/dpl/utils/warp_iri.h
index 35b700cb48061435a7a1b7cf1cd1afce4c685cd1..91f08fd1a2cfeecd359258b9ed4ae189ddf364d6 100644 (file)
  *    limitations under the License.
  */
 /**
- * @file    wrt_utility.h
- * @version    0.6
- * @author    Wei Dong(d.wei@samsung.com)
- * @author    Ma Quan(jason.ma@samsung.com)
- * @brief     Header file of widget manager common functions
+ * @file        wrt_utility.h
+ * @version     0.8
+ * @author      Janusz Majnert <j.majnert@samsung.com>
+ * @brief       Common utility functions
  */
 
 #ifndef _WRT_UTILITY_H_
 #define _WRT_UTILITY_H_
 
-#include <stdbool.h>
 #include <sys/stat.h>
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**
- * File options
- */
-enum
-{
-    WRT_FILEUTILS_RECUR = 4 //this is the default for almost all WrtMakeDir calls (once called with 0)
-};
-
-/**
- * Combine the parentPath and fileName into a new absolute file name.
- *
- * @param[out]    absolutePath
- * @param[in]    parentPath
- * @param[in]    fileName
- *
- * @return    if success, return true; or return false.
- */
-bool _WrtUtilSetAbsolutePath(char* absolutePath,
-        const char* parentPath,
-        const char* fileName);
-
 /**
  * Joins two paths into one
  *
@@ -65,21 +37,6 @@ bool _WrtUtilSetAbsolutePath(char* absolutePath,
  */
 void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std::string &child);
 
-/**
- * This function is used to make a directory.
- * it's neccessary to free the returned dir path.
- *
- * @param[in] path    Specified the directory path
- * @param[in] mode    Operation mode the you want to set
- * @param[in] flags   WRT_FILEUTILS_RECUR if you want to make parent's directory recusively,
- *                    WRT_FILEUTILS_NONE if not.
- *
- * @return    TRUE on success or FALSE on failure.
- */
-bool _WrtMakeDir (const char *path,
-        long mode,
-        int flags);
-
 /**
  * Creates directories specified by path
  *
@@ -94,15 +51,6 @@ bool _WrtMakeDir (const char *path,
  */
 bool WrtUtilMakeDir(const std::string &newpath, mode_t mode=0755);
 
-/**
- * This function is used to remove a directory from the file system.
- *
- * @param[in]  path    Specified the directory path
- *
- * @return    TRUE on success or FALSE on failure.
- */
-bool _WrtUtilRemoveDir(const char* path);
-
 /**
  * This function removes the directory or file pointed to by path
  *
@@ -112,17 +60,6 @@ bool _WrtUtilRemoveDir(const char* path);
  */
 bool WrtUtilRemove(const std::string &path);
 
-/**
- * This function is used to convert a string to lowercase.
- *
- * @param[in]  str            the string need to be converted.
- * @param[in]  lowerStr    the converted string.
- *
- * @return    TRUE on success or FALSE on failure.
- */
-bool _WrtUtilStringToLower(const char* str,
-        char** lowerStr);
-
 /**
  * This function converts a string to lowercase
  *
@@ -152,9 +89,5 @@ bool WrtUtilFileExists(const std::string &path);
  */
 bool WrtUtilDirExists(const std::string &path);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif //_WRT_UTILITY_H_
 
index 47f8229a54b892fc9710b5e7c33bc77e45c591a5..bc2afdb28be192e99cbb8732bc935e79fc2a760c 100644 (file)
@@ -22,9 +22,9 @@
  */
 
 #include <string.h>
-#include <dirent.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <fts.h>
 
 #include <sstream>
 #include <vector>
 #include <dpl/utils/folder_size.h>
 
 namespace Utils {
-namespace {
-
-size_t getObjectSize(const std::string& path)
-{
-    struct stat tmp;
-
-    if (stat(path.c_str(), &tmp) == -1) {
-        LogError("Failed to open file" << path);
-        return 0;
-    }
-    //it is not a file nor a directory
-    //not counting
-    if (!S_ISDIR(tmp.st_mode) && !S_ISREG(tmp.st_mode)) {
-        LogWarning("Not a regular file nor a directory: " << path);
-        return 0;
-    }
-    return tmp.st_size;
-}
-}
 
 size_t getFolderSize(const std::string& path)
 {
     size_t size = 0;
-
-    DIR *dir;
-    std::vector<std::string> localDirs;
-    if ((dir=opendir(path.c_str())) == NULL) {
-        LogError("Cannot open dir " << path);
+    FTS *fts;
+    FTSENT *ftsent;
+    char * const paths[] = {const_cast<char * const>(path.c_str()), NULL};
+
+    if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) {
+        //ERROR
+        int error = errno;
+        LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: "
+                << strerror(error));
         return 0;
     }
-    struct dirent* el;
-    while ((el = readdir(dir)) != 0) {
-        if (strcmp(el->d_name, ".") == 0 || strcmp(el->d_name, "..") == 0) {
-            continue;
-        }
-        struct stat tmp;
-        std::string local = path + el->d_name;
-        if (stat(local.c_str(), &tmp) == -1) {
-            LogError("Failed to open file " << local);
-            char* errstring = strerror(errno);
-            LogError("Reason: " << errstring);
-            continue;
-        }
 
-        size += getObjectSize(local);
-        if (S_ISDIR(tmp.st_mode)) {
-            localDirs.push_back(local + "/");
+    while ((ftsent = fts_read(fts)) != NULL) {
+        switch (ftsent->fts_info) {
+            case FTS_DP:
+            case FTS_DC:
+                //directory in postorder and directory causing a loop
+                break;
+            case FTS_F:
+            case FTS_D:
+            case FTS_NSOK:
+            case FTS_SL:
+            case FTS_SLNONE:
+            case FTS_DEFAULT:
+                //regular files and other objects that can be counted
+                size += ftsent->fts_statp->st_size;
+                break;
+            case FTS_NS:
+            case FTS_DOT:
+            case FTS_DNR:
+            case FTS_ERR:
+            default:
+                LogWarning(__PRETTY_FUNCTION__
+                        << ": traversal failed on file: "
+                        << ftsent->fts_path
+                        << " with error: "
+                        << strerror(ftsent->fts_errno));
+                return 0;
         }
     }
 
-    closedir(dir);
-
-    FOREACH (localDir, localDirs) {
-        size += getFolderSize(*localDir);
+    if (fts_close(fts) == -1) {
+        int error = errno;
+        LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
+                << strerror(error));
+        return 0;
     }
 
     return size;
index e9222114a9b3b7f95a1cccf539b5f52863953745..fbe2f8a52236fc2a78eba3f39d75a3bb9b96b54c 100644 (file)
  *    limitations under the License.
  */
 /**
- * @file       wrt_utility.cpp
- * @version    0.6
- * @author Wei Dong(d.wei@samsung.com)
- * @author Ma Quan(jason.ma@samsung.com)
- * @brief  This file implemented some common functions for widget manager
+ * @file        wrt_utility.cpp
+ * @version     0.8
+ * @author      Janusz Majnert <j.majnert@samsung.com>
+ * @brief       Implementation of some common utility functions
  */
 
-#include <stdio.h>
-#include <dirent.h>
-#include <errno.h>
-#include <libgen.h>
 #include <fts.h>
-#include <sys/types.h>
+#include <string>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <ctype.h>
 #include <dpl/log/log.h>
 #include <dpl/utils/wrt_utility.h>
 
-#ifndef MAX_WIDGET_PATH_LENGTH
-#define MAX_WIDGET_PATH_LENGTH    1024
-#endif
-
-//will be replaced by WrtUtilJoinPaths
-bool _WrtUtilSetAbsolutePath(char* absolutePath,
-        const char* parentPath,
-        const char* fileName)
-{
-    int len;
-    if (NULL == absolutePath || NULL == parentPath || NULL == fileName) {
-        return false;
-    }
-    len = strlen(parentPath);
-    if (len > 0) {
-        // not check the valid of parentPath and fileName.
-        if (parentPath[len - 1] == '/') {
-            snprintf(absolutePath,
-                     MAX_WIDGET_PATH_LENGTH,
-                     "%s%s",
-                     parentPath,
-                     fileName);
-        } else {
-            snprintf(absolutePath,
-                     MAX_WIDGET_PATH_LENGTH,
-                     "%s/%s",
-                     parentPath,
-                     fileName);
-        }
-    } else {
-        LogDebug("The parent path is null");
-        return false;
-    }
-
-    //some widget use Windows notation. We need to change '\' to '/'
-    for (int i = 0; absolutePath[i] != 0; ++i) {
-        if (absolutePath[i] == '\\') {
-            absolutePath[i] = '/';
-        }
-    }
-
-    return true;
-}
-
 void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std::string &child)
 {
     size_t parent_len = parent.length();;
@@ -91,53 +45,6 @@ void WrtUtilJoinPaths(std::string &joined, const std::string &parent, const std:
     }
 }
 
-// check it deeply later.
-bool _WrtMakeDir (const char *path,
-        long mode,
-        int flags)
-{
-    if (NULL == path) {
-        return false;
-    }
-
-    const int defaultMode = 0777;
-    if (!(flags & WRT_FILEUTILS_RECUR)) {
-        if (mkdir(path, defaultMode) < 0) {
-            LogDebug("Failed to make dir " << path);
-            return false;
-        }
-        if (mode != -1 && chmod(path, mode) < 0) {
-            LogDebug("Failed to chmod");
-            remove(path);
-            return false;
-        }
-    } else {
-        struct stat st;
-        if (stat(path, &st) < 0 && errno == ENOENT) {
-            bool ret;
-            char *buf = NULL;
-            char *parent = NULL;
-            //            mode_t mask;
-
-            //            mask = umask (0);
-            //            umask (mask);
-
-            buf = strdup(path);
-            parent = dirname(buf);
-            //ret = _WrtMakeDir(parent, (defaultMode & ~mask) | 0300, WRT_FILEUTILS_RECUR);
-            ret = _WrtMakeDir(parent, (defaultMode) | 0300, WRT_FILEUTILS_RECUR);
-            free(buf);
-
-            if ((!ret) || (!_WrtMakeDir(path, mode, 0))) {
-                LogDebug("Failed to _WrtMakeDir");
-                return false;
-            }
-        }
-    }
-
-    return true;
-}
-
 bool WrtUtilMakeDir(const std::string &newpath, mode_t mode)
 {
     size_t pos = 0;
@@ -163,71 +70,6 @@ bool WrtUtilMakeDir(const std::string &newpath, mode_t mode)
     return true;
 }
 
-// will be replaced with the latter function
-bool _WrtUtilRemoveDir(const char* path)
-{
-    DIR* dir = NULL;
-    struct dirent* ptr = NULL;
-    char childPath[MAX_WIDGET_PATH_LENGTH + 1] = { 0 };
-    if (path == NULL) {
-        LogWarning("Path is null");
-        return false;
-    }
-    dir = opendir(path);
-    if (NULL != dir) {
-        while ((ptr = readdir(dir)) != NULL) {
-            if ((!strcmp(ptr->d_name, ".")) || (!strcmp(ptr->d_name, ".."))) {
-                continue;
-            }
-            int len = strlen(path);
-            if (path[len - 1] == '/') {
-                snprintf(childPath,
-                         MAX_WIDGET_PATH_LENGTH,
-                         "%s%s",
-                         path,
-                         ptr->d_name);
-            } else {
-                snprintf(childPath,
-                         MAX_WIDGET_PATH_LENGTH,
-                         "%s/%s",
-                         path,
-                         ptr->d_name);
-            }
-            if (ptr->d_type == DT_DIR) {
-                if (!_WrtUtilRemoveDir(childPath)) {
-                    closedir(dir);
-                    return false;
-                }
-            } else {
-                if (unlink(childPath) != 0) {
-                    closedir(dir);
-                    LogWarning("Failed to remove file " << childPath);
-                    return false;
-                }
-            }
-        }
-        closedir(dir);
-    } else if (errno == ENOTDIR) {
-        if (unlink(path) != 0) {
-            LogWarning("Failed to remove file " << path);
-            return false;
-        }
-        return true;
-    } else if (errno == ENOENT) { //not exist
-        LogWarning("Cannot remove non existent directory " << path);
-        return true;
-    } else {
-        LogWarning("Can't remove directory " << path);
-        return false;
-    }
-    if (rmdir(path) != 0) {
-        LogWarning("Removing directory failed :" << path << " errno: " << errno);
-        return false;
-    }
-
-    return true;
-}
-
 bool WrtUtilRemove(const std::string &path)
 {
     FTS *fts;
@@ -303,35 +145,6 @@ bool WrtUtilRemove(const std::string &path)
     return rv;
 }
 
-// shall be replaced with the latter function
-bool _WrtUtilStringToLower(const char* str, char** lowerStr)
-{
-    if (!str || !lowerStr) {
-        return true;
-    }
-
-    char* cur = NULL;
-    int length = strlen(str);
-
-    *lowerStr = (char*)malloc(length + 1);
-
-    if (!(*lowerStr)) {
-        return false;
-    }
-
-    memset(*lowerStr, 0, length + 1);
-    strncpy(*lowerStr, str, length);
-
-    cur = *lowerStr;
-
-    while (*str != '\0') {
-        *cur++ = tolower(*str++);
-        //cur++;
-    }
-
-    return true;
-}
-
 void WrtUtilStringToLower(std::string &out, const std::string &in)
 {
     out.clear();
index b9e10db9f49ee79e6cd7db4ed7c8ecac84b237fb..fca13c503fc939307214541da174819bcd1d1891 100644 (file)
@@ -1,7 +1,7 @@
-#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.66
+#sbs-git:slp/pkgs/w/wrt-commons wrt-commons 0.2.67
 Name:       wrt-commons
 Summary:    Wrt common library
-Version:    0.2.66
+Version:    0.2.67
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0