Update zone policy test code for DPM api update 68/67568/2 accepted/tizen/common/20160427.144524 accepted/tizen/ivi/20160428.002843 accepted/tizen/mobile/20160428.005119 accepted/tizen/tv/20160428.002607 accepted/tizen/wearable/20160428.002934 submit/tizen/20160427.092619
authorSungbae Yoo <sungbae.yoo@samsung.com>
Wed, 27 Apr 2016 08:34:51 +0000 (17:34 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Wed, 27 Apr 2016 09:17:25 +0000 (18:17 +0900)
Change-Id: Id0cf0816f51b055c193dbd1b38681233a1e230b3
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
src/zone.c

index 6863d43..a33af82 100755 (executable)
@@ -3,16 +3,11 @@
 
 int create_zone_handler(struct dpm_toolkit_entity* self)
 {
-       dpm_client_h handle;
+        dpm_zone_policy_h policy;
+       dpm_context_h context;
        char* wizappid;
        int ret;
 
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create client handle");
-               return POLICY_RESULT_FAIL;
-       }
-
        handler_display_input_popup("Zone name", self);
        wizappid = (char*)xmlGetProp(self->model, (xmlChar*) "wizappid");
 
@@ -21,29 +16,52 @@ int create_zone_handler(struct dpm_toolkit_entity* self)
                return POLICY_RESULT_FAIL;
        }
 
-       ret = dpm_create_zone(handle, self->entry_input, wizappid);
+        context = dpm_context_create();
+        if (context == NULL) {
+                dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to create client context");
+                return POLICY_RESULT_FAIL;
+        }
+
+        policy = dpm_context_acquire_zone_policy(context);
+        if (policy == NULL) {
+                dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get zone policy interface");
+                dpm_context_destroy(context);
+                return POLICY_RESULT_FAIL;
+        }
+
+       ret = dpm_zone_create(policy, self->entry_input, wizappid);
 
-       dpm_destroy_client(handle);
+        dpm_context_release_zone_policy(context, policy);
+        dpm_context_destroy(context);
 
        return (ret == DPM_ERROR_NONE) ? POLICY_RESULT_SUCCESS : POLICY_RESULT_FAIL;
 }
 
 int destroy_zone_handler(struct dpm_toolkit_entity* self)
 {
-       dpm_client_h handle;
+        dpm_zone_policy_h policy;
+       dpm_context_h context;
        int ret;
 
-       handle = dpm_create_client();
-       if (handle == NULL) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create client handle");
-               return POLICY_RESULT_FAIL;
-       }
-
        handler_display_input_popup("Zone name", self);
 
-       ret = dpm_remove_zone(handle, self->entry_input);
+        context = dpm_context_create();
+        if (context == NULL) {
+                dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to create client context");
+                return POLICY_RESULT_FAIL;
+        }
+
+        policy = dpm_context_acquire_zone_policy(context);
+        if (policy == NULL) {
+                dlog_print(DLOG_DEBUG, LOG_TAG, "Failed to get zone policy interface");
+                dpm_context_destroy(context);
+                return POLICY_RESULT_FAIL;
+        }
+
+       ret = dpm_zone_destroy(policy, self->entry_input);
 
-       dpm_destroy_client(handle);
+        dpm_context_release_zone_policy(context, policy);
+        dpm_context_destroy(context);
 
        return (ret == DPM_ERROR_NONE) ? POLICY_RESULT_SUCCESS : POLICY_RESULT_FAIL;
 }