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