FIoRegistry.h => iniparser.h
authorull <ull@ull-Samsung-DeskTop-System.(none)>
Tue, 30 Jul 2013 02:25:23 +0000 (11:25 +0900)
committerull <ull@ull-Samsung-DeskTop-System.(none)>
Tue, 30 Jul 2013 05:07:30 +0000 (14:07 +0900)
Change-Id: I3d13ec00c7361eb83621c232a74421773174accc

packaging/osp-appfw.spec
res/common/opt/usr/etc/system-log.ini
src/CMakeLists.txt
src/base/FBaseSys.cpp [changed mode: 0644->0755]
src/base/inc/FBase_Log.h

index 447d580..606053f 100644 (file)
@@ -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
 
index f786f20..910e5ae 100755 (executable)
@@ -1,16 +1,16 @@
-#Suppression\r
+[Suppression]\r
 SUPPRESSION=\r
 \r
-#Application\r
+[Application]\r
 INFO=YES\r
 DEBUG=YES\r
 EXCEPTION=YES\r
 \r
-#Platform\r
+[Platform]\r
 INFO=YES\r
 EXCEPTION=YES\r
 \r
-#PlatformModules\r
+[PlatformModules]\r
 NID_APP=YES\r
 NID_BASE=YES\r
 NID_BASE_COL=YES\r
index efd0cd8..17ed1ca 100644 (file)
@@ -17,6 +17,7 @@ pkg_check_modules(pkgs REQUIRED
        heynoti
        badge
        icu-i18n
+       iniparser
        libpcre
        libsoup-2.4
        libxml-2.0
old mode 100644 (file)
new mode 100755 (executable)
index a560d93..cb72ea2
@@ -27,8 +27,6 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
-#include <FIoRegistry.h>
-#include <FIoFile.h>
 #include <FAppTypes.h>
 #include <FBaseLog.h>
 #include <FBaseSysLog.h>
 #include "FBase_StringConverter.h"
 #include "FApp_AppInfo.h"
 
+extern "C" {
+#include <iniparser.h>
+}
+
 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();
        }
 }
 
index 9b11e33..5f22cfc 100644 (file)
@@ -24,7 +24,6 @@
 #include <stdarg.h>
 #include <FOspConfig.h>
 #include <FBaseDataType.h>
-#include <FIoRegistry.h>
 
 #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_