summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Son <seungha.son@samsung.com>2017-08-03 13:20:58 +0900
committerSeungha Son <seungha.son@samsung.com>2017-08-03 15:51:29 +0900
commitfd658b3734033663687088613d29c69c80e00501 (patch)
treea10896edacc4126eb1ad2e0eb8ce65cb3c0c5d96
parentaefca08c2befade03e8a3153ac54feff31cb9bf9 (diff)
downloadbadge-fd658b3734033663687088613d29c69c80e00501.tar.gz
badge-fd658b3734033663687088613d29c69c80e00501.tar.bz2
badge-fd658b3734033663687088613d29c69c80e00501.zip
Add badge feature
Signed-off-by: Seungha Son <seungha.son@samsung.com> Change-Id: I7910a4f183aeaa1f511ff1368584ff428e6aceea
-rwxr-xr-xCMakeLists.txt1
-rwxr-xr-xdoc/badge_doc.h8
-rwxr-xr-xinclude/badge.h10
-rwxr-xr-xinclude/badge_error.h1
-rwxr-xr-xinclude/badge_internal.h9
-rw-r--r--include/badge_private.h43
-rwxr-xr-xpackaging/badge.spec1
-rwxr-xr-xsrc/badge.c11
-rwxr-xr-xsrc/badge_internal.c18
9 files changed, 100 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fa0c6a..9681930 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,7 @@ pkg_check_modules(pkgs REQUIRED
dbus-glib-1
vconf
capi-appfw-package-manager
+ capi-system-info
db-util
libtzplatform-config
pkgmgr-info
diff --git a/doc/badge_doc.h b/doc/badge_doc.h
index 884f696..975a594 100755
--- a/doc/badge_doc.h
+++ b/doc/badge_doc.h
@@ -30,4 +30,12 @@
*
* @section BADGE_MODULE_OVERVIEW Overview
* It provides functions for creating and inserting and updating badge.
+ *
+ * @section CAPI_BADGE_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/badge\n
+ * It is recommended to design feature related codes in your application for reliability.\n
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
*/
diff --git a/include/badge.h b/include/badge.h
index 1cd6a29..7137d1f 100755
--- a/include/badge.h
+++ b/include/badge.h
@@ -51,6 +51,7 @@ extern "C" {
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
* @retval BADGE_ERROR_IO_ERROR Error from I/O
* @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @par Sample code:
* @code
@@ -82,6 +83,7 @@ int badge_new(const char *writable_app_id) TIZEN_DEPRECATED_API;
* @retval #BADGE_ERROR_IO_ERROR Error from I/O
* @retval #BADGE_ERROR_SERVICE_NOT_READY Service is not ready
* @retval #BADGE_ERROR_INVALID_PACKAGE The caller application is not signed with the certificate of the badge_app_id
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @par Sample code:
* @code
@@ -111,6 +113,7 @@ int badge_add(const char *badge_app_id);
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
* @retval BADGE_ERROR_IO_ERROR Error from I/O
* @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @par Sample code:
* @code
@@ -141,6 +144,7 @@ int badge_remove(const char *app_id);
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
* @retval BADGE_ERROR_IO_ERROR Error from I/O
* @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_new()
* @par Sample code:
@@ -173,6 +177,7 @@ int badge_set_count(const char *app_id, unsigned int count);
* @retval BADGE_ERROR_FROM_DB Error from DB
* @retval BADGE_ERROR_ALREADY_EXIST Already exist
* @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_new()
* @see badge_set_count()
@@ -206,6 +211,7 @@ int badge_get_count(const char *app_id, unsigned int *count);
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
* @retval BADGE_ERROR_IO_ERROR Error from I/O
* @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_new()
* @par Sample code:
@@ -239,6 +245,7 @@ int badge_set_display(const char *app_id, unsigned int is_display);
* @retval BADGE_ERROR_NOT_EXIST Not exist
* @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
* @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_new()
* @see badge_set_count()
@@ -285,6 +292,7 @@ typedef bool (*badge_foreach_cb)(const char *app_id, unsigned int count, void *u
* @retval BADGE_ERROR_FROM_DB Error form DB
* @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
* @retval BADGE_ERROR_NOT_EXIST Not exist
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_foreach_cb()
*/
@@ -328,6 +336,7 @@ typedef void (*badge_change_cb)(unsigned int action, const char *app_id,
* @retval BADGE_ERROR_INVALID_PARAMETER Invalid parameter
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
* @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_new()
* @see badge_remove()
@@ -346,6 +355,7 @@ int badge_register_changed_cb(badge_change_cb callback, void *user_data);
* @retval BADGE_ERROR_INVALID_PARAMETER Invalid parameter
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
* @retval BADGE_ERROR_NOT_EXIST Not exist
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_register_changed_cb()
*/
diff --git a/include/badge_error.h b/include/badge_error.h
index 7651756..c1dac61 100755
--- a/include/badge_error.h
+++ b/include/badge_error.h
@@ -44,6 +44,7 @@ typedef enum _badge_error_e {
BADGE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
BADGE_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
BADGE_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Error from I/O */
+ BADGE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 4.0) */
BADGE_ERROR_FROM_DB = TIZEN_ERROR_BADGE | 0x01, /**< Error from DB */
BADGE_ERROR_ALREADY_EXIST = TIZEN_ERROR_BADGE | 0x02, /**< Already exist */
BADGE_ERROR_FROM_DBUS = TIZEN_ERROR_BADGE | 0x03, /**< Error from DBus */
diff --git a/include/badge_internal.h b/include/badge_internal.h
index 64e55f0..a0fe5ba 100755
--- a/include/badge_internal.h
+++ b/include/badge_internal.h
@@ -56,8 +56,9 @@ typedef struct badge_info {
* @privilege %http://tizen.org/privilege/notification
* @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
* @return 1 if badge service is ready, other value if badge service isn't ready
- * @exception BADGE_ERROR_NONE Success
- * @exception BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval BADGE_ERROR_NONE Success
+ * @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
*/
int badge_is_service_ready(void);
@@ -73,6 +74,7 @@ int badge_is_service_ready(void);
* @retval BADGE_ERROR_NONE Success
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
* @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_is_service_ready()
*/
@@ -90,6 +92,7 @@ int badge_add_deferred_task(
* @retval BADGE_ERROR_NONE Success
* @retval BADGE_ERROR_INVALID_PARAMETER Invalid parameter
* @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_is_service_ready()
*/
@@ -112,6 +115,7 @@ int badge_del_deferred_task(
* @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
* @retval BADGE_ERROR_NOT_EXIST Not exist
* @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @see badge_new()
* @see badge_remove()
@@ -174,6 +178,7 @@ void badge_changed_cb_call(unsigned int action, const char *pkgname,
* @param[in] pkgname The name of the designated package
* @param[in] writable_pkg The name of package which is authorized to change the badge
* @return #BADGE_ERROR_NONE if success, other value if failure
+ * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
* @see #badge_error_e
* @par Sample code:
* @code
diff --git a/include/badge_private.h b/include/badge_private.h
new file mode 100644
index 0000000..c26cca1
--- /dev/null
+++ b/include/badge_private.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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_PRIVATE_H__
+#define __BADGE_PRIVATE_H__
+
+#include <system_info.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define BADGE_FEATURE "http://tizen.org/feature/badge"
+#define CHECK_BADGE_FEATURE() \
+ do { \
+ bool is_supported = false; \
+ if (!system_info_get_platform_bool(BADGE_FEATURE, &is_supported)) { \
+ if (is_supported == false) { \
+ LOGE("[%s] feature is disabled", BADGE_FEATURE); \
+ return BADGE_ERROR_NOT_SUPPORTED; \
+ } \
+ } \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __BADGE_PRIVATE_H__ */
diff --git a/packaging/badge.spec b/packaging/badge.spec
index 1daa468..0a113b4 100755
--- a/packaging/badge.spec
+++ b/packaging/badge.spec
@@ -15,6 +15,7 @@ BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(libsmack)
+BuildRequires: pkgconfig(capi-system-info)
BuildRequires: cmake
Requires(post): /sbin/ldconfig
requires(postun): /sbin/ldconfig
diff --git a/src/badge.c b/src/badge.c
index 15df5c2..78cb88d 100755
--- a/src/badge.c
+++ b/src/badge.c
@@ -27,11 +27,13 @@
#include "badge_error.h"
#include "badge_internal.h"
#include "badge_ipc.h"
+#include "badge_private.h"
EXPORT_API
int badge_new(const char *writable_app_id)
{
dlog_print(DLOG_WARN, LOG_TAG, "DEPRECATION WARNING: badge_new() is deprecated and will be removed from next release. Use badge_add() instead.");
+ CHECK_BADGE_FEATURE();
if (writable_app_id == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -41,12 +43,14 @@ int badge_new(const char *writable_app_id)
EXPORT_API
int badge_add(const char *badge_app_id)
{
+ CHECK_BADGE_FEATURE();
return badge_add_for_uid(badge_app_id, getuid());
}
EXPORT_API
int badge_remove(const char *app_id)
{
+ CHECK_BADGE_FEATURE();
if (app_id == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -56,6 +60,7 @@ int badge_remove(const char *app_id)
EXPORT_API
int badge_foreach(badge_foreach_cb callback, void *user_data)
{
+ CHECK_BADGE_FEATURE();
if (callback == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -65,6 +70,7 @@ int badge_foreach(badge_foreach_cb callback, void *user_data)
EXPORT_API
int badge_set_count(const char *app_id, unsigned int count)
{
+ CHECK_BADGE_FEATURE();
if (app_id == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -74,6 +80,7 @@ int badge_set_count(const char *app_id, unsigned int count)
EXPORT_API
int badge_get_count(const char *app_id, unsigned int *count)
{
+ CHECK_BADGE_FEATURE();
if (app_id == NULL || count == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -83,6 +90,7 @@ int badge_get_count(const char *app_id, unsigned int *count)
EXPORT_API
int badge_set_display(const char *app_id, unsigned int is_display)
{
+ CHECK_BADGE_FEATURE();
if (app_id == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -92,6 +100,7 @@ int badge_set_display(const char *app_id, unsigned int is_display)
EXPORT_API
int badge_get_display(const char *app_id, unsigned int *is_display)
{
+ CHECK_BADGE_FEATURE();
if (app_id == NULL || is_display == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -101,6 +110,7 @@ int badge_get_display(const char *app_id, unsigned int *is_display)
EXPORT_API
int badge_register_changed_cb(badge_change_cb callback, void *data)
{
+ CHECK_BADGE_FEATURE();
if (callback == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -110,6 +120,7 @@ int badge_register_changed_cb(badge_change_cb callback, void *data)
EXPORT_API
int badge_unregister_changed_cb(badge_change_cb callback)
{
+ CHECK_BADGE_FEATURE();
if (callback == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
diff --git a/src/badge_internal.c b/src/badge_internal.c
index 21e9999..570b2f9 100755
--- a/src/badge_internal.c
+++ b/src/badge_internal.c
@@ -36,6 +36,7 @@
#include "badge_internal.h"
#include "badge_ipc.h"
#include "badge_db.h"
+#include "badge_private.h"
#define BADGE_PKGNAME_LEN 512
#define BADGE_TABLE_NAME "badge_data"
@@ -1321,6 +1322,7 @@ char *_badge_pkgs_new(int *err, const char *pkg1, ...)
EXPORT_API
int badge_create_for_uid(const char *pkgname, const char *writable_pkg, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
char *caller = NULL;
int err = BADGE_ERROR_NONE;
@@ -1339,6 +1341,7 @@ int badge_create_for_uid(const char *pkgname, const char *writable_pkg, uid_t ui
EXPORT_API
int badge_new_for_uid(const char *writable_app_id, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
char *caller = NULL;
int err = BADGE_ERROR_NONE;
@@ -1357,6 +1360,7 @@ int badge_new_for_uid(const char *writable_app_id, uid_t uid)
EXPORT_API
int badge_add_for_uid(const char *badge_app_id, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
char *caller = NULL;
int err = BADGE_ERROR_NONE;
@@ -1391,6 +1395,7 @@ out:
EXPORT_API
int badge_remove_for_uid(const char *app_id, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
char *caller = NULL;
int result = BADGE_ERROR_NONE;
@@ -1412,12 +1417,14 @@ out:
EXPORT_API
int badge_is_existing_for_uid(const char *app_id, bool *existing, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
return badge_ipc_request_is_existing(app_id, existing, uid);
}
EXPORT_API
int badge_foreach_for_uid(badge_foreach_cb callback, void *user_data, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
int result = BADGE_ERROR_NONE;
result = badge_ipc_request_get_list(callback, user_data, uid);
if (result == BADGE_ERROR_IO_ERROR)
@@ -1428,6 +1435,7 @@ int badge_foreach_for_uid(badge_foreach_cb callback, void *user_data, uid_t uid)
EXPORT_API
int badge_set_count_for_uid(const char *app_id, unsigned int count, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
char *caller = NULL;
int result = BADGE_ERROR_NONE;
@@ -1450,6 +1458,7 @@ out:
EXPORT_API
int badge_get_count_for_uid(const char *app_id, unsigned int *count, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
int result = BADGE_ERROR_NONE;
result = badge_ipc_request_get_count(app_id, count, uid);
@@ -1462,6 +1471,7 @@ int badge_get_count_for_uid(const char *app_id, unsigned int *count, uid_t uid)
EXPORT_API
int badge_set_display_for_uid(const char *app_id, unsigned int is_display, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
char *caller = NULL;
int result = BADGE_ERROR_NONE;
@@ -1483,6 +1493,7 @@ out:
EXPORT_API
int badge_get_display_for_uid(const char *app_id, unsigned int *is_display, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
int result = BADGE_ERROR_NONE;
result = badge_ipc_request_get_display(app_id, is_display, uid);
@@ -1495,6 +1506,7 @@ int badge_get_display_for_uid(const char *app_id, unsigned int *is_display, uid_
EXPORT_API
int badge_register_changed_cb_for_uid(badge_change_cb callback, void *data, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
struct _badge_cb_data *bd = NULL;
GList *badge_cb_list = NULL;
GList *badge_found_list = NULL;
@@ -1546,6 +1558,7 @@ int badge_register_changed_cb_for_uid(badge_change_cb callback, void *data, uid_
EXPORT_API
int badge_unregister_changed_cb_for_uid(badge_change_cb callback, uid_t uid)
{
+ CHECK_BADGE_FEATURE();
GList *badge_cb_list = NULL;
GList *badge_delete_list = NULL;
struct _badge_cb_data *bd = NULL;
@@ -1583,6 +1596,7 @@ int badge_unregister_changed_cb_for_uid(badge_change_cb callback, uid_t uid)
EXPORT_API
int badge_is_service_ready(void)
{
+ CHECK_BADGE_FEATURE();
return badge_ipc_is_master_ready();
}
@@ -1590,6 +1604,7 @@ EXPORT_API
int badge_add_deferred_task(
void (*badge_add_deferred_task)(void *data), void *user_data)
{
+ CHECK_BADGE_FEATURE();
return badge_ipc_add_deferred_task(badge_add_deferred_task, user_data);
}
@@ -1597,12 +1612,14 @@ EXPORT_API
int badge_del_deferred_task(
void (*badge_add_deferred_task)(void *data))
{
+ CHECK_BADGE_FEATURE();
return badge_ipc_del_deferred_task(badge_add_deferred_task);
}
EXPORT_API
int badge_is_existing(const char *app_id, bool *existing)
{
+ CHECK_BADGE_FEATURE();
if (app_id == NULL || existing == NULL)
return BADGE_ERROR_INVALID_PARAMETER;
@@ -1612,6 +1629,7 @@ int badge_is_existing(const char *app_id, bool *existing)
EXPORT_API
int badge_create(const char *pkgname, const char *writable_pkg)
{
+ CHECK_BADGE_FEATURE();
if (pkgname == NULL)
return BADGE_ERROR_INVALID_PARAMETER;