Commit e3ccbbc784970ec693b007de97a6a8e3f5bfbda5
1 parent
6d9c0535
Exists in
master
Com a versão do update funcionando
Showing
26 changed files
with
850 additions
and
1375 deletions
Show diff stats
Makefile
... | ... | @@ -23,10 +23,10 @@ OUT = testLibras |
23 | 23 | |
24 | 24 | |
25 | 25 | # Arquivos de implementação |
26 | -FILES = src\pyTradutor.cpp src\pyClip.cpp update\src\checkVersion.cpp | |
26 | +FILES = src\pyTradutor.cpp src\pyClip.cpp update\src\pyVlibrasUpdate.cpp | |
27 | 27 | |
28 | 28 | #Headers |
29 | -INCLUDES = include\pyTradutor.h include\pyClip.h update\include\checkVersion.h | |
29 | +INCLUDES = include\pyTradutor.h include\pyClip.h update\include\pyVlibrasUpdate.h | |
30 | 30 | |
31 | 31 | CLEAN_OBJ = del -q *.obj |
32 | 32 | |
... | ... | @@ -34,7 +34,7 @@ HOME = %homepath% |
34 | 34 | |
35 | 35 | #Gera executável testLibras |
36 | 36 | all: $(FILES) $(INCLUDES) src\testLibras.cpp |
37 | - $(CC) -Fe$(OUT) -clr src\testLibras.cpp $(FILES) $(CFLAGS) $(LFLAGS) | |
37 | + $(CC) -Fe$(OUT) -EHsc src\testLibras.cpp $(FILES) $(CFLAGS) $(LFLAGS) | |
38 | 38 | $(CLEAN_OBJ) |
39 | 39 | |
40 | 40 | #Gera dll na arquitetura x86 | ... | ... |
include/util.h
... | ... | @@ -1,46 +0,0 @@ |
1 | -#using <System.dll> | |
2 | -#using <System.Xml.dll> | |
3 | - | |
4 | -#include <iostream> | |
5 | -#include <string> | |
6 | -#include <vector> | |
7 | - | |
8 | - | |
9 | -using namespace std; | |
10 | -using namespace System; | |
11 | - | |
12 | -using namespace System::Net; | |
13 | -using namespace System::IO; | |
14 | -using namespace System::Xml; | |
15 | - | |
16 | - | |
17 | - | |
18 | - | |
19 | - | |
20 | - | |
21 | - | |
22 | - | |
23 | - public ref class Util { | |
24 | - | |
25 | - private: | |
26 | - static string clrStringTostring(String^ strIn); | |
27 | - static vector <string> localVersion(void); | |
28 | - | |
29 | - public: | |
30 | - static bool down; | |
31 | - static WebClient^ myWebClient; | |
32 | - | |
33 | - Util(); | |
34 | - | |
35 | - bool downloading; | |
36 | - | |
37 | - static bool checkNet(void); | |
38 | - static vector <string> checkVersion(bool atualize); | |
39 | - | |
40 | - | |
41 | - }; | |
42 | - | |
43 | - | |
44 | - | |
45 | - | |
46 | - |
... | ... | @@ -0,0 +1,83 @@ |
1 | +::############################## Instalador VLibras ############################ | |
2 | +::# # | |
3 | +::# Bruno Santos # | |
4 | +::# brunosantos@lavid.ufpb.br # | |
5 | +::# # | |
6 | +::############################################################################## | |
7 | + | |
8 | +::Define Título da janela do prompt | |
9 | +TITLE Instalador VLibras-Core Windows | |
10 | + | |
11 | +::Limpa a tela | |
12 | +CLS | |
13 | + | |
14 | +::Desabilita mensagens | |
15 | +@ECHO off | |
16 | + | |
17 | +ECHO ############### Instalando VLibras ############### | |
18 | + | |
19 | +::################# Variáveis de Ambiente ################# | |
20 | +ECHO Exportando Variaveis de Ambiente: | |
21 | + | |
22 | +ECHO AELIUS_DATA | |
23 | +SETX AELIUS_DATA %HOMEDRIVE%\vlibras-libs\aelius_data /M | |
24 | + | |
25 | +ECHO NLTK_DATA | |
26 | +SETX NLTK_DATA %HOMEDRIVE%\vlibras-libs\nltk_data /M | |
27 | + | |
28 | +ECHO HUNPOS_TAGGER | |
29 | +SETX HUNPOS_TAGGER %HOMEDRIVE%\vlibras-libs\bin\hunpos-tag.exe /M | |
30 | + | |
31 | +ECHO PYTHONPATH | |
32 | +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 | |
33 | + | |
34 | +@echo off | |
35 | +set path_value=%PATH% | |
36 | + | |
37 | +If NOT "%path_value%"=="%path_value:vlibras=%" ( | |
38 | + echo ok | |
39 | +) else ( | |
40 | + SETX "PATH" "%PATH%";%HOMEDRIVE%\vlibras-libs\bin;%HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages /M | |
41 | +) | |
42 | + | |
43 | +::################# Instalação do Python ################# | |
44 | +msiexec /i python-2.7.9.msi /passive | |
45 | +ECHO OK | |
46 | + | |
47 | +::################# Dependências ################# | |
48 | +c:\Python27\python.exe pip-6.0.8-py2.py3-none-any.whl/pip install pip-6.0.8-py2.py3-none-any.whl | |
49 | +ECHO OK | |
50 | + | |
51 | +c:\Python27\Scripts\pip install PyYAML-3.11-cp27-none-win32.whl | |
52 | +ECHO OK | |
53 | + | |
54 | +c:\Python27\Scripts\pip install numpy-1.9.2+mkl-cp27-none-win32.whl | |
55 | +ECHO OK | |
56 | + | |
57 | +c:\Python27\Scripts\pip install six-1.9.0-py2.py3-none-any.whl | |
58 | +ECHO OK | |
59 | + | |
60 | +c:\Python27\Scripts\pip install pyparsing-2.0.3-py2-none-any.whl | |
61 | +ECHO OK | |
62 | + | |
63 | +c:\Python27\Scripts\pip install pytz-2014.10-py2.py3-none-any.whl | |
64 | +ECHO OK | |
65 | + | |
66 | +c:\Python27\Scripts\pip install python_dateutil-2.4.0-py2.py3-none-any.whl | |
67 | +ECHO OK | |
68 | + | |
69 | +c:\Python27\Scripts\pip install matplotlib-1.4.3-cp27-none-win32.whl | |
70 | +ECHO OK | |
71 | + | |
72 | +c:\Python27\Scripts\pip install nltk-3.0.2-py2.py3-none-any.whl | |
73 | +ECHO OK | |
74 | + | |
75 | +c:\Python27\Scripts\pip install future-0.14.3-py2-none-any.whl | |
76 | +ECHO OK | |
77 | + | |
78 | +::################# HUNPOS.PY & DATA.PY ############################# | |
79 | +COPY %HOMEDRIVE%\vlibras-libs\nltk_data\hunpos.py %homedrive%\Python27\Lib\site-packages\nltk\tag\ /y | |
80 | +COPY %HOMEDRIVE%\vlibras-libs\nltk_data\data.py %homedrive%\Python27\Lib\site-packages\nltk /y | |
81 | +COPY %HOMEDRIVE%\vlibras-libs\nltk_data\nltk_tgrep.py %homedrive%\Python27\Lib\site-packages /y | |
82 | + | |
83 | +ECHO VLibras Tradutor instalado com sucesso! | ... | ... |
install/inno setup/user_install.bat
... | ... | @@ -1,83 +0,0 @@ |
1 | -::############################## Instalador VLibras ############################ | |
2 | -::# # | |
3 | -::# Bruno Santos # | |
4 | -::# brunosantos@lavid.ufpb.br # | |
5 | -::# # | |
6 | -::############################################################################## | |
7 | - | |
8 | -::Define Título da janela do prompt | |
9 | -TITLE Instalador VLibras-Core Windows | |
10 | - | |
11 | -::Limpa a tela | |
12 | -CLS | |
13 | - | |
14 | -::Desabilita mensagens | |
15 | -@ECHO off | |
16 | - | |
17 | -ECHO ############### Instalando VLibras ############### | |
18 | - | |
19 | -::################# Variáveis de Ambiente ################# | |
20 | -ECHO Exportando Variaveis de Ambiente: | |
21 | - | |
22 | -ECHO AELIUS_DATA | |
23 | -SETX AELIUS_DATA %HOMEDRIVE%\vlibras-libs\aelius_data /M | |
24 | - | |
25 | -ECHO NLTK_DATA | |
26 | -SETX NLTK_DATA %HOMEDRIVE%\vlibras-libs\nltk_data /M | |
27 | - | |
28 | -ECHO HUNPOS_TAGGER | |
29 | -SETX HUNPOS_TAGGER %HOMEDRIVE%\vlibras-libs\bin\hunpos-tag.exe /M | |
30 | - | |
31 | -ECHO PYTHONPATH | |
32 | -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 | |
33 | - | |
34 | -@echo off | |
35 | -set path_value=%PATH% | |
36 | - | |
37 | -If NOT "%path_value%"=="%path_value:vlibras=%" ( | |
38 | - echo ok | |
39 | -) else ( | |
40 | - SETX "PATH" "%PATH%";%HOMEDRIVE%\vlibras-libs\bin;%HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages /M | |
41 | -) | |
42 | - | |
43 | -::################# Instalação do Python ################# | |
44 | -msiexec /i python-2.7.9.msi /passive | |
45 | -ECHO OK | |
46 | - | |
47 | -::################# Dependências ################# | |
48 | -c:\Python27\python.exe pip-6.0.8-py2.py3-none-any.whl/pip install pip-6.0.8-py2.py3-none-any.whl | |
49 | -ECHO OK | |
50 | - | |
51 | -c:\Python27\Scripts\pip install PyYAML-3.11-cp27-none-win32.whl | |
52 | -ECHO OK | |
53 | - | |
54 | -c:\Python27\Scripts\pip install numpy-1.9.2+mkl-cp27-none-win32.whl | |
55 | -ECHO OK | |
56 | - | |
57 | -c:\Python27\Scripts\pip install six-1.9.0-py2.py3-none-any.whl | |
58 | -ECHO OK | |
59 | - | |
60 | -c:\Python27\Scripts\pip install pyparsing-2.0.3-py2-none-any.whl | |
61 | -ECHO OK | |
62 | - | |
63 | -c:\Python27\Scripts\pip install pytz-2014.10-py2.py3-none-any.whl | |
64 | -ECHO OK | |
65 | - | |
66 | -c:\Python27\Scripts\pip install python_dateutil-2.4.0-py2.py3-none-any.whl | |
67 | -ECHO OK | |
68 | - | |
69 | -c:\Python27\Scripts\pip install matplotlib-1.4.3-cp27-none-win32.whl | |
70 | -ECHO OK | |
71 | - | |
72 | -c:\Python27\Scripts\pip install nltk-3.0.2-py2.py3-none-any.whl | |
73 | -ECHO OK | |
74 | - | |
75 | -c:\Python27\Scripts\pip install future-0.14.3-py2-none-any.whl | |
76 | -ECHO OK | |
77 | - | |
78 | -::################# HUNPOS.PY & DATA.PY ############################# | |
79 | -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\hunpos.py %homedrive%\Python27\Lib\site-packages\nltk\tag\ /y | |
80 | -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\data.py %homedrive%\Python27\Lib\site-packages\nltk /y | |
81 | -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\nltk_tgrep.py %homedrive%\Python27\Lib\site-packages /y | |
82 | - | |
83 | -ECHO VLibras Tradutor instalado com sucesso! |
install/inno setup/user_install.iss
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | ;##################################################################### |
7 | 7 | |
8 | 8 | #define MyAppName "VLibras" |
9 | -#define MyAppVersion "beta" | |
9 | +#define MyAppVersion "3.0.0" | |
10 | 10 | #define MyAppPublisher "LAViD" |
11 | 11 | #define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" |
12 | 12 | #define MyAppExeName "VlibrasPlayer.exe" |
... | ... | @@ -24,9 +24,9 @@ AppUpdatesURL={#MyAppURL} |
24 | 24 | DefaultDirName={sd}\vlibras-libs |
25 | 25 | DisableDirPage=yes |
26 | 26 | DefaultGroupName={#MyAppName} |
27 | -OutputBaseFilename=vlibras_desktop_win_2.0.0 | |
27 | +OutputBaseFilename=vlibras_instalador_3.0.0 | |
28 | 28 | DisableProgramGroupPage=yes |
29 | -OutputDir="C:\Users\ezequiel\Desktop\vlibras_installer_2.0.0" | |
29 | +OutputDir="C:\Users\ezequiel\Desktop\vlibras_installer_3.0.0" | |
30 | 30 | SetupIconFile="C:\Users\ezequiel\Desktop\user_install\icons\icon_vlibras.ico" |
31 | 31 | Compression=lzma |
32 | 32 | SolidCompression=yes |
... | ... | @@ -43,8 +43,8 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ |
43 | 43 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 |
44 | 44 | |
45 | 45 | [Files] |
46 | -;Source: "C:\Users\ezequiel\Desktop\vc_redist.x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; | |
47 | -;Source: "C:\Users\ezequiel\Desktop\dotNetFx40_Client_x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; | |
46 | + | |
47 | +;Source: "C:\Users\ezequiel\Desktop\dotnetfx45_full_x86_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; | |
48 | 48 | Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs |
49 | 49 | |
50 | 50 | |
... | ... | @@ -58,13 +58,11 @@ Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; |
58 | 58 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" |
59 | 59 | |
60 | 60 | [Run] |
61 | -;Filename: {tmp}\dotNetFx40_Client_x86.exe; Flags: runhidden; Parameters: /q /norestart; StatusMsg: Instalando .NET Framework 4.5 | |
62 | -;Filename: {tmp}\vc_redist.x86.exe; Flags: runhidden; Parameters: /q /norestart; StatusMsg: Instalando Visual C++ ... | |
63 | 61 | Filename: {sd}\vlibras-libs\required\user_install.bat; Flags: runhidden; StatusMsg: Finalizando Instalação... |
64 | -Filename: {sd}\vlibras-libs\update\vlibras-up.exe; StatusMsg: Instalando atualização... | |
65 | - | |
62 | +Filename: {sd}\vlibras-libs\update\vlibrasPlayerDictUp.exe; StatusMsg: Instalando atualização... | |
66 | 63 | |
67 | 64 | |
65 | + | |
68 | 66 | |
69 | 67 | |
70 | 68 | ... | ... |
plugin/corePlugin.cpp
... | ... | @@ -5,27 +5,24 @@ |
5 | 5 | #define EXPORT_API __declspec(dllimport) |
6 | 6 | #endif |
7 | 7 | |
8 | -#include <process.h> | |
9 | 8 | #include "corePlugin.h" |
9 | +#include <time.h> | |
10 | 10 | |
11 | - | |
11 | +using namespace std; | |
12 | 12 | |
13 | 13 | |
14 | 14 | extern "C" |
15 | 15 | { |
16 | - | |
17 | 16 | |
18 | - | |
17 | + | |
19 | 18 | EXPORT_API int coreInitialize() |
20 | 19 | { |
21 | 20 | //Objeto usado para traduzir |
22 | 21 | tradutor = new PyTradutor(); |
23 | - checkversion = new CheckVersion(); | |
24 | - check =0; | |
25 | - | |
22 | + update = new PyVlibrasUpdate(); | |
26 | 23 | //Objeto usado para copiar texto da área de transferência |
27 | 24 | clipboard.bdragOn(); |
28 | - | |
25 | + | |
29 | 26 | return 1; |
30 | 27 | } |
31 | 28 | |
... | ... | @@ -41,86 +38,55 @@ |
41 | 38 | |
42 | 39 | EXPORT_API int coreUpdateInstall_player() |
43 | 40 | { |
44 | - | |
45 | - char szPath[] = "C:\\vlibras-libs\\update\\vlibras-up.exe"; | |
46 | - string params = "C:\\vlibras-libs\\update\\vlibras-up.exe "; | |
47 | - params.append(checkversion->playerUrl); | |
48 | - params.append(" installer "); | |
49 | - params.append(checkversion->playerVersionFull); | |
50 | - PROCESS_INFORMATION pif; //Gives info on the thread and.. | |
51 | - //..process for the new process | |
52 | - STARTUPINFO si; //Defines how to start the program | |
53 | - | |
54 | - ZeroMemory(&si,sizeof(si)); //Zero the STARTUPINFO struct | |
55 | - si.cb = sizeof(si); //Must set size of structure | |
56 | - | |
57 | - BOOL bRet = CreateProcess( | |
58 | - szPath, //Path to executable file | |
59 | - (LPSTR)params.c_str(), //Command string - not needed here | |
60 | - NULL, //Process handle not inherited | |
61 | - NULL, //Thread handle not inherited | |
62 | - FALSE, //No inheritance of handles | |
63 | - 0, //No special flags | |
64 | - NULL, //Same environment block as this prog | |
65 | - NULL, //Current directory - no separate path | |
66 | - &si, //Pointer to STARTUPINFO | |
67 | - &pif); //Pointer to PROCESS_INFORMATION | |
41 | + update->install("c:\\vlibras-libs\\update\\bin\\vlibrasPlayerDictUp.exe","NULL"); | |
68 | 42 | |
69 | - | |
70 | - | |
71 | - CloseHandle(pif.hProcess); //Close handle to process | |
72 | - CloseHandle(pif.hThread); | |
73 | - | |
74 | 43 | return 1; |
75 | 44 | } |
76 | 45 | |
77 | 46 | |
78 | 47 | EXPORT_API int coreUpdateInstall_dict() |
79 | 48 | { |
80 | - char szPath[] = "C:\\vlibras-libs\\update\\vlibras-up.exe"; | |
81 | - string params = "C:\\vlibras-libs\\update\\vlibras-up.exe "; | |
82 | - params.append(checkversion->dictUrl.c_str()); | |
83 | - params.append(" dictionary "); | |
84 | - params.append(checkversion->dictVersionFull); | |
85 | - PROCESS_INFORMATION pif; //Gives info on the thread and.. | |
86 | - //..process for the new process | |
87 | - STARTUPINFO si; //Defines how to start the program | |
88 | - | |
89 | - ZeroMemory(&si,sizeof(si)); //Zero the STARTUPINFO struct | |
90 | - si.cb = sizeof(si); //Must set size of structure | |
91 | - | |
92 | - BOOL bRet = CreateProcess( | |
93 | - szPath, //Path to executable file | |
94 | - (LPSTR)params.c_str(), //Command string - not needed here | |
95 | - NULL, //Process handle not inherited | |
96 | - NULL, //Thread handle not inherited | |
97 | - FALSE, //No inheritance of handles | |
98 | - 0, //No special flags | |
99 | - NULL, //Same environment block as this prog | |
100 | - NULL, //Current directory - no separate path | |
101 | - &si, //Pointer to STARTUPINFO | |
102 | - &pif); //Pointer to PROCESS_INFORMATION | |
103 | - | |
104 | - CloseHandle(pif.hProcess); //Close handle to process | |
105 | - CloseHandle(pif.hThread); | |
49 | + update->install("c:\\vlibras-libs\\update\\bin\\vlibrasPlayerDictUp.exe","NULL"); | |
106 | 50 | |
107 | 51 | return 1; |
108 | 52 | } |
109 | 53 | |
110 | 54 | |
111 | - | |
112 | 55 | EXPORT_API int coreUpdateCheck() |
113 | 56 | { |
114 | - | |
115 | - checkversion->checkRefresh(); | |
116 | - | |
117 | - return checkversion->vstatus; | |
57 | + | |
58 | + string line_in_str; | |
59 | + ifstream file_version; | |
60 | + int return_int = -1; | |
61 | + try | |
62 | + { | |
63 | + update->checkExe("C:\\Python27\\python.exe c:\\vlibras-libs\\update\\py\\VlibrasCheckVersion.pyc","check"); | |
64 | + | |
65 | + clock_t time_end; | |
66 | + time_end = clock() + 3000 * CLOCKS_PER_SEC/1000; | |
67 | + while (clock() < time_end); | |
68 | + | |
69 | + | |
70 | + file_version.open("c:\\vlibras-libs\\update\\version\\version.txt"); | |
71 | + | |
72 | + getline(file_version, line_in_str); | |
73 | + file_version.close(); | |
74 | + return_int = atoi(line_in_str.c_str()); | |
75 | + | |
76 | + return return_int; | |
77 | + } | |
78 | + catch (exception e) | |
79 | + { | |
80 | + return -1; | |
81 | + } | |
82 | + return return_int; | |
118 | 83 | } |
119 | 84 | |
120 | 85 | EXPORT_API int coreFinalize() |
121 | 86 | { |
122 | 87 | clipboard.bdragOff(); |
123 | 88 | delete tradutor; |
89 | + delete update; | |
124 | 90 | return 1; |
125 | 91 | } |
126 | 92 | ... | ... |
plugin/corePlugin.h
... | ... | @@ -21,8 +21,9 @@ VLibras-Core |
21 | 21 | |
22 | 22 | #include "pyClip.h" |
23 | 23 | #include "pyTradutor.h" |
24 | -#include "checkVersion.h" | |
25 | -#include <string.h> | |
24 | +#include "pyVlibrasUpdate.h" | |
25 | +#include <fstream> | |
26 | +#include <string> | |
26 | 27 | |
27 | 28 | |
28 | 29 | using namespace std; |
... | ... | @@ -31,12 +32,13 @@ extern "C" |
31 | 32 | { |
32 | 33 | //Usado para traduzir português para glosa |
33 | 34 | PyTradutor *tradutor; |
34 | - int check; | |
35 | + | |
36 | + | |
35 | 37 | //Usado para copiar texto da área de transferência |
36 | 38 | PyClip clipboard; |
37 | 39 | |
38 | 40 | //Usado para verificar se existe atualização |
39 | - CheckVersion *checkversion; | |
41 | + PyVlibrasUpdate *update; | |
40 | 42 | |
41 | 43 | //Inicializa Objetos |
42 | 44 | EXPORT_API int coreInitize(void); | ... | ... |
plugin/testPlugin.cpp
... | ... | @@ -13,7 +13,14 @@ metodo2 execute; |
13 | 13 | typedef int (WINAPI*metodo3)(); |
14 | 14 | metodo3 finalize; |
15 | 15 | typedef int (WINAPI*metodo4)(); |
16 | -metodo4 update; | |
16 | +metodo4 coreUpdateCheck; | |
17 | + | |
18 | +typedef int (WINAPI*metodo5)(); | |
19 | +metodo5 coreUpdateInstall_player; | |
20 | + | |
21 | +typedef int (WINAPI*metodo6)(); | |
22 | +metodo6 coreUpdateInstall_dict; | |
23 | + | |
17 | 24 | |
18 | 25 | int main(int argc, char *argv[]) |
19 | 26 | { |
... | ... | @@ -29,26 +36,26 @@ int main(int argc, char *argv[]) |
29 | 36 | initialize=(metodo1)GetProcAddress((HMODULE)hDLL, "coreInitialize"); |
30 | 37 | execute=(metodo2)GetProcAddress((HMODULE)hDLL, "coreExecute"); |
31 | 38 | finalize=(metodo3)GetProcAddress((HMODULE)hDLL, "coreFinalize"); |
32 | - update=(metodo4)GetProcAddress((HMODULE)hDLL, "coreUpdate"); | |
39 | + coreUpdateCheck=(metodo4)GetProcAddress((HMODULE)hDLL, "coreUpdateCheck"); | |
40 | + coreUpdateInstall_player=(metodo5)GetProcAddress((HMODULE)hDLL, "coreUpdateInstall_player"); | |
41 | + coreUpdateInstall_dict=(metodo6)GetProcAddress((HMODULE)hDLL, "coreUpdateInstall_dict"); | |
33 | 42 | |
34 | 43 | //Executa coreInitialize |
35 | 44 | int init = initialize(); |
36 | 45 | cout <<"return initialize: " << init <<endl; |
37 | 46 | |
38 | - int in = update(); | |
39 | - cout <<"return update: " << in <<endl; | |
47 | + int a = coreUpdateCheck(); | |
48 | + cout <<"return coreUpdateCheck: " << a <<endl; | |
49 | + | |
50 | + int b = coreUpdateInstall_player(); | |
51 | + cout <<"return coreUpdateInstall_player: " << b <<endl; | |
52 | + | |
53 | + int c = coreUpdateInstall_dict(); | |
54 | + cout <<"return coreUpdateInstall_dict: " << c <<endl; | |
55 | + | |
56 | + | |
40 | 57 | |
41 | - //in = update(); | |
42 | - //cout <<"return update2: " << in <<endl; | |
43 | 58 | |
44 | - //in=0; | |
45 | - //in = update(); | |
46 | - //cout <<"return update3: " << in <<endl; | |
47 | - | |
48 | - //Executa coreExecute | |
49 | - //char* exec = execute(); | |
50 | - //cout << "return execute: " << exec <<endl; | |
51 | -while(1); | |
52 | 59 | //Executa coreFinalize |
53 | 60 | int final = finalize(); |
54 | 61 | cout << "return finalize: " << final <<endl; | ... | ... |
src/pyClip.cpp
... | ... | @@ -55,7 +55,7 @@ PyClip::~PyClip() |
55 | 55 | char * PyClip::clip() |
56 | 56 | { |
57 | 57 | // Call the callable object 'pFunc' with arguments given by the tuple 'pArgs' |
58 | - pResult = PyObject_CallObject(pFunc,pArgs); | |
58 | + pResult = PyObject_CallObject(pFunc,NULL); | |
59 | 59 | assert(pResult!=NULL); |
60 | 60 | |
61 | 61 | return PyString_AsString(pResult); | ... | ... |
src/util.cpp
... | ... | @@ -1,165 +0,0 @@ |
1 | -#include <windows.h> | |
2 | -#include "util.h" | |
3 | - | |
4 | - | |
5 | - | |
6 | -Util::Util(){ | |
7 | - //downloading = true; | |
8 | - //downloading = down; | |
9 | -} | |
10 | - | |
11 | -string Util::clrStringTostring(String^ strIn) | |
12 | -{ | |
13 | - | |
14 | - char cStr[256]; | |
15 | - | |
16 | - | |
17 | - sprintf(cStr, "%s", strIn); | |
18 | - string stlString(cStr); | |
19 | - | |
20 | - return stlString; | |
21 | -} | |
22 | - | |
23 | - | |
24 | - | |
25 | -bool Util::checkNet() | |
26 | -{ | |
27 | - | |
28 | - try | |
29 | - { | |
30 | - | |
31 | - WebRequest^ request = WebRequest::Create( "http://vlibras.lavid.ufpb.br" ); | |
32 | - | |
33 | - // If required by the server, set the credentials. | |
34 | - //request->Credentials = CredentialCache::DefaultCredentials; | |
35 | - | |
36 | - // Get the response. | |
37 | - HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse()); | |
38 | - | |
39 | - if (response->StatusDescription == "OK"){ | |
40 | - | |
41 | - return true; | |
42 | - } | |
43 | - return false; | |
44 | - response->Close(); | |
45 | - } | |
46 | - catch ( WebException^ e ) | |
47 | - { | |
48 | - return false; | |
49 | - } | |
50 | - | |
51 | -} | |
52 | - | |
53 | - | |
54 | -vector<string> Util::checkVersion(bool atualize) | |
55 | -{ | |
56 | - XmlDocument^ xmlDoc; | |
57 | - XmlNodeList^ files; | |
58 | - XmlDocument^ xmlDocLocal; | |
59 | - XmlNodeList^ filesLocal; | |
60 | - vector<string> updates; | |
61 | - vector<string> localversion = localVersion(); | |
62 | - try | |
63 | - { | |
64 | - xmlDoc = (gcnew XmlDocument()); | |
65 | - xmlDocLocal = (gcnew XmlDocument()); | |
66 | - | |
67 | - | |
68 | - string url = "http://vlibras.lavid.ufpb.br/api/dicionario/"+localversion[3]+"?type=windows"; | |
69 | - WebRequest^ request = WebRequest::Create( gcnew String(url.c_str())); | |
70 | - // If required by the server, set the credentials. | |
71 | - request->Credentials = CredentialCache::DefaultCredentials; | |
72 | - // Get the response. | |
73 | - HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse()); | |
74 | - if (!(response->StatusDescription == "OK")) | |
75 | - goto erro; | |
76 | - // Get the stream containing content returned by the server. | |
77 | - Stream^ dataStream = response->GetResponseStream(); | |
78 | - // Open the stream using a StreamReader for easy access. | |
79 | - StreamReader^ reader = gcnew StreamReader( dataStream ); | |
80 | - // Read the content. | |
81 | - String^ responseFromServer = reader->ReadToEnd(); | |
82 | - xmlDoc->LoadXml(responseFromServer); | |
83 | - files = xmlDoc->GetElementsByTagName("version"); | |
84 | - | |
85 | - long numitems = files->Count; | |
86 | - | |
87 | - | |
88 | - | |
89 | - //for (int i=0;i<numitems;i++) | |
90 | - if(numitems>0) | |
91 | - { | |
92 | - String^ playerVersion = files[0]["playerVersion"]->InnerText; | |
93 | - String^ dictionaryVersion = files[0]["dictionaryVersion"]->InnerText; | |
94 | - | |
95 | - if(String::Compare( playerVersion, gcnew String(localversion[1].c_str()))) | |
96 | - { | |
97 | - updates.push_back("playerVersion"); | |
98 | - updates.push_back(clrStringTostring(playerVersion)); | |
99 | - updates.push_back(clrStringTostring(files[0]["playerUrl"]->InnerText)); | |
100 | - } | |
101 | - if(String::Compare(dictionaryVersion,gcnew String(localversion[3].c_str()))) | |
102 | - { | |
103 | - updates.push_back("dictionaryVersion"); | |
104 | - updates.push_back(clrStringTostring(dictionaryVersion)); | |
105 | - updates.push_back(clrStringTostring(files[0]["dictionaryUrl"]->InnerText)); | |
106 | - } | |
107 | - | |
108 | - //if(atualize) | |
109 | - //saveNewXmlVersion(playerVersion,dictionaryVersion); | |
110 | - | |
111 | - } | |
112 | - | |
113 | - erro: | |
114 | - // Cleanup the streams and the response. | |
115 | - reader->Close(); | |
116 | - dataStream->Close(); | |
117 | - }catch(Exception^ e) | |
118 | - { | |
119 | - updates.push_back("faill"); | |
120 | - return updates; | |
121 | - } | |
122 | - | |
123 | - return updates; | |
124 | -} | |
125 | - | |
126 | - | |
127 | -vector<string> Util::localVersion() | |
128 | -{ | |
129 | - XmlDocument^ xmlDocLocal; | |
130 | - XmlNodeList^ filesLocal; | |
131 | - vector<string> updates; | |
132 | - try | |
133 | - { | |
134 | - xmlDocLocal = (gcnew XmlDocument()); | |
135 | - //xml version local | |
136 | - StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); | |
137 | - | |
138 | - String^ responseLocal = readerLocal->ReadToEnd(); | |
139 | - | |
140 | - xmlDocLocal->LoadXml(responseLocal); | |
141 | - | |
142 | - filesLocal = xmlDocLocal->GetElementsByTagName("version"); | |
143 | - | |
144 | - updates.push_back("playerVersion"); | |
145 | - String^ playerVersion = filesLocal[0]["playerVersion"]->InnerText; | |
146 | - updates.push_back(clrStringTostring(playerVersion)); | |
147 | - updates.push_back("dictionaryVersion"); | |
148 | - String^ dictionaryVersion = filesLocal[0]["dictionaryVersion"]->InnerText; | |
149 | - updates.push_back(clrStringTostring(dictionaryVersion)); | |
150 | - | |
151 | - // Cleanup the streams and the response. | |
152 | - readerLocal->Close(); | |
153 | - }catch(Exception^ e) | |
154 | - { | |
155 | - return updates; | |
156 | - } | |
157 | - | |
158 | - return updates; | |
159 | -} | |
160 | - | |
161 | - | |
162 | - | |
163 | - | |
164 | - | |
165 | - | |
166 | 0 | \ No newline at end of file |
update/Makefile
1 | 1 | ############################## MAKEFILE VLIBRAS ############################ |
2 | 2 | # # |
3 | -# Bruno Santos # | |
4 | -# brunosantos@lavid.ufpb.br # | |
5 | 3 | # Ezequiel Silva # |
6 | 4 | # ezequielsilva@lavid.ufpb.br # # |
7 | 5 | # # |
8 | 6 | ############################################################################ |
9 | 7 | |
10 | -# Includes | |
11 | -CFLAGS = -I include | |
12 | - | |
13 | -# Link com as libs utilizadas | |
14 | -#LFLAGS = -link C:\Python27\libs\python27.lib | |
15 | 8 | |
16 | 9 | # Compilador Nativo |
17 | 10 | CC = cl |
18 | 11 | |
19 | -# Nome do arquivo de saída | |
20 | -OUT = vlibras-up | |
21 | - | |
22 | -# Arquivos de implementação | |
23 | -FILES = src\util.cpp src\janelaAtualizacao.cpp | |
12 | +OUTDICT = vlibrasPlayerDictUp | |
24 | 13 | |
25 | -#Headers | |
26 | -INCLUDES = include\util.h include\janelaAtualizacao.h | |
27 | 14 | |
28 | -CLEAN_OBJ = del -q *.obj | |
15 | +CLEAN_OBJ = del -q *.obj | |
29 | 16 | |
30 | -HOME = %homepath% | |
31 | 17 | |
32 | -#Gera executável testLibras | |
33 | -all: $(FILES) $(INCLUDES) | |
34 | - $(CC) -Fe$(OUT) -clr vlibrasUpdate.cpp $(FILES) $(CFLAGS) | |
18 | +#Gera executável | |
19 | +all: | |
20 | + $(CC) -Fe$(OUTDICT) -EHsc vlibrasDictPlayerInstall.cpp | |
35 | 21 | $(CLEAN_OBJ) |
36 | 22 | |
37 | 23 | |
38 | - | |
39 | - | |
40 | 24 | #Limpa arquivos objetos e executáveis criados |
41 | 25 | clean: |
42 | 26 | del -q *.exe *.obj | ... | ... |
update/include/checkVersion.h
... | ... | @@ -1,53 +0,0 @@ |
1 | -//***************************************************************** | |
2 | -/* | |
3 | -VLibras: Verificação de atualização | |
4 | - | |
5 | - | |
6 | -Ezequiel Silva | |
7 | -ezequielsilva@lavid.ufpb.br | |
8 | -VLibras-Core | |
9 | -2015 | |
10 | -*/ | |
11 | -//***************************************************************** | |
12 | - | |
13 | -/** | |
14 | -* \file checkVersion.h | |
15 | -* \Ezequiel Silva | |
16 | -* \date Outubro 2015 | |
17 | -*/ | |
18 | - | |
19 | - | |
20 | - | |
21 | -#include <tchar.h> | |
22 | -#include <iostream> | |
23 | -#include <string> | |
24 | -#include <fstream> | |
25 | -#include <urlmon.h> | |
26 | - | |
27 | -#pragma comment(lib, "urlmon.lib") | |
28 | -using namespace std; | |
29 | - | |
30 | - class CheckVersion | |
31 | -{ | |
32 | - | |
33 | -private: | |
34 | - void checkLocal(); | |
35 | - void checkApi(); | |
36 | - void reset(); | |
37 | -public: | |
38 | - long playerVersion = -1; | |
39 | - long dictVersion = -1; | |
40 | - long localPlayerVersion = -1; | |
41 | - long localDictVersion = -1; | |
42 | - string playerVersionFull = ""; | |
43 | - string dictVersionFull = ""; | |
44 | - string playerUrl = ""; | |
45 | - string dictUrl = ""; | |
46 | - string dictCallVersion ="0.0.0_0.0.0"; | |
47 | - int vstatus = -1; | |
48 | - | |
49 | - CheckVersion(); | |
50 | - void checkRefresh(); | |
51 | - | |
52 | - | |
53 | -}; | |
54 | 0 | \ No newline at end of file |
update/include/janelaAtualizacao.h
... | ... | @@ -1,66 +0,0 @@ |
1 | -//***************************************************************** | |
2 | -/* | |
3 | -VLibras: Atualização | |
4 | - | |
5 | - | |
6 | -Ezequiel Silva | |
7 | -ezequielsilva@lavid.ufpb.br | |
8 | -VLibras-Core | |
9 | -2015 | |
10 | -*/ | |
11 | -//***************************************************************** | |
12 | - | |
13 | -/** | |
14 | -* \file checkVersion.h | |
15 | -* \Ezequiel Silva | |
16 | -* \date Outubro 2015 | |
17 | -*/ | |
18 | - | |
19 | -// ############### NÃO USADO ################### | |
20 | - | |
21 | - | |
22 | - | |
23 | -#include <string> | |
24 | - | |
25 | -#using <System.dll> | |
26 | -#using <System.Windows.Forms.dll> | |
27 | -#using <System.Drawing.dll> | |
28 | - | |
29 | - | |
30 | -using namespace System::Windows::Forms; | |
31 | -using namespace System; | |
32 | -using namespace System::Drawing; | |
33 | -using namespace System::ComponentModel; | |
34 | -using namespace std; | |
35 | - | |
36 | -public ref class JanelaAtualizacao : public Form | |
37 | -{ | |
38 | - private: | |
39 | - | |
40 | - bool downloading; | |
41 | - RichTextBox^ richTextBox1; | |
42 | - Label^ lbInformacao; | |
43 | - Label^ topo; | |
44 | - int vez=0; | |
45 | - Bitmap^ animatedImage; | |
46 | - String^ informacao; | |
47 | - void btOKevent(Object^ sender, EventArgs^ e); | |
48 | - void XFormClosing(Object^ sender, FormClosingEventArgs^ e); | |
49 | - | |
50 | - public: | |
51 | - static ProgressBar^ progressBar1; | |
52 | - static Label^ lbInfDownload; | |
53 | - Button^ btOK; | |
54 | - JanelaAtualizacao(); | |
55 | - | |
56 | - void initializeComponent(); | |
57 | - void setInfoWhite(String^ info); | |
58 | - void setInfoGreen(String^ info); | |
59 | - void setInfoRed(String^ info); | |
60 | - void start(); | |
61 | - void EnableButton(); | |
62 | - | |
63 | - | |
64 | - | |
65 | -}; | |
66 | - |
... | ... | @@ -0,0 +1,31 @@ |
1 | +//***************************************************************** | |
2 | +/* | |
3 | + | |
4 | +Copyright (c) 2015 Ezequiel Silva | |
5 | +VLibras-Core group at LAViD, Federal University of Paraiba | |
6 | +*/ | |
7 | +//***************************************************************** | |
8 | + | |
9 | +/** | |
10 | +* \file pyVlibrasUpdate.h | |
11 | +* \authors Ezequiel Silva | |
12 | +* \date Setembro 2015 | |
13 | +*/ | |
14 | +#ifndef _PHVLIBRASUPDATE_H | |
15 | +#define _PHVLIBRASUPDATE_H | |
16 | + | |
17 | +#include <windows.h> | |
18 | + | |
19 | +/** \brief Classe para execução do Vlibras Update. | |
20 | +* | |
21 | +*/ | |
22 | +class PyVlibrasUpdate | |
23 | +{ | |
24 | + | |
25 | + public: | |
26 | + int install(char* strFunct, char* strstrParams); | |
27 | + void checkExe(char* strFunct, char* strstrParams); | |
28 | + | |
29 | +}; | |
30 | + | |
31 | +#endif | |
0 | 32 | \ No newline at end of file | ... | ... |
update/include/util.h
... | ... | @@ -1,51 +0,0 @@ |
1 | -#using <System.dll> | |
2 | -#using <System.Xml.dll> | |
3 | -#using <System.IO.Compression.FileSystem.dll> | |
4 | - | |
5 | -#include <iostream> | |
6 | -#include <string> | |
7 | -#include <vector> | |
8 | - | |
9 | - | |
10 | -using namespace std; | |
11 | -using namespace System; | |
12 | -using namespace System::ComponentModel; | |
13 | -using namespace System::Net; | |
14 | -using namespace System::IO; | |
15 | -using namespace System::Xml; | |
16 | -using namespace System::Threading; | |
17 | -using namespace System::IO::Compression; | |
18 | - | |
19 | - | |
20 | - | |
21 | - | |
22 | - | |
23 | - | |
24 | - | |
25 | - public ref class Util { | |
26 | - | |
27 | - private: | |
28 | - static string clrStringTostring(String^ strIn); | |
29 | - static vector <string> localVersion(void); | |
30 | - | |
31 | - public: | |
32 | - static bool down; | |
33 | - static WebClient^ myWebClient; | |
34 | - | |
35 | - Util(); | |
36 | - | |
37 | - bool downloading; | |
38 | - static bool saveNewXmlVersion(string playerVersion,string dictionaryVersion); | |
39 | - static string Download(DownloadProgressChangedEventHandler^ dpch ,string url, string fileName); | |
40 | - static bool checkNet(void); | |
41 | - static vector <string> checkVersion(bool atualize); | |
42 | - static bool extractZip(string zipFile, string outPath); | |
43 | - static bool backup(void); | |
44 | - static bool restore(void); | |
45 | - | |
46 | - }; | |
47 | - | |
48 | - | |
49 | - | |
50 | - | |
51 | - |
update/src/checkVersion.cpp
... | ... | @@ -1,182 +0,0 @@ |
1 | - | |
2 | - | |
3 | -#include "checkVersion.h" | |
4 | - | |
5 | -using namespace std; | |
6 | - | |
7 | - | |
8 | - | |
9 | - CheckVersion::CheckVersion() | |
10 | - { | |
11 | - //reset(); | |
12 | - } | |
13 | - | |
14 | - void CheckVersion::checkRefresh() | |
15 | - { | |
16 | - reset(); | |
17 | - checkLocal(); | |
18 | - checkApi(); | |
19 | - if(!(localDictVersion == -1 || dictVersion == -1 || localPlayerVersion == -1 || playerVersion == -1)) | |
20 | - { | |
21 | - vstatus = 0; | |
22 | - if(localDictVersion < dictVersion && localPlayerVersion < playerVersion) | |
23 | - vstatus=1; | |
24 | - else if(localPlayerVersion < playerVersion) | |
25 | - vstatus = 1; | |
26 | - else if(localDictVersion < dictVersion) | |
27 | - vstatus = 2; | |
28 | - } | |
29 | - else | |
30 | - vstatus = -1; | |
31 | - | |
32 | - } | |
33 | - | |
34 | - | |
35 | - | |
36 | - | |
37 | -void find_and_replace(string& source, string const& find, string const& replace) | |
38 | -{ | |
39 | - for(string::size_type i = 0; (i = source.find(find, i)) != string::npos;) | |
40 | - { | |
41 | - source.replace(i, find.length(), replace); | |
42 | - i += replace.length(); | |
43 | - } | |
44 | -} | |
45 | - | |
46 | - | |
47 | -void CheckVersion::checkLocal() | |
48 | -{ | |
49 | - | |
50 | - int result = 0; | |
51 | - string line; | |
52 | - ifstream myfile ("c:\\vlibras-libs\\update\\updateVersion.xml"); | |
53 | - | |
54 | - if (myfile.is_open()) | |
55 | - { | |
56 | - while ( getline(myfile,line) ) | |
57 | - { | |
58 | - if(strstr(line.c_str(),"<dictionaryVersion>")) | |
59 | - { | |
60 | - string version; | |
61 | - int ia = line.find("<dictionaryVersion>")+19; | |
62 | - int ib = line.find("</dictionaryVersion>")-23; | |
63 | - version = line.substr(ia,ib); | |
64 | - dictCallVersion = version; | |
65 | - find_and_replace(version,".",""); | |
66 | - find_and_replace(version,"_",""); | |
67 | - find_and_replace(version," ",""); | |
68 | - localDictVersion = atoi(version.c_str()); | |
69 | - } | |
70 | - else if(strstr(line.c_str(),"<playerVersion>")) | |
71 | - { | |
72 | - string version; | |
73 | - int ia = line.find("<playerVersion>")+15; | |
74 | - int ib = line.find("</playerVersion>")-19; | |
75 | - version = line.substr(ia,ib); | |
76 | - find_and_replace(version,".",""); | |
77 | - find_and_replace(version,"_",""); | |
78 | - find_and_replace(version," ",""); | |
79 | - localPlayerVersion = atoi(version.c_str()); | |
80 | - } | |
81 | - | |
82 | - } | |
83 | - | |
84 | - myfile.close(); | |
85 | - | |
86 | - } | |
87 | - | |
88 | - | |
89 | - } | |
90 | - | |
91 | -void CheckVersion::checkApi() | |
92 | -{ | |
93 | - | |
94 | -cout << "dictCallVersion ====> " << dictCallVersion<< endl; | |
95 | -string url = "http://vlibras.lavid.ufpb.br/api/dicionario/"; | |
96 | -url.append(dictCallVersion); | |
97 | -url.append("?type=windows"); | |
98 | - HRESULT hr = URLDownloadToFile ( NULL, _T(url.c_str()), _T("c:\\vlibras-libs\\update\\netVersion.xml"), 0, NULL ); | |
99 | - if(SUCCEEDED(hr)){ | |
100 | - | |
101 | - string line; | |
102 | - ifstream myfile ("c:\\vlibras-libs\\update\\netVersion.xml"); | |
103 | - if (myfile.is_open()) | |
104 | - { | |
105 | - while ( getline(myfile,line) ) | |
106 | - { | |
107 | - if(strstr(line.c_str(),"<dictionaryVersion>")) | |
108 | - { | |
109 | - string version; | |
110 | - int ia = line.find("<dictionaryVersion>")+19; | |
111 | - int ib = line.find("</dictionaryVersion>")-23; | |
112 | - version = line.substr(ia,ib); | |
113 | - dictVersionFull = version; | |
114 | - find_and_replace(version,".",""); | |
115 | - find_and_replace(version,"_",""); | |
116 | - find_and_replace(version," ",""); | |
117 | - dictVersion = atoi(version.c_str()); | |
118 | - } | |
119 | - else if(strstr(line.c_str(),"<playerVersion>")) | |
120 | - { | |
121 | - string version; | |
122 | - int ia = line.find("<playerVersion>")+15; | |
123 | - int ib = line.find("</playerVersion>")-19; | |
124 | - version = line.substr(ia,ib); | |
125 | - playerVersionFull = version; | |
126 | - find_and_replace(version,".",""); | |
127 | - find_and_replace(version,"_",""); | |
128 | - find_and_replace(version," ",""); | |
129 | - playerVersion = atoi(version.c_str()); | |
130 | - | |
131 | - } | |
132 | - else if(strstr(line.c_str(),"<playerUrl>")) | |
133 | - { | |
134 | - string version; | |
135 | - int ia = line.find("<playerUrl>")+11; | |
136 | - int ib = line.find("</playerUrl>")-15; | |
137 | - version = line.substr(ia,ib); | |
138 | - playerUrl = version; | |
139 | - } | |
140 | - else if(strstr(line.c_str(),"<dictionaryUrl>")) | |
141 | - { | |
142 | - string version; | |
143 | - int ia = line.find("<dictionaryUrl>")+15; | |
144 | - int ib = line.find("</dictionaryUrl>")-19; | |
145 | - version = line.substr(ia,ib); | |
146 | - dictUrl = version; | |
147 | - } | |
148 | - } | |
149 | - myfile.close(); | |
150 | - } | |
151 | - | |
152 | - | |
153 | - } | |
154 | - | |
155 | -} | |
156 | - | |
157 | - | |
158 | -void CheckVersion::reset() | |
159 | - { | |
160 | - playerVersion = -1; | |
161 | - dictVersion = -1; | |
162 | - localPlayerVersion = -1; | |
163 | - localDictVersion = -1; | |
164 | - playerUrl = ""; | |
165 | - dictUrl = ""; | |
166 | - vstatus = -1; | |
167 | - } | |
168 | - | |
169 | -//return | |
170 | -// -1 se erro | |
171 | -//0 se não necessita de atualização | |
172 | -// 1 se tiver para player | |
173 | -// 2 se dicionario | |
174 | - | |
175 | - | |
176 | - | |
177 | - | |
178 | - | |
179 | - | |
180 | - | |
181 | - | |
182 | - |
update/src/janelaAtualizacao.cpp
... | ... | @@ -1,151 +0,0 @@ |
1 | -#include "janelaAtualizacao.h" | |
2 | -#include "Util.h" | |
3 | - | |
4 | - | |
5 | -JanelaAtualizacao::JanelaAtualizacao() | |
6 | -{ | |
7 | - initializeComponent(); | |
8 | -} | |
9 | - | |
10 | -void JanelaAtualizacao::initializeComponent() | |
11 | -{ | |
12 | - | |
13 | - this->downloading = true; | |
14 | - this->Size = System::Drawing::Size(500, 250); | |
15 | - this->progressBar1 = (gcnew ProgressBar()); | |
16 | - this->btOK = (gcnew Button()); | |
17 | - this->lbInfDownload = (gcnew Label()); | |
18 | - this->lbInformacao = (gcnew Label()); | |
19 | - this->Name = "Vlibras-Desktop-Update"; | |
20 | - this->Text = "Atualização - Vlibras-Desktop"; | |
21 | - this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog; | |
22 | - this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; | |
23 | - //this->ControlBox = false; | |
24 | - this->MaximizeBox = false; | |
25 | - this->BackColor = Drawing::Color::White; | |
26 | - //this->MinimizeBox = false; | |
27 | - //this->BackgroundImage = Image::FromFile("c:\\vlibras-libs\\image\\background.png"); | |
28 | - //this->Opacity = 0.97; | |
29 | - Drawing::Icon^ IC = gcnew Drawing::Icon("c:\\vlibras-libs\\icons\\icon_vlibras.ico"); | |
30 | - this->Icon = IC; | |
31 | - this->SuspendLayout(); | |
32 | - //this->FormBorderStyle = ::FormBorderStyle::None; | |
33 | - this->FormClosing += gcnew FormClosingEventHandler(this, &JanelaAtualizacao::XFormClosing); | |
34 | - | |
35 | - // progressBar1 | |
36 | - // | |
37 | - this->progressBar1->Location = Point(7, 85); | |
38 | - this->progressBar1->Name = "progressBar1"; | |
39 | - this->progressBar1->Size = System::Drawing::Size(470, 30); | |
40 | - //this->progressBar1->TabIndex = 0; | |
41 | - this->progressBar1->Minimum = 0; | |
42 | - this->progressBar1->Maximum = 100; | |
43 | - //this->progressBar1->Style = ProgressBarStyle::Marquee; | |
44 | - //progressBar1->Visible = false; | |
45 | - //progressBar1->Enabled = false; | |
46 | - // | |
47 | - | |
48 | - // | |
49 | - this->lbInformacao->Location = Point(7, 15); | |
50 | - this->lbInformacao->Name = "label"; | |
51 | - this->lbInformacao->Size = System::Drawing::Size(470, 23); | |
52 | - this->lbInformacao->BackColor = Drawing::Color::Transparent; | |
53 | - //this->lbInformacao->ForeColor=Drawing::Color::White; | |
54 | - | |
55 | - // | |
56 | - this->lbInfDownload->Location = Point(7, 120); | |
57 | - this->lbInfDownload->Name = "labelDownload"; | |
58 | - this->lbInfDownload->Size = System::Drawing::Size(470, 23); | |
59 | - this->lbInfDownload->BackColor = Drawing::Color::Transparent; | |
60 | - //this->lbInfDownload->Font = gcnew System::Drawing::Font("Arial", 12); | |
61 | - //this->lbInfDownload->ForeColor=Drawing::Color::White; | |
62 | - | |
63 | - | |
64 | - // btOK | |
65 | - // | |
66 | - | |
67 | - this->btOK->Location = Point(390, this->Bottom-80); | |
68 | - this->btOK->Name = "btOK"; | |
69 | - this->btOK->Size = System::Drawing::Size(80, 30); | |
70 | - this->btOK->TabIndex = 1; | |
71 | - this->btOK->Text = "OK"; | |
72 | - this->btOK->UseVisualStyleBackColor = true; | |
73 | - this->btOK->Click += gcnew EventHandler(this, &JanelaAtualizacao::btOKevent); | |
74 | - //this->btOK | |
75 | - // | |
76 | - | |
77 | - // | |
78 | - //this->Controls->Add(this->topo); | |
79 | - this->Controls->Add(this->lbInformacao); | |
80 | - this->Controls->Add(this->lbInfDownload); | |
81 | - this->Controls->Add(this->progressBar1); | |
82 | - this->Controls->Add(this->btOK); | |
83 | - this->btOK->Enabled = false; | |
84 | - //this->Controls->Add(this->richTextBox1); | |
85 | - | |
86 | - //this->ResumeLayout(false); | |
87 | - | |
88 | -} | |
89 | - | |
90 | -void JanelaAtualizacao::setInfoWhite(String^ info) | |
91 | -{ | |
92 | - this->lbInformacao->Location = Point(7, 20); | |
93 | - this->lbInformacao->Font = gcnew System::Drawing::Font("Serif", 12); | |
94 | - this->lbInformacao->Text = info; | |
95 | - //this->lbInformacao->ForeColor=Drawing::Color::White; | |
96 | - this->lbInformacao->TextAlign = ContentAlignment::MiddleCenter; | |
97 | - | |
98 | -} | |
99 | - | |
100 | -void JanelaAtualizacao::setInfoGreen(String^ info) | |
101 | -{ | |
102 | - this->lbInformacao->Location = Point(7, 75); | |
103 | - this->lbInformacao->Font = gcnew System::Drawing::Font("Arial", 15); | |
104 | - this->lbInformacao->Text = info; | |
105 | - this->lbInformacao->ForeColor=Drawing::Color::Green; | |
106 | - this->lbInformacao->TextAlign = ContentAlignment::MiddleCenter; | |
107 | - | |
108 | -} | |
109 | -void JanelaAtualizacao::setInfoRed(String^ info) | |
110 | -{ | |
111 | - this->lbInformacao->Location = Point(7, 75); | |
112 | - this->lbInformacao->Font = gcnew System::Drawing::Font("Arial", 15); | |
113 | - this->lbInformacao->Text = info; | |
114 | - this->lbInformacao->ForeColor=Drawing::Color::Red; | |
115 | - this->lbInformacao->TextAlign = ContentAlignment::MiddleCenter; | |
116 | - | |
117 | -} | |
118 | - | |
119 | - | |
120 | - | |
121 | - | |
122 | -void JanelaAtualizacao::btOKevent(Object^ sender, EventArgs^ e) | |
123 | -{ | |
124 | - | |
125 | - this->Close(); | |
126 | - | |
127 | -} | |
128 | - | |
129 | - | |
130 | - | |
131 | -void JanelaAtualizacao::start() | |
132 | -{ | |
133 | - | |
134 | -} | |
135 | - | |
136 | - | |
137 | -void JanelaAtualizacao::EnableButton() | |
138 | -{ | |
139 | - btOK->Enabled = true; | |
140 | -} | |
141 | - | |
142 | - | |
143 | -void JanelaAtualizacao::XFormClosing(Object^ sender, FormClosingEventArgs^ e) | |
144 | -{ | |
145 | - | |
146 | -} | |
147 | - | |
148 | - | |
149 | - | |
150 | - | |
151 | - | |
152 | 0 | \ No newline at end of file |
... | ... | @@ -0,0 +1,103 @@ |
1 | + | |
2 | +/** | |
3 | +* \file pyVlibrasUpdate.cpp | |
4 | +* \authors Ezequiel Silva | |
5 | +* \date outubro 2015 | |
6 | +*/ | |
7 | + | |
8 | +#include "pyVlibrasUpdate.h" | |
9 | + | |
10 | + | |
11 | +void PyVlibrasUpdate::checkExe(char* strFunct, char* strstrParams) | |
12 | +{ | |
13 | + | |
14 | + STARTUPINFO StartupInfo; | |
15 | + PROCESS_INFORMATION ProcessInfo; | |
16 | + char Args[4096]; | |
17 | + char *pEnvCMD = NULL; | |
18 | + char *pDefaultCMD = "CMD.EXE"; | |
19 | + ULONG rc; | |
20 | + | |
21 | + memset(&StartupInfo, 0, sizeof(StartupInfo)); | |
22 | + StartupInfo.cb = sizeof(STARTUPINFO); | |
23 | + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; | |
24 | + StartupInfo.wShowWindow = SW_HIDE; | |
25 | + | |
26 | + Args[0] = 0; | |
27 | + | |
28 | + pEnvCMD = getenv("COMSPEC"); | |
29 | + | |
30 | + if(pEnvCMD){ | |
31 | + | |
32 | + strcpy(Args, pEnvCMD); | |
33 | + } | |
34 | + else{ | |
35 | + strcpy(Args, pDefaultCMD); | |
36 | + } | |
37 | + | |
38 | + // "/c" option - Do the command then terminate the command window | |
39 | + strcat(Args, " /c "); | |
40 | + //the application you would like to run from the command window | |
41 | + strcat(Args, strFunct); | |
42 | + strcat(Args, " "); | |
43 | + //the parameters passed to the application being run from the command window. | |
44 | + strcat(Args, strstrParams); | |
45 | + | |
46 | + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) | |
47 | + { | |
48 | + return -1; | |
49 | + } | |
50 | + | |
51 | + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); | |
52 | + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) | |
53 | + rc = 0; | |
54 | + | |
55 | + CloseHandle(ProcessInfo.hThread); | |
56 | + CloseHandle(ProcessInfo.hProcess); | |
57 | + | |
58 | + | |
59 | +} | |
60 | + | |
61 | +int PyVlibrasUpdate::install(char* strFunct, char* strstrParams) | |
62 | +{ | |
63 | + | |
64 | + STARTUPINFO StartupInfo; | |
65 | + PROCESS_INFORMATION ProcessInfo; | |
66 | + char Args[4096]; | |
67 | + char *pEnvCMD = NULL; | |
68 | + char *pDefaultCMD = "CMD.EXE"; | |
69 | + | |
70 | + memset(&StartupInfo, 0, sizeof(StartupInfo)); | |
71 | + StartupInfo.cb = sizeof(STARTUPINFO); | |
72 | + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; | |
73 | + StartupInfo.wShowWindow = SW_HIDE; | |
74 | + | |
75 | + Args[0] = 0; | |
76 | + | |
77 | + pEnvCMD = getenv("COMSPEC"); | |
78 | + | |
79 | + if(pEnvCMD){ | |
80 | + | |
81 | + strcpy(Args, pEnvCMD); | |
82 | + } | |
83 | + else{ | |
84 | + strcpy(Args, pDefaultCMD); | |
85 | + } | |
86 | + | |
87 | + // "/c" option - Do the command then terminate the command window | |
88 | + strcat(Args, " /c "); | |
89 | + //the application you would like to run from the command window | |
90 | + strcat(Args, strFunct); | |
91 | + strcat(Args, " "); | |
92 | + //the parameters passed to the application being run from the command window. | |
93 | + strcat(Args, strstrParams); | |
94 | + | |
95 | + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE,CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) | |
96 | + { | |
97 | + return -1; | |
98 | + } | |
99 | + | |
100 | + return -1; | |
101 | + | |
102 | +} | |
103 | + | ... | ... |
update/src/util.cpp
... | ... | @@ -1,286 +0,0 @@ |
1 | -#include <windows.h> | |
2 | -#include "util.h" | |
3 | - | |
4 | - | |
5 | - | |
6 | -Util::Util(){ | |
7 | - //downloading = true; | |
8 | - //downloading = down; | |
9 | -} | |
10 | - | |
11 | -string Util::clrStringTostring(String^ strIn) | |
12 | -{ | |
13 | - | |
14 | - char cStr[256]; | |
15 | - | |
16 | - | |
17 | - sprintf(cStr, "%s", strIn); | |
18 | - string stlString(cStr); | |
19 | - | |
20 | - return stlString; | |
21 | -} | |
22 | - | |
23 | - void DownloadProgressCallback(Object^ sender, | |
24 | - DownloadProgressChangedEventArgs^ e) | |
25 | - { | |
26 | - // Displays the operation identifier, and the transfer progress. | |
27 | - Console::WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...", | |
28 | - (String ^)e->UserState, | |
29 | - e->BytesReceived, | |
30 | - e->TotalBytesToReceive, | |
31 | - e->ProgressPercentage); | |
32 | - } | |
33 | - | |
34 | - void DownloadFileCallBack2(Object^ sender, AsyncCompletedEventArgs^ args) | |
35 | - { | |
36 | - cout<<"Terminou de baixar"<< endl; | |
37 | - | |
38 | - } | |
39 | - | |
40 | - | |
41 | -bool Util::checkNet() | |
42 | -{ | |
43 | - | |
44 | - try | |
45 | - { | |
46 | - | |
47 | - WebRequest^ request = WebRequest::Create( "http://vlibras.lavid.ufpb.br" ); | |
48 | - | |
49 | - // If required by the server, set the credentials. | |
50 | - //request->Credentials = CredentialCache::DefaultCredentials; | |
51 | - | |
52 | - // Get the response. | |
53 | - HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse()); | |
54 | - | |
55 | - if (response->StatusDescription == "OK"){ | |
56 | - | |
57 | - return true; | |
58 | - } | |
59 | - return false; | |
60 | - response->Close(); | |
61 | - } | |
62 | - catch ( WebException^ e ) | |
63 | - { | |
64 | - return false; | |
65 | - } | |
66 | - | |
67 | -} | |
68 | - | |
69 | - | |
70 | -vector<string> Util::checkVersion(bool atualize) | |
71 | -{ | |
72 | - XmlDocument^ xmlDoc; | |
73 | - XmlNodeList^ files; | |
74 | - XmlDocument^ xmlDocLocal; | |
75 | - XmlNodeList^ filesLocal; | |
76 | - vector<string> updates; | |
77 | - vector<string> localversion = localVersion(); | |
78 | - try | |
79 | - { | |
80 | - xmlDoc = (gcnew XmlDocument()); | |
81 | - xmlDocLocal = (gcnew XmlDocument()); | |
82 | - | |
83 | - | |
84 | - string url = "http://vlibras.lavid.ufpb.br/api/dicionario/"+localversion[3]+"?type=windows"; | |
85 | - WebRequest^ request = WebRequest::Create( gcnew String(url.c_str())); | |
86 | - // If required by the server, set the credentials. | |
87 | - request->Credentials = CredentialCache::DefaultCredentials; | |
88 | - // Get the response. | |
89 | - HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse()); | |
90 | - if (!(response->StatusDescription == "OK")) | |
91 | - goto erro; | |
92 | - // Get the stream containing content returned by the server. | |
93 | - Stream^ dataStream = response->GetResponseStream(); | |
94 | - // Open the stream using a StreamReader for easy access. | |
95 | - StreamReader^ reader = gcnew StreamReader( dataStream ); | |
96 | - // Read the content. | |
97 | - String^ responseFromServer = reader->ReadToEnd(); | |
98 | - xmlDoc->LoadXml(responseFromServer); | |
99 | - files = xmlDoc->GetElementsByTagName("version"); | |
100 | - | |
101 | - long numitems = files->Count; | |
102 | - | |
103 | - | |
104 | - | |
105 | - //for (int i=0;i<numitems;i++) | |
106 | - if(numitems>0) | |
107 | - { | |
108 | - String^ playerVersion = files[0]["playerVersion"]->InnerText; | |
109 | - String^ dictionaryVersion = files[0]["dictionaryVersion"]->InnerText; | |
110 | - | |
111 | - if(String::Compare( playerVersion, gcnew String(localversion[1].c_str()))) | |
112 | - { | |
113 | - updates.push_back("playerVersion"); | |
114 | - updates.push_back(clrStringTostring(playerVersion)); | |
115 | - updates.push_back(clrStringTostring(files[0]["playerUrl"]->InnerText)); | |
116 | - } | |
117 | - if(String::Compare(dictionaryVersion,gcnew String(localversion[3].c_str()))) | |
118 | - { | |
119 | - updates.push_back("dictionaryVersion"); | |
120 | - updates.push_back(clrStringTostring(dictionaryVersion)); | |
121 | - updates.push_back(clrStringTostring(files[0]["dictionaryUrl"]->InnerText)); | |
122 | - } | |
123 | - | |
124 | - //if(atualize) | |
125 | - //saveNewXmlVersion(playerVersion,dictionaryVersion); | |
126 | - | |
127 | - } | |
128 | - | |
129 | - erro: | |
130 | - // Cleanup the streams and the response. | |
131 | - reader->Close(); | |
132 | - dataStream->Close(); | |
133 | - }catch(Exception^ e) | |
134 | - { | |
135 | - return updates; | |
136 | - } | |
137 | - | |
138 | - return updates; | |
139 | -} | |
140 | - | |
141 | - | |
142 | -vector<string> Util::localVersion() | |
143 | -{ | |
144 | - XmlDocument^ xmlDocLocal; | |
145 | - XmlNodeList^ filesLocal; | |
146 | - vector<string> updates; | |
147 | - try | |
148 | - { | |
149 | - xmlDocLocal = (gcnew XmlDocument()); | |
150 | - //xml version local | |
151 | - StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); | |
152 | - | |
153 | - String^ responseLocal = readerLocal->ReadToEnd(); | |
154 | - | |
155 | - xmlDocLocal->LoadXml(responseLocal); | |
156 | - | |
157 | - filesLocal = xmlDocLocal->GetElementsByTagName("version"); | |
158 | - | |
159 | - updates.push_back("playerVersion"); | |
160 | - String^ playerVersion = filesLocal[0]["playerVersion"]->InnerText; | |
161 | - updates.push_back(clrStringTostring(playerVersion)); | |
162 | - updates.push_back("dictionaryVersion"); | |
163 | - String^ dictionaryVersion = filesLocal[0]["dictionaryVersion"]->InnerText; | |
164 | - updates.push_back(clrStringTostring(dictionaryVersion)); | |
165 | - | |
166 | - // Cleanup the streams and the response. | |
167 | - readerLocal->Close(); | |
168 | - }catch(Exception^ e) | |
169 | - { | |
170 | - return updates; | |
171 | - } | |
172 | - | |
173 | - return updates; | |
174 | -} | |
175 | - | |
176 | - | |
177 | -string Util::Download(DownloadProgressChangedEventHandler^ dpch ,string url, string fileName) | |
178 | -{ | |
179 | - try | |
180 | - { | |
181 | - myWebClient = gcnew WebClient(); | |
182 | - Uri^ uri = gcnew Uri(gcnew String(url.c_str())); | |
183 | - myWebClient->DownloadProgressChanged += dpch; | |
184 | - myWebClient->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallBack2 ); | |
185 | - String^ outPath = gcnew String(("c:\\vlibras-libs\\update\\"+fileName).c_str()); | |
186 | - myWebClient->DownloadFileAsync(uri, outPath); | |
187 | - }catch (Exception^ e) | |
188 | - { | |
189 | - return "FALHA"; | |
190 | - } | |
191 | - | |
192 | - return "OK"; | |
193 | - } | |
194 | - | |
195 | - | |
196 | - | |
197 | - bool Util::saveNewXmlVersion(string playerVersion,string dictionaryVersion) | |
198 | - { | |
199 | - | |
200 | - XmlDocument^ xmlDocLocal; | |
201 | - XmlNodeList^ filesLocal; | |
202 | - vector<string> updates; | |
203 | - try | |
204 | - { | |
205 | - xmlDocLocal = (gcnew XmlDocument()); | |
206 | - //xml version local | |
207 | - StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); | |
208 | - | |
209 | - String^ responseLocal = readerLocal->ReadToEnd(); | |
210 | - | |
211 | - xmlDocLocal->LoadXml(responseLocal); | |
212 | - | |
213 | - filesLocal = xmlDocLocal->GetElementsByTagName("version"); | |
214 | - | |
215 | - if(!playerVersion.empty()) | |
216 | - filesLocal[0]["playerVersion"]->InnerText = gcnew String(playerVersion.c_str()); | |
217 | - | |
218 | - if(!dictionaryVersion.empty()) | |
219 | - filesLocal[0]["dictionaryVersion"]->InnerText = gcnew String(dictionaryVersion.c_str()); | |
220 | - | |
221 | - | |
222 | - // Cleanup the streams and the response. | |
223 | - readerLocal->Close(); | |
224 | - | |
225 | - xmlDocLocal->Save("c:\\vlibras-libs\\update\\updateVersion.xml"); | |
226 | - }catch(Exception^ e) | |
227 | - { | |
228 | - | |
229 | - } | |
230 | - | |
231 | - return true; | |
232 | - } | |
233 | - | |
234 | - | |
235 | - bool Util::extractZip(string zipFile, string outPath) | |
236 | - { | |
237 | - try | |
238 | - { | |
239 | - String^ zipPath = gcnew String(zipFile.c_str()); | |
240 | - String^ extractPath = gcnew String(outPath.c_str()); | |
241 | - ZipFile::ExtractToDirectory(zipPath, extractPath); | |
242 | - | |
243 | - }catch(Exception^ e) | |
244 | - { | |
245 | - return false; | |
246 | - } | |
247 | - | |
248 | - return true; | |
249 | - } | |
250 | - | |
251 | -bool Util::backup() | |
252 | -{ | |
253 | - CHAR nome_atual[] = "c:\\vlibras-libs"; | |
254 | - // novo nome do diretório | |
255 | - CHAR nome_novo[] = "c:\\vlibras-libs-BK"; | |
256 | - | |
257 | - // renomear o diretório | |
258 | - if(MoveFile(nome_atual, nome_novo)){ | |
259 | - | |
260 | - } | |
261 | - else{ | |
262 | - return false; | |
263 | - } | |
264 | - return true; | |
265 | -} | |
266 | -bool Util::restore() | |
267 | -{ | |
268 | - CHAR nome_atual[] = "c:\\vlibras-libs-BK"; | |
269 | - // novo nome do diretório | |
270 | - CHAR nome_novo[] = "c:\\vlibras-libs"; | |
271 | - | |
272 | - // renomear o diretório | |
273 | - if(MoveFile(nome_atual, nome_novo)){ | |
274 | - return true; | |
275 | - } | |
276 | - else{ | |
277 | - return false; | |
278 | - //GetLastError() << endl; | |
279 | - } | |
280 | - return true; | |
281 | -} | |
282 | - | |
283 | - | |
284 | - | |
285 | - | |
286 | - | |
287 | 0 | \ No newline at end of file |
update/update-icon.ico
No preview for this file type
... | ... | @@ -0,0 +1,87 @@ |
1 | +#!/usr/bin/env python | |
2 | +# -*- coding: utf-8 -*- | |
3 | +import wx | |
4 | +from urllib2 import URLError | |
5 | +from urllib2 import HTTPError | |
6 | +import urllib2,os | |
7 | +import random | |
8 | +import time | |
9 | +from wx.lib.pubsub import pub | |
10 | +from threading import Thread | |
11 | + | |
12 | + | |
13 | + | |
14 | +class DownloadFile(): | |
15 | + | |
16 | + def __init__(self,url,nameFile): | |
17 | + self.url = url | |
18 | + self.nameFile = nameFile | |
19 | + self.downloading = True | |
20 | + | |
21 | + def start(self): | |
22 | + | |
23 | + file_name = self.nameFile | |
24 | + try: | |
25 | + u = urllib2.urlopen(self.url) | |
26 | + f = open(file_name, 'wb') | |
27 | + meta = u.info() | |
28 | + file_size = int(meta.getheaders("Content-Length")[0]) | |
29 | + | |
30 | + except: | |
31 | + | |
32 | + return False | |
33 | + | |
34 | + block_sz = 8192 | |
35 | + while self.downloading: | |
36 | + buffer = u.read(block_sz) | |
37 | + if not buffer: | |
38 | + self.downloading = False | |
39 | + f.write(buffer) | |
40 | + | |
41 | + return True | |
42 | + | |
43 | + | |
44 | + | |
45 | +class DownloadFile2(Thread): | |
46 | + | |
47 | + def __init__(self,url,nameFile): | |
48 | + self.url = url | |
49 | + self.nameFile = nameFile | |
50 | + self.downloading = True | |
51 | + Thread.__init__(self) | |
52 | + | |
53 | + | |
54 | + def stop(self): | |
55 | + self.downloading = False | |
56 | + | |
57 | + | |
58 | + def run(self): | |
59 | + | |
60 | + file_name = self.nameFile | |
61 | + try: | |
62 | + u = urllib2.urlopen(self.url) | |
63 | + f = open(file_name, 'wb') | |
64 | + meta = u.info() | |
65 | + file_size = int(meta.getheaders("Content-Length")[0]) | |
66 | + | |
67 | + except : | |
68 | + wx.CallAfter(pub.sendMessage, "erroDeConexao", msg="Falha na conexao") | |
69 | + self.downloading = False; | |
70 | + return False | |
71 | + | |
72 | + | |
73 | + file_size_dl = 0 | |
74 | + block_sz = 8192 | |
75 | + while self.downloading: | |
76 | + buffer = u.read(block_sz) | |
77 | + if not buffer: | |
78 | + break | |
79 | + | |
80 | + file_size_dl += len(buffer) | |
81 | + f.write(buffer) | |
82 | + status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size) | |
83 | + status = status + chr(8)*(len(status)+1) | |
84 | + | |
85 | + wx.CallAfter(pub.sendMessage, "updateProgress", msg=(file_size_dl * 100. / file_size)) | |
86 | + if (file_size_dl * 100. / file_size) >=100: | |
87 | + wx.CallAfter(pub.sendMessage, "downloadSucess", msg="Download realizado") | ... | ... |
... | ... | @@ -0,0 +1,87 @@ |
1 | +# -*- coding: cp1252 -*- | |
2 | +import json, zipfile, subprocess,urllib | |
3 | +from os import popen | |
4 | +import sys | |
5 | + | |
6 | +PATH_RESOURCE = 'c:/vlibras-libs/update/' | |
7 | +TXT_LOCAL_VERSION = PATH_RESOURCE+'version/version.txt' | |
8 | +JSON_LOCAL_NAME = PATH_RESOURCE+'version/version.json' | |
9 | +JSON_API_NAME = PATH_RESOURCE+'download/versionApi.json' | |
10 | +URL_REQUEST_API = 'http://150.165.205.94:8000/versionApi.json' | |
11 | + | |
12 | + | |
13 | + | |
14 | + | |
15 | +def check(): | |
16 | + | |
17 | + try: | |
18 | + | |
19 | + with open(JSON_LOCAL_NAME) as data_file: | |
20 | + json_data = json.load(data_file) | |
21 | + | |
22 | + my_dict_version_full = json_data['dictionaryVersion'].encode('utf-8') | |
23 | + my_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") | |
24 | + my_dict_version = my_dict_version_full.replace(".", "").replace("_", "") | |
25 | + | |
26 | + if(not downladFileApi(URL_REQUEST_API)): | |
27 | + return 'erro' | |
28 | + | |
29 | + with open(JSON_API_NAME) as data: | |
30 | + json_data = json.load(data) | |
31 | + | |
32 | + api_dict_version = json_data['dictionaryVersion'].encode('utf-8').replace(".", "").replace("_", "") | |
33 | + api_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") | |
34 | + url_download_player = json_data['playerUrl'].encode('utf-8') | |
35 | + url_download_dict = json_data['dictionaryUrl'].encode('utf-8') | |
36 | + | |
37 | + | |
38 | + if int(api_player_version) > int(my_player_version): | |
39 | + return url_download_player | |
40 | + | |
41 | + elif int(api_dict_version) > int(my_dict_version): | |
42 | + | |
43 | + return url_download_dict | |
44 | + | |
45 | + else: | |
46 | + return 'atualizado' | |
47 | + | |
48 | + except Exception, e: | |
49 | + print e | |
50 | + return 'erro' | |
51 | + | |
52 | + | |
53 | +def downladFileApi(_url): | |
54 | + try: | |
55 | + | |
56 | + urllib.urlretrieve (_url, JSON_API_NAME) | |
57 | + | |
58 | + return True | |
59 | + except Exception, e: | |
60 | + print e | |
61 | + return False | |
62 | + | |
63 | + | |
64 | + | |
65 | + | |
66 | +if __name__ == '__main__': | |
67 | + txt_local_version = open(TXT_LOCAL_VERSION, 'w') | |
68 | + result = check() | |
69 | + if result.endswith('.exe'): | |
70 | + txt_local_version.write('1') | |
71 | + elif result.endswith('.zip'): | |
72 | + txt_local_version.write('2') | |
73 | + elif (result == 'atualizado'): | |
74 | + txt_local_version.write('0') | |
75 | + else: | |
76 | + txt_local_version.write('-1') | |
77 | + | |
78 | + txt_local_version.close() | |
79 | + print result | |
80 | + | |
81 | + | |
82 | + | |
83 | + | |
84 | + | |
85 | + | |
86 | + | |
87 | + | ... | ... |
... | ... | @@ -0,0 +1,109 @@ |
1 | +# -*- coding: cp1252 -*- | |
2 | +import json, zipfile, subprocess,urllib | |
3 | +from os import popen | |
4 | +from threading import Thread | |
5 | +from VlibrasUpdateInstall import* | |
6 | + | |
7 | +url_download_player ='' | |
8 | +url_download_dict ='' | |
9 | +PATH_RESOURCE = 'C:/vlibras-libs/update/' | |
10 | +JSON_LOCAL_NAME = 'version/version.json' | |
11 | +JSON_API_NAME = 'download/versionApi.json' | |
12 | +PLAYER_DICT_UPDATE_PATH = PATH_RESOURCE+'bin/vlibrasPlayerDictUp.exe ' | |
13 | +DICTIONARY_NAME = 'download/vlibras_dicionario.zip' | |
14 | +INSTALL_PLAYER_NAME = 'download/Vlibras_Up.exe' | |
15 | +URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/' | |
16 | +DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles' | |
17 | + | |
18 | + | |
19 | + | |
20 | + | |
21 | + | |
22 | + | |
23 | +def checkVersion(): | |
24 | + | |
25 | +## try: | |
26 | +## | |
27 | +## with open(PATH_RESOURCE+JSON_LOCAL_NAME) as data_file: | |
28 | +## json_data = json.load(data_file) | |
29 | +## | |
30 | +## my_dict_version_full = json_data['dictionaryVersion'].encode('utf-8') | |
31 | +## my_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") | |
32 | +## my_dict_version = my_dict_version_full.replace(".", "").replace("_", "") | |
33 | +## | |
34 | +## if(not downladFileApi(URL_REQUEST_API+my_dict_version_full+'?type=linux')): | |
35 | +## return 'erro' | |
36 | +## | |
37 | +## with open(PATH_RESOURCE+JSON_API_NAME) as data: | |
38 | +## json_data = json.load(data) | |
39 | +## | |
40 | +## api_dict_version = json_data['dictionaryVersion'].encode('utf-8').replace(".", "").replace("_", "") | |
41 | +## api_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") | |
42 | +## url_download_player = json_data['playerUrl'].encode('utf-8') | |
43 | +## url_download_dict = json_data['dictionaryUrl'].encode('utf-8') | |
44 | +## | |
45 | +## | |
46 | +## if int(api_player_version) > int(my_player_version): | |
47 | +## return url_download_player | |
48 | +## | |
49 | +## elif int(api_dict_version) > int(my_dict_version): | |
50 | +## | |
51 | +## return url_download_dict | |
52 | +## | |
53 | +## else: | |
54 | +## return "atualizado" | |
55 | +## | |
56 | +## except: | |
57 | + | |
58 | + return "erro" | |
59 | + | |
60 | + | |
61 | +def downladFileApi(_url): | |
62 | + try: | |
63 | + | |
64 | + urllib.urlretrieve (_url, PATH_RESOURCE+JSON_API_NAME) | |
65 | + | |
66 | + return True | |
67 | + except: | |
68 | + return False | |
69 | + | |
70 | +def installPlayer(): | |
71 | + try: | |
72 | +## with open(PATH_RESOURCE+JSON_API_NAME) as data: | |
73 | +## json_data = json.load(data) | |
74 | + | |
75 | +## url_download_player = json_data['playerUrl'].encode('utf-8') | |
76 | + # install = CallInstall() | |
77 | + # install.start() | |
78 | + process = subprocess.Popen(["C:\\Python27\\python.exe", "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"]) | |
79 | +## update_json_file() | |
80 | + except Exception, e: | |
81 | + print e | |
82 | + return -1 | |
83 | + return 1 | |
84 | + | |
85 | +def installDict(): | |
86 | + try: | |
87 | +## install = CallInstall() | |
88 | +## install.start() | |
89 | + | |
90 | + process = subprocess.Popen(["C:\\Python27\\python.exe", "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"]) | |
91 | +## with open(PATH_RESOURCE+JSON_API_NAME) as data: | |
92 | +## json_data = json.load(data) | |
93 | +## url_download_dict = json_data['dictionaryUrl'].encode('utf-8') | |
94 | +## process = subprocess.Popen(PLAYER_DICT_UPDATE_PATH+url_download_dict) | |
95 | + except Exception, e: | |
96 | + print e | |
97 | + return -1 | |
98 | + return 1 | |
99 | + | |
100 | + | |
101 | +if __name__ == '__main__': | |
102 | + print installPlayer() | |
103 | + | |
104 | + | |
105 | + | |
106 | + | |
107 | + | |
108 | + | |
109 | + | ... | ... |
... | ... | @@ -0,0 +1,212 @@ |
1 | + | |
2 | +# -*- coding: utf-8 -*- | |
3 | + | |
4 | +import wx | |
5 | +import subprocess | |
6 | +import time | |
7 | +from wx.lib.pubsub import pub | |
8 | +from DownloadFile import * | |
9 | +from VlibrasCheckVersion import * | |
10 | +import zipfile | |
11 | + | |
12 | + | |
13 | + | |
14 | +PATH_RESOURCE = 'C:/vlibras-libs/update/' | |
15 | +DICTIONARY_NAME = 'download/vlibras_dicionario.zip' | |
16 | +INSTALL_PLAYER_NAME = 'download/Vlibras_Up.exe' | |
17 | +DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles' | |
18 | + | |
19 | +class UpdateView(wx.Frame): | |
20 | + | |
21 | + def __init__(self,_downloadFile,_serv_type): | |
22 | + | |
23 | + self.serv_type = _serv_type | |
24 | + self.downloadFile = _downloadFile | |
25 | + style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | |
26 | + wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(480,250)) | |
27 | + # Define o ícone para a janela | |
28 | + self.SetIcon(wx.Icon("c:/vlibras-libs/icons/icon_vlibras.ico", wx.BITMAP_TYPE_ICO)) | |
29 | + self.myPanel = wx.Panel(self, -1) | |
30 | + self.myPanel.SetBackgroundColour('#F5F5F5') | |
31 | +## btnOk = wx.Button(self.myPanel, label="OK",pos=(365, 180), size=(80, 25)) | |
32 | + btnCancel = wx.Button(self.myPanel, label="Cancelar",pos=(365, 180), size=(80, 25)) | |
33 | + self.myText = wx.StaticText(self.myPanel, -1, pos=(5,105)) | |
34 | + #self.myText.SetBackgroundColour('#123456') | |
35 | + self.myText.SetForegroundColour('#000000') | |
36 | + self.progress = wx.Gauge(self.myPanel, range=100,pos=(5,80),size=(463,25)) | |
37 | + self.Center() | |
38 | + | |
39 | + # Anexa um evento ao botão | |
40 | +## self.Bind(wx.EVT_BUTTON, self.onBtnOkClick, btnOk) | |
41 | + self.Bind(wx.EVT_BUTTON, self.onBtnCancelClick, btnCancel) | |
42 | + self.__close_callback = None | |
43 | + self.Bind(wx.EVT_CLOSE, self._when_closed) | |
44 | + | |
45 | + #registra listeners na classe DownloadFile | |
46 | + pub.subscribe(self.downloadSucess, "downloadSucess") | |
47 | + pub.subscribe(self.erroDeConexao, "erroDeConexao") | |
48 | + pub.subscribe(self.updateProgress, "updateProgress") | |
49 | + self.percentDownload = 0; | |
50 | + | |
51 | + | |
52 | + #inicia o download do arquivo | |
53 | + if(self.serv_type != ''): | |
54 | + self.downloadFile.start() | |
55 | + | |
56 | + def erroDeConexao(self, msg): | |
57 | + wx.MessageBox('Ocorreu um erro ao tentar fazer atualização. \n Por favor tente mais tarde.', 'Informação',wx.OK | wx.ICON_INFORMATION) | |
58 | + self.Destroy() | |
59 | + | |
60 | + def register_close_callback(self, callback): | |
61 | + self.__close_callback = callback | |
62 | + | |
63 | + def _when_closed(self, event): | |
64 | + self.OnCloseFrame(event); | |
65 | +## event.Skip() | |
66 | + | |
67 | + | |
68 | +## def onBtnOkClick(self, event): | |
69 | +## self.downloadFile.start() | |
70 | + | |
71 | + def onBtnCancelClick(self, event): | |
72 | + self.OnCloseFrame(event); | |
73 | + | |
74 | + | |
75 | + def downloadSucess(self, msg): | |
76 | + self.percentDownload = 100.0 | |
77 | + time.sleep( 2 ) | |
78 | + if (self.serv_type == 'dict'): | |
79 | + with zipfile.ZipFile(PATH_RESOURCE+DICTIONARY_NAME, "r") as z: | |
80 | + z.extractall(DICTIONARY_EXTRACT_PATH) | |
81 | + self.update_json_file() | |
82 | + self.ShowMessage('Vlibras Atualizado com sucesso!') | |
83 | + | |
84 | + else: | |
85 | + self.Hide() | |
86 | + process = subprocess.call(PATH_RESOURCE+INSTALL_PLAYER_NAME+' /SILENT /SUPPRESSMSGBOXES /NORESTART') | |
87 | + self.update_json_file() | |
88 | + self.ShowMessage('Vlibras Atualizado com sucesso!') | |
89 | + self.downloadFile.stop() | |
90 | + self.Destroy() | |
91 | + | |
92 | + | |
93 | + def updateProgress(self, msg): | |
94 | + value = msg | |
95 | + val = 'Baixando' | |
96 | + | |
97 | + self.percentDownload = value | |
98 | + self.myText.SetLabel(val) | |
99 | + self.progress.SetValue(value) | |
100 | + | |
101 | + def ShowMessage(self, mesagem): | |
102 | + wx.MessageBox(mesagem, 'Informação', | |
103 | + wx.OK | wx.ICON_INFORMATION) | |
104 | + def ShowMessageError(self, mesagem): | |
105 | + wx.MessageBox(mesagem, 'Informação', | |
106 | + wx.OK | wx.ICON_ERROR) | |
107 | + self.downloadFile.stop() | |
108 | + self.Destroy() | |
109 | + | |
110 | + | |
111 | + | |
112 | + | |
113 | + | |
114 | + # monitora a interação do usuário no botão de fechar | |
115 | + def OnCloseFrame(self, event): | |
116 | + if(self.percentDownload>= 100): | |
117 | + self.downloadFile.stop() | |
118 | + self.Destroy() | |
119 | + dialog = wx.MessageDialog(self, message = "Tem certeza que deseja cancelar a atualização?", caption = "Cancelar Atualização", | |
120 | + style = wx.YES_NO | wx.ICON_QUESTION) | |
121 | + response = dialog.ShowModal() | |
122 | + | |
123 | + if (response == wx.ID_YES): | |
124 | + self.downloadFile.stop() | |
125 | + | |
126 | + self.Destroy() | |
127 | + else: | |
128 | + event.StopPropagation() | |
129 | + | |
130 | + | |
131 | + # atualiza o json local com as informações da api | |
132 | + def update_json_file(self): | |
133 | + with open(PATH_RESOURCE+JSON_API_NAME) as data: | |
134 | + json_data = json.load(data) | |
135 | + | |
136 | + jsonFile = open(PATH_RESOURCE+JSON_LOCAL_NAME, "w+") | |
137 | + jsonFile.write(json.dumps(json_data)) | |
138 | + jsonFile.close() | |
139 | + | |
140 | + | |
141 | +class ShowInfo(wx.Frame): | |
142 | + | |
143 | + def __init__(self,_mesagem): | |
144 | + self.mesagem = _mesagem | |
145 | + style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | |
146 | + wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(480,250)) | |
147 | + def ShowMessage(self): | |
148 | + wx.MessageBox(self.mesagem, 'Informação', | |
149 | + wx.OK | wx.ICON_INFORMATION) | |
150 | + def ShowMessageError(self): | |
151 | + wx.MessageBox(self.mesagem, 'Informação', | |
152 | + wx.OK | wx.ICON_ERROR) | |
153 | + | |
154 | + | |
155 | + | |
156 | + | |
157 | + | |
158 | +def installDictionary(_url): | |
159 | + app = wx.App(False) | |
160 | + downloadFile2 = DownloadFile2(_url, PATH_RESOURCE+DICTIONARY_NAME) | |
161 | + frame = UpdateView(downloadFile2,'dict') | |
162 | + frame.register_close_callback(lambda: True) | |
163 | + frame.Show() | |
164 | + app.MainLoop() | |
165 | + print _url | |
166 | + return 'OK' | |
167 | + | |
168 | +def installPlayer(_url): | |
169 | + app = wx.App(False) | |
170 | + downloadFile2 = DownloadFile2(_url, PATH_RESOURCE+INSTALL_PLAYER_NAME) | |
171 | + frame = UpdateView(downloadFile2,'player') | |
172 | + frame.register_close_callback(lambda: True) | |
173 | + frame.Show() | |
174 | + app.MainLoop() | |
175 | + print _url | |
176 | + return 'OK' | |
177 | + | |
178 | + | |
179 | +if __name__ == '__main__': | |
180 | + app = wx.App(False) | |
181 | + result = check() | |
182 | + if result.endswith('.zip'): | |
183 | + installDictionary(result) | |
184 | + elif result.endswith('.exe'): | |
185 | + installPlayer(result) | |
186 | + elif (result == 'atualizado'): | |
187 | +## up.Show() | |
188 | + ShowInfo('O VLibras já está atualizado!').ShowMessage() | |
189 | + else: | |
190 | +## up.Show() | |
191 | + ShowInfo('Ocorreu um erro ao tentar atualizar o VLibras!').ShowMessageError() | |
192 | + | |
193 | +## app.MainLoop() | |
194 | + | |
195 | + | |
196 | + | |
197 | +def initInstall(): | |
198 | + app = wx.App(False) | |
199 | + result = check() | |
200 | + if result.endswith('.zip'): | |
201 | + installDictionary(result) | |
202 | + elif result.endswith('.exe'): | |
203 | + installPlayer(result) | |
204 | + elif (result == 'atualizado'): | |
205 | +## up.Show() | |
206 | + ShowInfo('O VLibras já está atualizado!').ShowMessage() | |
207 | + else: | |
208 | +## up.Show() | |
209 | + ShowInfo('Ocorreu um erro ao tentar atualizar o VLibras!').ShowMessageError() | |
210 | + | |
211 | +## app.MainLoop() | |
212 | + | ... | ... |
... | ... | @@ -0,0 +1,61 @@ |
1 | + | |
2 | + | |
3 | +#include <windows.h> //include all the basics | |
4 | + //string and other mapping macros | |
5 | + | |
6 | + | |
7 | +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |
8 | + LPSTR lpCmdLine, int nShowCmd) | |
9 | +{ | |
10 | + | |
11 | + STARTUPINFO StartupInfo; | |
12 | + PROCESS_INFORMATION ProcessInfo; | |
13 | + char Args[4096]; | |
14 | + char *pEnvCMD = NULL; | |
15 | + char *pDefaultCMD = "CMD.EXE"; | |
16 | + ULONG rc; | |
17 | + | |
18 | + memset(&StartupInfo, 0, sizeof(StartupInfo)); | |
19 | + StartupInfo.cb = sizeof(STARTUPINFO); | |
20 | + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; | |
21 | + StartupInfo.wShowWindow = SW_HIDE; | |
22 | + | |
23 | + Args[0] = 0; | |
24 | + | |
25 | + pEnvCMD = getenv("COMSPEC"); | |
26 | + | |
27 | + if(pEnvCMD){ | |
28 | + | |
29 | + strcpy(Args, pEnvCMD); | |
30 | + } | |
31 | + else{ | |
32 | + strcpy(Args, pDefaultCMD); | |
33 | + } | |
34 | + | |
35 | + // "/c" option - Do the command then terminate the command window | |
36 | + strcat(Args, " /c "); | |
37 | + //the application you would like to run from the command window | |
38 | + strcat(Args, "c:\\Python27\\python.exe"); | |
39 | + strcat(Args, " "); | |
40 | + //the parameters passed to the application being run from the command window. | |
41 | + strcat(Args, "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"); | |
42 | + | |
43 | + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, | |
44 | + CREATE_NEW_CONSOLE, | |
45 | + NULL, | |
46 | + NULL, | |
47 | + &StartupInfo, | |
48 | + &ProcessInfo)) | |
49 | + { | |
50 | + return GetLastError(); | |
51 | + } | |
52 | + | |
53 | + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); | |
54 | + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) | |
55 | + rc = 0; | |
56 | + | |
57 | + CloseHandle(ProcessInfo.hThread); | |
58 | + CloseHandle(ProcessInfo.hProcess); | |
59 | + | |
60 | + return 0; | |
61 | +} | |
0 | 62 | \ No newline at end of file | ... | ... |
update/vlibrasUpdate.cpp
... | ... | @@ -1,172 +0,0 @@ |
1 | - | |
2 | -#include <Windows.h> | |
3 | -#include "util.h" | |
4 | -#include "janelaAtualizacao.h" | |
5 | -#include <iostream> | |
6 | - | |
7 | -using namespace std; | |
8 | -using namespace System::Threading; | |
9 | -using namespace System::Windows::Forms; | |
10 | - | |
11 | -void atualizarProgresbar(Object^ sender, DownloadProgressChangedEventArgs^ e){ | |
12 | - | |
13 | - JanelaAtualizacao::progressBar1->Value= e->ProgressPercentage; | |
14 | - int kbr = e->BytesReceived/1024; | |
15 | - int kbtotal = e->TotalBytesToReceive/1024; | |
16 | - JanelaAtualizacao::lbInfDownload->Text = gcnew String(kbr+" kb ("+kbr/1024+" MB) Baixado de "+kbtotal+" kb ("+kbtotal/1024+" MB) | "+ e->ProgressPercentage+"%"); | |
17 | - | |
18 | - | |
19 | -} | |
20 | - | |
21 | - | |
22 | -public ref class UpdateBack | |
23 | -{ | |
24 | - JanelaAtualizacao^ j; | |
25 | - bool isSilence; | |
26 | - String^ playerVersion; | |
27 | - String^ dictionaryVersion; | |
28 | - | |
29 | -public: | |
30 | - UpdateBack(JanelaAtualizacao^ jan,bool __isSilence) | |
31 | - { | |
32 | - j = jan; | |
33 | - isSilence = __isSilence; | |
34 | - } | |
35 | - void start() | |
36 | - { | |
37 | - j->setInfoWhite("Estabelecendo conexão com o servidor..."); | |
38 | - //JanelaAtualizacao::progressBar1->Style = ProgressBarStyle::Marquee; | |
39 | - | |
40 | - | |
41 | - if(Util::checkNet()) | |
42 | - { | |
43 | - j->setInfoWhite("Verificando versão..."); | |
44 | - | |
45 | - vector<string> versions = Util::checkVersion(true); | |
46 | - if(versions.size()>2) | |
47 | - { | |
48 | - | |
49 | - switch (versions.size()) | |
50 | - { | |
51 | - case 3: | |
52 | - if(versions[0]=="playerVersion") | |
53 | - { | |
54 | - installPlayer(versions[2],versions[1]); | |
55 | - } | |
56 | - else if(versions[0]=="dictionaryVersion") | |
57 | - { | |
58 | - installDicionario(versions[2],versions[1]); | |
59 | - | |
60 | - } | |
61 | - break; | |
62 | - case 6: | |
63 | - // if(versions[3]=="dictionaryVersion") | |
64 | - // { | |
65 | - // installDicionario(versions[5],versions[4]); | |
66 | - // //Util::extractZip() | |
67 | - // } | |
68 | - if(versions[0]=="playerVersion") | |
69 | - { | |
70 | - installPlayer(versions[2],versions[1]); | |
71 | - } | |
72 | - | |
73 | - break; | |
74 | - } | |
75 | - | |
76 | - } | |
77 | - else | |
78 | - { | |
79 | - JanelaAtualizacao::progressBar1->Visible = false; | |
80 | - j->setInfoGreen("Você já está com a versão mais atualizada!"); | |
81 | - j->EnableButton(); | |
82 | - } | |
83 | - | |
84 | - }else | |
85 | - { | |
86 | - JanelaAtualizacao::progressBar1->Visible = false; | |
87 | - j->setInfoRed("Não foi possível estabelecer conexão com o servidor!"); | |
88 | - | |
89 | - } | |
90 | - | |
91 | - if(isSilence) | |
92 | - j->Close(); | |
93 | - j->EnableButton(); | |
94 | - | |
95 | - } | |
96 | - | |
97 | - void installDicionario(string url, string version) | |
98 | - { | |
99 | - //JanelaAtualizacao::progressBar1->Style = ProgressBarStyle::Continuous; | |
100 | - //JanelaAtualizacao::progressBar1->Value=0; | |
101 | - Util::Download(gcnew DownloadProgressChangedEventHandler(atualizarProgresbar),url,"vlibrasDicionario.zip"); | |
102 | - j->setInfoWhite("Baixando nova versão do dicionário VLibras "); | |
103 | - while(JanelaAtualizacao::progressBar1->Value<100); | |
104 | - | |
105 | - j->setInfoWhite("Extraindo arquivos..."); | |
106 | - | |
107 | - //Sleep(3000); | |
108 | - Util::extractZip("C:\\vlibras-libs\\update\\vlibrasDicionario.zip","C:\\vlibras-libs\\Player\\VLibrasPlayer_Data\\Bundles"); | |
109 | - JanelaAtualizacao::progressBar1->Visible = false; | |
110 | - j->setInfoGreen("Atualização feita com sucesso!"); | |
111 | - Util::saveNewXmlVersion("",version); | |
112 | - j->EnableButton(); | |
113 | - } | |
114 | - | |
115 | - void installPlayer(string url, string version) | |
116 | - { | |
117 | - //j->EnableButton(); | |
118 | - //JanelaAtualizacao::progressBar1->Style = ProgressBarStyle::Continuous; | |
119 | - //JanelaAtualizacao::progressBar1->Value=0; | |
120 | - Util::Download(gcnew DownloadProgressChangedEventHandler(atualizarProgresbar),url,"vlibrasInstaller.exe"); | |
121 | - j->setInfoWhite("Baixando nova versão do Vlibras..."); | |
122 | - while(JanelaAtualizacao::progressBar1->Value<100); | |
123 | - | |
124 | - | |
125 | - | |
126 | - String^ installer = gcnew String("C:\\vlibras-libs\\update\\"); | |
127 | - installer+="vlibrasInstaller.exe"; | |
128 | - //Process::Start(installer); | |
129 | - System::Diagnostics::Process^ vlibrasinstall = gcnew System::Diagnostics::Process(); | |
130 | - vlibrasinstall->StartInfo->FileName = installer; | |
131 | - vlibrasinstall->StartInfo->Arguments = " /SILENT /SUPPRESSMSGBOXES /NORESTART "; | |
132 | - vlibrasinstall->Start(); | |
133 | - Util::saveNewXmlVersion(version,""); | |
134 | - j->Close(); | |
135 | - | |
136 | - } | |
137 | -}; | |
138 | - | |
139 | -[STAThread] | |
140 | -int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow) | |
141 | -{ | |
142 | - UpdateBack^ updateBack; | |
143 | - JanelaAtualizacao^ updateView = gcnew JanelaAtualizacao(); | |
144 | - | |
145 | - if(__argv[1] != NULL) | |
146 | - { | |
147 | - char* silen = "silence"; | |
148 | - if(*__argv[1] == *silen) | |
149 | - updateBack = gcnew UpdateBack(updateView,true); | |
150 | - else | |
151 | - updateBack = gcnew UpdateBack(updateView,false); | |
152 | - } | |
153 | - else | |
154 | - updateBack = gcnew UpdateBack(updateView,false); | |
155 | - | |
156 | - Application::EnableVisualStyles(); | |
157 | - | |
158 | - //Thread^ t2 = gcnew Thread(gcnew ThreadStart(updateView, &JanelaAtualizacao::start)); | |
159 | - //t2->Start(); | |
160 | - | |
161 | - Thread^ t3 = gcnew Thread(gcnew ThreadStart(updateBack, &UpdateBack::start)); | |
162 | - t3->Start(); | |
163 | - | |
164 | - | |
165 | - updateView->ShowDialog(); | |
166 | - t3->Abort(); | |
167 | - | |
168 | - //Application::Run(updateView); | |
169 | - | |
170 | - return 0; | |
171 | - } | |
172 | - |