# WineBottler Custom Verbs
#----------------------------------------------------------------

w_metadata depends apps \
    title="Dependency Walker" \
    publisher="Steve P. Miller" \
    year="2012" \
    media="download" \
    file1="depends22_x86.zip" \
    installed_exe1="C:/Dependency Walker/depends.exe" \
    homepage="http://www.dependencywalker.com"

load_depends()
{
    w_download http://www.dependencywalker.com/depends22_x86.zip 03d73abba0e856c81ba994505373fdb94a13b84eb29e6c268be1bf21b7417ca3
    w_try_unzip -d "$W_DRIVE_C/Dependency Walker" "$W_CACHE/$W_PACKAGE/$file1"
    chmod +x "$W_DRIVE_C/Dependency Walker/depends.exe"
}

#----------------------------------------------------------------

w_metadata reshacker apps \
    title="Resource Hacker" \
    publisher="Angus Johnson" \
    year="2009" \
    media="download" \
    file1="reshack_setup.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/Resource Hacker/ResHacker.exe" \
    homepage="http://www.angusj.com/resourcehacker"

load_reshacker()
{
    w_download http://www.angusj.com/resourcehacker/reshack_setup.exe bf461d7f5978336ce52b76ec55b53a61bdc68a59
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata wix apps \
    title="Windows Installer XML v3" \
    publisher="Microsoft" \
    year="2012" \
    media="download" \
    file1="Wix3.msi" \
    installed_exe1="$W_PROGRAMS_X86_WIN/Windows Installer XML v3/bin/candle.exe" \
    homepage="http://www.angusj.com/resourcehacker"

load_wix()
{
    w_download http://download.codeplex.com/Download?ProjectName=wix&DownloadId=119160&FileTime=129168985376800000&Build=18696 483ecddf7e871ce5a2a41706f2dd5ac708d4dc81
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata plc apps \
    title="profax Lerncenter" \
    publisher="profax Verlag AG" \
    year="2013" \
    media="download" \
    file1="profax_Lerncenter_Windows_Setup_1.4.5d102_mit_MULTIDINGSDA.msi" \
    installed_exe1="$W_PROGRAMS_X86_WIN/profax Lerncenter/profax Lerncenter.exe" \
    homepage="http://www.profax.ch"

load_plc()
{
    w_download http://www.profax.ch/downloads/nightly/profax_Lerncenter_Windows_Setup_1.4.5d102_mit_MULTIDINGSDA.msi dd5d7c8200ccf168776209ea8e0d2be69cf12225
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE msiexec /i $file1
}

#----------------------------------------------------------------

w_metadata teach2000 apps \
    title="Teach 2000" \
    publisher="digischool.nl" \
    year="2012" \
    media="download" \
    file1="teach853.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/Teach2000/Teach2000.exe" \
    homepage="http://www.teach2000.org"

load_teach2000()
{
    w_download http://www.digischool.nl/teach2000/teach853.exe c50edfa4d3c8f964035c8774eaa9f9696182eb2e
    w_call msxml4
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata shareholder2 apps \
    title="Shareholder R2" \
    publisher="ProSoft" \
    year="2013" \
    media="download" \
    file1="setup_shareholder.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/proSoft24/Shareholder/Shareholder.exe" \
    homepage="http://www.shareholder24.de"

load_shareholder2()
{
    w_download http://www.shareholder24.de/download/full/setup_shareholder.exe ad341f57ad86bacf173fd42db63459a7276ced29
    
    #w_call dcom98
    #w_call ie6
    #w_call gdiplus
    #w_call mfc42
    #w_call msxml6
    #w_call richtx32
    #w_call winxp
    
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata metatrader5 apps \
    title="Metatrader 5" \
    publisher="MetaQuotes Software Corp." \
    year="2013 (use Wine 4.0.x!)" \
    media="download" \
    file1="mt5setup.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/MetaTrader 5/terminal.exe" \
    homepage="http://www.metaquotes.net"

load_metatrader5()
{
    w_download https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe d437fd760587d24e094864215b86a441cc64ab897cace2b2a21a46614b3f4e36
    
#    w_call vcrun6
#    w_call ie8
    
    w_try_cd "$W_CACHE/$W_PACKAGE"
    # don't run mt5 after installation
    (
        sh << __EOF__
    WB_DONE=""
    while [[ "\$WB_DONE" == "" ]] ; do
        WB_DONE="\$(ps aux | grep '[t]erminal.exe *\$' | awk '{print \$2}')"
        sleep 1
    done
    kill \$WB_DONE
__EOF__
    ) &
    #$WINE $file1 ${W_OPT_UNATTENDED:+ /auto} &>/tmp/lmb.log  || exit 0
    $WINE $file1 || exit 0
}

#----------------------------------------------------------------

w_metadata buspro apps \
    title="BusPro" \
    publisher="BusPro AG" \
    year="2011" \
    media="download" \
    file1="inst83.exe" \
    installed_exe1="C:/BUSPRO/BUSPRO.exe" \
    homepage="http://www.buspro.ch"

load_buspro()
{
    w_download http://buspro.ch/fileadmin/files/05-downloads/software/inst83.exe 39147be2a50a6033d2c33bf281299926e08e9230
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata elster apps \
    title="Elster Formular" \
    publisher="Freistaat Bayern" \
    year="2011" \
    media="download" \
    file1="ElsterFormular-13.2.0.8623k.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/ElsterFormular/bin/elfostarter.exe" \
    homepage="http://www.elster.de"

load_elster()
{
    w_download https://download.elster.de/download/2011/ElsterFormular-13.2.0.8623k.exe 4abe07eb75f961f06bfcad2464961b6412055c2b
    w_call vcrun2008
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 --mode unattended
}

#----------------------------------------------------------------

w_metadata textpad apps \
    title="TextPad" \
    publisher="Helios Software Solutions" \
    year="2013" \
    media="download" \
    file1="setup.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/Textpad 7/TextPad.exe" \
    homepage="http://www.textpad.com"

load_textpad()
{
    w_download http://www.textpad.com/download/v70/txpeng709.zip 3876c56f7e8b5ab0154ced0918f751fda8e02760
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata divagis apps \
    title="DIVA-GIS" \
    publisher="Robert Hijmans" \
    year="2012" \
    media="download" \
    file1="setup.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/DIVA-GIS/diva.exe" \
    homepage="http://www.diva-gis.org"

load_divagis()
{
    w_download http://diva-gis.org/soft/diva75.zip a9d433ffa7290bafcd06ac87d36704b094e4ad80
    w_try_unzip "$W_CACHE/$W_PACKAGE"/diva75.zip
    
#    w_try_unzip -d "$W_PROGRAMS_X86_WIN/Dependency Walker" "$W_CACHE/$W_PACKAGE/$file1"
#    chmod +x "$W_PROGRAMS_X86_WIN/Dependency Walker/depends.exe"
    
    w_call mdac28
    w_call vcrun6
    
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata mp3tag apps \
    title="Mp3tag" \
    publisher="Florian Heidenreich" \
    year="2013" \
    media="download" \
    file1="mp3tagv265asetup.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/Mp3tag/Mp3tag.exe" \
    homepage="http://www.mp3tag.de/"

load_mp3tag()
{
    w_download http://download.mp3tag.de/mp3tagv265asetup.exe 5ae914e78fa62f13b678c58a86d2c576b7e74581
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata openmpt apps \
    title="Open ModPlug Tracker" \
    publisher="Olivier Lapicque" \
    year="2014" \
    media="download" \
    file1="OpenMPT-1.23.03.00-Setup.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/OpenMPT/mptrack.exe" \
    homepage="http://www.openmpt.org/"

load_openmpt()
{
    w_download http://openmpt.org/download_file.php?file=OpenMPT-1.23.03.00-Setup.exe 83f5134350c76420976c53a9fad1f0b064fb75c4 OpenMPT-1.23.03.00-Setup.exe
    w_try_cd "$W_CACHE/$W_PACKAGE"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
}

#----------------------------------------------------------------

w_metadata pubmed2xl apps \
    title="PubMed2XL" \
    publisher="Nitin Arora" \
    year="2013" \
    media="download" \
    file1="PubMed2XL-2.01-setup.exe" \
    installed_exe1="$W_PROGRAMS_X86_WIN/PubMed2XL-2.01/PubMed2XL.exe" \
    homepage="http://blog.humaneguitarist.org/projects/pubmed2xl"

load_pubmed2xl()
{
    w_download_to "${W_PROGRAMS_X86_UNIX}/" http://blog.humaneguitarist.org/uploads/PubMed2XL/PubMed2XL-2.01-setup.exe 74515586f4bc0f8a58cdb2186f5fa0247c3c450a0945fcaf7de1cd80d21b9e4c
    w_try_cd "${W_PROGRAMS_X86_UNIX}"
    w_try $WINE $file1 ${W_OPT_UNATTENDED:+ /S}
    w_try rm -f "$file1"
}