From: Soyoung Kim Date: Thu, 25 Oct 2012 10:17:48 +0000 (+0900) Subject: update test for wrt-commons_0.2.67 X-Git-Tag: submit/security-server/20121025.101816 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7b31057bdea9e2f5f75ef986f25b3f7b91fc6a7;p=platform%2Fframework%2Fweb%2Fwrt-commons.git update test for wrt-commons_0.2.67 --- diff --git a/debian/changelog b/debian/changelog index e1c3083..face727 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Wed, 24 Oct 2012 17:02:50 +0900 + wrt-commons (0.2.66) unstable; urgency=low * Release wrt-commons_0.2.66 diff --git a/etc/wrt_commons_create_clean_db.sh b/etc/wrt_commons_create_clean_db.sh index b5275a2..a9d9dc6 100755 --- a/etc/wrt_commons_create_clean_db.sh +++ b/etc/wrt_commons_create_clean_db.sh @@ -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 diff --git a/modules/localization/config.cmake b/modules/localization/config.cmake index 218cb71..80f77c4 100644 --- a/modules/localization/config.cmake +++ b/modules/localization/config.cmake @@ -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 diff --git a/modules/localization/include/dpl/localization/localization_utils.h b/modules/localization/include/dpl/localization/localization_utils.h index ed72233..f971f93 100644 --- a/modules/localization/include/dpl/localization/localization_utils.h +++ b/modules/localization/include/dpl/localization/localization_utils.h @@ -75,10 +75,4 @@ struct WidgetStartFileInfo typedef DPL::Optional OptionalWidgetIcon; typedef DPL::Optional 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 diff --git a/modules/localization/src/w3c_file_localization.cpp b/modules/localization/src/w3c_file_localization.cpp index 8e91255..c0ddc01 100644 --- a/modules/localization/src/w3c_file_localization.cpp +++ b/modules/localization/src/w3c_file_localization.cpp @@ -48,7 +48,6 @@ DPL::Optional 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); diff --git a/modules/utils/config.cmake b/modules/utils/config.cmake index ac46c1e..2b0beca 100644 --- a/modules/utils/config.cmake +++ b/modules/utils/config.cmake @@ -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 diff --git a/modules/utils/include/dpl/utils/wrt_utility.h b/modules/utils/include/dpl/utils/wrt_utility.h index 35b700c..91f08fd 100644 --- a/modules/utils/include/dpl/utils/wrt_utility.h +++ b/modules/utils/include/dpl/utils/wrt_utility.h @@ -14,45 +14,17 @@ * 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 + * @brief Common utility functions */ #ifndef _WRT_UTILITY_H_ #define _WRT_UTILITY_H_ -#include #include -#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_ diff --git a/modules/utils/src/folder_size.cpp b/modules/utils/src/folder_size.cpp index 47f8229..bc2afdb 100644 --- a/modules/utils/src/folder_size.cpp +++ b/modules/utils/src/folder_size.cpp @@ -22,9 +22,9 @@ */ #include -#include #include #include +#include #include #include @@ -34,60 +34,56 @@ #include 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 localDirs; - if ((dir=opendir(path.c_str())) == NULL) { - LogError("Cannot open dir " << path); + FTS *fts; + FTSENT *ftsent; + char * const paths[] = {const_cast(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; diff --git a/modules/utils/src/wrt_utility.cpp b/modules/utils/src/wrt_utility.cpp index e922211..fbe2f8a 100644 --- a/modules/utils/src/wrt_utility.cpp +++ b/modules/utils/src/wrt_utility.cpp @@ -14,67 +14,21 @@ * 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 + * @brief Implementation of some common utility functions */ -#include -#include -#include -#include #include -#include +#include #include +#include +#include +#include #include #include -#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(); diff --git a/packaging/wrt-commons.spec b/packaging/wrt-commons.spec index b9e10db..fca13c5 100644 --- a/packaging/wrt-commons.spec +++ b/packaging/wrt-commons.spec @@ -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