From 306dd6757b1bc79db15d211e065cbc3bc5623d1a Mon Sep 17 00:00:00 2001 From: ezequiel Date: Tue, 23 Feb 2016 09:47:12 -0300 Subject: [PATCH] Modificado o codigo do modulo update para codigo nativo do proprio inno setup, descartando todo código python. --- Makefile | 6 +++--- install/devel_install.bat | 89 ----------------------------------------------------------------------------------------- install/inno setup/user_instalBK.bat | 83 ----------------------------------------------------------------------------------- install/inno setup/user_install.bat | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ install/inno setup/user_install.iss | 62 ++++++++++++++++++++++++++++++++++++++++++++------------------ install/inno setup/user_install2.iss | 51 --------------------------------------------------- plugin/corePlugin.cpp | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------ plugin/corePlugin.h | 13 +++++++++++-- update/DownloadVlibrasDicionario.iss | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/DownloadVlibrasPlayer.iss | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/Makefile | 35 ----------------------------------- update/icon/UnityPlayer.png | Bin 0 -> 2287 bytes update/icon/avatar.bmp | Bin 0 -> 154542 bytes update/icon/bdrag.ico | Bin 0 -> 82726 bytes update/icon/icon_vlibras.ico | Bin 0 -> 99678 bytes update/icon/player.bmp | Bin 0 -> 7654 bytes update/icon/small2.bmp | Bin 0 -> 9294 bytes update/include/pyVlibrasUpdate.h | 31 ------------------------------- update/include/vlibrasUpdate.h | 30 ++++++++++++++++++++++++++++++ update/it_download/it_download.iss | 318 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/it_download/languages/itd_ptbr.ini | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ update/src/pyVlibrasUpdate.cpp | 103 ------------------------------------------------------------------------------------------------------- update/src/vlibrasUpdate.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ update/unzip.iss | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/updatePython/DownloadFile.py | 58 ---------------------------------------------------------- update/updatePython/Util.py | 75 --------------------------------------------------------------------------- update/updatePython/VlibrasCheckVersion.py | 28 ---------------------------- update/updatePython/frameUpdate.py | 94 ---------------------------------------------------------------------------------------------- update/updatePython/update.py | 113 ----------------------------------------------------------------------------------------------------------------- update/updatePython/version.py | 102 ------------------------------------------------------------------------------------------------------ update/updatePython/writeSucessInstall.py | 26 -------------------------- update/vlibrasDictInstall.cpp | 61 ------------------------------------------------------------- update/vlibrasJsonParse.iss | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/vlibrasPlayerInstall.cpp | 61 ------------------------------------------------------------- update/writeSucessInstall.cpp | 61 ------------------------------------------------------------- 35 files changed, 1284 insertions(+), 1124 deletions(-) delete mode 100644 install/devel_install.bat delete mode 100644 install/inno setup/user_instalBK.bat create mode 100644 install/inno setup/user_install.bat delete mode 100644 install/inno setup/user_install2.iss create mode 100644 update/DownloadVlibrasDicionario.iss create mode 100644 update/DownloadVlibrasPlayer.iss delete mode 100644 update/Makefile create mode 100644 update/icon/UnityPlayer.png create mode 100644 update/icon/avatar.bmp create mode 100644 update/icon/bdrag.ico create mode 100644 update/icon/icon_vlibras.ico create mode 100644 update/icon/player.bmp create mode 100644 update/icon/small2.bmp delete mode 100644 update/include/pyVlibrasUpdate.h create mode 100644 update/include/vlibrasUpdate.h create mode 100644 update/it_download/it_download.iss create mode 100644 update/it_download/languages/itd_ptbr.ini delete mode 100644 update/src/pyVlibrasUpdate.cpp create mode 100644 update/src/vlibrasUpdate.cpp create mode 100644 update/unzip.iss delete mode 100644 update/updatePython/DownloadFile.py delete mode 100644 update/updatePython/Util.py delete mode 100644 update/updatePython/VlibrasCheckVersion.py delete mode 100644 update/updatePython/frameUpdate.py delete mode 100644 update/updatePython/update.py delete mode 100644 update/updatePython/version.py delete mode 100644 update/updatePython/writeSucessInstall.py delete mode 100644 update/vlibrasDictInstall.cpp create mode 100644 update/vlibrasJsonParse.iss delete mode 100644 update/vlibrasPlayerInstall.cpp delete mode 100644 update/writeSucessInstall.cpp diff --git a/Makefile b/Makefile index 2c45d30..fbea484 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,10 @@ OUT = testLibras # Arquivos de implementação -FILES = src\pyTradutor.cpp src\pyClip.cpp update\src\pyVlibrasUpdate.cpp +FILES = src\pyTradutor.cpp src\pyClip.cpp update\src\vlibrasUpdate.cpp #Headers -INCLUDES = include\pyTradutor.h include\pyClip.h update\include\pyVlibrasUpdate.h +INCLUDES = include\pyTradutor.h include\pyClip.h update\include\vlibrasUpdate.h CLEAN_OBJ = del -q *.obj @@ -51,7 +51,7 @@ plugin-x64: $(FILES) $(INCLUDES) #Gera .obj da classe de teste testLibras: $(FILES) $(INCLUDES) src\testLibras.cpp - $(CC) -c -FotestLibras -EHsc Main.cpp $(FILES) $(CFLAGS) $(LFLAGS) + $(CC) -c -o testLibras -EHsc $(FILES) $(CFLAGS) $(LFLAGS) #Gera.obj do pyTradutor pyTradutor: src\pyTradutor.cpp src\pyTradutor.h diff --git a/install/devel_install.bat b/install/devel_install.bat deleted file mode 100644 index c365813..0000000 --- a/install/devel_install.bat +++ /dev/null @@ -1,89 +0,0 @@ -::############################## Instalador VLibras ############################ -::# # -::# Bruno Santos # -::# brunosantos@lavid.ufpb.br # -::# # -::############################################################################## - -::Define Título da janela do prompt -TITLE Instalador VLibras-Core Windows - -::Limpa a tela -CLS - -::Desabilita mensagens -@ECHO off - -ECHO ############### Instalando VLibras ############### - -::################# Variáveis de Ambiente ################# -:VAR -ECHO Deseja Exportar as variaveis de ambiente: (S - N) - -::Solicita valor do usuário -SET /p valor=--^> - -IF /I %valor% == n GOTO NO_VAR -IF /I %valor% == s (ECHO OK!) ELSE (GOTO VAR) - -ECHO. -ECHO Exportando Variaveis de Ambiente: -ECHO. - -::Váriaveis Permanentes (Sistema) -ECHO AELIUS_DATA -SETX AELIUS_DATA %HOMEPATH%\vlibras-libs\aelius_data /M - -ECHO NLTK_DATA -SETX NLTK_DATA %HOMEPATH%\vlibras-libs\nltk_data /M - -ECHO HUNPOS_TAGGER -SETX HUNPOS_TAGGER %HOMEPATH%\vlibras-libs\bin\hunpos-tag.exe /M - -ECHO PYTHONPATH -SETX PYTHONPATH %HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages;%HOMEPATH%\vlibras-libs;%HOMEPATH%\vlibras-translate\src;%HOMEPATH%\vlibras-core-win\Clipboard /M - -SETX "PATH" "%PATH%";%HOMEPATH%\vlibras-libs\bin;%HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages /M - -::Código executa a partir desse ponto caso o usuário não precise configurar as variáveis de ambiente -:NO_VAR - -::################# Instalação do Python ################# -:PYTHON -ECHO Deseja Instalar o Python-2.7.9: (S - N) - -SET /p valor=--^> -IF /I %valor% == n GOTO NO_PYTHON -IF /I %valor% == s (ECHO OK!) ELSE (GOTO PYTHON) - -msiexec /i python-2.7.9.msi /passive - -::Código executa a partir desse ponto caso o usuário não precise Instalar o Python -:NO_PYTHON - -::################# Instalação do Aelius ################# -:TRADUTOR -ECHO Deseja Instalar o VLibras Tradutor (S - N) - -SET /p valor=--^> -IF /I %valor% == n GOTO END -IF /I %valor% == s (ECHO OK!) ELSE (GOTO TRADUTOR) - -pyyaml.exe -numpy.exe -matplotlib.exe -nltk.exe - -IF NOT EXIST C:"\Program Files (x86)\7-Zip" (msiexec /i 7zip.msi /passive) - -ECHO 7-Zip instalado com sucesso! - -COPY C:"\Program Files (x86)\7-Zip\7z.exe" %SYSTEMROOT%\System32 - -::################# Instalação do VLibras ################# - -ECHO Extraindo Arquivos... -7z x -o%HOMEPATH% vlibras-libs.zip vlibras-libs - -:END -ECHO VLibras Tradutor instalado com sucesso! diff --git a/install/inno setup/user_instalBK.bat b/install/inno setup/user_instalBK.bat deleted file mode 100644 index c233a65..0000000 --- a/install/inno setup/user_instalBK.bat +++ /dev/null @@ -1,83 +0,0 @@ -::############################## Instalador VLibras ############################ -::# # -::# Bruno Santos # -::# brunosantos@lavid.ufpb.br # -::# # -::############################################################################## - -::Define Título da janela do prompt -TITLE Instalador VLibras-Core Windows - -::Limpa a tela -CLS - -::Desabilita mensagens -@ECHO off - -ECHO ############### Instalando VLibras ############### - -::################# Variáveis de Ambiente ################# -ECHO Exportando Variaveis de Ambiente: - -ECHO AELIUS_DATA -SETX AELIUS_DATA %HOMEDRIVE%\vlibras-libs\aelius_data /M - -ECHO NLTK_DATA -SETX NLTK_DATA %HOMEDRIVE%\vlibras-libs\nltk_data /M - -ECHO HUNPOS_TAGGER -SETX HUNPOS_TAGGER %HOMEDRIVE%\vlibras-libs\bin\hunpos-tag.exe /M - -ECHO PYTHONPATH -SETX PYTHONPATH %HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages;%HOMEDRIVE%\vlibras-libs;%HOMEDRIVE%\vlibras-libs\vlibras-translate\src;%HOMEDRIVE%\vlibras-libs\Clipboard /M - -@echo off -set path_value=%PATH% - -If NOT "%path_value%"=="%path_value:vlibras=%" ( - echo ok -) else ( - SETX "PATH" "%PATH%";%HOMEDRIVE%\vlibras-libs\bin;%HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages /M -) - -::################# Instalação do Python ################# -msiexec /i python-2.7.9.msi /passive -ECHO OK - -::################# Dependências ################# -c:\Python27\python.exe pip-6.0.8-py2.py3-none-any.whl/pip install pip-6.0.8-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install PyYAML-3.11-cp27-none-win32.whl -ECHO OK - -c:\Python27\Scripts\pip install numpy-1.9.2+mkl-cp27-none-win32.whl -ECHO OK - -c:\Python27\Scripts\pip install six-1.9.0-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install pyparsing-2.0.3-py2-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install pytz-2014.10-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install python_dateutil-2.4.0-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install matplotlib-1.4.3-cp27-none-win32.whl -ECHO OK - -c:\Python27\Scripts\pip install nltk-3.0.2-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install future-0.14.3-py2-none-any.whl -ECHO OK - -::################# HUNPOS.PY & DATA.PY ############################# -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\hunpos.py %homedrive%\Python27\Lib\site-packages\nltk\tag\ /y -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\data.py %homedrive%\Python27\Lib\site-packages\nltk /y -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\nltk_tgrep.py %homedrive%\Python27\Lib\site-packages /y - -ECHO VLibras Tradutor instalado com sucesso! diff --git a/install/inno setup/user_install.bat b/install/inno setup/user_install.bat new file mode 100644 index 0000000..a9f8033 --- /dev/null +++ b/install/inno setup/user_install.bat @@ -0,0 +1,132 @@ +::############################## Instalador VLibras ############################ +::# # +::# Bruno Santos # +::# brunosantos@lavid.ufpb.br +::# Ezequiel Silva # +::# ezequielsilva@lavid.ufpb.br # +::# # +::############################################################################## + +::Define Título da janela do prompt +TITLE Instalador VLibras Windows + +::Limpa a tela +CLS + +::Desabilita mensagens +@ECHO off + +ECHO ############### Instalando VLibras ############### + + + + +set PATH_VLIBRAS="%HOMEDRIVE%\VLibras" + + + +::################# Variáveis de Ambiente ################# +ECHO Exportando Variaveis de Ambiente: + +ECHO AELIUS_DATA +SETX AELIUS_DATA %PATH_VLIBRAS%\aelius_data /M + +ECHO NLTK_DATA +SETX NLTK_DATA %PATH_VLIBRAS%\nltk_data /M + +ECHO HUNPOS_TAGGER +SETX HUNPOS_TAGGER %PATH_VLIBRAS%\bin\hunpos-tag.exe /M + +ECHO TRANSLATE_DATA +SETX TRANSLATE_DATA %PATH_VLIBRAS%\translate\data /M + +ECHO PYTHONPATH +SETX PYTHONPATH %HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages;%PATH_VLIBRAS%;%PATH_VLIBRAS%\bin;%PATH_VLIBRAS%\translate\src;%PATH_VLIBRAS%\Clipboard;%PATH_VLIBRAS%\update;%PATH_VLIBRAS%\nltk_data;%PATH_VLIBRAS%\Aelius /M + +@echo off +set path_value=%PATH% + +::ECHO PATH +::SETX PATH %PATH_VLIBRAS%\bin;%HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages /M + + + + + +SET MYPATHCOPY=%PATH% +SET PATH_COPY= +SET ENCONTRADO="NO" + + +:search +for /f "delims=; tokens=1,2*" %%p in ("%MYPATHCOPY%") do ( + + ECHO.%%~p | FIND /I "ibras" >Nul && ( + Echo %%~p + ) || ( + + ECHO.%%~p | FIND /I "Python27" >Nul && ( + Echo %%~p + ) || ( + SET "PATH_COPY=%%~p;%PATH_COPY%" + ) + ) + + SET MYPATHCOPY=%%~q;%%~r +) + +if "%MYPATHCOPY%"==";" goto done; +goto search; + +:done + + +SETX "PATH" "%PATH_COPY%;%%PYTHONPATH%%" /M +SETX "PATH" "%PATH_COPY%;%%PYTHONPATH%%" + +echo %PATH% + +::################# Instalação do Python ################# +::msiexec /i python-2.7.9.msi /passive +::ECHO OK + +::################# Dependências ################# + + +c:\Python27\python.exe pip-6.0.8-py2.py3-none-any.whl/pip install pip-6.0.8-py2.py3-none-any.whl +ECHO OK + + +c:\Python27\Scripts\pip install PyYAML-3.11-cp27-none-win32.whl +ECHO OK + +c:\Python27\Scripts\pip install numpy-1.9.2+mkl-cp27-none-win32.whl +ECHO OK + +c:\Python27\Scripts\pip install six-1.9.0-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install pyparsing-2.0.3-py2-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install pytz-2014.10-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install python_dateutil-2.4.0-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install matplotlib-1.4.3-cp27-none-win32.whl +ECHO OK + +c:\Python27\Scripts\pip install nltk-3.0.2-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install future-0.14.3-py2-none-any.whl +ECHO OK + +::################# HUNPOS.PY & DATA.PY ############################# +COPY %PATH_VLIBRAS%\nltk_data\hunpos.py %homedrive%\Python27\Lib\site-packages\nltk\tag\ /y +COPY %PATH_VLIBRAS%\nltk_data\data.py %homedrive%\Python27\Lib\site-packages\nltk /y +COPY %PATH_VLIBRAS%\nltk_data\nltk_tgrep.py %homedrive%\Python27\Lib\site-packages /y + +ECHO VLibras Tradutor instalado com sucesso! diff --git a/install/inno setup/user_install.iss b/install/inno setup/user_install.iss index acd796d..6d172c7 100644 --- a/install/inno setup/user_install.iss +++ b/install/inno setup/user_install.iss @@ -6,7 +6,7 @@ ;##################################################################### #define MyAppName "VLibras" -#define MyAppVersion "3.0.0" +#define MyAppVersion "4.0.0" #define MyAppPublisher "LAViD" #define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" #define MyAppExeName "VlibrasPlayer.exe" @@ -14,24 +14,25 @@ [Setup] -AppId={{9AA2CD86-F136-47FA-9EFE-474057F0C45F} +AppId= {{84B73167-EF7F-42BB-9CCD-E1A8E2C53659-vlibras} +;AppId={{B3EAE3FB-FD9B-4877-8430-B7F5C2940EC2} AppName={#MyAppName} AppVersion={#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} -DefaultDirName={pf}\VLibras +DefaultDirName={sd}\VLibras DisableDirPage=yes DefaultGroupName={#MyAppName} -OutputBaseFilename=vlibras_instalador_3.0.0 +OutputBaseFilename=vlibras_instalador_4.0.0 DisableProgramGroupPage=yes -OutputDir="C:\Users\ezequiel\Desktop\vlibras_installer_3.0.0" -SetupIconFile="C:\Users\ezequiel\Desktop\user_install\icons\icon_vlibras.ico" +OutputDir="vlibras_installer_4.0.0" +SetupIconFile="icon\icon_vlibras.ico" Compression=lzma SolidCompression=yes -WizardImageFile = "C:\Users\ezequiel\Desktop\user_install\icons\avatar.bmp" -WizardSmallImageFile = "C:\Users\ezequiel\Desktop\user_install\icons\player.bmp" +WizardImageFile = "user_install\icons\avatar.bmp" +WizardSmallImageFile = "user_install\icons\player.bmp" @@ -43,27 +44,52 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 [Files] - -;Source: "C:\Users\ezequiel\Desktop\dotnetfx45_full_x86_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; -Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs - - + ;Source: itdownload.dll; Flags: dontcopy; DestDir: {tmp} + ;Source: "Player\*"; DestDir: "{app}\Player"; Flags: ignoreversion recursesubdirs createallsubdirs; + ;Source: "wx_3.0.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; + Source: "python-2.7.9.msi"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; + Source: "user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; + Source: "required\*"; DestDir: "{tmp}\required"; Flags: ignoreversion recursesubdirs createallsubdirs deleteafterinstall [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; IconFilename: "{app}\icons\icon_vlibras.ico" Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" -Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\icons\icon_vlibras.ico" -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Parameters: -single-instance; Tasks: desktopicon; IconFilename: "{app}\icons\icon_vlibras.ico" +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" [Run] -Filename: {app}\required\user_install.bat; Flags: runhidden; StatusMsg: Finalizando Instalação... -Filename: {app}\update\vlibrasDictUp.exe; StatusMsg: Instalando atualização... +Filename: msiexec ; Flags: runhidden; Parameters: /i {tmp}\python-2.7.9.msi /passive; StatusMsg: Instalando python-2.7.9... +Filename: {tmp}\required\user_install.bat; Flags: runhidden; StatusMsg: Instalando dependências... +;Filename: {tmp}\wx_3.0.exe; Flags: runhidden; Parameters: /VERYSILENT /SUPPRESSMSGBOXES /NORESTART; StatusMsg: Instalando wx +;Filename: {app}\update\bin\writeSucess.exe; Flags: runhidden; StatusMsg: Finalizando +;Filename: {app}\update\bin\vlibrasDictUp.exe; Flags: runhidden; StatusMsg: Instalando atualização + + + +[Code] + +procedure CurStepChanged(CurStep: TSetupStep); + +var + ErrorCode: Integer; +begin - + if CurStep = ssDone then + begin + //chama o instalador baixado + if not ShellExec('', ExpandConstant('{app}\update\bin\DicionarioUpdate.exe'), '', '', SW_SHOW, ewNoWait, ErrorCode) then + begin + MsgBox('Houve um erro ao Instalar Dicionário ', mbError, MB_OK); + end; + end; + + + +end; diff --git a/install/inno setup/user_install2.iss b/install/inno setup/user_install2.iss deleted file mode 100644 index 5b1e38a..0000000 --- a/install/inno setup/user_install2.iss +++ /dev/null @@ -1,51 +0,0 @@ -;################### INSTALADOR VLIBRAS WINDOWS ###################### -;# Bruno Santos # -;# brunosantos@lavid.ufpb.br # -;##################################################################### - -#define MyAppName "VLibras" -#define MyAppVersion "beta" -#define MyAppPublisher "LAViD" -#define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" -#define MyAppExeName "Playerx86.exe" - -[Setup] -AppId={{84B73167-EF7F-42BB-9CCD-E1A8E2C53659} -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -DefaultDirName={pf}\vlibras-libs -DisableDirPage=yes -DefaultGroupName={#MyAppName} -DisableProgramGroupPage=yes -OutputDir="C:\Users\ezequiel\Desktop\output" -OutputBaseFilename=VLibras Installer -SetupIconFile="C:\Users\ezequiel\vlibras-libs\icons\icon_vlibras.ico" -Compression=lzma -SolidCompression=yes -WizardImageFile = "C:\Users\ezequiel\vlibras-libs\icons\avatar.bmp" -WizardSmallImageFile = "C:\Users\ezequiel\vlibras-libs\icons\small2.bmp" - -[Languages] -Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}" -Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 - -[Files] -Source: "C:\vlibras-libs\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs - -[Icons] -Name: "{group}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; IconFilename: "{app}\icons\icon_vlibras.ico" -Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" -Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" -Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\icons\icon_vlibras.ico" -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" - -[Run] -Filename: {app}\vlibras-libs\required\user_install.bat; Flags: runhidden - diff --git a/plugin/corePlugin.cpp b/plugin/corePlugin.cpp index a5023c8..658cf48 100644 --- a/plugin/corePlugin.cpp +++ b/plugin/corePlugin.cpp @@ -8,21 +8,79 @@ #include "corePlugin.h" #include + using namespace std; + ofstream logfile; + - extern "C" +//Assinatura do método itd_downloadfile utilizado na dll +typedef int (WINAPI*download)(char * arg1, char * arg2); +download itd_downloadfile; + +//usado para representar as versoes tanto da api quanto local +typedef struct Versions { + char versionDicionario[7]={'0','0','0','0','0','0','\0'}; + char versionPlayer[4]={'0','0','0','\0'}; +} Version; + +// usado para carregar os jsons de versoes +Version loadVersion(char* pPathTempJson) +{ + Version version; + string line_in_str; + ifstream file_versionApi; + int i; + try + { + file_versionApi.open(pPathTempJson); + while ( getline (file_versionApi, line_in_str) ) + { + if(strstr(line_in_str.c_str(), "playerVersion")){ + i = 0; + for (char & c : line_in_str) + if(isdigit(c)) + version.versionPlayer[i++]=c; + version.versionPlayer[i]='\0'; + } + else if(strstr(line_in_str.c_str(), "dictionaryVersion")){ + + i = 0; + for (char & c : line_in_str) + if(isdigit(c)) + version.versionDicionario[i++]=c; + version.versionDicionario[i]='\0'; + } + } + file_versionApi.close(); + } + catch (exception e) + { + + } + return version; +} + - + extern "C" +{ + EXPORT_API int coreInitialize() { //Objeto usado para traduzir tradutor = new PyTradutor(); - update = new PyVlibrasUpdate(); + update = new VlibrasUpdate(); //Objeto usado para copiar texto da área de transferência clipboard.bdragOn(); - + logfile.open ("C:\\VLibras\\update\\log.txt"); + pPathTempJson ="c:\\VLibras\\update\\VLibrasVersionApi.json"; + pPathVlibrasJson = "c:\\VLibras\\version.json"; + //Carrega a dll + hDLL1 = LoadLibrary("c:\\VLibras\\update\\plugins\\itdownload.dll"); + //Relaciona método local com o método implementado na dll + itd_downloadfile=(download)GetProcAddress((HMODULE)hDLL1, "itd_downloadfile"); + return 1; } @@ -38,7 +96,7 @@ using namespace std; EXPORT_API int coreUpdateInstall_player() { - update->install("c:\\vlibras-libs\\update\\vlibrasPlayerUp.exe","NULL"); + update->install("C:\\VLibras\\update\\bin\\PlayerUpdate.exe","NULL"); return 1; } @@ -46,7 +104,7 @@ using namespace std; EXPORT_API int coreUpdateInstall_dict() { - update->install("c:\\vlibras-libs\\update\\bin\\vlibrasDictUp.exe","NULL"); + update->install("C:\\VLibras\\update\\bin\\DicionarioUpdate.exe","NULL"); return 1; } @@ -54,37 +112,50 @@ using namespace std; EXPORT_API int coreUpdateCheck() { - - string line_in_str; - ifstream file_version; - int return_int = -1; - try - { - update->checkExe("C:\\Python27\\python.exe c:\\vlibras-libs\\update\\py\\VlibrasCheckVersion.pyc","check"); - - clock_t time_end; + + if (!hDLL1){ + logfile <<__TIMESTAMP__<< " --> Não carregou dll itdownload.dll.\n"; + return -1; + } + + //faz download do json de versao + int codDownload = itd_downloadfile("http://vlibras.lavid.ufpb.br/api/dicionario/0.0.0_0.0.0?type=json",pPathTempJson); + + clock_t time_end; time_end = clock() + 3000 * CLOCKS_PER_SEC/1000; while (clock() < time_end); - - - file_version.open("c:\\vlibras-libs\\update\\version\\version.txt"); + + //verifica se existe os dois arquivos de versao + if(!ifstream(pPathTempJson) || !ifstream(pPathVlibrasJson) || (codDownload > 0 )){ + + logfile <<__TIMESTAMP__ <<" --> codDownload: "< atoi(versionLocal.versionPlayer)) + return 1; + else if(atoi(versionApi.versionDicionario)> atoi(versionLocal.versionDicionario)) + return 2; + else + return 0; + logfile <<__TIMESTAMP__ <<" --> codDownload2: "< #include +#include + using namespace std; @@ -38,7 +40,14 @@ extern "C" PyClip clipboard; //Usado para verificar se existe atualização - PyVlibrasUpdate *update; + VlibrasUpdate *update; + + HINSTANCE hDLL1; + + char* pPathTempJson; + + char* pPathVlibrasJson; + //Inicializa Objetos EXPORT_API int coreInitize(void); diff --git a/update/DownloadVlibrasDicionario.iss b/update/DownloadVlibrasDicionario.iss new file mode 100644 index 0000000..dfe04ab --- /dev/null +++ b/update/DownloadVlibrasDicionario.iss @@ -0,0 +1,173 @@ + +#define MyAppName "Atualização - VLibras Dicionário" +#define MyAppVersion "3.0.0" +#define MyAppPublisher "LAViD" +#define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" +#define MyAppExeName "VlibrasDicionario.exe" + + + +[Setup] + +Uninstallable = no +AppName={#MyAppName} +AppVersion={#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={sd}\VLibras\update +DisableDirPage=yes +DisableWelcomePage=yes +DefaultGroupName={#MyAppName} +OutputBaseFilename=DicionarioUpdate +DisableProgramGroupPage=yes +DisableFinishedPage=no +OutputDir="DicionaryUpdate" +SetupIconFile="icon\icon_vlibras.ico" +Compression=lzma +SolidCompression=yes +WizardImageFile = "icon\avatar.bmp" +WizardSmallImageFile = "icon\player.bmp" + + + +[Languages] +Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" + + +[Files] +Source: it_download\languages\itd_ptbr.ini; Flags: dontcopy + +#include "it_download\it_download.iss"; +#include "vlibrasJsonParse.iss"; +#include "unzip.iss"; + +[CustomMessages] + ErrorJson=A {#MyAppName} não conseguiu conexão com a internet.%nFavor verifique sua conexão e tente novamente.%n%n + DownloadFinalizado=A nova versão do VLibras foi baixado com sucesso .%nSiga os proximos passos para instalar essa nova versão em seu computador.%n%n + FinalizarApp=O instalador de atualização será encerrado. + VersaoJaAtualizada=Não existe {#MyAppName} disponível%n Sua versão Já está atualizada!%n%n + + +[Code] + +var +//url do dicionario a ser baixado +Url: string; +// a versão do dicionario a ser baixado +VersionDicionaryApi: string; +// a versão do dicionario instalado +VersionDicionaryLocal: string; + + +//chamado ao inicializar o instalador +procedure InitializeWizard(); + +begin + //adciona o titulo na janela + WizardForm.Caption := '{#MyAppName}'; + //extrai o arquivo de tradução do ITD_download + ExtractTemporaryFile('itd_ptbr.ini'); + + //carrega o arquivo de traduçao PT-BR + ITD_LoadStrings(expandconstant('{tmp}\itd_ptbr.ini')); + + + //busca no json baixado, a url do dicionario a ser baixado + Url := jsonVersionGetValue(ExpandConstant('{tmp}\file.json'),'dictionaryUrl'); + + //verifica se existe uma url válida + if not (Url = 'null') + then + //função da dll ITD_download adciona arquivo para ser baixado + itd_addfile(Url,ExpandConstant('{sd}\VLibras\update\download\VlibrasDicionario.zip')); + + //inicia o download e mostra as informações na tela + itd_downloadafter(wpReady); + + +end; + + + +function InitializeSetup: Boolean; + +var +codDownloadJson: Integer; +versaoDictApiInteger: Integer; +versaoDictLocalInteger: Integer; +tempVersion: string; + +begin + + //busca a versão atual do dicionario local + VersionDicionaryLocal:= jsonVersionGetValue(ExpandConstant('{sd}\VLibras\version.json'),'dictionaryVersion'); + tempVersion:= VersionDicionaryLocal; + StringChangeEx(tempVersion, '.', '', True); + StringChangeEx(tempVersion, '_', '', True); + + + versaoDictLocalInteger:= StrToInt(tempVersion); + + //faz o download do json contendo as versoes disponiveis + codDownloadJson:= ITD_DownloadFile('http://vlibras.lavid.ufpb.br/api/dicionario/'+VersionDicionaryLocal+'?type=json',expandconstant('{tmp}\file.json')); + + + + //busca no json baixado, a versão do dicionario a ser baixado + VersionDicionaryApi:= jsonVersionGetValue(ExpandConstant('{tmp}\file.json'),'dictionaryVersion'); + + tempVersion:= VersionDicionaryApi; + StringChangeEx(tempVersion, '.', '', True); + StringChangeEx(tempVersion, '_', '', True); + + + + //verifica se o download do json de versoes foi bem sucedido. + if (codDownloadJson = 0) then + begin + versaoDictApiInteger:= StrToInt(tempVersion); + //verifica se é nescessario atualizar + if (versaoDictLocalInteger < versaoDictApiInteger) then + begin + Result := True; + end + else begin + MsgBox(ExpandConstant('{cm:VersaoJaAtualizada}'+'{cm:FinalizarApp}'), mbInformation, MB_OK); + Result := False; + end; + end + else begin + MsgBox(ExpandConstant('{cm:ErrorJson}'+'{cm:FinalizarApp}'), mbInformation, MB_OK); + //a instalação finaliza + Result := False; + end; +end; + + +procedure CurStepChanged(CurStep: TSetupStep); + +var + ErrorCode: Integer; +begin + + //após terminar o download da atualização. + if CurStep=ssInstall then begin + + WizardForm.CancelButton.Enabled := False; + WizardForm.Update; + // extrai o dicionario na pasta Bundles do player + Unzip(expandconstant('{sd}\VLibras\update\download\VlibrasDicionario.zip'),expandconstant('{sd}\VLibras\Player\VLibrasPlayer_Data\Bundles')); + DeleteFile(expandconstant('{sd}\VLibras\update\download\VlibrasDicionario.zip')); + end; + + if CurStep = ssDone then + begin + //atualiza a versao do dicionario no json local + jsonVersionReplaceValue('dictionaryVersion',VersionDicionaryApi); + + end; + +end; + diff --git a/update/DownloadVlibrasPlayer.iss b/update/DownloadVlibrasPlayer.iss new file mode 100644 index 0000000..20bc23a --- /dev/null +++ b/update/DownloadVlibrasPlayer.iss @@ -0,0 +1,169 @@ + +#define MyAppName "Atualização - VLibras" +#define MyAppVersion "3.0.0" +#define MyAppPublisher "LAViD" +#define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" +#define MyAppExeName "VlibrasPlayer.exe" + + + +[Setup] + +Uninstallable = no +AppName={#MyAppName} +AppVersion={#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={sd}\VLibras\update +DisableDirPage=yes +DisableWelcomePage=yes +DefaultGroupName={#MyAppName} +OutputBaseFilename=PlayerUpdate +DisableProgramGroupPage=yes +DisableFinishedPage=yes +OutputDir="PlayerUpdate" +SetupIconFile="icon\icon_vlibras.ico" +Compression=lzma +SolidCompression=yes +WizardImageFile = "icon\avatar.bmp" +WizardSmallImageFile = "icon\player.bmp" + + + +[Languages] +Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" + + +[Files] +Source: it_download\languages\itd_ptbr.ini; Flags: dontcopy + +#include "it_download\it_download.iss"; +#include "vlibrasJsonParse.iss"; + +[CustomMessages] + ErrorJson=A {#MyAppName} não conseguiu conexão com a internet.%nFavor verifique sua conexão e tente novamente.%n%n + DownloadFinalizado=A nova versão do VLibras foi baixado com sucesso .%nSiga os proximos passos para instalar essa nova versão em seu computador.%n%n + FinalizarApp=O instalador de atualização será encerrado. + VersaoJaAtualizada=Não existe {#MyAppName} disponível%n Sua versão Já está atualizada!%n%n + + +[Code] + +var + +Url: string; + +// a versão do player a ser baixado +VersionplayerApi: string; +// a versão do player instalado +VersionplayerLocal: string; + + +//chamado ao inicializar o instalador +procedure InitializeWizard(); + +begin + + WizardForm.Caption := '{#MyAppName}'; + ExtractTemporaryFile('itd_ptbr.ini'); + + //carrega o arquivo de traduçao portugues-br + ITD_LoadStrings(expandconstant('{tmp}\itd_ptbr.ini')); + + //busca no json baixado, a url do player a ser baixado + Url := jsonVersionGetValue(ExpandConstant('{tmp}\file.json'),'playerUrl'); + + //verifica se existe uma url válida + if not (Url = 'null') + then + //função da dll adciona arquivo para ser baixado + itd_addfile(Url,ExpandConstant('{sd}\VLibras\update\download\vlibrasUpdate.exe')); + + //inicia o download e mostra as informações na tela + itd_downloadafter(wpReady); + +end; + + + +function InitializeSetup: Boolean; + +var +codDownloadJson: Integer; +versaoPlayerApiInteger: Integer; +versaoPlayerLocalInteger: Integer; +tempVersion: string; + +begin + + //busca a versão atual do player local + VersionplayerLocal:= jsonVersionGetValue(ExpandConstant('{sd}\VLibras\version.json'),'playerVersion'); + tempVersion:= VersionplayerLocal; + StringChangeEx(tempVersion, '.', '', True); + + + versaoPlayerLocalInteger:= StrToInt(tempVersion); + + //faz o download do json contendo as versoes disponiveis + codDownloadJson:= ITD_DownloadFile('http://vlibras.lavid.ufpb.br/api/dicionario/0.0.0_0.0.0?type=json',expandconstant('{tmp}\file.json')); + + //busca no json baixado, a versão do player a ser baixado + VersionplayerApi:= jsonVersionGetValue(ExpandConstant('{tmp}\file.json'),'playerVersion'); + + tempVersion:= VersionplayerApi; + StringChangeEx(tempVersion, '.', '', True); + StringChangeEx(tempVersion, '_', '', True); + + + + //verifica se o download do json de versoes foi bem sucedido. + if (codDownloadJson = 0) then + begin + versaoPlayerApiInteger:= StrToInt(tempVersion); + //verifica se é nescessario atualizar + if (versaoPlayerLocalInteger < versaoPlayerApiInteger) then + begin + Result := True; + end + else begin + MsgBox(ExpandConstant('{cm:VersaoJaAtualizada}'+'{cm:FinalizarApp}'), mbInformation, MB_OK); + Result := False; + end; + end + else begin + MsgBox(ExpandConstant('{cm:ErrorJson}'+'{cm:FinalizarApp}'), mbInformation, MB_OK); + //a instalação finaliza + Result := False; + end; +end; + + +procedure CurStepChanged(CurStep: TSetupStep); + +var + ErrorCode: Integer; +begin + + + if CurStep=ssInstall then begin //após terminar o download da atualização. + + MsgBox(ExpandConstant('{cm:DownloadFinalizado}'), mbInformation, MB_OK); + end; + + if CurStep = ssDone then + begin + //chama o instalador baixado + if not ShellExec('', ExpandConstant('{sd}\VLibras\update\download\vlibrasUpdate.exe'), '', '', SW_SHOW, ewNoWait, ErrorCode) then + begin + MsgBox('Houve um erro ao Instalar atualização, favor entrar em contato com os desenvolvedores. ', mbError, MB_OK); + end; + end; + + + + + +end; + diff --git a/update/Makefile b/update/Makefile deleted file mode 100644 index 5b172c6..0000000 --- a/update/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -############################## MAKEFILE VLIBRAS ############################ -# # -# Ezequiel Silva # -# ezequielsilva@lavid.ufpb.br # # -# # -############################################################################ - - -# Compilador Nativo -CC = cl - -OUTPLAYER = vlibrasUp -OUTDICT = vlibrasDictUp -OUTWRITE = writeSucess - - - -CLEAN_OBJ = del -q *.obj - - -#Gera executável -all: - - $(CC) -Fe$(OUTPLAYER) -EHsc vlibrasPlayerInstall.cpp - $(CC) -Fe$(OUTDICT) -EHsc vlibrasDictInstall.cpp - $(CC) -Fe$(OUTWRITE) -EHsc writeSucessInstall.cpp - $(CLEAN_OBJ) - - -#Limpa arquivos objetos e executáveis criados -clean: - del -q *.exe *.obj - rm -rf doc - - diff --git a/update/icon/UnityPlayer.png b/update/icon/UnityPlayer.png new file mode 100644 index 0000000..d5dbe7f Binary files /dev/null and b/update/icon/UnityPlayer.png differ diff --git a/update/icon/avatar.bmp b/update/icon/avatar.bmp new file mode 100644 index 0000000..f1f7884 Binary files /dev/null and b/update/icon/avatar.bmp differ diff --git a/update/icon/bdrag.ico b/update/icon/bdrag.ico new file mode 100644 index 0000000..1ae4d40 Binary files /dev/null and b/update/icon/bdrag.ico differ diff --git a/update/icon/icon_vlibras.ico b/update/icon/icon_vlibras.ico new file mode 100644 index 0000000..0632ae2 Binary files /dev/null and b/update/icon/icon_vlibras.ico differ diff --git a/update/icon/player.bmp b/update/icon/player.bmp new file mode 100644 index 0000000..babd051 Binary files /dev/null and b/update/icon/player.bmp differ diff --git a/update/icon/small2.bmp b/update/icon/small2.bmp new file mode 100644 index 0000000..b127708 Binary files /dev/null and b/update/icon/small2.bmp differ diff --git a/update/include/pyVlibrasUpdate.h b/update/include/pyVlibrasUpdate.h deleted file mode 100644 index 69465aa..0000000 --- a/update/include/pyVlibrasUpdate.h +++ /dev/null @@ -1,31 +0,0 @@ -//***************************************************************** -/* - -Copyright (c) 2015 Ezequiel Silva -VLibras-Core group at LAViD, Federal University of Paraiba -*/ -//***************************************************************** - -/** -* \file pyVlibrasUpdate.h -* \authors Ezequiel Silva -* \date Setembro 2015 -*/ -#ifndef _PHVLIBRASUPDATE_H -#define _PHVLIBRASUPDATE_H - -#include - -/** \brief Classe para execução do Vlibras Update. -* -*/ -class PyVlibrasUpdate -{ - - public: - int install(char* strFunct, char* strstrParams); - void checkExe(char* strFunct, char* strstrParams); - -}; - -#endif \ No newline at end of file diff --git a/update/include/vlibrasUpdate.h b/update/include/vlibrasUpdate.h new file mode 100644 index 0000000..3344484 --- /dev/null +++ b/update/include/vlibrasUpdate.h @@ -0,0 +1,30 @@ +//***************************************************************** +/* + +Copyright (c) 2015 Ezequiel Silva +VLibras-Core group at LAViD, Federal University of Paraiba +*/ +//***************************************************************** + +/** +* \file pyVlibrasUpdate.h +* \authors Ezequiel Silva +* \date Setembro 2015 +*/ +#ifndef _PHVLIBRASUPDATE_H +#define _PHVLIBRASUPDATE_H + +#include + +/** \brief Classe para execução do Vlibras Update. +* +*/ +class VlibrasUpdate +{ + + public: + int install(char* strFunct, char* strstrParams); + +}; + +#endif \ No newline at end of file diff --git a/update/it_download/it_download.iss b/update/it_download/it_download.iss new file mode 100644 index 0000000..32016d6 --- /dev/null +++ b/update/it_download/it_download.iss @@ -0,0 +1,318 @@ +[Files] +Source: it_download\itdownload.dll; Flags: dontcopy; DestDir: {tmp} + +[Code] +(* + Inno Tools Downloader DLL + Copyright (C) Sherlock Software 2008 + Version 0.3.5 + + Contact: + The author, Nicholas Sherlock, at nick@sherlocksoftware.org. + Comments, questions and suggestions welcome. + + Website: + http://www.sherlocksoftware.org/ + + History: + 0.3.5 - Moved strings used in the updater example to the language file, so that they + may be more easily translated. + Added event functions to support the example of integration with InnoTools tray. + Fixes bugs that could cause the download to hang until + some mouse movements were received. + Allows "detailed mode" to be turned on with ITD_SetOption + Allows the HTTP agent to be set with ITD_SetOption + 0.3.4 - Added Brazilian Portuguese translation by Ronaldo Souza + 0.3.3 - The "Hilbrand Edskes" release :), lots of suggestions and corrections from him, thank you! + The "Retry" button is now translated. + The "Current file" progress bar is hidden if only one file is being downloaded. + The page's title and description are updated in the case of failed downloads. + Several updates to the translations. + Several small GUI fixes. + 0.3.2 - Minor tweaks to the English language file and the translation example script (example4.iss) + Added Dutch translation by Hilbrand Edskes + Added French translation by Néo + 0.3.1 - Added language file examples, fixed several missing language strings + Preliminary support for proxy server autodetection + Allows the size of a file to be queried with ITD_GetFileSize + Several small bugfixes + 0.3.0 - Properly supports timeouts. + Fixes bug with time remaining. + DLL is required again. + Supports localization through ITD_LoadStrings, ITD_SetString + Add mirrors for files + Post HTTP documents + Quick view and detailed view + 0.2.2 - Fixed empty strings '' in calls and added timeouts + 0.2.1 - Renamed identifiers to avoid name clashes + 0.2.0 - Converted from DLL to pure native code +*) + +procedure ITD_Cancel; + external 'itd_cancel@files:itdownload.dll stdcall'; + +procedure ITD_ClearFiles; + external 'itd_clearfiles@files:itdownload.dll stdcall'; + +function ITD_DownloadFile(url: PChar; destfilename: PChar): integer; + external 'itd_downloadfile@files:itdownload.dll stdcall'; + +function ITD_GetResultLen: integer; + external 'itd_getresultlen@files:itdownload.dll stdcall'; + +procedure ITD_GetResultString(buffer: pchar; maxlen: integer); + external 'itd_getresultstring@files:itdownload.dll stdcall'; + +procedure ITD_Internal_InitUI(HostHwnd: dword); + external 'itd_initui@files:itdownload.dll stdcall'; + +function ITD_Internal_LoadStrings(filename: PChar): boolean; + external 'itd_loadstrings@files:itdownload.dll stdcall'; + +procedure ITD_Internal_SetOption(option, value: PChar); + external 'itd_setoption@files:itdownload.dll stdcall'; + +function ITD_Internal_GetFileSize(url: pchar; var size: Cardinal): boolean; + external 'itd_getfilesize@files:itdownload.dll stdcall'; + +function ITD_Internal_GetString(index: integer): boolean; + external 'itd_getstring@files:itdownload.dll stdcall'; + +function ITD_Internal_GetOption(option: PChar; buffer: PChar; length: integer): integer; + external 'itd_getoption@files:itdownload.dll stdcall'; + +procedure ITD_Internal_SetString(index: integer; value: PChar); + external 'itd_setstring@files:itdownload.dll stdcall'; + +procedure ITD_Internal_AddFile(url: PChar; destfilename: PChar); + external 'itd_addfile@files:itdownload.dll stdcall'; + +procedure ITD_Internal_AddMirror(url: PChar; destfilename: PChar); + external 'itd_addmirror@files:itdownload.dll stdcall'; + +procedure ITD_Internal_AddFileSize(url: PChar; destfilename: PChar; size: integer); + external 'itd_addfilesize@files:itdownload.dll stdcall'; + +function ITD_Internal_DownloadFiles(surface: hwnd): integer; + external 'itd_downloadfiles@files:itdownload.dll stdcall'; + +function ITD_FileCount: integer; + external 'itd_filecount@files:itdownload.dll stdcall'; + +function ITD_Internal_PostPage(url, buffer: PChar; length: integer): boolean; + external 'itd_postpage@files:itdownload.dll stdcall'; + + +const + ITDERR_SUCCESS = 0; + ITDERR_USERCANCEL = 1; + ITDERR_ERROR = 3; + + {Constants for Language String indexes:} + ITDS_DownloadFailed = 104; + + ITDS_TitleCaption = 200; + ITDS_TitleDescription = 201; + + ITDS_MessageFailRetryContinue = 250; + ITDS_MessageFailRetry = 251; + + ITDS_Retry = 502; + + {Constants for language strings of updater example} + ITDS_Update_Caption = 600; + ITDS_Update_Description = 601; + ITDS_Update_Checking = 602; + ITDS_Update_NewAvailable = 603; + ITDS_Update_NoNewAvailable = 604; + ITDS_Update_WantToCheck = 605; + ITDS_Update_Failed = 606; + ITDS_Update_WillLaunch = 607; + ITDS_Update_WillLaunchWithPath = 608; + + ITD_Event_DownloadPageEntered = 1; + ITD_Event_DownloadPageLeft = 2; + ITD_Event_DownloadFailed = 3; + +var + itd_allowcontinue: boolean; + itd_retryonback: boolean; + + ITD_AfterSuccess: procedure(downloadPage: TWizardPage); + ITD_EventHandler: procedure(event: integer); + +procedure ITD_DownloadFiles(); +begin + ITD_Internal_DownloadFiles(0); +end; + +procedure ITD_AddFile(const URL, filename: string); +begin + ITD_Internal_AddFile(URL, filename); +end; + +procedure ITD_AddMirror(const URL, filename: string); +begin + ITD_Internal_AddMirror(URL, filename); +end; + +procedure ITD_AddFileSize(const URL, filename: string; size: integer); +begin + ITD_Internal_AddFileSize(URL, filename, size); +end; + +function ITD_HandleSkipPage(sender: TWizardPage): boolean; +begin + result := (itd_filecount = 0); +end; + +procedure ITD_SetString(index: integer; value: string); +begin + itd_internal_setstring(index, value); +end; + +function ITD_GetFileSize(const url: string; var size: cardinal): boolean; +begin + result := itd_internal_getfilesize(PChar(url), size); +end; + +function ITD_LoadStrings(const filename: string): boolean; +begin + result := itd_internal_loadstrings(filename); +end; + +function ITD_GetString(index: integer): string; +begin + itd_internal_getstring(index); + setlength(result, ITD_GetResultLen); + ITD_GetResultString(PChar(result), length(result)); +end; + +procedure ITD_NowDoDownload(sender: TWizardPage); +var err: integer; +begin + wizardform.backbutton.enabled := false; + wizardform.nextbutton.enabled := false; + + sender.caption := ITD_GetString(ITDS_TitleCaption); + sender.description := ITD_GetString(ITDS_TitleDescription); + + err := ITD_Internal_DownloadFiles(sender.surface.handle); + + case err of + ITDERR_SUCCESS: begin + wizardform.nextbutton.enabled := true; + wizardform.nextbutton.onclick(nil); + + if itd_aftersuccess <> nil then + itd_aftersuccess(sender); + end; + ITDERR_USERCANCEL: ; //Don't show a message, this happens on setup close and cancel click + else begin + //Some unexpected error, like connection interrupted + wizardform.backbutton.caption := ITD_GetString(ITDS_Retry); + wizardform.backbutton.enabled := true; + wizardform.backbutton.show(); + itd_retryonback := true; + + wizardform.nextbutton.enabled := itd_allowcontinue; + + if ITD_EventHandler <> nil then + ITD_EventHandler(ITD_Event_DownloadFailed); + + if itd_allowcontinue then begin //Download failed, we can retry, continue, or exit + sender.caption := ITD_GetString(ITDS_DownloadFailed); + sender.description := ITD_GetString(ITDS_MessageFailRetryContinue); + + MsgBox(ITD_GetString(ITDS_MessageFailRetryContinue), mbError, MB_OK) + end else begin //Download failed, we must retry or exit setup + sender.caption := ITD_GetString(ITDS_DownloadFailed); + sender.description := ITD_GetString(ITDS_MessageFailRetry); + + MsgBox(ITD_GetString(ITDS_MessageFailRetry), mbError, MB_OK) + end; + end; + end; +end; + +procedure ITD_HandleShowPage(sender: TWizardPage); +begin + wizardform.nextbutton.enabled := false; + wizardform.backbutton.hide(); + + if ITD_EventHandler <> nil then + ITD_EventHandler(ITD_Event_DownloadPageEntered); + + itd_nowdodownload(sender); +end; + +function ITD_HandleBackClick(sender: TWizardpage): boolean; +begin + result := false; + if itd_retryonback then begin + itd_retryonback := false; + wizardform.backbutton.hide(); + itd_nowdodownload(sender); + end; +end; + +function ITD_HandleNextClick(sender: TWizardpage): boolean; +begin + if ITD_EventHandler <> nil then + ITD_EventHandler(ITD_Event_DownloadPageLeft); + + result := true; +end; + +procedure ITD_Init; +begin + //Currently a NOP. Don't count on it in future. +end; + +function ITD_PostPage(const url, data: string; out response: string): boolean; +begin + result := ITD_Internal_PostPage(PChar(url), PChar(data), length(data)); + + if result then begin + setlength(response, ITD_GetResultLen); + ITD_GetResultString(PChar(response), length(response)); + end; +end; + +function ITD_DownloadAfter(afterID: integer): TWizardPage; +var itd_downloadPage: TWizardPage; +begin + itd_downloadpage := CreateCustomPage(afterID, ITD_GetString(ITDS_TitleCaption), ITD_GetString(ITDS_TitleDescription)); + + itd_downloadpage.onactivate := @itd_handleshowpage; + itd_downloadpage.onshouldskippage := @itd_handleskippage; + itd_downloadpage.onbackbuttonclick := @itd_handlebackclick; + itd_downloadpage.onnextbuttonclick := @itd_handlenextclick; + + itd_internal_initui(itd_downloadpage.surface.handle); + + result := itd_downloadpage; +end; + +procedure ITD_SetOption(const option, value: string); +begin + //The options which call ITD_SetString are depreciated, use ITD_SetString directly + if comparetext(option, 'UI_Caption') = 0 then + ITD_SetString(ITDS_TitleCaption, value) + else if comparetext(option, 'UI_Description') = 0 then + ITD_SetString(ITDS_TitleDescription, value) + else if comparetext(option, 'UI_FailMessage') = 0 then + ITD_SetString(ITDS_MessageFailRetry, value) + else if comparetext(option, 'UI_FailOrContinueMessage') = 0 then + ITD_SetString(ITDS_MessageFailRetryContinue, value) + else if comparetext(option, 'UI_AllowContinue') = 0 then + ITD_AllowContinue := (value = '1') + else + ITD_Internal_SetOption(option, value); +end; + +function ITD_GetOption(const option: string): string; +begin + setlength(result, 500); + setlength(result, itd_internal_getoption(pchar(option), pchar(result), length(result))); +end; diff --git a/update/it_download/languages/itd_ptbr.ini b/update/it_download/languages/itd_ptbr.ini new file mode 100644 index 0000000..dc68b57 --- /dev/null +++ b/update/it_download/languages/itd_ptbr.ini @@ -0,0 +1,49 @@ +[Author] +Contributors=Ronaldo Souza +Contributors=Ezequiel Silva + +[Strings] +100=Obtendo informações da atualização... +101=Iniciando o download... +102=Baixando... +103=Download completo! +104=Erro no download. +105=Baixando (%s)... + +200=Baixando Atualização do VLibras +201=Favor aguardar enquanto o VLibras baixa os arquivos... + +250=Desculpe, os arquivos não puderam ser baixados. Clique em 'Repetir' para tentar baixar os arquivos novamente, ou clique em 'Prosseguir' para continuar a instalação assim mesmo. +251=Desculpe, os arquivos não puderam ser baixados. Clique em 'Repetir' para tentar baixar os arquivos novamente, ou clique em 'Cancelar' para abortar a instalação. + +300=Arquivo: +301=Velocidade: +302=Status: +303=Tempo decorrido: +304=Tempo restante: +305=Arquivo corrente: +306=Progresso total: + +400=Desconhecido + +450=segundo +451=segundos +452=minuto +453=minutos +454=hora +455=horas +456=dia +457=dias +458=%1 %2/s +459=%1 %2 de %3 %4 +460=%1 %2 de desconhecido +461=Não + +470=B +471=KB +472=MB +473=GB + +500=Detalhes +501=Esconder +502=Repetir \ No newline at end of file diff --git a/update/src/pyVlibrasUpdate.cpp b/update/src/pyVlibrasUpdate.cpp deleted file mode 100644 index 0a8c0c7..0000000 --- a/update/src/pyVlibrasUpdate.cpp +++ /dev/null @@ -1,103 +0,0 @@ - -/** -* \file pyVlibrasUpdate.cpp -* \authors Ezequiel Silva -* \date outubro 2015 -*/ - -#include "pyVlibrasUpdate.h" - - -void PyVlibrasUpdate::checkExe(char* strFunct, char* strstrParams) -{ - - STARTUPINFO StartupInfo; - PROCESS_INFORMATION ProcessInfo; - char Args[4096]; - char *pEnvCMD = NULL; - char *pDefaultCMD = "CMD.EXE"; - ULONG rc; - - memset(&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(STARTUPINFO); - StartupInfo.dwFlags = STARTF_USESHOWWINDOW; - StartupInfo.wShowWindow = SW_HIDE; - - Args[0] = 0; - - pEnvCMD = getenv("COMSPEC"); - - if(pEnvCMD){ - - strcpy(Args, pEnvCMD); - } - else{ - strcpy(Args, pDefaultCMD); - } - - // "/c" option - Do the command then terminate the command window - strcat(Args, " /c "); - //the application you would like to run from the command window - strcat(Args, strFunct); - strcat(Args, " "); - //the parameters passed to the application being run from the command window. - strcat(Args, strstrParams); - - if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) - { - return; - } - - WaitForSingleObject(ProcessInfo.hProcess, INFINITE); - if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) - rc = 0; - - CloseHandle(ProcessInfo.hThread); - CloseHandle(ProcessInfo.hProcess); - - -} - -int PyVlibrasUpdate::install(char* strFunct, char* strstrParams) -{ - - STARTUPINFO StartupInfo; - PROCESS_INFORMATION ProcessInfo; - char Args[4096]; - char *pEnvCMD = NULL; - char *pDefaultCMD = "CMD.EXE"; - - memset(&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(STARTUPINFO); - StartupInfo.dwFlags = STARTF_USESHOWWINDOW; - StartupInfo.wShowWindow = SW_HIDE; - - Args[0] = 0; - - pEnvCMD = getenv("COMSPEC"); - - if(pEnvCMD){ - - strcpy(Args, pEnvCMD); - } - else{ - strcpy(Args, pDefaultCMD); - } - - // "/c" option - Do the command then terminate the command window - strcat(Args, " /c "); - //the application you would like to run from the command window - strcat(Args, strFunct); - strcat(Args, " "); - //the parameters passed to the application being run from the command window. - strcat(Args, strstrParams); - - if (!CreateProcess( NULL, Args, NULL, NULL, FALSE,CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) - { - return -1; - } - - return -1; - -} - diff --git a/update/src/vlibrasUpdate.cpp b/update/src/vlibrasUpdate.cpp new file mode 100644 index 0000000..3f87ea8 --- /dev/null +++ b/update/src/vlibrasUpdate.cpp @@ -0,0 +1,53 @@ + +/** +* \file vlibrasUpdate.cpp +* \authors Ezequiel Silva +* \date outubro 2015 +*/ + +#include "vlibrasUpdate.h" + + +int VlibrasUpdate::install(char* strFunct, char* strstrParams) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, strFunct); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, strstrParams); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE,CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) + { + return -1; + } + + return 0; + +} + diff --git a/update/unzip.iss b/update/unzip.iss new file mode 100644 index 0000000..bb34543 --- /dev/null +++ b/update/unzip.iss @@ -0,0 +1,99 @@ +#IFDEF UNICODE + #DEFINE AW "W" +#ELSE + #DEFINE AW "A" +#ENDIF + +// --- Start "ShellExecuteEx" Helper + +const + WAIT_TIMEOUT = $00000102; + SEE_MASK_NOCLOSEPROCESS = $00000040; + INFINITE = $FFFFFFFF; { Infinite timeout } + +type + TShellExecuteInfo = record + cbSize: DWORD; + fMask: Cardinal; + Wnd: HWND; + lpVerb: string; + lpFile: string; + lpParameters: string; + lpDirectory: string; + nShow: Integer; + hInstApp: THandle; + lpIDList: DWORD; + lpClass: string; + hkeyClass: THandle; + dwHotKey: DWORD; + hMonitor: THandle; + hProcess: THandle; + end; + +function ShellExecuteEx(var lpExecInfo: TShellExecuteInfo): BOOL; + external 'ShellExecuteEx{#AW}@shell32.dll stdcall'; +function WaitForSingleObject(hHandle: THandle; dwMilliseconds: DWORD): DWORD; + external 'WaitForSingleObject@kernel32.dll stdcall'; +function CloseHandle(hObject: THandle): BOOL; external 'CloseHandle@kernel32.dll stdcall'; + + + + +procedure Unzip(source: String; targetdir: String); +var + I: Integer; + unzipTool, unzipParams : String; // path and param for the unzip tool + ExecInfo: TShellExecuteInfo; // info object for ShellExecuteEx() +begin + // source and targetdir might contain {tmp} or {app} constant, so expand/resolve it to path names + source := ExpandConstant(source); + targetdir := ExpandConstant(targetdir); + + // prepare 7zip execution + unzipTool := ExpandConstant('{sd}\VLibras\bin\7z.exe'); + unzipParams := ' x "' + source + '" -o"' + targetdir + '" -y'; + + // prepare information about the application being executed by ShellExecuteEx() + ExecInfo.cbSize := SizeOf(ExecInfo); + ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS; + ExecInfo.Wnd := 0; + ExecInfo.lpFile := unzipTool; + ExecInfo.lpParameters := unzipParams; + ExecInfo.nShow := SW_HIDE; + + WizardForm.StatusLabel.Caption := 'Aguarde enquanto o dicionário é instalado...'; + WizardForm.ProgressGauge.Min := 0; + WizardForm.ProgressGauge.Max := 100; + + if not FileExists(unzipTool) + then MsgBox('Erro ao tentar instalar Dicionario: ' + unzipTool, mbError, MB_OK) + else if not FileExists(source) + then MsgBox('Arquivo de Dicionario não encontrado: ' + source, mbError, MB_OK) + else begin + + + if ShellExecuteEx(ExecInfo) then + I := 0; + begin + while WaitForSingleObject(ExecInfo.hProcess, 100) = WAIT_TIMEOUT + do begin + + I := I+1; + if I > 100 then + begin + WizardForm.FilenameLabel.Caption := 'Finalizando...'; + WizardForm.ProgressGauge.Position := 100; + end + else + begin + WizardForm.FilenameLabel.Caption := 'Feito ' + IntToStr(I) + '%'; + WizardForm.ProgressGauge.Position := I; + end; + + WizardForm.Refresh(); + end; + CloseHandle(ExecInfo.hProcess); + end; + + end; +end; diff --git a/update/updatePython/DownloadFile.py b/update/updatePython/DownloadFile.py deleted file mode 100644 index 4ce8874..0000000 --- a/update/updatePython/DownloadFile.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import wx -from urllib2 import URLError -from urllib2 import HTTPError -import urllib2,os -import random -import time -from wx.lib.pubsub import pub -from threading import Thread - - -class DownloadFile2(Thread): - - def __init__(self,url,nameFile): - self.url = url - self.nameFile = nameFile - self.downloading = True - Thread.__init__(self) - - - def stop(self): - self.downloading = False - - - def run(self): - - file_name = self.nameFile - try: - u = urllib2.urlopen(self.url) - f = open(file_name, 'wb') - meta = u.info() - file_size = int(meta.getheaders("Content-Length")[0]) - - except : - self.downloading = False; - wx.CallAfter(pub.sendMessage, "erroDeConexao", msg="Falha na conexao") - - return False - - - file_size_dl = 0 - block_sz = 8192 - while self.downloading: - buffer = u.read(block_sz) - if not buffer: - break - - file_size_dl += len(buffer) - f.write(buffer) - status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size) - status = status + chr(8)*(len(status)+1) - - wx.CallAfter(pub.sendMessage, "updateProgress", msg=(file_size_dl * 100. / file_size)) - if (file_size_dl * 100. / file_size) >=100: - wx.CallAfter(pub.sendMessage, "updateProgress", msg=(100)) - self.downloading = False; - wx.CallAfter(pub.sendMessage, "downloadSucess", msg="Download realizado") diff --git a/update/updatePython/Util.py b/update/updatePython/Util.py deleted file mode 100644 index a46d247..0000000 --- a/update/updatePython/Util.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- -import os.path -import json, zipfile, subprocess,urllib -from os import popen -import sys , shutil - -import wx - -PATH_RESOURCE = os.getenv("ProgramFiles")+'/VLibras/' -DICTIONARY_EXTRACT_PATH = PATH_RESOURCE+'/Player/VLibrasPlayer_Data/Bundles' -DICTIONARY_ZIP_PATH = PATH_RESOURCE+'update/download/vlibras_dicionario.zip' -TXT_DICT_VERSION = PATH_RESOURCE+'update/version/dictVersion.txt' -TXT_PLAYER_VERSION = PATH_RESOURCE+'update/version/playerVersion.txt' -TXT_PLAYER_VERSION_DOWNLOAD = PATH_RESOURCE+'update/version/DownloadPlayerVersion.txt' -JSON_API_VERSION = PATH_RESOURCE+'update/download/versionApi.json' -URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/' -TEXT_CHECK_INSTALL = PATH_RESOURCE+'installSucess.txt' -INSTALL_PLAYER_PATH = PATH_RESOURCE+'update/download/Vlibras_Up.exe' -PATH_PLAYER = PATH_RESOURCE+'Player/VlibrasPlayer.exe' -ICON = PATH_RESOURCE+'icons/icon_vlibras.ico' - - -## atualiza a versão do arquivo de dicionario -def updateFileDictVersion(version): - try: - txt_local_version = open(TXT_DICT_VERSION, 'w') - txt_local_version.write(version) - txt_local_version.close() - return True - except: - return False - - -## artualiza a versão do arquivo de player -def updateFilePlayerVersion(version): - try: - if os.path.isfile(TXT_PLAYER_VERSION): - txt_local_version = open(TXT_PLAYER_VERSION, 'w') - txt_local_version.write(version) - txt_local_version.close() - return True - else: - return False - except: - return False - - -## apos atualizar, criar arquivo de sucesso -##e move o atualizador do player para fora da pasta original para que o desinstalador não cause problema -def updateSuccess(): - txt_local_version = open(TEXT_CHECK_INSTALL, 'w') - txt_local_version.write('sucess') - txt_local_version.close() - shutil.move(PATH_RESOURCE+'update/bin/vlibrasPlayerUp.exe', PATH_RESOURCE+'update/') - -## faz dawnload do json das versões -def downladFileApi(_url): - try: - urllib.urlretrieve (_url, JSON_API_VERSION) - return True - except Exception, e: - print e - return False - - -def extractDictZip(): - dlg = wx.ProgressDialog("Atualização VLibras", "Finalizando Atualização...", style = wx.PD_APP_MODAL) - dlg.Pulse() - - - with zipfile.ZipFile(DICTIONARY_ZIP_PATH, "r") as z: - - z.extractall(DICTIONARY_EXTRACT_PATH) - dlg.Destroy() - diff --git a/update/updatePython/VlibrasCheckVersion.py b/update/updatePython/VlibrasCheckVersion.py deleted file mode 100644 index 4e78303..0000000 --- a/update/updatePython/VlibrasCheckVersion.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -from os import popen -from version import TVersion - -PATH_RESOURCE = 'c:/vlibras-libs/update/' -TXT_LOCAL_VERSION = PATH_RESOURCE+'version/version.txt' - -"""Usado pelo player para verificar se existe versão disponivel""" -"""O resultVersion (1 = player para átualizar, 2 = dicionartio para atualizar, 0 = não existe atualização disponível) -eh escrito no arquivo update/version.txt e eh lido pelo corePlugin""" - -if __name__ == '__main__': - - tversion = TVersion() - tversion.start() - - txt_local_version = open(TXT_LOCAL_VERSION, 'w') - - """Verifica se exite uma nova versao disponivel""" - resultVersion = tversion.checkVersion() - - """escreve o resultado no arquivo""" - txt_local_version.write(resultVersion) - - txt_local_version.close() - - print resultVersion - # print 'Finished' diff --git a/update/updatePython/frameUpdate.py b/update/updatePython/frameUpdate.py deleted file mode 100644 index 321507c..0000000 --- a/update/updatePython/frameUpdate.py +++ /dev/null @@ -1,94 +0,0 @@ - -# -*- coding: utf-8 -*- - -import wx -import subprocess -import time -import os.path -from wx.lib.pubsub import pub -from DownloadFile import * -from VlibrasCheckVersion import * -import Util -from threading import Thread - -class UpdateView(wx.Frame,Thread): - - def __init__(self): - - Thread.__init__(self) - style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX - wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(380,150)) - self.SetIcon(wx.Icon(Util.ICON, wx.BITMAP_TYPE_ICO)) - self.myPanel = wx.Panel(self, -1) - self.myPanel.SetBackgroundColour('#F5F5F5') - btnCancel = wx.Button(self.myPanel, label="Cancelar",pos=(270, 85), size=(80, 25)) - self.txtInfo = wx.StaticText(self.myPanel, -1, pos=(5,105)) - self.txtInfo.SetForegroundColour('#000000') - self.progress = wx.Gauge(self.myPanel, range=100,pos=(5,40),size=(365,23)) - self.Center() - - # Anexa um evento ao botão - self.Bind(wx.EVT_BUTTON, self.onBtnCancelClick, btnCancel) - self.__close_callback = None - self.Bind(wx.EVT_CLOSE, self._when_closed) - - pub.subscribe(self.erroDeConexao, "erroDeConexao") - pub.subscribe(self.updateProgress, "updateProgress") - self.percentDownload = 0; - self.register_close_callback(lambda: True) - self.dlg = wx.ProgressDialog("Atualização", "Verificando Atualização...", style = wx.PD_CAN_ABORT | wx.PD_APP_MODAL) - self.pulse = True - - def run(self): - pulse =True - while self.pulse and pulse: - if(not pulse): - self.dlg.Destroy() - break - (pulse, skip) = self.dlg.Pulse() - - self.dlg.Destroy() - - """ chamado quando termina de verificacao de atualização """ - def closePulseDialog(self): - self.pulse = False - - - def erroDeConexao(self, msg): - wx.MessageBox('Ocorreu um erro ao tentar fazer atualização. \n Por favor tente mais tarde.', 'Informação',wx.OK | wx.ICON_INFORMATION) - self.Destroy() - - def register_close_callback(self, callback): - self.__close_callback = callback - - def _when_closed(self, event): - wx.CallAfter(pub.sendMessage, "cancelDownload",event = event) - # self.OnCloseFrame(event); - - - def onBtnCancelClick(self, event): - print 'cancel' - wx.CallAfter(pub.sendMessage, "cancelDownload",event = event) - - - def updateProgress(self, msg): - value = msg - self.percentDownload = value - self.progress.SetValue(value) - - def ShowMessage(self, mesagem): - dialog = wx.MessageDialog(self, message = mesagem, caption = "Atualização", - style = wx.OK | wx.ICON_INFORMATION) - dialog.ShowModal() - - def ShowMessageError(self, mesagem): - wx.MessageBox(mesagem, 'Informação', - wx.OK | wx.ICON_ERROR) - # self.downloadFile.stop() - self.Destroy() - - def showMessageDialog(self): - dialog = wx.MessageDialog(self, message = "Tem certeza que deseja cancelar a atualização?", caption = "Cancelar Atualização", - style = wx.YES_NO | wx.ICON_QUESTION) - return dialog.ShowModal() - diff --git a/update/updatePython/update.py b/update/updatePython/update.py deleted file mode 100644 index c3cfc7c..0000000 --- a/update/updatePython/update.py +++ /dev/null @@ -1,113 +0,0 @@ -# -*- coding: utf-8 -*- - -from version import TVersion -from frameUpdate import UpdateView -import wx -from DownloadFile import * -import Util -from wx.lib.pubsub import pub -import subprocess -import time -import os - - - -class Update(object): - """docstring for Update""" - - def __init__(self, version,frame): - super(Update, self).__init__() - self.version = version - self.frame = frame - self.downloadFile = None - pub.subscribe(self.downloadSucess, "downloadSucess") - pub.subscribe(self.cancelDownload, "cancelDownload") - - def cancelDownload(self,event): - - if(self.frame.percentDownload>= 100): - if not (self.downloadFile == None): - self.downloadFile.stop() - self.frame.Destroy() - - response = self.frame.showMessageDialog() - - if (response == wx.ID_YES): - if not (self.downloadFile == None): - self.downloadFile.stop() - self.frame.Destroy() - self.frame.ShowMessage('Atualização Cancelada!') - else: - event.StopPropagation() - - - def stopDownload(self): - if not (self.downloadFile == None): - self.downloadFile.stop() - - def startDownloadPlayer(self): - # #inicia o download do arquivo - self.downloadFile = DownloadFile2(version.url_download_player, Util.INSTALL_PLAYER_PATH) - self.downloadFile.start() - self.frame.txtInfo.SetLabel('Baixando a atualização...') - - def startDownloadDict(self): - # #inicia o download do arquivo - self.downloadFile = DownloadFile2(version.url_download_dict, Util.DICTIONARY_ZIP_PATH) - self.downloadFile.start() - self.frame.txtInfo.SetLabel('Baixando a atualização...') - - """funcao chamada pelo DownloadFile quando terminado o download tanto do dicionario quanto do player""" - def downloadSucess(self, msg): - self.frame.Hide() - self.frame.txtInfo.SetLabel('Instalando Atualização...') - if(self.version.isUpdateDict()): - try: - Util.extractDictZip() - self.frame.ShowMessage('O Dicionário VLibras foi atualizado com sucesso!') - Util.updateFileDictVersion(self.version.api_dict_version_full) - except: - self.frame.ShowMessageError('Houve um erro ao atualizar o VLibras!') - - elif (self.version.isUpdatePlayer()): - - process = subprocess.call(Util.INSTALL_PLAYER_PATH) - time.sleep( 3 ) - if os.path.isfile(Util.TEXT_CHECK_INSTALL): - self.frame.ShowMessage('O VLibras foi atualizado com sucesso!') - Util.updateFilePlayerVersion(self.version.api_player_version_full) - - else: - self.frame.ShowMessageError('O VLibras não foi atualizado!') - subprocess.Popen(Util.PATH_PLAYER) - - self.frame.Destroy() - - -if __name__ == '__main__': - - app = wx.App(False) - frame = UpdateView() - version = TVersion() - #version.start() - frame.start() - update = Update(version,frame) - print version.checkVersion(); - frame.closePulseDialog() - - if(version.isUpdatePlayer()): - frame.Show() - update.startDownloadPlayer() - app.MainLoop() - - elif(version.isUpdateDict()): - frame.Show() - update.startDownloadDict() - app.MainLoop() - - else: - - frame.ShowMessage('O VLibras está atualizado!') - - - diff --git a/update/updatePython/version.py b/update/updatePython/version.py deleted file mode 100644 index 437538f..0000000 --- a/update/updatePython/version.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding: utf-8 -*- -import os.path -import json, zipfile, subprocess,urllib -from os import popen -import Util -import sys , shutil -from threading import Thread - - -class TVersion(Thread): - """classe responsável por fornecer as versões do player e do dicionário""" - def __init__(self): - - self.api_dict_version_full = '0.0.0_0.0.0' - self.api_dict_version = 000000 - self.api_player_version = 000 - self.api_player_version_full = '0.0.0' - self.url_download_player = '' - self.url_download_dict = '' - self.local_dict_version_full = '0.0.0_0.0.0' - self.local_dict_version = 000000 - self.local_player_version = 000 - Thread.__init__(self) - - - def run(self): - self.loadLocalVersion() - self.loadApiVersion() - - ## Carrega a versão online do dicionario e do play - def loadApiVersion(self): - try: - if(Util.downladFileApi(Util.URL_REQUEST_API+self.local_dict_version_full+'?type=json')): - with open(Util.JSON_API_VERSION) as data: - json_data = json.load(data) - - self.api_dict_version_full = json_data['dictionaryVersion'].encode('utf-8') - self.api_dict_version = int(json_data['dictionaryVersion'].encode('utf-8').replace(".", "").replace("_", "")) - self.api_player_version = int(json_data['playerVersion'].encode('utf-8').replace(".", "")) - self.api_player_version_full = json_data['playerVersion'].encode('utf-8') - self.url_download_player = json_data['playerUrl'].encode('utf-8') - self.url_download_dict = json_data['dictionaryUrl'].encode('utf-8') - else: - print 'Erro ao fazer download do json de versoes' - except: - print 'Erro ao carregar JSON_API_VERSION' - - - ## Carrega a versão local do dicionario e do play - def loadLocalVersion(self): - - if os.path.isfile(Util.TXT_DICT_VERSION): - fileDictVersion = open(Util.TXT_DICT_VERSION,'r') - versionLocalDict = fileDictVersion.readline() - fileDictVersion.close() - self.local_dict_version_full = versionLocalDict - self.local_dict_version = int(versionLocalDict.encode('utf-8').replace(".", "").replace("_", "")) - - if os.path.isfile(Util.TXT_PLAYER_VERSION): - filePlayerVersion = open(Util.TXT_PLAYER_VERSION,'r') - versionLocalPlayer = filePlayerVersion.readline() - filePlayerVersion.close() - self.local_player_version = int(versionLocalPlayer.encode('utf-8').replace(".", "")) - - - ## Verifica se a vesao local do player é menor que a disponível pra download - def isUpdatePlayer(self): - return self.api_player_version > self.local_player_version - - ## Verifica se a vesao local do dicionário é menor que a disponível pra download - def isUpdateDict(self): - return self.api_dict_version > self.local_dict_version - - ## recarrega as versões - def reload(self): - self.loadLocalVersion() - self.loadApiVersion() - - """return (1 = player para átualizar, 2 = dicionario para atualizar, 0 = não existe atualização disponível) """ - def checkVersion(self): - self.reload() - if(self.isUpdatePlayer()): - return '1'; - elif (self.isUpdateDict()): - return '2' - else: - return '0' - - - - - -if __name__ == '__main__': - - version = TVersion() - version.start() - version.checkVersion(); - - print'existe novo player: ',version.isUpdatePlayer() - print 'existe novo dicionario: ',version.isUpdateDict() - print 'versao local do dicionario: ',version.local_dict_version - print 'versao api do dicionario: ',version.api_dict_version diff --git a/update/updatePython/writeSucessInstall.py b/update/updatePython/writeSucessInstall.py deleted file mode 100644 index c8a1833..0000000 --- a/update/updatePython/writeSucessInstall.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -import Util, os - - -if __name__ == '__main__': - - Util.updateSuccess() - - for raiz, diretorios, arquivos in os.walk('C:/vlibras-libs/vlibras-translate/src'): - for arquivo in arquivos: - if arquivo.endswith('.py'): - os.remove(os.path.join(raiz,arquivo)) - - - - - - - - - - - - - - diff --git a/update/vlibrasDictInstall.cpp b/update/vlibrasDictInstall.cpp deleted file mode 100644 index f86255c..0000000 --- a/update/vlibrasDictInstall.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -#include //include all the basics - //string and other mapping macros - - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, int nShowCmd) -{ - - STARTUPINFO StartupInfo; - PROCESS_INFORMATION ProcessInfo; - char Args[4096]; - char *pEnvCMD = NULL; - char *pDefaultCMD = "CMD.EXE"; - ULONG rc; - - memset(&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(STARTUPINFO); - StartupInfo.dwFlags = STARTF_USESHOWWINDOW; - StartupInfo.wShowWindow = SW_HIDE; - - Args[0] = 0; - - pEnvCMD = getenv("COMSPEC"); - - if(pEnvCMD){ - - strcpy(Args, pEnvCMD); - } - else{ - strcpy(Args, pDefaultCMD); - } - - // "/c" option - Do the command then terminate the command window - strcat(Args, " /c "); - //the application you would like to run from the command window - strcat(Args, "c:\\Python27\\python.exe"); - strcat(Args, " "); - //the parameters passed to the application being run from the command window. - strcat(Args, "..\\py\\update.pyc"); - - if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, - CREATE_NEW_CONSOLE, - NULL, - NULL, - &StartupInfo, - &ProcessInfo)) - { - return GetLastError(); - } - - WaitForSingleObject(ProcessInfo.hProcess, INFINITE); - if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) - rc = 0; - - CloseHandle(ProcessInfo.hThread); - CloseHandle(ProcessInfo.hProcess); - - return 0; -} \ No newline at end of file diff --git a/update/vlibrasJsonParse.iss b/update/vlibrasJsonParse.iss new file mode 100644 index 0000000..a4c88e8 --- /dev/null +++ b/update/vlibrasJsonParse.iss @@ -0,0 +1,102 @@ + + + + + +[code] + + +function jsonVersionGetValue(const FileName, TagName: string): string; +var + TmpStringLines: string; + FileLines: TStringList; + I: Integer; + Tag: string; + Line: string; + TagPos: Integer; + Valor: string; + + +begin + Result := 'null'; + FileLines := TStringList.Create; + + Tag := '"' + TagName + '"'; + + try + LoadStringFromfile(FileName, TmpStringLines); + FileLines.Text:= TmpStringLines; + except + ShowExceptionMessage; + end; + + for I := 0 to FileLines.Count - 1 do + begin + Line := FileLines[I]; + TagPos := Pos(Tag, Line); + if TagPos > 0 then + begin + + Valor := Copy(Line, TagPos + Length(Tag)+3, MaxInt); + StringChangeEx(Valor, ',', '', True); + + Result := Copy(Valor,0,Length(Valor)-1); + + Break; + end; + end; + FileLines.Free; +end; + + + + +function jsonVersionReplaceValue(TagName, TagValue: string): boolean; + +var + TmpStringLines: string; + FileLines: TStringList; + I: Integer; + Tag: string; + Line: string; + TagPos: Integer; + Valor: string; + linesText: string; + jsonPath: string; + + +begin + FileLines := TStringList.Create; + + jsonPath:= ExpandConstant('{sd}\VLibras\version.json'); + if LoadStringFromfile(jsonPath, TmpStringLines) then begin + + FileLines.Text:= TmpStringLines; + end; + + Result := True; + Tag := '"' + TagName + '"'; + + for I := 0 to FileLines.Count - 1 do + begin + Line := FileLines[I]; + TagPos := Pos(Tag, Line); + if TagPos > 0 then + begin + + Delete(Line, TagPos + Length(Tag), MaxInt); + + Line := Line + ': "' + TagValue + '"'; + FileLines[I] := Line; + linesText := FileLines.Text; + FileLines.Free; + if not SaveStringToFile(ExpandConstant('{sd}\VLibras\version.json'), linesText, False) then + Result := False; + Break; + end; + end; +end; + + + + diff --git a/update/vlibrasPlayerInstall.cpp b/update/vlibrasPlayerInstall.cpp deleted file mode 100644 index 5b2a137..0000000 --- a/update/vlibrasPlayerInstall.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -#include //include all the basics - //string and other mapping macros - - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, int nShowCmd) -{ - - STARTUPINFO StartupInfo; - PROCESS_INFORMATION ProcessInfo; - char Args[4096]; - char *pEnvCMD = NULL; - char *pDefaultCMD = "CMD.EXE"; - ULONG rc; - - memset(&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(STARTUPINFO); - StartupInfo.dwFlags = STARTF_USESHOWWINDOW; - StartupInfo.wShowWindow = SW_HIDE; - - Args[0] = 0; - - pEnvCMD = getenv("COMSPEC"); - - if(pEnvCMD){ - - strcpy(Args, pEnvCMD); - } - else{ - strcpy(Args, pDefaultCMD); - } - - // "/c" option - Do the command then terminate the command window - strcat(Args, " /c "); - //the application you would like to run from the command window - strcat(Args, "python"); - strcat(Args, " "); - //the parameters passed to the application being run from the command window. - strcat(Args, "py\\update.pyc"); - - if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, - CREATE_NEW_CONSOLE, - NULL, - NULL, - &StartupInfo, - &ProcessInfo)) - { - return GetLastError(); - } - - WaitForSingleObject(ProcessInfo.hProcess, INFINITE); - if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) - rc = 0; - - CloseHandle(ProcessInfo.hThread); - CloseHandle(ProcessInfo.hProcess); - - return 0; -} \ No newline at end of file diff --git a/update/writeSucessInstall.cpp b/update/writeSucessInstall.cpp deleted file mode 100644 index 460925a..0000000 --- a/update/writeSucessInstall.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -#include //include all the basics - //string and other mapping macros - - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, int nShowCmd) -{ - - STARTUPINFO StartupInfo; - PROCESS_INFORMATION ProcessInfo; - char Args[4096]; - char *pEnvCMD = NULL; - char *pDefaultCMD = "CMD.EXE"; - ULONG rc; - - memset(&StartupInfo, 0, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(STARTUPINFO); - StartupInfo.dwFlags = STARTF_USESHOWWINDOW; - StartupInfo.wShowWindow = SW_HIDE; - - Args[0] = 0; - - pEnvCMD = getenv("COMSPEC"); - - if(pEnvCMD){ - - strcpy(Args, pEnvCMD); - } - else{ - strcpy(Args, pDefaultCMD); - } - - // "/c" option - Do the command then terminate the command window - strcat(Args, " /c "); - //the application you would like to run from the command window - strcat(Args, "c:\\Python27\\python.exe"); - strcat(Args, " "); - //the parameters passed to the application being run from the command window. - strcat(Args, "..\\py\\writeSucessInstall.pyc"); - - if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, - CREATE_NEW_CONSOLE, - NULL, - NULL, - &StartupInfo, - &ProcessInfo)) - { - return GetLastError(); - } - - WaitForSingleObject(ProcessInfo.hProcess, INFINITE); - if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) - rc = 0; - - CloseHandle(ProcessInfo.hThread); - CloseHandle(ProcessInfo.hProcess); - - return 0; -} \ No newline at end of file -- libgit2 0.21.2