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