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.
24 #include <notification.h>
25 #include <notification_list.h>
26 #include <notification_debug.h>
27 #include <notification_internal.h>
29 struct _notification_list {
30 notification_list_h prev;
31 notification_list_h next;
36 notification_list_h _notification_list_create(void)
38 notification_list_h list = NULL;
40 list = (notification_list_h) malloc(sizeof(struct _notification_list));
42 NOTIFICATION_ERR("NO MEMORY");
54 EXPORT_API notification_list_h notification_list_get_head(notification_list_h list)
56 notification_list_h cur_list = NULL;
59 NOTIFICATION_ERR("INVALID DATA : list == NULL");
65 while (cur_list->prev != NULL) {
66 cur_list = cur_list->prev;
72 EXPORT_API notification_list_h notification_list_get_tail(notification_list_h list)
74 notification_list_h cur_list = NULL;
77 NOTIFICATION_ERR("INVALID DATA : list == NULL");
83 while (cur_list->next != NULL) {
84 cur_list = cur_list->next;
90 EXPORT_API notification_list_h notification_list_get_prev(notification_list_h list)
92 notification_list_h cur_list = NULL;
95 NOTIFICATION_ERR("INVALID DATA : list == NULL");
101 return cur_list->prev;
104 EXPORT_API notification_list_h notification_list_get_next(notification_list_h list)
106 notification_list_h cur_list = NULL;
109 NOTIFICATION_ERR("INVALID DATA : list == NULL");
115 return cur_list->next;
118 EXPORT_API notification_h notification_list_get_data(notification_list_h list)
120 notification_list_h cur_list = NULL;
123 NOTIFICATION_ERR("INVALID DATA : list == NULL");
129 return cur_list->noti;
132 EXPORT_API notification_list_h notification_list_append(notification_list_h list,
135 notification_list_h new_list = NULL;
136 notification_list_h cur_list = NULL;
139 NOTIFICATION_ERR("INVALID DATA : data == NULL");
144 cur_list = notification_list_get_tail(list);
146 new_list = _notification_list_create();
147 if (new_list == NULL) {
148 NOTIFICATION_ERR("NO MEMORY");
152 cur_list->next = new_list;
153 new_list->prev = cur_list;
155 new_list->noti = noti;
157 cur_list = _notification_list_create();
158 if (cur_list == NULL) {
159 NOTIFICATION_ERR("NO MEMORY");
164 new_list->noti = noti;
170 EXPORT_API notification_list_h notification_list_remove(notification_list_h list,
173 notification_list_h cur_list = NULL;
174 notification_list_h prev_list = NULL;
175 notification_list_h next_list = NULL;
177 cur_list = notification_list_get_head(list);
178 while (cur_list != NULL) {
179 if (cur_list->noti == noti) {
181 prev_list = cur_list->prev;
182 next_list = cur_list->next;
184 if (next_list != NULL) {
185 if (prev_list != NULL) {
186 prev_list->next = next_list;
187 next_list->prev = prev_list;
189 next_list->prev = NULL;
192 if (prev_list != NULL) {
193 prev_list->next = NULL;
201 cur_list = cur_list->next;
204 if (prev_list != NULL) {
205 return notification_list_get_head(prev_list);
206 } else if (next_list != NULL) {