max = _get_max_len();
pkgname = malloc(max);
if (!pkgname) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc memory");
return NULL;
+ /* LCOV_EXCL_STOP */
}
memset(pkgname, 0x00, max);
if (ret != AUL_R_OK) {
fd = open("/proc/self/cmdline", O_RDONLY);
if (fd < 0) {
+ /* LCOV_EXCL_START */
free(pkgname);
return NULL;
+ /* LCOV_EXCL_STOP */
}
ret = read(fd, pkgname, max - 1);
if (ret <= 0) {
+ /* LCOV_EXCL_START */
close(fd);
free(pkgname);
return NULL;
+ /* LCOV_EXCL_STOP */
}
close(fd);
}
if (pkgname[0] == '\0') {
+ /* LCOV_EXCL_START */
free(pkgname);
return NULL;
+ /* LCOV_EXCL_STOP */
} else {
return pkgname;
}
BADGE_TABLE_NAME, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc sql query");
return BADGE_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
if (sqlret != SQLITE_OK) {
+ /* LCOV_EXCL_START */
ERR("DB err [%s]", sqlite3_errmsg(db));
ERR("query[%s]", sqlbuf);
result = BADGE_ERROR_FROM_DB;
goto free_and_return;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_step(stmt);
BADGE_OPTION_TABLE_NAME, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc sql query");
return BADGE_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
if (sqlret != SQLITE_OK) {
+ /* LCOV_EXCL_START */
ERR("DB err [%s]", sqlite3_errmsg(db));
ERR("query[%s]", sqlbuf);
result = BADGE_ERROR_FROM_DB;
goto free_and_return;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_step(stmt);
if (g_strcmp0(caller, pkgname) == 0)
return BADGE_ERROR_NONE;
+ /* LCOV_EXCL_START */
if (_is_same_certinfo(caller, pkgname) == 1)
return BADGE_ERROR_NONE;
sqlite3_finalize(stmt);
return result;
+ /* LCOV_EXCL_STOP */
}
int _badge_is_existing(const char *pkgname, bool *existing)
int result = BADGE_ERROR_NONE;
if (!pkgname || !existing) {
+ /* LCOV_EXCL_START */
ERR("pkgname : %s, existing : %p", pkgname, existing);
return BADGE_ERROR_INVALID_PARAMETER;
+ /* LCOV_EXCL_STOP */
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%d]", sqlret);
if (sqlret == SQLITE_PERM)
return BADGE_ERROR_PERMISSION_DENIED;
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
result = _badge_check_data_inserted(pkgname, db);
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%d]", sqlret);
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
sqlbuf = sqlite3_mprintf("SELECT pkgname, badge FROM %q",
BADGE_TABLE_NAME);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc sql query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto free_and_return;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
if (sqlret != SQLITE_OK) {
+ /* LCOV_EXCL_START */
ERR("fail to sqlite3_prepare_v2 - [%s]", sqlite3_errmsg(db));
ERR("query[%s]", sqlbuf);
result = BADGE_ERROR_FROM_DB;
goto free_and_return;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_step(stmt);
if (pkg) {
badge_info = (badge_info_s *)calloc(sizeof(badge_info_s), 1);
if (badge_info == NULL) {
+ /* LCOV_EXCL_START */
ERR("alloc badge_info fail");
result = BADGE_ERROR_OUT_OF_MEMORY;
break;
+ /* LCOV_EXCL_STOP */
}
badge_info->pkg = strdup(pkg);
badge_info->badge_count = badge_count;
*badge_list = g_list_append(*badge_list, badge_info);
} else {
+ /* LCOV_EXCL_START */
ERR("db has invaild data");
result = BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
} while (sqlite3_step(stmt) == SQLITE_ROW);
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%s][%d]", BADGE_DB_PATH, sqlret);
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
/* Check pkgname & id */
ret = _badge_check_data_inserted(badge->pkgname, db);
if (ret != BADGE_ERROR_NOT_EXIST) {
+ /* LCOV_EXCL_START */
result = ret;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
sqlbuf = sqlite3_mprintf("INSERT INTO %q " \
BADGE_TABLE_NAME,
badge->pkgname, badge->writable_pkgs);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
ret = badge_db_exec(db, sqlbuf, NULL);
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("failed to insert badge[%s], err[%d]",
badge->pkgname, ret);
result = ret;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
/* inserting badge options */
BADGE_OPTION_TABLE_NAME,
badge->pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
ret = badge_db_exec(db, sqlbuf, NULL);
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("failed to insert badge option[%s], err[%d]",
badge->pkgname, sqlret);
result = ret;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
return_close_db:
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%d]", sqlret);
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
ret = _badge_check_data_inserted(pkgname, db);
sqlbuf = sqlite3_mprintf("DELETE FROM %q WHERE pkgname = %Q",
BADGE_TABLE_NAME, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
ret = badge_db_exec(db, sqlbuf, NULL);
sqlbuf = sqlite3_mprintf("DELETE FROM %q WHERE pkgname = %Q",
BADGE_OPTION_TABLE_NAME, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
ret = badge_db_exec(db, sqlbuf, NULL);
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("failed to remove badge option[%s], err[%d]",
pkgname, ret);
result = ret;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
return_close_db:
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%d]", sqlret);
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
ret = _badge_check_data_inserted(pkgname, db);
"WHERE pkgname = %Q",
BADGE_TABLE_NAME, count, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
ret = badge_db_exec(db, sqlbuf, NULL);
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("failed to set badge[%s] count[%d], err[%d]",
pkgname, count, ret);
result = ret;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
return_close_db:
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%d]", sqlret);
if (sqlret == SQLITE_PERM)
return BADGE_ERROR_PERMISSION_DENIED;
else
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
ret = _badge_check_data_inserted(pkgname, db);
"WHERE pkgname = %Q",
BADGE_TABLE_NAME, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
if (sqlret != SQLITE_OK) {
+ /* LCOV_EXCL_START */
ERR("fail to prepare %s - [%s]",
sqlbuf, sqlite3_errmsg(db));
result = BADGE_ERROR_FROM_DB;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_step(stmt);
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%d]", sqlret);
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
ret = _badge_check_data_inserted(pkgname, db);
"WHERE pkgname = %Q",
BADGE_OPTION_TABLE_NAME, is_display, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
ret = badge_db_exec(db, sqlbuf, NULL);
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("failed to set badge[%s] option[%d], err[%d]",
pkgname, is_display, ret);
result = ret;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
} else if (ret == BADGE_ERROR_NOT_EXIST) {
BADGE_OPTION_TABLE_NAME,
pkgname, is_display);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
ret = badge_db_exec(db, sqlbuf, NULL);
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("failed to set badge[%s] option[%d], err[%d]",
pkgname, is_display, ret);
result = ret;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
} else {
result = ret;
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
sqlret = db_util_open(BADGE_DB_PATH, &db, 0);
if (sqlret != SQLITE_OK || !db) {
+ /* LCOV_EXCL_START */
ERR("fail to db_util_open - [%d]", sqlret);
if (sqlret == SQLITE_PERM)
return BADGE_ERROR_PERMISSION_DENIED;
else
return BADGE_ERROR_FROM_DB;
+ /* LCOV_EXCL_STOP */
}
ret = _badge_check_option_inserted(pkgname, db);
"WHERE pkgname = %Q",
BADGE_OPTION_TABLE_NAME, pkgname);
if (!sqlbuf) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc query");
result = BADGE_ERROR_OUT_OF_MEMORY;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
if (sqlret != SQLITE_OK) {
+ /* LCOV_EXCL_START */
ERR("fail to prepare %s - [%s]",
sqlbuf, sqlite3_errmsg(db));
result = BADGE_ERROR_FROM_DB;
goto return_close_db;
+ /* LCOV_EXCL_STOP */
}
sqlret = sqlite3_step(stmt);
sqlret = db_util_close(db);
if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
+ WARN("fail to db_util_close - [%d]", sqlret); /* LCOV_EXCL_LINE */
return result;
}
ret = _badge_changed_monitor_init();
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("badge_ipc_monitor_init err : %d", ret);
_badge_unregister_changed_cb(callback);
return ret;
+ /* LCOV_EXCL_STOP */
}
return BADGE_ERROR_NONE;
}
result = g_new0(char, length + 1); /* 1 for null terminate */
if (!result) {
+ /* LCOV_EXCL_START */
ERR("fail to alloc memory");
if (err)
*err = BADGE_ERROR_OUT_OF_MEMORY;
free(caller_pkgname);
return NULL;
+ /* LCOV_EXCL_STOP */
}
ptr = result;
&err);
if (err || (result == NULL)) {
+ /* LCOV_EXCL_START */
if (err) {
ERR("No reply. error = %s", err->message);
g_error_free(err);
}
is_master_started = 0;
+ /* LCOV_EXCL_STOP */
} else {
g_variant_get(result, "(b)", &name_exist);
if (!name_exist) {
+ /* LCOV_EXCL_START */
ERR("Name not exist %s", PROVIDER_BUS_NAME);
ERR("the master has been stopped");
is_master_started = 0;
+ /* LCOV_EXCL_STOP */
} else {
DBG("the master has been started");
is_master_started = 1;
return BADGE_ERROR_INVALID_PARAMETER;
}
+/* LCOV_EXCL_START */
static void _do_deferred_task(void)
{
task_list *list_do;
list_do = list_temp;
}
}
+/* LCOV_EXCL_STOP */
/*
* dbus handler implementation
*/
+/* LCOV_EXCL_START */
static void _insert_badge_notify(GVariant *parameters)
{
char *pkgname = NULL;
g_variant_get(parameters, "(&s)", &pkgname);
badge_changed_cb_call(BADGE_ACTION_CREATE, pkgname, 0);
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _delete_badge_notify(GVariant *parameters)
{
char *pkgname = NULL;
g_variant_get(parameters, "(&s)", &pkgname);
badge_changed_cb_call(BADGE_ACTION_REMOVE, pkgname, 0);
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _set_badge_count_notify(GVariant *parameters)
{
char *pkgname = NULL;
g_variant_get(parameters, "(&si)", &pkgname, &count);
badge_changed_cb_call(BADGE_ACTION_UPDATE, pkgname, count);
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _set_disp_option_notify(GVariant *parameters)
{
char *pkgname = NULL;
g_variant_get(parameters, "(&si)", &pkgname, &is_display);
badge_changed_cb_call(BADGE_ACTION_CHANGED_DISPLAY, pkgname, is_display);
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _handle_badge_notify(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
else if (g_strcmp0(signal_name, "set_disp_option_notify") == 0)
_set_disp_option_notify(parameters);
}
+/* LCOV_EXCL_STOP */
static int _dbus_init(void)
{
if (_gdbus_conn == NULL) {
_gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (_gdbus_conn == NULL) {
+ /* LCOV_EXCL_START */
if (error != NULL) {
ERR("Failed to get dbus [%s]", error->message);
g_error_free(error);
}
+ /* LCOV_EXCL_STOP */
return BADGE_ERROR_IO_ERROR;
}
badge_error_quark();
DBG("subscribe id : %d", id);
if (id == 0) {
+ /* LCOV_EXCL_START */
ret = BADGE_ERROR_IO_ERROR;
ERR("Failed to _register_noti_dbus_interface");
+ /* LCOV_EXCL_STOP */
} else {
monitor_id = id;
}
PROVIDER_BADGE_INTERFACE_NAME,
cmd);
if (!msg) {
+ /* LCOV_EXCL_START */
ERR("Can't allocate new method call");
if (body)
g_variant_unref(body);
return BADGE_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
}
if (body != NULL)
g_object_unref(msg);
if (!*reply) {
+ /* LCOV_EXCL_START */
ret = BADGE_ERROR_SERVICE_NOT_READY;
if (err != NULL) {
ERR("No reply. cmd = %s, error = %s", cmd, err->message);
g_error_free(err);
}
return ret;
+ /* LCOV_EXCL_STOP */
}
if (g_dbus_message_to_gerror(*reply, &err)) {
return _send_service_register();
}
+/* LCOV_EXCL_START */
static void _on_name_appeared(GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
_do_deferred_task();
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _on_name_vanished(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
DBG("name vanished : %s", name);
is_master_started = 0;
}
+/* LCOV_EXCL_STOP */
int badge_ipc_monitor_init(void)
{
ret = _dbus_init();
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("Can't init dbus %d", ret);
return ret;
+ /* LCOV_EXCL_STOP */
}
ret = _dbus_signal_init();
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("Can't init dbus signal %d", ret);
return ret;
+ /* LCOV_EXCL_STOP */
}
ret = _ipc_monitor_register();
if (ret != BADGE_ERROR_NONE) {
+ /* LCOV_EXCL_START */
ERR("Can't init ipc_monitor_register %d", ret);
return ret;
+ /* LCOV_EXCL_STOP */
}
if (provider_monitor_id == 0) {
NULL);
if (provider_monitor_id == 0) {
+ /* LCOV_EXCL_START */
ERR("watch on name fail");
g_dbus_connection_signal_unsubscribe(_gdbus_conn, monitor_id);
monitor_id = 0;
return BADGE_ERROR_IO_ERROR;
+ /* LCOV_EXCL_STOP */
}
}