diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-27 16:59:55 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-27 16:59:55 +0300 |
commit | 57caccea67c62a5064f963430842cd81af5cf7bd (patch) | |
tree | 1bd471a6a3e9750356035f25cac4312ac4e27455 /src | |
parent | c025845a5b3b052c915a3e54b81d1c4ca473cb03 (diff) |
App: Upgrading to version 1.8.0
Removal of the embedded font library means that the UI strings may not have the right fonts available.
The app version is now recorded in prefs.cfg.
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -55,6 +55,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
55 | #include <the_Foundation/process.h> | 55 | #include <the_Foundation/process.h> |
56 | #include <the_Foundation/sortedarray.h> | 56 | #include <the_Foundation/sortedarray.h> |
57 | #include <the_Foundation/time.h> | 57 | #include <the_Foundation/time.h> |
58 | #include <the_Foundation/version.h> | ||
58 | #include <SDL.h> | 59 | #include <SDL.h> |
59 | 60 | ||
60 | #include <stdio.h> | 61 | #include <stdio.h> |
@@ -176,6 +177,7 @@ const iString *dateStr_(const iDate *date) { | |||
176 | 177 | ||
177 | static iString *serializePrefs_App_(const iApp *d) { | 178 | static iString *serializePrefs_App_(const iApp *d) { |
178 | iString *str = new_String(); | 179 | iString *str = new_String(); |
180 | appendCStr_String(str, "version app:" LAGRANGE_APP_VERSION "\n"); | ||
179 | #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) | 181 | #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) |
180 | appendFormat_String(str, "customframe arg:%d\n", d->prefs.customFrame); | 182 | appendFormat_String(str, "customframe arg:%d\n", d->prefs.customFrame); |
181 | #endif | 183 | #endif |
@@ -336,6 +338,7 @@ static void loadPrefs_App_(iApp *d) { | |||
336 | iUnused(d); | 338 | iUnused(d); |
337 | iBool haveCA = iFalse; | 339 | iBool haveCA = iFalse; |
338 | d->isLoadingPrefs = iTrue; /* affects which notifications get posted */ | 340 | d->isLoadingPrefs = iTrue; /* affects which notifications get posted */ |
341 | iVersion upgradedFromAppVersion = { 0 }; | ||
339 | /* Create the data dir if it doesn't exist yet. */ | 342 | /* Create the data dir if it doesn't exist yet. */ |
340 | makeDirs_Path(collectNewCStr_String(dataDir_App_())); | 343 | makeDirs_Path(collectNewCStr_String(dataDir_App_())); |
341 | iFile *f = new_File(prefsFileName_()); | 344 | iFile *f = new_File(prefsFileName_()); |
@@ -379,6 +382,11 @@ static void loadPrefs_App_(iApp *d) { | |||
379 | continue; /* can't change downloads directory */ | 382 | continue; /* can't change downloads directory */ |
380 | } | 383 | } |
381 | #endif | 384 | #endif |
385 | else if (equal_Command(cmd, "version")) { | ||
386 | /* This is a special command that lets us know which version we're upgrading from. | ||
387 | It was added in v1.8.0. */ | ||
388 | init_Version(&upgradedFromAppVersion, range_Command(cmd, "app")); | ||
389 | } | ||
382 | else { | 390 | else { |
383 | postCommandString_Root(NULL, &cmdStr); | 391 | postCommandString_Root(NULL, &cmdStr); |
384 | } | 392 | } |
@@ -391,10 +399,17 @@ static void loadPrefs_App_(iApp *d) { | |||
391 | setCACertificates_TlsRequest(&d->prefs.strings[caFile_PrefsString], | 399 | setCACertificates_TlsRequest(&d->prefs.strings[caFile_PrefsString], |
392 | &d->prefs.strings[caPath_PrefsString]); | 400 | &d->prefs.strings[caPath_PrefsString]); |
393 | } | 401 | } |
402 | iRelease(f); | ||
403 | /* Upgrade checks. */ | ||
404 | if (cmp_Version(&upgradedFromAppVersion, &(iVersion){ 1, 8, 0 }) < 0) { | ||
405 | /* When upgrading to v1.8.0, the old hardcoded font library is gone and that means | ||
406 | UI strings may not have the right fonts available for the UI to remain | ||
407 | usable. */ | ||
408 | postCommandf_App("uilang id:en"); | ||
409 | } | ||
394 | #if !defined (LAGRANGE_ENABLE_CUSTOM_FRAME) | 410 | #if !defined (LAGRANGE_ENABLE_CUSTOM_FRAME) |
395 | d->prefs.customFrame = iFalse; | 411 | d->prefs.customFrame = iFalse; |
396 | #endif | 412 | #endif |
397 | iRelease(f); | ||
398 | d->isLoadingPrefs = iFalse; | 413 | d->isLoadingPrefs = iFalse; |
399 | } | 414 | } |
400 | 415 | ||