Update source from tizen 2.3
[platform/core/base/rpm-installer.git] / backend / src / vconf / rpm-vconf-intf.c
index 12a38d9..41413da 100755 (executable)
 #define VCONF_RPM_INSTALLER_LAST_REQUESTINFO_OPTIONS \
        VCONF_RPM_INSTALLER"/requestinfo/options"
 
-#define ERR_RETURN_LEN 32
+#define ERR_RETURN_LEN                 256
 
 extern pkgmgr_installer *pi;
 extern char *gpkgname;
+extern int broadcast_disable;
 
 int _ri_get_backend_state()
 {
        int ret = -1;
        int state = -1;
 
-       _d_msg(DEBUG_INFO,"_ri_get_backend_state\n");
+//     _LOGD("_ri_get_backend_state\n");
        ret = vconf_get_int(VCONF_RPM_INSTALLER_BACKEND_STATE, &state);
        if (ret == -1) {
-               _d_msg(DEBUG_ERR,
+               _LOGE(
                       "_ri_get_backend_state: vconf_get_int FAIL\n");
        } else {
                ret = state;
@@ -71,10 +72,10 @@ int _ri_set_backend_state(int state)
                vconf_unset_recursive(VCONF_RPM_INSTALLER);
        }
 
-       _d_msg(DEBUG_INFO,"_ri_set_backend_state\n");
+//     _LOGD("_ri_set_backend_state\n");
        ret = vconf_set_int(VCONF_RPM_INSTALLER_BACKEND_STATE, state);
        if (ret == -1) {
-               _d_msg(DEBUG_ERR,
+               _LOGE(
                       "_ri_set_backend_state: vconf_set_int FAIL\n");
        }
 
@@ -87,11 +88,11 @@ int _ri_get_backend_state_info()
        int state = -1;
        ret = vconf_get_int(VCONF_RPM_INSTALLER_BACKEND_STATEINFO, &state);
        if (ret == -1) {
-               _d_msg(DEBUG_ERR,
+               _LOGE(
                       "_ri_get_backend_state_info: vconf_get_int FAIL\n");
        } else {
                ret = state;
-       /*      _d_msg(DEBUG_INFO,"_ri_get_backend_state_info state[%d]\n", state);*/
+       /*      _LOGD("_ri_get_backend_state_info state[%d]\n", state);*/
        }
        return ret;
 }
@@ -99,10 +100,10 @@ int _ri_get_backend_state_info()
 int _ri_set_backend_state_info(int state)
 {
        int ret = -1;
-       _d_msg(DEBUG_INFO,"_ri_set_backend_state_info %d\n", state);
+//     _LOGD("_ri_set_backend_state_info %d\n", state);
        ret = vconf_set_int(VCONF_RPM_INSTALLER_BACKEND_STATEINFO, state);
        if (ret == -1)
-               _d_msg(DEBUG_ERR,
+               _LOGE(
                       "_ri_set_backend_state_info: vconf_set_int FAIL\n");
 
        return ret;
@@ -116,13 +117,13 @@ int _ri_get_last_input_info(char **pkgid, int *preqcommand, int *poptions)
        ret = vconf_get_int(VCONF_RPM_INSTALLER_LAST_REQUESTINFO_COMMAND,
                            preqcommand);
        if (ret == -1)
-               _d_msg(DEBUG_ERR,
+               _LOGE(
                       "_ri_get_last_input_info: VCONF_RPM_INSTALLER_LAST_REQUESTINFO_COMMAND: vconf_get_int FAIL\n");
 
        ret = vconf_get_int(VCONF_RPM_INSTALLER_LAST_REQUESTINFO_OPTIONS,
                            poptions);
        if (ret == -1)
-               _d_msg(DEBUG_ERR,
+               _LOGE(
                       "_ri_get_last_input_info: VCONF_RPM_INSTALLER_LAST_REQUESTINFO_OPTIONS: vconf_get_int FAIL\n");
 
        *pkgid = vconf_get_str(VCONF_RPM_INSTALLER_LAST_REQUESTINFO_PKGNAME);
@@ -139,49 +140,67 @@ void _ri_save_last_input_info(char *pkgid, int reqcommand, int options)
                            VCONF_RPM_INSTALLER_LAST_REQUESTINFO_COMMAND,
                            reqcommand);
        if (ret == -1)
-               _d_msg(DEBUG_ERR, "vconf_keylist_add_int FAIL\n");
+               _LOGE("vconf_keylist_add_int FAIL\n");
        ret = vconf_keylist_add_str(kl,
                            VCONF_RPM_INSTALLER_LAST_REQUESTINFO_PKGNAME,
                            pkgid);
        if (ret == -1)
-               _d_msg(DEBUG_ERR, "vconf_keylist_add_str FAIL\n");
+               _LOGE("vconf_keylist_add_str FAIL\n");
        ret = vconf_keylist_add_int(kl,
                            VCONF_RPM_INSTALLER_LAST_REQUESTINFO_OPTIONS,
                            options);
        if (ret == -1)
-               _d_msg(DEBUG_ERR, "vconf_keylist_add_int FAIL\n");
+               _LOGE("vconf_keylist_add_int FAIL\n");
 
        if (vconf_set(kl))
-               _d_msg(DEBUG_ERR,
+               _LOGE(
                       "_ri_save_last_input_info: Failure in writing vconf\n");
 
        ret = vconf_keylist_free(kl);
        if (ret == -1)
-               _d_msg(DEBUG_ERR, "vconf_keylist_free FAIL\n");
+               _LOGE("vconf_keylist_free FAIL\n");
 }
 
-void _ri_broadcast_status_notification(char *pkgid, char *key, char *val)
+void _ri_broadcast_status_notification(const char *pkgid, char *pkg_type, char *key, char *val)
 {
-       char *pkgid_tmp = NULL;
+       const char *pkgid_tmp = pkgid;
        char buf[ERR_RETURN_LEN] = {'\0'};
        int ret_val = 0;
 
+       if (broadcast_disable)
+               return;
+
+#if 0
        if (gpkgname != NULL)
                pkgid_tmp = gpkgname;
        else
                pkgid_tmp = pkgid;
+#endif
 
-       ret_val = _ri_string_to_error_no(val);
-       _d_msg(DEBUG_INFO, "pkgid = %s, key = %s, val = %s, ret_val = %d\n", pkgid_tmp, key, val, ret_val);
-
-       if (ret_val == RPM_INSTALLER_ERR_UNKNOWN){
-               if (pi != NULL)
-                       pkgmgr_installer_send_signal(pi, PKGTYPE, pkgid_tmp, key, val);
-               else
-                       _d_msg(DEBUG_ERR, "Failure in sending broadcast message\n");
+       if (pi == NULL) {
+               _LOGE("Failure in sending broadcast message\n");
+               return;
        }
-       else{
+
+       if (strcmp(key,PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR) == 0) {
+               ret_val = atoi(val);
+
+               _LOGD("pkgid=[%s], key=[%s], val=[%s]\n", pkgid_tmp, key, val);
+
                snprintf(buf, ERR_RETURN_LEN - 1, "%d", ret_val);
-               pkgmgr_installer_send_signal(pi, PKGTYPE, pkgid_tmp, key, buf);
+               pkgmgr_installer_send_signal(pi, pkg_type, pkgid_tmp, key, buf);
+               return;
+       } else {
+               ret_val = _ri_string_to_error_no(val);
+
+               _LOGD( "pkgid=[%s], key=[%s], val=[%s]\n", pkgid_tmp, key, val);
+
+               if (ret_val == RPM_INSTALLER_ERR_UNKNOWN){
+                       pkgmgr_installer_send_signal(pi, pkg_type, pkgid_tmp, key, val);
+               }
+               else{
+                       snprintf(buf, ERR_RETURN_LEN - 1, "%d:%s", ret_val, val);
+                       pkgmgr_installer_send_signal(pi, pkg_type, pkgid_tmp, key, buf);
+               }
        }
 }