2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
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 General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * 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.
26 static struct event_methods event_methods;
27 static const char *e_requestor;
28 static const char *e_system;
30 void event_main_loop_run(void)
32 if (! event_methods.main_loop_run) {
33 dbg(0,"no event system set\n");
36 event_methods.main_loop_run();
39 void event_main_loop_quit(void)
41 if (event_methods.main_loop_quit)
42 event_methods.main_loop_quit();
47 event_add_watch(void *fd, enum event_watch_cond cond, struct callback *cb)
49 return event_methods.add_watch(fd, cond, cb);
53 event_remove_watch(struct event_watch *ev)
55 event_methods.remove_watch(ev);
58 struct event_timeout *
59 event_add_timeout(int timeout, int multi, struct callback *cb)
61 return event_methods.add_timeout(timeout, multi, cb);
65 event_remove_timeout(struct event_timeout *ev)
67 event_methods.remove_timeout(ev);
71 event_add_idle(int priority, struct callback *cb)
73 return event_methods.add_idle(priority,cb);
77 event_remove_idle(struct event_idle *ev)
79 event_methods.remove_idle(ev);
83 event_call_callback(struct callback_list *cb)
85 event_methods.call_callback(cb);
89 event_request_system(const char *system, const char *requestor)
91 void (*event_type_new)(struct event_methods *meth);
93 if (strcmp(e_system, system)) {
94 dbg(0,"system '%s' already requested by '%s', can't set to '%s' as requested from '%s'\n", e_system, e_requestor, system, requestor);
99 event_type_new=plugin_get_event_type(system);
100 if (! event_type_new) {
101 dbg(0,"unsupported event system '%s' requested from '%s'\n", system, requestor);
104 event_type_new(&event_methods);
106 e_requestor=requestor;