Initial refactoring merge 91/19091/1 accepted/tizen_3.0.2014.q3_common accepted/tizen_3.0.m14.3_ivi accepted/tizen_generic accepted/tizen_ivi_panda tizen_3.0.2014.q3_common tizen_3.0.2014.q4_common tizen_3.0.2015.q1_common tizen_3.0.m14.2_ivi tizen_3.0.m14.3_ivi tizen_3.0_ivi accepted/tizen/generic/20140408.094752 accepted/tizen/ivi/20140410.192308 accepted/tizen/ivi/panda/20140408.203207 accepted/tizen/mobile/20140409.082618 submit/tizen/20140408.080407 submit/tizen_mobile/20141120.000000 tizen_3.0.2014.q3_common_release tizen_3.0.m14.2_ivi_release tizen_3.0.m14.3_ivi_release tizen_3.0_ivi_release
authorDongchul Lim <dc7.lim@samsung.com>
Mon, 7 Apr 2014 10:48:18 +0000 (19:48 +0900)
committerDongchul Lim <dc7.lim@samsung.com>
Mon, 7 Apr 2014 10:48:37 +0000 (19:48 +0900)
Change-Id: I6ca834add7dfde7081365675100a185fd262a186

AUTHORS [deleted file]
CMakeLists.txt
packaging/tel-plugin-database.spec
src/database_main.c [changed mode: 0644->0755]

diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644 (file)
index 0e9faa9..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,6 +0,0 @@
-Jongman Park <jman.park@samsung.com>
-Ja-young Gu <jygu@samsung.com>
-Kyeongchul Kim <kyeongchul.kim@samsung.com>
-DongHoo Park <donghoo.park@samsung.>
-Youngman Park <youngman.park@samsung.com>
-Inho Oh <inho48.oh@samsung.com>
index 161d60b..0c6de60 100644 (file)
@@ -28,9 +28,7 @@ ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"TEL_PLUGIN_DATABASE\"")
 MESSAGE(${CMAKE_C_FLAGS})
 MESSAGE(${CMAKE_EXE_LINKER_FLAGS})
 
-SET(SRCS
-               src/database_main.c
-)
+SET(SRCS src/database_main.c)
 
 
 # library build
index a090118..a319c86 100644 (file)
@@ -1,6 +1,10 @@
-Name:       tel-plugin-database
-Summary:    Telephony DataBase storage plugin
-Version:    0.1.7
+%define major 3
+%define minor 0
+%define patchlevel 1
+
+Name: tel-plugin-database
+Summary: Telephony DataBase storage plugin
+Version:    %{major}.%{minor}.%{patchlevel}
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
old mode 100644 (file)
new mode 100755 (executable)
index 471e4bf..c33e6c5
@@ -1,9 +1,7 @@
 /*
  * tel-plugin-database
  *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: DongHoo Park <donghoo.park@samsung.com>
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +14,6 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 #include <stdio.h>
@@ -31,7 +28,7 @@
 #include <plugin.h>
 #include <storage.h>
 
-static void* create_handle(Storage *strg, const char *path)
+static void *create_handle(TcoreStorage *strg, const char *path)
 {
        int rv = 0;
        sqlite3 *handle = NULL;
@@ -46,10 +43,12 @@ static void* create_handle(Storage *strg, const char *path)
        return handle;
 }
 
-static gboolean remove_handle(Storage *strg, void *handle)
+static gboolean remove_handle(TcoreStorage *strg, void *handle)
 {
-       if (!handle)
+       if (!handle) {
+               err("handle is null");
                return FALSE;
+       }
 
        db_util_close(handle);
        //free(handle);
@@ -58,21 +57,21 @@ static gboolean remove_handle(Storage *strg, void *handle)
        return TRUE;
 }
 
-static gboolean update_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param)
+static gboolean update_query_database(TcoreStorage *strg, void *handle,
+               const char *query, GHashTable *in_param)
 {
        int rv = 0;
        sqlite3_stmt* stmt = NULL;
-       char szQuery[1000+1];   // +1 is for NULL Termination Character '\0'
-
+       char sz_query[1000+1] = {0, };
        GHashTableIter iter;
        gpointer key, value;
 
        dbg("update query");
 
-       memset(szQuery, '\0', 1001);
-       strncpy(szQuery, query, 1000);
+       memset(sz_query, '\0', 1001);
+       strncpy(sz_query, query, 1000);
 
-       rv = sqlite3_prepare_v2(handle, szQuery, strlen(szQuery), &stmt, NULL);
+       rv = sqlite3_prepare_v2(handle, sz_query, strlen(sz_query), &stmt, NULL);
        if (rv != SQLITE_OK) {
                err("fail to connect to table (%d)", rv);
                return FALSE;
@@ -85,15 +84,16 @@ static gboolean update_query_database(Storage *strg, void *handle, const char *q
                if (!value || g_strcmp0((const char*) value, "") == 0) {
                        dbg("bind null");
                        rv = sqlite3_bind_null(stmt, atoi((const char*) key));
-               }
-               else {
+               } else {
                        dbg("bind value");
-                       rv = sqlite3_bind_text(stmt, atoi((const char*) key), (const char*) value, strlen((const char*) value),
+                       rv = sqlite3_bind_text(stmt, atoi((const char*) key),
+                                       (const char*) value,
+                                       strlen((const char*) value),
                                        SQLITE_STATIC);
                }
 
                if (rv != SQLITE_OK) {
-                       dbg("fail to bind data (%d)", rv);
+                       err("fail to bind data (%d)", rv);
                        return FALSE;
                }
        }
@@ -109,22 +109,22 @@ static gboolean update_query_database(Storage *strg, void *handle, const char *q
        return TRUE;
 }
 
-static gboolean read_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param,
+static gboolean read_query_database(TcoreStorage *strg, void *handle,
+               const char *query, GHashTable *in_param,
                GHashTable *out_param, int out_param_cnt)
 {
        int rv = 0, index = 0, outter_index = 0;
-       sqlite3_stmt* stmt = NULL;
-       char szQuery[5000+1];   // +1 is for NULL Termination Character '\0'
-
+       sqlite3_stmt *stmt = NULL;
+       char sz_query[5000+1] = {0, };
        GHashTableIter iter;
        gpointer key, value;
 
        dbg("read query");
 
-       memset(szQuery, '\0', 5001);
-       strncpy(szQuery, query, 5000);
+       memset(sz_query, '\0', 5001);
+       strncpy(sz_query, query, 5000);
 
-       rv = sqlite3_prepare_v2(handle, szQuery, strlen(szQuery), &stmt, NULL);
+       rv = sqlite3_prepare_v2(handle, sz_query, strlen(sz_query), &stmt, NULL);
        if (rv != SQLITE_OK) {
                err("fail to connect to table (%d)", rv);
                return FALSE;
@@ -133,20 +133,24 @@ static gboolean read_query_database(Storage *strg, void *handle, const char *que
        if (in_param) {
                g_hash_table_iter_init(&iter, in_param);
                while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
-                       dbg("key(%s), value(%s)", (const char*)key, (const char*)value);
+                       dbg("key(%s), value(%s)",
+                               (const char*)key, (const char*)value);
 
                        if (!value || g_strcmp0((const char*) value, "") == 0) {
                                dbg("bind null");
-                               rv = sqlite3_bind_null(stmt, atoi((const char*) key));
-                       }
-                       else {
+                               rv = sqlite3_bind_null(stmt,
+                                               atoi((const char*) key));
+                       else {
                                dbg("bind value");
-                               rv = sqlite3_bind_text(stmt, atoi((const char*) key), (const char*) value, strlen((const char*) value),
+                               rv = sqlite3_bind_text(stmt,
+                                               atoi((const char*) key),
+                                               (const char*) value,
+                                               strlen((const char*) value),
                                                SQLITE_STATIC);
                        }
 
                        if (rv != SQLITE_OK) {
-                               dbg("fail to bind data (%d)", rv);
+                               err("fail to bind data (%d)", rv);
                                return FALSE;
                        }
                }
@@ -156,43 +160,43 @@ static gboolean read_query_database(Storage *strg, void *handle, const char *que
        dbg("read query executed (%d)", rv);
 
        while (rv == SQLITE_ROW) {
-
                char tmp_key_outter[10];
                GHashTable *out_param_data;
 
-               out_param_data = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
+               out_param_data = g_hash_table_new_full(g_str_hash,
+                                       g_str_equal, NULL, g_free);
 
                for (index = 0; index < out_param_cnt; index++) {
                        char *tmp = NULL, tmp_key[10];
                        tmp = (char *) sqlite3_column_text(stmt, index);
                        snprintf(tmp_key, sizeof(tmp_key), "%d", index);
-                       g_hash_table_insert(out_param_data, g_strdup(tmp_key), g_strdup(tmp));
+                       g_hash_table_insert(out_param_data, g_strdup(tmp_key),
+                                       g_strdup(tmp));
                }
-
                snprintf(tmp_key_outter, sizeof(tmp_key_outter), "%d", outter_index);
                g_hash_table_insert(out_param, g_strdup(tmp_key_outter), out_param_data);
                outter_index++;
                rv = sqlite3_step(stmt);
        }
-
        sqlite3_finalize(stmt);
        return TRUE;
 }
 
-static gboolean insert_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param)
+static gboolean insert_query_database(TcoreStorage *strg, void *handle,
+               const char *query, GHashTable *in_param)
 {
        int rv = 0;
-       sqlite3_stmt* stmt = NULL;
-       char szQuery[5000+1];   // +1 is for NULL Termination Character '\0'
-
+       sqlite3_stmt *stmt = NULL;
+       char sz_query[5000+1] = {0, };
        GHashTableIter iter;
        gpointer key, value;
+
        dbg("insert query");
 
-       memset(szQuery, '\0', 5001);
-       strncpy(szQuery, query, 5000);
+       memset(sz_query, '\0', 5001);
+       strncpy(sz_query, query, 5000);
 
-       rv = sqlite3_prepare_v2(handle, szQuery, strlen(szQuery), &stmt, NULL);
+       rv = sqlite3_prepare_v2(handle, sz_query, strlen(sz_query), &stmt, NULL);
        if (rv != SQLITE_OK) {
                err("fail to connect to table (%d)", rv);
                return FALSE;
@@ -205,19 +209,19 @@ static gboolean insert_query_database(Storage *strg, void *handle, const char *q
                if (!value || g_strcmp0((const char*) value, "") == 0) {
                        dbg("bind null");
                        rv = sqlite3_bind_null(stmt, atoi((const char*) key));
-               }
-               else {
+               } else {
                        dbg("bind value");
-                       rv = sqlite3_bind_text(stmt, atoi((const char*) key), (const char*) value, strlen((const char*) value),
+                       rv = sqlite3_bind_text(stmt, atoi((const char*) key),
+                                       (const char*) value,
+                                       strlen((const char*) value),
                                        SQLITE_STATIC);
                }
 
                if (rv != SQLITE_OK) {
-                       dbg("fail to bind data (%d)", rv);
+                       err("fail to bind data (%d)", rv);
                        return FALSE;
                }
        }
-
        rv = sqlite3_step(stmt);
        dbg("insert query executed (%d)", rv);
        sqlite3_finalize(stmt);
@@ -228,20 +232,21 @@ static gboolean insert_query_database(Storage *strg, void *handle, const char *q
        return TRUE;
 }
 
-static gboolean remove_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param)
+static gboolean remove_query_database(TcoreStorage *strg, void *handle,
+               const char *query, GHashTable *in_param)
 {
        int rv = 0;
-       sqlite3_stmt* stmt = NULL;
-       char szQuery[1000+1];   // +1 is for NULL Termination Character '\0'
-
+       sqlite3_stmt *stmt = NULL;
+       char sz_query[1000+1] = {0, };
        GHashTableIter iter;
        gpointer key, value;
+
        dbg("remove query");
 
-       memset(szQuery, '\0', 1001);
-       strncpy(szQuery, query, 1000);
+       memset(sz_query, '\0', 1001);
+       strncpy(sz_query, query, 1000);
 
-       rv = sqlite3_prepare_v2(handle, szQuery, strlen(szQuery), &stmt, NULL);
+       rv = sqlite3_prepare_v2(handle, sz_query, strlen(sz_query), &stmt, NULL);
        if (rv != SQLITE_OK) {
                err("fail to connect to table (%d)", rv);
                return FALSE;
@@ -254,19 +259,19 @@ static gboolean remove_query_database(Storage *strg, void *handle, const char *q
                if (!value || g_strcmp0((const char*) value, "") == 0) {
                        dbg("bind null");
                        rv = sqlite3_bind_null(stmt, atoi((const char*) key));
-               }
-               else {
+               } else {
                        dbg("bind value");
-                       rv = sqlite3_bind_text(stmt, atoi((const char*) key), (const char*) value, strlen((const char*) value),
+                       rv = sqlite3_bind_text(stmt, atoi((const char*) key),
+                                       (const char*) value,
+                                       strlen((const char*) value),
                                        SQLITE_STATIC);
                }
 
                if (rv != SQLITE_OK) {
-                       dbg("fail to bind data (%d)", rv);
+                       err("fail to bind data (%d)", rv);
                        return FALSE;
                }
        }
-
        rv = sqlite3_step(stmt);
        dbg("remove query executed (%d)", rv);
        sqlite3_finalize(stmt);
@@ -274,11 +279,10 @@ static gboolean remove_query_database(Storage *strg, void *handle, const char *q
        if (rv != SQLITE_DONE) {
                return FALSE;
        }
-
        return TRUE;
 }
 
-struct storage_operations ops = {
+TcoreStorageOperations storage_ops = {
        .create_handle = create_handle,
        .remove_handle = remove_handle,
        .update_query_database = update_query_database,
@@ -295,12 +299,11 @@ static gboolean on_load()
 
 static gboolean on_init(TcorePlugin *p)
 {
-       if (!p)
-               return FALSE;
+       tcore_check_return_value_assert(p != NULL, FALSE);
 
-       tcore_storage_new(p, "database", &ops);
+       tcore_storage_new(p, "database", &storage_ops);
 
-       dbg("finish to initialize database plug-in");
+       dbg("database plug-in init done !!");
        return TRUE;
 }