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