alternate instance info regarding newly added client object.
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]
Change-Id: I383de7d9c170a35937cc48480038af7d3bcbdd41
extern void client_paused(struct client_node *client);
extern void client_resumed(struct client_node *client);
+/* Related with Context-Aware service */
extern int client_subscribe(struct client_node *client, const char *cluster, const char *category);
extern int client_unsubscribe(struct client_node *client, const char *cluster, const char *category);
extern int client_is_subscribed(struct client_node *client, const char *cluster, const char *category);
+/* Related with category */
+extern int client_subscribe_category(struct client_node *client, const char *category);
+extern int client_unsubscribe_category(struct client_node *client, const char *category);
+extern int client_is_subscribed_by_category(struct client_node *client, const char *category);
+
extern int client_init(void);
extern void client_fini(void);
.destroy_event_list = NULL,
};
-struct subscribe_item {
+struct subscribe_item { /* Cluster & Sub-cluster. related with Context-aware service */
char *cluster;
char *category;
};
+struct category_subscribe_item {
+ char *category;
+};
+
struct global_event_item {
void *cbdata;
int (*cb)(struct client_node *client, void *data);
Eina_List *data_list;
Eina_List *subscribe_list;
+ Eina_List *category_subscribe_list;
int faulted;
char *direct_addr;
struct event_item *event;
struct data_item *data;
struct subscribe_item *item;
+ struct category_subscribe_item *category_item;
Ecore_Timer *timer;
timer = client_del_data(client, "create,timer");
DbgFree(item);
}
+ EINA_LIST_FREE(client->category_subscribe_list, category_item) {
+ DbgFree(category_item->category);
+ DbgFree(category_item);
+ }
+
if (client->paused) {
s_info.nr_of_paused_clients--;
}
return DBOX_STATUS_ERROR_NOT_EXIST;
}
+HAPI int client_subscribe_category(struct client_node *client, const char *category)
+{
+ struct category_subscribe_item *item;
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ item->category = strdup(category);
+ if (!item->category) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ DbgFree(item);
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ client->category_subscribe_list = eina_list_append(client->category_subscribe_list, item);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+HAPI int client_unsubscribe_category(struct client_node *client, const char *category)
+{
+ struct category_subscribe_item *item;
+ Eina_List *l;
+ Eina_List *n;
+
+ EINA_LIST_FOREACH_SAFE(client->category_subscribe_list, l, n, item) {
+ if (!strcasecmp(category, item->category)) {
+ client->category_subscribe_list = eina_list_remove(client->category_subscribe_list, item);
+ DbgFree(item->category);
+ DbgFree(item);
+ return DBOX_STATUS_ERROR_NONE;
+ }
+ }
+
+ return DBOX_STATUS_ERROR_NOT_EXIST;
+}
+
+HAPI int client_is_subscribed_by_category(struct client_node *client, const char *category)
+{
+ struct category_subscribe_item *item;
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(client->category_subscribe_list, l, item) {
+ if (!strcasecmp(item->category, category)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
HAPI int client_subscribe(struct client_node *client, const char *cluster, const char *category)
{
struct subscribe_item *item;
return NULL;
}
-static struct packet *client_subscribe_category(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_subscribed_category(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *category;
* 2. Send created events to the client.
* 3. Add this client to "client_only_view_list"
*/
+ if (client_subscribe_category(client, category) == DBOX_STATUS_ERROR_NONE) {
+ package_alter_instances_to_client(client, ALTER_CREATE);
+ }
out:
/*! \note No reply packet */
return NULL;
}
-static struct packet *client_unsubscribe_category(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_unsubscribed_category(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *category;
/*!
* \TODO
+ * 0. Is this client subscribed to given "category"?
* 1. Get a list of created dynamicbox instances
* 2. and then send destroyed event to this client.
* 3. Remove this client from the "client_only_view_list"
*/
+ if (client_unsubscribe_category(client, category) == DBOX_STATUS_ERROR_NONE) {
+ package_alter_instances_to_client(client, ALTER_DESTROY);
+ }
out:
/*! \note No reply packet */
return NULL;
}
-
static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
{
struct slave_node *slave;
},
{
.cmd = CMD_STR_SUBSCRIBE_CATEGORY,
- .handler = client_subscribe_category,
+ .handler = client_subscribed_category,
},
{
.cmd = CMD_STR_UNSUBSCRIBE_CATEGORY,
- .handler = client_unsubscribe_category,
+ .handler = client_unsubscribed_category,
},
{