extern void *instance_get_data(struct inst_info *inst, const char *tag);
extern void instance_reload_period(struct inst_info *inst, double period);
+extern struct packet *instance_duplicate_packet_create(struct inst_info *inst, struct pkg_info *info, int width, int height);
+
+extern struct packet *instance_watch_create(const char *pkgname, int width, int height);
/* End of a file */
extern int slave_rpc_async_request(struct slave_node *slave, const char *pkgname, struct packet *packet, void (*ret_cb)(struct slave_node *slave, const struct packet *packet, void *data), void *data, int urgent);
extern int slave_rpc_request_only(struct slave_node *slave, const char *pkgname, struct packet *packet, int urgent);
-extern int slave_rpc_update_handle(struct slave_node *slave, int handle);
+extern int slave_rpc_update_handle(struct slave_node *slave, int handle, int delete_pending_packet);
extern int slave_rpc_ping(struct slave_node *slave);
extern void slave_rpc_request_update(const char *pkgname, const char *id, const char *cluster, const char *category, const char *content, int force);
extern int slave_rpc_handle(struct slave_node *slave);
extern int slave_rpc_init(struct slave_node *slave);
extern int slave_rpc_fini(struct slave_node *slave);
-extern int slave_rpc_clear_pending_list(struct slave_node *slave);
-
/* End of a file */
return ECORE_CALLBACK_RENEW;
}
+static inline void unfork_package(struct inst_info *inst)
+{
+ DbgFree(inst->id);
+ inst->id = NULL;
+
+ if (inst->update_timer) {
+ ecore_timer_del(inst->update_timer);
+ inst->update_timer = NULL;
+ }
+}
+
static inline int fork_package(struct inst_info *inst, const char *pkgname)
{
struct pkg_info *info;
instance_ref(inst);
if (package_add_instance(inst->info, inst) < 0) {
- instance_destroy(inst, WIDGET_DESTROY_TYPE_FAULT);
+ DbgFree(inst->widget.extra_buffer);
+ DbgFree(inst->gbar.extra_buffer);
+ unfork_package(inst);
+ (void)client_unref(inst->client);
+ DbgFree(inst->title);
+ DbgFree(inst->category);
+ DbgFree(inst->cluster);
+ DbgFree(inst->content);
+ DbgFree(inst);
return NULL;
}
slave_load_instance(package_slave(inst->info));
- // Before activate an instance, update its id first for client
+ /**
+ * @note
+ * Before activate an instance,
+ * Update its Id first for client.
+ */
instance_send_update_id(inst);
if (instance_activate(inst) < 0) {
struct inst_info *inst;
struct packet *result;
unsigned int cmd = CMD_NEW;
- int ret;
inst = calloc(1, sizeof(*inst));
if (!inst) {
return NULL;
}
+ /**
+ * @note
+ * This timestamp will not be used by viewer.
+ * So we can set it manually from here.
+ */
inst->timestamp = util_timestamp();
inst->widget.width = width;
inst->widget.height = height;
ErrPrint("Failed to allocate buffer for gbar extra buffer\n");
}
}
+
+ /**
+ * We don't need to set the state of this instance from here.
+ * But, in case of fail to add a new instance to package information(inst->info) data,
+ * the "instance_destroy" will be invoked.
+ * it will try to get the state of an instance.
+ */
+ inst->state = INST_INIT;
+ inst->requested_state = INST_INIT;
instance_ref(inst);
+
+ /**
+ * @note
+ * We already create a slave object from caller.
+ * This will finds it and map it to package information object
+ */
if (package_add_instance(inst->info, inst) < 0) {
ErrPrint("Failed to package_add_instance\n");
- instance_destroy(inst, WIDGET_DESTROY_TYPE_FAULT);
+ unfork_package(inst);
+ DbgFree(inst->widget.extra_buffer);
+ DbgFree(inst->gbar.extra_buffer);
+ DbgFree(inst);
return NULL;
}
- slave_load_instance(package_slave(inst->info));
-
/**
* Before activate an instance, update its id first for client
instance_send_update_id(inst);
inst->widget.width,
inst->widget.height,
client_direct_addr(inst->client));
+
if (!result) {
ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
+ package_del_instance(inst->info, inst); /* This will reset the inst->info->slave */
+ unfork_package(inst);
+ DbgFree(inst->widget.extra_buffer);
+ DbgFree(inst->gbar.extra_buffer);
+ DbgFree(inst);
return NULL;
}
+ slave_load_instance(package_slave(inst->info));
+
inst->requested_state = INST_ACTIVATED;
inst->state = INST_ACTIVATED;
#define LAZY_GBAR_OPEN_TAG "lazy,gbar,open"
#define LAZY_GBAR_CLOSE_TAG "lazy,gbar,close"
+#define CATEGORY_WATCH_CLOCK "com.samsung.wmanager.WATCH_CLOCK"
+
#define ACCESS_TYPE_DOWN 0
#define ACCESS_TYPE_MOVE 1
#define ACCESS_TYPE_UP 2
int service_fd;
int slave_fd;
int remote_client_fd;
+
+ struct hello_context {
+ int pid;
+ int handle;
+ } hello_ctx;
} s_info = {
.info_fd = -1,
.client_fd = -1,
.service_fd = -1,
.slave_fd = -1,
.remote_client_fd = -1,
+ .hello_ctx = {
+ .pid = -1,
+ .handle = -1,
+ },
};
struct access_info {
if (slave) {
if (slave_valid(slave)) {
- inst = package_find_instance_by_id(widget_id, id);
+ inst = package_find_instance_by_id(pkgname, id);
} else {
ErrPrint("slave is not valid (%s)\n", id);
return WIDGET_STATUS_ERROR_INVALID_PARAMETER;
return -1; /* Delete this callback */
}
-
static struct packet *client_gbar_key_set(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
* After updating handle,
* slave activated callback will be called.
*/
- slave_rpc_update_handle(slave, handle);
+ slave_rpc_update_handle(slave, handle, 0);
out:
return NULL;
int ret;
double timestamp;
- if (s_slave_hello.pid > 0) {
- ErrPrint("Process [%d] sent hello sync prepare. but hello sync is not called.\n", s_slave_hello.pid);
+ if (s_info.hello_ctx.pid > 0) {
+ ErrPrint("Process [%d] sent hello sync prepare. but hello sync is not called.\n", s_info.hello_ctx.pid);
}
ret = packet_get(packet, "d", ×tamp);
}
if (aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)) != AUL_R_OK) {
- ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
+ ErrPrint("pid[%d] is not authroized provider package, try to find it using its name\n", pid);
goto out;
}
- s_slave_hello.pid = pid;
- s_slave_hello.handle = handle;
+ s_info.hello_ctx.pid = pid;
+ s_info.hello_ctx.handle = handle;
out:
return NULL;
if (!info) {
char *pkgid;
- pkgid = widget_service_package_id(widget_id);
+ pkgid = widget_service_get_package_id(widget_id);
if (!pkgid) {
DbgFree(widget_id);
goto out;
ErrPrint("Failed to create a new slave for %s\n", slavename);
goto out;
}
+
slave_set_pid(slave, pid);
slave_set_valid(slave);
- if (s_slave_hello.pid == pid) {
- slave_rpc_update_handle(slave, s_slave_hello.handle);
+ if (s_info.hello_ctx.pid == pid) {
+ /**
+ * @note
+ * Delete all pending packets
+ */
+ slave_rpc_update_handle(slave, s_info.hello_ctx.handle, 1);
} else {
- ErrPrint("slave_hello pid[%d] != pid[%d]", s_slave_hello.pid,pid);
+ ErrPrint("slave_hello pid[%d] != pid[%d]", s_info.hello_ctx.pid,pid);
}
DbgPrint("Slave is activated by request: %d (%s)/(%s)\n", pid, pkgname, slavename);
result = instance_watch_create(widget_id, width, height);
if (!result) {
ErrPrint("Failed to create a new instance\n");
+ if (slave_unref(slave)) {
+ ErrPrint("Slave is not deleted yet\n");
+ }
}
DbgFree(widget_id);
}
unsigned int widget_size;
Eina_List *inst_list;
Eina_List *inst_l;
- int count = 0;
const char *category;
widget_id = is_valid_slave(pid, abi, pkgname);
if (!info) {
char *pkgid;
- pkgid = widget_service_package_id(widget_id);
+ pkgid = widget_service_get_package_id(widget_id);
if (!pkgid) {
DbgFree(widget_id);
goto out;
inst_list = package_instance_list(info);
inst = NULL;
EINA_LIST_FOREACH(inst_list, inst_l, inst) {
- if (!strcmp(instance_package(inst), widget_id)) {
+ if (!strcmp(package_name(instance_package(inst)), widget_id)) {
break;
}
inst = NULL;
slave_set_valid(slave);
if (strcmp(CATEGORY_WATCH_CLOCK, category) == 0) {
- //if the new provider is watch app, destroy the old watch app instance
+ /**
+ * @note
+ * If a new provider is watch app, destroy the old watch app instance
+ */
package_del_instance_by_category(CATEGORY_WATCH_CLOCK, widget_id);
}
- slave_rpc_clear_pending_list(slave);
-
- if (s_slave_hello.pid == pid) {
- slave_rpc_update_handle(slave, s_slave_hello.handle);
+ if (s_info.hello_ctx.pid == pid) {
+ slave_rpc_update_handle(slave, s_info.hello_ctx.handle, 0);
} else {
- ErrPrint("slave_hello pid[%d] != pid[%d]", s_slave_hello.pid, pid);
+ ErrPrint("slave_hello pid[%d] != pid[%d]", s_info.hello_ctx.pid, pid);
}
DbgPrint("Slave is activated by request: %d (%s)/(%s)\n", pid, pkgname, slavename);
DbgFree(widget_id);
}
- s_slave_hello.pid = -1;
- s_slave_hello.handle = -1;
+ s_info.hello_ctx.pid = -1;
+ s_info.hello_ctx.handle = -1;
out:
return result;
#endif
char *hw_acceleration;
+ int valid;
};
struct event {
return WIDGET_ERROR_NONE;
}
-HAPI int slave_rpc_update_handle(struct slave_node *slave, int handle)
+HAPI int slave_rpc_update_handle(struct slave_node *slave, int handle, int delete_pending_packet)
{
struct slave_rpc *rpc;
struct command *command;
slave_activated(slave);
EINA_LIST_FREE(rpc->pending_list, command) {
- push_command(command);
+ if (delete_pending_packet) {
+ destroy_command(command);
+ } else {
+ push_command(command);
+ }
}
return WIDGET_ERROR_NONE;
return slave_rpc_request_only(slave, NULL, packet, 0);
}
-HAPI int slave_rpc_clear_pending_list(struct slave_node *slave)
-{
- struct slave_rpc *rpc;
- struct command *command;
-
- rpc = slave_data(slave, "rpc");
- if (!rpc) {
- /*!
- * \note
- * Return negative value will remove this callback from the event list of the slave
- */
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
- EINA_LIST_FREE(rpc->pending_list, command) {
- assert(command->slave == slave);
-
- destroy_command(command);
- }
-
- return WIDGET_ERROR_NONE;
-}
-
/* End of a file */
#include <com-core.h>
#include <widget_service.h>
+#include <widget_service_internal.h>
#include <Ecore.h>