summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseungha.son <seungha.son@samsung.com>2016-10-11 13:10:33 +0900
committerseungha.son <seungha.son@samsung.com>2016-10-11 14:53:31 +0900
commitc05da09c8dd87288705fae69b0c1b648d9bb0379 (patch)
tree59b4daa317fa213df61d20d079d9604a03216458
parent2b5b5ee5c4144287a345cb04fec1caba3453f2a2 (diff)
downloadbadge-c05da09c8dd87288705fae69b0c1b648d9bb0379.tar.gz
badge-c05da09c8dd87288705fae69b0c1b648d9bb0379.tar.bz2
badge-c05da09c8dd87288705fae69b0c1b648d9bb0379.zip
Signed-off-by: seungha.son <seungha.son@samsung.com> Change-Id: If8c27db3a0ee1b046f9e1cb5360d749897dd7617
-rwxr-xr-xCMakeLists.txt2
-rwxr-xr-xdoc/doxygen.conf2
-rwxr-xr-xinclude/badge_setting.h61
-rwxr-xr-xinclude/badge_setting_service.h40
-rwxr-xr-xpackaging/badge.spec1
-rwxr-xr-xsrc/badge_setting.c339
6 files changed, 1 insertions, 444 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a386b44..1be439a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,14 +16,12 @@ SET(INSTALL_HEADERS_DEVEL
badge.h
badge_error.h
badge_internal.h
- badge_setting_service.h
badge_db.h
)
SET(SRCS
src/badge.c
src/badge_error.c
- src/badge_setting.c
src/badge_db.c
src/badge_ipc.c
src/badge_internal.c
diff --git a/doc/doxygen.conf b/doc/doxygen.conf
index 6005bb2..c899e2a 100755
--- a/doc/doxygen.conf
+++ b/doc/doxygen.conf
@@ -648,7 +648,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = ./badge_doc.h ../include/badge_db.h ../include/badge_error.h ../include/badge.h ../include/badge_setting.h
+INPUT = ./badge_doc.h ../include/badge_db.h ../include/badge_error.h ../include/badge.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
diff --git a/include/badge_setting.h b/include/badge_setting.h
deleted file mode 100755
index 3da78d0..0000000
--- a/include/badge_setting.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * libbadge
- *
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
- * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * 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.
- *
- */
-
-#ifndef __BADGE_SETTING_H__
-#define __BADGE_SETTING_H__
-
-#include <stdbool.h>
-#include <sys/types.h>
-#include <badge_error.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @brief This function sets badge property for designated package.
- * @param[in] pkgname The name of designated package
- * @param[in] property name
- * @param[in] property value
- * @return #BADGE_ERROR_NONE if success, other value if failure
- * @see #badge_error_e
- */
-int badge_setting_property_set(const char *pkgname, const char *property, const char *value);
-
-int badge_setting_property_set_for_uid(const char *pkgname, const char *property, const char *value, uid_t uid);
-
-/**
- * @brief This function gets badge property for designated package.
- * @param[in] pkgname The name of designated package
- * @param[in] property name
- * @param[in] pointer which can save the getting value
- * @return #BADGE_ERROR_NONE if success, other value if failure
- * @see #badge_error_e
- */
-int badge_setting_property_get(const char *pkgname, const char *property, char **value);
-
-int badge_setting_property_get_for_uid(const char *pkgname, const char *property, char **value, uid_t uid);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/include/badge_setting_service.h b/include/badge_setting_service.h
deleted file mode 100755
index 8d8ce57..0000000
--- a/include/badge_setting_service.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * libbadge
- *
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
- * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * 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.
- *
- */
-
-#ifndef __BADGE_SETTING_SERVICE_H__
-#define __BADGE_SETTING_SERVICE_H__
-
-#include <stdbool.h>
-#include <sys/types.h>
-#include <badge_error.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int badge_setting_db_set(const char *pkgname, const char *property, const char *value, uid_t uid);
-int badge_setting_db_get(const char *pkgname, const char *property, char **value, uid_t uid);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/packaging/badge.spec b/packaging/badge.spec
index 1807b18..836e2a6 100755
--- a/packaging/badge.spec
+++ b/packaging/badge.spec
@@ -81,5 +81,4 @@ fi
%{_includedir}/badge/badge_error.h
%{_includedir}/badge/badge_internal.h
%{_includedir}/badge/badge_db.h
-%{_includedir}/badge/badge_setting_service.h
%{_libdir}/pkgconfig/%{name}.pc
diff --git a/src/badge_setting.c b/src/badge_setting.c
deleted file mode 100755
index d8aba7e..0000000
--- a/src/badge_setting.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * libbadge
- *
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
- * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * 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 <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <sqlite3.h>
-#include <db-util.h>
-#include <tzplatform_config.h>
-
-#include "badge.h"
-#include "badge_log.h"
-#include "badge_error.h"
-#include "badge_internal.h"
-#include "badge_ipc.h"
-#include "badge_db.h"
-#include "badge_setting.h"
-
-#define SETTING_DB_TABLE "notification_setting"
-#define SETTING_DB_FILE tzplatform_mkpath(TZ_SYS_DB, "/.notification_parser.db")
-
-
-struct prop_table {
- const char *property;
- const char *column;
- const char *default_value;
-};
-
-static struct prop_table g_prop_table[] = {
- {
- .property = "OPT_BADGE",
- .column = "badge",
- .default_value = "ON",
- },
- {
- .property = NULL,
- .column = NULL,
- .default_value = NULL,
- }
-};
-
-static const char *_get_prop_column(const char *property)
-{
- int i;
-
- for (i = 0; g_prop_table[i].property; i++) {
- if (strcmp(g_prop_table[i].property, property))
- continue;
-
- return g_prop_table[i].column;
- }
-
- return NULL;
-}
-
-#ifdef TBD
-static const char *_get_prop_default_value(const char *property)
-{
- int i;
-
- for (i = 0; g_prop_table[i].property; i++) {
- if (strcmp(g_prop_table[i].property, property))
- continue;
-
- return g_prop_table[i].default_value;
- }
-
- return NULL;
-}
-#endif
-
-static int _is_record_exist(const char *pkgname, sqlite3 *db)
-{
- sqlite3_stmt *stmt = NULL;
- int count = 0;
- int result = BADGE_ERROR_NONE;
- char *sqlbuf = NULL;
- int sqlret;
-
- if (!pkgname)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!db)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- sqlbuf = sqlite3_mprintf("SELECT count(*) FROM %q WHERE " \
- "appid = %Q",
- SETTING_DB_TABLE, pkgname);
-
- if (!sqlbuf) {
- ERR("fail to alloc sql query");
- return BADGE_ERROR_OUT_OF_MEMORY;
- }
-
- sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
- if (sqlret != SQLITE_OK) {
- ERR("DB err [%s]", sqlite3_errmsg(db));
- ERR("query[%s]", sqlbuf);
- result = BADGE_ERROR_FROM_DB;
- goto free_and_return;
- }
-
- sqlret = sqlite3_step(stmt);
- if (sqlret == SQLITE_ROW)
- count = sqlite3_column_int(stmt, 0);
- else
- count = 0;
-
- if (count > 0)
- result = BADGE_ERROR_ALREADY_EXIST;
- else
- result = BADGE_ERROR_NOT_EXIST;
-
-free_and_return:
- if (sqlbuf)
- sqlite3_free(sqlbuf);
-
- if (stmt)
- sqlite3_finalize(stmt);
-
- return result;
-}
-
-EXPORT_API int badge_setting_db_set(const char *pkgname, const char *property, const char *value, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- int result = BADGE_ERROR_NONE;
- sqlite3 *db = NULL;
- char *sqlbuf = NULL;
- int sqlret;
- const char *column = NULL;
-
- if (!pkgname)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!property)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!value)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- column = _get_prop_column(property);
- if (!column)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- sqlret = db_util_open(SETTING_DB_FILE, &db, 0);
- if (sqlret != SQLITE_OK || !db) {
- ERR("fail to db_util_open - [%d]", sqlret);
- return BADGE_ERROR_FROM_DB;
- }
-
- ret = _is_record_exist(pkgname, db);
- if (ret != BADGE_ERROR_ALREADY_EXIST) {
- result = ret;
- goto return_close_db;
- }
-
- sqlbuf = sqlite3_mprintf("UPDATE %q SET %q = %Q " \
- "WHERE appid = %Q",
- SETTING_DB_TABLE, column, value, pkgname);
- if (!sqlbuf) {
- ERR("fail to alloc query");
- result = BADGE_ERROR_OUT_OF_MEMORY;
- goto return_close_db;
- }
-
- ret = badge_db_exec(db, sqlbuf, NULL);
- if (ret != BADGE_ERROR_NONE) {
- ERR("failed to set pkgname[%s] option[%s], value[%s], err[%d]",
- pkgname, column, value, ret);
- result = ret;
- goto return_close_db;
- }
-
-return_close_db:
- if (sqlbuf)
- sqlite3_free(sqlbuf);
-
- sqlret = db_util_close(db);
- if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
-
- return result;
-}
-
-EXPORT_API int badge_setting_db_get(const char *pkgname, const char *property, char **value, uid_t uid)
-{
- int ret = BADGE_ERROR_NONE;
- int result = BADGE_ERROR_NONE;
- sqlite3 *db = NULL;
- char *sqlbuf = NULL;
- sqlite3_stmt *stmt = NULL;
- int sqlret;
- const char *column = NULL;
- int get_bytes;
- char *get_data;
-
- if (!pkgname)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!property)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!value)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- column = _get_prop_column(property);
- if (!column)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- sqlret = db_util_open(SETTING_DB_FILE, &db, 0);
- if (sqlret != SQLITE_OK || !db) {
- ERR("fail to db_util_open - [%d]", sqlret);
- return BADGE_ERROR_FROM_DB;
- }
-
- ret = _is_record_exist(pkgname, db);
- if (ret != BADGE_ERROR_ALREADY_EXIST) {
- result = ret;
- goto return_close_db;
- }
-
- /* LCOV_EXCL_START */
- sqlbuf = sqlite3_mprintf("SELECT %q FROM %q " \
- "WHERE appid = %Q",
- column, SETTING_DB_TABLE, pkgname);
- if (!sqlbuf) {
- ERR("fail to alloc query");
- result = BADGE_ERROR_OUT_OF_MEMORY;
- goto return_close_db;
- }
-
- sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
- if (sqlret != SQLITE_OK) {
- ERR("fail to prepare %s - [%s]",
- sqlbuf, sqlite3_errmsg(db));
- result = BADGE_ERROR_FROM_DB;
- goto return_close_db;
- }
-
- sqlret = sqlite3_step(stmt);
- if (sqlret == SQLITE_ROW) {
- get_bytes = sqlite3_column_bytes(stmt, 0);
- get_data = (char *)calloc(get_bytes + 1, sizeof(char));
- if (get_data != NULL) {
- memcpy(get_data, sqlite3_column_text(stmt, 0),
- get_bytes * sizeof(char));
- get_data[get_bytes] = '\0';
- *value = get_data;
- } else {
- ERR("fail to alloc query");
- result = BADGE_ERROR_OUT_OF_MEMORY;
- goto return_close_db;
- }
- }
- /* LCOV_EXCL_STOP */
-
-return_close_db:
- if (sqlbuf)
- sqlite3_free(sqlbuf);
-
- if (stmt)
- sqlite3_finalize(stmt);
-
- sqlret = db_util_close(db);
- if (sqlret != SQLITE_OK)
- WARN("fail to db_util_close - [%d]", sqlret);
-
- return result;
-}
-
-EXPORT_API int badge_setting_property_set_for_uid(const char *pkgname, const char *property, const char *value, uid_t uid)
-{
- int ret = 0;
-
- if (!pkgname)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!property)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!value)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = badge_ipc_setting_property_set(pkgname, property, value, uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- return BADGE_ERROR_NONE;
-}
-
-EXPORT_API int badge_setting_property_set(const char *pkgname, const char *property, const char *value)
-{
- return badge_setting_property_set_for_uid(pkgname, property, value, getuid());
-}
-
-EXPORT_API int badge_setting_property_get_for_uid(const char *pkgname, const char *property, char **value, uid_t uid)
-{
- int ret = 0;
-
- if (!pkgname)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!property)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- if (!value)
- return BADGE_ERROR_INVALID_PARAMETER;
-
- ret = badge_ipc_setting_property_get(pkgname, property, value, uid);
- if (ret != BADGE_ERROR_NONE)
- return ret;
-
- return BADGE_ERROR_NONE;
-}
-
-EXPORT_API int badge_setting_property_get(const char *pkgname, const char *property, char **value)
-{
- return badge_setting_property_get_for_uid(pkgname, property, value, getuid());
-}