|
1 /* -*- mode: C; c-file-style: "gnu" -*- */ |
|
2 /* expirelist.h List of stuff that expires |
|
3 * |
|
4 * Copyright (C) 2003 Red Hat, Inc. |
|
5 * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
6 * Licensed under the Academic Free License version 2.1 |
|
7 * |
|
8 * This program is free software; you can redistribute it and/or modify |
|
9 * it under the terms of the GNU General Public License as published by |
|
10 * the Free Software Foundation; either version 2 of the License, or |
|
11 * (at your option) any later version. |
|
12 * |
|
13 * This program is distributed in the hope that it will be useful, |
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 * GNU General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with this program; if not, write to the Free Software |
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 * |
|
22 */ |
|
23 |
|
24 #ifndef BUS_EXPIRE_LIST_H |
|
25 #define BUS_EXPIRE_LIST_H |
|
26 |
|
27 #include <dbus/dbus.h> |
|
28 #ifndef __SYMBIAN32__ |
|
29 #include <dbus/dbus-list.h> |
|
30 #include <dbus/dbus-mainloop.h> |
|
31 #else |
|
32 #include "dbus-list.h" |
|
33 #include "dbus-mainloop.h" |
|
34 #endif //__SYMBIAN32 |
|
35 |
|
36 typedef struct BusExpireList BusExpireList; |
|
37 typedef struct BusExpireItem BusExpireItem; |
|
38 |
|
39 typedef dbus_bool_t (* BusExpireFunc) (BusExpireList *list, |
|
40 DBusList *link, |
|
41 void *data); |
|
42 |
|
43 struct BusExpireList |
|
44 { |
|
45 DBusList *items; /**< List of BusExpireItem */ |
|
46 DBusTimeout *timeout; |
|
47 DBusLoop *loop; |
|
48 BusExpireFunc expire_func; |
|
49 void *data; |
|
50 int expire_after; /**< Expire after milliseconds (thousandths) */ |
|
51 }; |
|
52 |
|
53 /* embed this in a child expire item struct */ |
|
54 struct BusExpireItem |
|
55 { |
|
56 long added_tv_sec; /**< Time we were added (seconds component) */ |
|
57 long added_tv_usec; /**< Time we were added (microsec component) */ |
|
58 }; |
|
59 |
|
60 BusExpireList* bus_expire_list_new (DBusLoop *loop, |
|
61 int expire_after, |
|
62 BusExpireFunc expire_func, |
|
63 void *data); |
|
64 void bus_expire_list_free (BusExpireList *list); |
|
65 |
|
66 #define ELAPSED_MILLISECONDS_SINCE(orig_tv_sec, orig_tv_usec, \ |
|
67 now_tv_sec, now_tv_usec) \ |
|
68 (((double) (now_tv_sec) - (double) (orig_tv_sec)) * 1000.0 + \ |
|
69 ((double) (now_tv_usec) - (double) (orig_tv_usec)) / 1000.0) |
|
70 |
|
71 void bus_expire_timeout_set_interval (DBusTimeout *timeout, |
|
72 int next_interval); |
|
73 |
|
74 #endif /* BUS_EXPIRE_LIST_H */ |