Add pd_move event is added
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 4 Mar 2013 10:46:42 +0000 (10:46 +0000)
committerSung-jae Park <nicesj.park@samsung.com>
Mon, 4 Mar 2013 10:46:42 +0000 (10:46 +0000)
pd create / lb create & pd,show / lb,show sequence is updated

Change-Id: If0e1ec3c8f4434fad5698e0e7cb6557a22667b1f

packaging/data-provider-master.spec
src/instance.c
src/script_handler.c
src/server.c

index e8520e5..c7e104b 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.17.0
+Version: 0.17.1
 Release: 1
 Group: framework/livebox
 License: Flora License
index 06149c6..fc66287 100644 (file)
@@ -867,9 +867,6 @@ static void reactivate_cb(struct slave_node *slave, const struct packet *packet,
 
                        if (pd_type == PD_TYPE_SCRIPT && inst->pd.canvas.script && inst->pd.is_opened_for_reactivate) {
                                double x, y;
-
-                               instance_slave_get_pd_pos(inst, &x, &y);
-
                                /*!
                                 * \note
                                 * We should to send a request to open a PD to slave.
@@ -878,6 +875,7 @@ static void reactivate_cb(struct slave_node *slave, const struct packet *packet,
                                 * To do that, send open request from here.
                                 */
                                ret = instance_slave_open_pd(inst, NULL);
+                               instance_slave_get_pd_pos(inst, &x, &y);
 
                                /*!
                                 * \note
@@ -1153,10 +1151,12 @@ static int pd_script_close_cb(struct client_node *client, void *inst)
 {
        int ret;
 
+       ret = script_handler_unload(instance_pd_script(inst), 1);
+       DbgPrint("Unload script: %d\n", ret);
+
        ret = instance_slave_close_pd(inst, client);
        DbgPrint("Forcely close the PD ret: %d\n", ret);
 
-       ret = script_handler_unload(instance_pd_script(inst), 1);
        return -1; /* Delete this callback */
 }
 
@@ -1953,6 +1953,7 @@ HAPI int instance_signal_emit(struct inst_info *inst, const char *signal, const
                return -EFAULT;
        }
 
+       DbgPrint("Signal emit: %s(%s), %s(%s), %lf, %lf, %lf, %lf, %lfx%lf, %d\n", pkgname, id, signal, part, sx, sy, ex, ey, x, y, down);
        ret = slave_rpc_request_only(slave, pkgname, packet, 0); 
        return ret;
 }
@@ -2435,6 +2436,7 @@ HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *clie
        }
 
        inst->pd.owner = client;
+       DbgPrint("pd,show event is sent\n");
        return ret;
 }
 
@@ -2504,7 +2506,7 @@ HAPI int instance_client_pd_created(struct inst_info *inst, int status)
                break;
        }
 
-       inst->pd.need_to_send_close_event = 1;
+       inst->pd.need_to_send_close_event = (status == 0);
 
        packet = packet_create_noack("pd_created", "sssiii", 
                        package_name(inst->info), inst->id, buf_id,
@@ -2516,7 +2518,7 @@ HAPI int instance_client_pd_created(struct inst_info *inst, int status)
 
        ret = CLIENT_SEND_EVENT(inst, packet);
 
-       if (inst->pd.pended_update_cnt) {
+       if (inst->pd.need_to_send_close_event && inst->pd.pended_update_cnt) {
                DbgPrint("Apply pended desc(%d) - %s\n", inst->pd.pended_update_cnt, inst->pd.pended_update_desc);
                instance_pd_updated_by_instance(inst, inst->pd.pended_update_desc);
                inst->pd.pended_update_cnt = 0;
index 116c220..2fe88da 100644 (file)
@@ -265,6 +265,8 @@ HAPI int script_handler_load(struct script_info *info, int is_pd)
                        return -EFAULT;
                }
                info->loaded = 1;
+               script_signal_emit(e, util_uri_to_path(instance_id(info->inst)),
+                               is_pd ? "pd,show" : "lb,show", 0.0f, 0.0f, 0.0f, 0.0f);
        } else {
                ErrPrint("Evas: (nil) %dx%d\n", info->w, info->h);
        }
@@ -275,9 +277,6 @@ HAPI int script_handler_load(struct script_info *info, int is_pd)
        ecore_evas_activate(info->ee);
        fb_sync(info->fb);
 
-       if (e)
-               script_signal_emit(e, util_uri_to_path(instance_id(info->inst)),
-                                       is_pd ? "pd,show" : "lb,show", 0.0f, 0.0f, 0.0f, 0.0f);
        return 0;
 }
 
@@ -300,7 +299,8 @@ HAPI int script_handler_unload(struct script_info *info, int is_pd)
 
        e = script_handler_evas(info);
        if (e) {
-               script_signal_emit(e, util_uri_to_path(instance_id(info->inst)), is_pd ? "pd,hide" : "lb,hide", 0.0f, 0.0f, 0.0f, 0.0f);
+               script_signal_emit(e, util_uri_to_path(instance_id(info->inst)),
+                               is_pd ? "pd,hide" : "lb,hide", 0.0f, 0.0f, 0.0f, 0.0f);
                if (info->port->unload(info->port_data, e) < 0)
                        ErrPrint("Failed to unload script object. but go ahead\n");
                evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, render_post_cb);
index 85a7f28..c22c399 100644 (file)
@@ -869,6 +869,8 @@ static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct p
                goto out;
        }
 
+       DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
+
        /*!
         * \NOTE:
         * Trust the package name which are sent by the client.
@@ -984,6 +986,7 @@ static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct pac
                goto out;
        }
 
+       DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
        /*!
         * \NOTE:
         * Trust the package name which are sent by the client.
@@ -1099,6 +1102,7 @@ static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct p
                goto out;
        }
 
+       DbgPrint("(%dx%d) - (%lfx%lf)\n", w, h, x, y);
        /*!
         * \NOTE:
         * Trust the package name which are sent by the client.
@@ -3495,6 +3499,57 @@ static Eina_Bool lazy_pd_destroyed_cb(void *data)
        return ECORE_CALLBACK_CANCEL;
 }
 
+static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
+{
+       struct client_node *client;
+       struct inst_info *inst;
+       const char *pkgname;
+       const char *id;
+       double x = 0.0f;
+       double y = 0.0f;
+       int ret;
+
+       client = client_find_by_pid(pid);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               ret = -ENOENT;
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
+       if (ret != 4) {
+               ErrPrint("Parameter is not correct\n");
+               ret = -EINVAL;
+               goto out;
+       }
+
+       DbgPrint("pid[%d] pkgname[%s] id[%s] %lfx%lf\n", pid, pkgname, id, x, y);
+
+       inst = package_find_instance_by_id(pkgname, id);
+       if (!inst)
+               ret = -ENOENT;
+       else if (package_is_fault(instance_package(inst)))
+               ret = -EFAULT;
+       else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
+               instance_slave_set_pd_pos(inst, x, y);
+               ret = instance_signal_emit(inst,
+                               "pd,move", util_uri_to_path(instance_id(inst)),
+                               0.0, 0.0, 0.0, 0.0, x, y, 0);
+       } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
+               instance_slave_set_pd_pos(inst, x, y);
+               script_handler_update_pointer(instance_pd_script(inst), x, y, 0);
+               ret = instance_signal_emit(inst,
+                               "pd,move", util_uri_to_path(instance_id(inst)),
+                               0.0, 0.0, 0.0, 0.0, x, y, 0);
+       } else {
+               ErrPrint("Invalid PD type\n");
+               ret = -EINVAL;
+       }
+out:
+       DbgPrint("Update PD position: %lfx%lf (%d)\n", x, y, ret);
+       return NULL;
+}
+
 static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
 {
        struct client_node *client;
@@ -3559,8 +3614,8 @@ static struct packet *client_create_pd(pid_t pid, int handle, const struct packe
                 * so we can hanle it later.
                 */
                instance_slave_set_pd_pos(inst, x, y);
-               ret = instance_slave_open_pd(inst, client);
                script_handler_update_pointer(instance_pd_script(inst), x, y, 0);
+               ret = instance_slave_open_pd(inst, client);
                ret = script_handler_load(instance_pd_script(inst), 1);
 
                /*!
@@ -3577,6 +3632,8 @@ static struct packet *client_create_pd(pid_t pid, int handle, const struct packe
                        inst = instance_ref(inst); /* To guarantee the inst */
                        if (!ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst))
                                instance_unref(inst);
+               } else {
+                       instance_client_pd_created(inst, ret);
                }
        } else {
                ErrPrint("Invalid PD TYPE\n");
@@ -3629,7 +3686,7 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
        else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
                ret = instance_signal_emit(inst,
                                "pd,hide", util_uri_to_path(instance_id(inst)),
-                               0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
+                               0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
                ret = instance_slave_close_pd(inst, client);
 
                /*!
@@ -3641,9 +3698,8 @@ static struct packet *client_destroy_pd(pid_t pid, int handle, const struct pack
                 */
 
        } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
-               ret = instance_slave_close_pd(inst, client);
-
                ret = script_handler_unload(instance_pd_script(inst), 1);
+               ret = instance_slave_close_pd(inst, client);
 
                /*!
                 * \note
@@ -5272,6 +5328,10 @@ static struct method s_client_table[] = {
                .handler = client_create_pd, /* pid, pkgname, filename, ret */
        },
        {
+               .cmd = "pd_move",
+               .handler = client_pd_move, /* pkgname, id, x, y */
+       },
+       {
                .cmd = "destroy_pd",
                .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
        },