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