Merge branch 'tizen_2.2' of ssh://review.tizendev.org:29418/apps/home/notification... accepted/tizen/ivi/stable accepted/tizen_generic accepted/tizen_ivi_panda tizen_ivi_panda accepted/tizen/20131023.064031 accepted/tizen/20131023.171112 accepted/tizen/20131112.015237 accepted/tizen/ivi/panda/20140403.015148 accepted/tizen_ivi_stable/20131116.101645 submit/tizen/20131023.055614 submit/tizen_ivi_panda/20140403.011821 submit/tizen_ivi_stable/20131116.100111
authoryoungsub ko <ys4610.ko@samsung.com>
Wed, 23 Oct 2013 05:29:58 +0000 (14:29 +0900)
committeryoungsub ko <ys4610.ko@samsung.com>
Wed, 23 Oct 2013 05:29:58 +0000 (14:29 +0900)
Conflicts:
packaging/notification.spec
src/notification_ipc.c

1  2 
CMakeLists.txt
include/notification_ipc.h
packaging/notification.spec
src/notification.c
src/notification_ipc.c

diff --cc CMakeLists.txt
@@@ -37,7 -40,7 +39,6 @@@ pkg_check_modules(pkgs REQUIRE
        dlog 
        ail 
        aul 
--      appsvc
        dbus-1
        dbus-glib-1
        com-core
Simple merge
@@@ -14,11 -14,9 +14,10 @@@ BuildRequires: pkgconfig(dbus-1
  BuildRequires: pkgconfig(dlog)
  BuildRequires: pkgconfig(ail)
  BuildRequires: pkgconfig(aul)
--BuildRequires: pkgconfig(appsvc)
  BuildRequires: pkgconfig(dbus-glib-1)
  BuildRequires: pkgconfig(com-core)
 +BuildRequires: pkgconfig(ecore)
 +BuildRequires: pkgconfig(eina)
  
  BuildRequires: cmake
  Requires(post): /sbin/ldconfig
  
  chown :5000 /opt/dbspace/.notification.db
  chown :5000 /opt/dbspace/.notification.db-journal
 -chmod 640 /opt/dbspace/.notification.db
 -chmod 640 /opt/dbspace/.notification.db-journal
 +chmod 660 /opt/dbspace/.notification.db
 +chmod 660 /opt/dbspace/.notification.db-journal
+ chsmack -a 'notification::db' /opt/dbspace/.notification.db*
 -vconftool set -t string memory/private/libstatus/message "" -i -g 5000 -f
 +vconftool set -t string memory/private/libstatus/message "" -i -g 5000
  
  %postun -p /sbin/ldconfig
  
@@@ -30,7 -30,7 +30,6 @@@
  
  #include <aul.h>
  #include <ail.h>
--#include <appsvc.h>
  #include <vconf-keys.h>
  #include <vconf.h>
  
  #include <notification_internal.h>
  #include <notification_debug.h>
  
- #define NOTIFICATION_IPC_TIMEOUT 1.0
+ #define NOTIFICATION_IPC_TIMEOUT 0.0
  
 -#if !defined(VCONFKEY_MASTER_STARTED)
 -#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
 -#endif
 -
  static struct info {
        int server_fd;
+       int server_cl_fd;
+       int server_cl_fd_ref_cnt;
        int client_fd;
        const char *socket_file;
        struct {
        } server_cb;
        int initialized;
        int is_started_cb_set_svc;
 -      int is_started_cb_set_task;
  } s_info = {
        .server_fd = -1,
+       .server_cl_fd = -1,
+       .server_cl_fd_ref_cnt = 0,
        .client_fd = -1,
        .socket_file = NOTIFICATION_ADDR,
        .initialized = 0,
@@@ -65,21 -75,57 +69,26 @@@ struct _task_list 
        void *data;
  };
  
+ typedef struct _result_cb_item {
+       void (*result_cb)(int priv_id, int result, void *data);
+       void *data;
+ } result_cb_item;
  static task_list *g_task_list;
  
 -static notification_error_e notification_ipc_monitor_register(void);
 -static notification_error_e notification_ipc_monitor_deregister(void);
 -static void _do_deffered_task(void);
 -static void _master_started_cb_task(keynode_t *node, void *data);
 +static Eina_Bool _do_deffered_task(void *data);
  
 -/*!
 - * functions to check state of master
 +/*
 + * The concept of having to deffer a task till the "master" was
 + * started is now defunct since we use systemd to auto activate
 + * the service, with clients blissfully unaware of the state
 + * of the service at the time they attempt to use the socket.
 + *
 + * To enable backwards compatability we now setup an idle handler
 + * to cleanup all the deffered task.  This keeps the call behavior
 + * as non-blocking and is true to the original spirit (i.e. run
 + * the task when the service is available)
   */
 -static inline void _set_master_started_cb(vconf_callback_fn cb) {
 -      int ret = -1;
 -
 -      ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED,
 -                      cb, NULL);
 -      if (ret != 0) {
 -              NOTIFICATION_ERR("failed to notify key(%s) : %d",
 -                              VCONFKEY_MASTER_STARTED, ret);
 -      }
 -}
 -
 -static inline void _unset_master_started_cb(vconf_callback_fn cb) {
 -      int ret = -1;
 -
 -      ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED,
 -                      cb);
 -      if (ret != 0) {
 -              NOTIFICATION_ERR("failed to notify key(%s) : %d",
 -                              VCONFKEY_MASTER_STARTED, ret);
 -      }
 -}
 -
 -int notification_ipc_is_master_ready(void)
 -{
 -      int ret = -1, is_master_started = 0;
 -
 -      ret = vconf_get_bool(VCONFKEY_MASTER_STARTED, &is_master_started);
 -      if (ret == 0 && is_master_started == 1) {
 -              NOTIFICATION_ERR("the master has been started");
 -      } else {
 -              is_master_started = 0;
 -              NOTIFICATION_ERR("the master has been stopped");
 -      }
 -
 -      return is_master_started;
 -}
  
  notification_error_e
  notification_ipc_add_deffered_task(
@@@ -175,26 -226,61 +184,27 @@@ static Eina_Bool _do_deffered_task(voi
        task_list *list_do = NULL;
        task_list *list_temp = NULL;
  
 -      if (g_task_list == NULL) {
 -              return;
 -      }
 -
 -      list_do = g_task_list;
 -      g_task_list = NULL;
 -      if (s_info.is_started_cb_set_task == 1) {
 -              _unset_master_started_cb(_master_started_cb_task);
 -              s_info.is_started_cb_set_task = 0;
 -      }
 -      while (list_do->prev != NULL) {
 -              list_do = list_do->prev;
 -      }
 +      if (g_task_list) {
 +        list_do = g_task_list;
 +        g_task_list = NULL;
  
 -      while (list_do != NULL) {
 -              if (list_do->task_cb != NULL) {
 -                      list_do->task_cb(list_do->data);
 -                      NOTIFICATION_DBG("called:%p", list_do->task_cb);
 -              }
 -              list_temp = list_do->next;
 -              free(list_do);
 -              list_do = list_temp;
 -      }
 -}
 +        while (list_do->prev != NULL) {
 +            list_do = list_do->prev;
 +        }
  
 -static void _master_started_cb_service(keynode_t *node,
 -              void *data) {
 -      int ret = NOTIFICATION_ERROR_NONE;
 +        while (list_do != NULL) {
 +            if (list_do->task_cb != NULL) {
 +                list_do->task_cb(list_do->data);
 +                NOTIFICATION_DBG("called:%p", list_do->task_cb);
 +            }
 +            list_temp = list_do->next;
 +            free(list_do);
 +            list_do = list_temp;
 +        }
 +    }
  
 -      if (notification_ipc_is_master_ready()) {
 -              NOTIFICATION_ERR("try to register a notification service");
 -              ret = notification_ipc_monitor_deregister();
 -              if (ret != NOTIFICATION_ERROR_NONE) {
 -                      NOTIFICATION_ERR("failed to unregister a monitor");
 -              }
 -              ret = notification_ipc_monitor_register();
 -              if (ret != NOTIFICATION_ERROR_NONE) {
 -                      NOTIFICATION_ERR("failed to register a monitor");
 -              }
 -      } else {
 -              NOTIFICATION_ERR("try to unregister a notification service");
 -              ret = notification_ipc_monitor_deregister();
 -              if (ret != NOTIFICATION_ERROR_NONE) {
 -                      NOTIFICATION_ERR("failed to deregister a monitor");
 -              }
 -      }
 -}
 -
 -static void _master_started_cb_task(keynode_t *node,
 -              void *data) {
 -
 -      if (notification_ipc_is_master_ready()) {
 -              _do_deffered_task();
 -      }
 +    return ECORE_CALLBACK_CANCEL;
  }
  
  /*!
@@@ -968,3 -1194,62 +1080,60 @@@ notification_error_e notification_ipc_r
  
        return status;
  }
 -              NOTIFICATION_ERR("failed to receive answer(delete)");
+ notification_error_e notification_ipc_noti_setting_property_set(const char *pkgname, const char *property, const char *value)
+ {
+       int status = 0;
+       int ret = 0;
+       struct packet *packet;
+       struct packet *result;
+       packet = packet_create("set_noti_property", "sss", pkgname, property, value);
+       result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
+                       packet,
+                       NOTIFICATION_IPC_TIMEOUT);
+       packet_destroy(packet);
+       if (result != NULL) {
+               if (packet_get(result, "ii", &status, &ret) != 2) {
+                       NOTIFICATION_ERR("Failed to get a result packet");
+                       packet_unref(result);
+                       return NOTIFICATION_ERROR_IO;
+               }
+               packet_unref(result);
+       } else {
 -              NOTIFICATION_ERR("failed to receive answer(delete)");
+               return NOTIFICATION_ERROR_SERVICE_NOT_READY;
+       }
+       return status;
+ }
+ notification_error_e notification_ipc_noti_setting_property_get(const char *pkgname, const char *property, char **value)
+ {
+       int status = 0;
+       char *ret = NULL;
+       struct packet *packet;
+       struct packet *result;
+       packet = packet_create("get_noti_property", "ss", pkgname, property);
+       result = com_core_packet_oneshot_send(NOTIFICATION_ADDR,
+                       packet,
+                       NOTIFICATION_IPC_TIMEOUT);
+       packet_destroy(packet);
+       if (result != NULL) {
+               if (packet_get(result, "is", &status, &ret) != 2) {
+                       NOTIFICATION_ERR("Failed to get a result packet");
+                       packet_unref(result);
+                       return NOTIFICATION_ERROR_IO;
+               }
+               if (status == NOTIFICATION_ERROR_NONE && ret != NULL) {
+                       *value = strdup(ret);
+               }
+               packet_unref(result);
+       } else {
+               return NOTIFICATION_ERROR_SERVICE_NOT_READY;
+       }
+       return status;
+ }