51 |
/* style */ |
/* style */ |
52 |
{ "style", STORE_STRING, OFFSET(style) }, |
{ "style", STORE_STRING, OFFSET(style) }, |
53 |
|
|
54 |
|
/* map */ |
55 |
|
{ "no_icons", STORE_BOOL, OFFSET(no_icons) }, |
56 |
|
|
57 |
{ NULL, -1, -1 } |
{ NULL, -1, -1 } |
58 |
}; |
}; |
59 |
|
|
90 |
else |
else |
91 |
settings->password = strdup("<password>"); |
settings->password = strdup("<password>"); |
92 |
|
|
|
settings->wms_server = g_strdup("http://onearth.jpl.nasa.gov"); |
|
|
settings->wms_path = g_strdup("/wms.cgi"); |
|
|
|
|
93 |
settings->style = g_strdup(DEFAULT_STYLE); |
settings->style = g_strdup(DEFAULT_STYLE); |
94 |
|
|
95 |
/* ------ overwrite with settings from gconf if present ------- */ |
/* ------ overwrite with settings from gconf if present ------- */ |
137 |
} |
} |
138 |
} |
} |
139 |
|
|
140 |
|
/* restore wms server list */ |
141 |
|
char *key = g_strdup_printf("/apps/" PACKAGE "/wms/count"); |
142 |
|
GConfValue *value = gconf_client_get(client, key, NULL); |
143 |
|
if(value) { |
144 |
|
gconf_value_free(value); |
145 |
|
|
146 |
|
int i, count = gconf_client_get_int(client, key, NULL); |
147 |
|
g_free(key); |
148 |
|
|
149 |
|
wms_server_t **cur = &settings->wms_server; |
150 |
|
for(i=0;i<count;i++) { |
151 |
|
key = g_strdup_printf("/apps/" PACKAGE "/wms/name%d", i); |
152 |
|
char *name = gconf_client_get_string(client, key, NULL); |
153 |
|
g_free(key); |
154 |
|
key = g_strdup_printf("/apps/" PACKAGE "/wms/server%d", i); |
155 |
|
char *server = gconf_client_get_string(client, key, NULL); |
156 |
|
g_free(key); |
157 |
|
key = g_strdup_printf("/apps/" PACKAGE "/wms/path%d", i); |
158 |
|
char *path = gconf_client_get_string(client, key, NULL); |
159 |
|
g_free(key); |
160 |
|
|
161 |
|
/* apply valid entry to list */ |
162 |
|
if(name && server && path) { |
163 |
|
*cur = g_new0(wms_server_t, 1); |
164 |
|
(*cur)->name = name; |
165 |
|
(*cur)->server = server; |
166 |
|
(*cur)->path = path; |
167 |
|
cur = &(*cur)->next; |
168 |
|
} else { |
169 |
|
if(name) g_free(name); |
170 |
|
if(server) g_free(server); |
171 |
|
if(path) g_free(path); |
172 |
|
} |
173 |
|
} |
174 |
|
} else { |
175 |
|
g_free(key); |
176 |
|
|
177 |
|
/* add default server(s) */ |
178 |
|
printf("No WMS servers configured, adding default\n"); |
179 |
|
settings->wms_server = wms_server_get_default(); |
180 |
|
} |
181 |
|
|
182 |
return settings; |
return settings; |
183 |
} |
} |
184 |
|
|
220 |
g_free(key); |
g_free(key); |
221 |
st++; |
st++; |
222 |
} |
} |
223 |
|
|
224 |
|
/* store list of wms servers */ |
225 |
|
wms_server_t *cur = settings->wms_server; |
226 |
|
int count = 0; |
227 |
|
while(cur) { |
228 |
|
char *key = g_strdup_printf("/apps/" PACKAGE "/wms/name%d", count); |
229 |
|
gconf_client_set_string(client, key, cur->name, NULL); |
230 |
|
g_free(key); |
231 |
|
key = g_strdup_printf("/apps/" PACKAGE "/wms/server%d", count); |
232 |
|
gconf_client_set_string(client, key, cur->server, NULL); |
233 |
|
g_free(key); |
234 |
|
key = g_strdup_printf("/apps/" PACKAGE "/wms/path%d", count); |
235 |
|
gconf_client_set_string(client, key, cur->path, NULL); |
236 |
|
g_free(key); |
237 |
|
|
238 |
|
count++; |
239 |
|
cur = cur->next; |
240 |
|
} |
241 |
|
|
242 |
|
char *key = g_strdup_printf("/apps/" PACKAGE "/wms/count"); |
243 |
|
gconf_client_set_int(client, key, count, NULL); |
244 |
|
g_free(key); |
245 |
} |
} |
246 |
|
|
247 |
void settings_free(settings_t *settings) { |
void settings_free(settings_t *settings) { |
248 |
store_t *st = store; |
store_t *st = store; |
249 |
|
|
250 |
/* this is only required because wms_xxx is not yet stored properly */ |
wms_servers_free(settings->wms_server); |
251 |
g_free(settings->wms_server); |
|
|
g_free(settings->wms_path); |
|
|
|
|
252 |
while(st->key) { |
while(st->key) { |
253 |
void **ptr = ((void*)settings) + st->offset; |
void **ptr = ((void*)settings) + st->offset; |
254 |
|
|