From: ull Date: Tue, 30 Jul 2013 02:25:23 +0000 (+0900) Subject: FIoRegistry.h => iniparser.h X-Git-Tag: submit/tizen/20131210.080830^2^2~213^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2283727efe48325571b747e61adfea4e8c605c62;p=platform%2Fframework%2Fnative%2Fappfw.git FIoRegistry.h => iniparser.h Change-Id: I3d13ec00c7361eb83621c232a74421773174accc --- diff --git a/packaging/osp-appfw.spec b/packaging/osp-appfw.spec index 447d580..606053f 100644 --- a/packaging/osp-appfw.spec +++ b/packaging/osp-appfw.spec @@ -49,6 +49,7 @@ BuildRequires: pkgconfig(edbus) BuildRequires: pkgconfig(efreet) BuildRequires: pkgconfig(ethumb) BuildRequires: pkgconfig(icu-i18n) +BuildRequires: pkgconfig(iniparser) BuildRequires: pkgconfig(libpcre) BuildRequires: pkgconfig(libssl) BuildRequires: pkgconfig(libsoup-2.4) @@ -85,6 +86,7 @@ Requires: chromium Requires: message-port Requires: osp-env-config Requires: sqlite +Requires: iniparser Provides: libosp-appfw.so.1, libosp-newlib.so.1 diff --git a/res/common/opt/usr/etc/system-log.ini b/res/common/opt/usr/etc/system-log.ini index f786f20..910e5ae 100755 --- a/res/common/opt/usr/etc/system-log.ini +++ b/res/common/opt/usr/etc/system-log.ini @@ -1,16 +1,16 @@ -#Suppression +[Suppression] SUPPRESSION= -#Application +[Application] INFO=YES DEBUG=YES EXCEPTION=YES -#Platform +[Platform] INFO=YES EXCEPTION=YES -#PlatformModules +[PlatformModules] NID_APP=YES NID_BASE=YES NID_BASE_COL=YES diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index efd0cd8..17ed1ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,7 @@ pkg_check_modules(pkgs REQUIRED heynoti badge icu-i18n + iniparser libpcre libsoup-2.4 libxml-2.0 diff --git a/src/base/FBaseSys.cpp b/src/base/FBaseSys.cpp old mode 100644 new mode 100755 index a560d93..cb72ea2 --- a/src/base/FBaseSys.cpp +++ b/src/base/FBaseSys.cpp @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include #include #include @@ -36,6 +34,10 @@ #include "FBase_StringConverter.h" #include "FApp_AppInfo.h" +extern "C" { +#include +} + using namespace Tizen::Base; using namespace Tizen::Io; using namespace Tizen::Base::Collection; @@ -47,7 +49,11 @@ using namespace Tizen::App; #define LOG_TAG_NULL "" #endif +void __InitializeLogLevel(dictionary *pDic); +void __InitializePlatformModule(dictionary *pDic); + static const char LOG_TAG_ASSERT[] = "Assert"; +static const char FILE_DEBUGMODE[] = "/opt/etc/.debugmode"; bool iniLoaded = false; @@ -431,7 +437,7 @@ AppassertInternal(const char* pFunction, int lineNumber) char logTag[LOG_MODULE_NAME_LEN_MAX]; vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &appDebug); - platformDebug = File::IsFileExist( "/opt/etc/.debugmode"); + platformDebug = (0 == access(FILE_DEBUGMODE, F_OK)); snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", appName); logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0'; @@ -459,7 +465,7 @@ AppassertfInternal(const char* expr, const char* pFunction, int lineNumber, cons va_start(args, pFormat); vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &appDebug); - platformDebug = File::IsFileExist( "/opt/etc/.debugmode"); + platformDebug = (0 == access(FILE_DEBUGMODE, F_OK)); if( (platformDebug == false) && (appDebug == 0) ) { @@ -599,7 +605,7 @@ SysAssertInternal(const char* pFileName, int lineNumber, const char* pFunction) bool platformDebug; char logBody[LOG_LEN_MAX]; - platformDebug = File::IsFileExist( "/opt/etc/.debugmode"); + platformDebug = (0 == access(FILE_DEBUGMODE, F_OK)); if(!platformDebug) { @@ -620,7 +626,7 @@ SysAssertfInternal(const char* expr, const char* pFunction, int lineNumber, cons bool platformDebug; va_list args; - platformDebug = File::IsFileExist( "/opt/etc/.debugmode"); + platformDebug = (0 == access(FILE_DEBUGMODE, F_OK)); if(!platformDebug) { @@ -892,110 +898,119 @@ __InitializeLogInfo() { iniLoaded = true; - Registry reg; - - const String regPath(L"/opt/usr/etc/system-log.ini"); - - result r; + dictionary *pDic; + pDic = iniparser_load("/opt/usr/etc/system-log.ini"); - r = reg.Construct(regPath, REG_OPEN_READ_ONLY, 0); - - if (IsFailed(r)) + if (pDic == NULL) { ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] opening ini file failed.\n"); return; } - __InitializeLogLevel(reg); - __InitializePlatformModule(reg); + __InitializeLogLevel(pDic); + __InitializePlatformModule(pDic); + + iniparser_freedict(pDic); } void -__InitializeLogLevel(const Registry& reg) +__InitializeLogLevel(dictionary *pDic) { - const String sectApp(L"Application"); - const String sectPlatform(L"Platform"); + char sectApp[]="Application"; + char sectPlatform[]="Platform"; - const String entryInfo(L"INFO"); - const String entryDebug(L"DEBUG"); - const String entryException(L"EXCEPTION"); + char entryInfo[]="INFO"; + char entryDebug[]="DEBUG"; + char entryException[]="EXCEPTION"; - const String strYes(L"YES"); - String retString; + char strYes[]="YES"; + char *pVal; - result r; + char keyString[LOG_MODULE_NAME_LEN_MAX*2]; + int retVal; - r = reg.GetValue(sectApp, entryInfo, retString); - if (IsFailed(r)) + sprintf(keyString, "%s:%s", sectApp, entryInfo); + keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0'; + pVal = iniparser_getstr(pDic, keyString); + if (pVal == NULL) { ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/INFO failed.\n"); return; } - logInfo.applicationInfoEnabled = retString.Equals(strYes); - retString.Clear(); + retVal = strcmp(strYes, pVal); + logInfo.applicationInfoEnabled = (retVal == 0); - r = reg.GetValue(sectApp, entryDebug, retString); - if (IsFailed(r)) + sprintf(keyString, "%s:%s", sectApp, entryDebug); + keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0'; + pVal = iniparser_getstr(pDic, keyString); + if (pVal == NULL) { ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/DEBUG failed.\n"); return; } - logInfo.applicationDebugEnabled = retString.Equals(strYes); - retString.Clear(); + retVal = strcmp(strYes, pVal); + logInfo.applicationDebugEnabled = (retVal == 0); - r = reg.GetValue(sectApp, entryException, retString); - if (IsFailed(r)) + sprintf(keyString, "%s:%s", sectApp, entryException); + keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0'; + pVal = iniparser_getstr(pDic, keyString); + if (pVal == NULL) { ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/EXCEPTION failed.\n"); return; } - logInfo.applicationExceptionEnabled = retString.Equals(strYes); - retString.Clear(); + retVal = strcmp(strYes, pVal); + logInfo.applicationExceptionEnabled = (retVal == 0); - r = reg.GetValue(sectPlatform, entryInfo, retString); - if (IsFailed(r)) + sprintf(keyString, "%s:%s", sectPlatform, entryInfo); + keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0'; + pVal = iniparser_getstr(pDic, keyString); + if (pVal == NULL) { ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/INFO failed.\n"); return; } - logInfo.platformInfoEnabled = retString.Equals(strYes); - retString.Clear(); + retVal = strcmp(strYes, pVal); + logInfo.platformInfoEnabled = (retVal == 0); - r = reg.GetValue(sectPlatform, entryException, retString); - if (IsFailed(r)) + sprintf(keyString, "%s:%s", sectPlatform, entryException); + keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0'; + pVal = iniparser_getstr(pDic, keyString); + if (pVal == NULL) { ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/EXCEPTION failed.\n"); return; } - logInfo.platformExceptionEnabled = retString.Equals(strYes); - retString.Clear(); + retVal = strcmp(strYes, pVal); + logInfo.platformExceptionEnabled = (retVal == 0); } void -__InitializePlatformModule(const Registry& reg) +__InitializePlatformModule(dictionary *pDic) { - const String strYes(L"YES"); - String retString; + char sectModule[]="PlatformModules"; + char strYes[]="YES"; - const String sectModule(L"PlatformModules"); + char *pVal; + int retVal; - result r; + char keyString[LOG_MODULE_NAME_LEN_MAX*2]; for (int i = 0; i < NID_MAX; i++) { - String strEntry(logInfo.logTable[i].logIDName); - r = reg.GetValue(sectModule, strEntry, retString); - if (IsFailed(r)) + + sprintf(keyString, "%s:%s", sectModule, logInfo.logTable[i].logIDName); + keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0'; + pVal = iniparser_getstr(pDic, keyString); + if (pVal == NULL) { - ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding PlatformModules/%ls failed.\n", strEntry.GetPointer()); + ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding PlatformModules/%ls failed.\n", logInfo.logTable[i].logIDName); } else { - logInfo.logTable[i].loggingEnabled = retString.Equals(strYes); + retVal = strcmp(strYes, pVal); + logInfo.logTable[i].loggingEnabled = (retVal == 0); } - - strEntry.Clear(); - retString.Clear(); } } diff --git a/src/base/inc/FBase_Log.h b/src/base/inc/FBase_Log.h index 9b11e33..5f22cfc 100644 --- a/src/base/inc/FBase_Log.h +++ b/src/base/inc/FBase_Log.h @@ -24,7 +24,6 @@ #include #include #include -#include #ifdef __cplusplus extern "C" { @@ -87,10 +86,8 @@ const char* __GetModuleName(LogID id); bool __GetEnableInfo(LogID id); void __InitializeLogInfo(void); -void __InitializeLogLevel(const Tizen::Io::Registry& reg); -void __InitializePlatformModule(const Tizen::Io::Registry& reg); #ifdef __cplusplus } #endif // __cplusplus -#endif // _FBASE_INTERNAL_LOG_H_ \ No newline at end of file +#endif // _FBASE_INTERNAL_LOG_H_