apply FSL(Flora Software License)
[apps/home/libug-worldclock-efl.git] / include / worldclock_util.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 __DEF_WORLDCLOCK_UTIL_H_
18 #define __DEF_WORLDCLOCK_UTIL_H_
19
20 #include <appcore-efl.h>
21 #include <Elementary.h>
22 #include <unicode/umachine.h>
23 #include "worldclock.h"
24
25 /**
26  * Compare the city name of two cities
27  *
28  * @param[in]  data1   record data of city1
29  * @param[in]  data2   record data of city2
30  *
31  * @return     -1 if city name of city2 is bigger than city1's
32  *              1 if city name of city1 is bigger than city2's
33  *              0 if city name of city2 is equal to city1, or meet error
34  */
35 int worldclock_city_compare_cb(const void *data1, const void *data2);
36
37 /**
38  * Compare timezone of two cities
39  *
40  * @param[in]  data1   recorder of city1
41  * @param[in]  data2   recorder of city2
42  *
43  * @return     -1 if timezone of city2 is bigger than city1's
44  *              1 if timezone of city1 is bigger than city2's
45  *              0 if timezone of city2 is equal to city1, or meet error
46  */
47 int worldclock_time_compare_cb(const void *data1, const void *data2);
48
49 /**
50  * Compare sequence of two cities
51  *
52  * @param[in]  data1   recorder of city1
53  * @param[in]  data2   recorder of city2
54  *
55  * @return     -1 if sequence of city2 is bigger than city1's
56  *              1 if sequence of city1 is bigger than city2's
57  *              0 if sequence of city2 is equal to city1, or meet error
58  */
59 int worldclock_sequence_compare_cb(const void *data1, const void *data2);
60
61 /**
62  * Checking whether the count of city list meet the max number
63  *
64  * @param[in]  city list
65  *
66  * @return     EINA_TRUE if list full
67  *             EINA_FALSE if not
68  */
69 Eina_Bool worldclock_is_city_list_full(Eina_List *eina_list);
70
71 /**
72  * Insert given city into given eina list
73  *
74  * @param[in]  city list
75  * @param[in]  cs  given city
76  *
77  * @return     -1 if not exist
78  *             0 if list full
79  *             list-count if success,
80  */
81 int worldclock_append_city_to_list(Eina_List **p_eina_list, Wcl_CitySet *cs);
82
83 /**
84  * Insert given city into given eina list
85  *
86  * @param[in]  city list
87  * @param[in]  cs  given city
88  * @param[in]  position to insert
89  *
90  * @return     -1 if not exist
91  *             0 if list full
92  *             list-count if success,
93  */
94 int worldclock_insert_city_to_list(Eina_List **p_eina_list, Wcl_CitySet *cs,
95                                    int position);
96
97 /**
98  * Remove all items in eina_list
99  *
100  * @param[in]  glist            given eina list
101  * @param[in]  is_free_element  flag to define if free data in every item is needed
102  *
103  * @return     EINA_TRUE if remove successfully
104  */
105 Eina_Bool worldclock_util_glist_remove_all(Eina_List *glist,
106                                            Eina_Bool is_free_element);
107
108 /**
109  * Creat new popup window, and show it
110  *
111  * @param[in]  parent Parent for such popup
112  * @param[in]  data   Data used in this function
113  * @param[in]  info   String displayed on popup
114  *
115  * @return
116  */
117 void worldclock_show_popup(Evas_Object *parent, Evas_Object **p_popup,
118                            char *info);
119
120 /**
121  * Check whether given city exist in given eina_list
122  *
123  * @param[in]  eina_list   given eina list
124  * @param[in]  cs          record of given city
125  * @return     EINA_FALSE if not exist
126  *             EINA_TRUE if exist
127  */
128 Eina_Bool worldclock_whether_city_exist_in_eina_list(Eina_List *eina_list,
129                                                      Wcl_CitySet *cs);
130
131 /**
132  * Reset now time of genlist item data
133  *
134  * @param[in]  eina_list   given eina list
135  *
136  * @return
137  */
138 void worldclock_reset_now_time(Eina_List *eina_list);
139
140 /**
141  * Create layout by load edj according group name from edj file
142  *
143  * @param[in]  parent   Parent of new layout
144  * @param[in]  file     EDJE file
145  * @param[in]  group    name of group
146  *
147  * @return     NULL if meet error
148  *             Pointer to new layout
149  */
150 Evas_Object *worldclock_load_edj(Evas_Object *parent, const char *file,
151                                  const char *group);
152
153 /**
154  * Search word in string
155  * * Set color on the word if found
156  * * Set max length to aimed string, replace tail with ...
157  *
158  * @param[in]  string      source string for search
159  * @param[in]  searchword  word which used for search
160  * @param[in]  max_len     Max length of string which to display
161  *
162  * @return  string which for displaying
163  */
164 const char *worldclock_searchword_in_string(const char *string,
165                                             char *searchword, int max_len);
166
167 /**
168  * This function is used to compute the length of string which displaying on entry
169  * The html flag which could change the actual length of string should be ignored.
170  *
171  * @param[in]  str    source string which got from entry
172  *
173  * @return  The length of the displaying part about str
174  */
175 int worldclock_str_get_displaying_length(const char *str);
176
177 /**
178  * This function is used to get the displaying of string which displaying on entry
179  *
180  * @param[in]  src    source string which got from entry
181  * @param[in]  dst    dest string which write the displaying part to
182  *
183  * @return  The length of displaying part
184  */
185 int worldclock_str_get_displaying_part(const char *src, char *dst);
186
187 /**
188  * This function is used to justify whethet html flag exist in string
189  *
190  * @param[in]  str    source string which got from entry
191  *
192  * @return  EINA_TRUE if contain html
193  */
194 Eina_Bool worldclock_str_is_contain_html(const char *str);
195
196 /**
197  * This function is used to convert string type from Unicode to UTF8
198  *
199  * @param[in]  unichars    source string whose type is Unicode
200  *
201  * @return  The result string whose type is UTF8
202  */
203 char *worldclock_strToUTF8(const UChar * unichars);
204
205 int worldclock_dst_get(const Wcl_CitySet *cs);
206 time_t worldclock_genlist_time_get(Wcl_CitySet *cs, void *data);
207
208 Evas_Object *widget_create_controlbar(Evas_Object *parent, const char *style);
209 #endif                          /* __DEF_WORLDCLOCK_UTIL_H_ */