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