fa886127e103fb889707e946bea35bc8c58d0dbc
[apps/livebox/data-provider-master.git] / include / client_life.h
1 /*
2  * Copyright 2013  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 enum client_event {
18         CLIENT_EVENT_ACTIVATE,
19         CLIENT_EVENT_DEACTIVATE
20 };
21
22 enum client_global_event {
23         CLIENT_GLOBAL_EVENT_CREATE,
24         CLIENT_GLOBAL_EVENT_DESTROY
25 };
26
27 struct inst_info;
28 struct packet;
29
30 /*!
31  * \note
32  * Create & Destroy
33  */
34 extern struct client_node *client_create(pid_t pid, int handle);
35 #define client_destroy(client)  client_unref(client)
36
37 /*!
38  * \note
39  * Reference count
40  */
41 extern struct client_node *client_ref(struct client_node *client);
42 extern struct client_node *client_unref(struct client_node *client);
43 extern const int const client_refcnt(const struct client_node *client);
44
45 /*!
46  * \note
47  * Information of client PID
48  */
49 extern const pid_t const client_pid(const struct client_node *client);
50 extern struct client_node *client_find_by_pid(pid_t pid);
51 extern struct client_node *client_find_by_rpc_handle(int handle);
52
53 /*!
54  * \note
55  * Statistics for state of client
56  */
57 extern const int const client_count_paused(void);
58 extern int client_is_all_paused(void);
59 extern int client_count(void);
60
61 /*!
62  * \note
63  * For dead signal handler
64  */
65 extern struct client_node *client_deactivated_by_fault(struct client_node *client);
66 extern void client_reset_fault(struct client_node *client);
67 extern const int const client_is_faulted(const struct client_node *client);
68
69 /*!
70  * \note
71  * For other components which wants to know the state of a client
72  */
73 extern int client_event_callback_add(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data);
74 extern int client_event_callback_del(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data);
75
76 extern int client_global_event_handler_del(enum client_global_event event_type, int (*cb)(struct client_node *, void *), void *data);
77 extern int client_global_event_handler_add(enum client_global_event event_type, int (*cb)(struct client_node *client, void *data), void *data);
78
79 /*!
80  * \note
81  * Private data set & get
82  */
83 extern int client_set_data(struct client_node *client, const char *tag, void *data);
84 extern void *client_data(struct client_node *client, const char *tag);
85 extern void *client_del_data(struct client_node *client, const char *tag);
86
87 /*!
88  * Handling the client statues
89  * Paused or Resumed
90  */
91 extern void client_paused(struct client_node *client);
92 extern void client_resumed(struct client_node *client);
93
94 extern int client_subscribe(struct client_node *client, const char *cluster, const char *category);
95 extern int client_unsubscribe(struct client_node *client, const char *cluster, const char *category);
96 extern int client_is_subscribed(struct client_node *client, const char *cluster, const char *category);
97
98 extern int client_init(void);
99 extern void client_fini(void);
100
101 extern int client_browse_list(const char *cluster, const char *category, int (*cb)(struct client_node *client, void *data), void *data);
102 extern int client_nr_of_subscriber(const char *cluster, const char *category);
103
104 extern int client_broadcast(struct inst_info *inst, struct packet *packet);
105 /* End of a file */