On Thursday 22 January 2009 15:13, [email protected] wrote:
> Author: Zero3
> Date: 2009-01-22 15:13:07 +0000 (Thu, 22 Jan 2009)
> New Revision: 25210
> 
> Added:
>    trunk/apps/wininstaller/BuildAll.cmd
>    trunk/apps/wininstaller/bin/
>    trunk/apps/wininstaller/compiler/
>    trunk/apps/wininstaller/compiler/AutoHotkeySC_Normal.bin
>    trunk/apps/wininstaller/compiler/AutoHotkeySC_VistaElevated.bin
>    trunk/apps/wininstaller/src_freenethelpers/
>    trunk/apps/wininstaller/src_freenethelpers/FreenetLauncher.ahk
>    trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk
>    trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk
>    trunk/apps/wininstaller/src_freenetinstaller/
>    trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk
>    trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Header.png
>    trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Icon.ico
>    
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Include_FileInstalls.inc
>    
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Include_Helpers.inc
>    
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Include_Info.inc
>    
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Uninstaller.ahk
>    trunk/apps/wininstaller/src_freenetinstaller/files_bundle/
>    trunk/apps/wininstaller/src_freenetinstaller/files_bundle/Ntrights.exe
>    trunk/apps/wininstaller/src_freenetinstaller/files_bundle/RemProf.exe
>    
trunk/apps/wininstaller/src_freenetinstaller/files_bundle/jre-online-installer.exe
>    trunk/apps/wininstaller/src_freenetinstaller/files_bundle/netuser.exe
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/
>    
trunk/apps/wininstaller/src_freenetinstaller/files_install/LICENSE.Freenet
>    
trunk/apps/wininstaller/src_freenetinstaller/files_install/LICENSE.Mantissa
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/bin/
>    
trunk/apps/wininstaller/src_freenetinstaller/files_install/bin/wrapper-windows-x86-32.exe
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/freenet.ico
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/lib/
>    
trunk/apps/wininstaller/src_freenetinstaller/files_install/lib/wrapper-windows-x86-32.dll
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/plugins/
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/seednodes.fref
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/startssl.pem
>    trunk/apps/wininstaller/src_freenetinstaller/files_install/wrapper.conf
> Log:
> Initial commit of native Windows installer
> 
...
> Added: trunk/apps/wininstaller/src_freenethelpers/FreenetLauncher.ahk
> ===================================================================
...
> +;
> +; Try browser: FireFox
> +;
> +RegRead, _FFVersion, HKEY_LOCAL_MACHINE, SOFTWARE\Mozilla\Mozilla Firefox, 
CurrentVersion
> +
> +If (!ErrorLevel && _FFVersion <> "")
> +{
> +     RegRead, _FFPath, HKEY_LOCAL_MACHINE, SOFTWARE\Mozilla\Mozilla 
Firefox\%_FFVersion%\Main, PathToExe
> +
> +     If (!ErrorLevel && _FFPath <> "" && FileExist(_FFPath))
> +     {
> +             Run, %_FFPath% "%_URL%", , UseErrorLevel
> +             ExitApp, 0
> +     }
> +}
> +
> +;
> +; Try browser: Internet Explorer
> +;
> +IfExist, %A_ProgramFiles%\Internet Explorer\iexplore.exe
> +{
> +     Run, %A_ProgramFiles%\Internet Explorer\iexplore.exe "%_URL%", , 
UseErrorLevel
> +     ExitApp, 0
> +}
> +
> +;
> +; No usable browser found
> +;
> +PopupErrorMessage("Freenet Launcher was unable to find a supported 
browser.`n`nPlease install one of the supported browsers, or 
manually`nnavigate to the URL inside freenet.url.dat.`n`nFreenet Launcher 
supports the following browsers:`n- Mozilla FireFox`n- Internet Explorer (not 
recommended)")
> +ExitApp, 1

Can't we just fall back to using the system browser? We should not give the 
impression that we support Internet Explorer in any way, shape or form! 
Trying Firefox makes sense, of course.
...
> Added: trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk
> ===================================================================
> --- trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk         
>                 
(rev 0)
> +++ trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller.ahk 
2009-01-22 15:13:07 UTC (rev 25210)
> @@ -0,0 +1,393 @@
> +;
> +; Windows Freenet Installer by Zero3 (zero3 that-a-thingy zero3 
that-dot-thingy dk) - http://freenetproject.org/
> +;
> +
> +;
> +; Don't-touch-unless-you-know-what-you-are-doing settings
> +;
> +#NoEnv                                                               ; 
> Recommended for performance and compatibility with future 
AutoHotkey releases
> +#NoTrayIcon                                                  ; We won't need 
> this...
> +#SingleInstance      ignore                                          ; Only 
> allow one instance of at any given time 
(theoretically, if we allowed multiple, we could run into some temp files 
problems)
> +#Include FreenetInstaller_Include_Info.inc                   ; Include 
> version and build 
info (which should be updated by the compiler bot before compiling this 
installer)
> +
> +SendMode, Input                                                      ; 
> Recommended for new scripts due to its superior 
speed and reliability
> +SetFormat, FLOAT, 0.0                                                ; 
> Remove trailing zeroes on floats. We won't 
need the precision and it looks stupid with numbers printed with 27 trailing 
zeroes
> +StringCaseSense, Off                                         ; Treat A-Z as 
> equal to a-z when comparing 
strings. Useful when dealing with folders, as Windows treat them as equals.
> +_FontSize := 9                                                       ; Our 
> font size. Changing this *might* mess up some of 
the margin calculations! See comment for _TextHeight calculation below as 
well.
> +Gui, +OwnDialogs                                             ; Make 
> messageboxes "stick" to the main GUI
> +
> +;
> +; Customizable settings
> +;
> +_GuiWidth := 450+10+10                                               ; Main 
> GUI width. Should be the same size as 
the header image + default element margins (used for the GUI window itself)
> +_StandardMargin := 12                                                ; Our 
> standard margin. Must be at least 8 px.
> +_ButtonWidth := 100                                          ; Width of our 
> buttons
> +
> +_RequiredJRE := 1.5                                          ; Java version 
> required by Freenet. If not found, 
user will be asked to upgrade/install via the bundled online installer
> +_UsedFreeSpace := _Inc_InstallSize+256                               ; What 
> we actually need. 
Installation size + default datastore size
> +_RequiredFreeSpace := _UsedFreeSpace+512                     ; In MB, how 
> much free space do 
we require to install? What we actually use + enough free space for Windows 
to continue operating (in case install dir is on system drive... and to not 
block the drive in general)
> +_InternalPathLength := 75                                    ; Length of 
> longest path within the Freenet 
installation. Installation will refuse to continue if install path + this 
number exceeds 255 (FAT32 and NTFS limit)
> +
> +_DefaultInstallDir = %A_ProgramFiles%\Freenet                        ; 
> Default installation 
directory
> +_DefaultInstallStartMenuShortcuts := 1                               ; 
> Install start menu shortcut(s) 
by default?
> +_DefaultInstallDesktopShortcuts := 1                         ; Install 
> desktop shorctu(s) by 
default?
> +_DefaultBrowseAfterInstall := 1                                      ; 
> Browse Freenet after installation by 
default?
> +)
> +_InternalPathLength := 75                                    ; Length of 
> longest path within the Freenet 
installation. Installation will refuse to continue if install path + this 
number exceeds 255 (FAT32 and NTFS limit)
> +
> +_DefaultInstallDir = %A_ProgramFiles%\Freenet                        ; 
> Default installation 
directory
> +_DefaultInstallStartMenuShortcuts := 1                               ; 
> Install start menu shortcut(s) 
by default?
> +_DefaultInstallDesktopShortcuts := 1                         ; Install 
> desktop shorctu(s) by 
default?
> +_DefaultBrowseAfterInstall := 1                                      ; 
> Browse Freenet after installation by 
default?
> +
> +;
> +; General init stuff
> +;
> +FileRemoveDir, %A_Temp%\FreenetInstaller, 1                                  
>                         ; Remove any old temp 
dir
> +FileCreateDir, %A_Temp%\FreenetInstaller                                     
>                         ; Create a new temp dir
> +If (ErrorLevel)
> +{
> +     MsgBox, 16, Freenet Installer fatal error, Freenet Installer was not 
> able 
to unpack necessary installation files 
to:`n`n%A_Temp%\FreenetInstaller`n`nPlease make sure that Freenet Installer 
has full access to the system's temporary files folder. ; 16 = Icon Hand 
(stop/error)
> +     ExitApp
> +}
> +SetWorkingDir, %A_Temp%\FreenetInstaller                                     
>                         ; Switch to our new temp 
dir as working dir. *NO* FileInstall lines before this!
> +
> +FileInstall, 
FreenetInstaller_Icon.ico, %A_WorkingDir%\FreenetInstaller_Icon.ico             
        ; 
Unpack our small icon
> +Menu, Tray, Icon, FreenetInstaller_Icon.ico                                  
>                         ; Set tray and GUI icon 
to our icon. Must be done before any Gui command to work
> +
> +Gui, Font, s%_FontSize%, MS sans serif                                       
>                                 ; As default font may vary 
(and thereby mess up custom positioning and layout), we should force a 
specific

Localisation may also mess stuff up. Many languages use twice the width as 
english does to represent the same information. You need to ensure that the 
UI works no matter what language is being used.

> +
> +_StandardMargin2 := _StandardMargin-8
> +Gui, Margin, , %_StandardMargin2%                            ; 0=8px (which 
> is minimum?). (A margin 
of 2px seems to be used outside groupboxes. Need to figure out why that is.)
> +
> +_TextHeight := 2+_FontSize+2                                 ; 9px has 2px 
> built-in margin on top on 
bottom, making a normal line 13px high (except groupbox header text on 
classic theme, which seem to have 3px on top and 1px on bottom)
> +_GuiWidth2 := _GuiWidth-10-10                                        ; 
> GuiWidth - element left margin - 
element right margin (used for main elements such as header image, groupboxes 
and headlines)
> +_GBTopMargin := _TextHeight+(_StandardMargin/2)                      ; 
> Pixels from y 
coordinate of start of groupbox whereafter content should begin
> +_GBBottomMargin := 2+(_StandardMargin/2)                     ; Bottom margin 
> inside a 
groupbox
> +_VSpacingFromGBBottom := _GBBottomMargin+_StandardMargin     ; Used when 
> extra 
vertical spacing after a groupbox is wanted
> +_GBHorMargin := 2+_StandardMargin                            ; Horizontal 
> margin for text within a 
groupbox (2px groupbox border + our standard margin)
> +_GuiWidth3 := _GuiWidth2-_GBHorMargin-_GBHorMargin           ; GuiWidth2 - 
> groupbox 
left margin - groupbox right margin (used for groupbox elements)
> +_MixLineTextPush := (24/2)-(_TextHeight/2)                   ; Used for 
> vertically 
centering text on the same lines as one or more buttons. 
(Buttonheight/2)-(Textheight/2)
> +
> +;
...
> +;
> +; Create our custom user
> +;
> +_CustomUserPassword := GenerateRandomNumberString(12)                        
>                                 ; According to 
the old installer, 12 chars is max. to avoid warnings about 
backwards-compatability. The password itself is apparently also needed to run 
services under a custom account.
> +RunWait, %comspec% /c "net user 
Freenet%_InstallSuffix% %_CustomUserPassword% /add /comment:"Freenet service 
user. Please do not 
delete!" /expires:never /passwordchg:no /fullname:"Freenet%_InstallSuffix% 
user"", , Hide UseErrorLevel

On the old installer we tried 3 different patterns in the hope of finding a 
password that is acceptable to the user's security policy ...
> +
> +If (A_OSVersion = "WIN_VISTA")
> +{
> +     RunWait, %comspec% /c "icacls "%_InstallDir%" /E /T /C /G 
Freenet%_InstallSuffix%:F", , Hide UseErrorLevel
> +}
> +Else
> +{
> +     RunWait, %comspec% /c "cacls "%_InstallDir%" /E /T /C /G 
Freenet%_InstallSuffix%:F", , Hide UseErrorLevel
> +}
> +
> +RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows 
NT\CurrentVersion\Winlogon\SpecialAccounts\UserList, Freenet%_InstallSuffix%, 
0
...
> Added: 
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Include_Helpers.inc
> ===================================================================
...
> +
> +     RegExMatch(_InstallDir, "i)([a-z]:\\).+", _InstallDrive)                
>                         ; Check for a 
valid drive. If found, store in _InstallDrive1 (subpattern match number 1 = 
array 1)
> +     If (ErrorLevel || _InstallDrive1 = "")
> +     {
> +             GuiControl, +cRed, _cInstallDirStatusText
> +             GuiControl, Text, _cInstallDirStatusText, Invalid install path!
> +             GuiControl, +Disabled, _cInstallButton
> +     }
> +     Else if (StrLen(_InstallDir) + _InternalPathLength > 255)
> +     {
> +             GuiControl, +cRed, _cInstallDirStatusText
> +             GuiControl, Text, _cInstallDirStatusText, Invalid install path! 
> (Too long 
for file system to handle)
> +             GuiControl, +Disabled, _cInstallButton
> +     }
> +     Else
> +     {
> +             DriveSpaceFree, _InstallDriveFreeSpace, %_InstallDrive1%
> +             If (_InstallDriveFreeSpace < _RequiredFreeSpace)
> +             {
> +                     GuiControl, +cRed, _cInstallDirStatusText
> +                     GuiControl, Text, _cInstallDirStatusText, Not enough 
> free space on 
installation drive!
> +                     GuiControl, +Disabled, _cInstallButton
> +             }
> +             Else IfExist, %_InstallDir%\freenet.jar

IMHO this is not reliable. If freenet auto-updates, it alternates between 
freenet.jar and freenet.jar.new, you should check for both (we don't delete 
the old one however, so it should be reasonable...)

You should probably check whether the directory is empty.

> +
> +TestPortAvailability(_Port)
> +{
> +     global
> +
> +     VarSetCapacity(wsaData, 32)
> +     _Result := DllCall("Ws2_32\WSAStartup", "UShort", 0x0002, "UInt", 
&wsaData)                               ; Request Winsock 2.0 (0x0002)
> +
> +     if (ErrorLevel)
> +     {
> +             MsgBox, 16, Freenet Installer fatal error, Freenet Installer 
> was not able 
to create a Winsock 2.0 socket`nfor port availability testing. ; 16 = Icon 
Hand (stop/error)
> +             Exit()
> +     }
> +     Else If (_Result)                                                       
>                                 ; Non-zero, which means it failed (most 
Winsock functions return 0 upon success)
> +     {
> +             _Error := DllCall("Ws2_32\WSAGetLastError")
> +             DllCall("Ws2_32\WSACleanup")
> +             MsgBox, 16, Freenet Installer fatal error, Freenet Installer 
> was not able 
to create a Winsock 2.0 socket`nfor port availability testing 
(Error: %_Error%). ; 16 = Icon Hand (stop/error)
> +             Exit()
> +     }
> +
> +     AF_INET = 2
> +     SOCK_STREAM = 1
> +     IPPROTO_TCP = 6
> +
> +     _Socket := DllCall("Ws2_32\socket", "Int", AF_INET, "Int", 
SOCK_STREAM, "Int", IPPROTO_TCP)
> +     if (_Socket = -1)
> +     {
> +             _Error := DllCall("Ws2_32\WSAGetLastError")
> +             DllCall("Ws2_32\WSACleanup")
> +             MsgBox, 16, Freenet Installer fatal error, Freenet Installer 
> was not able 
to create a Winsock 2.0 socket`nfor port availability testing 
(Error: %_Error%). ; 16 = Icon Hand (stop/error)
> +             Exit()
> +     }
> +
> +     SizeOfSocketAddress = 16
> +     VarSetCapacity(SocketAddress, SizeOfSocketAddress)
> +     InsertInteger(2, SocketAddress, 0, AF_INET)
> +     InsertInteger(DllCall("Ws2_32\htons", "UShort", _Port), SocketAddress, 
> 2, 
2)
> +     InsertInteger(DllCall("Ws2_32\inet_addr", "Str", "127.0.0.1"), 
SocketAddress, 4, 4)
> +
> +     If DllCall("Ws2_32\connect", "UInt", _Socket, "UInt", 
&SocketAddress, "Int", SizeOfSocketAddress)
> +     {
> +             _Available := 1                                                 
>                                 ; DllCall returned non-zero, e.g. fail - 
> which 
means port is most likely free
> +     }
> +     Else
> +     {
> +             _Available := 0
> +     }
> +
> +     DllCall("Ws2_32\WSACleanup")                                            
>                                 ; Do a cleanup (including closing of 
any open sockets)
> +     return _Available
> +}
> +
> +InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
> +{
> +     global
> +
> +     Loop, %pSize%                                                           
>                                 ; Copy each byte in the integer into the 
structure as raw binary data.
> +     {
> +             DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, 
> "UInt", 
1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF)
> +     }
> +}

Ewwwwwwwwwwwww!
> +
> +GenerateRandomNumberString(_RandomNumberLength)
> +{
> +     global
> +
> +     _RandomNumberString =                                                   
>                                 ; Empty variable
> +
> +     Loop, %_RandomNumberLength%
> +     {
> +             Random, _RandomNumber, 0, 9
> +             
> +             _RandomNumberString = %_RandomNumberString%%_RandomNumber%
> +     }
> +
> +     return _RandomNumberString
> +}
> 
> Added: 
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Include_Info.inc
> ===================================================================
> --- 
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Include_Info.inc  
                        
(rev 0)
> +++ 
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Include_Info.inc  
2009-01-22 15:13:07 UTC (rev 25210)
> @@ -0,0 +1,15 @@
> +;
> +; Windows Freenet Installer - Include file - Build info
> +;
> +; This file contains build info variables used for displaying info in the 
installer. These values should
> +; be updated by a build script before compiling the installer. Will be 
included directly into the
> +; installer (at the top) at compile time.
> +;
> +; _Inc_FreenetVersion - (string) Version of Freenet the installer contains.
> +; _Inc_FreenetBuild - (string) Build of Freenet the installer contains.
> +; _Inc_InstallSize - (float) In MB, size of all files to be installed.
> +;
> +
> +_Inc_FreenetVersion = 0.7
> +_Inc_FreenetBuild = #1204
> +_Inc_InstallSize := 9.04
> 
> Added: 
trunk/apps/wininstaller/src_freenetinstaller/FreenetInstaller_Uninstaller.ahk
> ===================================================================
...
> +
> +;
> +; Remove our custom user
> +;
> +Progress, , Removing custom user...
> +
> +FileInstall, files_bundle\RemProf.exe, %A_WorkingDir%\RemProf.exe            
>                         ; 
Extract 3rd party "RemProf" tool from 
http://www.ctrl-alt-del.com.au/CAD_TSUtils.htm. Freeware, but not 
open-source :(. Removes the profile folder and its registry entry of 
specified user
> +RunWait, %A_WorkingDir%\RemProf.exe Freenet%_InstallSuffix%, , Hide 
UseErrorLevel
> +FileDelete, %A_WorkingDir%\RemProf.exe

Grrrr!
> +
> +RunWait, %comspec% /c "net user Freenet%_InstallSuffix% /delete", , Hide 
UseErrorLevel
> +
> +Progress, 6
> +
> +;
> +; Done!
> +;
> +Progress, Off
> +MsgBox, 64, Freenet uninstaller, Freenet has been uninstalled!       ; 64 = 
> Icon 
Asterisk (info)
> +

Attachment: pgpapcfMKQOK1.pgp
Description: PGP signature

_______________________________________________
Devl mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to