Add update_mode.
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 1 Apr 2013 14:13:52 +0000 (14:13 +0000)
committerSung-jae Park <nicesj.park@samsung.com>
Mon, 1 Apr 2013 14:13:52 +0000 (14:13 +0000)
Active & Passive update mode.

These two words are used for viewer.
If a viewer wants to update the content of boxes without any updated events, it can use the active mode.
or it can update by the updated event.

passive mode is default.
So every viewer will get updated event then they should to update the content of boxes.

Change-Id: I2463907ca3ecf903cdf34d8404b166c701716f94

include/instance.h
src/instance.c
src/server.c

index dc50fc1..9f57c56 100644 (file)
@@ -162,6 +162,8 @@ extern int instance_signal_emit(struct inst_info *inst, const char *emission, co
 extern int instance_change_group(struct inst_info *inst, const char *cluster, const char *category);
 extern int instance_set_visible_state(struct inst_info *inst, enum livebox_visible_state state);
 extern enum livebox_visible_state instance_visible_state(struct inst_info *inst);
+extern int instance_set_update_mode(struct inst_info *inst, int active_update);
+extern int instance_active_update(struct inst_info *inst);
 
 /*!
  * \note
index 6fc0f8b..0fb485d 100644 (file)
@@ -94,7 +94,8 @@ struct inst_info {
        char *title;
        int is_pinned_up;
        double sleep_at;
-       int scroll_locked;
+       int scroll_locked; /*!< Scroller which is in viewer is locked. */
+       int active_update; /*!< Viewer will reload the buffer by itself, so the provider doesn't need to send the updated event */
 
        enum livebox_visible_state visible;
 
@@ -1354,7 +1355,7 @@ HAPI int instance_reactivate(struct inst_info *inst)
                break;
        }
 
-       packet = packet_create("renew", "sssiidssiis",
+       packet = packet_create("renew", "sssiidssiisii",
                        package_name(inst->info),
                        inst->id,
                        inst->content,
@@ -1364,7 +1365,9 @@ HAPI int instance_reactivate(struct inst_info *inst)
                        inst->cluster,
                        inst->category,
                        inst->lb.width, inst->lb.height,
-                       package_abi(inst->info));
+                       package_abi(inst->info),
+                       inst->scroll_locked,
+                       inst->active_update);
        if (!packet) {
                ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
                return LB_STATUS_ERROR_FAULT;
@@ -1600,6 +1603,41 @@ HAPI void instance_pd_updated(const char *pkgname, const char *id, const char *d
        instance_pd_updated_by_instance(inst, descfile);
 }
 
+HAPI int instance_set_update_mode(struct inst_info *inst, int active_update)
+{
+       int ret;
+       struct packet *packet;
+
+       if (package_is_fault(inst->info)) {
+               DbgPrint("Fault package [%s]\n", package_name(inst->info));
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       if (inst->active_update == active_update) {
+               DbgPrint("Active update is not changed: %d\n", inst->active_update);
+               return LB_STATUS_ERROR_ALREADY;
+       }
+
+       /* NOTE: param is resued from here */
+       packet = packet_create_noack("update_mode", "ssi", package_name(inst->info), inst->id, active_update);
+       if (!packet) {
+               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
+               return LB_STATUS_ERROR_FAULT;
+       }
+
+       ret = slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
+
+       if (ret == LB_STATUS_SUCCESS)
+               inst->active_update = active_update;
+
+       return ret;
+}
+
+HAPI int instance_active_update(struct inst_info *inst)
+{
+       return inst->active_update;
+}
+
 HAPI void instance_set_lb_info(struct inst_info *inst, int w, int h, double priority, const char *content, const char *title)
 {
        char *_content = NULL;
index b6a6f43..2380d25 100644 (file)
@@ -315,14 +315,12 @@ static struct packet *client_clicked(pid_t pid, int handle, const struct packet
        client = client_find_by_pid(pid);
        if (!client) {
                ErrPrint("Client %d is not exists\n", pid);
-               ret = LB_STATUS_ERROR_NOT_EXIST;
                goto out;
        }
 
        ret = packet_get(packet, "sssddd", &pkgname, &id, &event, &timestamp, &x, &y);
        if (ret != 6) {
                ErrPrint("Parameter is not matched\n");
-               ret = LB_STATUS_ERROR_INVALID;
                goto out;
        }
 
@@ -335,11 +333,45 @@ static struct packet *client_clicked(pid_t pid, int handle, const struct packet
         */
        inst = package_find_instance_by_id(pkgname, id);
        if (!inst)
-               ret = LB_STATUS_ERROR_NOT_EXIST;
+               ErrPrint("Instance is not exists\n");
        else if (package_is_fault(instance_package(inst)))
-               ret = LB_STATUS_ERROR_FAULT;
+               ErrPrint("Fault package\n");
        else
-               ret = instance_clicked(inst, event, timestamp, x, y);
+               (void)instance_clicked(inst, event, timestamp, x, y);
+
+out:
+       /*! \note No reply packet */
+       return NULL;
+}
+
+static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet)
+{
+       struct client_node *client;
+       int active_update;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       struct inst_info *inst;
+
+       client = client_find_by_pid(pid);
+       if (!client) {
+               ErrPrint("Client %d is not exists\n", pid);
+               goto out;
+       }
+
+       ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
+       if (ret != 3) {
+               ErrPrint("Invalid argument\n");
+               goto out;
+       }
+
+       inst = package_find_instance_by_id(pkgname, id);
+       if (!inst)
+               ErrPrint("Instance is not exists\n");
+       else if (package_is_fault(instance_package(inst)))
+               ErrPrint("Fault package\n");
+       else
+               instance_set_update_mode(inst, active_update);
 
 out:
        /*! \note No reply packet */
@@ -3019,15 +3051,13 @@ static struct packet *client_resume_request(pid_t pid, int handle, const struct
 
        client = client_find_by_pid(pid);
        if (!client) {
-               ErrPrint("Client %d is paused - manually reported\n", pid);
-               ret = LB_STATUS_ERROR_NOT_EXIST;
+               ErrPrint("Client %d is not exists\n", pid);
                goto out;
        }
 
        ret = packet_get(packet, "d", &timestamp);
        if (ret != 1) {
                ErrPrint("Invalid parameter\n");
-               ret = LB_STATUS_ERROR_INVALID;
                goto out;
        }
 
@@ -6244,6 +6274,11 @@ static struct method s_client_table[] = {
        },
 
        {
+               .cmd = "update_mode",
+               .handler = client_update_mode,
+       },
+
+       {
                .cmd = NULL,
                .handler = NULL,
        },