#include <notification.h>
#include <gio/gio.h>
#include <alarm.h>
+#include <aul.h>
#include "pkgmgr.h"
#include "service_common.h"
#include <notification_db.h>
#define PROVIDER_NOTI_INTERFACE_NAME "org.tizen.data_provider_noti_service"
+#define NOTI_TEMPLATE_LIMIT 10
+#define BUF_LEN 256
typedef struct _dnd_alarm_id dnd_alarm_id_s;
GVariant *reply_body = NULL;
int ret = NOTIFICATION_ERROR_INVALID_OPERATION;
- int uid = get_sender_uid(sender);
+ uid_t uid = get_sender_uid(sender);
+ pid_t pid = get_sender_pid(sender);
if (g_strcmp0(method_name, "noti_service_register") == 0)
ret = service_register(parameters, &reply_body, sender,
ret = notification_get_setting_by_package_name(parameters, &reply_body, uid);
else if (g_strcmp0(method_name, "load_system_setting") == 0)
ret = notification_load_system_setting(parameters, &reply_body, uid);
+ else if (g_strcmp0(method_name, "save_as_template") == 0)
+ ret = notification_add_noti_template(parameters, &reply_body, uid);
+ else if (g_strcmp0(method_name, "create_from_template") == 0)
+ ret = notification_get_noti_template(parameters, &reply_body, pid, uid);
+ else if (g_strcmp0(method_name, "create_from_package_template") == 0)
+ ret = notification_get_noti_package_template(parameters, &reply_body, uid);
if (ret == NOTIFICATION_ERROR_NONE) {
DbgPrint("notification service success : %d", ret);
" <arg type='v' name='setting' direction='out'/>"
" </method>"
+ " <method name='save_as_template'>"
+ " <arg type='v' name='noti' direction='in'/>"
+ " <arg type='s' name='name' direction='in'/>"
+ " </method>"
+
+ " <method name='create_from_template'>"
+ " <arg type='s' name='name' direction='in'/>"
+ " <arg type='v' name='noti' direction='out'/>"
+ " </method>"
+
+ " <method name='create_from_package_template'>"
+ " <arg type='s' name='appid' direction='in'/>"
+ " <arg type='s' name='name' direction='in'/>"
+ " <arg type='v' name='noti' direction='out'/>"
+ " </method>"
+
" <method name='post_toast'>"
" </method>"
" </interface>"
ErrPrint("cannot make reply_body");
return NOTIFICATION_ERROR_OUT_OF_MEMORY;
}
+
DbgPrint("_del_noti_multiple done !!");
return ret;
}
return ret;
}
+int notification_add_noti_template(GVariant *parameters, GVariant **reply_body, uid_t uid)
+{
+ notification_h noti;
+ int ret;
+ GVariant *body = NULL;
+ GVariant *coupled_body = NULL;
+ char *template_name = NULL;
+ int count = 0;
+
+ noti = notification_create(NOTIFICATION_TYPE_NOTI);
+ if (noti != NULL) {
+ g_variant_get(parameters, "(v&s)", &coupled_body, &template_name);
+ g_variant_get(coupled_body, "(v)", &body);
+
+ ret = notification_ipc_make_noti_from_gvariant(noti, body);
+ g_variant_unref(coupled_body);
+ g_variant_unref(body);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ErrPrint("failed to make a notification:%d\n", ret);
+ return ret;
+ }
+
+ ret = notification_noti_check_count_for_template(noti, &count);
+ if (count > NOTI_TEMPLATE_LIMIT)
+ return NOTIFICATION_ERROR_MAX_EXCEEDED;
+
+ ret = notification_noti_add_template(noti, template_name);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ErrPrint("failed to add a notification:%d\n", ret);
+ return ret;
+ }
+ } else {
+ ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ return ret;
+}
+
+int notification_get_noti_template(GVariant *parameters, GVariant **reply_body, pid_t pid, uid_t uid)
+{
+ int ret;
+ char appid[BUF_LEN] = {0, };
+ char *template_name = NULL;
+ notification_h noti;
+
+ noti = notification_create(NOTIFICATION_TYPE_NOTI);
+ if (noti != NULL) {
+ g_variant_get(parameters, "(&s)", &template_name);
+
+ ret = aul_app_get_appid_bypid_for_uid(pid, appid, sizeof(appid), uid);
+ if (ret != AUL_R_OK) {
+ ErrPrint("failed to get appid:%d", ret);
+ return ret;
+ }
+
+ ret = notification_noti_get_package_template(noti, appid, template_name);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ DbgPrint("failed to get template:%d", ret);
+ return ret;
+ }
+
+ *reply_body = notification_ipc_make_gvariant_from_noti(noti, false);
+ notification_free(noti);
+
+ if (*reply_body == NULL) {
+ ErrPrint("cannot make reply_body");
+ return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ DbgPrint("_get_noti_template done !!");
+ return ret;
+}
+
+int notification_get_noti_package_template(GVariant *parameters, GVariant **reply_body, uid_t uid)
+{
+ int ret;
+ char *pkgname = NULL;
+ char *template_name = NULL;
+ notification_h noti;
+
+ noti = notification_create(NOTIFICATION_TYPE_NOTI);
+ if (noti != NULL) {
+ g_variant_get(parameters, "(&s&s)", &pkgname, &template_name);
+
+ ret = notification_noti_get_package_template(noti, pkgname, template_name);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ DbgPrint("failed to get template:%d", ret);
+ return ret;
+ }
+
+ *reply_body = notification_ipc_make_gvariant_from_noti(noti, false);
+ notification_free(noti);
+
+ if (*reply_body == NULL) {
+ ErrPrint("cannot make reply_body");
+ return NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ DbgPrint("_get_noti_package_template done !!");
+ return ret;
+}
+
static void _notification_data_init(void)
{
int property = 0;
static int _package_uninstall_cb(uid_t uid, const char *pkgname, enum pkgmgr_status status, double value, void *data)
{
notification_setting_delete_package_for_uid(pkgname, uid);
+ notification_noti_delete_template(pkgname);
return 0;
}