Commit 9057738d431bd2d8f0b7d2a87c4fa7f7950bd5ed
1 parent
95e4b2e6
Exists in
master
Nova versão do update
Showing
10 changed files
with
345 additions
and
179 deletions
Show diff stats
Makefile
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | ############################################################################ |
9 | 9 | |
10 | 10 | # Includes |
11 | -CFLAGS = -I C:\Python27\include -I include -I "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" | |
11 | +CFLAGS = -I C:\Python27\include -I include -I update\include -I "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" | |
12 | 12 | |
13 | 13 | # Link com as libs utilizadas |
14 | 14 | LFLAGS = -link C:\Python27\libs\python27.lib |
... | ... | @@ -23,10 +23,10 @@ OUT = testLibras |
23 | 23 | |
24 | 24 | |
25 | 25 | # Arquivos de implementação |
26 | -FILES = src\pyTradutor.cpp src\pyClip.cpp src\util.cpp | |
26 | +FILES = src\pyTradutor.cpp src\pyClip.cpp update\src\checkVersion.cpp | |
27 | 27 | |
28 | 28 | #Headers |
29 | -INCLUDES = include\pyTradutor.h include\pyClip.h include\util.h | |
29 | +INCLUDES = include\pyTradutor.h include\pyClip.h update\include\checkVersion.h | |
30 | 30 | |
31 | 31 | CLEAN_OBJ = del -q *.obj |
32 | 32 | |
... | ... | @@ -40,7 +40,7 @@ all: $(FILES) $(INCLUDES) src\testLibras.cpp |
40 | 40 | #Gera dll na arquitetura x86 |
41 | 41 | plugin-x86: $(FILES) $(INCLUDES) |
42 | 42 | IF NOT EXIST plugin\Plugin-x86 mkdir plugin\Plugin-x86 |
43 | - $(CC) -Feplugin\Plugin-x86\CorePlugin -LD plugin\corePlugin.cpp $(FILES) -I plugin\corePlugin.h -clr $(CFLAGS) $(LFLAGS) | |
43 | + $(CC) -Feplugin\Plugin-x86\CorePlugin -LD plugin\corePlugin.cpp $(FILES) -I plugin\corePlugin.h -EHsc $(CFLAGS) $(LFLAGS) | |
44 | 44 | $(CLEAN_OBJ) |
45 | 45 | |
46 | 46 | #Gera dll na arquitetura x64 | ... | ... |
include/util.h
1 | 1 | #using <System.dll> |
2 | 2 | #using <System.Xml.dll> |
3 | -#using <System.IO.Compression.FileSystem.dll> | |
4 | 3 | |
5 | 4 | #include <iostream> |
6 | 5 | #include <string> |
... | ... | @@ -9,12 +8,11 @@ |
9 | 8 | |
10 | 9 | using namespace std; |
11 | 10 | using namespace System; |
12 | -using namespace System::ComponentModel; | |
11 | + | |
13 | 12 | using namespace System::Net; |
14 | 13 | using namespace System::IO; |
15 | 14 | using namespace System::Xml; |
16 | -using namespace System::Threading; | |
17 | -using namespace System::IO::Compression; | |
15 | + | |
18 | 16 | |
19 | 17 | |
20 | 18 | |
... | ... | @@ -35,13 +33,10 @@ using namespace System::IO::Compression; |
35 | 33 | Util(); |
36 | 34 | |
37 | 35 | bool downloading; |
38 | - static bool saveNewXmlVersion(string playerVersion,string dictionaryVersion); | |
39 | - static string Download(DownloadProgressChangedEventHandler^ dpch ,string url, string fileName); | |
36 | + | |
40 | 37 | static bool checkNet(void); |
41 | 38 | static vector <string> checkVersion(bool atualize); |
42 | - static bool extractZip(string zipFile, string outPath); | |
43 | - static bool backup(void); | |
44 | - static bool restore(void); | |
39 | + | |
45 | 40 | |
46 | 41 | }; |
47 | 42 | ... | ... |
install/inno setup/user_install.iss
... | ... | @@ -26,7 +26,7 @@ DisableDirPage=yes |
26 | 26 | DefaultGroupName={#MyAppName} |
27 | 27 | OutputBaseFilename=vlibras_desktop_win_2.0.0 |
28 | 28 | DisableProgramGroupPage=yes |
29 | -OutputDir="C:\Users\ezequiel\Desktop\vlibras_desktop_win_2.0.0" | |
29 | +OutputDir="C:\Users\ezequiel\Desktop\vlibras_installer_2.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 | +;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; | |
48 | 48 | Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs |
49 | 49 | |
50 | 50 | |
... | ... | @@ -58,10 +58,10 @@ 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 | -Filename: {sd}\vlibras-libs\required\user_install.bat; Flags: runhidden; StatusMsg: Instalando dependências... | |
64 | -Filename: {sd}\vlibras-libs\update\vlibras-up.exe; Parameters: silence; StatusMsg: Instalando atualização... | |
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 | +Filename: {sd}\vlibras-libs\required\user_install.bat; Flags: runhidden; StatusMsg: Finalizando Instalação... | |
64 | +Filename: {sd}\vlibras-libs\update\vlibrasCheckUp.exe; Flags: runhidden; Parameters: /q /norestart; StatusMsg: Instalando atualização... | |
65 | 65 | |
66 | 66 | |
67 | 67 | ... | ... |
plugin/corePlugin.cpp
... | ... | @@ -5,22 +5,22 @@ |
5 | 5 | #define EXPORT_API __declspec(dllimport) |
6 | 6 | #endif |
7 | 7 | |
8 | - | |
8 | +#include <process.h> | |
9 | 9 | #include "corePlugin.h" |
10 | 10 | |
11 | 11 | |
12 | 12 | |
13 | + | |
13 | 14 | extern "C" |
14 | 15 | { |
15 | 16 | |
16 | - | |
17 | - | |
18 | - | |
17 | + | |
19 | 18 | |
20 | 19 | EXPORT_API int coreInitialize() |
21 | 20 | { |
22 | 21 | //Objeto usado para traduzir |
23 | 22 | tradutor = new PyTradutor(); |
23 | + checkversion = new CheckVersion(); | |
24 | 24 | check =0; |
25 | 25 | |
26 | 26 | //Objeto usado para copiar texto da área de transferência |
... | ... | @@ -41,14 +41,69 @@ |
41 | 41 | |
42 | 42 | EXPORT_API int coreUpdateInstall_player() |
43 | 43 | { |
44 | - System::Diagnostics::Process::Start("C:\\vlibras-libs\\update\\vlibras-up.exe"); | |
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 | |
68 | + | |
69 | + | |
70 | + | |
71 | + CloseHandle(pif.hProcess); //Close handle to process | |
72 | + CloseHandle(pif.hThread); | |
73 | + | |
45 | 74 | return 1; |
46 | 75 | } |
47 | 76 | |
48 | 77 | |
49 | 78 | EXPORT_API int coreUpdateInstall_dict() |
50 | 79 | { |
51 | - System::Diagnostics::Process::Start("C:\\vlibras-libs\\update\\vlibras-up.exe"); | |
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); | |
106 | + | |
52 | 107 | return 1; |
53 | 108 | } |
54 | 109 | |
... | ... | @@ -56,33 +111,10 @@ |
56 | 111 | |
57 | 112 | EXPORT_API int coreUpdateCheck() |
58 | 113 | { |
114 | + | |
115 | + checkversion->checkRefresh(); | |
59 | 116 | |
60 | - | |
61 | - vector<string> updates = Util::checkVersion(false); | |
62 | - if(updates.size()>2) | |
63 | - { | |
64 | - | |
65 | - switch (updates.size()) | |
66 | - { | |
67 | - case 3: | |
68 | - if(updates[0]=="playerVersion") | |
69 | - { | |
70 | - return 1; | |
71 | - } | |
72 | - else if(updates[0]=="dictionaryVersion") | |
73 | - { | |
74 | - return 2; | |
75 | - } | |
76 | - break; | |
77 | - case 6: | |
78 | - return 1; | |
79 | - | |
80 | - break; | |
81 | - } | |
82 | - | |
83 | - } else if(updates.size()==1) | |
84 | - return -1; | |
85 | - return 0; | |
117 | + return checkversion->vstatus; | |
86 | 118 | } |
87 | 119 | |
88 | 120 | EXPORT_API int coreFinalize() | ... | ... |
plugin/corePlugin.h
... | ... | @@ -3,6 +3,8 @@ |
3 | 3 | VLibras: Plugin para integração com Unity |
4 | 4 | |
5 | 5 | Bruno santos |
6 | +Ezequiel Silva | |
7 | +ezequielsilva@lavid.ufpb.br | |
6 | 8 | VLibras-Core |
7 | 9 | 2015 |
8 | 10 | */ |
... | ... | @@ -10,8 +12,8 @@ VLibras-Core |
10 | 12 | |
11 | 13 | /** |
12 | 14 | * \file corePlugin.h |
13 | -* \authors Bruno Santos | |
14 | -* \date Janeiro 2015 | |
15 | +* \authors Bruno Santos, Ezequiel Silva | |
16 | +* \date Janeiro 2015 / Outubro 2015 | |
15 | 17 | */ |
16 | 18 | #ifndef _COREPLUGIN_H |
17 | 19 | #define _COREPLUGIN_H |
... | ... | @@ -19,8 +21,9 @@ VLibras-Core |
19 | 21 | |
20 | 22 | #include "pyClip.h" |
21 | 23 | #include "pyTradutor.h" |
24 | +#include "checkVersion.h" | |
22 | 25 | #include <string.h> |
23 | -#include "Util.h" | |
26 | + | |
24 | 27 | |
25 | 28 | using namespace std; |
26 | 29 | |
... | ... | @@ -32,6 +35,8 @@ extern "C" |
32 | 35 | //Usado para copiar texto da área de transferência |
33 | 36 | PyClip clipboard; |
34 | 37 | |
38 | + //Usado para verificar se existe atualização | |
39 | + CheckVersion *checkversion; | |
35 | 40 | |
36 | 41 | //Inicializa Objetos |
37 | 42 | EXPORT_API int coreInitize(void); | ... | ... |
src/util.cpp
... | ... | @@ -20,23 +20,7 @@ string Util::clrStringTostring(String^ strIn) |
20 | 20 | return stlString; |
21 | 21 | } |
22 | 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 | - | |
23 | + | |
40 | 24 | |
41 | 25 | bool Util::checkNet() |
42 | 26 | { |
... | ... | @@ -175,112 +159,6 @@ vector<string> Util::localVersion() |
175 | 159 | } |
176 | 160 | |
177 | 161 | |
178 | -string Util::Download(DownloadProgressChangedEventHandler^ dpch ,string url, string fileName) | |
179 | -{ | |
180 | - try | |
181 | - { | |
182 | - myWebClient = gcnew WebClient(); | |
183 | - Uri^ uri = gcnew Uri(gcnew String(url.c_str())); | |
184 | - myWebClient->DownloadProgressChanged += dpch; | |
185 | - myWebClient->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallBack2 ); | |
186 | - String^ outPath = gcnew String(("c:\\vlibras-libs\\update\\"+fileName).c_str()); | |
187 | - myWebClient->DownloadFileAsync(uri, outPath); | |
188 | - }catch (Exception^ e) | |
189 | - { | |
190 | - return "FALHA"; | |
191 | - } | |
192 | - | |
193 | - return "OK"; | |
194 | - } | |
195 | - | |
196 | - | |
197 | - | |
198 | - bool Util::saveNewXmlVersion(string playerVersion,string dictionaryVersion) | |
199 | - { | |
200 | - | |
201 | - XmlDocument^ xmlDocLocal; | |
202 | - XmlNodeList^ filesLocal; | |
203 | - vector<string> updates; | |
204 | - try | |
205 | - { | |
206 | - xmlDocLocal = (gcnew XmlDocument()); | |
207 | - //xml version local | |
208 | - StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); | |
209 | - | |
210 | - String^ responseLocal = readerLocal->ReadToEnd(); | |
211 | - | |
212 | - xmlDocLocal->LoadXml(responseLocal); | |
213 | - | |
214 | - filesLocal = xmlDocLocal->GetElementsByTagName("version"); | |
215 | - | |
216 | - if(!playerVersion.empty()) | |
217 | - filesLocal[0]["playerVersion"]->InnerText = gcnew String(playerVersion.c_str()); | |
218 | - | |
219 | - if(!dictionaryVersion.empty()) | |
220 | - filesLocal[0]["dictionaryVersion"]->InnerText = gcnew String(dictionaryVersion.c_str()); | |
221 | - | |
222 | - | |
223 | - // Cleanup the streams and the response. | |
224 | - readerLocal->Close(); | |
225 | - | |
226 | - xmlDocLocal->Save("c:\\vlibras-libs\\update\\updateVersion.xml"); | |
227 | - }catch(Exception^ e) | |
228 | - { | |
229 | - | |
230 | - } | |
231 | - | |
232 | - return true; | |
233 | - } | |
234 | - | |
235 | - | |
236 | - bool Util::extractZip(string zipFile, string outPath) | |
237 | - { | |
238 | - try | |
239 | - { | |
240 | - String^ zipPath = gcnew String(zipFile.c_str()); | |
241 | - String^ extractPath = gcnew String(outPath.c_str()); | |
242 | - ZipFile::ExtractToDirectory(zipPath, extractPath); | |
243 | - | |
244 | - }catch(Exception^ e) | |
245 | - { | |
246 | - return false; | |
247 | - } | |
248 | - | |
249 | - return true; | |
250 | - } | |
251 | - | |
252 | -bool Util::backup() | |
253 | -{ | |
254 | - CHAR nome_atual[] = "c:\\vlibras-libs"; | |
255 | - // novo nome do diretório | |
256 | - CHAR nome_novo[] = "c:\\vlibras-libs-BK"; | |
257 | - | |
258 | - // renomear o diretório | |
259 | - if(MoveFile(nome_atual, nome_novo)){ | |
260 | - | |
261 | - } | |
262 | - else{ | |
263 | - return false; | |
264 | - } | |
265 | - return true; | |
266 | -} | |
267 | -bool Util::restore() | |
268 | -{ | |
269 | - CHAR nome_atual[] = "c:\\vlibras-libs-BK"; | |
270 | - // novo nome do diretório | |
271 | - CHAR nome_novo[] = "c:\\vlibras-libs"; | |
272 | - | |
273 | - // renomear o diretório | |
274 | - if(MoveFile(nome_atual, nome_novo)){ | |
275 | - return true; | |
276 | - } | |
277 | - else{ | |
278 | - return false; | |
279 | - //GetLastError() << endl; | |
280 | - } | |
281 | - return true; | |
282 | -} | |
283 | - | |
284 | 162 | |
285 | 163 | |
286 | 164 | ... | ... |
... | ... | @@ -0,0 +1,53 @@ |
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 | +}; | |
0 | 54 | \ No newline at end of file | ... | ... |
update/include/janelaAtualizacao.h
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 | + | |
1 | 23 | #include <string> |
2 | 24 | |
3 | 25 | #using <System.dll> | ... | ... |
... | ... | @@ -0,0 +1,182 @@ |
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/util.cpp
... | ... | @@ -108,7 +108,6 @@ vector<string> Util::checkVersion(bool atualize) |
108 | 108 | String^ playerVersion = files[0]["playerVersion"]->InnerText; |
109 | 109 | String^ dictionaryVersion = files[0]["dictionaryVersion"]->InnerText; |
110 | 110 | |
111 | - MessageBox(0, "version local "+(gcnew String(localversion[1].c_str()))+" \n Server Version : "+playerVersion,"MessageBox caption", MB_OK); | |
112 | 111 | if(String::Compare( playerVersion, gcnew String(localversion[1].c_str()))) |
113 | 112 | { |
114 | 113 | updates.push_back("playerVersion"); | ... | ... |