Diff of /trunk/src/gconf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 34 by harbaum, Wed Jul 29 19:24:15 2009 UTC revision 167 by harbaum, Mon Nov 9 07:50:37 2009 UTC
# Line 78  static store_t store[] = { Line 78  static store_t store[] = {
78    { "cachelist_items",  STORE_INT,    OFFSET(cachelist_items) },    { "cachelist_items",  STORE_INT,    OFFSET(cachelist_items) },
79    { "compass_damping",  STORE_INT,    OFFSET(compass_damping) },    { "compass_damping",  STORE_INT,    OFFSET(compass_damping) },
80    { "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) },    { "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) },
81      { "cachelist_update", STORE_BOOL,   OFFSET(cachelist_update) },
82      { "disable_gcvote",   STORE_BOOL,   OFFSET(disable_gcvote) },
83  #ifdef USE_MAEMO  #ifdef USE_MAEMO
84    { "mmpoi_dontlaunch", STORE_BOOL,   OFFSET(mmpoi_dontlaunch) },    { "mmpoi_dontlaunch", STORE_BOOL,   OFFSET(mmpoi_dontlaunch) },
85    { "cachelist_dss",    STORE_BOOL,   OFFSET(cachelist_disable_screensaver) },    { "cachelist_dss",    STORE_BOOL,   OFFSET(cachelist_disable_screensaver) },
86    { "goto_dss",         STORE_BOOL,   OFFSET(goto_disable_screensaver) },    { "goto_dss",         STORE_BOOL,   OFFSET(goto_disable_screensaver) },
   { "cachelist_update", STORE_BOOL,   OFFSET(cachelist_update) },  
87  #endif  #endif
88    #ifdef ENABLE_OSM_GPS_MAP
89      { "map_lat",          STORE_FLOAT,  OFFSET(map.pos.lat) },
90      { "map_lon",          STORE_FLOAT,  OFFSET(map.pos.lon) },
91      { "map_zoom",         STORE_INT,    OFFSET(map.zoom) },
92      { "map_source",       STORE_INT,    OFFSET(map.source) },
93    #endif
94    { NULL, -1, -1 }    { NULL, -1, -1 }
95  };  };
96    
# Line 127  char *gconf_restore_closed_name(appdata_ Line 133  char *gconf_restore_closed_name(appdata_
133  void gconf_save_state(appdata_t *appdata) {  void gconf_save_state(appdata_t *appdata) {
134    int entries = 0;    int entries = 0;
135    
136      /* free proxy settings */
137      if(appdata->proxy) {
138        proxy_t *proxy = appdata->proxy;
139    
140        if(proxy->authentication_password) g_free(proxy->authentication_password);
141        if(proxy->authentication_user)     g_free(proxy->authentication_user);
142        if(proxy->host)                    g_free(proxy->host);
143        if(proxy->ignore_hosts)            g_free(proxy->ignore_hosts);
144    
145        g_free(proxy);
146        appdata->proxy = NULL;
147      }
148    
149    gpx_t *gpx = appdata->gpx;    gpx_t *gpx = appdata->gpx;
150    while(gpx) {    while(gpx) {
151      char str[128];      char str[128];
# Line 202  void gconf_load_state(appdata_t *appdata Line 221  void gconf_load_state(appdata_t *appdata
221    appdata->manual_goto.lat = appdata->manual_goto.lon = NAN;    appdata->manual_goto.lat = appdata->manual_goto.lon = NAN;
222    appdata->gps.lat = appdata->gps.lon = NAN;    appdata->gps.lat = appdata->gps.lon = NAN;
223    
224      /* ------------- get proxy settings -------------------- */
225      if(gconf_client_get_bool(appdata->gconf_client,
226                               PROXY_KEY "use_http_proxy", NULL)) {
227        proxy_t *proxy = appdata->proxy = g_new0(proxy_t, 1);
228    
229        /* get basic settings */
230        proxy->host = gconf_client_get_string(appdata->gconf_client,
231                                              PROXY_KEY "host", NULL);
232        proxy->port = gconf_client_get_int(appdata->gconf_client,
233                                           PROXY_KEY "port", NULL);
234        proxy->ignore_hosts =
235          gconf_client_get_string(appdata->gconf_client,
236                                  PROXY_KEY "ignore_hosts", NULL);
237    
238        /* check for authentication */
239        proxy->use_authentication =
240          gconf_client_get_bool(appdata->gconf_client,
241                                PROXY_KEY "use_authentication", NULL);
242    
243        if(proxy->use_authentication) {
244          proxy->authentication_user =
245            gconf_client_get_string(appdata->gconf_client,
246                                    PROXY_KEY "authentication_user", NULL);
247          proxy->authentication_password =
248            gconf_client_get_string(appdata->gconf_client,
249                                    PROXY_KEY "authentication_password", NULL);
250        }
251      }
252    
253    int i, entries = gconf_client_get_int(appdata->gconf_client,    int i, entries = gconf_client_get_int(appdata->gconf_client,
254                                   GCONF_KEY_CNT, NULL);                                   GCONF_KEY_CNT, NULL);
255    
# Line 212  void gconf_load_state(appdata_t *appdata Line 260  void gconf_load_state(appdata_t *appdata
260      char str[128];      char str[128];
261      snprintf(str, sizeof(str), GCONF_KEY_GPX, i);      snprintf(str, sizeof(str), GCONF_KEY_GPX, i);
262      char *fname = gconf_client_get_string(appdata->gconf_client, str, NULL);      char *fname = gconf_client_get_string(appdata->gconf_client, str, NULL);
   
263      if(fname) {      if(fname) {
264        /* check if there's a valid name stored for this file. */        /* check if there's a valid name stored for this file. */
265        /* if yes it's a "closed" file */        /* if yes it's a "closed" file */
# Line 228  void gconf_load_state(appdata_t *appdata Line 275  void gconf_load_state(appdata_t *appdata
275          else          else
276            *gpx = gpx_parse(dialog, fname);            *gpx = gpx_parse(dialog, fname);
277    
278          free(fname);          if(!*gpx) {
279              /* restoring the gpx file failed, mark it as unusable, but save */
280              /* its presence for later use */
281    
282              /* create "closed" entry to remember this file for next */
283              /* load attempt */
284              *gpx = g_new0(gpx_t, 1);
285              (*gpx)->filename = fname;
286              char *p = fname;
287              if(strrchr(fname, '/'))
288                p = strrchr(fname, '/')+1;
289    
290              (*gpx)->name = g_strdup_printf(_("Failed to load: %s"), p);
291              (*gpx)->closed = TRUE;
292            } else
293              free(fname);
294        }        }
     }  
   
     /* use next gpx entry of this was loaded successfully */  
     if(*gpx)  
295        gpx = &((*gpx)->next);        gpx = &((*gpx)->next);
296        }
297    }    }
298    
299    gpx_busy_dialog_destroy(dialog);    gpx_busy_dialog_destroy(dialog);
# Line 308  void gconf_load_state(appdata_t *appdata Line 367  void gconf_load_state(appdata_t *appdata
367      appdata->search = SEARCH_NAME | SEARCH_ID;      appdata->search = SEARCH_NAME | SEARCH_ID;
368    
369    if(!appdata->image_path) {    if(!appdata->image_path) {
370    #ifdef USE_MAEMO
371        /* update cachelist by default */
372        appdata->cachelist_update = TRUE;
373    #endif
374    
375      /* use gps by default */      /* use gps by default */
376      appdata->use_gps = TRUE;      appdata->use_gps = TRUE;
# Line 326  void gconf_load_state(appdata_t *appdata Line 389  void gconf_load_state(appdata_t *appdata
389  #endif  #endif
390      appdata->image_path = strdup(DEFAULT_IMAGE_PATH);      appdata->image_path = strdup(DEFAULT_IMAGE_PATH);
391    
392        /* check if this path is actually accessible */
393        /* and change it to the current users home if not */
394        /* (this should only happen on scratchbox) */
395        if(!g_file_test(appdata->image_path, G_FILE_TEST_IS_DIR)) {
396          if(g_mkdir_with_parents(appdata->image_path, 0700) != 0) {
397            char *p = getenv("HOME");
398            if(!p) p = "/tmp/";
399    
400            appdata->image_path =
401              g_strdup_printf("%s%s%s", p,
402                              (p[strlen(p)-1]!='/')?"/":"",
403                              DEFAULT_IMAGE_PATH_HOME);
404            printf("using alt path %s\n", appdata->image_path);
405          }
406        }
407    
408    } else {    } else {
409      /* some versions old versions messed up the path */      /* some versions old versions messed up the path */
410      if(appdata->image_path[strlen(appdata->image_path)-1] != '/') {      if(appdata->image_path[strlen(appdata->image_path)-1] != '/') {

Legend:
Removed from v.34  
changed lines
  Added in v.167