return NOTIFICATION_ERROR_FROM_DB;
}
- ret =
- sqlite3_bind_double(stmt, index, val);
+ ret = sqlite3_bind_double(stmt, index, val);
if (ret != SQLITE_OK) {
- NOTIFICATION_ERR("Insert double : %f",
- val);
+ NOTIFICATION_ERR("Insert double : %f", val);
return NOTIFICATION_ERROR_FROM_DB;
}
return notification_db_exec(db, query);
}
-int notification_noti_insert(notification_h noti)
+EXPORT_API int notification_noti_insert(notification_h noti)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
/* Initialize private ID */
noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
char *base_query = "select "
"type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, "
return ret;
}
-int notification_noti_update(notification_h noti)
+EXPORT_API int notification_noti_update(notification_h noti)
{
sqlite3 *db;
sqlite3_stmt *stmt = NULL;
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
/* Check private ID is exist */
ret = _notification_noti_check_priv_id(noti, db);
ret = _notification_noti_bind_query_double(stmt, "$progress_size",noti->progress_size);
if (ret != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
- if (stmt) {
- sqlite3_finalize(stmt);
- }
- return ret;
+ goto err;
}
ret = _notification_noti_bind_query_double(stmt, "$progress_percentage",noti->progress_percentage);
if (ret != NOTIFICATION_ERROR_NONE) {
NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
- if (stmt) {
- sqlite3_finalize(stmt);
- }
- return ret;
+ goto err;
}
ret = sqlite3_step(stmt);
return ret;
}
-int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid)
+EXPORT_API int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid)
{
int ret = NOTIFICATION_ERROR_NONE;
int i = 0, data_cnt = 0;
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
if (pkgname == NULL) {
if (type != NOTIFICATION_TYPE_NONE) {
}
}
+ if (num_deleted != NULL) {
+ *num_deleted = 0;
+ }
if (list_deleted_rowid != NULL) {
*list_deleted_rowid = NULL;
snprintf(query, sizeof(query),
while(sqlite3_step(stmt) == SQLITE_ROW) {
if (data_cnt % 8 == 0) {
- *list_deleted_rowid =
- (int *)realloc(*list_deleted_rowid, sizeof(int) * (data_cnt + 8 + 1));
+ int *tmp;
+
+ tmp = (int *)realloc(*list_deleted_rowid, sizeof(int) * (data_cnt + 8 + 1));
+ if (tmp) {
+ *list_deleted_rowid = tmp;
+ } else {
+ NOTIFICATION_ERR("Heap: %s\n", strerror(errno));
+ /*!
+ * \TODO
+ * How can I handle this?
+ */
+ free(*list_deleted_rowid);
+ *list_deleted_rowid = NULL;
+ ret = NOTIFICATION_ERROR_NO_MEMORY;
+ goto err;
+ }
}
*((*list_deleted_rowid) + data_cnt) = sqlite3_column_int(stmt, 0);
data_cnt++;
snprintf(query, sizeof(query), "%s where priv_id in (%s)", query_base, query_where);
NOTIFICATION_ERR("check : %s", query);
- notification_db_exec(db, query);
+ ret = notification_db_exec(db, query);
} else {
free(*list_deleted_rowid);
*list_deleted_rowid = NULL;
snprintf(query_base, sizeof(query_base), "delete from noti_list ");
snprintf(query, sizeof(query), "%s %s", query_base, query_where);
- notification_db_exec(db, query);
+ ret = notification_db_exec(db, query);
if (num_deleted != NULL) {
*num_deleted = sqlite3_changes(db);
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
+ if (num_deleted != NULL) {
+ *num_deleted = 0;
+ }
if (list_deleted_rowid != NULL) {
*list_deleted_rowid = NULL;
snprintf(query, sizeof(query),
while(sqlite3_step(stmt) == SQLITE_ROW) {
if (data_cnt % 8 == 0) {
- *list_deleted_rowid =
- (int *)realloc(*list_deleted_rowid, sizeof(int) * (data_cnt + 8 + 1));
+ int *tmp;
+ tmp = (int *)realloc(*list_deleted_rowid, sizeof(int) * (data_cnt + 8 + 1));
+ if (tmp) {
+ *list_deleted_rowid = tmp;
+ } else {
+ free(*list_deleted_rowid);
+ *list_deleted_rowid = NULL;
+ ret = NOTIFICATION_ERROR_NO_MEMORY;
+ goto err;
+ }
}
*((*list_deleted_rowid) + data_cnt) = sqlite3_column_int(stmt, 0);
data_cnt++;
snprintf(query, sizeof(query), "%s where priv_id in (%s)", query_base, query_where);
NOTIFICATION_ERR("check : %s", query);
- notification_db_exec(db, query);
+ ret = notification_db_exec(db, query);
} else {
free(*list_deleted_rowid);
*list_deleted_rowid = NULL;
snprintf(query, sizeof(query), "delete from noti_list %s", query_where);
/* execute DB */
- notification_db_exec(db, query);
-
- return NOTIFICATION_ERROR_NONE;
+ ret = notification_db_exec(db, query);
}
err:
sqlite3 *db = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
int internal_group_id = 0;
+ int ret;
/* Check pkgname is valid */
if (pkgname == NULL) {
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
/* Get internal group id using priv id */
internal_group_id =
pkgname, internal_group_id);
/* execute DB */
- notification_db_exec(db, query);
+ ret = notification_db_exec(db, query);
/* Close DB */
- if (db) {
- notification_db_close(&db);
- }
+ notification_db_close(&db);
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
-int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id)
+EXPORT_API int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id)
{
sqlite3 *db = NULL;
char query[NOTIFICATION_QUERY_MAX] = { 0, };
+ int ret;
/* Check pkgname is valid */
if (pkgname == NULL) {
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
/* Make query */
snprintf(query, sizeof(query), "delete from noti_list "
priv_id);
/* execute DB */
- notification_db_exec(db, query);
+ ret = notification_db_exec(db, query);
/* Close DB */
if (db) {
notification_db_close(&db);
}
- return NOTIFICATION_ERROR_NONE;
+ return ret;
}
notification_error_e notification_noti_get_count(notification_type_e type,
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
/* Check current sim status */
ret_vconf = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status);
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
/* Check current sim status */
ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status);
goto err;
}
- ret = sqlite3_step(stmt);
- while (ret == SQLITE_ROW) {
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
/* Make notification list */
noti = _notification_noti_get_item(stmt);
if (noti != NULL) {
break;
}
}
-
- ret = sqlite3_step(stmt);
}
ret = NOTIFICATION_ERROR_NONE;
notification_h noti = NULL;
int internal_count = 0;
int internal_group_id = 0;
- int status;
+ int status = 0; /* If the vconf_get_int failed, the status will be the garbage value */
/* Open DB */
db = notification_db_open(DBPATH);
+ if (!db) {
+ return NOTIFICATION_ERROR_FROM_DB;
+ }
/* Check current sim status */
ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status);
goto err;
}
- ret = sqlite3_step(stmt);
- while (ret == SQLITE_ROW) {
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
/* Make notification list */
noti = _notification_noti_get_item(stmt);
if (noti != NULL) {
break;
}
}
-
- ret = sqlite3_step(stmt);
}
ret = NOTIFICATION_ERROR_NONE;