summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMi-Ju Lee <miju52.lee@samsung.com>2018-12-14 10:50:21 (GMT)
committermk5004.lee <mk5004.lee@samsung.com>2019-01-11 02:17:57 (GMT)
commit68e3717e197af1879c3f45ab4954b5446a6260df (patch)
tree1cd1e99fde5c0024e73961bdaf66984ac23d08c3
parent141507aa0d18e567f32e1862355d3fad9ae6d640 (diff)
downloadbadge-68e3717e197af1879c3f45ab4954b5446a6260df.zip
badge-68e3717e197af1879c3f45ab4954b5446a6260df.tar.gz
badge-68e3717e197af1879c3f45ab4954b5446a6260df.tar.bz2
Add badge_new_for APIrefs/changes/76/195576/2
Change-Id: I7f467d045e5ce52962e9d038c80e3ed22a0806ba
-rw-r--r--include/badge_internal.h34
-rw-r--r--src/badge_internal.c46
2 files changed, 80 insertions, 0 deletions
diff --git a/include/badge_internal.h b/include/badge_internal.h
index a0fe5ba..ed0988a 100644
--- a/include/badge_internal.h
+++ b/include/badge_internal.h
@@ -201,6 +201,40 @@ int badge_create_for_uid(const char *pkgname, const char *writable_pkg, uid_t ui
int badge_new_for_uid(const char *writable_app_id, uid_t uid);
+/**
+ * @internal
+ * @brief Creates a badge for the application specified by the badge_app_id.
+ * @since_tizen 5.5
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/notification
+ * @details Creates new badge to display.
+ * @param[in] badge_app_id The id of the application for which the badge will be created. This should be the same package id with the caller application's package id
+ * @param[in] writable_app_id The id of the application which is authorized to change the badge
+ * @return #BADGE_ERROR_NONE if success, other value if failure
+ * @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_IO_ERROR Error from I/O
+ * @retval #BADGE_ERROR_SERVICE_NOT_READY Service is not ready
+ * @retval #BADGE_ERROR_INVALID_PACKAGE Error while caller package is different with the id of the application badge creates
+ * @see #badge_error_e
+ * @par Sample code:
+ * @code
+#include <badge_internal.h>
+
+{
+ int err = BADGE_ERROR_NONE;
+
+ err = badge_new_for(badge_app_id,app_id);
+ if(err != BADGE_ERROR_NONE) {
+ return;
+ }
+}
+ * @endcode
+ */
+int badge_new_for(const char *badge_app_id, const char *writable_app_id);
+int badge_new_for_for_uid(const char *badge_app_id, const char *writable_app_id, uid_t uid);
+
int badge_add_for_uid(const char *badge_app_id, uid_t uid);
int badge_remove_for_uid(const char *app_id, uid_t uid);
diff --git a/src/badge_internal.c b/src/badge_internal.c
index 1046e6f..701f7b4 100644
--- a/src/badge_internal.c
+++ b/src/badge_internal.c
@@ -1357,6 +1357,52 @@ int badge_new_for_uid(const char *writable_app_id, uid_t uid)
return err;
}
+int badge_new_for_for_uid(const char *badge_app_id, const char *writable_app_id, uid_t uid)
+{
+ CHECK_BADGE_FEATURE();
+ char *caller = NULL;
+ int err = BADGE_ERROR_NONE;
+
+ caller = _badge_get_pkgname_by_pid();
+ if (!caller) {
+ ERR("Failed to get caller pkgname");
+ return BADGE_ERROR_PERMISSION_DENIED;
+ }
+
+ if (badge_app_id == NULL) {
+ badge_app_id = caller;
+ } else {
+ int pkgmgr_ret = PACKAGE_MANAGER_ERROR_NONE;
+ package_manager_compare_result_type_e compare_result =
+ PACKAGE_MANAGER_COMPARE_MISMATCH;
+
+ pkgmgr_ret = package_manager_compare_app_cert_info(badge_app_id,
+ caller, &compare_result);
+
+ if (pkgmgr_ret != PACKAGE_MANAGER_ERROR_NONE ||
+ compare_result != PACKAGE_MANAGER_COMPARE_MATCH) {
+ err = BADGE_ERROR_INVALID_PACKAGE;
+ goto out;
+ }
+ }
+
+ err = badge_ipc_request_insert(badge_app_id, writable_app_id, caller, uid);
+out:
+ if (caller)
+ free(caller);
+ return err;
+}
+
+EXPORT_API
+int badge_new_for(const char *badge_app_id, const char *writable_app_id)
+{
+ CHECK_BADGE_FEATURE();
+ if (writable_app_id == NULL)
+ return BADGE_ERROR_INVALID_PARAMETER;
+
+ return badge_new_for_for_uid(badge_app_id, writable_app_id, getuid());
+}
+
EXPORT_API
int badge_add_for_uid(const char *badge_app_id, uid_t uid)
{