ui/common/properties.c

changeset 94
7fdf1489b82f
parent 79
483d7342b439
equal deleted inserted replaced
93:5ee236155955 94:7fdf1489b82f
160 160
161 fclose(file); 161 fclose(file);
162 free(path); 162 free(path);
163 } 163 }
164 164
165 void uic_store_app_properties() { 165 int uic_store_app_properties() {
166 char *path = ui_configfile("application.properties"); 166 char *path = ui_configfile("application.properties");
167 if(!path) { 167 if(!path) {
168 return; 168 return 1;
169 } 169 }
170 170
171 FILE *file = fopen(path, "w"); 171 FILE *file = fopen(path, "w");
172 if(!file) { 172 if(!file) {
173 fprintf(stderr, "Ui Error: Cannot open properties file: %s\n", path); 173 fprintf(stderr, "Ui Error: Cannot open properties file: %s\n", path);
174 free(path); 174 free(path);
175 return; 175 return 1;
176 } 176 }
177 177
178 int ret = 0;
178 if(ucx_properties_store(application_properties, file)) { 179 if(ucx_properties_store(application_properties, file)) {
179 fprintf(stderr, "Ui Error: Cannot store application properties.\n"); 180 fprintf(stderr, "Ui Error: Cannot store application properties.\n");
181 ret = 1;
180 } 182 }
181 183
182 fclose(file); 184 fclose(file);
183 free(path); 185 free(path);
184 } 186
185 187 return ret;
186 188 }
187 char* ui_get_property(char *name) { 189
190
191 const char* ui_get_property(const char *name) {
188 return cxMapGet(application_properties, name); 192 return cxMapGet(application_properties, name);
189 } 193 }
190 194
191 void ui_set_property(char *name, char *value) { 195 void ui_set_property(const char *name, const char *value) {
192 cxMapPut(application_properties, name, value); 196 cxMapPut(application_properties, name, (char*)value);
193 } 197 }
194 198
195 void ui_set_default_property(char *name, char *value) { 199 const char* ui_set_default_property(const char *name, const char *value) {
196 char *v = cxMapGet(application_properties, name); 200 const char *v = cxMapGet(application_properties, name);
197 if(!v) { 201 if(!v) {
198 cxMapPut(application_properties, name, value); 202 cxMapPut(application_properties, name, (char*)value);
199 } 203 v = value;
200 } 204 }
201 205 return v;
206 }
207
208 int ui_properties_store(void) {
209 return uic_store_app_properties();
210 }
202 211
203 212
204 static char* uic_concat_path(const char *base, const char *p, const char *ext) { 213 static char* uic_concat_path(const char *base, const char *p, const char *ext) {
205 size_t baselen = strlen(base); 214 size_t baselen = strlen(base);
206 215

mercurial