sync with private git. updated the license and the boilerplates
[apps/home/quickpanel.git] / daemon / notifications / noti_box.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *  http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <string.h>
18 #include <Ecore_X.h>
19
20 #include "quickpanel-ui.h"
21 #include "common.h"
22 #include "list_util.h"
23 #include "quickpanel_def.h"
24 #include "noti_box.h"
25 #include "noti_node.h"
26 #include "noti.h"
27 #include "noti_util.h"
28 #ifdef QP_ANIMATED_IMAGE_ENABLE
29 #include "animated_image.h"
30 #endif
31
32 #define IMAGE_NO_RESIZE 0
33 #define IMAGE_RESIZE 1
34
35 #define TEXT_NO_CR 0
36 #define TEXT_CR 1
37
38 static void _noti_box_call_item_cb(Evas_Object *noti_box, const char *emission) {
39         retif(noti_box == NULL, , "invalid parameter");
40         retif(emission == NULL, , "invalid parameter");
41
42         INFO("recevied emission:%s", emission);
43
44         void (*cb)(void *data, Evas_Object *obj) = NULL;
45         noti_box_h *data = NULL;
46
47         data = evas_object_data_get(noti_box, E_DATA_NOTI_BOX_H);
48
49         if (strncmp(emission,"selected", strlen("selected")) == 0) {
50                 cb = evas_object_data_get(noti_box, E_DATA_CB_SELECTED_ITEM);
51
52                 if (cb != NULL && data != NULL) {
53                         cb(data->data, noti_box);
54                 }
55         }
56         if (strncmp(emission,"button_1", strlen("button_1")) == 0) {
57                 cb = evas_object_data_get(noti_box, E_DATA_CB_BUTTON_1);
58
59                 if (cb != NULL && data != NULL) {
60                         cb(data->data, noti_box);
61                 }
62         }
63         if (strncmp(emission,"deleted", strlen("deleted")) == 0) {
64                 cb = evas_object_data_get(noti_box, E_DATA_CB_DELETED_ITEM);
65
66                 if (cb != NULL && data != NULL) {
67                         cb(data->data, noti_box);
68                 }
69         }
70 }
71
72 static void _signal_cb(void *data, Evas_Object *o, const char *emission, const char *source)
73 {
74         retif(data == NULL, , "invalid parameter");
75         retif(o == NULL, , "invalid parameter");
76         retif(emission == NULL, , "invalid parameter");
77
78         _noti_box_call_item_cb(o, emission);
79 }
80
81
82 HAPI Evas_Object *noti_box_create(Evas_Object *parent, notification_ly_type_e layout) {
83         Evas_Object *box = NULL;
84
85         box = elm_layout_add(parent);
86
87         if (layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE
88                         || layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE) {
89                 elm_layout_file_set(box, DEFAULT_EDJ,
90                                 "quickpanel/notibox/single_multi");
91         } else if (layout == NOTIFICATION_LY_NOTI_THUMBNAIL) {
92                 elm_layout_file_set(box, DEFAULT_EDJ, "quickpanel/notibox/thumbnail");
93         } else {
94                 elm_layout_file_set(box, DEFAULT_EDJ,
95                                 "quickpanel/notibox/single_multi");
96         }
97
98         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99         evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
100         evas_object_show(box);
101
102         noti_box_h *box_h = (noti_box_h *) malloc(sizeof(noti_box_h));
103         box_h->layout = layout;
104         box_h->status = STATE_NORMAL;
105         box_h->data = NULL;
106         evas_object_data_set(box, E_DATA_NOTI_BOX_H, box_h);
107         INFO("created notibox:%p", box);
108
109         //add event
110         elm_object_signal_callback_add(box,
111                         "selected",
112                         "edje",
113                         _signal_cb,
114                         parent
115         );
116
117         //add event
118         elm_object_signal_callback_add(box,
119                         "button_1",
120                         "edje",
121                         _signal_cb,
122                         parent
123         );
124
125         //add event
126         elm_object_signal_callback_add(box,
127                         "deleted",
128                         "edje",
129                         _signal_cb,
130                         parent
131         );
132
133         return box;
134 }
135
136 static Evas_Object *_set_image(Evas_Object *noti_box, notification_h noti,
137                 notification_image_type_e image_type, const char *part, int is_stretch) {
138
139         Evas_Object *content = NULL;
140         char *image = NULL;
141         int w = 0, h =0;
142         int part_w = 0, part_h =0;
143         double scale = 1.0;
144
145         retif(part == NULL, NULL,"invalid parameter");
146
147         struct appdata *ad = quickpanel_get_app_data();
148         if (ad != NULL) {
149                 scale = ad->scale;
150         }
151
152         notification_get_image(noti, image_type, &image);
153
154         if (image != NULL) {
155                 content = elm_image_add(noti_box);
156                 elm_image_file_set(content, image, image);
157                 if (is_stretch == IMAGE_RESIZE) {
158                         elm_image_aspect_fixed_set(content, EINA_FALSE);
159                         elm_image_resizable_set(content, EINA_TRUE, EINA_TRUE);
160                 } else {
161                         elm_image_object_size_get(content, &w, &h);
162
163                         if (strcmp(part, BOX_PART_ICON) == 0) {
164                                 part_w = scale * BOX_ICON_SIZE_W;
165                                 part_h = scale * BOX_ICON_SIZE_H;
166                         }
167                         if (strcmp(part, BOX_PART_ICON_SUB) == 0) {
168                                 part_w = scale * BOX_ICON_SUB_SIZE_W;
169                                 part_h = scale * BOX_ICON_SUB_SIZE_H;
170                         }
171
172                         if (part_w != 0 && part_h != 0) {
173                                 if (w > part_w || h > part_h) {
174                                         elm_image_aspect_fixed_set(content, EINA_FALSE);
175                                         elm_image_resizable_set(content, EINA_TRUE, EINA_TRUE);
176                                 } else {
177                                         elm_image_aspect_fixed_set(content, EINA_TRUE);
178                                         elm_image_resizable_set(content, EINA_FALSE, EINA_FALSE);
179                                 }
180                         } else {
181                                 elm_image_aspect_fixed_set(content, EINA_TRUE);
182                                 elm_image_resizable_set(content, EINA_FALSE, EINA_FALSE);
183                         }
184                 }
185
186                 elm_object_part_content_set(noti_box, part, content);
187                 elm_object_signal_emit(noti_box, "object.show", part);
188         }
189
190         return content;
191 }
192
193 static int _set_text(Evas_Object *noti_box, notification_h noti,
194                 notification_text_type_e text_type, const char *part, int is_need_effect, int is_support_cr) {
195         char buf[128] = { 0, };
196
197         char *text = NULL;
198         char *text_utf8 = NULL;
199         time_t time = 0;
200
201         if (notification_get_time_from_text(noti, text_type, &time) == NOTIFICATION_ERROR_NONE) {
202                 if ((int)time > 0) {
203                         quickpanel_noti_get_time(time, buf, sizeof(buf));
204                         text = buf;
205                 }
206         } else {
207                 notification_get_text(noti, text_type, &text);
208         }
209
210         if (text != NULL) {
211                 if (strlen(text) > 0) {
212
213                         if (is_support_cr == TEXT_CR) {
214                                 text_utf8 = elm_entry_utf8_to_markup(text);
215                                 if (text_utf8 != NULL) {
216                                         elm_object_part_text_set(noti_box, part, text_utf8);
217                                         free(text_utf8);
218                                 } else {
219                                         elm_object_part_text_set(noti_box, part, text);
220                                 }
221                         } else {
222                                 quickpanel_util_char_replace(text, _NEWLINE, _SPACE);
223                                 elm_object_part_text_set(noti_box, part, text);
224                         }
225
226                         if (is_need_effect == 1)
227                                 elm_object_signal_emit(noti_box, "object.show.effect", part);
228                         else
229                                 elm_object_signal_emit(noti_box, "object.show", part);
230                 }
231
232                 return strlen(text);
233         }
234
235         return 0;
236 }
237
238 static int _check_text_null(notification_h noti,
239                 notification_text_type_e text_type) {
240         char *text = NULL;
241
242         notification_get_text(noti, text_type, &text);
243
244         if (text == NULL) {
245                 return 1;
246         }
247
248         return 0;
249 }
250
251 static int _check_image_null(notification_h noti,
252                 notification_image_type_e image_type) {
253         char *image = NULL;
254
255         notification_get_image(noti, image_type, &image);
256
257         if (image == NULL) {
258                 return 1;
259         }
260
261         if (strncasecmp(image, "(null)", strlen(image)) == 0) {
262                 return 1;
263         }
264
265         return 0;
266 }
267
268 static void _noti_box_set_layout_single(Evas_Object *noti_box,
269                 notification_h noti) {
270         char *dir = NULL;
271         char *domain = NULL;
272         int is_need_effect = 0;
273         int is_contents_only = 0;
274         int is_sub_info_1_only = 0;
275         Evas_Object *icon = NULL;
276
277         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND) == 0) {
278                 is_need_effect = 1;
279         }
280
281         if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_1) == 1
282                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1) == 1
283                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_2) == 1
284                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_2) == 1) {
285                 is_contents_only = 1;
286         }
287
288         if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_1) != 1
289                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1) == 1
290                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_2) == 1
291                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_2) == 1) {
292                 is_sub_info_1_only = 1;
293         }
294
295         DBG("is_contents_only:%d is_sub_info_1_only:%d", is_contents_only, is_sub_info_1_only);
296
297         notification_get_text_domain(noti, &domain, &dir);
298         if (domain != NULL && dir != NULL)
299                 bindtextdomain(domain, dir);
300
301         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_TITLE,
302                         "object.text.title", is_need_effect, TEXT_CR);
303
304         if (is_contents_only == 1) {
305                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_CONTENT,
306                                 "object.text.contents.multiline", is_need_effect, TEXT_CR);
307         } else {
308                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_CONTENT,
309                                 "object.text.contents", is_need_effect, TEXT_NO_CR);
310
311                 if (is_sub_info_1_only == 1) {
312                         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_1,
313                                                                                 "object.text.info.1.multiline", is_need_effect, TEXT_CR);
314                 } else {
315                         if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_1) == 0) {
316                                 if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1) == 1) {
317                                         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_1,
318                                                         "object.text.info.1", is_need_effect, TEXT_NO_CR);
319                                 } else {
320                                         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_1,
321                                                         "object.text.info.1.short", is_need_effect, TEXT_NO_CR);
322                                         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1,
323                                                         "object.text.info.sub.1", is_need_effect, TEXT_NO_CR);
324                                 }
325                         }
326                         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_2,
327                                         "object.text.info.2", is_need_effect, TEXT_NO_CR);
328                 }
329         }
330
331         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 0) {
332                 _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON,
333                                 "object.icon.sub", IMAGE_NO_RESIZE);
334                 icon = _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL,
335                                 "object.icon", IMAGE_NO_RESIZE);
336 #ifdef QP_ANIMATED_IMAGE_ENABLE
337                 quickpanel_animated_image_add(icon);
338 #endif
339         } else {
340                 icon = _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON,
341                                 "object.icon", IMAGE_NO_RESIZE);
342 #ifdef QP_ANIMATED_IMAGE_ENABLE
343                 quickpanel_animated_image_add(icon);
344 #endif
345                 _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB,
346                                 "object.icon.sub", IMAGE_NO_RESIZE);
347         }
348         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND,
349                         "object.icon.background", IMAGE_RESIZE);
350
351         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND) == 0) {
352                 elm_object_signal_emit(noti_box, "box.show.dim", "box.prog");
353         }
354         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_ICON) == 1
355                         && _check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 1) {
356                 elm_object_signal_emit(noti_box, "box.hide.icon.bg", "box.prog");
357         }
358         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB) == 0
359                         || _check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 0) {
360                 elm_object_signal_emit(noti_box, "box.show.sub.bg", "box.prog");
361         }
362 }
363
364 static void _noti_box_set_layout_multi(Evas_Object *noti_box,
365                 notification_h noti) {
366         int length = 0;
367         char *dir = NULL;
368         char *domain = NULL;
369         char buf[128] = {0,};
370         int is_need_effect = 0;
371         int is_sub_info_1_only = 0;
372         Evas_Object *icon = NULL;
373
374         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND) == 0) {
375                 is_need_effect = 1;
376         }
377
378         if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_1) != 1
379                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1) == 1
380                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_2) == 1
381                 && _check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_2) == 1) {
382                 is_sub_info_1_only = 1;
383         }
384
385         DBG("is_sub_info_1_only:%d", is_sub_info_1_only);
386
387         notification_get_text_domain(noti, &domain, &dir);
388         if (domain != NULL && dir != NULL)
389                 bindtextdomain(domain, dir);
390
391         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_TITLE,
392                         "object.text.title", is_need_effect, TEXT_CR);
393         if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT) == 0) {
394                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_CONTENT,
395                                 "object.text.contents.short", is_need_effect, TEXT_NO_CR);
396                 length = _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT,
397                                 "object.text.count", is_need_effect, TEXT_NO_CR);
398                 length = (length >= 5) ? 5 : length;
399                 snprintf(buf, sizeof(buf), "box.count.%d", length);
400                 elm_object_signal_emit(noti_box, buf, "box.prog");
401         } else {
402                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_CONTENT,
403                                 "object.text.contents", is_need_effect, TEXT_NO_CR);
404         }
405
406         if (is_sub_info_1_only == 1) {
407                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_1,
408                                                                         "object.text.info.1.multiline", is_need_effect, TEXT_CR);
409         } else {
410                 if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_1) == 0) {
411                         if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1) == 1) {
412                                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_1,
413                                                 "object.text.info.1", is_need_effect, TEXT_NO_CR);
414                         } else {
415                                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_1,
416                                                 "object.text.info.1.short", is_need_effect, TEXT_NO_CR);
417                                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_1,
418                                                 "object.text.info.sub.1", is_need_effect, TEXT_NO_CR);
419                         }
420                 }
421                 if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_2) == 0) {
422                         if (_check_text_null(noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_2) == 1) {
423                                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_2,
424                                                 "object.text.info.2", is_need_effect, TEXT_NO_CR);
425                         } else {
426                                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_2,
427                                                 "object.text.info.2.short", is_need_effect, TEXT_NO_CR);
428                                 _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_INFO_SUB_2,
429                                                 "object.text.info.sub.2", is_need_effect, TEXT_NO_CR);
430                         }
431                 }
432         }
433
434         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 0) {
435                 _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON,
436                                 "object.icon.sub", IMAGE_NO_RESIZE);
437                 icon = _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL,
438                                 "object.icon", IMAGE_NO_RESIZE);
439 #ifdef QP_ANIMATED_IMAGE_ENABLE
440                 quickpanel_animated_image_add(icon);
441 #endif
442         } else {
443                 icon = _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON,
444                                 "object.icon", IMAGE_NO_RESIZE);
445 #ifdef QP_ANIMATED_IMAGE_ENABLE
446                 quickpanel_animated_image_add(icon);
447 #endif
448                 _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB,
449                                 "object.icon.sub", IMAGE_NO_RESIZE);
450         }
451         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND,
452                         "object.icon.background", IMAGE_RESIZE);
453         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND) == 0) {
454                 elm_object_signal_emit(noti_box, "box.show.dim", "box.prog");
455         }
456         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_ICON) == 1
457                         && _check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 1) {
458                 elm_object_signal_emit(noti_box, "box.hide.icon.bg", "box.prog");
459         }
460         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB) == 0
461                         || _check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 0) {
462                 elm_object_signal_emit(noti_box, "box.show.sub.bg", "box.prog");
463         }
464 }
465
466 static void _noti_box_set_layout_thumbnail(Evas_Object *noti_box,
467                 notification_h noti) {
468         char *dir = NULL;
469         char *domain = NULL;
470         int is_need_effect = 0;
471         Evas_Object *icon = NULL;
472
473         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND) == 0)
474                 is_need_effect = 1;
475         else
476                 is_need_effect = 0;
477
478         notification_get_text_domain(noti, &domain, &dir);
479         if (domain != NULL && dir != NULL)
480                 bindtextdomain(domain, dir);
481
482         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_TITLE,
483                         "object.text.title", is_need_effect, TEXT_CR);
484         _set_text(noti_box, noti, NOTIFICATION_TEXT_TYPE_CONTENT,
485                         "object.text.contents", is_need_effect, TEXT_NO_CR);
486
487         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 0) {
488                 _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON,
489                                 "object.icon.sub", IMAGE_NO_RESIZE);
490                 icon = _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL,
491                                 "object.icon", IMAGE_NO_RESIZE);
492 #ifdef QP_ANIMATED_IMAGE_ENABLE
493                 quickpanel_animated_image_add(icon);
494 #endif
495         } else {
496                 icon = _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON,
497                                 "object.icon", IMAGE_NO_RESIZE);
498 #ifdef QP_ANIMATED_IMAGE_ENABLE
499                 quickpanel_animated_image_add(icon);
500 #endif
501                 _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB,
502                                 "object.icon.sub", IMAGE_NO_RESIZE);
503         }
504         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND,
505                         "object.icon.background", IMAGE_RESIZE);
506
507         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_LIST_1,
508                         "object.thumbnail.list.1", IMAGE_RESIZE);
509         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_LIST_2,
510                         "object.thumbnail.list.2", IMAGE_RESIZE);
511         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_LIST_3,
512                         "object.thumbnail.list.3", IMAGE_RESIZE);
513         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_LIST_4,
514                         "object.thumbnail.list.4", IMAGE_RESIZE);
515         _set_image(noti_box, noti, NOTIFICATION_IMAGE_TYPE_LIST_5,
516                         "object.thumbnail.list.5", IMAGE_RESIZE);
517
518         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_BACKGROUND) == 0) {
519                 elm_object_signal_emit(noti_box, "box.show.dim", "box.prog");
520         }
521         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_ICON) == 1
522                         && _check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 1) {
523                 elm_object_signal_emit(noti_box, "box.hide.icon.bg", "box.prog");
524         }
525         if (_check_image_null(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB) == 0
526                         || _check_image_null(noti, NOTIFICATION_IMAGE_TYPE_THUMBNAIL) == 0) {
527                 elm_object_signal_emit(noti_box, "box.show.sub.bg", "box.prog");
528         }
529 }
530
531 static void _noti_box_set_layout(Evas_Object *noti_box, notification_h noti,
532                 notification_ly_type_e layout) {
533
534         INFO("layout:%d", layout);
535
536         switch (layout) {
537                 case NOTIFICATION_LY_NOTI_EVENT_SINGLE:
538                         _noti_box_set_layout_single(noti_box, noti);
539                         break;
540                 case NOTIFICATION_LY_NOTI_EVENT_MULTIPLE:
541                         _noti_box_set_layout_multi(noti_box, noti);
542                         break;
543                 case NOTIFICATION_LY_NOTI_THUMBNAIL:
544                         _noti_box_set_layout_thumbnail(noti_box, noti);
545                         break;
546                 case NOTIFICATION_LY_NONE:
547                 case NOTIFICATION_LY_ONGOING_EVENT:
548                 case NOTIFICATION_LY_ONGOING_PROGRESS:
549                 case NOTIFICATION_LY_MAX:
550                         ERR("not supported layout type:%d", layout);
551                         break;
552         }
553 }
554
555 HAPI void noti_box_remove(Evas_Object *noti_box) {
556
557         retif(noti_box == NULL, , "invalid parameter");
558
559         noti_box_h *noti_box_h = evas_object_data_get(noti_box, E_DATA_NOTI_BOX_H);
560
561         if (noti_box_h != NULL)
562                 free(noti_box_h);
563
564         evas_object_data_del(noti_box, E_DATA_NOTI_BOX_H);
565         evas_object_data_del(noti_box, E_DATA_CB_SELECTED_ITEM);
566         evas_object_data_del(noti_box, E_DATA_CB_DELETED_ITEM);
567
568         INFO("removed notibox:%p", noti_box);
569
570         evas_object_del(noti_box);
571 }
572
573 HAPI void noti_box_set_status(Evas_Object *noti_box, int status) {
574         retif(noti_box == NULL, , "invalid parameter");
575
576         noti_box_h *noti_box_h = evas_object_data_get(noti_box, E_DATA_NOTI_BOX_H);
577
578         if (noti_box_h != NULL) {
579                 noti_box_h->status = status;
580         }
581 }
582
583 HAPI int noti_box_get_status(Evas_Object *noti_box) {
584         retif(noti_box == NULL, STATE_NORMAL, "invalid parameter");
585
586         noti_box_h *noti_box_h = evas_object_data_get(noti_box, E_DATA_NOTI_BOX_H);
587
588         if (noti_box_h != NULL) {
589                 return noti_box_h->status;
590         }
591
592         return STATE_DELETING;
593 }
594
595 HAPI void noti_box_node_set(Evas_Object *noti_box, void *data) {
596         retif(noti_box == NULL, , "invalid parameter");
597         retif(data == NULL, , "invalid parameter");
598
599         noti_box_h *noti_box_data = evas_object_data_get(noti_box, E_DATA_NOTI_BOX_H);
600
601         if (noti_box_data != NULL) {
602                 noti_box_data->data = data;
603
604                 if (data != NULL) {
605                         noti_node_item *item = data;
606                         _noti_box_set_layout(noti_box, item->noti, noti_box_data->layout);
607                 }
608         }
609 }
610
611 HAPI void *noti_box_node_get(Evas_Object *noti_box) {
612         retif(noti_box == NULL, NULL, "invalid parameter");
613
614         noti_box_h *noti_box_data = evas_object_data_get(noti_box, E_DATA_NOTI_BOX_H);
615
616         if (noti_box_data != NULL) {
617                 return noti_box_data->data;
618         }
619
620         return NULL;
621 }
622
623 HAPI void noti_box_set_item_selected_cb(Evas_Object *noti_box,
624                 void(*selected_cb)(void *data, Evas_Object *obj)) {
625         retif(noti_box == NULL, , "invalid parameter");
626         retif(selected_cb == NULL, , "invalid parameter");
627
628         evas_object_data_set(noti_box, E_DATA_CB_SELECTED_ITEM, selected_cb);
629 }
630
631 HAPI void noti_box_set_item_button_1_cb(Evas_Object *noti_box,
632                 void(*button_1_cb)(void *data, Evas_Object *obj)) {
633         retif(noti_box == NULL, , "invalid parameter");
634         retif(button_1_cb == NULL, , "invalid parameter");
635
636         evas_object_data_set(noti_box, E_DATA_CB_BUTTON_1, button_1_cb);
637 }
638
639 HAPI void noti_box_set_item_deleted_cb(Evas_Object *noti_box,
640                 void(*deleted_cb)(void *data, Evas_Object *obj)) {
641         retif(noti_box == NULL, , "invalid parameter");
642         retif(deleted_cb == NULL, , "invalid parameter");
643
644         evas_object_data_set(noti_box, E_DATA_CB_DELETED_ITEM, deleted_cb);
645 }