modules/information/ext_storage: fix sigsegv
[apps/core/preloaded/indicator-win.git] / src / icon.c
1 /*
2  *  Indicator
3  *
4  * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20
21 #include <Eina.h>
22 #include <app_preference.h>
23
24 #include "common.h"
25 #include "box.h"
26 #include "icon.h"
27 #include "list.h"
28 #include "main.h"
29 #include "indicator_gui.h"
30 #include "util.h"
31 #include "log.h"
32
33 #define PRIVATE_DATA_KEY_ICON_B_ANI "p_i_ba"
34
35 extern int current_angle;
36
37 #define ON_TIMER_ICON_ANIMATION_FRAME_TIME 0.3
38 #define UPLOAD_ICON_ANIMATION_SIGNAL    "indicator.ani.uploading.%d"
39 #define DOWNLOAD_ICON_ANIMATION_SIGNAL "indicator.ani.downloading.%d"
40
41 static unsigned int update_icon_flag = 1;       // For battery problem
42
43 static void _reset_on_timer_icon_animation(icon_s *icon)
44 {
45         ret_if(!icon);
46
47         if (icon->p_animation_timer) {
48                 ecore_timer_del(icon->p_animation_timer);
49                 icon->p_animation_timer = NULL;
50         }
51         icon->animation_in_progress = EINA_FALSE;
52         icon->last_animation_timestamp = ecore_time_unix_get();
53         icon->signal_to_emit_prefix[0] = '\0';
54         icon->animation_state = UD_ICON_ANI_STATE_0;
55 }
56
57
58
59 static Eina_Bool _animate_on_timer_cb(void *data)
60 {
61         icon_s *icon = NULL;
62
63         retv_if(!data, ECORE_CALLBACK_CANCEL);
64
65         icon = (icon_s *)data;
66
67         if (icon->animation_in_progress == EINA_FALSE) {
68                 icon->p_animation_timer = NULL;
69                 return ECORE_CALLBACK_CANCEL;
70         }
71
72         if ((ecore_time_unix_get() - icon->last_animation_timestamp) < ON_TIMER_ICON_ANIMATION_FRAME_TIME) {
73                 return ECORE_CALLBACK_RENEW;
74         }
75
76         Evas_Object *img_edje = elm_layout_edje_get(icon->img_obj.obj);
77         retv_if(!img_edje, ECORE_CALLBACK_CANCEL);
78
79         char signal_to_emit[32] = {'\0',};
80         sprintf(signal_to_emit,icon->signal_to_emit_prefix,icon->animation_state);
81
82         edje_object_signal_emit(img_edje, signal_to_emit,"prog");
83
84         if (icon->animation_state == UD_ICON_ANI_STATE_MAX) {
85                 icon->animation_state = UD_ICON_ANI_STATE_0;
86         } else {
87                 icon->animation_state++;
88         }
89         icon->last_animation_timestamp = ecore_time_unix_get();
90
91         return ECORE_CALLBACK_RENEW;
92 }
93
94
95
96 static const char *_icon_ani_type_set_send_signal(icon_s *icon, Icon_Ani_Type type)
97 {
98         retv_if(!icon, NULL);
99
100         const char *BLINK_SIGNAL = "icon,state,blink";
101         const char *ROATATE_SIGNAL = "icon,state,rotate";
102         const char *METRONOME_SIGNAL = "icon,state,metronome";
103         const char *DEFAULT = "icon,state,default";
104         const char *send_signal = DEFAULT;
105
106         switch (type) {
107         case ICON_ANI_BLINK:
108                 send_signal = BLINK_SIGNAL;
109                 break;
110         case ICON_ANI_ROTATE:
111                 send_signal = ROATATE_SIGNAL;
112                 break;
113         case ICON_ANI_METRONOME:
114                 send_signal = METRONOME_SIGNAL;
115                 break;
116         case ICON_ANI_DOWNLOADING:
117         case ICON_ANI_UPLOADING:
118                 /* If this icon is already animated during download/upload we don't have to set timer again */
119                 if (icon->animation_in_progress == EINA_FALSE) {
120                         _reset_on_timer_icon_animation(icon);
121                         send_signal = "dummy.signal";
122
123                         if (type == ICON_ANI_DOWNLOADING) {
124                                 strncpy(icon->signal_to_emit_prefix, DOWNLOAD_ICON_ANIMATION_SIGNAL, sizeof(DOWNLOAD_ICON_ANIMATION_SIGNAL));
125                         }
126
127                         if (type == ICON_ANI_UPLOADING) {
128                                 strncpy(icon->signal_to_emit_prefix, UPLOAD_ICON_ANIMATION_SIGNAL,sizeof(UPLOAD_ICON_ANIMATION_SIGNAL));
129                         }
130                         icon->animation_in_progress = EINA_TRUE;
131                         icon->p_animation_timer = ecore_timer_add(ON_TIMER_ICON_ANIMATION_FRAME_TIME,_animate_on_timer_cb, icon);
132                 }
133                 break;
134         default:
135                 break;
136         }
137
138         return send_signal;
139 }
140
141
142
143 void icon_ani_set(icon_s *icon, Icon_Ani_Type type)
144 {
145         Evas_Object *img_edje = NULL;
146         const char *send_signal = NULL;
147
148         ret_if(!icon);
149
150         icon->ani = type;
151
152         if (!icon->obj_exist) return;
153
154         send_signal = _icon_ani_type_set_send_signal(icon, type);
155         ret_if(!send_signal);
156
157         switch (icon->type) {
158         case INDICATOR_IMG_ICON:
159                 img_edje = elm_layout_edje_get(icon->img_obj.obj);
160                 edje_object_signal_emit(img_edje, send_signal,"elm.swallow.icon");
161                 break;
162         case INDICATOR_TXT_ICON:
163                 break;
164         case INDICATOR_TXT_WITH_IMG_ICON:
165                 break;
166         case INDICATOR_DIGIT_ICON:
167                 img_edje = elm_layout_edje_get(icon->img_obj.obj);
168                 edje_object_signal_emit(img_edje, send_signal,"elm.swallow.icon");
169                 break;
170         default:
171                 break;
172         }
173 }
174
175
176
177 static void _fixed_icon_layout_file_set(icon_s *icon, Evas_Object *ly)
178 {
179         ret_if(!icon);
180         ret_if(!ly);
181
182         if(icon->type == INDICATOR_DIGIT_ICON && icon->digit_area == DIGIT_DOZENS) {
183                 elm_layout_file_set(ly, util_get_res_file_path(ICON_THEME_FILE), "elm/indicator/icon/dozen_digit");
184         } else {
185                 elm_layout_file_set(ly, util_get_res_file_path(ICON_THEME_FILE), "elm/indicator/icon/base");
186         }
187 }
188
189
190
191 static void _noti_ani_icon_layout_file_set(int noti_is_ani, Evas_Object *ly)
192 {
193         ret_if(!ly);
194
195         if (noti_is_ani) {
196                 evas_object_data_set(ly, PRIVATE_DATA_KEY_ICON_B_ANI, (void *) 1);
197                 elm_layout_file_set(ly, util_get_res_file_path(ICON_NONFIXED_THEME_ANI_FILE), "elm/indicator/icon/base");
198         } else {
199                 elm_layout_file_set(ly, util_get_res_file_path(ICON_NONFIXED_THEME_FILE), "elm/indicator/icon/base");
200         }
201 }
202
203
204
205 static Evas_Object *_img_icon_add(win_info *win, icon_s *icon)
206 {
207         char path[PATH_MAX];
208         Evas_Object *evas_icon;
209         Evas_Object *ly;
210         const char *imgpath = NULL;
211         int noti_is_ani = 0;
212         int b_ani = 0;
213
214         retv_if(!win, NULL);
215         retv_if(!icon, NULL);
216
217         imgpath = (char *) icon->img_obj.data;
218
219         _reset_on_timer_icon_animation(icon);
220
221         if (icon->img_obj.width <= 0) {
222                 icon->img_obj.width = DEFAULT_ICON_WIDTH;
223         }
224
225         if (icon->img_obj.height <= 0) {
226                 icon->img_obj.height = DEFAULT_ICON_HEIGHT;
227         }
228
229         memset(path, 0x00, sizeof(path));
230
231         ly = elm_layout_add(win->layout);
232         retv_if(!ly, NULL);
233
234         if (icon->area == INDICATOR_ICON_AREA_FIXED) {
235                 _fixed_icon_layout_file_set(icon, ly);
236         } else {
237                 noti_is_ani = util_check_noti_ani(imgpath);
238                 _noti_ani_icon_layout_file_set(noti_is_ani, ly);
239         }
240
241         evas_icon = elm_image_add(ly);
242         retv_if(!evas_icon, NULL);
243
244         b_ani = (int) evas_object_data_get(ly, PRIVATE_DATA_KEY_ICON_B_ANI);
245         if (!b_ani) {
246                 /* Absolute path? */
247                 if (strncmp(imgpath, "/", 1) != 0) {
248                         snprintf(path, sizeof(path), "%s/%s", util_get_icon_dir(), imgpath);
249                 } else {
250                         strncpy(path, imgpath, sizeof(path)-1);
251                 }
252
253                 if (!ecore_file_exists(path)) {
254                         _E("icon file does not exist : %s", path);
255                 }
256                 elm_image_file_set(evas_icon, path, NULL);
257         }
258
259         evas_object_size_hint_min_set(evas_icon, ELM_SCALE_SIZE(icon->img_obj.width), ELM_SCALE_SIZE(icon->img_obj.height));
260         elm_object_part_content_set(ly, "elm.swallow.icon", evas_icon);
261
262         evas_object_data_set(ly, DATA_KEY_IMG_ICON, evas_icon);
263         evas_object_size_hint_min_set(ly, ELM_SCALE_SIZE(icon->img_obj.width), ELM_SCALE_SIZE(icon->img_obj.height));
264         evas_object_hide(ly);
265
266         return ly;
267 }
268
269
270
271 char *icon_label_set(const char *buf, char *font_name, char *font_style, int font_size, void *data)
272 {
273         Eina_Strbuf *temp_buf = NULL;
274         char *ret_str = NULL;
275         char *label_font = ICON_FONT_NAME;
276         char *label_font_style = ICON_FONT_STYLE;
277         int label_font_size = ICON_FONT_SIZE;
278         Eina_Bool buf_result = EINA_FALSE;
279
280         retif(data == NULL || buf == NULL, NULL, "Invalid parameter!");
281
282         temp_buf = eina_strbuf_new();
283         if (font_name != NULL)
284                 label_font = font_name;
285         if (font_style != NULL)
286                 label_font_style = font_style;
287         if (font_size > 0)
288                 label_font_size = font_size;
289
290         buf_result = eina_strbuf_append_printf(temp_buf, CUSTOM_LABEL_STRING,
291                                                    label_font, label_font_style,
292                                                    label_font_size, buf);
293
294         if (buf_result != EINA_FALSE)
295                 ret_str = eina_strbuf_string_steal(temp_buf);
296
297         eina_strbuf_free(temp_buf);
298
299         return ret_str;
300 }
301
302
303
304 Eina_Bool icon_add(win_info *win, icon_s *icon)
305 {
306         retv_if(!icon, EINA_FALSE);
307
308         switch (icon->type) {
309         case INDICATOR_TXT_ICON:
310                 break;
311         case INDICATOR_IMG_ICON:
312                 icon->img_obj.obj = _img_icon_add(win, icon);
313                 break;
314         case INDICATOR_TXT_WITH_IMG_ICON:
315                 break;
316         case INDICATOR_DIGIT_ICON:
317                 icon->img_obj.obj = _img_icon_add(win, icon);
318                 break;
319         default:
320                 _E("Icon type check error!");
321                 return EINA_FALSE;
322         }
323         icon->obj_exist = EINA_TRUE;
324
325         return EINA_TRUE;
326 }
327
328
329
330 Eina_Bool icon_del(icon_s *icon)
331 {
332         Evas_Object *icon_obj;
333         retif(icon == NULL, EINA_FALSE, "Invalid parameter!");
334
335         _reset_on_timer_icon_animation(icon);
336
337         if (icon->obj_exist != EINA_FALSE) {
338                 if (icon->img_obj.obj) {
339                         icon_obj =
340                                 evas_object_data_get(icon->img_obj.obj, DATA_KEY_IMG_ICON);
341                         evas_object_del(icon_obj);
342                         evas_object_del(icon->img_obj.obj);
343                         icon->img_obj.obj = NULL;
344                 }
345         }
346         return EINA_TRUE;
347 }
348
349
350
351 /******************************************************************************
352  *
353  * Static functions : util functions - check priority
354  *
355  *****************************************************************************/
356
357 static int _show_others_in_same_priority(icon_s *icon)
358 {
359         icon_s *wish_add_icon;
360         int area = icon->area;
361         retif(icon == NULL, FAIL, "Invalid parameter!");
362
363         wish_add_icon = list_try_to_find_icon_to_show(icon->area, icon->priority);
364         if (wish_add_icon == NULL)
365         {
366                 return OK;
367         }
368
369         if (box_exist_icon(wish_add_icon))
370         {
371                 /* Already shown icon */
372                 return OK;
373         }
374
375         if(area ==INDICATOR_ICON_AREA_NOTI)
376         {
377                 box_pack_append(wish_add_icon);
378         }
379         else
380         {
381                 box_pack(wish_add_icon);
382         }
383
384         return OK;
385 }
386
387
388
389 static int _hide_others_in_view_list(icon_s *icon)
390 {
391         icon_s *wish_remove_icon = NULL;
392         retif(icon == NULL, FAIL, "Invalid parameter!");
393
394         if (INDICATOR_ICON_AREA_SYSTEM == icon->area || INDICATOR_ICON_AREA_NOTI == icon->area || INDICATOR_ICON_AREA_MINICTRL == icon->area)
395         {
396                 Icon_AddType ret;
397
398                 /* In Case of Nonfixed icon, remove same or
399                  * lower priority icon. Check count of non-fixed view list
400                  * to insert icon
401                  */
402                 ret = box_is_enable_to_insert_in_non_fixed_list(icon);
403                 icon->wish_to_show = EINA_TRUE;
404                 list_update(icon);
405
406                 switch (ret) {
407                 case CAN_ADD_WITH_DEL_NOTI:
408                         wish_remove_icon = list_try_to_find_icon_to_remove(INDICATOR_ICON_AREA_NOTI,0);
409                         box_unpack(wish_remove_icon);
410
411                         retif(wish_remove_icon == NULL, FAIL, "Unexpected Error : CAN_ADD_WITH_DEL_NOTI");
412                         break;
413                 case CAN_ADD_WITH_DEL_SYSTEM:
414                         wish_remove_icon = list_try_to_find_icon_to_remove(INDICATOR_ICON_AREA_SYSTEM,0);
415
416                         box_unpack(wish_remove_icon);
417                         retif(wish_remove_icon == NULL, FAIL, "Unexpected Error : CAN_ADD_WITH_DEL_SYSTEM");
418                         break;
419                 case CAN_ADD_WITH_DEL_MINICTRL:
420                         wish_remove_icon = list_try_to_find_icon_to_remove(INDICATOR_ICON_AREA_MINICTRL,0);
421
422                         box_unpack(wish_remove_icon);
423                         retif(wish_remove_icon == NULL, FAIL, "Unexpected Error : CAN_ADD_WITH_DEL_MINICTRL");
424                         break;
425                 case CAN_ADD_WITHOUT_DEL:
426                         break;
427                 case CANNOT_ADD:
428                         return FAIL;
429                         break;
430                 }
431
432                 return OK;
433         }
434         else if (INDICATOR_ICON_AREA_FIXED == icon->area)
435         {
436                 /* In Case of fixed icon, remove same priority icon */
437                 wish_remove_icon = list_try_to_find_icon_to_remove(INDICATOR_ICON_AREA_FIXED,icon->priority);
438
439                 /* First icon in the priority */
440                 if (wish_remove_icon == NULL)
441                 {
442                         return OK;
443                 }
444
445                 /* Already shown icon */
446                 if (wish_remove_icon == icon)
447                 {
448                         return FAIL;
449                 }
450
451                 icon->wish_to_show = EINA_TRUE;
452                 list_update(icon);
453
454                 /* Wish_remove_icon is always_top icon */
455                 if (wish_remove_icon->always_top)
456                 {
457                         return FAIL;
458                 }
459
460                 /* Other Icon of Same Priority should remove in view list */
461                 box_unpack(wish_remove_icon);
462         }
463
464         return OK;
465 }
466
467
468
469 /******************************************************************************
470  *
471  * Util Functions : external
472  *
473  *****************************************************************************/
474
475 #if 0
476 int icon_width_set(icon_s *icon)
477 {
478         return 0;
479 }
480 #endif
481
482
483 static int _icon_update(icon_s *icon)
484 {
485         struct appdata *ad = NULL;
486         Evas_Object *img_eo;
487         char buf[PATH_MAX];
488
489         retif(icon == NULL || icon->ad == NULL, FAIL, "Invalid parameter!");
490         ad = icon->ad;
491
492         memset(buf, 0x00, sizeof(buf));
493
494         if (icon->type == INDICATOR_IMG_ICON || icon->type == INDICATOR_TXT_WITH_IMG_ICON || icon->type == INDICATOR_DIGIT_ICON) {
495                 if (icon->area== INDICATOR_ICON_AREA_FIXED) {
496                         if(icon->type == INDICATOR_DIGIT_ICON && icon->digit_area == DIGIT_DOZENS) {
497                                 elm_layout_file_set(icon->img_obj.obj, util_get_res_file_path(ICON_THEME_FILE), "elm/indicator/icon/dozen_digit");
498                         } else {
499                                 elm_layout_file_set(icon->img_obj.obj, util_get_res_file_path(ICON_THEME_FILE), "elm/indicator/icon/base");
500                         }
501                 } else {
502                         if(util_check_noti_ani(icon->img_obj.data)) {
503                                 elm_layout_file_set(icon->img_obj.obj, util_get_res_file_path(ICON_NONFIXED_THEME_ANI_FILE), "elm/indicator/icon/base");
504                         } else{
505                                 elm_layout_file_set(icon->img_obj.obj, util_get_res_file_path(ICON_NONFIXED_THEME_FILE), "elm/indicator/icon/base");
506                         }
507                 }
508
509                 img_eo = evas_object_data_get(icon->img_obj.obj, DATA_KEY_IMG_ICON);
510
511                 util_start_noti_ani(icon);
512
513                 /* Check absolute path */
514                 retif(icon->img_obj.data == NULL, FAIL,"Invalid parameter!");
515
516                 if (strncmp(icon->img_obj.data, "/", 1) != 0) {
517                         snprintf(buf, sizeof(buf), "%s/%s", util_get_icon_dir(),icon->img_obj.data);
518                         elm_image_file_set(img_eo, buf, NULL);
519                 } else {
520                         retif(icon->img_obj.data[0] == '\0', FAIL,"Invalid parameter!");
521                         elm_image_file_set(img_eo, icon->img_obj.data, NULL);
522                 }
523
524                 if (icon->img_obj.width >= 0 && icon->img_obj.height>=0) {
525                         evas_object_size_hint_min_set(img_eo,
526                                 ELM_SCALE_SIZE(icon->img_obj.width),
527                                 ELM_SCALE_SIZE(icon->img_obj.height));
528                 } else {
529                         evas_object_size_hint_min_set(img_eo, ELM_SCALE_SIZE(DEFAULT_ICON_WIDTH), ELM_SCALE_SIZE(DEFAULT_ICON_HEIGHT));
530                 }
531         }
532
533         if (icon->area == INDICATOR_ICON_AREA_SYSTEM) {
534                 int bDisplay = 0;
535                 bDisplay = 1;
536                 if(ad->opacity_mode == INDICATOR_OPACITY_TRANSPARENT && bDisplay == 1) {
537                         util_send_status_message_start(ad,2.5);
538                 }
539         }
540
541         return OK;
542 }
543
544
545
546 void icon_show(icon_s *icon)
547 {
548         struct appdata *ad = NULL;
549
550         ret_if(!icon);
551         ret_if(!(icon->ad));
552
553         ad = (struct appdata *)icon->ad;
554
555         if (icon->obj_exist != EINA_FALSE) {
556                 if (icon->priority == INDICATOR_PRIORITY_NOTI_2) {
557                         box_unpack(icon);
558                         box_pack(icon);
559                         box_update_display(&(ad->win));
560                 } else {
561                         _icon_update(icon);
562                 }
563         }
564
565         if (_hide_others_in_view_list(icon) == FAIL) {
566                 return;
567         }
568
569         box_pack(icon);
570
571         box_update_display(&(ad->win));
572 }
573
574 void icon_hide(icon_s *icon)
575 {
576         int ret;
577
578         retif(icon == NULL, , "Invalid parameter!");
579         struct appdata *ad = (struct appdata *)icon->ad;
580
581         icon->wish_to_show = EINA_FALSE;
582
583         if (icon->exist_in_view == EINA_TRUE) {
584                 ret = box_unpack(icon);
585
586                 if (ret == FAIL)
587                         SECURE_ERR("Failed to unpack %s!", icon->name);
588
589                 _show_others_in_same_priority(icon);
590
591                 box_update_display(&(ad->win));
592
593         }
594 }
595
596
597 #if 0
598 void icon_event_count_set(int count, void *data)
599 {
600         static int _cnt = -1;
601         char buf[1024];
602
603         retif(data == NULL, , "Cannot get layout!");
604
605         if (_cnt != count) {
606                 memset(buf, 0x00, sizeof(buf));
607                 if (count) {
608                         snprintf(buf, sizeof(buf), "%d", count);
609                         util_signal_emit(data,"badge,show,1","elm.image.badge");
610                 } else {
611                         util_signal_emit(data,"badge,hide,1","elm.image.badge");
612                 }
613
614                 util_part_text_emit(data,"elm.text.badge", buf);
615                 _cnt = count;
616         }
617 }
618 #endif
619
620
621 unsigned int icon_get_update_flag(void)
622 {
623         return update_icon_flag;
624 }
625
626
627
628 void icon_set_update_flag(unsigned int val)
629 {
630         DBG("SET UPDATE FLAG %d",val);
631         update_icon_flag = val;
632 }
633
634
635
636 void icon_reset_list(void)
637 {
638         int system_cnt = box_get_count(SYSTEM_LIST);
639
640         if (system_cnt > box_get_enabled_system_count()) {
641                 while(system_cnt > box_get_enabled_system_count()) {
642                         icon_s *wish_remove_icon = NULL;
643                         wish_remove_icon = list_try_to_find_icon_to_remove(INDICATOR_ICON_AREA_SYSTEM, 0);
644
645                         if (wish_remove_icon == NULL) {
646                                 break;
647                         }
648
649                         box_unpack(wish_remove_icon);
650                         system_cnt = box_get_count(SYSTEM_LIST);
651                         SECURE_DBG("system remove %s %d",wish_remove_icon->name,system_cnt);
652                 }
653         } else {
654                 while (system_cnt < box_get_enabled_system_count()) {
655                         icon_s *wish_add_icon = NULL;
656                         wish_add_icon = list_try_to_find_icon_to_show(INDICATOR_ICON_AREA_SYSTEM, 0);
657                         if (wish_add_icon == NULL) {
658                                 break;
659                         }
660
661                         if (box_exist_icon(wish_add_icon)) {
662                                 break;
663                         }
664
665                         box_pack_append(wish_add_icon);
666                         system_cnt = box_get_count(SYSTEM_LIST);
667                         SECURE_DBG("system insert %s %d",wish_add_icon->name,system_cnt);
668                         if(system_cnt == box_get_enabled_system_count()) {
669                                 SECURE_DBG("quit adding %d %d",system_cnt,box_get_enabled_system_count());
670                                 break;
671                         }
672                 }
673         }
674
675         int minictrl_cnt = box_get_count(MINICTRL_LIST);
676
677         if (minictrl_cnt > box_get_minictrl_list()) {
678                 DBG("11 minictrl_cnt : %d //  box_get_minictrl_list : %d", minictrl_cnt, box_get_minictrl_list());
679                 while (minictrl_cnt > box_get_minictrl_list()) {
680                         DBG("22 minictrl_cnt : %d //  box_get_minictrl_list : %d", minictrl_cnt, box_get_minictrl_list());
681                         icon_s *wish_remove_icon = NULL;
682                         wish_remove_icon = list_try_to_find_icon_to_remove(INDICATOR_ICON_AREA_MINICTRL,0);
683
684                         if (wish_remove_icon == NULL) {
685                                 DBG("icon_reset_list NULL!");
686                                 break;
687                         }
688
689                         box_unpack(wish_remove_icon);
690                         minictrl_cnt = box_get_count(MINICTRL_LIST);
691                         SECURE_DBG("minictrl remove %s %d",wish_remove_icon->name,minictrl_cnt);
692                 }
693         } else {
694                 while (minictrl_cnt < box_get_minictrl_list()) {
695                         icon_s *wish_add_icon = NULL;
696                         wish_add_icon = list_try_to_find_icon_to_show(INDICATOR_ICON_AREA_MINICTRL, 0);
697                         if (wish_add_icon == NULL) {
698                                 break;
699                         }
700
701                         if (box_exist_icon(wish_add_icon)) {
702                                 break;
703                         }
704
705                         box_pack_append(wish_add_icon);
706                         minictrl_cnt = box_get_count(MINICTRL_LIST);
707                         SECURE_DBG("minictrl insert %s %d",wish_add_icon->name,minictrl_cnt);
708                         if(minictrl_cnt==box_get_minictrl_list()) {
709                                 SECURE_DBG("quit adding %d %d", minictrl_cnt, box_get_minictrl_list());
710                                 break;
711                         }
712                 }
713         }
714
715         int noti_cnt = box_get_count(NOTI_LIST);
716
717         if (noti_cnt > box_get_enabled_noti_count()) {
718                 while (noti_cnt > box_get_enabled_noti_count()) {
719                         icon_s *wish_remove_icon = NULL;
720                         wish_remove_icon = list_try_to_find_icon_to_remove(INDICATOR_ICON_AREA_NOTI, 0);
721
722                         if (wish_remove_icon == NULL) {
723                                 break;
724                         }
725
726                         box_unpack(wish_remove_icon);
727                         noti_cnt = box_get_count(NOTI_LIST);
728                         SECURE_DBG("remove %s %d",wish_remove_icon->name,noti_cnt);
729                 }
730         } else {
731                 while (noti_cnt < box_get_enabled_noti_count()) {
732                         icon_s *wish_add_icon = NULL;
733                         wish_add_icon = list_try_to_find_icon_to_show(INDICATOR_ICON_AREA_NOTI, 0);
734                         if (wish_add_icon == NULL) {
735                                 break;
736                         }
737
738                         if (box_exist_icon(wish_add_icon)) {
739                                 break;
740                         }
741
742                         box_pack_append(wish_add_icon);
743                         noti_cnt = box_get_count(NOTI_LIST);
744                         SECURE_DBG("insert %s %d", wish_add_icon->name, noti_cnt);
745                         if(noti_cnt==box_get_enabled_noti_count()) {
746                                 SECURE_DBG("quit adding %d %d", noti_cnt, box_get_enabled_noti_count());
747                                 break;
748                         }
749                 }
750         }
751 }
752
753
754
755 static void _show_hide_more_noti(win_info* win, bool show)
756 {
757         int err = preference_set_boolean(INDICATOR_MORE_NOTI, show);
758         retm_if(err != PREFERENCE_ERROR_NONE, "preference_set_boolean failed: %s", get_error_message(err));
759 }
760
761 void icon_handle_more_notify_icon(win_info* win)
762 {
763         retif(win == NULL, , "Invalid parameter!");
764         DBG("icon_handle_more_notify_icon called !!");
765 /*      int system_cnt = box_get_count(SYSTEM_LIST);
766         int minictrl_cnt = box_get_count(MINICTRL_LIST);
767         int noti_cnt = list_get_noti_count();
768
769         DBG("System count : %d, Minictrl count : %d, Notification count : %d", system_cnt, minictrl_cnt, noti_cnt);
770         if(win->type == INDICATOR_WIN_PORT)
771         {
772                 DBG("PORT :: %d", (system_cnt + minictrl_cnt + noti_cnt));
773                 if((system_cnt + minictrl_cnt + noti_cnt) > MAX_NOTI_ICONS_PORT)
774                 {
775                         _show_hide_more_noti(win, true);
776                         DBG("PORT :: handle_more_notify_show");
777                 }
778                 else
779                 {*/
780                         _show_hide_more_noti(win, false);
781                         DBG("PORT :: handle_more_notify_hide");
782                 /*}
783         }*/
784 }
785
786
787
788 void* icon_util_make(void* input)
789 {
790         icon_s *icon = (icon_s *)input;
791
792         retif(input == NULL,NULL, "Invalid parameter!");
793
794         icon_s *obj = NULL;
795         obj = calloc(1, sizeof(icon_s));
796
797         if (obj) {
798                 memset(obj, 0, sizeof(icon_s));
799                 memcpy(obj,input,sizeof(icon_s));
800                 obj->name = strdup(icon->name);
801         }
802
803         return obj;
804 }
805
806
807
808 /* End of file */