diff options
author | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:29:58 +0900 |
---|---|---|
committer | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:29:58 +0900 |
commit | c17dc905783b7ebe6043390fdfe29528380eb2ae (patch) | |
tree | 5c43f45a4291ea68da7610679d0f3b0a47cc4b06 /include | |
download | badge-c17dc905783b7ebe6043390fdfe29528380eb2ae.tar.gz badge-c17dc905783b7ebe6043390fdfe29528380eb2ae.tar.bz2 badge-c17dc905783b7ebe6043390fdfe29528380eb2ae.zip |
Initialize Tizen 2.3
Diffstat (limited to 'include')
-rwxr-xr-x | include/badge.h | 309 | ||||
-rwxr-xr-x | include/badge_db.h | 46 | ||||
-rwxr-xr-x | include/badge_error.h | 66 | ||||
-rwxr-xr-x | include/badge_internal.h | 76 | ||||
-rwxr-xr-x | include/badge_ipc.h | 54 | ||||
-rwxr-xr-x | include/badge_log.h | 81 | ||||
-rwxr-xr-x | include/badge_setting.h | 39 | ||||
-rwxr-xr-x | include/badge_setting_service.h | 39 |
8 files changed, 710 insertions, 0 deletions
diff --git a/include/badge.h b/include/badge.h new file mode 100755 index 0000000..347dcad --- /dev/null +++ b/include/badge.h @@ -0,0 +1,309 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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_DEF_H__ +#define __BADGE_DEF_H__ + +#include <stdbool.h> +#include <badge_error.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file badge.h + * @brief This file contains the badge APIs + */ + +/** + * @addtogroup BADGE_TYPE + * @{ + */ + +/** + * @brief Enumeration for Badge action + */ +enum _badge_action { + BADGE_ACTION_CREATE = 0, + BADGE_ACTION_REMOVE, + BADGE_ACTION_UPDATE, + BADGE_ACTION_CHANGED_DISPLAY, + BADGE_ACTION_SERVICE_READY, +}; + + +/** + * @brief Called to retrieve the badge existed. + * @param[in] pkgname The name of package + * @param[in] count The count of badge + * @param[in] user_data The user data passed from the foreach function + * @pre badge_foreach_existed() will invoke this callback. + * @see badge_foreach_existed() + */ +typedef void (*badge_cb)(const char *pkgname, unsigned int count, void *data); + + +/** + * @brief Called when badge information is changed. + * @param[in] action The type of changing + * @param[in] pkgname The name of package + * @param[in] count The count of badge + * @param[in] user_data The user data passed from the callback register function + * @pre badge_register_changed_cb() will invoke this callback. + * @see badge_unregister_changed_cb() + */ +typedef void (*badge_change_cb)(unsigned int action, const char *pkgname, + unsigned int count, void *data); + +/** + * @} + */ + +/** + * @addtogroup BADGE_MODULE + * @{ + */ + +/** + * @brief This function creates badge for designated package. + * @details Creates new badge to display. + * @param[in] pkgname The name of designated package + * @param[in] writable_pkg The name of package which is authorized to change badge + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @par Sample code: + * @code +#include <badge.h> +... +{ + badge_error_e err = BADGE_ERROR_NONE; + + err = badge_create("org.tizen.sms", "org.tizen.sms2"); + if(err != BADGE_ERROR_NONE) { + return; + } + +} + * @endcode + */ +badge_error_e badge_create(const char *pkgname, const char *writable_pkg); + + +/** + * @brief This function removes badge for designated package. + * @param[in] pkgname The name of designated package + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @par Sample code: + * @code +#include <badge.h> +... +{ + badge_error_e err = BADGE_ERROR_NONE; + + err = badge_remove("org.tizen.sms"); + if(err != BADGE_ERROR_NONE) { + return; + } + +} + * @endcode + */ +badge_error_e badge_remove(const char *pkgname); + +/** + * @brief This function sets badge count for designated package. + * @param[in] pkgname The name of designated package + * @param[in] count The count of badge + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_create() + * @par Sample code: + * @code +#include <badge.h> +... +{ + badge_error_e err = BADGE_ERROR_NONE; + + err = badge_set_count("org.tizen.sms", 1); + if(err != BADGE_ERROR_NONE) { + return; + } + +} + * @endcode + */ +badge_error_e badge_set_count(const char *pkgname, unsigned int count); + +/** + * @brief This function gets badge count for designated package. + * @param[in] pkgname The name of designated package + * @param[out] count The count of badge + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_create() + * @see badge_set_count() + * @par Sample code: + * @code +#include <badge.h> +... +{ + badge_error_e err = BADGE_ERROR_NONE; + + err = badge_get_count("org.tizen.sms", 1); + if(err != BADGE_ERROR_NONE) { + return; + } + +} + * @endcode + */ +badge_error_e badge_get_count(const char *pkgname, unsigned int *count); + +/** + * @brief This function sets displaying option for designated package. + * @param[in] pkgname The name of designated package + * @param[in] is_display The displaying option, 1 = display 0 = not display + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_create() + * @par Sample code: + * @code +#include <badge.h> +... +{ + badge_error_e err = BADGE_ERROR_NONE; + + err = badge_set_display("org.tizen.sms", 1); + if(err != BADGE_ERROR_NONE) { + return; + } + +} + * @endcode + */ +badge_error_e badge_set_display(const char *pkgname, unsigned int is_display); + +/** + * @brief This function gets displaying option for designated package. + * @param[in] pkgname The name of designated package + * @param[out] is_display The displaying option, 1 = display 0 = not display + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_create() + * @see badge_set_count() + * @par Sample code: + * @code +#include <badge.h> +... +{ + int is_display = 0; + badge_error_e err = BADGE_ERROR_NONE; + + err = badge_get_display("org.tizen.sms", &is_display); + if(err != BADGE_ERROR_NONE) { + return; + } + +} + * @endcode + */ +badge_error_e badge_get_display(const char *pkgname, unsigned int *is_display); + +/** + * @brief This function tests badge for designated package is existed or not. + * @param[in] pkgname The name of designated package + * @param[out] existing The bool value of badge existing status + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_create() + * @see badge_remove() + * @par Sample code: + * @code +#include <badge.h> +... +{ + badge_error_e err = BADGE_ERROR_NONE; + bool exist; + + err = badge_is_existing("org.tizen.sms", &exist); + if(err != BADGE_ERROR_NONE) { + return; + } + +} + * @endcode + */ +badge_error_e badge_is_existing(const char *pkgname, bool *existing); + +/** + * @brief This function retrieves all badges which are existed. + * @param[in] callback The callback function + * @param[in] data The user data to be passed to the callback function + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_get_count() + * @see badge_is_existing() + */ +badge_error_e badge_foreach_existed(badge_cb callback, void *data); + +/** + * @brief This function registers callback function to receive badge changed event. + * @param[in] callback The callback function + * @param[in] data The user data to be passed to the callback function + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_create() + * @see badge_remove() + * @see badge_set_count() + */ +badge_error_e badge_register_changed_cb(badge_change_cb callback, void *data); + +/** + * @brief This function unregisters callback function to receive badge changed event. + * @param[in] callback The callback function + * @return #BADGE_ERROR_NONE if success, other value if failure + * @see #badge_error_e + * @see badge_register_changed_cb() + */ +badge_error_e badge_unregister_changed_cb(badge_change_cb callback); + +/** + * @} + */ + +int badge_is_service_ready(void); + +badge_error_e badge_add_deffered_task( + void (*deffered_task_cb)(void *data), void *user_data); + +badge_error_e badge_del_deffered_task( + void (*deffered_task_cb)(void *data)); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __BADGE_DEF_H__ */ + + diff --git a/include/badge_db.h b/include/badge_db.h new file mode 100755 index 0000000..1d490c5 --- /dev/null +++ b/include/badge_db.h @@ -0,0 +1,46 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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_DB_DEF_H__ +#define __BADGE_DB_DEF_H__ + +#include <stdbool.h> +#include <sqlite3.h> +#include <badge_error.h> + +#ifdef __cplusplus +extern "C" { +#endif + +badge_error_e badge_db_insert(const char *pkgname, const char *writable_pkg, const char *caller); +badge_error_e badge_db_delete(const char *pkgname, const char *caller_pkg); +badge_error_e badge_db_set_count(const char *pkgname, const char *caller_pkg, int count); +badge_error_e badge_db_set_display_option(const char *pkgname, const char *caller_pkg, int is_display); +badge_error_e badge_db_exec(sqlite3 * db, const char *query, int *num_changes); + +#ifdef __cplusplus + } +#endif + +#endif /* __BADGE_DB_DEF_H__ */ + diff --git a/include/badge_error.h b/include/badge_error.h new file mode 100755 index 0000000..89d1abb --- /dev/null +++ b/include/badge_error.h @@ -0,0 +1,66 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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_ERROR_DEF_H__ +#define __BADGE_ERROR_DEF_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file badge_error.h + * @brief This file contains the badge APIs + */ + +/** + * @addtogroup BADGE_TYPE + * @{ + */ + +/** + * @breief Enumeration for Badge error + */ +typedef enum _badge_error_e { + BADGE_ERROR_NONE = 0, /**< Success */ + BADGE_ERROR_INVALID_DATA = -1, /**< Invalid parameter */ + BADGE_ERROR_NO_MEMORY = -2, /**< No memory */ + BADGE_ERROR_FROM_DB = -3, /**< Error from DB */ + BADGE_ERROR_ALREADY_EXIST = -4, /**< Already exist */ + BADGE_ERROR_FROM_DBUS = -5, /**< Error from DBus */ + BADGE_ERROR_NOT_EXIST = -6, /**< Not exist */ + BADGE_ERROR_PERMISSION_DENIED = -7, /**< Permission denied */ + BADGE_ERROR_IO = -8, /**< Error from I/O */ + BADGE_ERROR_SERVICE_NOT_READY = -9, /**< Error service not ready */ +} badge_error_e; + +/** + * @} + */ + +#ifdef __cplusplus + } +#endif + +#endif /* __BADGE_ERROR_DEF_H__ */ + diff --git a/include/badge_internal.h b/include/badge_internal.h new file mode 100755 index 0000000..d3b6681 --- /dev/null +++ b/include/badge_internal.h @@ -0,0 +1,76 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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_INTERNAL_DEF_H__ +#define __BADGE_INTERNAL_DEF_H__ + +#include <stdbool.h> +#include <stdarg.h> + +#include "badge_error.h" +#include "badge.h" + +#ifndef EXPORT_API +#define EXPORT_API __attribute__ ((visibility("default"))) +#endif + +typedef struct _badge_h badge_h; + +char *_badge_get_pkgname_by_pid(void); + +badge_error_e _badge_is_existing(const char *pkgname, bool *existing); + +badge_error_e _badge_foreach_existed(badge_cb callback, void *data); + +badge_error_e _badge_insert(badge_h *badge); + +badge_error_e _badge_remove(const char *caller, const char *pkgname); + +badge_error_e _badget_set_count(const char *caller, const char *pkgname, + unsigned int count); + +badge_error_e _badget_get_count(const char *pkgname, unsigned int *count); + +badge_error_e _badget_set_display(const char *pkgname, + unsigned int is_display); + +badge_error_e _badget_get_display(const char *pkgname, unsigned int *is_display); + +badge_error_e _badge_register_changed_cb(badge_change_cb callback, void *data); + +badge_error_e _badge_unregister_changed_cb(badge_change_cb callback); + +badge_error_e _badge_free(badge_h *badge); + +badge_h *_badge_new(const char *pkgname, const char *writable_pkgs, + badge_error_e *err); + +char *_badge_pkgs_new(badge_error_e *err, const char *pkg1, ...); + +char *_badge_pkgs_new_valist(badge_error_e *err, + const char *pkg1, va_list args); + +void badge_changed_cb_call(unsigned int action, const char *pkgname, + unsigned int count); + +#endif /* __BADGE_INTERNAL_DEF_H__ */ + diff --git a/include/badge_ipc.h b/include/badge_ipc.h new file mode 100755 index 0000000..3574402 --- /dev/null +++ b/include/badge_ipc.h @@ -0,0 +1,54 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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_IPC_H__ +#define __BADGE_IPC_H__ + +#include <badge.h> + +#define BADGE_ADDR "/tmp/.badge.service" + +#ifdef __cplusplus +extern "C" { +#endif + +struct packet; + +badge_error_e badge_ipc_monitor_init(void); +badge_error_e badge_ipc_monitor_fini(void); + +badge_error_e badge_ipc_request_insert(const char *pkgname, const char *writable_pkg, const char *caller); +badge_error_e badge_ipc_request_delete(const char *pkgname, const char *caller); +badge_error_e badge_ipc_request_set_count(const char *pkgname, const char *caller, int count); +badge_error_e badge_ipc_request_set_display(const char *pkgname, const char *caller, int display_option); + +int badge_ipc_is_master_ready(void); +badge_error_e badge_ipc_add_deffered_task(void (*deffered_task_cb)(void *data), void *user_data); +badge_error_e badge_ipc_del_deffered_task(void (*deffered_task_cb)(void *data)); + +badge_error_e badge_ipc_setting_property_set(const char *pkgname, const char *property, const char *value); +badge_error_e badge_ipc_setting_property_get(const char *pkgname, const char *property, char **value); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/badge_log.h b/include/badge_log.h new file mode 100755 index 0000000..58a3d8c --- /dev/null +++ b/include/badge_log.h @@ -0,0 +1,81 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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_LOG_DEF_H__ +#define __BADGE_LOG_DEF_H__ + +#ifdef BADGE_USE_DLOG + +#include <dlog.h> +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "BADGE" + +#define DBG(fmt , args...) \ + do { \ + SECURE_LOGD("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define INFO(fmt , args...) \ + do { \ + SECURE_LOGI("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define WARN(fmt , args...) \ + do { \ + SECURE_LOGW("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define ERR(fmt , args...) \ + do { \ + SECURE_LOGE("[%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#else /* BADGE_USE_DLOG */ + +#include <stdio.h> + +#define DBG(fmt , args...) \ + do { \ + printf("[D][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define INFO(fmt , args...) \ + do { \ + printf("[I][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define WARN(fmt , args...) \ + do { \ + printf("[W][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#define ERR(fmt , args...) \ + do { \ + printf("[E][%s : %d] "fmt"\n", __func__, __LINE__, ##args); \ + } while (0) + +#endif /* BADGE_USE_DLOG */ + +#endif /* __BADGE_LOG_DEF_H__ */ diff --git a/include/badge_setting.h b/include/badge_setting.h new file mode 100755 index 0000000..6934dcf --- /dev/null +++ b/include/badge_setting.h @@ -0,0 +1,39 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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 <badge_error.h> + +#ifdef __cplusplus +extern "C" { +#endif + +badge_error_e badge_setting_property_set(const char *pkgname, const char *property, const char *value); +badge_error_e badge_setting_property_get(const char *pkgname, const char *property, char **value); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/badge_setting_service.h b/include/badge_setting_service.h new file mode 100755 index 0000000..9b452a7 --- /dev/null +++ b/include/badge_setting_service.h @@ -0,0 +1,39 @@ +/* + * libbadge + * + * Copyright (c) 2000 - 2012 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 <badge_error.h> + +#ifdef __cplusplus +extern "C" { +#endif + +badge_error_e badge_setting_db_set(const char *pkgname, const char *property, const char *value); +badge_error_e badge_setting_db_get(const char *pkgname, const char *property, char **value); + +#ifdef __cplusplus +} +#endif +#endif |