Apply private file sharing 23/135723/11
authorjusung son <jusung07.son@samsung.com>
Mon, 26 Jun 2017 05:58:54 +0000 (14:58 +0900)
committerjusung son <jusung07.son@samsung.com>
Thu, 6 Jul 2017 10:50:32 +0000 (19:50 +0900)
- Related patch
  [notification] https://review.tizen.org/gerrit/#/c/134317//

Change-Id: I40f177335cdbfed90b86dfbb96b1bcdbc9682c0c
Signed-off-by: jusung son <jusung07.son@samsung.com>
src/notification_service.c

index a5ed603..a0a334f 100755 (executable)
@@ -37,6 +37,7 @@
 #include <notification_setting_service.h>
 #include <notification_db.h>
 #include <notification_viewer.h>
+#include <notification_shared_file.h>
 
 #define PROVIDER_NOTI_INTERFACE_NAME "org.tizen.data_provider_noti_service"
 #define PROVIDER_NOTI_EVENT_INTERFACE_NAME "org.tizen.data_provider_noti_event_service"
@@ -90,10 +91,12 @@ static void _on_name_vanished(GDBusConnection *connection,
                const gchar     *name,
                gpointer         user_data)
 {
-       DbgPrint("name vanished : %s", name);
        monitoring_info_s *info = (monitoring_info_s *)user_data;
+
+       DbgPrint("name vanished : %s", name);
        if (info) {
                DbgPrint("name vanished uid : %d", info->uid);
+               notification_remove_private_sharing_target_id(name, info->uid);
                g_bus_unwatch_name(info->watcher_id);
                delete_monitoring_list(&_monitoring_hash, info->bus_name, info->uid);
 
@@ -117,59 +120,89 @@ static void _noti_dbus_method_call_handler(GDBusConnection *conn,
        uid_t uid = get_sender_uid(sender);
        pid_t pid = get_sender_pid(sender);
 
-       if (g_strcmp0(method_name, "noti_service_register") == 0)
+       if (g_strcmp0(method_name, "noti_service_register") == 0) {
                ret = service_register(parameters, &reply_body, sender,
                                _on_name_appeared, _on_name_vanished, &_monitoring_hash, uid);
-       else if (g_strcmp0(method_name, "update_noti") == 0)
+               if (ret == NOTIFICATION_ERROR_NONE)
+                       notification_add_private_sharing_target_id(pid, sender, uid);
+       }
+       else if (g_strcmp0(method_name, "update_noti") == 0) {
                ret = notification_update_noti(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "add_noti") == 0)
+       }
+       else if (g_strcmp0(method_name, "add_noti") == 0) {
                ret = notification_add_noti(parameters, &reply_body, sender, uid);
-       else if (g_strcmp0(method_name, "refresh_noti") == 0)
+       }
+       else if (g_strcmp0(method_name, "refresh_noti") == 0) {
                ret = notification_refresh_noti(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "del_noti_single") == 0)
+       }
+       else if (g_strcmp0(method_name, "del_noti_single") == 0) {
                ret = notification_del_noti_single(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "del_noti_multiple") == 0)
+       }
+       else if (g_strcmp0(method_name, "del_noti_multiple") == 0) {
                ret = notification_del_noti_multiple(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "get_noti_count") == 0)
+       }
+       else if (g_strcmp0(method_name, "get_noti_count") == 0) {
                ret = notification_get_noti_count(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "update_noti_setting") == 0)
+       }
+       else if (g_strcmp0(method_name, "update_noti_setting") == 0) {
                ret = notification_update_noti_setting(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "update_noti_sys_setting") == 0)
+       }
+       else if (g_strcmp0(method_name, "update_noti_sys_setting") == 0) {
                ret = notification_update_noti_sys_setting(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "load_noti_by_tag") == 0)
+       }
+       else if (g_strcmp0(method_name, "load_noti_by_tag") == 0) {
                ret = notification_load_noti_by_tag(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "load_noti_by_priv_id") == 0)
+       }
+       else if (g_strcmp0(method_name, "load_noti_by_priv_id") == 0) {
                ret = notification_load_noti_by_priv_id(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "load_noti_grouping_list") == 0)
+       }
+       else if (g_strcmp0(method_name, "load_noti_grouping_list") == 0) {
+               notification_add_private_sharing_target_id(pid, sender, uid);
                ret = notification_load_grouping_list(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "load_noti_detail_list") == 0)
+       }
+       else if (g_strcmp0(method_name, "load_noti_detail_list") == 0) {
+               notification_add_private_sharing_target_id(pid, sender, uid);
                ret = notification_load_detail_list(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "get_setting_array") == 0)
+       }
+       else if (g_strcmp0(method_name, "get_setting_array") == 0) {
                ret = notification_get_setting_array(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "get_setting_by_app_id") == 0)
+       }
+       else if (g_strcmp0(method_name, "get_setting_by_app_id") == 0) {
                ret = notification_get_setting_by_app_id(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "load_system_setting") == 0)
+       }
+       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)
+       }
+       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)
+       }
+       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)
+       }
+       else if (g_strcmp0(method_name, "create_from_package_template") == 0) {
                ret = notification_get_noti_package_template(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "get_noti_block_state") == 0)
+       }
+       else if (g_strcmp0(method_name, "get_noti_block_state") == 0) {
                ret = notification_get_block_state(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "load_dnd_allow_exception") == 0)
+       }
+       else if (g_strcmp0(method_name, "load_dnd_allow_exception") == 0) {
                ret = notification_load_dnd_allow_exception(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "update_dnd_allow_exception") == 0)
+       }
+       else if (g_strcmp0(method_name, "update_dnd_allow_exception") == 0) {
                ret = notification_update_dnd_allow_exception(parameters, &reply_body, uid);
-       else if (g_strcmp0(method_name, "send_noti_event") == 0)
+       }
+       else if (g_strcmp0(method_name, "send_noti_event") == 0) {
                ret = notification_send_noti_event(parameters, &reply_body);
-       else if (g_strcmp0(method_name, "send_noti_event_by_priv_id") == 0)
+       }
+       else if (g_strcmp0(method_name, "send_noti_event_by_priv_id") == 0) {
                ret = notification_send_noti_event_by_priv_id(parameters, &reply_body);
-       else if (g_strcmp0(method_name, "check_event_receiver") == 0)
+       }
+       else if (g_strcmp0(method_name, "check_event_receiver") == 0) {
                ret = notification_check_event_receiver(parameters, &reply_body);
-       else if (g_strcmp0(method_name, "reset_event_handler") == 0)
+       }
+       else if (g_strcmp0(method_name, "reset_event_handler") == 0) {
                ret = notification_reset_event_receiver(parameters, &reply_body, sender);
+       }
 
        if (ret == NOTIFICATION_ERROR_NONE) {
                DbgPrint("notification service success : %d", ret);
@@ -415,6 +448,8 @@ static int _add_noti(GVariant **reply_body, notification_h noti, uid_t uid)
                return ret;
        }
 
+       notification_set_private_sharing(noti, uid);
+
        body = notification_ipc_make_gvariant_from_noti(noti, true);
        if (body == NULL) {
                ErrPrint("cannot make gvariant to noti");
@@ -657,8 +692,19 @@ static int _update_noti(GVariant **reply_body, notification_h noti, uid_t uid)
        int ret;
        GVariant *body = NULL;
        int priv_id = NOTIFICATION_PRIV_ID_NONE;
+       notification_h source_noti;
 
        print_noti(noti);
+
+       if (notification_validate_private_sharing(noti) == false) {
+               source_noti = notification_create(NOTIFICATION_TYPE_NOTI);
+               notification_get_id(noti, NULL, &priv_id);
+               notification_noti_get_by_priv_id(source_noti, priv_id);
+
+               notification_calibrate_private_sharing(noti, source_noti);
+               notification_free(source_noti);
+       }
+
        ret = notification_noti_update(noti);
        if (ret != NOTIFICATION_ERROR_NONE) {
                ErrPrint("failed to update a notification:%d\n", ret);
@@ -671,6 +717,8 @@ static int _update_noti(GVariant **reply_body, notification_h noti, uid_t uid)
                return ret;
        }
 
+       notification_set_private_sharing(noti, uid);
+
        body = notification_ipc_make_gvariant_from_noti(noti, true);
        if (body == NULL) {
                ErrPrint("cannot make gvariant to noti");
@@ -838,6 +886,7 @@ int notification_load_grouping_list(GVariant *parameters, GVariant **reply_body,
                list_iter = notification_list_get_head(get_list);
                do {
                        noti = notification_list_get_data(list_iter);
+                       notification_set_private_sharing(noti, param_uid);
                        body = notification_ipc_make_gvariant_from_noti(noti, true);
                        g_variant_builder_add(builder, "(v)", body);
 
@@ -1069,6 +1118,7 @@ int notification_load_detail_list(GVariant *parameters, GVariant **reply_body, u
                list_iter = notification_list_get_head(get_list);
                do {
                        noti = notification_list_get_data(list_iter);
+                       notification_set_private_sharing(noti, param_uid);
                        body = notification_ipc_make_gvariant_from_noti(noti, true);
                        if (body) {
                                g_variant_builder_add(builder, "(v)", body);
@@ -1182,6 +1232,8 @@ int notification_del_noti_single(GVariant *parameters, GVariant **reply_body, ui
                        return ret;
                }
 
+               notification_remove_private_sharing(app_id, priv_id, param_uid);
+
                ret = __delete_sender_info(priv_id);
                if (ret != NOTIFICATION_ERROR_NONE)
                        return ret;
@@ -1242,6 +1294,7 @@ int notification_del_noti_multiple(GVariant *parameters, GVariant **reply_body,
                }
 
                for (i = 0; i < num_deleted; i++) {
+                       notification_remove_private_sharing(app_id, *(list_deleted + i), param_uid);
                        ret = __delete_sender_info(*(list_deleted + i));
                        if (ret != NOTIFICATION_ERROR_NONE)
                                return ret;