* It will change the instance's state to "ACTIVATED"
* But now, the master will not send "created" event to the clients.
*
- * Because the clients don't watn to know the re-created liveboxes.
+ * Because the clients don't want to know the re-created liveboxes.
* They just want to know about fault liveboxes to display deactivated
* message.
*
* Yes, it is right. But the instance cannot be deleted directly.
* Because some callbacks still reference it to complete its job.
* So the instance needs to keep this DESTROYED state for a while
- * until all callbacks are done to their jobs.
+ * until all callbacks are done for their remained jobs.
*
* To unload the instance from the slave,
* The master should send a request to the slave,
INST_REQUEST_TO_DESTROY, /*!< Sent a request to a slave, when the master receives deleted event, the master will delete this */
};
+enum livebox_visible_state { /*!< Must be sync'd with livebox-viewer */
+ LB_SHOW = 0x00, /*!< Livebox is showed. Default state */
+ LB_HIDE = 0x01, /*!< Livebox is hide, with no update event, but keep update timer */
+
+ LB_HIDE_WITH_PAUSE = 0x02, /*!< Livebix is hide, it needs to be paused (with freezed update timer) */
+
+ LB_VISIBLE_ERROR = 0xFFFFFFFF, /* To enlarge the size of this enumeration type */
+};
+
struct inst_info;
struct pkg_info;
struct script_handle;
extern int instance_clicked(struct inst_info *inst, const char *event, double timestamp, double x, double y);
extern int instance_text_signal_emit(struct inst_info *inst, const char *emission, const char *source, double sx, double sy, double ex, double ey);
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);
/*!
* \note
char *category;
char *title;
+ enum livebox_visible_state visible;
+
struct {
int width;
int height;
#define CLIENT_SEND_EVENT(instance, packet) ((instance)->client ? client_rpc_async_request((instance)->client, (packet)) : client_rpc_broadcast((instance), (packet)))
+static inline int pause_livebox(struct inst_info *inst)
+{
+ struct packet *packet;
+ int ret;
+
+ packet = packet_create_noack("lb_pause", "ss", package_name(inst->info), inst->id);
+ if (!packet) {
+ ErrPrint("Failed to create a new packet\n");
+ return -EFAULT;
+ }
+
+ return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet);
+}
+
+/*! \TODO Wake up the freeze'd timer */
+static inline int resume_livebox(struct inst_info *inst)
+{
+ struct packet *packet;
+ int ret;
+
+ packet = packet_create_noack("lb_resume", "ss", package_name(inst->info), inst->id);
+ if (!packet) {
+ ErrPrint("Failed to create a new packet\n");
+ return -EFAULT;
+ }
+
+ return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet);
+}
+
int instance_unicast_created_event(struct inst_info *inst, struct client_node *client)
{
struct packet *packet;
if (pd_type == PD_TYPE_SCRIPT && inst->pd.canvas.script && inst->pd.is_opened_for_reactivate)
script_handler_load(inst->pd.canvas.script, 1);
+ switch (inst->visible) {
+ case LB_SHOW:
+ /* Do nothing */
+ break;
+ case LB_HIDE:
+ /* Do nothing */
+ break;
+ case LB_HIDE_WITH_PAUSE:
+ pause_livebox(inst);
+ break;
+ default:
+ ErrPrint("Unknown visibility\n");
+ break;
+ }
+
/*!
* \note After recreated, send the update event to the client
*/
const char *title;
const char *content;
+ if (inst->client && inst->visible != LB_SHOW) {
+ DbgPrint("Livebox is hidden. ignore update event\n");
+ return;
+ }
+
lb_type = package_lb_type(inst->info);
if (lb_type == LB_TYPE_SCRIPT)
id = fb_id(script_handler_fb(inst->lb.canvas.script));
enum pd_type pd_type;
const char *id;
+ if (inst->client && inst->visible != LB_SHOW) {
+ DbgPrint("Livebox is hidden. ignore update event\n");
+ return;
+ }
+
if (!descfile)
descfile = inst->id;
return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, pinup_cb, cbdata);
}
+int instance_set_visible_state(struct inst_info *inst, enum livebox_visible_state state)
+{
+ if (inst->visible == state) {
+ DbgPrint("Visibility has no changed\n");
+ return 0;
+ }
+
+ switch (state) {
+ case LB_SHOW:
+ case LB_HIDE:
+ if (inst->visible == LB_HIDE_WITH_PAUSE) {
+ if (resume_livebox(inst) == 0)
+ inst->visible = state;
+ } else {
+ inst->visible = state;
+ }
+ break;
+
+ case LB_HIDE_WITH_PAUSE:
+ if (pause_livebox(inst) == 0)
+ inst->visible = LB_HIDE_WITH_PAUSE;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static void resize_cb(struct slave_node *slave, const struct packet *packet, void *data)
{
struct resize_cbdata *cbdata = data;
static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
- struct packet *result;
const char *pkgname;
const char *id;
const char *event;
ret = instance_clicked(inst, event, timestamp, x, y);
out:
- result = packet_create_reply(packet, "i", ret);
- if (!result)
- ErrPrint("Failed to create a packet\n");
-
- return result;
+ return NULL;
}
/* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
return result;
}
+static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
+{
+ struct client_node *client;
+ const char *pkgname;
+ const char *id;
+ enum livebox_visible_state state;
+ int ret;
+ struct inst_info *inst;
+
+ DbgPrint("Client[%d] request arrived\n", pid);
+
+ 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, (int *)&state);
+ if (ret != 3) {
+ ErrPrint("Parameter is not matched\n");
+ goto out;
+ }
+
+ DbgPrint("pkgname[%s] id[%s] state[%d]\n", pkgname, id, state);
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst)
+ goto out;
+ else if (package_is_fault(instance_package(inst)))
+ goto out;
+ else
+ ret = instance_set_visible_state(inst, state);
+
+out:
+ return NULL;
+}
+
static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
{
struct client_node *client;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
goto out;
}
- ret = slave_rpc_request_only(slave, packet);
+ ret = slave_rpc_request_only(slave, pkgname, packet);
} else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
struct script_info *script;
Evas *e;
const char *cluster;
const char *category;
struct client_node *client;
- struct packet *result;
int ret;
DbgPrint("Client[%d] request arrived\n", pid);
package_alter_instances_to_client(client);
out:
- result = packet_create_reply(packet, "i", ret);
- if (!result)
- ErrPrint("Failed to create a packet\n");
-
- return result;
+ return NULL;
}
static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
const char *cluster_id;
const char *category_id;
struct client_node *client;
- struct packet *result;
int ret;
struct cluster *cluster;
struct category *category;
group_list_category_pkgs(category, update_pkg_cb, NULL);
out:
- result = packet_create_reply(packet, "i", ret);
- if (!result)
- ErrPrint("Failed to create a packet\n");
- return result;
+ return NULL;
}
static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
const char *cluster;
const char *category;
struct client_node *client;
- struct packet *result;
int ret;
DbgPrint("Client[%d] request arrived\n", pid);
ret = client_unsubscribe(client, cluster, category);
out:
- result = packet_create_reply(packet, "i", ret);
- if (!result)
- ErrPrint("Failed to create a packet\n");
- return result;
+ return NULL;
}
static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
.cmd = "refresh_group",
.handler = client_refresh_group,
},
+ {
+ .cmd = "change,visibility",
+ .handler = client_change_visibility,
+ },
/*!
* \note services for slave
*/