]> git.itanic.dy.fi Git - maemo-mapper/blob - src/types.h
08fa06462636c9fb56e940722ccc2d836a4efac6
[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_TOGGLE_LAYERS,
196     CUSTOM_ACTION_ENUM_COUNT
197 } CustomAction;
198
199 /** This enum defines all of the customizable keys. */
200 typedef enum
201 {
202     CUSTOM_KEY_UP,
203     CUSTOM_KEY_LEFT,
204     CUSTOM_KEY_DOWN,
205     CUSTOM_KEY_RIGHT,
206     CUSTOM_KEY_SELECT,
207     CUSTOM_KEY_INCREASE,
208     CUSTOM_KEY_DECREASE,
209     CUSTOM_KEY_FULLSCREEN,
210     CUSTOM_KEY_ESC,
211     CUSTOM_KEY_ENUM_COUNT
212 } CustomKey;
213
214 /** This enum defines all of the colorable objects. */
215 typedef enum
216 {
217     COLORABLE_MARK,
218     COLORABLE_MARK_VELOCITY,
219     COLORABLE_MARK_OLD,
220     COLORABLE_TRACK,
221     COLORABLE_TRACK_MARK,
222     COLORABLE_TRACK_BREAK,
223     COLORABLE_ROUTE,
224     COLORABLE_ROUTE_WAY,
225     COLORABLE_ROUTE_BREAK,
226     COLORABLE_POI,
227     COLORABLE_ENUM_COUNT
228 } Colorable;
229
230 typedef enum
231 {
232     DDPDDDDD,
233     DD_MMPMMM,
234     DD_MM_SSPS,
235     DDPDDDDD_NSEW,
236     DD_MMPMMM_NSEW,
237     DD_MM_SSPS_NSEW,
238     NSEW_DDPDDDDD,
239     NSEW_DD_MMPMMM,
240     NSEW_DD_MM_SSPS,
241     DEG_FORMAT_ENUM_COUNT
242 } DegFormat;
243
244 typedef enum
245 {
246     SPEED_LOCATION_BOTTOM_LEFT,
247     SPEED_LOCATION_BOTTOM_RIGHT,
248     SPEED_LOCATION_TOP_RIGHT,
249     SPEED_LOCATION_TOP_LEFT,
250     SPEED_LOCATION_ENUM_COUNT
251 } SpeedLocation;
252
253 typedef enum
254 {
255     MAP_UPDATE_ADD,
256     MAP_UPDATE_OVERWRITE,
257     MAP_UPDATE_AUTO,
258     MAP_UPDATE_DELETE,
259     MAP_UPDATE_ENUM_COUNT
260 } MapUpdateType;
261
262 typedef enum
263 {
264     GPS_RCVR_BT,
265     GPS_RCVR_GPSD,
266     GPS_RCVR_FILE,
267     GPS_RCVR_ENUM_COUNT
268 } GpsRcvrType;
269
270 /** A general definition of a point in the Maemo Mapper unit system. */
271 typedef struct _Point Point;
272 struct _Point {
273     gint unitx;
274     gint unity;
275     time_t time;
276     gint altitude;
277 };
278
279 /** A WayPoint, which is a Point with a description. */
280 typedef struct _WayPoint WayPoint;
281 struct _WayPoint {
282     Point *point;
283     gchar *desc;
284 };
285
286 /** A Path is a set of PathPoints and WayPoints. */
287 typedef struct _Path Path;
288 struct _Path {
289     Point *head; /* points to first element in array; NULL if empty. */
290     Point *tail; /* points to last element in array. */
291     Point *cap; /* points after last slot in array. */
292     WayPoint *whead; /* points to first element in array; NULL if empty. */
293     WayPoint *wtail; /* points to last element in array. */
294     WayPoint *wcap; /* points after last slot in array. */
295 };
296
297 /** Data to describe a POI. */
298 typedef struct _PoiInfo PoiInfo;
299 struct _PoiInfo {
300     gint poi_id;
301     gint cat_id;
302     gdouble lat;
303     gdouble lon;
304     gchar *label;
305     gchar *desc;
306     gchar *clabel;
307 };
308
309 /** Data regarding a map repository. */
310 typedef struct _RepoData RepoData;
311 struct _RepoData {
312     gchar *name;
313     gchar *url;
314     gchar *db_filename;
315     gchar *db_dirname;
316     gint dl_zoom_steps;
317     gint view_zoom_steps;
318     gboolean double_size;
319     gboolean nextable;
320     gint min_zoom;
321     gint max_zoom;
322     RepoType type;
323     RepoData *layers;
324     gint8 layer_level;
325     gboolean layer_enabled;
326     gboolean layer_was_enabled; /* needed for ability to temporarily toggle layers on and off */
327     gint layer_refresh_interval;
328     gint layer_refresh_countdown;
329 #ifdef MAPDB_SQLITE
330     sqlite3 *db;
331     sqlite3_stmt *stmt_map_select;
332     sqlite3_stmt *stmt_map_exists;
333     sqlite3_stmt *stmt_map_update;
334     sqlite3_stmt *stmt_map_insert;
335     sqlite3_stmt *stmt_map_delete;
336     sqlite3_stmt *stmt_dup_select;
337     sqlite3_stmt *stmt_dup_exists;
338     sqlite3_stmt *stmt_dup_insert;
339     sqlite3_stmt *stmt_dup_increm;
340     sqlite3_stmt *stmt_dup_decrem;
341     sqlite3_stmt *stmt_dup_delete;
342     sqlite3_stmt *stmt_trans_begin;
343     sqlite3_stmt *stmt_trans_commit;
344     sqlite3_stmt *stmt_trans_rollback;
345 #else
346     GDBM_FILE db;
347 #endif
348     GtkWidget *menu_item;
349 };
350
351 /** GPS Data and Satellite **/
352 typedef struct _GpsData GpsData;
353 struct _GpsData {
354     gint fix;
355     gint fixquality;
356     gdouble lat;
357     gdouble lon;
358     gfloat speed;    /* in knots */
359     gfloat maxspeed;    /* in knots */
360     gfloat heading;
361     gfloat hdop;
362     gfloat pdop;
363     gfloat vdop;
364     gint satinview;
365     gint satinuse;
366     gint satforfix[12];
367 };
368
369 typedef struct _GpsSatelliteData GpsSatelliteData;
370 struct _GpsSatelliteData {
371     gint prn;
372     gint elevation;
373     gint azimuth;
374     gint snr;
375 };
376
377 /** Data used for rendering the entire screen. */
378 typedef struct _MapRenderTask MapRenderTask;
379 struct _MapRenderTask
380 {
381     RepoData *repo;
382     Point new_center;
383     gint old_offsetx;
384     gint old_offsety;
385     gint screen_width_pixels;
386     gint screen_height_pixels;
387     gint zoom;
388     gint rotate_angle;
389     gboolean smooth_pan;
390     GdkPixbuf *pixbuf;
391 };
392
393 /** Data used for rendering the entire screen. */
394 typedef struct _MapOffsetArgs MapOffsetArgs;
395 struct _MapOffsetArgs
396 {
397     gfloat old_center_offset_devx;
398     gfloat old_center_offset_devy;
399     gfloat new_center_offset_devx;
400     gfloat new_center_offset_devy;
401     gint rotate_angle;
402     gfloat percent_complete;
403 };
404
405 typedef struct _ThreadLatch ThreadLatch;
406 struct _ThreadLatch
407 {
408     gboolean is_open;
409     gboolean is_done_adding_tasks;
410     gint num_tasks;
411     gint num_done;
412     GMutex *mutex;
413     GCond *cond;
414 };
415
416 /** Data used during the asynchronous progress update phase of automatic map
417  * downloading. */
418 typedef struct _MapUpdateTask MapUpdateTask;
419 struct _MapUpdateTask
420 {
421     gint priority;
422     gint tilex;
423     gint tiley;
424     ThreadLatch *refresh_latch;
425     GdkPixbuf *pixbuf;
426     RepoData *repo;
427     gint8 update_type;
428     gint8 zoom;
429     gint8 vfs_result;
430     gint8 batch_id;
431     gint8 layer_level;
432 };
433
434 /** Data used during the asynchronous automatic route downloading operation. */
435 typedef struct _AutoRouteDownloadData AutoRouteDownloadData;
436 struct _AutoRouteDownloadData {
437     gboolean enabled;
438     gboolean in_progress;
439     gchar *source_url;
440     gchar *dest;
441     gboolean avoid_highways;
442 };
443
444 /** Data to describe the GPS connection. */
445 typedef struct _GpsRcvrInfo GpsRcvrInfo;
446 struct _GpsRcvrInfo {
447     GpsRcvrType type;
448     gchar *bt_mac;
449     gchar *file_path;
450     gchar *gpsd_host;
451     gint gpsd_port;
452 };
453
454 typedef struct _BrowseInfo BrowseInfo;
455 struct _BrowseInfo {
456     GtkWidget *dialog;
457     GtkWidget *txt;
458 };
459
460 #endif /* ifndef MAEMO_MAPPER_TYPES_H */