Commit 95e4b2e649cc7ccbd3293621c3f2f024259ac760
1 parent
78850984
Exists in
master
Adciona vlibras update e faz modificações
Showing
17 changed files
with
1268 additions
and
24 deletions
Show diff stats
Makefile
| 1 | ############################## MAKEFILE VLIBRAS ############################ | 1 | ############################## MAKEFILE VLIBRAS ############################ |
| 2 | # # | 2 | # # |
| 3 | # Bruno Santos # | 3 | # Bruno Santos # |
| 4 | -# brunosantos@lavid.ufpb.br # | 4 | +# brunosantos@lavid.ufpb.br # |
| 5 | +# Ezequiel Silva # | ||
| 6 | +# ezequielsilva@lavid.ufpb.br # | ||
| 5 | # # | 7 | # # |
| 6 | ############################################################################ | 8 | ############################################################################ |
| 7 | 9 | ||
| 8 | # Includes | 10 | # Includes |
| 9 | -CFLAGS = -I C:\Python27\include -I include | 11 | +CFLAGS = -I C:\Python27\include -I include -I "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" |
| 10 | 12 | ||
| 11 | # Link com as libs utilizadas | 13 | # Link com as libs utilizadas |
| 12 | LFLAGS = -link C:\Python27\libs\python27.lib | 14 | LFLAGS = -link C:\Python27\libs\python27.lib |
| @@ -17,11 +19,14 @@ CC = cl | @@ -17,11 +19,14 @@ CC = cl | ||
| 17 | # Nome do arquivo de saída | 19 | # Nome do arquivo de saída |
| 18 | OUT = testLibras | 20 | OUT = testLibras |
| 19 | 21 | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 20 | # Arquivos de implementação | 25 | # Arquivos de implementação |
| 21 | -FILES = src\pyTradutor.cpp src\pyClip.cpp | 26 | +FILES = src\pyTradutor.cpp src\pyClip.cpp src\util.cpp |
| 22 | 27 | ||
| 23 | #Headers | 28 | #Headers |
| 24 | -INCLUDES = include\pyTradutor.h include\pyClip.h | 29 | +INCLUDES = include\pyTradutor.h include\pyClip.h include\util.h |
| 25 | 30 | ||
| 26 | CLEAN_OBJ = del -q *.obj | 31 | CLEAN_OBJ = del -q *.obj |
| 27 | 32 | ||
| @@ -29,13 +34,13 @@ HOME = %homepath% | @@ -29,13 +34,13 @@ HOME = %homepath% | ||
| 29 | 34 | ||
| 30 | #Gera executável testLibras | 35 | #Gera executável testLibras |
| 31 | all: $(FILES) $(INCLUDES) src\testLibras.cpp | 36 | all: $(FILES) $(INCLUDES) src\testLibras.cpp |
| 32 | - $(CC) -Fe$(OUT) -EHsc src\testLibras.cpp $(FILES) $(CFLAGS) $(LFLAGS) | 37 | + $(CC) -Fe$(OUT) -clr src\testLibras.cpp $(FILES) $(CFLAGS) $(LFLAGS) |
| 33 | $(CLEAN_OBJ) | 38 | $(CLEAN_OBJ) |
| 34 | 39 | ||
| 35 | #Gera dll na arquitetura x86 | 40 | #Gera dll na arquitetura x86 |
| 36 | plugin-x86: $(FILES) $(INCLUDES) | 41 | plugin-x86: $(FILES) $(INCLUDES) |
| 37 | IF NOT EXIST plugin\Plugin-x86 mkdir plugin\Plugin-x86 | 42 | IF NOT EXIST plugin\Plugin-x86 mkdir plugin\Plugin-x86 |
| 38 | - $(CC) -Feplugin\Plugin-x86\CorePlugin -EHsc -LD plugin\corePlugin.cpp $(FILES) -I plugin\corePlugin.h $(CFLAGS) $(LFLAGS) | 43 | + $(CC) -Feplugin\Plugin-x86\CorePlugin -LD plugin\corePlugin.cpp $(FILES) -I plugin\corePlugin.h -clr $(CFLAGS) $(LFLAGS) |
| 39 | $(CLEAN_OBJ) | 44 | $(CLEAN_OBJ) |
| 40 | 45 | ||
| 41 | #Gera dll na arquitetura x64 | 46 | #Gera dll na arquitetura x64 |
icon/icon_vlibras.ico
No preview for this file type
| @@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
| 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 | + |
install/inno setup/user_install.iss
| 1 | ;################### INSTALADOR VLIBRAS WINDOWS ###################### | 1 | ;################### INSTALADOR VLIBRAS WINDOWS ###################### |
| 2 | ;# Bruno Santos # | 2 | ;# Bruno Santos # |
| 3 | -;# brunosantos@lavid.ufpb.br # | 3 | +;# brunosantos@lavid.ufpb.br # |
| 4 | +;# Ezequiel Silva # | ||
| 5 | +;# ezequielsilva@lavid.ufpb.br # | ||
| 4 | ;##################################################################### | 6 | ;##################################################################### |
| 5 | 7 | ||
| 6 | #define MyAppName "VLibras" | 8 | #define MyAppName "VLibras" |
| 7 | #define MyAppVersion "beta" | 9 | #define MyAppVersion "beta" |
| 8 | #define MyAppPublisher "LAViD" | 10 | #define MyAppPublisher "LAViD" |
| 9 | #define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" | 11 | #define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" |
| 10 | -#define MyAppExeName "Playerx86.exe" | 12 | +#define MyAppExeName "VlibrasPlayer.exe" |
| 13 | + | ||
| 14 | + | ||
| 11 | 15 | ||
| 12 | [Setup] | 16 | [Setup] |
| 13 | AppId={{9AA2CD86-F136-47FA-9EFE-474057F0C45F} | 17 | AppId={{9AA2CD86-F136-47FA-9EFE-474057F0C45F} |
| @@ -20,14 +24,16 @@ AppUpdatesURL={#MyAppURL} | @@ -20,14 +24,16 @@ AppUpdatesURL={#MyAppURL} | ||
| 20 | DefaultDirName={sd}\vlibras-libs | 24 | DefaultDirName={sd}\vlibras-libs |
| 21 | DisableDirPage=yes | 25 | DisableDirPage=yes |
| 22 | DefaultGroupName={#MyAppName} | 26 | DefaultGroupName={#MyAppName} |
| 27 | +OutputBaseFilename=vlibras_desktop_win_2.0.0 | ||
| 23 | DisableProgramGroupPage=yes | 28 | DisableProgramGroupPage=yes |
| 24 | -OutputDir="C:\Users\bruno\Desktop\output" | ||
| 25 | -OutputBaseFilename=VLibras Installer | ||
| 26 | -SetupIconFile="C:\Users\bruno\Desktop\user_install\icons\icon_vlibras.ico" | 29 | +OutputDir="C:\Users\ezequiel\Desktop\vlibras_desktop_win_2.0.0" |
| 30 | +SetupIconFile="C:\Users\ezequiel\Desktop\user_install\icons\icon_vlibras.ico" | ||
| 27 | Compression=lzma | 31 | Compression=lzma |
| 28 | SolidCompression=yes | 32 | SolidCompression=yes |
| 29 | -WizardImageFile = "C:\Users\bruno\Desktop\user_install\icons\avatar.bmp" | ||
| 30 | -WizardSmallImageFile = "C:\Users\bruno\Desktop\user_install\icons\small2.bmp" | 33 | +WizardImageFile = "C:\Users\ezequiel\Desktop\user_install\icons\avatar.bmp" |
| 34 | +WizardSmallImageFile = "C:\Users\ezequiel\Desktop\user_install\icons\player.bmp" | ||
| 35 | + | ||
| 36 | + | ||
| 31 | 37 | ||
| 32 | [Languages] | 38 | [Languages] |
| 33 | Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" | 39 | Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" |
| @@ -37,7 +43,12 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ | @@ -37,7 +43,12 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ | ||
| 37 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 | 43 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 |
| 38 | 44 | ||
| 39 | [Files] | 45 | [Files] |
| 40 | -Source: "C:\Users\bruno\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs | 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 | +Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 41 | 52 | ||
| 42 | [Icons] | 53 | [Icons] |
| 43 | Name: "{group}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; IconFilename: "{app}\icons\icon_vlibras.ico" | 54 | Name: "{group}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; IconFilename: "{app}\icons\icon_vlibras.ico" |
| @@ -47,5 +58,14 @@ Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; | @@ -47,5 +58,14 @@ Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; | ||
| 47 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" | 58 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" |
| 48 | 59 | ||
| 49 | [Run] | 60 | [Run] |
| 50 | -Filename: {sd}\vlibras-libs\required\user_install.bat; Flags: runhidden | 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... | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + | ||
| 51 | 71 |
| @@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
| 1 | +;################### INSTALADOR VLIBRAS WINDOWS ###################### | ||
| 2 | +;# Bruno Santos # | ||
| 3 | +;# brunosantos@lavid.ufpb.br # | ||
| 4 | +;##################################################################### | ||
| 5 | + | ||
| 6 | +#define MyAppName "VLibras" | ||
| 7 | +#define MyAppVersion "beta" | ||
| 8 | +#define MyAppPublisher "LAViD" | ||
| 9 | +#define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" | ||
| 10 | +#define MyAppExeName "Playerx86.exe" | ||
| 11 | + | ||
| 12 | +[Setup] | ||
| 13 | +AppId={{84B73167-EF7F-42BB-9CCD-E1A8E2C53659} | ||
| 14 | +AppName={#MyAppName} | ||
| 15 | +AppVersion={#MyAppVersion} | ||
| 16 | +AppPublisher={#MyAppPublisher} | ||
| 17 | +AppPublisherURL={#MyAppURL} | ||
| 18 | +AppSupportURL={#MyAppURL} | ||
| 19 | +AppUpdatesURL={#MyAppURL} | ||
| 20 | +DefaultDirName={pf}\vlibras-libs | ||
| 21 | +DisableDirPage=yes | ||
| 22 | +DefaultGroupName={#MyAppName} | ||
| 23 | +DisableProgramGroupPage=yes | ||
| 24 | +OutputDir="C:\Users\ezequiel\Desktop\output" | ||
| 25 | +OutputBaseFilename=VLibras Installer | ||
| 26 | +SetupIconFile="C:\Users\ezequiel\vlibras-libs\icons\icon_vlibras.ico" | ||
| 27 | +Compression=lzma | ||
| 28 | +SolidCompression=yes | ||
| 29 | +WizardImageFile = "C:\Users\ezequiel\vlibras-libs\icons\avatar.bmp" | ||
| 30 | +WizardSmallImageFile = "C:\Users\ezequiel\vlibras-libs\icons\small2.bmp" | ||
| 31 | + | ||
| 32 | +[Languages] | ||
| 33 | +Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" | ||
| 34 | + | ||
| 35 | +[Tasks] | ||
| 36 | +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}" | ||
| 37 | +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 | ||
| 38 | + | ||
| 39 | +[Files] | ||
| 40 | +Source: "C:\vlibras-libs\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs | ||
| 41 | + | ||
| 42 | +[Icons] | ||
| 43 | +Name: "{group}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; IconFilename: "{app}\icons\icon_vlibras.ico" | ||
| 44 | +Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" | ||
| 45 | +Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" | ||
| 46 | +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: desktopicon; IconFilename: "{app}\icons\icon_vlibras.ico" | ||
| 47 | +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" | ||
| 48 | + | ||
| 49 | +[Run] | ||
| 50 | +Filename: {app}\vlibras-libs\required\user_install.bat; Flags: runhidden | ||
| 51 | + |
plugin/corePlugin.cpp
| @@ -5,18 +5,27 @@ | @@ -5,18 +5,27 @@ | ||
| 5 | #define EXPORT_API __declspec(dllimport) | 5 | #define EXPORT_API __declspec(dllimport) |
| 6 | #endif | 6 | #endif |
| 7 | 7 | ||
| 8 | + | ||
| 8 | #include "corePlugin.h" | 9 | #include "corePlugin.h" |
| 9 | 10 | ||
| 11 | + | ||
| 12 | + | ||
| 10 | extern "C" | 13 | extern "C" |
| 11 | { | 14 | { |
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 12 | EXPORT_API int coreInitialize() | 20 | EXPORT_API int coreInitialize() |
| 13 | { | 21 | { |
| 14 | //Objeto usado para traduzir | 22 | //Objeto usado para traduzir |
| 15 | tradutor = new PyTradutor(); | 23 | tradutor = new PyTradutor(); |
| 24 | + check =0; | ||
| 16 | 25 | ||
| 17 | //Objeto usado para copiar texto da área de transferência | 26 | //Objeto usado para copiar texto da área de transferência |
| 18 | clipboard.bdragOn(); | 27 | clipboard.bdragOn(); |
| 19 | - | 28 | + |
| 20 | return 1; | 29 | return 1; |
| 21 | } | 30 | } |
| 22 | 31 | ||
| @@ -24,11 +33,58 @@ | @@ -24,11 +33,58 @@ | ||
| 24 | { | 33 | { |
| 25 | //Copia área de transferência para input | 34 | //Copia área de transferência para input |
| 26 | char *input = clipboard.clip(); | 35 | char *input = clipboard.clip(); |
| 27 | - | 36 | + |
| 28 | //Retorna a tradução do texto para glosa | 37 | //Retorna a tradução do texto para glosa |
| 29 | return tradutor->convertStringToGlosa(input); | 38 | return tradutor->convertStringToGlosa(input); |
| 30 | } | 39 | } |
| 31 | 40 | ||
| 41 | + | ||
| 42 | + EXPORT_API int coreUpdateInstall_player() | ||
| 43 | + { | ||
| 44 | + System::Diagnostics::Process::Start("C:\\vlibras-libs\\update\\vlibras-up.exe"); | ||
| 45 | + return 1; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + EXPORT_API int coreUpdateInstall_dict() | ||
| 50 | + { | ||
| 51 | + System::Diagnostics::Process::Start("C:\\vlibras-libs\\update\\vlibras-up.exe"); | ||
| 52 | + return 1; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + EXPORT_API int coreUpdateCheck() | ||
| 58 | + { | ||
| 59 | + | ||
| 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; | ||
| 86 | + } | ||
| 87 | + | ||
| 32 | EXPORT_API int coreFinalize() | 88 | EXPORT_API int coreFinalize() |
| 33 | { | 89 | { |
| 34 | clipboard.bdragOff(); | 90 | clipboard.bdragOff(); |
plugin/corePlugin.h
| @@ -16,10 +16,11 @@ VLibras-Core | @@ -16,10 +16,11 @@ VLibras-Core | ||
| 16 | #ifndef _COREPLUGIN_H | 16 | #ifndef _COREPLUGIN_H |
| 17 | #define _COREPLUGIN_H | 17 | #define _COREPLUGIN_H |
| 18 | 18 | ||
| 19 | -#include <iostream> | 19 | + |
| 20 | #include "pyClip.h" | 20 | #include "pyClip.h" |
| 21 | #include "pyTradutor.h" | 21 | #include "pyTradutor.h" |
| 22 | #include <string.h> | 22 | #include <string.h> |
| 23 | +#include "Util.h" | ||
| 23 | 24 | ||
| 24 | using namespace std; | 25 | using namespace std; |
| 25 | 26 | ||
| @@ -27,18 +28,28 @@ extern "C" | @@ -27,18 +28,28 @@ extern "C" | ||
| 27 | { | 28 | { |
| 28 | //Usado para traduzir português para glosa | 29 | //Usado para traduzir português para glosa |
| 29 | PyTradutor *tradutor; | 30 | PyTradutor *tradutor; |
| 30 | - | 31 | + int check; |
| 31 | //Usado para copiar texto da área de transferência | 32 | //Usado para copiar texto da área de transferência |
| 32 | PyClip clipboard; | 33 | PyClip clipboard; |
| 34 | + | ||
| 33 | 35 | ||
| 34 | //Inicializa Objetos | 36 | //Inicializa Objetos |
| 35 | EXPORT_API int coreInitize(void); | 37 | EXPORT_API int coreInitize(void); |
| 36 | 38 | ||
| 37 | //Faz tradução de Português para glosa | 39 | //Faz tradução de Português para glosa |
| 38 | EXPORT_API char* coreExecute(void); | 40 | EXPORT_API char* coreExecute(void); |
| 39 | - | 41 | + |
| 42 | + //faz atualização player | ||
| 43 | + EXPORT_API int coreUpdateInstall_player(void); | ||
| 44 | + | ||
| 45 | + //faz atualização dicionário | ||
| 46 | + EXPORT_API int coreUpdateInstall_dict(void); | ||
| 47 | + //check atualização | ||
| 48 | + EXPORT_API int coreUpdateCheck(void); | ||
| 40 | //Libera Objetos utilizados | 49 | //Libera Objetos utilizados |
| 41 | EXPORT_API int coreFinalize(void); | 50 | EXPORT_API int coreFinalize(void); |
| 51 | + | ||
| 52 | + | ||
| 42 | } | 53 | } |
| 43 | 54 | ||
| 44 | #endif | 55 | #endif |
| 45 | \ No newline at end of file | 56 | \ No newline at end of file |
plugin/testPlugin.cpp
| @@ -12,6 +12,8 @@ metodo2 execute; | @@ -12,6 +12,8 @@ metodo2 execute; | ||
| 12 | 12 | ||
| 13 | typedef int (WINAPI*metodo3)(); | 13 | typedef int (WINAPI*metodo3)(); |
| 14 | metodo3 finalize; | 14 | metodo3 finalize; |
| 15 | +typedef int (WINAPI*metodo4)(); | ||
| 16 | +metodo4 update; | ||
| 15 | 17 | ||
| 16 | int main(int argc, char *argv[]) | 18 | int main(int argc, char *argv[]) |
| 17 | { | 19 | { |
| @@ -27,19 +29,30 @@ int main(int argc, char *argv[]) | @@ -27,19 +29,30 @@ int main(int argc, char *argv[]) | ||
| 27 | initialize=(metodo1)GetProcAddress((HMODULE)hDLL, "coreInitialize"); | 29 | initialize=(metodo1)GetProcAddress((HMODULE)hDLL, "coreInitialize"); |
| 28 | execute=(metodo2)GetProcAddress((HMODULE)hDLL, "coreExecute"); | 30 | execute=(metodo2)GetProcAddress((HMODULE)hDLL, "coreExecute"); |
| 29 | finalize=(metodo3)GetProcAddress((HMODULE)hDLL, "coreFinalize"); | 31 | finalize=(metodo3)GetProcAddress((HMODULE)hDLL, "coreFinalize"); |
| 32 | + update=(metodo4)GetProcAddress((HMODULE)hDLL, "coreUpdate"); | ||
| 30 | 33 | ||
| 31 | //Executa coreInitialize | 34 | //Executa coreInitialize |
| 32 | int init = initialize(); | 35 | int init = initialize(); |
| 33 | cout <<"return initialize: " << init <<endl; | 36 | cout <<"return initialize: " << init <<endl; |
| 37 | + | ||
| 38 | + int in = update(); | ||
| 39 | + cout <<"return update: " << in <<endl; | ||
| 40 | + | ||
| 41 | + //in = update(); | ||
| 42 | + //cout <<"return update2: " << in <<endl; | ||
| 43 | + | ||
| 44 | + //in=0; | ||
| 45 | + //in = update(); | ||
| 46 | + //cout <<"return update3: " << in <<endl; | ||
| 34 | 47 | ||
| 35 | //Executa coreExecute | 48 | //Executa coreExecute |
| 36 | - char* exec = execute(); | ||
| 37 | - cout << "return execute: " << exec <<endl; | ||
| 38 | - | 49 | + //char* exec = execute(); |
| 50 | + //cout << "return execute: " << exec <<endl; | ||
| 51 | +while(1); | ||
| 39 | //Executa coreFinalize | 52 | //Executa coreFinalize |
| 40 | int final = finalize(); | 53 | int final = finalize(); |
| 41 | cout << "return finalize: " << final <<endl; | 54 | cout << "return finalize: " << final <<endl; |
| 42 | - | 55 | + |
| 43 | //Libera dll | 56 | //Libera dll |
| 44 | FreeLibrary((HMODULE)hDLL); | 57 | FreeLibrary((HMODULE)hDLL); |
| 45 | 58 |
| @@ -0,0 +1,287 @@ | @@ -0,0 +1,287 @@ | ||
| 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 | + updates.push_back("faill"); | ||
| 136 | + return updates; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + return updates; | ||
| 140 | +} | ||
| 141 | + | ||
| 142 | + | ||
| 143 | +vector<string> Util::localVersion() | ||
| 144 | +{ | ||
| 145 | + XmlDocument^ xmlDocLocal; | ||
| 146 | + XmlNodeList^ filesLocal; | ||
| 147 | + vector<string> updates; | ||
| 148 | + try | ||
| 149 | + { | ||
| 150 | + xmlDocLocal = (gcnew XmlDocument()); | ||
| 151 | + //xml version local | ||
| 152 | + StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); | ||
| 153 | + | ||
| 154 | + String^ responseLocal = readerLocal->ReadToEnd(); | ||
| 155 | + | ||
| 156 | + xmlDocLocal->LoadXml(responseLocal); | ||
| 157 | + | ||
| 158 | + filesLocal = xmlDocLocal->GetElementsByTagName("version"); | ||
| 159 | + | ||
| 160 | + updates.push_back("playerVersion"); | ||
| 161 | + String^ playerVersion = filesLocal[0]["playerVersion"]->InnerText; | ||
| 162 | + updates.push_back(clrStringTostring(playerVersion)); | ||
| 163 | + updates.push_back("dictionaryVersion"); | ||
| 164 | + String^ dictionaryVersion = filesLocal[0]["dictionaryVersion"]->InnerText; | ||
| 165 | + updates.push_back(clrStringTostring(dictionaryVersion)); | ||
| 166 | + | ||
| 167 | + // Cleanup the streams and the response. | ||
| 168 | + readerLocal->Close(); | ||
| 169 | + }catch(Exception^ e) | ||
| 170 | + { | ||
| 171 | + return updates; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + return updates; | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | + | ||
| 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 | + | ||
| 285 | + | ||
| 286 | + | ||
| 287 | + | ||
| 0 | \ No newline at end of file | 288 | \ No newline at end of file |
| @@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
| 1 | +############################## MAKEFILE VLIBRAS ############################ | ||
| 2 | +# # | ||
| 3 | +# Bruno Santos # | ||
| 4 | +# brunosantos@lavid.ufpb.br # | ||
| 5 | +# Ezequiel Silva # | ||
| 6 | +# ezequielsilva@lavid.ufpb.br # # | ||
| 7 | +# # | ||
| 8 | +############################################################################ | ||
| 9 | + | ||
| 10 | +# Includes | ||
| 11 | +CFLAGS = -I include | ||
| 12 | + | ||
| 13 | +# Link com as libs utilizadas | ||
| 14 | +#LFLAGS = -link C:\Python27\libs\python27.lib | ||
| 15 | + | ||
| 16 | +# Compilador Nativo | ||
| 17 | +CC = cl | ||
| 18 | + | ||
| 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 | ||
| 24 | + | ||
| 25 | +#Headers | ||
| 26 | +INCLUDES = include\util.h include\janelaAtualizacao.h | ||
| 27 | + | ||
| 28 | +CLEAN_OBJ = del -q *.obj | ||
| 29 | + | ||
| 30 | +HOME = %homepath% | ||
| 31 | + | ||
| 32 | +#Gera executável testLibras | ||
| 33 | +all: $(FILES) $(INCLUDES) | ||
| 34 | + $(CC) -Fe$(OUT) -clr vlibrasUpdate.cpp $(FILES) $(CFLAGS) | ||
| 35 | + $(CLEAN_OBJ) | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + | ||
| 40 | +#Limpa arquivos objetos e executáveis criados | ||
| 41 | +clean: | ||
| 42 | + del -q *.exe *.obj | ||
| 43 | + rm -rf doc | ||
| 44 | + | ||
| 45 | + |
| @@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
| 1 | +#include <string> | ||
| 2 | + | ||
| 3 | +#using <System.dll> | ||
| 4 | +#using <System.Windows.Forms.dll> | ||
| 5 | +#using <System.Drawing.dll> | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +using namespace System::Windows::Forms; | ||
| 9 | +using namespace System; | ||
| 10 | +using namespace System::Drawing; | ||
| 11 | +using namespace System::ComponentModel; | ||
| 12 | +using namespace std; | ||
| 13 | + | ||
| 14 | +public ref class JanelaAtualizacao : public Form | ||
| 15 | +{ | ||
| 16 | + private: | ||
| 17 | + | ||
| 18 | + bool downloading; | ||
| 19 | + RichTextBox^ richTextBox1; | ||
| 20 | + Label^ lbInformacao; | ||
| 21 | + Label^ topo; | ||
| 22 | + int vez=0; | ||
| 23 | + Bitmap^ animatedImage; | ||
| 24 | + String^ informacao; | ||
| 25 | + void btOKevent(Object^ sender, EventArgs^ e); | ||
| 26 | + void XFormClosing(Object^ sender, FormClosingEventArgs^ e); | ||
| 27 | + | ||
| 28 | + public: | ||
| 29 | + static ProgressBar^ progressBar1; | ||
| 30 | + static Label^ lbInfDownload; | ||
| 31 | + Button^ btOK; | ||
| 32 | + JanelaAtualizacao(); | ||
| 33 | + | ||
| 34 | + void initializeComponent(); | ||
| 35 | + void setInfoWhite(String^ info); | ||
| 36 | + void setInfoGreen(String^ info); | ||
| 37 | + void setInfoRed(String^ info); | ||
| 38 | + void start(); | ||
| 39 | + void EnableButton(); | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + | ||
| 43 | +}; | ||
| 44 | + |
| @@ -0,0 +1,51 @@ | @@ -0,0 +1,51 @@ | ||
| 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 | + |
| @@ -0,0 +1,151 @@ | @@ -0,0 +1,151 @@ | ||
| 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 | + | ||
| 0 | \ No newline at end of file | 152 | \ No newline at end of file |
| @@ -0,0 +1,287 @@ | @@ -0,0 +1,287 @@ | ||
| 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 | + MessageBox(0, "version local "+(gcnew String(localversion[1].c_str()))+" \n Server Version : "+playerVersion,"MessageBox caption", MB_OK); | ||
| 112 | + if(String::Compare( playerVersion, gcnew String(localversion[1].c_str()))) | ||
| 113 | + { | ||
| 114 | + updates.push_back("playerVersion"); | ||
| 115 | + updates.push_back(clrStringTostring(playerVersion)); | ||
| 116 | + updates.push_back(clrStringTostring(files[0]["playerUrl"]->InnerText)); | ||
| 117 | + } | ||
| 118 | + if(String::Compare(dictionaryVersion,gcnew String(localversion[3].c_str()))) | ||
| 119 | + { | ||
| 120 | + updates.push_back("dictionaryVersion"); | ||
| 121 | + updates.push_back(clrStringTostring(dictionaryVersion)); | ||
| 122 | + updates.push_back(clrStringTostring(files[0]["dictionaryUrl"]->InnerText)); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + //if(atualize) | ||
| 126 | + //saveNewXmlVersion(playerVersion,dictionaryVersion); | ||
| 127 | + | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + erro: | ||
| 131 | + // Cleanup the streams and the response. | ||
| 132 | + reader->Close(); | ||
| 133 | + dataStream->Close(); | ||
| 134 | + }catch(Exception^ e) | ||
| 135 | + { | ||
| 136 | + return updates; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + return updates; | ||
| 140 | +} | ||
| 141 | + | ||
| 142 | + | ||
| 143 | +vector<string> Util::localVersion() | ||
| 144 | +{ | ||
| 145 | + XmlDocument^ xmlDocLocal; | ||
| 146 | + XmlNodeList^ filesLocal; | ||
| 147 | + vector<string> updates; | ||
| 148 | + try | ||
| 149 | + { | ||
| 150 | + xmlDocLocal = (gcnew XmlDocument()); | ||
| 151 | + //xml version local | ||
| 152 | + StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); | ||
| 153 | + | ||
| 154 | + String^ responseLocal = readerLocal->ReadToEnd(); | ||
| 155 | + | ||
| 156 | + xmlDocLocal->LoadXml(responseLocal); | ||
| 157 | + | ||
| 158 | + filesLocal = xmlDocLocal->GetElementsByTagName("version"); | ||
| 159 | + | ||
| 160 | + updates.push_back("playerVersion"); | ||
| 161 | + String^ playerVersion = filesLocal[0]["playerVersion"]->InnerText; | ||
| 162 | + updates.push_back(clrStringTostring(playerVersion)); | ||
| 163 | + updates.push_back("dictionaryVersion"); | ||
| 164 | + String^ dictionaryVersion = filesLocal[0]["dictionaryVersion"]->InnerText; | ||
| 165 | + updates.push_back(clrStringTostring(dictionaryVersion)); | ||
| 166 | + | ||
| 167 | + // Cleanup the streams and the response. | ||
| 168 | + readerLocal->Close(); | ||
| 169 | + }catch(Exception^ e) | ||
| 170 | + { | ||
| 171 | + return updates; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + return updates; | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | + | ||
| 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 | + | ||
| 285 | + | ||
| 286 | + | ||
| 287 | + | ||
| 0 | \ No newline at end of file | 288 | \ No newline at end of file |
No preview for this file type
| @@ -0,0 +1,172 @@ | @@ -0,0 +1,172 @@ | ||
| 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 | + |