67 |
{ "compass_locked", STORE_BOOL, OFFSET(compass_locked) }, |
{ "compass_locked", STORE_BOOL, OFFSET(compass_locked) }, |
68 |
{ "latitude", STORE_FLOAT, OFFSET(home.lat) }, |
{ "latitude", STORE_FLOAT, OFFSET(home.lat) }, |
69 |
{ "longitude", STORE_FLOAT, OFFSET(home.lon) }, |
{ "longitude", STORE_FLOAT, OFFSET(home.lon) }, |
|
{ "manual_goto_lat", STORE_FLOAT, OFFSET(manual_goto.lat) }, |
|
|
{ "manual_goto_lon", STORE_FLOAT, OFFSET(manual_goto.lon) }, |
|
70 |
{ "gps_lat", STORE_FLOAT, OFFSET(gps.lat) }, |
{ "gps_lat", STORE_FLOAT, OFFSET(gps.lat) }, |
71 |
{ "gps_lon", STORE_FLOAT, OFFSET(gps.lon) }, |
{ "gps_lon", STORE_FLOAT, OFFSET(gps.lon) }, |
72 |
{ "search_in", STORE_INT, OFFSET(search) }, |
{ "search_in", STORE_INT, OFFSET(search) }, |
76 |
{ "cachelist_items", STORE_INT, OFFSET(cachelist_items) }, |
{ "cachelist_items", STORE_INT, OFFSET(cachelist_items) }, |
77 |
{ "compass_damping", STORE_INT, OFFSET(compass_damping) }, |
{ "compass_damping", STORE_INT, OFFSET(compass_damping) }, |
78 |
{ "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) }, |
{ "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) }, |
79 |
|
{ "cachelist_update", STORE_BOOL, OFFSET(cachelist_update) }, |
80 |
|
{ "disable_gcvote", STORE_BOOL, OFFSET(disable_gcvote) }, |
81 |
|
{ "username", STORE_STRING, OFFSET(username) }, |
82 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
83 |
{ "mmpoi_dontlaunch", STORE_BOOL, OFFSET(mmpoi_dontlaunch) }, |
{ "mmpoi_dontlaunch", STORE_BOOL, OFFSET(mmpoi_dontlaunch) }, |
84 |
{ "cachelist_dss", STORE_BOOL, OFFSET(cachelist_disable_screensaver) }, |
{ "cachelist_dss", STORE_BOOL, OFFSET(cachelist_disable_screensaver) }, |
85 |
{ "goto_dss", STORE_BOOL, OFFSET(goto_disable_screensaver) }, |
{ "goto_dss", STORE_BOOL, OFFSET(goto_disable_screensaver) }, |
|
{ "cachelist_update", STORE_BOOL, OFFSET(cachelist_update) }, |
|
86 |
#endif |
#endif |
87 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |
88 |
{ "map_lat", STORE_FLOAT, OFFSET(map.pos.lat) }, |
{ "map_lat", STORE_FLOAT, OFFSET(map.pos.lat) }, |
89 |
{ "map_lon", STORE_FLOAT, OFFSET(map.pos.lon) }, |
{ "map_lon", STORE_FLOAT, OFFSET(map.pos.lon) }, |
90 |
{ "map_zoom", STORE_INT, OFFSET(map.zoom) }, |
{ "map_zoom", STORE_INT, OFFSET(map.zoom) }, |
91 |
|
{ "map_source", STORE_INT, OFFSET(map.source) }, |
92 |
#endif |
#endif |
93 |
|
|
94 |
|
{ "geotoad/password", STORE_STRING, OFFSET(gt.password) }, |
95 |
|
{ "geotoad/filename", STORE_STRING, OFFSET(gt.filename) }, |
96 |
|
{ "geotoad/distance", STORE_FLOAT, OFFSET(gt.distance) }, |
97 |
|
{ "geotoad/lat", STORE_FLOAT, OFFSET(gt.lat) }, |
98 |
|
{ "geotoad/lon", STORE_FLOAT, OFFSET(gt.lon) }, |
99 |
|
{ "geotoad/flags", STORE_INT, OFFSET(gt.flags) }, |
100 |
|
|
101 |
{ NULL, -1, -1 } |
{ NULL, -1, -1 } |
102 |
}; |
}; |
103 |
|
|
119 |
} |
} |
120 |
|
|
121 |
void gconf_remove_closed_name(appdata_t *appdata, char *filename) { |
void gconf_remove_closed_name(appdata_t *appdata, char *filename) { |
122 |
|
if(!filename || !strlen(filename)) return; |
123 |
|
|
124 |
char *key = g_strdup_printf(GCONF_KEY_CLOSED, get_basename(filename)); |
char *key = g_strdup_printf(GCONF_KEY_CLOSED, get_basename(filename)); |
125 |
gconf_client_unset(appdata->gconf_client, key, NULL); |
gconf_client_unset(appdata->gconf_client, key, NULL); |
126 |
g_free(key); |
g_free(key); |
127 |
} |
} |
128 |
|
|
129 |
void gconf_save_closed_name(appdata_t *appdata, char *filename, char *name) { |
void gconf_save_closed_name(appdata_t *appdata, char *filename, char *name) { |
130 |
|
if(!filename || !strlen(filename)) return; |
131 |
|
|
132 |
char *key = g_strdup_printf(GCONF_KEY_CLOSED, get_basename(filename)); |
char *key = g_strdup_printf(GCONF_KEY_CLOSED, get_basename(filename)); |
133 |
gconf_client_set_string(appdata->gconf_client, key, name, NULL); |
gconf_client_set_string(appdata->gconf_client, key, name, NULL); |
134 |
g_free(key); |
g_free(key); |
135 |
} |
} |
136 |
|
|
137 |
char *gconf_restore_closed_name(appdata_t *appdata, char *filename) { |
char *gconf_restore_closed_name(appdata_t *appdata, char *filename) { |
138 |
|
if(!filename || !strlen(filename)) return NULL; |
139 |
|
|
140 |
char *key = g_strdup_printf(GCONF_KEY_CLOSED, get_basename(filename)); |
char *key = g_strdup_printf(GCONF_KEY_CLOSED, get_basename(filename)); |
141 |
char *ret = gconf_client_get_string(appdata->gconf_client, key, NULL); |
char *ret = gconf_client_get_string(appdata->gconf_client, key, NULL); |
142 |
g_free(key); |
g_free(key); |
146 |
void gconf_save_state(appdata_t *appdata) { |
void gconf_save_state(appdata_t *appdata) { |
147 |
int entries = 0; |
int entries = 0; |
148 |
|
|
149 |
|
/* free proxy settings */ |
150 |
|
if(appdata->proxy) { |
151 |
|
proxy_t *proxy = appdata->proxy; |
152 |
|
|
153 |
|
if(proxy->authentication_password) g_free(proxy->authentication_password); |
154 |
|
if(proxy->authentication_user) g_free(proxy->authentication_user); |
155 |
|
if(proxy->host) g_free(proxy->host); |
156 |
|
if(proxy->ignore_hosts) g_free(proxy->ignore_hosts); |
157 |
|
|
158 |
|
g_free(proxy); |
159 |
|
appdata->proxy = NULL; |
160 |
|
} |
161 |
|
|
162 |
gpx_t *gpx = appdata->gpx; |
gpx_t *gpx = appdata->gpx; |
163 |
while(gpx) { |
while(gpx) { |
164 |
char str[128]; |
char str[128]; |
197 |
if((char*)(*ptr)) { |
if((char*)(*ptr)) { |
198 |
gconf_client_set_string(appdata->gconf_client, key, (char*)(*ptr), NULL); |
gconf_client_set_string(appdata->gconf_client, key, (char*)(*ptr), NULL); |
199 |
} |
} |
200 |
|
g_free((char*)(*ptr)); |
201 |
|
*ptr = NULL; |
202 |
break; |
break; |
203 |
|
|
204 |
case STORE_BOOL: |
case STORE_BOOL: |
233 |
|
|
234 |
/* default positions are invalid */ |
/* default positions are invalid */ |
235 |
appdata->home.lat = appdata->home.lon = NAN; |
appdata->home.lat = appdata->home.lon = NAN; |
|
appdata->manual_goto.lat = appdata->manual_goto.lon = NAN; |
|
236 |
appdata->gps.lat = appdata->gps.lon = NAN; |
appdata->gps.lat = appdata->gps.lon = NAN; |
237 |
|
appdata->geomath.lat = appdata->geomath.lon = NAN; |
238 |
|
|
239 |
|
appdata->gt.lat = appdata->gt.lon = NAN; |
240 |
|
appdata->gt.distance = 1.0; // in km/mil |
241 |
|
|
242 |
|
/* ------------- get proxy settings -------------------- */ |
243 |
|
if(gconf_client_get_bool(appdata->gconf_client, |
244 |
|
PROXY_KEY "use_http_proxy", NULL)) { |
245 |
|
proxy_t *proxy = appdata->proxy = g_new0(proxy_t, 1); |
246 |
|
|
247 |
|
/* get basic settings */ |
248 |
|
proxy->host = gconf_client_get_string(appdata->gconf_client, |
249 |
|
PROXY_KEY "host", NULL); |
250 |
|
proxy->port = gconf_client_get_int(appdata->gconf_client, |
251 |
|
PROXY_KEY "port", NULL); |
252 |
|
proxy->ignore_hosts = |
253 |
|
gconf_client_get_string(appdata->gconf_client, |
254 |
|
PROXY_KEY "ignore_hosts", NULL); |
255 |
|
|
256 |
|
/* check for authentication */ |
257 |
|
proxy->use_authentication = |
258 |
|
gconf_client_get_bool(appdata->gconf_client, |
259 |
|
PROXY_KEY "use_authentication", NULL); |
260 |
|
|
261 |
|
if(proxy->use_authentication) { |
262 |
|
proxy->authentication_user = |
263 |
|
gconf_client_get_string(appdata->gconf_client, |
264 |
|
PROXY_KEY "authentication_user", NULL); |
265 |
|
proxy->authentication_password = |
266 |
|
gconf_client_get_string(appdata->gconf_client, |
267 |
|
PROXY_KEY "authentication_password", NULL); |
268 |
|
} |
269 |
|
} |
270 |
|
|
271 |
|
/* restore everything listed in the store table */ |
272 |
|
store_t *st = store; |
273 |
|
while(st->key) { |
274 |
|
void **ptr = ((void*)appdata) + st->offset; |
275 |
|
char *key = g_strdup_printf(GCONF_PATH "%s", st->key); |
276 |
|
|
277 |
|
/* check if key is present */ |
278 |
|
GConfValue *value = gconf_client_get(appdata->gconf_client, key, NULL); |
279 |
|
if(value) { |
280 |
|
gconf_value_free(value); |
281 |
|
|
282 |
|
switch(st->type) { |
283 |
|
case STORE_STRING: { |
284 |
|
char **str = (char**)ptr; |
285 |
|
*str = gconf_client_get_string(appdata->gconf_client, key, NULL); |
286 |
|
} break; |
287 |
|
|
288 |
|
case STORE_BOOL: |
289 |
|
*((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL); |
290 |
|
break; |
291 |
|
|
292 |
|
case STORE_INT: |
293 |
|
*((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL); |
294 |
|
break; |
295 |
|
|
296 |
|
case STORE_FLOAT: |
297 |
|
*((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL); |
298 |
|
break; |
299 |
|
|
300 |
|
default: |
301 |
|
printf("Unsupported type %d\n", st->type); |
302 |
|
break; |
303 |
|
} |
304 |
|
} |
305 |
|
g_free(key); |
306 |
|
st++; |
307 |
|
} |
308 |
|
|
309 |
int i, entries = gconf_client_get_int(appdata->gconf_client, |
int i, entries = gconf_client_get_int(appdata->gconf_client, |
310 |
GCONF_KEY_CNT, NULL); |
GCONF_KEY_CNT, NULL); |
316 |
char str[128]; |
char str[128]; |
317 |
snprintf(str, sizeof(str), GCONF_KEY_GPX, i); |
snprintf(str, sizeof(str), GCONF_KEY_GPX, i); |
318 |
char *fname = gconf_client_get_string(appdata->gconf_client, str, NULL); |
char *fname = gconf_client_get_string(appdata->gconf_client, str, NULL); |
|
|
|
319 |
if(fname) { |
if(fname) { |
320 |
/* check if there's a valid name stored for this file. */ |
/* check if there's a valid name stored for this file. */ |
321 |
/* if yes it's a "closed" file */ |
/* if yes it's a "closed" file */ |
327 |
(*gpx)->closed = TRUE; |
(*gpx)->closed = TRUE; |
328 |
} else { |
} else { |
329 |
if(g_file_test(fname, G_FILE_TEST_IS_DIR)) |
if(g_file_test(fname, G_FILE_TEST_IS_DIR)) |
330 |
*gpx = gpx_parse_dir(dialog, fname); |
*gpx = gpx_parse_dir(dialog, fname, appdata->username); |
331 |
else |
else |
332 |
*gpx = gpx_parse(dialog, fname); |
*gpx = gpx_parse(dialog, fname, appdata->username); |
333 |
|
|
334 |
free(fname); |
if(!*gpx) { |
335 |
|
/* restoring the gpx file failed, mark it as unusable, but save */ |
336 |
|
/* its presence for later use */ |
337 |
|
|
338 |
|
/* create "closed" entry to remember this file for next */ |
339 |
|
/* load attempt */ |
340 |
|
*gpx = g_new0(gpx_t, 1); |
341 |
|
(*gpx)->filename = fname; |
342 |
|
char *p = fname; |
343 |
|
if(strrchr(fname, '/')) |
344 |
|
p = strrchr(fname, '/')+1; |
345 |
|
|
346 |
|
(*gpx)->name = g_strdup_printf(_("Failed to load: %s"), p); |
347 |
|
(*gpx)->closed = TRUE; |
348 |
|
} else |
349 |
|
free(fname); |
350 |
} |
} |
|
} |
|
|
|
|
|
/* use next gpx entry of this was loaded successfully */ |
|
|
if(*gpx) |
|
351 |
gpx = &((*gpx)->next); |
gpx = &((*gpx)->next); |
352 |
|
} |
353 |
} |
} |
354 |
|
|
355 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
374 |
} |
} |
375 |
} |
} |
376 |
|
|
|
/* restore everything listed in the store table */ |
|
|
store_t *st = store; |
|
|
while(st->key) { |
|
|
void **ptr = ((void*)appdata) + st->offset; |
|
|
char *key = g_strdup_printf(GCONF_PATH "%s", st->key); |
|
|
|
|
|
/* check if key is present */ |
|
|
GConfValue *value = gconf_client_get(appdata->gconf_client, key, NULL); |
|
|
if(value) { |
|
|
gconf_value_free(value); |
|
|
|
|
|
switch(st->type) { |
|
|
case STORE_STRING: { |
|
|
char **str = (char**)ptr; |
|
|
*str = gconf_client_get_string(appdata->gconf_client, key, NULL); |
|
|
} break; |
|
|
|
|
|
case STORE_BOOL: |
|
|
*((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL); |
|
|
break; |
|
|
|
|
|
case STORE_INT: |
|
|
*((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL); |
|
|
break; |
|
|
|
|
|
case STORE_FLOAT: |
|
|
*((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL); |
|
|
break; |
|
|
|
|
|
default: |
|
|
printf("Unsupported type %d\n", st->type); |
|
|
break; |
|
|
} |
|
|
} |
|
|
g_free(key); |
|
|
st++; |
|
|
} |
|
|
|
|
377 |
/* ----- set all kinds of defaults ------- */ |
/* ----- set all kinds of defaults ------- */ |
378 |
|
|
379 |
if(!appdata->compass_damping) appdata->compass_damping = 1; |
if(!appdata->compass_damping) appdata->compass_damping = 1; |
385 |
appdata->search = SEARCH_NAME | SEARCH_ID; |
appdata->search = SEARCH_NAME | SEARCH_ID; |
386 |
|
|
387 |
if(!appdata->image_path) { |
if(!appdata->image_path) { |
388 |
|
#ifdef USE_MAEMO |
389 |
|
/* update cachelist by default */ |
390 |
|
appdata->cachelist_update = TRUE; |
391 |
|
#endif |
392 |
|
|
393 |
/* use gps by default */ |
/* use gps by default */ |
394 |
appdata->use_gps = TRUE; |
appdata->use_gps = TRUE; |
407 |
#endif |
#endif |
408 |
appdata->image_path = strdup(DEFAULT_IMAGE_PATH); |
appdata->image_path = strdup(DEFAULT_IMAGE_PATH); |
409 |
|
|
410 |
|
/* check if this path is actually accessible */ |
411 |
|
/* and change it to the current users home if not */ |
412 |
|
/* (this should only happen on scratchbox) */ |
413 |
|
if(!g_file_test(appdata->image_path, G_FILE_TEST_IS_DIR)) { |
414 |
|
if(g_mkdir_with_parents(appdata->image_path, 0700) != 0) { |
415 |
|
char *p = getenv("HOME"); |
416 |
|
if(!p) p = "/tmp/"; |
417 |
|
|
418 |
|
appdata->image_path = |
419 |
|
g_strdup_printf("%s%s%s", p, |
420 |
|
(p[strlen(p)-1]!='/')?"/":"", |
421 |
|
DEFAULT_IMAGE_PATH_HOME); |
422 |
|
printf("using alt path %s\n", appdata->image_path); |
423 |
|
} |
424 |
|
} |
425 |
|
|
426 |
} else { |
} else { |
427 |
/* some versions old versions messed up the path */ |
/* some versions old versions messed up the path */ |
428 |
if(appdata->image_path[strlen(appdata->image_path)-1] != '/') { |
if(appdata->image_path[strlen(appdata->image_path)-1] != '/') { |
490 |
char *name = g_strdup(ICONPATH "welcome.gpx"); |
char *name = g_strdup(ICONPATH "welcome.gpx"); |
491 |
dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
492 |
printf("No GPX file loaded, trying to load demo\n"); |
printf("No GPX file loaded, trying to load demo\n"); |
493 |
appdata->gpx = gpx_parse(dialog, name); |
appdata->gpx = gpx_parse(dialog, name, appdata->username); |
494 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
495 |
g_free(name); |
g_free(name); |
496 |
} |
} |