NOTIFICATION_DEPRECATED_API int notification_delete_group_by_priv_id(const char *app_id,
notification_type_e type,
int priv_id);
+
+/**
+ * @brief This function will be deprecated.
+ *
+ */
+NOTIFICATION_DEPRECATED_API int notifiation_clear(notification_type_e type);
+
/**
* @brief This function will be deprecated.
*
int *count);
/**
- * @brief This function will be deprecated.
- *
+ * @internal
+ * @brief
+ * @details Gets the numbers of all notifications
+ * @since tizen 4.0
+ * @param[int] type the type of notification
+ * @param[out] count the numbers of all notifications
+ * @return NOTIFICATION_ERROR_NONE on success, other value on failure
+ * @retval NOTIFICATION_ERROR_NONE Success
+ * @retval NOTIFICATION_ERROR_INVALID_PARAMETER Invalid input value
+ * @retval NOTIFICATION_ERROR_IO_ERROR I/O Error
+ * @retval NOTIFICATION_ERROR_FROM_DB Error from DB
+ * @retval NOTIFICATION_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
*/
-NOTIFICATION_DEPRECATED_API int notifiation_clear(notification_type_e type);
+int notification_get_all_count(notification_type_e type, int *count);
+int notification_get_all_count_for_uid(notification_type_e type, int *count, uid_t uid);
/**
* @internal
int notification_ipc_send_event(notification_h noti, int event_type, int priv_id);
int notification_ipc_check_event_receiver(int priv_id, bool *available);
void notification_ipc_reset_event_handler(int priv_id);
+int notification_ipc_request_get_all_count(notification_type_e type, int *count, uid_t uid);
#ifdef __cplusplus
}
#endif
int group_id, int priv_id,
int *count, uid_t uid);
+int notification_noti_get_all_count(notification_type_e type, int *count, uid_t uid);
+
int notification_noti_get_grouping_list(notification_type_e type,
int count,
notification_list_h *list,
* limitations under the License.
*/
+#define NOTIFICATION_DB_TABLE "noti_list"
#define NOTIFICATION_SETTING_DB_TABLE "notification_setting"
#define NOTIFICATION_SYSTEM_SETTING_DB_TABLE "notification_system_setting"
#define NOTIFICATION_DND_ALLOW_EXCEPTION "dnd_allow_exception"
return ret;
}
+
+EXPORT_API int notification_get_all_count_for_uid(notification_type_e type, int *count, uid_t uid)
+{
+ int ret;
+
+ if (count == NULL) {
+ NOTIFICATION_ERR("Invalid parameter - count is null");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type < NOTIFICATION_TYPE_NONE || type > NOTIFICATION_TYPE_MAX) {
+ NOTIFICATION_ERR("Invalid parameter - wrong type");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = notification_ipc_request_get_all_count(type, count, uid);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ NOTIFICATION_ERR("Failed to get count [%d]", ret);
+ return ret;
+ }
+
+ return ret;
+}
+
+EXPORT_API int notification_get_all_count(notification_type_e type, int *count)
+{
+ return notification_get_all_count_for_uid(type, count, getuid());
+}
+
return ret;
}
+int notification_ipc_request_get_all_count(notification_type_e type, int *count, uid_t uid)
+{
+ int ret;
+ int ret_count = -1;
+ GDBusMessage *reply = NULL;
+ GVariant *reply_body = NULL;
+
+ ret = _dbus_init();
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ NOTIFICATION_ERR("Failed to init dbus connection[%d]", ret);
+ return ret;
+ }
+
+ ret = _send_sync_noti(g_variant_new("(ii)", type, uid),
+ &reply, "get_noti_all_count");
+ if (ret == NOTIFICATION_ERROR_NONE) {
+ reply_body = g_dbus_message_get_body(reply);
+ g_variant_get(reply_body, "(i)", &ret_count);
+ *count = ret_count;
+ }
+
+ if (reply)
+ g_object_unref(reply);
+
+ return ret;
+}
+
int notification_ipc_send_event(notification_h noti, int event_type, int priv_id)
{
int ret;
}
/* LCOV_EXCL_STOP */
+EXPORT_API int notification_noti_get_all_count(notification_type_e type, int *count, uid_t uid)
+{
+ int ret = NOTIFICATION_ERROR_NONE;
+ int sql_ret;
+ sqlite3 *db = NULL;
+ sqlite3_stmt *stmt = NULL;
+ char *sql_buf = NULL;
+
+ if (count == NULL) {
+ NOTIFICATION_ERR("Invalid parameter - count is null");
+ return NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ db = notification_db_open(DBPATH);
+ if (db == NULL) {
+ ret = get_last_result();
+ NOTIFICATION_ERR("Failed to open db [%d]", ret);
+ return ret;
+ }
+
+ if (type != NOTIFICATION_TYPE_NONE)
+ sql_buf = sqlite3_mprintf("SELECT count(*) FROM %q "
+ "WHERE uid = %d AND type = %d",
+ NOTIFICATION_DB_TABLE, uid, type);
+ else
+ sql_buf = sqlite3_mprintf("SELECT count(*) FROM %q WHERE uid = %d",
+ NOTIFICATION_DB_TABLE, uid);
+
+ if (sql_buf == NULL) {
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ NOTIFICATION_ERR("OOM - sqlite3_mprintf");
+ goto out;
+ }
+
+ sql_ret = sqlite3_prepare_v2(db, sql_buf, -1, &stmt, NULL);
+ if (sql_ret != SQLITE_OK) {
+ ret = NOTIFICATION_ERROR_FROM_DB;
+ NOTIFICATION_ERR("SQLITE3 Error - sqlite3_prepare_v2 [%d][%s]",
+ sql_ret, sqlite3_errmsg(db));
+ goto out;
+ }
+
+ sql_ret = sqlite3_step(stmt);
+ if (sql_ret == SQLITE_ROW)
+ *count = sqlite3_column_int(stmt, 0);
+ else
+ *count = 0;
+
+ NOTIFICATION_INFO("The numbers of all notification is [%d]", *count);
+
+out:
+ if (stmt)
+ sqlite3_finalize(stmt);
+ if (sql_buf)
+ sqlite3_free(sql_buf);
+ if (db)
+ notification_db_close(&db);
+
+ return ret;
+}
+
EXPORT_API int notification_noti_get_grouping_list(notification_type_e type,
int count,
notification_list_h *list,