Initialize the project.
[apps/livebox/livebox.git] / include / livebox.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 #ifndef __LIVEBOX_HELPER_H
18 #define __LIVEBOX_HELPER_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 struct livebox_buffer; /* Defined by provider */
25
26 /*!
27  * \brief
28  * Return values of livebox programming interfaces.
29  */
30 extern const int DONE; /*!< Operation is successfully done */
31 extern const int NEED_TO_SCHEDULE; /*!< Need to call the livebox_need_to_update and livebox_update_content */
32 extern const int OUTPUT_UPDATED; /*!< Contents is updated */
33 extern const int NEED_TO_CREATE; /*!< Need to create a new instance */
34 extern const int NEED_TO_DESTROY; /*!< Need to destroy this instance */
35
36 extern const int LB_SYS_EVENT_FONT_CHANGED; /*!< System font is changed */
37 extern const int LB_SYS_EVENT_LANG_CHANGED; /*!< System language is changed */
38 extern const int LB_SYS_EVENT_PAUSED;
39 extern const int LB_SYS_EVENT_RESUMED;
40
41 #define LB_DESC_TYPE_TEXT "text"
42 #define LB_DESC_TYPE_IMAGE "image"
43 #define LB_DESC_TYPE_SIGNAL "signal"
44 #define LB_DESC_TYPE_INFO "info"
45 #define LB_DESC_TYPE_DRAG "drag"
46 #define LB_DESC_TYPE_SCRIPT "script"
47
48 /*!
49  * \brief
50  * Extra event informatino for livebox_content_event interface function
51  */
52 #ifndef __PROVIDER_H
53 struct event_info {
54         struct {
55                 double x;
56                 double y;
57                 int down;
58         } pointer; /*!< Down/Up state and mouse position */
59
60         struct {
61                 double sx;
62                 double sy;
63                 double ex;
64                 double ey;
65         } part; /*!< Geometry of event received part */
66 };
67 #endif
68
69 struct livebox_desc;
70
71 /*!
72  * \brief Update a description file.
73  * \param[in] filename
74  * \param[in] for_pd
75  * \return handle
76  */
77 extern struct livebox_desc *livebox_desc_open(const char *filename, int for_pd);
78
79 /*!
80  * \brief Complete the description file updating
81  * \param[in] handle
82  * \return int
83  */
84 extern int livebox_desc_close(struct livebox_desc *handle);
85
86 /*!
87  * \brief Set the category information of current description data
88  * \param[in] handle
89  * \param[in] id
90  * \param[in] category
91  * \return int
92  */
93 extern int livebox_desc_set_category(struct livebox_desc *handle, const char *id, const char *category);
94
95 /*!
96  * \brief Set the content size
97  * \param[in] handle
98  * \param[in] id
99  * \param[in] w
100  * \param[in] h
101  * \return int
102  */
103 extern int livebox_desc_set_size(struct livebox_desc *handle, const char *id, int w, int h);
104
105 /*!
106  * \breif Set the target id of given block
107  *        Only available for the script block
108  * \param[in] handle
109  * \param[in] idx
110  * \param[in] id
111  * \return ret
112  */
113 extern int livebox_desc_set_id(struct livebox_desc *handle, int idx, const char *id);
114
115 /*!
116  * \brief Add a new block
117  * \param[in] handle
118  * \param[in] id ID of source script object
119  * \param[in] type image|text|script|signal|...
120  * \param[in] part target part to update with given content(data)
121  * \param[in] data content for specified part
122  * \param[in] group script group name
123  * \return idx Index of current description block
124  */
125 extern int livebox_desc_add_block(struct livebox_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *group);
126
127 /*!
128  * \brief Delete a added block
129  * \param[in] handle
130  * \param[in] idx Index of added block
131  * \return int
132  */
133 extern int livebox_desc_del_block(struct livebox_desc *handle, int idx);
134
135 /*!
136  * \brief Replace '\n' with '<br>'
137  * \param[in] str Source string
138  * \return char* allocated string
139  */
140 extern char *livebox_util_nl2br(const char *str);
141
142
143 /*!
144  * Interfaces for direct buffer management (Available only for the PD area)
145  */
146
147
148 #ifndef __PROVIDER_BUFFER_H
149 /*!
150  * \NOTE
151  * This enumeration value should be sync'd with provider
152  */
153 enum buffer_event {
154         BUFFER_EVENT_ENTER, /*!< */
155         BUFFER_EVENT_LEAVE, /*!< */
156         BUFFER_EVENT_DOWN, /*!< */
157         BUFFER_EVENT_MOVE, /*!< */
158         BUFFER_EVENT_UP, /*!< */
159 };
160 #endif
161
162 /*!
163  * \brief
164  * \param[in] filename
165  * \param[in] width
166  * \param[in] height
167  * \param[in] handler
168  * \param[in] data
169  * \return handler
170  */
171 extern struct livebox_buffer *livebox_acquire_buffer(const char *filename, int is_pd, int width, int height, int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *), void *data);
172
173 /*!
174  * \param[in] filename
175  * \return pixmap ID
176  */
177 extern unsigned long livebox_pixmap_id(struct livebox_buffer *handle);
178
179 /*!
180  * \brief
181  * \param[in] handle
182  * \return int
183  */
184 extern int livebox_release_buffer(struct livebox_buffer *handle);
185
186 /*!
187  * \brief
188  * \param[in] handle
189  * \return void* buffer
190  */
191 extern void *livebox_ref_buffer(struct livebox_buffer *handle);
192
193 /*!
194  * \brief
195  * \param[in] buffer
196  * \return int
197  */
198 extern int livebox_unref_buffer(void *buffer);
199
200 /*!
201  * \brief
202  * \param[in] handler
203  * \return int
204  */
205 extern int livebox_sync_buffer(struct livebox_buffer *handle);
206
207 #ifdef __cplusplus
208 }
209 #endif
210
211 #endif
212 /* End of a file */