; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{AE67302E-F4EC-4F2E-ACF9-52F649F090AC}
AppName=ISIM messenger
AppVersion=1.29.5398
AppVerName=ISIM messenger 1.29
VersionInfoVersion=1.29.5398
AppPublisherURL=http://www.sczdavos.eu/
AppSupportURL=http://www.sczdavos.eu/isim-messenger-zdrojovy-kod
AppUpdatesURL=http://www.sczdavos.eu/isim-messenger
DefaultDirName={pf}\ISIM messenger
DefaultGroupName=ISIM messenger
AllowNoIcons=yes
OutputDir=C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\Setup
OutputBaseFilename=isim_messenger_setup
SetupIconFile=C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\isim_icon.ico
Compression=lzma
SolidCompression=yes
AppMutex=ISIM messenger,Global\ISIM messenger
AppCopyright=sczdavos [David Jančík]

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"

[Dirs]
Name: "{userappdata}\ISIM messenger";

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\ISIM - open source messenger.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\ISIM - open source messenger.exe.config"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\UniversalUpdater.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\isim_icon.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\change.log"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\graphics\*"; DestDir: "{app}\graphics"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\plugins\*"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\David\Dropbox\Programming\C#\projects\ISIM - open source messenger\ISIM - open source messenger\bin\x86\Release\sounds\*"; DestDir: "{app}\sounds"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\ISIM messenger"; Filename: "{app}\ISIM - open source messenger.exe"
Name: "{group}\{cm:ProgramOnTheWeb,ISIM messenger}"; Filename: "http://www.sczdavos.eu/isim-messenger"
Name: "{commondesktop}\ISIM messenger"; Filename: "{app}\ISIM - open source messenger.exe"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\ISIM messenger"; Filename: "{app}\ISIM - open source messenger.exe"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\ISIM - open source messenger.exe"; Description: "{cm:LaunchProgram,ISIM messenger}"; Flags: nowait postinstall skipifsilent

[Code]
function InitializeSetup(): Boolean;
var
  keyExists: boolean;
  SPversion: Cardinal;
  Result1: boolean;
  ErrorCode: integer;
begin
  Result := true;

  keyExists := RegQueryDWordValue(HKLM,'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5', 'SP', SPversion);
  
  if ((keyExists = false) or (SPversion = 0)) then
  begin
      Result := false;

      if((ExpandConstant('{language}')) = 'czech') then
      begin
          Result1 := MsgBox('Aplikace vyžaduje .NET Framework min. v.3.5 SP1, který ve vašem počítači nebyl nalezen. Přejete si jej nyní stánout? (bez něj aplikaci nelze spustit)',
                  mbConfirmation, MB_YESNO) = idYes;
      end else
      begin
          Result1 := MsgBox('This application needs .NET Framework min. v.3.5 SP1, which is not installed on your computer. Would you like to download it? (you cannot run this app without it)',
                  mbConfirmation, MB_YESNO) = idYes;
      end;

      if (Result1 = true) then
      begin
        ShellExec('open',
        'http://www.microsoft.com/download/en/details.aspx?id=22',
        '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
      end;
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  lang : String;
begin
  if CurStep = ssPostInstall then begin
    lang := 'en-GB';
    if((ExpandConstant('{language}')) = 'czech') then begin
      lang := 'cs-CZ';
    end;
    SaveStringToFile(ExpandConstant('{userappdata}\ISIM messenger\lang.ini'), ExpandConstant(lang), False);
  end;
end;

[Registry]
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "ISIM messenger"; Flags: dontcreatekey uninsdeletevalue