Initialize the project.
[apps/livebox/data-provider-master.git] / include / client_life.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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_DEACTIVATE,
19         CLIENT_EVENT_DESTROY,
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 extern int client_destroy(struct client_node *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 int 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 extern const int const client_is_activated(const struct client_node *client);
70
71 /*!
72  * \note
73  * For other components which wants to know the state of a client
74  */
75 extern int client_event_callback_add(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data);
76 extern int client_event_callback_del(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data);
77
78 extern int client_global_event_handler_del(enum client_global_event event_type, int (*cb)(struct client_node *, void *), void *data);
79 extern int client_global_event_handler_add(enum client_global_event event_type, int (*cb)(struct client_node *client, void *data), void *data);
80
81 /*!
82  * \note
83  * Private data set & get
84  */
85 extern int client_set_data(struct client_node *client, const char *tag, void *data);
86 extern void *client_data(struct client_node *client, const char *tag);
87 extern void *client_del_data(struct client_node *client, const char *tag);
88
89 /*!
90  * Handling the client statues
91  * Paused or Resumed
92  */
93 extern void client_paused(struct client_node *client);
94 extern void client_resumed(struct client_node *client);
95
96 extern int client_subscribe(struct client_node *client, const char *cluster, const char *category);
97 extern int client_unsubscribe(struct client_node *client, const char *cluster, const char *category);
98 extern int client_is_subscribed(struct client_node *client, const char *cluster, const char *category);
99
100 extern int client_init(void);
101 extern int client_fini(void);
102
103 extern int client_browse_list(const char *cluster, const char *category, int (*cb)(struct client_node *client, void *data), void *data);
104 extern int client_nr_of_subscriber(const char *cluster, const char *category);
105
106 extern int client_broadcast(struct inst_info *inst, struct packet *packet);
107 /* End of a file */