sync with private git
authoryoungsub ko <ys4610.ko@samsung.com>
Wed, 29 May 2013 01:43:45 +0000 (10:43 +0900)
committeryoungsub ko <ys4610.ko@samsung.com>
Wed, 29 May 2013 01:43:45 +0000 (10:43 +0900)
include/notification_db.h
include/notification_debug.h
include/notification_noti.h
packaging/notification.spec
src/notification_db.c
src/notification_noti.c

index 171e5af..c9e3f79 100755 (executable)
@@ -44,7 +44,7 @@ sqlite3 *notification_db_open(const char *dbfile);
 
 int notification_db_close(sqlite3 ** db);
 
-int notification_db_exec(sqlite3 * db, const char *query);
+int notification_db_exec(sqlite3 * db, const char *query, int *num_changes);
 
 char *notification_db_column_text(sqlite3_stmt * stmt, int col);
 
index 1950cd7..519d3ae 100755 (executable)
 
 #define NOTIFICATION_WARN(fmt , args...) \
        do{ \
-               LOGI("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
+               LOGW("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
        } while(0)
 
 #define NOTIFICATION_ERR(fmt , args...) \
        do{ \
-               LOGI("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
+               LOGE("[%s : %d] "fmt"\n",__func__,__LINE__,##args ); \
        } while(0)
 
 #endif /* _DLOG_H_ */
index 77d960b..0c40bab 100755 (executable)
@@ -48,6 +48,7 @@ int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id);
 int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id);
 
 int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id);
+int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes);
 
 notification_error_e notification_noti_get_count(notification_type_e type,
                                                 const char *pkgname,
index c58d6ee..41d9d3b 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       notification
 Summary:    notification library
-Version:    0.2.3
+Version:    0.2.5
 Release:    1
 Group:      TBD
 License:    Apache-2.0
@@ -143,7 +143,7 @@ chown :5000 /opt/dbspace/.notification.db-journal
 chmod 660 /opt/dbspace/.notification.db
 chmod 660 /opt/dbspace/.notification.db-journal
 chsmack -a 'notification::db' /opt/dbspace/.notification.db*
-vconftool set -t string memory/private/libstatus/message "" -i -g 5000
+vconftool set -t string memory/private/libstatus/message "" -i -g 5000 -f
 
 %postun -p /sbin/ldconfig
 
index 6cfa2d6..2863668 100755 (executable)
@@ -66,7 +66,7 @@ int notification_db_close(sqlite3 ** db)
        return NOTIFICATION_ERROR_NONE;
 }
 
-int notification_db_exec(sqlite3 * db, const char *query)
+int notification_db_exec(sqlite3 * db, const char *query, int *num_changes)
 {
        int ret = 0;
        char *err_msg = NULL;
@@ -81,6 +81,9 @@ int notification_db_exec(sqlite3 * db, const char *query)
                sqlite3_free(err_msg);
                return NOTIFICATION_ERROR_FROM_DB;
        }
+       if (num_changes != NULL) {
+               *num_changes = sqlite3_changes(db);
+       }
 
        return NOTIFICATION_ERROR_NONE;
 }
index 996465e..9743069 100755 (executable)
@@ -745,7 +745,7 @@ static int _notification_noti_update_priv_id(sqlite3 * db, int rowid)
                        "priv_id = %d, internal_group_id = %d where rowid = %d",
                        rowid, rowid, rowid);
 
-       return notification_db_exec(db, query);
+       return notification_db_exec(db, query, NULL);
 }
 
 EXPORT_API int notification_noti_insert(notification_h noti)
@@ -1066,7 +1066,7 @@ EXPORT_API int notification_noti_delete_all(notification_type_e type, const char
                        snprintf(query, sizeof(query), "%s where priv_id in (%s)", query_base, query_where);
 
                        NOTIFICATION_ERR("check : %s", query);
-                       ret = notification_db_exec(db, query);
+                       ret = notification_db_exec(db, query, NULL);
                } else {
                        free(*list_deleted_rowid);
                        *list_deleted_rowid = NULL;
@@ -1080,7 +1080,7 @@ EXPORT_API int notification_noti_delete_all(notification_type_e type, const char
                snprintf(query_base, sizeof(query_base), "delete from noti_list ");
                snprintf(query, sizeof(query), "%s %s", query_base, query_where);
 
-               ret = notification_db_exec(db, query);
+               ret = notification_db_exec(db, query, NULL);
 
                if (num_deleted != NULL) {
                        *num_deleted = sqlite3_changes(db);
@@ -1175,7 +1175,7 @@ int notification_noti_delete_group_by_group_id(const char *pkgname,
                        snprintf(query, sizeof(query), "%s where priv_id in (%s)", query_base, query_where);
 
                        NOTIFICATION_ERR("check : %s", query);
-                       ret = notification_db_exec(db, query);
+                       ret = notification_db_exec(db, query, NULL);
                } else {
                        free(*list_deleted_rowid);
                        *list_deleted_rowid = NULL;
@@ -1189,7 +1189,7 @@ int notification_noti_delete_group_by_group_id(const char *pkgname,
                snprintf(query, sizeof(query), "delete from noti_list %s", query_where);
 
                /* execute DB */
-               ret = notification_db_exec(db, query);
+               ret = notification_db_exec(db, query, NULL);
        }
 
 err:
@@ -1233,7 +1233,7 @@ int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id)
                 pkgname, internal_group_id);
 
        /* execute DB */
-       ret = notification_db_exec(db, query);
+       ret = notification_db_exec(db, query, NULL);
 
        /* Close DB */
        notification_db_close(&db);
@@ -1264,7 +1264,44 @@ EXPORT_API int notification_noti_delete_by_priv_id(const char *pkgname, int priv
                 priv_id);
 
        /* execute DB */
-       ret = notification_db_exec(db, query);
+       ret = notification_db_exec(db, query, NULL);
+
+       /* Close DB */
+       if (db) {
+               notification_db_close(&db);
+       }
+
+       return ret;
+}
+
+EXPORT_API int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes)
+{
+       sqlite3 *db = NULL;
+       char query[NOTIFICATION_QUERY_MAX] = { 0, };
+       int ret;
+
+       /* Check pkgname is valid */
+       if (pkgname == NULL) {
+               return NOTIFICATION_ERROR_INVALID_DATA;
+       }
+
+       /* Open DB */
+       db = notification_db_open(DBPATH);
+       if (!db) {
+               return NOTIFICATION_ERROR_FROM_DB;
+       }
+
+       /* Make query */
+       snprintf(query, sizeof(query), "delete from noti_list "
+                "where caller_pkgname = '%s' and priv_id = %d", pkgname,
+                priv_id);
+
+       /* execute DB */
+       ret = notification_db_exec(db, query, num_changes);
+
+       if (num_changes != NULL) {
+               NOTIFICATION_DBG("deleted num:%d", *num_changes);
+       }
 
        /* Close DB */
        if (db) {