3 * oFono - Open Source Telephony
5 * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 struct ofono_watchlist *__ofono_watchlist_new(ofono_destroy_func destroy)
31 struct ofono_watchlist *watchlist;
33 watchlist = g_new0(struct ofono_watchlist, 1);
34 watchlist->destroy = destroy;
39 unsigned int __ofono_watchlist_add_item(struct ofono_watchlist *watchlist,
40 struct ofono_watchlist_item *item)
42 item->id = ++watchlist->next_id;
44 watchlist->items = g_slist_prepend(watchlist->items, item);
49 gboolean __ofono_watchlist_remove_item(struct ofono_watchlist *watchlist,
52 struct ofono_watchlist_item *item;
71 watchlist->items = c->next;
74 item->destroy(item->notify_data);
76 if (watchlist->destroy)
77 watchlist->destroy(item);
86 void __ofono_watchlist_free(struct ofono_watchlist *watchlist)
88 struct ofono_watchlist_item *item;
91 for (l = watchlist->items; l; l = l->next) {
95 item->destroy(item->notify_data);
97 if (watchlist->destroy)
98 watchlist->destroy(item);
101 g_slist_free(watchlist->items);
102 watchlist->items = NULL;