Merge branch 'upstream' into maemo
[navit-package] / navit / event.h
1 /**
2  * Navit, a modular navigation system.
3  * Copyright (C) 2005-2008 Navit Team
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 struct event_idle;
25 struct event_timeout;
26 struct event_watch;
27 struct callback;
28 struct callback_list;
29 struct file;
30
31 enum event_watch_cond {
32         event_watch_cond_read=1,
33         event_watch_cond_write,
34         event_watch_cond_except,
35 };
36
37 struct event_methods {
38         void (*main_loop_run)(void);
39         void (*main_loop_quit)(void);
40         struct event_watch *(*add_watch)(void *fd, enum event_watch_cond cond, struct callback *cb);
41         void (*remove_watch)(struct event_watch *ev);
42         struct event_timeout *(*add_timeout)(int timeout, int multi, struct callback *cb);
43         void (*remove_timeout)(struct event_timeout *ev);
44         struct event_idle *(*add_idle)(int priority, struct callback *cb);
45         void (*remove_idle)(struct event_idle *ev);
46         void (*call_callback)(struct callback_list *cb);
47 };
48
49
50 /* prototypes */
51 void event_main_loop_run(void);
52 void event_main_loop_quit(void);
53 struct event_watch *event_add_watch(void *fd, enum event_watch_cond cond, struct callback *cb);
54 void event_remove_watch(struct event_watch *ev);
55 struct event_timeout *event_add_timeout(int timeout, int multi, struct callback *cb);
56 void event_remove_timeout(struct event_timeout *ev);
57 struct event_idle *event_add_idle(int priority, struct callback *cb);
58 void event_remove_idle(struct event_idle *ev);
59 int event_request_system(const char *system, const char *requestor);
60 void event_call_callback(struct callback_list *cb);
61 /* end of prototypes */
62 #ifdef __cplusplus
63 }
64 #endif