4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include <Elementary.h>
32 #include <notification.h>
33 #include <notification_db.h>
34 #include <notification_noti.h>
35 #include <notification_debug.h>
36 #include <notification_private.h>
38 #define NOTI_BURST_DELETE_UNIT 10
39 static int toast_height;
40 static Eina_List *toast_list;
41 static Eina_List *toast_popup;
43 static void __free_and_set(void **target_ptr, void *new_ptr) {
44 if (target_ptr != NULL) {
45 if (*target_ptr != NULL) {
48 *target_ptr = new_ptr;
52 static int _notification_noti_bind_query_text(sqlite3_stmt * stmt, const char *name,
58 index = sqlite3_bind_parameter_index(stmt, name);
60 NOTIFICATION_ERR("Insert : invalid column name");
61 return NOTIFICATION_ERROR_FROM_DB;
65 sqlite3_bind_text(stmt, index, NOTIFICATION_CHECK_STR(str), -1,
67 if (ret != SQLITE_OK) {
68 NOTIFICATION_ERR("Insert text : %s",
69 NOTIFICATION_CHECK_STR(str));
70 return NOTIFICATION_ERROR_FROM_DB;
73 return NOTIFICATION_ERROR_NONE;
76 static int _notification_noti_bind_query_double(sqlite3_stmt * stmt, const char *name,
82 index = sqlite3_bind_parameter_index(stmt, name);
84 NOTIFICATION_ERR("Insert : invalid column name");
85 return NOTIFICATION_ERROR_FROM_DB;
88 ret = sqlite3_bind_double(stmt, index, val);
89 if (ret != SQLITE_OK) {
90 NOTIFICATION_ERR("Insert double : %f", val);
91 return NOTIFICATION_ERROR_FROM_DB;
94 return NOTIFICATION_ERROR_NONE;
97 static int _notification_noti_check_priv_id(notification_h noti, sqlite3 * db)
100 int ret = NOTIFICATION_ERROR_NONE;
102 sqlite3_stmt *stmt = NULL;
104 /* Make query to check priv_id exist */
105 query = sqlite3_mprintf("SELECT count(*) FROM noti_list WHERE caller_pkgname = '%s' AND priv_id = %d",
106 noti->caller_pkgname, noti->priv_id);
108 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
112 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
113 if (ret != SQLITE_OK) {
114 NOTIFICATION_ERR("Get count DB err(%d) : %s", ret,
116 ret = NOTIFICATION_ERROR_FROM_DB;
120 ret = sqlite3_step(stmt);
121 if (ret == SQLITE_ROW) {
122 result = sqlite3_column_int(stmt, 0);
127 sqlite3_finalize(stmt);
129 /* If result > 0, there is priv_id in DB */
131 ret = NOTIFICATION_ERROR_ALREADY_EXIST_ID;
142 static int _notification_noti_get_internal_group_id_by_priv_id(const char *pkgname,
147 sqlite3_stmt *stmt = NULL;
148 int ret = NOTIFICATION_ERROR_NONE, result = 0;
150 query = sqlite3_mprintf("SELECT internal_group_id FROM noti_list WHERE caller_pkgname = '%s' AND priv_id = %d",
153 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
157 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
158 if (ret != SQLITE_OK) {
159 NOTIFICATION_ERR("Get count DB err(%d) : %s", ret,
161 ret = NOTIFICATION_ERROR_FROM_DB;
165 ret = sqlite3_step(stmt);
166 if (ret == SQLITE_ROW) {
167 result = sqlite3_column_int(stmt, 0);
174 sqlite3_finalize(stmt);
181 if (ret != NOTIFICATION_ERROR_NONE) {
182 NOTIFICATION_ERR("failed to internal group ID:%d", ret);
188 static int _insertion_query_create(notification_h noti, char **query)
190 int b_encode_len = 0;
192 char *group_args = NULL;
193 char *b_image_path = NULL;
194 char *b_execute_option = NULL;
195 char *b_service_responding = NULL;
196 char *b_service_single_launch = NULL;
197 char *b_service_multi_launch = NULL;
200 char *b_format_args = NULL;
201 int flag_simmode = 0;
204 return NOTIFICATION_ERROR_INVALID_PARAMETER;
207 /* Decode bundle to insert DB */
209 bundle_encode(noti->args, (bundle_raw **) & args, &b_encode_len);
211 if (noti->group_args) {
212 bundle_encode(noti->group_args, (bundle_raw **) & group_args,
216 if (noti->b_execute_option) {
217 bundle_encode(noti->b_execute_option,
218 (bundle_raw **) & b_execute_option, &b_encode_len);
220 if (noti->b_service_responding) {
221 bundle_encode(noti->b_service_responding,
222 (bundle_raw **) & b_service_responding, &b_encode_len);
224 if (noti->b_service_single_launch) {
225 bundle_encode(noti->b_service_single_launch,
226 (bundle_raw **) & b_service_single_launch, &b_encode_len);
228 if (noti->b_service_multi_launch) {
229 bundle_encode(noti->b_service_multi_launch,
230 (bundle_raw **) & b_service_multi_launch, &b_encode_len);
234 bundle_encode(noti->b_text, (bundle_raw **) & b_text, &b_encode_len);
237 bundle_encode(noti->b_key, (bundle_raw **) & b_key, &b_encode_len);
239 if (noti->b_format_args) {
240 bundle_encode(noti->b_format_args,
241 (bundle_raw **) & b_format_args, &b_encode_len);
244 if (noti->b_image_path) {
245 bundle_encode(noti->b_image_path,
246 (bundle_raw **) & b_image_path, &b_encode_len);
249 /* Check only simmode property is enable */
250 if (noti->flags_for_property & NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE) {
255 *query = sqlite3_mprintf("INSERT INTO noti_list ("
258 "caller_pkgname, launch_pkgname, "
260 "group_id, internal_group_id, priv_id, "
262 "b_text, b_key, tag, b_format_args, num_format_args, "
263 "text_domain, text_dir, "
264 "time, insert_time, "
267 "b_service_responding, b_service_single_launch, b_service_multi_launch, "
268 "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
269 "flags_for_property, flag_simmode, display_applist, "
270 "progress_size, progress_percentage) values ("
277 "'%s', '%s', '%s', '%s', %d, "
283 "%d, '%s', %d, '%s', %d, %d, %d, %d,"
285 "$progress_size, $progress_percentage)",
288 NOTIFICATION_CHECK_STR(noti->caller_pkgname),
289 NOTIFICATION_CHECK_STR(noti->launch_pkgname),
290 NOTIFICATION_CHECK_STR(b_image_path), noti->group_id,
291 noti->internal_group_id, noti->priv_id,
292 NOTIFICATION_CHECK_STR(b_text), NOTIFICATION_CHECK_STR(b_key),
293 NOTIFICATION_CHECK_STR(noti->tag),
294 NOTIFICATION_CHECK_STR(b_format_args), noti->num_format_args,
295 NOTIFICATION_CHECK_STR(noti->domain),
296 NOTIFICATION_CHECK_STR(noti->dir), (int)noti->time,
297 (int)noti->insert_time, NOTIFICATION_CHECK_STR(args),
298 NOTIFICATION_CHECK_STR(group_args),
299 NOTIFICATION_CHECK_STR(b_execute_option),
300 NOTIFICATION_CHECK_STR(b_service_responding),
301 NOTIFICATION_CHECK_STR(b_service_single_launch),
302 NOTIFICATION_CHECK_STR(b_service_multi_launch),
303 noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path),
304 noti->vibration_type,
305 NOTIFICATION_CHECK_STR(noti->vibration_path),
310 noti->flags_for_property, flag_simmode, noti->display_applist);
312 /* Free decoded data */
320 if (b_execute_option) {
321 free(b_execute_option);
323 if (b_service_responding) {
324 free(b_service_responding);
326 if (b_service_single_launch) {
327 free(b_service_single_launch);
329 if (b_service_multi_launch) {
330 free(b_service_multi_launch);
347 if (*query == NULL) {
348 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
351 return NOTIFICATION_ERROR_NONE;
355 static int _update_query_create(notification_h noti, char **query)
357 int b_encode_len = 0;
359 char *group_args = NULL;
360 char *b_image_path = NULL;
361 char *b_execute_option = NULL;
362 char *b_service_responding = NULL;
363 char *b_service_single_launch = NULL;
364 char *b_service_multi_launch = NULL;
367 char *b_format_args = NULL;
368 int flag_simmode = 0;
371 return NOTIFICATION_ERROR_INVALID_PARAMETER;
374 /* Decode bundle to update DB */
376 bundle_encode(noti->args, (bundle_raw **) & args, &b_encode_len);
378 if (noti->group_args) {
379 bundle_encode(noti->group_args, (bundle_raw **) & group_args,
383 if (noti->b_execute_option) {
384 bundle_encode(noti->b_execute_option,
385 (bundle_raw **) & b_execute_option, &b_encode_len);
387 if (noti->b_service_responding) {
388 bundle_encode(noti->b_service_responding,
389 (bundle_raw **) & b_service_responding, &b_encode_len);
391 if (noti->b_service_single_launch) {
392 bundle_encode(noti->b_service_single_launch,
393 (bundle_raw **) & b_service_single_launch, &b_encode_len);
395 if (noti->b_service_multi_launch) {
396 bundle_encode(noti->b_service_multi_launch,
397 (bundle_raw **) & b_service_multi_launch, &b_encode_len);
401 bundle_encode(noti->b_text, (bundle_raw **) & b_text, &b_encode_len);
404 bundle_encode(noti->b_key, (bundle_raw **) & b_key, &b_encode_len);
406 if (noti->b_format_args) {
407 bundle_encode(noti->b_format_args,
408 (bundle_raw **) & b_format_args, &b_encode_len);
411 if (noti->b_image_path) {
412 bundle_encode(noti->b_image_path,
413 (bundle_raw **) & b_image_path, &b_encode_len);
416 /* Check only simmode property is enable */
417 if (noti->flags_for_property & NOTIFICATION_PROP_DISPLAY_ONLY_SIMMODE) {
422 *query = sqlite3_mprintf("UPDATE noti_list SET "
425 "launch_pkgname = '%s', "
426 "image_path = '%s', "
427 "b_text = '%s', b_key = '%s', tag = '%s', "
428 "b_format_args = '%s', num_format_args = %d, "
429 "text_domain = '%s', text_dir = '%s', "
430 "time = %d, insert_time = %d, "
431 "args = '%s', group_args = '%s', "
432 "b_execute_option = '%s', "
433 "b_service_responding = '%s', "
434 "b_service_single_launch = '%s', "
435 "b_service_multi_launch = '%s', "
436 "sound_type = %d, sound_path = '%s', "
437 "vibration_type = %d, vibration_path = '%s', "
438 "led_operation = %d, led_argb = %d, "
439 "led_on_ms = %d, led_off_ms = %d, "
440 "flags_for_property = %d, flag_simmode = %d, "
441 "display_applist = %d, "
442 "progress_size = $progress_size, progress_percentage = $progress_percentage "
443 "where priv_id = %d ",
446 NOTIFICATION_CHECK_STR(noti->launch_pkgname),
447 NOTIFICATION_CHECK_STR(b_image_path),
448 NOTIFICATION_CHECK_STR(b_text), NOTIFICATION_CHECK_STR(b_key),
449 NOTIFICATION_CHECK_STR(noti->tag),
450 NOTIFICATION_CHECK_STR(b_format_args), noti->num_format_args,
451 NOTIFICATION_CHECK_STR(noti->domain),
452 NOTIFICATION_CHECK_STR(noti->dir),
453 (int)noti->time, (int)noti->insert_time,
454 NOTIFICATION_CHECK_STR(args), NOTIFICATION_CHECK_STR(group_args),
455 NOTIFICATION_CHECK_STR(b_execute_option),
456 NOTIFICATION_CHECK_STR(b_service_responding),
457 NOTIFICATION_CHECK_STR(b_service_single_launch),
458 NOTIFICATION_CHECK_STR(b_service_multi_launch),
459 noti->sound_type, NOTIFICATION_CHECK_STR(noti->sound_path),
460 noti->vibration_type,
461 NOTIFICATION_CHECK_STR(noti->vibration_path),
466 noti->flags_for_property, flag_simmode, noti->display_applist,
469 /* Free decoded data */
477 if (b_execute_option) {
478 free(b_execute_option);
480 if (b_service_responding) {
481 free(b_service_responding);
483 if (b_service_single_launch) {
484 free(b_service_single_launch);
486 if (b_service_multi_launch) {
487 free(b_service_multi_launch);
504 if (*query == NULL) {
505 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
508 return NOTIFICATION_ERROR_NONE;
511 static void _notification_noti_populate_from_stmt(sqlite3_stmt * stmt, notification_h noti) {
514 if (stmt == NULL || noti == NULL) {
518 noti->type = sqlite3_column_int(stmt, col++);
519 noti->layout = sqlite3_column_int(stmt, col++);
520 __free_and_set((void **)&(noti->caller_pkgname), notification_db_column_text(stmt, col++));
521 __free_and_set((void **)&(noti->launch_pkgname), notification_db_column_text(stmt, col++));
522 noti->b_image_path = notification_db_column_bundle(stmt, col++);
523 noti->group_id = sqlite3_column_int(stmt, col++);
524 noti->internal_group_id = 0;
525 noti->priv_id = sqlite3_column_int(stmt, col++);
526 __free_and_set((void **)&(noti->tag), notification_db_column_text(stmt, col++));
528 noti->b_text = notification_db_column_bundle(stmt, col++);
529 noti->b_key = notification_db_column_bundle(stmt, col++);
530 noti->b_format_args = notification_db_column_bundle(stmt, col++);
531 noti->num_format_args = sqlite3_column_int(stmt, col++);
533 __free_and_set((void **)&(noti->domain), notification_db_column_text(stmt, col++));
534 __free_and_set((void **)&(noti->dir), notification_db_column_text(stmt, col++));
535 noti->time = sqlite3_column_int(stmt, col++);
536 noti->insert_time = sqlite3_column_int(stmt, col++);
537 noti->args = notification_db_column_bundle(stmt, col++);
538 noti->group_args = notification_db_column_bundle(stmt, col++);
540 noti->b_execute_option = notification_db_column_bundle(stmt, col++);
541 noti->b_service_responding = notification_db_column_bundle(stmt, col++);
542 noti->b_service_single_launch =
543 notification_db_column_bundle(stmt, col++);
544 noti->b_service_multi_launch =
545 notification_db_column_bundle(stmt, col++);
547 noti->sound_type = sqlite3_column_int(stmt, col++);
548 __free_and_set((void **)&(noti->sound_path), notification_db_column_text(stmt, col++));
549 noti->vibration_type = sqlite3_column_int(stmt, col++);
550 __free_and_set((void **)&(noti->vibration_path), notification_db_column_text(stmt, col++));
551 noti->led_operation = sqlite3_column_int(stmt, col++);
552 noti->led_argb = sqlite3_column_int(stmt, col++);
553 noti->led_on_ms = sqlite3_column_int(stmt, col++);
554 noti->led_off_ms = sqlite3_column_int(stmt, col++);
556 noti->flags_for_property = sqlite3_column_int(stmt, col++);
557 noti->display_applist = sqlite3_column_int(stmt, col++);
558 noti->progress_size = sqlite3_column_double(stmt, col++);
559 noti->progress_percentage = sqlite3_column_double(stmt, col++);
561 noti->app_icon_path = NULL;
562 noti->app_name = NULL;
563 noti->temp_title = NULL;
564 noti->temp_content = NULL;
567 static notification_h _notification_noti_get_item(sqlite3_stmt * stmt)
569 notification_h noti = NULL;
571 noti = (notification_h) calloc(1, sizeof(struct _notification));
576 _notification_noti_populate_from_stmt(stmt, noti);
581 int notification_noti_set_tag(const char *tag, char *value, char *buf, int buf_len)
585 len_total += (strlen(tag) * 2) + 5 + strlen(value) + 1;
587 if (buf_len <= len_total)
588 return NOTIFICATION_ERROR_INVALID_PARAMETER;
590 snprintf(buf, buf_len, "<%s>%s</%s>", tag, value, tag);
592 return NOTIFICATION_ERROR_NONE;
595 char *notification_noti_strip_tag(const char *tagged_str)
597 if (tagged_str == NULL)
600 int len_total = strlen(tagged_str);
605 char *b_f_e = strstr(tagged_str, ">");
606 char *b_e_s = strstr(tagged_str, "</");
608 if (b_f_e == NULL || b_e_s == NULL || (b_e_s - b_f_e - 1) <= 0)
611 return strndup(b_f_e + 1, b_e_s - b_f_e - 1);
614 int notification_noti_get_tag_type(const char *tagged_str)
616 if (tagged_str == NULL)
617 return TAG_TYPE_INVALID;
619 if (strlen(tagged_str)== 0)
620 return TAG_TYPE_INVALID;
622 char *b_f_s = strstr(tagged_str, "<");
623 char *b_f_e = strstr(tagged_str, ">");
625 if (b_f_s == NULL || b_f_e == NULL || (b_f_e - b_f_s - 1) <= 0)
626 return TAG_TYPE_INVALID;
628 char *start = b_f_s + 1;
629 int len_tag = b_f_e - b_f_s - 1;
631 if (strncmp(start,TAG_TIME,len_tag) == 0) {
632 return TAG_TYPE_TIME;
635 return TAG_TYPE_INVALID;
638 static int _notification_noti_update_priv_id(sqlite3 * db, int rowid)
640 int ret = NOTIFICATION_ERROR_NONE;
644 ret = NOTIFICATION_ERROR_INVALID_PARAMETER;
648 query = sqlite3_mprintf("UPDATE noti_list SET "
649 "priv_id = %d, internal_group_id = %d WHERE rowid = %d",
650 rowid, rowid, rowid);
652 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
656 ret = notification_db_exec(db, query, NULL);
666 EXPORT_API int notification_noti_insert(notification_h noti)
670 sqlite3_stmt *stmt = NULL;
672 char buf_key[32] = { 0, };
673 const char *title_key = NULL;
676 db = notification_db_open(DBPATH);
678 return get_last_result();
681 /* Initialize private ID */
682 noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
683 noti->group_id = NOTIFICATION_GROUP_ID_NONE;
684 noti->internal_group_id = NOTIFICATION_GROUP_ID_NONE;
687 ret = _insertion_query_create(noti, &query);
688 if (ret != NOTIFICATION_ERROR_NONE) {
692 ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
693 if (ret != SQLITE_OK) {
694 NOTIFICATION_ERR("Insert Query : %s", query);
695 NOTIFICATION_ERR("Insert DB error(%d) : %s", ret,
697 ret = NOTIFICATION_ERROR_FROM_DB;
702 if (noti->b_key != NULL) {
703 snprintf(buf_key, sizeof(buf_key), "%d",
704 NOTIFICATION_TEXT_TYPE_TITLE);
706 title_key = bundle_get_val(noti->b_key, buf_key);
709 if (title_key == NULL && noti->b_text != NULL) {
710 snprintf(buf_key, sizeof(buf_key), "%d",
711 NOTIFICATION_TEXT_TYPE_TITLE);
713 title_key = bundle_get_val(noti->b_text, buf_key);
716 if (title_key == NULL) {
717 title_key = noti->caller_pkgname;
721 ret = _notification_noti_bind_query_text(stmt, "$title_key", title_key);
722 if (ret != NOTIFICATION_ERROR_NONE) {
723 NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
726 ret = _notification_noti_bind_query_double(stmt, "$progress_size",noti->progress_size);
727 if (ret != NOTIFICATION_ERROR_NONE) {
728 NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
730 sqlite3_finalize(stmt);
734 ret = _notification_noti_bind_query_double(stmt, "$progress_percentage",noti->progress_percentage);
735 if (ret != NOTIFICATION_ERROR_NONE) {
736 NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
738 sqlite3_finalize(stmt);
743 ret = sqlite3_step(stmt);
744 if (ret == SQLITE_OK || ret == SQLITE_DONE) {
745 noti->priv_id = (int)sqlite3_last_insert_rowid(db);
746 if (_notification_noti_update_priv_id(db, noti->priv_id) == 0) {
747 ret = NOTIFICATION_ERROR_NONE;
749 ret = NOTIFICATION_ERROR_FROM_DB;
752 ret = NOTIFICATION_ERROR_FROM_DB;
756 sqlite3_finalize(stmt);
761 notification_db_close(&db);
771 int notification_noti_get_by_priv_id(notification_h noti, char *pkgname, int priv_id)
776 sqlite3_stmt *stmt = NULL;
778 if (priv_id < 0 || noti == NULL) {
779 ret = NOTIFICATION_ERROR_INVALID_PARAMETER;
784 db = notification_db_open(DBPATH);
786 return get_last_result();
789 char *base_query = "select "
790 "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, "
791 "tag, b_text, b_key, b_format_args, num_format_args, "
792 "text_domain, text_dir, time, insert_time, args, group_args, "
793 "b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
794 "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
795 "flags_for_property, display_applist, progress_size, progress_percentage "
798 if (pkgname != NULL) {
799 query = sqlite3_mprintf("%s where caller_pkgname = '%s' and priv_id = %d",
800 base_query ,pkgname, priv_id);
802 query = sqlite3_mprintf("%s where priv_id = %d", base_query, priv_id);
805 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
809 ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
810 if (ret != SQLITE_OK) {
811 NOTIFICATION_ERR("select Query : %s", query);
812 NOTIFICATION_ERR("select DB error(%d) : %s", ret,
814 ret = NOTIFICATION_ERROR_FROM_DB;
818 ret = sqlite3_step(stmt);
819 if (ret == SQLITE_ROW) {
820 _notification_noti_populate_from_stmt(stmt, noti);
821 ret = NOTIFICATION_ERROR_NONE;
823 ret = NOTIFICATION_ERROR_FROM_DB;
831 sqlite3_finalize(stmt);
836 notification_db_close(&db);
842 EXPORT_API int notification_noti_get_by_tag(notification_h noti, char *pkgname, char* tag)
847 sqlite3_stmt *stmt = NULL;
849 if (tag == NULL || noti == NULL) {
850 ret = NOTIFICATION_ERROR_INVALID_PARAMETER;
855 db = notification_db_open(DBPATH);
857 return get_last_result();
860 char *base_query = "select "
861 "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, "
862 "tag, b_text, b_key, b_format_args, num_format_args, "
863 "text_domain, text_dir, time, insert_time, args, group_args, "
864 "b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
865 "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
866 "flags_for_property, display_applist, progress_size, progress_percentage "
869 if (pkgname != NULL) {
870 query = sqlite3_mprintf("%s where caller_pkgname = '%s' and tag = '%s'",
871 base_query ,pkgname, tag);
873 query = sqlite3_mprintf("%s where tag = '%s'", base_query, tag);
876 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
880 ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
881 if (ret != SQLITE_OK) {
882 NOTIFICATION_ERR("select Query : %s", query);
883 NOTIFICATION_ERR("select DB error(%d) : %s", ret,
885 ret = NOTIFICATION_ERROR_FROM_DB;
889 ret = sqlite3_step(stmt);
890 if (ret == SQLITE_ROW) {
891 _notification_noti_populate_from_stmt(stmt, noti);
892 ret = NOTIFICATION_ERROR_NONE;
894 ret = NOTIFICATION_ERROR_FROM_DB;
902 sqlite3_finalize(stmt);
907 notification_db_close(&db);
913 EXPORT_API int notification_noti_update(notification_h noti)
917 sqlite3_stmt *stmt = NULL;
921 db = notification_db_open(DBPATH);
923 return get_last_result();
926 /* Check private ID is exist */
927 ret = _notification_noti_check_priv_id(noti, db);
928 if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
929 ret = NOTIFICATION_ERROR_NOT_EXIST_ID;
933 /* make update query */
934 ret = _update_query_create(noti, &query);
935 if (ret != NOTIFICATION_ERROR_NONE) {
939 ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
940 if (ret != SQLITE_OK) {
941 NOTIFICATION_ERR("Insert Query : %s", query);
942 NOTIFICATION_ERR("Insert DB error(%d) : %s", ret,
944 ret = NOTIFICATION_ERROR_FROM_DB;
948 ret = _notification_noti_bind_query_double(stmt, "$progress_size",noti->progress_size);
949 if (ret != NOTIFICATION_ERROR_NONE) {
950 NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
953 ret = _notification_noti_bind_query_double(stmt, "$progress_percentage",noti->progress_percentage);
954 if (ret != NOTIFICATION_ERROR_NONE) {
955 NOTIFICATION_ERR("Bind error : %s", sqlite3_errmsg(db));
959 ret = sqlite3_step(stmt);
960 if (ret == SQLITE_OK || ret == SQLITE_DONE) {
961 ret = NOTIFICATION_ERROR_NONE;
963 ret = NOTIFICATION_ERROR_FROM_DB;
967 sqlite3_finalize(stmt);
972 notification_db_close(&db);
982 EXPORT_API int notification_noti_delete_all(notification_type_e type, const char *pkgname, int *num_deleted, int **list_deleted_rowid)
984 int ret = NOTIFICATION_ERROR_NONE;
985 int ret_tmp = NOTIFICATION_ERROR_NONE;
986 int i = 0, data_cnt = 0;
988 sqlite3_stmt *stmt = NULL;
989 char buf[128] = { 0, };
990 char query[NOTIFICATION_QUERY_MAX] = { 0, };
991 char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
992 char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
995 db = notification_db_open(DBPATH);
997 return get_last_result();
1000 if (pkgname == NULL) {
1001 if (type != NOTIFICATION_TYPE_NONE) {
1002 snprintf(query_where, sizeof(query_where),
1003 "where type = %d ", type);
1006 if (type == NOTIFICATION_TYPE_NONE) {
1007 snprintf(query_where, sizeof(query_where),
1008 "where caller_pkgname = '%s' ", pkgname);
1010 snprintf(query_where, sizeof(query_where),
1011 "where caller_pkgname = '%s' and type = %d ",
1016 if (num_deleted != NULL) {
1019 if (list_deleted_rowid != NULL) {
1020 *list_deleted_rowid = NULL;
1021 snprintf(query, sizeof(query),
1022 "select priv_id from noti_list %s ", query_where);
1024 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
1025 if (ret != SQLITE_OK) {
1026 NOTIFICATION_ERR("Select Query : %s", query);
1027 NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
1028 sqlite3_errmsg(db));
1030 ret = NOTIFICATION_ERROR_FROM_DB;
1034 while(sqlite3_step(stmt) == SQLITE_ROW) {
1035 if (data_cnt % 8 == 0) {
1038 tmp = (int *)realloc(*list_deleted_rowid, sizeof(int) * (data_cnt + 8 + 1));
1040 *list_deleted_rowid = tmp;
1042 NOTIFICATION_ERR("Heap: %s\n", strerror(errno));
1045 * How can I handle this?
1047 free(*list_deleted_rowid);
1048 *list_deleted_rowid = NULL;
1049 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
1053 *((*list_deleted_rowid) + data_cnt) = sqlite3_column_int(stmt, 0);
1058 sqlite3_finalize(stmt);
1063 query_where[0] = '\0';
1064 snprintf(query_base, sizeof(query_base) - 1, "delete from noti_list");
1065 for (i = 0; i < data_cnt ; i++) {
1066 if (i % NOTI_BURST_DELETE_UNIT == 0 && i != 0) {
1067 snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where);
1068 ret_tmp = notification_db_exec(db, query, NULL);
1069 query_where[0] = '\0';
1070 if (ret == NOTIFICATION_ERROR_NONE) {
1074 snprintf(buf, sizeof(buf) - 1, "%s%d", (i % NOTI_BURST_DELETE_UNIT == 0) ? "" : ",", *((*list_deleted_rowid) + i));
1075 strncat(query_where, buf,sizeof(query_where) - strlen(query_where) - 1);
1077 if ((i <= NOTI_BURST_DELETE_UNIT) || ((i % NOTI_BURST_DELETE_UNIT) > 0) ) {
1078 snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where);
1079 ret_tmp = notification_db_exec(db, query, NULL);
1080 if (ret == NOTIFICATION_ERROR_NONE) {
1085 free(*list_deleted_rowid);
1086 *list_deleted_rowid = NULL;
1089 if (num_deleted != NULL) {
1090 *num_deleted = data_cnt;
1093 /* Make main query */
1094 snprintf(query_base, sizeof(query_base), "delete from noti_list ");
1095 snprintf(query, sizeof(query), "%s %s", query_base, query_where);
1097 ret = notification_db_exec(db, query, NULL);
1099 if (num_deleted != NULL) {
1100 *num_deleted = sqlite3_changes(db);
1106 sqlite3_finalize(stmt);
1110 notification_db_close(&db);
1116 int notification_noti_delete_group_by_group_id(const char *pkgname,
1117 int group_id, int *num_deleted, int **list_deleted_rowid)
1119 int ret = NOTIFICATION_ERROR_NONE;
1120 int ret_tmp = NOTIFICATION_ERROR_NONE;
1122 int i = 0, data_cnt = 0;
1123 sqlite3_stmt *stmt = NULL;
1124 char buf[128] = { 0, };
1125 char query[NOTIFICATION_QUERY_MAX] = { 0, };
1126 char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
1127 char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
1129 /* Check pkgname is valid */
1130 if (pkgname == NULL) {
1131 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1134 snprintf(query_where, sizeof(query_where),
1135 "where caller_pkgname = '%s' and group_id = %d", pkgname, group_id);
1138 db = notification_db_open(DBPATH);
1140 return get_last_result();
1143 if (num_deleted != NULL) {
1146 if (list_deleted_rowid != NULL) {
1147 *list_deleted_rowid = NULL;
1148 snprintf(query, sizeof(query),
1149 "select priv_id from noti_list %s ", query_where);
1151 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
1152 if (ret != SQLITE_OK) {
1153 NOTIFICATION_ERR("Select Query : %s", query);
1154 NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
1155 sqlite3_errmsg(db));
1157 ret = NOTIFICATION_ERROR_FROM_DB;
1161 while(sqlite3_step(stmt) == SQLITE_ROW) {
1162 if (data_cnt % 8 == 0) {
1164 tmp = (int *)realloc(*list_deleted_rowid, sizeof(int) * (data_cnt + 8 + 1));
1166 *list_deleted_rowid = tmp;
1168 free(*list_deleted_rowid);
1169 *list_deleted_rowid = NULL;
1170 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
1174 *((*list_deleted_rowid) + data_cnt) = sqlite3_column_int(stmt, 0);
1179 sqlite3_finalize(stmt);
1184 query_where[0] = '\0';
1185 snprintf(query_base, sizeof(query_base) - 1, "delete from noti_list");
1186 for (i = 0; i < data_cnt ; i++) {
1187 if (i % NOTI_BURST_DELETE_UNIT == 0 && i != 0) {
1188 snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where);
1189 ret_tmp = notification_db_exec(db, query, NULL);
1190 query_where[0] = '\0';
1191 if (ret == NOTIFICATION_ERROR_NONE) {
1195 snprintf(buf, sizeof(buf) - 1, "%s%d", (i % NOTI_BURST_DELETE_UNIT == 0) ? "" : ",", *((*list_deleted_rowid) + i));
1196 strncat(query_where, buf,sizeof(query_where) - strlen(query_where) - 1);
1198 if ((i <= NOTI_BURST_DELETE_UNIT) || ((i % NOTI_BURST_DELETE_UNIT) > 0) ) {
1199 snprintf(query, sizeof(query) - 1, "%s where priv_id in (%s)", query_base, query_where);
1200 ret_tmp = notification_db_exec(db, query, NULL);
1201 if (ret == NOTIFICATION_ERROR_NONE) {
1206 free(*list_deleted_rowid);
1207 *list_deleted_rowid = NULL;
1210 if (num_deleted != NULL) {
1211 *num_deleted = data_cnt;
1215 snprintf(query, sizeof(query), "delete from noti_list %s", query_where);
1218 ret = notification_db_exec(db, query, NULL);
1223 sqlite3_finalize(stmt);
1227 notification_db_close(&db);
1233 int notification_noti_delete_group_by_priv_id(const char *pkgname, int priv_id)
1236 char query[NOTIFICATION_QUERY_MAX] = { 0, };
1237 int internal_group_id = 0;
1240 /* Check pkgname is valid */
1241 if (pkgname == NULL) {
1242 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1246 db = notification_db_open(DBPATH);
1248 return get_last_result();
1251 /* Get internal group id using priv id */
1253 _notification_noti_get_internal_group_id_by_priv_id(pkgname,
1257 snprintf(query, sizeof(query), "delete from noti_list "
1258 "where caller_pkgname = '%s' and internal_group_id = %d",
1259 pkgname, internal_group_id);
1262 ret = notification_db_exec(db, query, NULL);
1265 notification_db_close(&db);
1270 EXPORT_API int notification_noti_delete_by_priv_id(const char *pkgname, int priv_id)
1273 char query[NOTIFICATION_QUERY_MAX] = { 0, };
1276 /* Check pkgname is valid */
1277 if (pkgname == NULL) {
1278 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1282 db = notification_db_open(DBPATH);
1284 return get_last_result();
1288 snprintf(query, sizeof(query), "delete from noti_list "
1289 "where caller_pkgname = '%s' and priv_id = %d", pkgname,
1293 ret = notification_db_exec(db, query, NULL);
1297 notification_db_close(&db);
1303 EXPORT_API int notification_noti_delete_by_priv_id_get_changes(const char *pkgname, int priv_id, int *num_changes)
1306 char query[NOTIFICATION_QUERY_MAX] = { 0, };
1309 /* Check pkgname is valid */
1310 if (pkgname == NULL) {
1311 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1315 db = notification_db_open(DBPATH);
1317 return get_last_result();
1321 snprintf(query, sizeof(query), "delete from noti_list "
1322 "where caller_pkgname = '%s' and priv_id = %d", pkgname,
1326 ret = notification_db_exec(db, query, num_changes);
1328 if (num_changes != NULL) {
1329 NOTIFICATION_DBG("deleted num:%d", *num_changes);
1334 notification_db_close(&db);
1340 int notification_noti_get_count(notification_type_e type,
1341 const char *pkgname,
1342 int group_id, int priv_id,
1346 sqlite3_stmt *stmt = NULL;
1347 char query[NOTIFICATION_QUERY_MAX] = { 0, };
1348 char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
1349 char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
1350 char query_where_more[NOTIFICATION_QUERY_MAX] = { 0, };
1352 int ret = 0, get_count = 0, internal_group_id = 0;
1353 int status = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
1355 int flag_where_more = 0;
1359 db = notification_db_open(DBPATH);
1361 return get_last_result();
1364 /* Check current sim status */
1365 ret_vconf = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status);
1368 snprintf(query_base, sizeof(query_base),
1369 "select count(*) from noti_list ");
1371 if (pkgname != NULL) {
1372 if (group_id == NOTIFICATION_GROUP_ID_NONE) {
1373 if (priv_id == NOTIFICATION_PRIV_ID_NONE) {
1374 snprintf(query_where, sizeof(query_where),
1375 "where caller_pkgname = '%s' ",
1380 _notification_noti_get_internal_group_id_by_priv_id
1381 (pkgname, priv_id, db);
1382 snprintf(query_where, sizeof(query_where),
1383 "where caller_pkgname = '%s' and internal_group_id = %d ",
1384 pkgname, internal_group_id);
1388 if (priv_id == NOTIFICATION_PRIV_ID_NONE) {
1389 snprintf(query_where, sizeof(query_where),
1390 "where caller_pkgname = '%s' and group_id = %d ",
1395 _notification_noti_get_internal_group_id_by_priv_id
1396 (pkgname, priv_id, db);
1397 snprintf(query_where, sizeof(query_where),
1398 "where caller_pkgname = '%s' and internal_group_id = %d ",
1399 pkgname, internal_group_id);
1406 if (ret_vconf == 0 && status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
1407 if (type != NOTIFICATION_TYPE_NONE) {
1408 snprintf(query_where_more, sizeof(query_where_more),
1409 "type = %d ", type);
1410 flag_where_more = 1;
1413 if (type != NOTIFICATION_TYPE_NONE) {
1414 snprintf(query_where_more, sizeof(query_where_more),
1415 "type = %d and flag_simmode = 0 ", type);
1416 flag_where_more = 1;
1418 snprintf(query_where_more, sizeof(query_where_more),
1419 "flag_simmode = 0 ");
1420 flag_where_more = 1;
1424 if (flag_where == 1) {
1425 if (flag_where_more == 1) {
1426 snprintf(query, sizeof(query), "%s %s and %s",
1427 query_base, query_where, query_where_more);
1429 snprintf(query, sizeof(query), "%s %s", query_base,
1434 if (flag_where_more == 1) {
1435 snprintf(query, sizeof(query), "%s where %s",
1436 query_base, query_where_more);
1438 snprintf(query, sizeof(query), "%s", query_base);
1442 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
1443 if (ret != SQLITE_OK) {
1444 NOTIFICATION_ERR("Select Query : %s", query);
1445 NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
1446 sqlite3_errmsg(db));
1448 ret = NOTIFICATION_ERROR_FROM_DB;
1452 ret = sqlite3_step(stmt);
1453 if (ret == SQLITE_ROW) {
1454 get_count = sqlite3_column_int(stmt, 0);
1457 ret = NOTIFICATION_ERROR_NONE;
1461 sqlite3_finalize(stmt);
1466 notification_db_close(&db);
1474 int notification_noti_get_grouping_list(notification_type_e type,
1476 notification_list_h *
1480 sqlite3_stmt *stmt = NULL;
1481 char query[NOTIFICATION_QUERY_MAX] = { 0, };
1482 char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
1483 char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
1486 notification_list_h get_list = NULL;
1487 notification_h noti = NULL;
1488 int internal_count = 0;
1492 db = notification_db_open(DBPATH);
1494 return get_last_result();
1497 /* Check current sim status */
1498 ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status);
1501 snprintf(query_base, sizeof(query_base), "select "
1502 "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, "
1503 "tag, b_text, b_key, b_format_args, num_format_args, "
1504 "text_domain, text_dir, time, insert_time, args, group_args, "
1505 "b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
1506 "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
1507 "flags_for_property, display_applist, progress_size, progress_percentage "
1510 if (status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
1511 if (type != NOTIFICATION_TYPE_NONE) {
1512 snprintf(query_where, sizeof(query_where),
1513 "where type = %d ", type);
1516 if (type != NOTIFICATION_TYPE_NONE) {
1517 snprintf(query_where, sizeof(query_where),
1518 "where type = %d and flag_simmode = 0 ", type);
1520 snprintf(query_where, sizeof(query_where),
1521 "where flag_simmode = 0 ");
1525 snprintf(query, sizeof(query),
1527 "group by internal_group_id "
1528 "order by rowid desc, time desc", query_base, query_where);
1530 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
1531 if (ret != SQLITE_OK) {
1532 NOTIFICATION_ERR("Select Query : %s", query);
1533 NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
1534 sqlite3_errmsg(db));
1536 ret = NOTIFICATION_ERROR_FROM_DB;
1540 while (sqlite3_step(stmt) == SQLITE_ROW) {
1541 /* Make notification list */
1542 noti = _notification_noti_get_item(stmt);
1546 get_list = notification_list_append(get_list, noti);
1548 if (count != -1 && internal_count >= count) {
1550 ("internal count %d >= count %d",
1551 internal_count, count);
1557 ret = NOTIFICATION_ERROR_NONE;
1561 sqlite3_finalize(stmt);
1566 notification_db_close(&db);
1569 if (get_list != NULL) {
1570 *list = notification_list_get_head(get_list);
1576 int notification_noti_get_detail_list(const char *pkgname,
1578 int priv_id, int count,
1579 notification_list_h *list)
1582 sqlite3_stmt *stmt = NULL;
1583 char query_base[NOTIFICATION_QUERY_MAX] = { 0, };
1584 char query_where[NOTIFICATION_QUERY_MAX] = { 0, };
1586 char query[NOTIFICATION_QUERY_MAX] = { 0, };
1588 notification_list_h get_list = NULL;
1589 notification_h noti = NULL;
1590 int internal_count = 0;
1591 int internal_group_id = 0;
1592 int status = 0; /* If the vconf_get_int failed, the status will be the garbage value */
1595 db = notification_db_open(DBPATH);
1597 return get_last_result();
1600 /* Check current sim status */
1601 ret = vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &status);
1604 snprintf(query_base, sizeof(query_base), "select "
1605 "type, layout, caller_pkgname, launch_pkgname, image_path, group_id, priv_id, "
1606 "tag, b_text, b_key, b_format_args, num_format_args, "
1607 "text_domain, text_dir, time, insert_time, args, group_args, "
1608 "b_execute_option, b_service_responding, b_service_single_launch, b_service_multi_launch, "
1609 "sound_type, sound_path, vibration_type, vibration_path, led_operation, led_argb, led_on_ms, led_off_ms, "
1610 "flags_for_property, display_applist, progress_size, progress_percentage "
1613 if (priv_id == NOTIFICATION_PRIV_ID_NONE && group_id == NOTIFICATION_GROUP_ID_NONE) {
1614 if (status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
1615 snprintf(query_where, sizeof(query_where),
1616 "where caller_pkgname = '%s' ", pkgname);
1618 snprintf(query_where, sizeof(query_where),
1619 "where caller_pkgname = '%s' and flag_simmode = 0 ", pkgname);
1623 _notification_noti_get_internal_group_id_by_priv_id(pkgname,
1626 if (status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
1627 snprintf(query_where, sizeof(query_where),
1628 "where caller_pkgname = '%s' and internal_group_id = %d ",
1629 pkgname, internal_group_id);
1631 snprintf(query_where, sizeof(query_where),
1632 "where caller_pkgname = '%s' and internal_group_id = %d and flag_simmode = 0 ",
1633 pkgname, internal_group_id);
1637 snprintf(query, sizeof(query),
1639 "order by rowid desc, time desc", query_base, query_where);
1641 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
1642 if (ret != SQLITE_OK) {
1643 NOTIFICATION_ERR("Select Query : %s", query);
1644 NOTIFICATION_ERR("Select DB error(%d) : %s", ret,
1645 sqlite3_errmsg(db));
1647 ret = NOTIFICATION_ERROR_FROM_DB;
1651 while (sqlite3_step(stmt) == SQLITE_ROW) {
1652 /* Make notification list */
1653 noti = _notification_noti_get_item(stmt);
1657 get_list = notification_list_append(get_list, noti);
1659 if (count != -1 && internal_count >= count) {
1661 ("internal count %d >= count %d",
1662 internal_count, count);
1668 ret = NOTIFICATION_ERROR_NONE;
1672 sqlite3_finalize(stmt);
1677 notification_db_close(&db);
1680 if (get_list != NULL) {
1681 *list = notification_list_get_head(get_list);
1687 EXPORT_API int notification_noti_check_tag(notification_h noti)
1690 int ret = NOTIFICATION_ERROR_NONE;
1693 sqlite3_stmt *stmt = NULL;
1695 if (noti->tag == NULL) {
1696 return NOTIFICATION_ERROR_NOT_EXIST_ID;
1700 db = notification_db_open(DBPATH);
1702 return get_last_result();
1705 query = sqlite3_mprintf("select priv_id from noti_list where caller_pkgname = '%s' and tag = '%s'",
1706 noti->caller_pkgname, noti->tag);
1707 if (query == NULL) {
1708 ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
1712 ret = sqlite3_prepare(db, query, strlen(query), &stmt, NULL);
1713 if (ret != SQLITE_OK) {
1714 NOTIFICATION_ERR("Get priv id DB err(%d) : %s", ret,
1715 sqlite3_errmsg(db));
1716 ret = NOTIFICATION_ERROR_FROM_DB;
1720 ret = sqlite3_step(stmt);
1721 if (ret == SQLITE_ROW) {
1722 result = sqlite3_column_int(stmt, 0);
1727 sqlite3_finalize(stmt);
1729 /* If result > 0, there is priv_id in DB */
1731 noti->priv_id = result;
1732 ret = NOTIFICATION_ERROR_ALREADY_EXIST_ID;
1734 ret = NOTIFICATION_ERROR_NOT_EXIST_ID;
1739 sqlite3_free(query);
1746 popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
1748 Eina_List *list = NULL;
1752 evas_object_del(toast_popup);
1754 evas_object_del((Evas_Object *)data);
1756 count = eina_list_count(toast_list);
1759 msg = (char *)eina_list_data_get(toast_list);
1762 eina_list_free(toast_list);
1764 } else if (count > 1) {
1765 msg = (char *)eina_list_data_get(toast_list);
1766 toast_list = eina_list_remove(toast_list, msg);
1768 _post_toast_message((char *)eina_list_data_get(toast_list));
1772 int _post_toast_message(char *message)
1775 Evas_Object *toast_window;
1778 double scale = elm_config_scale_get();
1781 toast_window = elm_win_add(NULL, "toast", ELM_WIN_BASIC);
1783 elm_win_alpha_set(toast_window, EINA_TRUE);
1784 elm_win_title_set(toast_window, "toast");
1786 elm_win_indicator_mode_set(toast_window, ELM_WIN_INDICATOR_SHOW);
1787 elm_win_indicator_type_set(toast_window,ELM_WIN_INDICATOR_TYPE_1);
1789 //elm_win_autodel_set(toast_win, EINA_TRUE);
1790 if (elm_win_wm_rotation_supported_get(toast_window)) {
1791 int rots[4] = { 0, 90, 180, 270 };
1792 elm_win_wm_rotation_available_rotations_set(toast_window, (const int*)(&rots), 4);
1795 e = evas_object_evas_get(toast_window);
1796 ee = ecore_evas_ecore_evas_get(e);
1797 ecore_evas_name_class_set(ee, "TOAST_POPUP", "SYSTEM_POPUP");
1799 evas_object_resize(toast_window, (480 * scale), (650 * scale));
1800 ecore_x_window_shape_input_rectangle_set(elm_win_xwindow_get(toast_window), 0, 0, (480 * scale), (650 * scale));
1802 toast_popup = elm_popup_add(toast_window);
1804 elm_object_style_set(toast_popup, "toast");
1805 evas_object_size_hint_weight_set(toast_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1807 elm_object_part_text_set(toast_popup,"elm.text", message);
1809 if (eina_list_count(toast_list) != 1) {
1810 elm_popup_timeout_set(toast_popup, 1.0);
1813 elm_popup_timeout_set(toast_popup, 3.0);
1815 evas_object_smart_callback_add(toast_popup, "timeout", popup_timeout_cb, (void *)toast_window);
1817 elm_win_prop_focus_skip_set(toast_window, EINA_TRUE);
1819 evas_object_show(toast_window);
1820 evas_object_show(toast_popup);
1825 EXPORT_API int notification_noti_post_toast_message(const char *message)
1831 msg = (char *)calloc(strlen(message) + 1, sizeof(char));
1832 strcpy(msg, message);
1835 if (eina_list_count(toast_list) == 10) {
1836 toast_list = eina_list_last(toast_list);
1837 eina_list_data_set(toast_list, msg);
1838 toast_list = eina_list_nth_list(toast_list, 0);
1843 count = eina_list_count(toast_list);
1845 toast_list = eina_list_append(toast_list, msg);
1846 let = _post_toast_message(msg);
1848 else if (count == 1) {
1849 if (strcmp(msg, (char *)eina_list_nth(toast_list, count - 1)) == 0) {
1850 elm_popup_timeout_set(toast_popup, 3.0);
1853 toast_list = eina_list_append(toast_list, msg);
1854 elm_popup_timeout_set(toast_popup, 1.0);
1857 else if (count >= 2) {
1858 if (strcmp(msg, (char *)eina_list_nth(toast_list, count - 1)) == 0) {
1862 toast_list = eina_list_append(toast_list, msg);