Hi,

Please find attached a patch with a new set of enhancement/fixes for the NSIS installer:

* new installer page allowing the user to delete MapSource cache
* fix for maps with a space in the overview name
* fix issues with custom versions of installer.nsi

  Thanks,

N.
Index: resources/installer/installer_template.nsi
===================================================================
--- resources/installer/installer_template.nsi  (revision 1904)
+++ resources/installer/installer_template.nsi  (working copy)
@@ -5,11 +5,17 @@
 ; Includes
 !include "MUI2.nsh"
 
+; Variables
+Var Dialog
+Var CheckBox
+Var CACHE_CLEANUP
+
 ; Installer pages
 !define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
 !insertmacro MUI_PAGE_WELCOME
-!insertmacro MUI_PAGE_LICENSE ${MAPNAME}_license.txt
+!insertmacro MUI_PAGE_LICENSE "${MAPNAME}_license.txt"
 !insertmacro MUI_PAGE_DIRECTORY
+Page custom CacheCleanupPage CacheCleanupPageLeave
 !insertmacro MUI_PAGE_INSTFILES
 !insertmacro MUI_PAGE_FINISH
 
@@ -21,10 +27,15 @@
 !insertmacro MUI_LANGUAGE "English"
 !insertmacro MUI_LANGUAGE "French"
 
+; English
 LangString AlreadyInstalled ${LANG_ENGLISH} "${INSTALLER_NAME} is already 
installed. $\n$\nClick `OK` to remove the previous version or `Cancel` to 
cancel this upgrade."
+LangString CacheCleanup ${LANG_ENGLISH} "Cleanup MapSource cache."
+LangString CacheCleanupSub ${LANG_ENGLISH} "Checking this box will cleanup 
MapSource cache for the map installed."
+; French
 LangString AlreadyInstalled ${LANG_FRENCH} "${INSTALLER_NAME} est déjà 
installé. $\n$\nAppuyez sur `OK` pour retirer la version précédente ou sur 
`Annuler` pour annuler cette mise à jour."
+LangString CacheCleanup ${LANG_FRENCH} "Nettoyer le cache de MapSource."
+LangString CacheCleanupSub ${LANG_FRENCH} "Cocher cette case forcera le 
nettoyage du cache de MapSource pour cette carte."
 
-
 ; Reservefiles
 !insertmacro MUI_RESERVEFILE_LANGDLL ;Language selection dialog
 
@@ -72,6 +83,29 @@
 !insertmacro MUI_UNGETLANGUAGE
 FunctionEnd
 
+Function CacheCleanupPage
+  !insertmacro MUI_HEADER_TEXT "$(CacheCleanup)" "$(CacheCleanupSub)"
+
+  nsDialogs::Create /NOUNLOAD 1018
+  Pop $Dialog
+  
+  ${If} $Dialog == error
+       Abort
+  ${EndIf}
+
+  ${NSD_CreateCheckBox} 0 0 100% 12u "$(CacheCleanup)"
+  Pop $CheckBox  
+
+  nsDialogs::Show  
+
+FunctionEnd
+
+Function CacheCleanupPageLeave
+
+       ${NSD_GetState} $CheckBox $CACHE_CLEANUP
+
+FunctionEnd
+
 Section "MainSection" SectionMain
 ; Files to be installed
   SetOutPath "$INSTDIR"
@@ -98,6 +132,12 @@
   WriteRegStr HKLM 
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_KEY}" 
"UninstallString" "$INSTDIR\Uninstall.exe"
   WriteRegDWORD HKLM 
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_KEY}" "NoModify" 1
   
+; Create desktop shortcuts if asked
+  StrCmp $CACHE_CLEANUP ${BST_CHECKED} CacheCleanup NoCacheCleanup
+  CacheCleanup:
+  Delete "$APPDATA\GARMIN\MapSource\TileCache\${FAMILY_ID}*"
+  NoCacheCleanup:
+  
 SectionEnd
 
 Section "Uninstall"
Index: src/uk/me/parabola/mkgmap/combiners/NsisBuilder.java
===================================================================
--- src/uk/me/parabola/mkgmap/combiners/NsisBuilder.java        (revision 1904)
+++ src/uk/me/parabola/mkgmap/combiners/NsisBuilder.java        (working copy)
@@ -23,7 +23,6 @@
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Locale;
 
 import uk.me.parabola.imgfmt.Utils;
 import uk.me.parabola.mkgmap.CommandArgs;
@@ -36,7 +35,7 @@
        private String licenseFilename;
        private String outputDir;
        private String familyName;
-       private String id;
+       private String familyId;
        private int productId;
 
        private boolean hasIndex;
@@ -46,16 +45,14 @@
        private String typName;
 
        public void init(CommandArgs args) {
-               int familyId = args.get("family-id", 
CommandArgs.DEFAULT_FAMILYID);
+               int familyIdInt = args.get("family-id", 
CommandArgs.DEFAULT_FAMILYID);
                productId = args.get("product-id", 1);
 
                baseFilename = args.get("overview-mapname", "osmmap");
                familyName = args.get("family-name", "OSM map");
 
-               String tmpId = Integer.toHexString(0x10000 | familyId);
+               familyId = Integer.toHexString(0x10000 | 
familyIdInt).substring(1,5);
 
-               id = tmpId.substring(3, 5) + tmpId.substring(1, 3);
-
                nsisFilename = baseFilename + ".nsi";
                licenseFilename = baseFilename + "_license.txt";
                
@@ -119,7 +116,7 @@
                        else if (strLine.contains("INSERT_REMOVED_FILES_HERE"))
                                writeRemovedFiles(pw);
                        else 
-                               pw.format(Locale.ROOT, strLine + "\n");
+                               pw.print(strLine + "\n");
                    }
                } catch (IOException e) {
                        System.err.println("Could not write NSIS file");
@@ -129,52 +126,54 @@
        }
        
        private void writeDefines(PrintWriter pw) {
-                       pw.format(Locale.ROOT, "!define DEFAULT_DIR 
\"C:\\Garmin\\Maps\\%s\"\n", familyName);
-                       pw.format(Locale.ROOT, "!define INSTALLER_DESCRIPTION 
\"%s\"\n", familyName);
-                       pw.format(Locale.ROOT, "!define INSTALLER_NAME 
\"%s\"\n", familyName);
-                       pw.format(Locale.ROOT, "!define MAPNAME \"%s\"\n", 
baseFilename);
-                       pw.format(Locale.ROOT, "!define PRODUCT_ID \"%s\"\n", 
productId);
-                       pw.format(Locale.ROOT, "!define REG_KEY \"%s\"\n", 
familyName);
+                       pw.format("!define DEFAULT_DIR 
\"C:\\Garmin\\Maps\\%s\"\n", familyName);
+                       pw.format("!define INSTALLER_DESCRIPTION \"%s\"\n", 
familyName);
+                       pw.format("!define INSTALLER_NAME \"%s\"\n", 
familyName);
+                       pw.format("!define MAPNAME \"%s\"\n", baseFilename);
+                       pw.format("!define FAMILY_ID \"%s\"\n", familyId);
+                       pw.format("!define PRODUCT_ID \"%s\"\n", productId);
+                       pw.format("!define REG_KEY \"%s\"\n", familyName);
                        if (hasIndex)
-                               pw.format(Locale.ROOT, "!define INDEX\n");
+                               pw.print("!define INDEX\n");
                        if (hasTyp)
-                               pw.format(Locale.ROOT, "!define TYPNAME 
\"%s\"\n", typName);
+                               pw.format("!define TYPNAME \"%s\"\n", typName);
        }
 
        private void writeRegBin(PrintWriter pw) {
+               String regId = familyId.substring(2, 4) + familyId.substring(0, 
2);
                // Ideally we should have a define for the family value but 
NSIS won't allow "hexadecimal" variables
-               pw.format(Locale.ROOT, "  WriteRegBin HKLM 
\"SOFTWARE\\Garmin\\MapSource\\Families\\${REG_KEY}\" \"ID\" %s\n", id);
+               pw.format("  WriteRegBin HKLM 
\"SOFTWARE\\Garmin\\MapSource\\Families\\${REG_KEY}\" \"ID\" %s\n", regId);
 }      
                        
        private void writeAddedFiles(PrintWriter pw) {
-                       pw.format(Locale.ROOT, "  File \"${MAPNAME}.img\"\n");
+                       pw.print("  File \"${MAPNAME}.img\"\n");
                        if (hasIndex) {
-                               pw.format(Locale.ROOT, "  File 
\"${MAPNAME}_mdr.img\"\n");
-                               pw.format(Locale.ROOT, "  File 
\"${MAPNAME}.mdx\"\n");
+                               pw.print("  File \"${MAPNAME}_mdr.img\"\n");
+                               pw.print("  File \"${MAPNAME}.mdx\"\n");
                        }
                        if (hasTyp)
-                               pw.format(Locale.ROOT, "  File \"%s\"\n", 
typName);
+                               pw.format("  File \"%s\"\n", typName);
 
-                       pw.format(Locale.ROOT, "  File \"${MAPNAME}.tdb\"\n");
+                       pw.print("  File \"${MAPNAME}.tdb\"\n");
                        for (String file : mapList)
-                               pw.format(Locale.ROOT, "  File \"%s.img\"\n", 
file);
+                               pw.format("  File \"%s.img\"\n", file);
        }
 
 
 
        private void writeRemovedFiles(PrintWriter pw) {
-                       pw.format(Locale.ROOT, "  Delete 
\"$INSTDIR\\${MAPNAME}.img\"\n");
+                       pw.print("  Delete \"$INSTDIR\\${MAPNAME}.img\"\n");
                        if (hasIndex) {
-                               pw.format(Locale.ROOT, "  Delete 
\"$INSTDIR\\${MAPNAME}_mdr.img\"\n");
-                               pw.format(Locale.ROOT, "  Delete 
\"$INSTDIR\\${MAPNAME}.mdx\"\n");
+                               pw.print("  Delete 
\"$INSTDIR\\${MAPNAME}_mdr.img\"\n");
+                               pw.print("  Delete 
\"$INSTDIR\\${MAPNAME}.mdx\"\n");
                        }
                        if (hasTyp)
-                               pw.format(Locale.ROOT, "  Delete 
\"$INSTDIR\\%s\"\n", typName);
-                       pw.format(Locale.ROOT, "  Delete 
\"$INSTDIR\\${MAPNAME}.tdb\"\n");
+                               pw.format("  Delete \"$INSTDIR\\%s\"\n", 
typName);
+                       pw.print("  Delete \"$INSTDIR\\${MAPNAME}.tdb\"\n");
                        for (String file : mapList) {
-                               pw.format(Locale.ROOT, "  Delete 
\"$INSTDIR\\%s.img\"\n", file);
+                               pw.format("  Delete \"$INSTDIR\\%s.img\"\n", 
file);
                        }
-                       pw.format(Locale.ROOT, "  Delete 
\"$INSTDIR\\Uninstall.exe\"\n");
+                       pw.print("  Delete \"$INSTDIR\\Uninstall.exe\"\n");
        }
 
 
@@ -204,10 +203,10 @@
                        
                    String strLine;
                    while ((strLine = br.readLine()) != null)   {
-                       pw.format(Locale.ROOT, strLine + "\n");
+                       pw.print(strLine + "\n");
                    }
        
-                       pw.format(Locale.ROOT, "Map created with mkgmap-r" + 
Version.VERSION +"\n");
+                       pw.print("Map created with mkgmap-r" + Version.VERSION 
+"\n");
                } catch (IOException e) {
                        System.err.println("Could not write license file");
                } finally {
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to