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 196 by harbaum, Thu Nov 19 07:39:00 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) },
87    { "cachelist_update", STORE_BOOL,   OFFSET(cachelist_update) },  #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  #endif
94    
95      { "gt_username",      STORE_STRING, OFFSET(gt.username) },
96      { "gt_password",      STORE_STRING, OFFSET(gt.password) },
97      { "gt_filename",      STORE_STRING, OFFSET(gt.filename) },
98      { "gt_distance",      STORE_FLOAT,  OFFSET(gt.distance) },
99      { "gt_lat",           STORE_FLOAT,  OFFSET(gt.lat) },
100      { "gt_lon",           STORE_FLOAT,  OFFSET(gt.lon) },
101      { "gt_flags",         STORE_INT,    OFFSET(gt.flags) },
102    
103    { NULL, -1, -1 }    { NULL, -1, -1 }
104  };  };
105    
# Line 127  char *gconf_restore_closed_name(appdata_ Line 142  char *gconf_restore_closed_name(appdata_
142  void gconf_save_state(appdata_t *appdata) {  void gconf_save_state(appdata_t *appdata) {
143    int entries = 0;    int entries = 0;
144    
145      /* free proxy settings */
146      if(appdata->proxy) {
147        proxy_t *proxy = appdata->proxy;
148    
149        if(proxy->authentication_password) g_free(proxy->authentication_password);
150        if(proxy->authentication_user)     g_free(proxy->authentication_user);
151        if(proxy->host)                    g_free(proxy->host);
152        if(proxy->ignore_hosts)            g_free(proxy->ignore_hosts);
153    
154        g_free(proxy);
155        appdata->proxy = NULL;
156      }
157    
158    gpx_t *gpx = appdata->gpx;    gpx_t *gpx = appdata->gpx;
159    while(gpx) {    while(gpx) {
160      char str[128];      char str[128];
# Line 165  void gconf_save_state(appdata_t *appdata Line 193  void gconf_save_state(appdata_t *appdata
193        if((char*)(*ptr)) {        if((char*)(*ptr)) {
194          gconf_client_set_string(appdata->gconf_client, key, (char*)(*ptr), NULL);          gconf_client_set_string(appdata->gconf_client, key, (char*)(*ptr), NULL);
195        }        }
196          g_free((char*)(*ptr));
197          *ptr = NULL;
198        break;        break;
199    
200      case STORE_BOOL:      case STORE_BOOL:
# Line 202  void gconf_load_state(appdata_t *appdata Line 232  void gconf_load_state(appdata_t *appdata
232    appdata->manual_goto.lat = appdata->manual_goto.lon = NAN;    appdata->manual_goto.lat = appdata->manual_goto.lon = NAN;
233    appdata->gps.lat = appdata->gps.lon = NAN;    appdata->gps.lat = appdata->gps.lon = NAN;
234    
235      appdata->gt.lat = appdata->gt.lon = NAN;
236    
237      /* ------------- get proxy settings -------------------- */
238      if(gconf_client_get_bool(appdata->gconf_client,
239                               PROXY_KEY "use_http_proxy", NULL)) {
240        proxy_t *proxy = appdata->proxy = g_new0(proxy_t, 1);
241    
242        /* get basic settings */
243        proxy->host = gconf_client_get_string(appdata->gconf_client,
244                                              PROXY_KEY "host", NULL);
245        proxy->port = gconf_client_get_int(appdata->gconf_client,
246                                           PROXY_KEY "port", NULL);
247        proxy->ignore_hosts =
248          gconf_client_get_string(appdata->gconf_client,
249                                  PROXY_KEY "ignore_hosts", NULL);
250    
251        /* check for authentication */
252        proxy->use_authentication =
253          gconf_client_get_bool(appdata->gconf_client,
254                                PROXY_KEY "use_authentication", NULL);
255    
256        if(proxy->use_authentication) {
257          proxy->authentication_user =
258            gconf_client_get_string(appdata->gconf_client,
259                                    PROXY_KEY "authentication_user", NULL);
260          proxy->authentication_password =
261            gconf_client_get_string(appdata->gconf_client,
262                                    PROXY_KEY "authentication_password", NULL);
263        }
264      }
265    
266    int i, entries = gconf_client_get_int(appdata->gconf_client,    int i, entries = gconf_client_get_int(appdata->gconf_client,
267                                   GCONF_KEY_CNT, NULL);                                   GCONF_KEY_CNT, NULL);
268    
# Line 212  void gconf_load_state(appdata_t *appdata Line 273  void gconf_load_state(appdata_t *appdata
273      char str[128];      char str[128];
274      snprintf(str, sizeof(str), GCONF_KEY_GPX, i);      snprintf(str, sizeof(str), GCONF_KEY_GPX, i);
275      char *fname = gconf_client_get_string(appdata->gconf_client, str, NULL);      char *fname = gconf_client_get_string(appdata->gconf_client, str, NULL);
   
276      if(fname) {      if(fname) {
277        /* check if there's a valid name stored for this file. */        /* check if there's a valid name stored for this file. */
278        /* if yes it's a "closed" file */        /* if yes it's a "closed" file */
# Line 228  void gconf_load_state(appdata_t *appdata Line 288  void gconf_load_state(appdata_t *appdata
288          else          else
289            *gpx = gpx_parse(dialog, fname);            *gpx = gpx_parse(dialog, fname);
290    
291          free(fname);          if(!*gpx) {
292              /* restoring the gpx file failed, mark it as unusable, but save */
293              /* its presence for later use */
294    
295              /* create "closed" entry to remember this file for next */
296              /* load attempt */
297              *gpx = g_new0(gpx_t, 1);
298              (*gpx)->filename = fname;
299              char *p = fname;
300              if(strrchr(fname, '/'))
301                p = strrchr(fname, '/')+1;
302    
303              (*gpx)->name = g_strdup_printf(_("Failed to load: %s"), p);
304              (*gpx)->closed = TRUE;
305            } else
306              free(fname);
307        }        }
     }  
   
     /* use next gpx entry of this was loaded successfully */  
     if(*gpx)  
308        gpx = &((*gpx)->next);        gpx = &((*gpx)->next);
309        }
310    }    }
311    
312    gpx_busy_dialog_destroy(dialog);    gpx_busy_dialog_destroy(dialog);
# Line 308  void gconf_load_state(appdata_t *appdata Line 380  void gconf_load_state(appdata_t *appdata
380      appdata->search = SEARCH_NAME | SEARCH_ID;      appdata->search = SEARCH_NAME | SEARCH_ID;
381    
382    if(!appdata->image_path) {    if(!appdata->image_path) {
383    #ifdef USE_MAEMO
384        /* update cachelist by default */
385        appdata->cachelist_update = TRUE;
386    #endif
387    
388      /* use gps by default */      /* use gps by default */
389      appdata->use_gps = TRUE;      appdata->use_gps = TRUE;
# Line 326  void gconf_load_state(appdata_t *appdata Line 402  void gconf_load_state(appdata_t *appdata
402  #endif  #endif
403      appdata->image_path = strdup(DEFAULT_IMAGE_PATH);      appdata->image_path = strdup(DEFAULT_IMAGE_PATH);
404    
405        /* check if this path is actually accessible */
406        /* and change it to the current users home if not */
407        /* (this should only happen on scratchbox) */
408        if(!g_file_test(appdata->image_path, G_FILE_TEST_IS_DIR)) {
409          if(g_mkdir_with_parents(appdata->image_path, 0700) != 0) {
410            char *p = getenv("HOME");
411            if(!p) p = "/tmp/";
412    
413            appdata->image_path =
414              g_strdup_printf("%s%s%s", p,
415                              (p[strlen(p)-1]!='/')?"/":"",
416                              DEFAULT_IMAGE_PATH_HOME);
417            printf("using alt path %s\n", appdata->image_path);
418          }
419        }
420    
421    } else {    } else {
422      /* some versions old versions messed up the path */      /* some versions old versions messed up the path */
423      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.196