]> git.itanic.dy.fi Git - maemo-mapper/blob - src/types.h
70ae7e1b6bad745d10a4a2772283d4e3884cfeec
[maemo-mapper] / src / types.h
1 /*
2  * Copyright (C) 2006, 2007 John Costigan.
3  *
4  * POI and GPS-Info code originally written by Cezary Jackiewicz.
5  *
6  * Default map data provided by http://www.openstreetmap.org/
7  *
8  * This file is part of Maemo Mapper.
9  *
10  * Maemo Mapper is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * Maemo Mapper is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Maemo Mapper.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #ifndef MAEMO_MAPPER_TYPES_H
25 #define MAEMO_MAPPER_TYPES_H
26
27 #include <time.h>
28 #include <gdbm.h>
29 #include <gtk/gtk.h>
30 #include <libgnomevfs/gnome-vfs.h>
31
32 #define _(String) gettext(String)
33
34 /* #define MAPDB_SQLITE */
35
36 #ifdef MAPDB_SQLITE
37 #include "sqlite3.h"
38 #endif
39
40 /** This enumerated type defines the possible connection states. */
41 typedef enum
42 {
43     /** The receiver is "off", meaning that either the bluetooth radio is
44      * off or the user has requested not to connect to the GPS receiver.
45      * No gtk_banner is visible. */
46     RCVR_OFF,
47
48     /** The connection with the receiver is down.  A gtk_banner is visible with
49      * the text, "Connecting to GPS receiver". */
50     RCVR_DOWN,
51
52     /** The connection with the receiver is up, but a GPS fix is not available.
53      * A gtk_banner is visible with the text, "(Re-)Establishing GPS fix". */
54     RCVR_UP,
55
56     /** The connection with the receiver is up and a GPS fix IS available.
57      * No gtk_banner is visible. */
58     RCVR_FIXED
59 } ConnState;
60
61 /** This enumerated type defines the supported types of repositories. */
62 typedef enum
63 {
64     REPOTYPE_NONE, /* No URL set. */
65     REPOTYPE_XYZ, /* x=%d, y=%d, and zoom=%d */
66     REPOTYPE_XYZ_INV, /* zoom=%0d, x=%d, y=%d */
67     REPOTYPE_QUAD_QRST, /* t=%s   (%s = {qrst}*) */
68     REPOTYPE_QUAD_ZERO, /* t=%0s  (%0s = {0123}*) */
69     REPOTYPE_WMS        /* "service=wms" */
70 } RepoType;
71
72 /** Possible center modes.  The "WAS" modes imply no current center mode;
73  * they only hint at what the last center mode was, so that it can be
74  * recalled. */
75 typedef enum
76 {
77     CENTER_WAS_LATLON = -2,
78     CENTER_WAS_LEAD = -1,
79     CENTER_LEAD = 1,
80     CENTER_LATLON = 2
81 } CenterMode;
82
83 /** This enum defines the states of the SAX parsing state machine. */
84 typedef enum
85 {
86     START,
87     INSIDE_GPX,
88     INSIDE_WPT,
89     INSIDE_WPT_NAME,
90     INSIDE_WPT_DESC,
91     INSIDE_PATH,
92     INSIDE_PATH_SEGMENT,
93     INSIDE_PATH_POINT,
94     INSIDE_PATH_POINT_ELE,
95     INSIDE_PATH_POINT_TIME,
96     INSIDE_PATH_POINT_DESC,
97     FINISH,
98     UNKNOWN,
99     ERROR,
100 } SaxState;
101
102 /** POI dialog action **/
103 typedef enum
104 {
105     ACTION_ADD_POI,
106     ACTION_EDIT_POI,
107 } POIAction;
108
109 /** Category list **/
110 typedef enum
111 {
112     CAT_ID,
113     CAT_ENABLED,
114     CAT_LABEL,
115     CAT_DESC,
116     CAT_POI_CNT,
117     CAT_NUM_COLUMNS
118 } CategoryList;
119
120 /** POI list **/
121 typedef enum
122 {
123     POI_SELECTED,
124     POI_POIID,
125     POI_CATID,
126     POI_LAT,
127     POI_LON,
128     POI_LATLON,
129     POI_BEARING,
130     POI_DISTANCE,
131     POI_LABEL,
132     POI_DESC,
133     POI_CLABEL,
134     POI_NUM_COLUMNS
135 } POIList;
136
137 /** This enum defines the possible units we can use. */
138 typedef enum
139 {
140     UNITS_KM,
141     UNITS_MI,
142     UNITS_NM,
143     UNITS_ENUM_COUNT
144 } UnitType;
145
146 typedef enum
147 {
148     UNBLANK_WITH_GPS,
149     UNBLANK_WHEN_MOVING,
150     UNBLANK_FULLSCREEN,
151     UNBLANK_WAYPOINT,
152     UNBLANK_NEVER,
153     UNBLANK_ENUM_COUNT
154 } UnblankOption;
155
156 /** This enum defines the possible font sizes. */
157 typedef enum
158 {
159     INFO_FONT_XXSMALL,
160     INFO_FONT_XSMALL,
161     INFO_FONT_SMALL,
162     INFO_FONT_MEDIUM,
163     INFO_FONT_LARGE,
164     INFO_FONT_XLARGE,
165     INFO_FONT_XXLARGE,
166     INFO_FONT_ENUM_COUNT
167 } InfoFontSize;
168
169 /** This enum defines the possible font sizes. */
170 typedef enum
171 {
172     ROTATE_DIR_UP,
173     ROTATE_DIR_RIGHT,
174     ROTATE_DIR_DOWN,
175     ROTATE_DIR_LEFT,
176     ROTATE_DIR_ENUM_COUNT
177 } RotateDir;
178
179 /** This enum defines all of the key-customizable actions. */
180 typedef enum
181 {
182     CUSTOM_ACTION_PAN_NORTH,
183     CUSTOM_ACTION_PAN_WEST,
184     CUSTOM_ACTION_PAN_SOUTH,
185     CUSTOM_ACTION_PAN_EAST,
186     CUSTOM_ACTION_PAN_UP,
187     CUSTOM_ACTION_PAN_DOWN,
188     CUSTOM_ACTION_PAN_LEFT,
189     CUSTOM_ACTION_PAN_RIGHT,
190     CUSTOM_ACTION_RESET_VIEW_ANGLE,
191     CUSTOM_ACTION_ROTATE_CLOCKWISE,
192     CUSTOM_ACTION_ROTATE_COUNTERCLOCKWISE,
193     CUSTOM_ACTION_TOGGLE_AUTOCENTER,
194     CUSTOM_ACTION_TOGGLE_AUTOROTATE,
195     CUSTOM_ACTION_ZOOM_IN,
196     CUSTOM_ACTION_ZOOM_OUT,
197     CUSTOM_ACTION_TOGGLE_FULLSCREEN,
198     CUSTOM_ACTION_TOGGLE_TRACKS,
199     CUSTOM_ACTION_TOGGLE_SCALE,
200     CUSTOM_ACTION_TOGGLE_POI,
201     CUSTOM_ACTION_CHANGE_REPO,
202     CUSTOM_ACTION_ROUTE_DISTNEXT,
203     CUSTOM_ACTION_ROUTE_DISTLAST,
204     CUSTOM_ACTION_TRACK_BREAK,
205     CUSTOM_ACTION_TRACK_CLEAR,
206     CUSTOM_ACTION_TRACK_DISTLAST,
207     CUSTOM_ACTION_TRACK_DISTFIRST,
208     CUSTOM_ACTION_TOGGLE_GPS,
209     CUSTOM_ACTION_TOGGLE_GPSINFO,
210     CUSTOM_ACTION_TOGGLE_SPEEDLIMIT,
211     CUSTOM_ACTION_RESET_BLUETOOTH,
212     CUSTOM_ACTION_ENUM_COUNT
213 } CustomAction;
214
215 /** This enum defines all of the customizable keys. */
216 typedef enum
217 {
218     CUSTOM_KEY_UP,
219     CUSTOM_KEY_LEFT,
220     CUSTOM_KEY_DOWN,
221     CUSTOM_KEY_RIGHT,
222     CUSTOM_KEY_SELECT,
223     CUSTOM_KEY_INCREASE,
224     CUSTOM_KEY_DECREASE,
225     CUSTOM_KEY_FULLSCREEN,
226     CUSTOM_KEY_ESC,
227     CUSTOM_KEY_ENUM_COUNT
228 } CustomKey;
229
230 /** This enum defines all of the colorable objects. */
231 typedef enum
232 {
233     COLORABLE_MARK,
234     COLORABLE_MARK_VELOCITY,
235     COLORABLE_MARK_OLD,
236     COLORABLE_TRACK,
237     COLORABLE_TRACK_MARK,
238     COLORABLE_TRACK_BREAK,
239     COLORABLE_ROUTE,
240     COLORABLE_ROUTE_WAY,
241     COLORABLE_ROUTE_BREAK,
242     COLORABLE_POI,
243     COLORABLE_ENUM_COUNT
244 } Colorable;
245
246 typedef enum
247 {
248     DDPDDDDD,
249     DD_MMPMMM,
250     DD_MM_SSPS,
251     DDPDDDDD_NSEW,
252     DD_MMPMMM_NSEW,
253     DD_MM_SSPS_NSEW,
254     NSEW_DDPDDDDD,
255     NSEW_DD_MMPMMM,
256     NSEW_DD_MM_SSPS,
257     DEG_FORMAT_ENUM_COUNT
258 } DegFormat;
259
260 typedef enum
261 {
262     SPEED_LOCATION_BOTTOM_LEFT,
263     SPEED_LOCATION_BOTTOM_RIGHT,
264     SPEED_LOCATION_TOP_RIGHT,
265     SPEED_LOCATION_TOP_LEFT,
266     SPEED_LOCATION_ENUM_COUNT
267 } SpeedLocation;
268
269 typedef enum
270 {
271     MAP_UPDATE_ADD,
272     MAP_UPDATE_OVERWRITE,
273     MAP_UPDATE_AUTO,
274     MAP_UPDATE_DELETE,
275     MAP_UPDATE_ENUM_COUNT
276 } MapUpdateType;
277
278 typedef enum
279 {
280     GPS_RCVR_BT,
281     GPS_RCVR_GPSD,
282     GPS_RCVR_FILE,
283     GPS_RCVR_ENUM_COUNT
284 } GpsRcvrType;
285
286 /** A general definition of a point in the Maemo Mapper unit system. */
287 typedef struct _Point Point;
288 struct _Point {
289     gint unitx;
290     gint unity;
291     time_t time;
292     gint altitude;
293 };
294
295 /** A WayPoint, which is a Point with a description. */
296 typedef struct _WayPoint WayPoint;
297 struct _WayPoint {
298     Point *point;
299     gchar *desc;
300 };
301
302 /** A Path is a set of PathPoints and WayPoints. */
303 typedef struct _Path Path;
304 struct _Path {
305     Point *head; /* points to first element in array; NULL if empty. */
306     Point *tail; /* points to last element in array. */
307     Point *cap; /* points after last slot in array. */
308     WayPoint *whead; /* points to first element in array; NULL if empty. */
309     WayPoint *wtail; /* points to last element in array. */
310     WayPoint *wcap; /* points after last slot in array. */
311 };
312
313 /** Data used during the SAX parsing operation. */
314 typedef struct _SaxData SaxData;
315 struct _SaxData {
316     SaxState state;
317     SaxState prev_state;
318     gint unknown_depth;
319     gboolean at_least_one_trkpt;
320     GString *chars;
321 };
322
323 typedef struct _PathSaxData PathSaxData;
324 struct _PathSaxData {
325     SaxData sax_data;
326     Path path;
327 };
328
329 /** Data to describe a POI. */
330 typedef struct _PoiInfo PoiInfo;
331 struct _PoiInfo {
332     gint poi_id;
333     gint cat_id;
334     gdouble lat;
335     gdouble lon;
336     gchar *label;
337     gchar *desc;
338     gchar *clabel;
339 };
340
341 typedef struct _PoiSaxData PoiSaxData;
342 struct _PoiSaxData {
343     SaxData sax_data;
344     GList *poi_list;
345     PoiInfo *curr_poi;
346 };
347
348 /** Data regarding a map repository. */
349 typedef struct _RepoData RepoData;
350 struct _RepoData {
351     gchar *name;
352     gchar *url;
353     gchar *db_filename;
354     gchar *db_dirname;
355     gint dl_zoom_steps;
356     gint view_zoom_steps;
357     gboolean double_size;
358     gboolean nextable;
359     gint min_zoom;
360     gint max_zoom;
361     RepoType type;
362 #ifdef MAPDB_SQLITE
363     sqlite3 *db;
364     sqlite3_stmt *stmt_map_select;
365     sqlite3_stmt *stmt_map_exists;
366     sqlite3_stmt *stmt_map_update;
367     sqlite3_stmt *stmt_map_insert;
368     sqlite3_stmt *stmt_map_delete;
369     sqlite3_stmt *stmt_dup_select;
370     sqlite3_stmt *stmt_dup_exists;
371     sqlite3_stmt *stmt_dup_insert;
372     sqlite3_stmt *stmt_dup_increm;
373     sqlite3_stmt *stmt_dup_decrem;
374     sqlite3_stmt *stmt_dup_delete;
375     sqlite3_stmt *stmt_trans_begin;
376     sqlite3_stmt *stmt_trans_commit;
377     sqlite3_stmt *stmt_trans_rollback;
378 #else
379     GDBM_FILE db;
380 #endif
381     GtkWidget *menu_item;
382 };
383
384 /** GPS Data and Satellite **/
385 typedef struct _GpsData GpsData;
386 struct _GpsData {
387     gint fix;
388     gint fixquality;
389     gdouble lat;
390     gdouble lon;
391     gfloat speed;    /* in knots */
392     gfloat maxspeed;    /* in knots */
393     gfloat heading;
394     gfloat hdop;
395     gfloat pdop;
396     gfloat vdop;
397     gint satinview;
398     gint satinuse;
399     gint satforfix[12];
400 };
401
402 typedef struct _GpsSatelliteData GpsSatelliteData;
403 struct _GpsSatelliteData {
404     gint prn;
405     gint elevation;
406     gint azimuth;
407     gint snr;
408 };
409
410 /** Data used for rendering the entire screen. */
411 typedef struct _MapRenderTask MapRenderTask;
412 struct _MapRenderTask
413 {
414     RepoData *repo;
415     Point new_center;
416     gint old_offsetx;
417     gint old_offsety;
418     gint screen_width_pixels;
419     gint screen_height_pixels;
420     gint zoom;
421     gint rotate_angle;
422     gboolean smooth_pan;
423     GdkPixbuf *pixbuf;
424 };
425
426 /** Data used for rendering the entire screen. */
427 typedef struct _MapOffsetArgs MapOffsetArgs;
428 struct _MapOffsetArgs
429 {
430     gfloat old_center_offset_devx;
431     gfloat old_center_offset_devy;
432     gfloat new_center_offset_devx;
433     gfloat new_center_offset_devy;
434     gint rotate_angle;
435     gfloat percent_complete;
436 };
437
438 typedef struct _ThreadLatch ThreadLatch;
439 struct _ThreadLatch
440 {
441     gboolean is_open;
442     gboolean is_done_adding_tasks;
443     gint num_tasks;
444     gint num_done;
445     GMutex *mutex;
446     GCond *cond;
447 };
448
449 /** Data used during the asynchronous progress update phase of automatic map
450  * downloading. */
451 typedef struct _MapUpdateTask MapUpdateTask;
452 struct _MapUpdateTask
453 {
454     gint priority;
455     gint tilex;
456     gint tiley;
457     ThreadLatch *refresh_latch;
458     GdkPixbuf *pixbuf;
459     RepoData *repo;
460     gint8 update_type;
461     gint8 zoom;
462     gint8 vfs_result;
463     gint8 batch_id;
464 };
465
466 /** Data used during the asynchronous automatic route downloading operation. */
467 typedef struct _AutoRouteDownloadData AutoRouteDownloadData;
468 struct _AutoRouteDownloadData {
469     gboolean enabled;
470     gboolean in_progress;
471     gchar *source_url;
472     gchar *dest;
473     gboolean avoid_highways;
474 };
475
476 /** Data to describe the GPS connection. */
477 typedef struct _GpsRcvrInfo GpsRcvrInfo;
478 struct _GpsRcvrInfo {
479     GpsRcvrType type;
480     gchar *bt_mac;
481     gchar *file_path;
482     gchar *gpsd_host;
483     gint gpsd_port;
484 };
485
486 typedef struct _BrowseInfo BrowseInfo;
487 struct _BrowseInfo {
488     GtkWidget *dialog;
489     GtkWidget *txt;
490 };
491
492 #endif /* ifndef MAEMO_MAPPER_TYPES_H */