/[zanavi_public1]/navit/navit/event.c
ZANavi

Contents of /navit/navit/event.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 40 - (show annotations) (download)
Wed Mar 4 14:00:54 2015 UTC (9 years ago) by zoff99
File MIME type: text/plain
File size: 2818 byte(s)
new market version, lots of fixes
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 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 General Public License for more details.
13 *
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.
18 */
19
20 #include <string.h>
21 #include <stdlib.h>
22 #include "event.h"
23 #include "plugin.h"
24 #include "debug.h"
25
26 static struct event_methods event_methods;
27 static const char *e_requestor;
28 static const char *e_system;
29
30 static int has_quit;
31
32 void event_main_loop_run(void)
33 {
34 if (! event_methods.main_loop_run)
35 {
36 dbg(0,"no event system set\n");
37 return;
38 }
39 event_methods.main_loop_run();
40 }
41
42 void event_main_loop_quit(void)
43 {
44 if (event_methods.main_loop_quit)
45 {
46 event_methods.main_loop_quit();
47 }
48 has_quit=1;
49 }
50
51 int
52 event_main_loop_has_quit(void)
53 {
54 return has_quit;
55 }
56
57 struct event_watch *
58 event_add_watch(void *fd, enum event_watch_cond cond, struct callback *cb)
59 {
60 return event_methods.add_watch(fd, cond, cb);
61 }
62
63 void
64 event_remove_watch(struct event_watch *ev)
65 {
66 event_methods.remove_watch(ev);
67 }
68
69 struct event_timeout *
70 event_add_timeout(int timeout, int multi, struct callback *cb)
71 {
72 return event_methods.add_timeout(timeout, multi, cb);
73 }
74
75 void
76 event_remove_timeout(struct event_timeout *ev)
77 {
78 event_methods.remove_timeout(ev);
79 }
80
81 struct event_idle *
82 event_add_idle(int priority, struct callback *cb)
83 {
84 return event_methods.add_idle(priority,cb);
85 }
86
87 void
88 event_remove_idle(struct event_idle *ev)
89 {
90 event_methods.remove_idle(ev);
91 }
92
93 void
94 event_call_callback(struct callback_list *cb)
95 {
96 event_methods.call_callback(cb);
97 }
98
99 char const *
100 event_system(void)
101 {
102 return e_system;
103 }
104
105 int
106 event_request_system(const char *system, const char *requestor)
107 {
108 void (*event_type_new)(struct event_methods *meth);
109 if (e_system)
110 {
111 if (strcmp(e_system, system))
112 {
113 dbg(0,"system '%s' already requested by '%s', can't set to '%s' as requested from '%s'\n", e_system, e_requestor, system, requestor);
114 return 0;
115 }
116 return 1;
117 }
118
119 #ifdef PLUGSSS
120 event_type_new=plugin_get_event_type(system);
121 if (! event_type_new)
122 {
123 dbg(0,"unsupported event system '%s' requested from '%s'\n", system, requestor);
124 return 0;
125 }
126 event_type_new(&event_methods);
127 #else
128 event_android_new(&event_methods);
129 #endif
130
131 e_system=system;
132 e_requestor=requestor;
133
134 return 1;
135 }
136
137

   
Visit the ZANavi Wiki