[Messaging] msg-service uses single global database file.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 13 Jan 2016 13:39:40 +0000 (14:39 +0100)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 13 Jan 2016 13:39:40 +0000 (14:39 +0100)
Added better handling for DB errors.
Added hardcoded path to msg-service database file.

Change-Id: Iacd218a33516d4c09964027e73cd6014a02bbc95
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
packaging/webapi-plugins.spec
src/messaging/messaging.gyp
src/messaging/messaging_database_manager.cc
src/messaging/messaging_database_manager.h

index f268a55..c2dd5f0 100644 (file)
@@ -290,7 +290,6 @@ BuildRequires: pkgconfig(capi-appfw-app-manager)
 BuildRequires: pkgconfig(capi-appfw-package-manager)
 BuildRequires: pkgconfig(capi-content-media-content)
 BuildRequires: pkgconfig(capi-media-metadata-extractor)
-BuildRequires: pkgconfig(libtzplatform-config)
 
 %if %{with wayland}
 %define display_type wayland
index 7edb5a6..7c76c44 100644 (file)
@@ -22,7 +22,6 @@
             'tapi',
             'vconf',
             'db-util',
-            'libtzplatform-config',
         ],
       },
       'sources': [
index b4ff9c1..2452823 100755 (executable)
@@ -24,7 +24,6 @@
 
 #include <msg_storage.h>
 #include <email-api.h>
-#include <tzplatform_config.h>
 
 #include "common/logger.h"
 #include "common/platform_exception.h"
@@ -205,13 +204,13 @@ msg_error_t MessagingDatabaseManager::connect()
         char strDBName[64];
 
         memset(strDBName, 0x00, sizeof(strDBName));
-        snprintf(strDBName, sizeof(strDBName), "%s/%s",
-                 tzplatform_getenv(TZ_USER_DB), MSG_DB_NAME);
+        snprintf(strDBName, sizeof(strDBName), "%s", MSG_DB_NAME);
 
         int err = db_util_open(strDBName, &sqlHandle, DB_UTIL_REGISTER_HOOK_METHOD);
 
         if (SQLITE_OK != err) {
-            LoggerE("DB connecting fail [%d]", err);
+            LoggerE("Failed to connect to database '%s', error: [%d]", strDBName, err);
+            sqlHandle = nullptr;
             return MSG_ERR_DB_CONNECT;
         }
 
@@ -251,8 +250,11 @@ msg_error_t MessagingDatabaseManager::getTable(std::string sqlQuery,
     *resultsCount = 0;
 
     freeTable(results);
-    connect();
 
+    if (MSG_SUCCESS != connect()) {
+        LoggerE("Failed to connect to database.");
+        return MSG_ERR_DB_CONNECT;
+    }
 
     char* error_msg = NULL;
     err = sqlite3_get_table(sqlHandle, sqlQuery.c_str(), results,
index 91977c1..561de9a 100755 (executable)
@@ -32,7 +32,7 @@ namespace extension {
 namespace messaging {
 
 // =================================================================
-#define MSG_DB_NAME                     ".msg_service.db"
+#define MSG_DB_NAME                     "/usr/dbspace/.msg_service.db"
 #define MSG_MESSAGE_TABLE_NAME          "MSG_MESSAGE_TABLE"
 #define MSG_FOLDER_TABLE_NAME           "MSG_FOLDER_TABLE"
 #define MSG_ADDRESS_TABLE_NAME          "MSG_ADDRESS_TABLE"