From e3ccbbc784970ec693b007de97a6a8e3f5bfbda5 Mon Sep 17 00:00:00 2001 From: ezequiel Date: Wed, 14 Oct 2015 17:36:52 -0300 Subject: [PATCH] Com a versão do update funcionando --- Makefile | 6 +++--- include/util.h | 46 ---------------------------------------------- install/inno setup/user_instalBK.bat | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ install/inno setup/user_install.bat | 83 ----------------------------------------------------------------------------------- install/inno setup/user_install.iss | 16 +++++++--------- plugin/corePlugin.cpp | 102 ++++++++++++++++++++++++++++++++++-------------------------------------------------------------------- plugin/corePlugin.h | 10 ++++++---- plugin/testPlugin.cpp | 35 +++++++++++++++++++++-------------- src/pyClip.cpp | 2 +- src/util.cpp | 165 --------------------------------------------------------------------------------------------------------------------------------------------------------------------- update/Makefile | 26 +++++--------------------- update/include/checkVersion.h | 53 ----------------------------------------------------- update/include/janelaAtualizacao.h | 66 ------------------------------------------------------------------ update/include/pyVlibrasUpdate.h | 31 +++++++++++++++++++++++++++++++ update/include/util.h | 51 --------------------------------------------------- update/src/checkVersion.cpp | 182 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- update/src/janelaAtualizacao.cpp | 151 ------------------------------------------------------------------------------------------------------------------------------------------------------- update/src/pyVlibrasUpdate.cpp | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/src/util.cpp | 286 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- update/update-icon.ico | Bin 99678 -> 0 bytes update/updatePython/DownloadFile.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/updatePython/VlibrasCheckVersion.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/updatePython/VlibrasUpdate.py | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/updatePython/VlibrasUpdateInstall.py | 212 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/vlibrasDictPlayerInstall.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ update/vlibrasUpdate.cpp | 172 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 26 files changed, 850 insertions(+), 1375 deletions(-) delete mode 100644 include/util.h create mode 100644 install/inno setup/user_instalBK.bat delete mode 100644 install/inno setup/user_install.bat delete mode 100644 src/util.cpp delete mode 100644 update/include/checkVersion.h delete mode 100644 update/include/janelaAtualizacao.h create mode 100644 update/include/pyVlibrasUpdate.h delete mode 100644 update/include/util.h delete mode 100644 update/src/checkVersion.cpp delete mode 100644 update/src/janelaAtualizacao.cpp create mode 100644 update/src/pyVlibrasUpdate.cpp delete mode 100644 update/src/util.cpp delete mode 100644 update/update-icon.ico create mode 100644 update/updatePython/DownloadFile.py create mode 100644 update/updatePython/VlibrasCheckVersion.py create mode 100644 update/updatePython/VlibrasUpdate.py create mode 100644 update/updatePython/VlibrasUpdateInstall.py create mode 100644 update/vlibrasDictPlayerInstall.cpp delete mode 100644 update/vlibrasUpdate.cpp diff --git a/Makefile b/Makefile index 72a6fdf..2c45d30 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,10 @@ OUT = testLibras # Arquivos de implementação -FILES = src\pyTradutor.cpp src\pyClip.cpp update\src\checkVersion.cpp +FILES = src\pyTradutor.cpp src\pyClip.cpp update\src\pyVlibrasUpdate.cpp #Headers -INCLUDES = include\pyTradutor.h include\pyClip.h update\include\checkVersion.h +INCLUDES = include\pyTradutor.h include\pyClip.h update\include\pyVlibrasUpdate.h CLEAN_OBJ = del -q *.obj @@ -34,7 +34,7 @@ HOME = %homepath% #Gera executável testLibras all: $(FILES) $(INCLUDES) src\testLibras.cpp - $(CC) -Fe$(OUT) -clr src\testLibras.cpp $(FILES) $(CFLAGS) $(LFLAGS) + $(CC) -Fe$(OUT) -EHsc src\testLibras.cpp $(FILES) $(CFLAGS) $(LFLAGS) $(CLEAN_OBJ) #Gera dll na arquitetura x86 diff --git a/include/util.h b/include/util.h deleted file mode 100644 index 182693f..0000000 --- a/include/util.h +++ /dev/null @@ -1,46 +0,0 @@ -#using -#using - -#include -#include -#include - - -using namespace std; -using namespace System; - -using namespace System::Net; -using namespace System::IO; -using namespace System::Xml; - - - - - - - - - public ref class Util { - - private: - static string clrStringTostring(String^ strIn); - static vector localVersion(void); - - public: - static bool down; - static WebClient^ myWebClient; - - Util(); - - bool downloading; - - static bool checkNet(void); - static vector checkVersion(bool atualize); - - - }; - - - - - diff --git a/install/inno setup/user_instalBK.bat b/install/inno setup/user_instalBK.bat new file mode 100644 index 0000000..c233a65 --- /dev/null +++ b/install/inno setup/user_instalBK.bat @@ -0,0 +1,83 @@ +::############################## Instalador VLibras ############################ +::# # +::# Bruno Santos # +::# brunosantos@lavid.ufpb.br # +::# # +::############################################################################## + +::Define Título da janela do prompt +TITLE Instalador VLibras-Core Windows + +::Limpa a tela +CLS + +::Desabilita mensagens +@ECHO off + +ECHO ############### Instalando VLibras ############### + +::################# Variáveis de Ambiente ################# +ECHO Exportando Variaveis de Ambiente: + +ECHO AELIUS_DATA +SETX AELIUS_DATA %HOMEDRIVE%\vlibras-libs\aelius_data /M + +ECHO NLTK_DATA +SETX NLTK_DATA %HOMEDRIVE%\vlibras-libs\nltk_data /M + +ECHO HUNPOS_TAGGER +SETX HUNPOS_TAGGER %HOMEDRIVE%\vlibras-libs\bin\hunpos-tag.exe /M + +ECHO PYTHONPATH +SETX PYTHONPATH %HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages;%HOMEDRIVE%\vlibras-libs;%HOMEDRIVE%\vlibras-libs\vlibras-translate\src;%HOMEDRIVE%\vlibras-libs\Clipboard /M + +@echo off +set path_value=%PATH% + +If NOT "%path_value%"=="%path_value:vlibras=%" ( + echo ok +) else ( + SETX "PATH" "%PATH%";%HOMEDRIVE%\vlibras-libs\bin;%HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages /M +) + +::################# Instalação do Python ################# +msiexec /i python-2.7.9.msi /passive +ECHO OK + +::################# Dependências ################# +c:\Python27\python.exe pip-6.0.8-py2.py3-none-any.whl/pip install pip-6.0.8-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install PyYAML-3.11-cp27-none-win32.whl +ECHO OK + +c:\Python27\Scripts\pip install numpy-1.9.2+mkl-cp27-none-win32.whl +ECHO OK + +c:\Python27\Scripts\pip install six-1.9.0-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install pyparsing-2.0.3-py2-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install pytz-2014.10-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install python_dateutil-2.4.0-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install matplotlib-1.4.3-cp27-none-win32.whl +ECHO OK + +c:\Python27\Scripts\pip install nltk-3.0.2-py2.py3-none-any.whl +ECHO OK + +c:\Python27\Scripts\pip install future-0.14.3-py2-none-any.whl +ECHO OK + +::################# HUNPOS.PY & DATA.PY ############################# +COPY %HOMEDRIVE%\vlibras-libs\nltk_data\hunpos.py %homedrive%\Python27\Lib\site-packages\nltk\tag\ /y +COPY %HOMEDRIVE%\vlibras-libs\nltk_data\data.py %homedrive%\Python27\Lib\site-packages\nltk /y +COPY %HOMEDRIVE%\vlibras-libs\nltk_data\nltk_tgrep.py %homedrive%\Python27\Lib\site-packages /y + +ECHO VLibras Tradutor instalado com sucesso! diff --git a/install/inno setup/user_install.bat b/install/inno setup/user_install.bat deleted file mode 100644 index c233a65..0000000 --- a/install/inno setup/user_install.bat +++ /dev/null @@ -1,83 +0,0 @@ -::############################## Instalador VLibras ############################ -::# # -::# Bruno Santos # -::# brunosantos@lavid.ufpb.br # -::# # -::############################################################################## - -::Define Título da janela do prompt -TITLE Instalador VLibras-Core Windows - -::Limpa a tela -CLS - -::Desabilita mensagens -@ECHO off - -ECHO ############### Instalando VLibras ############### - -::################# Variáveis de Ambiente ################# -ECHO Exportando Variaveis de Ambiente: - -ECHO AELIUS_DATA -SETX AELIUS_DATA %HOMEDRIVE%\vlibras-libs\aelius_data /M - -ECHO NLTK_DATA -SETX NLTK_DATA %HOMEDRIVE%\vlibras-libs\nltk_data /M - -ECHO HUNPOS_TAGGER -SETX HUNPOS_TAGGER %HOMEDRIVE%\vlibras-libs\bin\hunpos-tag.exe /M - -ECHO PYTHONPATH -SETX PYTHONPATH %HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages;%HOMEDRIVE%\vlibras-libs;%HOMEDRIVE%\vlibras-libs\vlibras-translate\src;%HOMEDRIVE%\vlibras-libs\Clipboard /M - -@echo off -set path_value=%PATH% - -If NOT "%path_value%"=="%path_value:vlibras=%" ( - echo ok -) else ( - SETX "PATH" "%PATH%";%HOMEDRIVE%\vlibras-libs\bin;%HOMEDRIVE%\Python27;%HOMEDRIVE%\Python27\Scripts;%HOMEDRIVE%\Python27\Lib\site-packages /M -) - -::################# Instalação do Python ################# -msiexec /i python-2.7.9.msi /passive -ECHO OK - -::################# Dependências ################# -c:\Python27\python.exe pip-6.0.8-py2.py3-none-any.whl/pip install pip-6.0.8-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install PyYAML-3.11-cp27-none-win32.whl -ECHO OK - -c:\Python27\Scripts\pip install numpy-1.9.2+mkl-cp27-none-win32.whl -ECHO OK - -c:\Python27\Scripts\pip install six-1.9.0-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install pyparsing-2.0.3-py2-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install pytz-2014.10-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install python_dateutil-2.4.0-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install matplotlib-1.4.3-cp27-none-win32.whl -ECHO OK - -c:\Python27\Scripts\pip install nltk-3.0.2-py2.py3-none-any.whl -ECHO OK - -c:\Python27\Scripts\pip install future-0.14.3-py2-none-any.whl -ECHO OK - -::################# HUNPOS.PY & DATA.PY ############################# -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\hunpos.py %homedrive%\Python27\Lib\site-packages\nltk\tag\ /y -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\data.py %homedrive%\Python27\Lib\site-packages\nltk /y -COPY %HOMEDRIVE%\vlibras-libs\nltk_data\nltk_tgrep.py %homedrive%\Python27\Lib\site-packages /y - -ECHO VLibras Tradutor instalado com sucesso! diff --git a/install/inno setup/user_install.iss b/install/inno setup/user_install.iss index 44d7d1a..9e45880 100644 --- a/install/inno setup/user_install.iss +++ b/install/inno setup/user_install.iss @@ -6,7 +6,7 @@ ;##################################################################### #define MyAppName "VLibras" -#define MyAppVersion "beta" +#define MyAppVersion "3.0.0" #define MyAppPublisher "LAViD" #define MyAppURL "http://vlibrasplayer.lavid.ufpb.br" #define MyAppExeName "VlibrasPlayer.exe" @@ -24,9 +24,9 @@ AppUpdatesURL={#MyAppURL} DefaultDirName={sd}\vlibras-libs DisableDirPage=yes DefaultGroupName={#MyAppName} -OutputBaseFilename=vlibras_desktop_win_2.0.0 +OutputBaseFilename=vlibras_instalador_3.0.0 DisableProgramGroupPage=yes -OutputDir="C:\Users\ezequiel\Desktop\vlibras_installer_2.0.0" +OutputDir="C:\Users\ezequiel\Desktop\vlibras_installer_3.0.0" SetupIconFile="C:\Users\ezequiel\Desktop\user_install\icons\icon_vlibras.ico" Compression=lzma SolidCompression=yes @@ -43,8 +43,8 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 [Files] -;Source: "C:\Users\ezequiel\Desktop\vc_redist.x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; -;Source: "C:\Users\ezequiel\Desktop\dotNetFx40_Client_x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; + +;Source: "C:\Users\ezequiel\Desktop\dotnetfx45_full_x86_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Source: "C:\Users\ezequiel\Desktop\user_install\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs @@ -58,13 +58,11 @@ Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\Player\{#MyAppExeName}"; Tasks: quicklaunchicon; IconFilename: "{app}\icons\icon_vlibras.ico" [Run] -;Filename: {tmp}\dotNetFx40_Client_x86.exe; Flags: runhidden; Parameters: /q /norestart; StatusMsg: Instalando .NET Framework 4.5 -;Filename: {tmp}\vc_redist.x86.exe; Flags: runhidden; Parameters: /q /norestart; StatusMsg: Instalando Visual C++ ... Filename: {sd}\vlibras-libs\required\user_install.bat; Flags: runhidden; StatusMsg: Finalizando Instalação... -Filename: {sd}\vlibras-libs\update\vlibras-up.exe; StatusMsg: Instalando atualização... - +Filename: {sd}\vlibras-libs\update\vlibrasPlayerDictUp.exe; StatusMsg: Instalando atualização... + diff --git a/plugin/corePlugin.cpp b/plugin/corePlugin.cpp index fe0f109..ea15c7b 100644 --- a/plugin/corePlugin.cpp +++ b/plugin/corePlugin.cpp @@ -5,27 +5,24 @@ #define EXPORT_API __declspec(dllimport) #endif -#include #include "corePlugin.h" +#include - +using namespace std; extern "C" { - - + EXPORT_API int coreInitialize() { //Objeto usado para traduzir tradutor = new PyTradutor(); - checkversion = new CheckVersion(); - check =0; - + update = new PyVlibrasUpdate(); //Objeto usado para copiar texto da área de transferência clipboard.bdragOn(); - + return 1; } @@ -41,86 +38,55 @@ EXPORT_API int coreUpdateInstall_player() { - - char szPath[] = "C:\\vlibras-libs\\update\\vlibras-up.exe"; - string params = "C:\\vlibras-libs\\update\\vlibras-up.exe "; - params.append(checkversion->playerUrl); - params.append(" installer "); - params.append(checkversion->playerVersionFull); - PROCESS_INFORMATION pif; //Gives info on the thread and.. - //..process for the new process - STARTUPINFO si; //Defines how to start the program - - ZeroMemory(&si,sizeof(si)); //Zero the STARTUPINFO struct - si.cb = sizeof(si); //Must set size of structure - - BOOL bRet = CreateProcess( - szPath, //Path to executable file - (LPSTR)params.c_str(), //Command string - not needed here - NULL, //Process handle not inherited - NULL, //Thread handle not inherited - FALSE, //No inheritance of handles - 0, //No special flags - NULL, //Same environment block as this prog - NULL, //Current directory - no separate path - &si, //Pointer to STARTUPINFO - &pif); //Pointer to PROCESS_INFORMATION + update->install("c:\\vlibras-libs\\update\\bin\\vlibrasPlayerDictUp.exe","NULL"); - - - CloseHandle(pif.hProcess); //Close handle to process - CloseHandle(pif.hThread); - return 1; } EXPORT_API int coreUpdateInstall_dict() { - char szPath[] = "C:\\vlibras-libs\\update\\vlibras-up.exe"; - string params = "C:\\vlibras-libs\\update\\vlibras-up.exe "; - params.append(checkversion->dictUrl.c_str()); - params.append(" dictionary "); - params.append(checkversion->dictVersionFull); - PROCESS_INFORMATION pif; //Gives info on the thread and.. - //..process for the new process - STARTUPINFO si; //Defines how to start the program - - ZeroMemory(&si,sizeof(si)); //Zero the STARTUPINFO struct - si.cb = sizeof(si); //Must set size of structure - - BOOL bRet = CreateProcess( - szPath, //Path to executable file - (LPSTR)params.c_str(), //Command string - not needed here - NULL, //Process handle not inherited - NULL, //Thread handle not inherited - FALSE, //No inheritance of handles - 0, //No special flags - NULL, //Same environment block as this prog - NULL, //Current directory - no separate path - &si, //Pointer to STARTUPINFO - &pif); //Pointer to PROCESS_INFORMATION - - CloseHandle(pif.hProcess); //Close handle to process - CloseHandle(pif.hThread); + update->install("c:\\vlibras-libs\\update\\bin\\vlibrasPlayerDictUp.exe","NULL"); return 1; } - EXPORT_API int coreUpdateCheck() { - - checkversion->checkRefresh(); - - return checkversion->vstatus; + + string line_in_str; + ifstream file_version; + int return_int = -1; + try + { + update->checkExe("C:\\Python27\\python.exe c:\\vlibras-libs\\update\\py\\VlibrasCheckVersion.pyc","check"); + + clock_t time_end; + time_end = clock() + 3000 * CLOCKS_PER_SEC/1000; + while (clock() < time_end); + + + file_version.open("c:\\vlibras-libs\\update\\version\\version.txt"); + + getline(file_version, line_in_str); + file_version.close(); + return_int = atoi(line_in_str.c_str()); + + return return_int; + } + catch (exception e) + { + return -1; + } + return return_int; } EXPORT_API int coreFinalize() { clipboard.bdragOff(); delete tradutor; + delete update; return 1; } diff --git a/plugin/corePlugin.h b/plugin/corePlugin.h index 5c15713..606da87 100644 --- a/plugin/corePlugin.h +++ b/plugin/corePlugin.h @@ -21,8 +21,9 @@ VLibras-Core #include "pyClip.h" #include "pyTradutor.h" -#include "checkVersion.h" -#include +#include "pyVlibrasUpdate.h" +#include +#include using namespace std; @@ -31,12 +32,13 @@ extern "C" { //Usado para traduzir português para glosa PyTradutor *tradutor; - int check; + + //Usado para copiar texto da área de transferência PyClip clipboard; //Usado para verificar se existe atualização - CheckVersion *checkversion; + PyVlibrasUpdate *update; //Inicializa Objetos EXPORT_API int coreInitize(void); diff --git a/plugin/testPlugin.cpp b/plugin/testPlugin.cpp index 834ba48..e3a70cd 100644 --- a/plugin/testPlugin.cpp +++ b/plugin/testPlugin.cpp @@ -13,7 +13,14 @@ metodo2 execute; typedef int (WINAPI*metodo3)(); metodo3 finalize; typedef int (WINAPI*metodo4)(); -metodo4 update; +metodo4 coreUpdateCheck; + +typedef int (WINAPI*metodo5)(); +metodo5 coreUpdateInstall_player; + +typedef int (WINAPI*metodo6)(); +metodo6 coreUpdateInstall_dict; + int main(int argc, char *argv[]) { @@ -29,26 +36,26 @@ int main(int argc, char *argv[]) initialize=(metodo1)GetProcAddress((HMODULE)hDLL, "coreInitialize"); execute=(metodo2)GetProcAddress((HMODULE)hDLL, "coreExecute"); finalize=(metodo3)GetProcAddress((HMODULE)hDLL, "coreFinalize"); - update=(metodo4)GetProcAddress((HMODULE)hDLL, "coreUpdate"); + coreUpdateCheck=(metodo4)GetProcAddress((HMODULE)hDLL, "coreUpdateCheck"); + coreUpdateInstall_player=(metodo5)GetProcAddress((HMODULE)hDLL, "coreUpdateInstall_player"); + coreUpdateInstall_dict=(metodo6)GetProcAddress((HMODULE)hDLL, "coreUpdateInstall_dict"); //Executa coreInitialize int init = initialize(); cout <<"return initialize: " << init < -#include "util.h" - - - -Util::Util(){ - //downloading = true; - //downloading = down; -} - -string Util::clrStringTostring(String^ strIn) -{ - - char cStr[256]; - - - sprintf(cStr, "%s", strIn); - string stlString(cStr); - - return stlString; -} - - - -bool Util::checkNet() -{ - - try - { - - WebRequest^ request = WebRequest::Create( "http://vlibras.lavid.ufpb.br" ); - - // If required by the server, set the credentials. - //request->Credentials = CredentialCache::DefaultCredentials; - - // Get the response. - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - - if (response->StatusDescription == "OK"){ - - return true; - } - return false; - response->Close(); - } - catch ( WebException^ e ) - { - return false; - } - -} - - -vector Util::checkVersion(bool atualize) -{ - XmlDocument^ xmlDoc; - XmlNodeList^ files; - XmlDocument^ xmlDocLocal; - XmlNodeList^ filesLocal; - vector updates; - vector localversion = localVersion(); - try - { - xmlDoc = (gcnew XmlDocument()); - xmlDocLocal = (gcnew XmlDocument()); - - - string url = "http://vlibras.lavid.ufpb.br/api/dicionario/"+localversion[3]+"?type=windows"; - WebRequest^ request = WebRequest::Create( gcnew String(url.c_str())); - // If required by the server, set the credentials. - request->Credentials = CredentialCache::DefaultCredentials; - // Get the response. - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - if (!(response->StatusDescription == "OK")) - goto erro; - // Get the stream containing content returned by the server. - Stream^ dataStream = response->GetResponseStream(); - // Open the stream using a StreamReader for easy access. - StreamReader^ reader = gcnew StreamReader( dataStream ); - // Read the content. - String^ responseFromServer = reader->ReadToEnd(); - xmlDoc->LoadXml(responseFromServer); - files = xmlDoc->GetElementsByTagName("version"); - - long numitems = files->Count; - - - - //for (int i=0;i0) - { - String^ playerVersion = files[0]["playerVersion"]->InnerText; - String^ dictionaryVersion = files[0]["dictionaryVersion"]->InnerText; - - if(String::Compare( playerVersion, gcnew String(localversion[1].c_str()))) - { - updates.push_back("playerVersion"); - updates.push_back(clrStringTostring(playerVersion)); - updates.push_back(clrStringTostring(files[0]["playerUrl"]->InnerText)); - } - if(String::Compare(dictionaryVersion,gcnew String(localversion[3].c_str()))) - { - updates.push_back("dictionaryVersion"); - updates.push_back(clrStringTostring(dictionaryVersion)); - updates.push_back(clrStringTostring(files[0]["dictionaryUrl"]->InnerText)); - } - - //if(atualize) - //saveNewXmlVersion(playerVersion,dictionaryVersion); - - } - - erro: - // Cleanup the streams and the response. - reader->Close(); - dataStream->Close(); - }catch(Exception^ e) - { - updates.push_back("faill"); - return updates; - } - - return updates; -} - - -vector Util::localVersion() -{ - XmlDocument^ xmlDocLocal; - XmlNodeList^ filesLocal; - vector updates; - try - { - xmlDocLocal = (gcnew XmlDocument()); - //xml version local - StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); - - String^ responseLocal = readerLocal->ReadToEnd(); - - xmlDocLocal->LoadXml(responseLocal); - - filesLocal = xmlDocLocal->GetElementsByTagName("version"); - - updates.push_back("playerVersion"); - String^ playerVersion = filesLocal[0]["playerVersion"]->InnerText; - updates.push_back(clrStringTostring(playerVersion)); - updates.push_back("dictionaryVersion"); - String^ dictionaryVersion = filesLocal[0]["dictionaryVersion"]->InnerText; - updates.push_back(clrStringTostring(dictionaryVersion)); - - // Cleanup the streams and the response. - readerLocal->Close(); - }catch(Exception^ e) - { - return updates; - } - - return updates; -} - - - - - - \ No newline at end of file diff --git a/update/Makefile b/update/Makefile index 43af671..7fe9f2f 100644 --- a/update/Makefile +++ b/update/Makefile @@ -1,42 +1,26 @@ ############################## MAKEFILE VLIBRAS ############################ # # -# Bruno Santos # -# brunosantos@lavid.ufpb.br # # Ezequiel Silva # # ezequielsilva@lavid.ufpb.br # # # # ############################################################################ -# Includes -CFLAGS = -I include - -# Link com as libs utilizadas -#LFLAGS = -link C:\Python27\libs\python27.lib # Compilador Nativo CC = cl -# Nome do arquivo de saída -OUT = vlibras-up - -# Arquivos de implementação -FILES = src\util.cpp src\janelaAtualizacao.cpp +OUTDICT = vlibrasPlayerDictUp -#Headers -INCLUDES = include\util.h include\janelaAtualizacao.h -CLEAN_OBJ = del -q *.obj +CLEAN_OBJ = del -q *.obj -HOME = %homepath% -#Gera executável testLibras -all: $(FILES) $(INCLUDES) - $(CC) -Fe$(OUT) -clr vlibrasUpdate.cpp $(FILES) $(CFLAGS) +#Gera executável +all: + $(CC) -Fe$(OUTDICT) -EHsc vlibrasDictPlayerInstall.cpp $(CLEAN_OBJ) - - #Limpa arquivos objetos e executáveis criados clean: del -q *.exe *.obj diff --git a/update/include/checkVersion.h b/update/include/checkVersion.h deleted file mode 100644 index 2bdd393..0000000 --- a/update/include/checkVersion.h +++ /dev/null @@ -1,53 +0,0 @@ -//***************************************************************** -/* -VLibras: Verificação de atualização - - -Ezequiel Silva -ezequielsilva@lavid.ufpb.br -VLibras-Core -2015 -*/ -//***************************************************************** - -/** -* \file checkVersion.h -* \Ezequiel Silva -* \date Outubro 2015 -*/ - - - -#include -#include -#include -#include -#include - -#pragma comment(lib, "urlmon.lib") -using namespace std; - - class CheckVersion -{ - -private: - void checkLocal(); - void checkApi(); - void reset(); -public: - long playerVersion = -1; - long dictVersion = -1; - long localPlayerVersion = -1; - long localDictVersion = -1; - string playerVersionFull = ""; - string dictVersionFull = ""; - string playerUrl = ""; - string dictUrl = ""; - string dictCallVersion ="0.0.0_0.0.0"; - int vstatus = -1; - - CheckVersion(); - void checkRefresh(); - - -}; \ No newline at end of file diff --git a/update/include/janelaAtualizacao.h b/update/include/janelaAtualizacao.h deleted file mode 100644 index 309bd4f..0000000 --- a/update/include/janelaAtualizacao.h +++ /dev/null @@ -1,66 +0,0 @@ -//***************************************************************** -/* -VLibras: Atualização - - -Ezequiel Silva -ezequielsilva@lavid.ufpb.br -VLibras-Core -2015 -*/ -//***************************************************************** - -/** -* \file checkVersion.h -* \Ezequiel Silva -* \date Outubro 2015 -*/ - -// ############### NÃO USADO ################### - - - -#include - -#using -#using -#using - - -using namespace System::Windows::Forms; -using namespace System; -using namespace System::Drawing; -using namespace System::ComponentModel; -using namespace std; - -public ref class JanelaAtualizacao : public Form -{ - private: - - bool downloading; - RichTextBox^ richTextBox1; - Label^ lbInformacao; - Label^ topo; - int vez=0; - Bitmap^ animatedImage; - String^ informacao; - void btOKevent(Object^ sender, EventArgs^ e); - void XFormClosing(Object^ sender, FormClosingEventArgs^ e); - - public: - static ProgressBar^ progressBar1; - static Label^ lbInfDownload; - Button^ btOK; - JanelaAtualizacao(); - - void initializeComponent(); - void setInfoWhite(String^ info); - void setInfoGreen(String^ info); - void setInfoRed(String^ info); - void start(); - void EnableButton(); - - - -}; - diff --git a/update/include/pyVlibrasUpdate.h b/update/include/pyVlibrasUpdate.h new file mode 100644 index 0000000..69465aa --- /dev/null +++ b/update/include/pyVlibrasUpdate.h @@ -0,0 +1,31 @@ +//***************************************************************** +/* + +Copyright (c) 2015 Ezequiel Silva +VLibras-Core group at LAViD, Federal University of Paraiba +*/ +//***************************************************************** + +/** +* \file pyVlibrasUpdate.h +* \authors Ezequiel Silva +* \date Setembro 2015 +*/ +#ifndef _PHVLIBRASUPDATE_H +#define _PHVLIBRASUPDATE_H + +#include + +/** \brief Classe para execução do Vlibras Update. +* +*/ +class PyVlibrasUpdate +{ + + public: + int install(char* strFunct, char* strstrParams); + void checkExe(char* strFunct, char* strstrParams); + +}; + +#endif \ No newline at end of file diff --git a/update/include/util.h b/update/include/util.h deleted file mode 100644 index df1917f..0000000 --- a/update/include/util.h +++ /dev/null @@ -1,51 +0,0 @@ -#using -#using -#using - -#include -#include -#include - - -using namespace std; -using namespace System; -using namespace System::ComponentModel; -using namespace System::Net; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Threading; -using namespace System::IO::Compression; - - - - - - - - public ref class Util { - - private: - static string clrStringTostring(String^ strIn); - static vector localVersion(void); - - public: - static bool down; - static WebClient^ myWebClient; - - Util(); - - bool downloading; - static bool saveNewXmlVersion(string playerVersion,string dictionaryVersion); - static string Download(DownloadProgressChangedEventHandler^ dpch ,string url, string fileName); - static bool checkNet(void); - static vector checkVersion(bool atualize); - static bool extractZip(string zipFile, string outPath); - static bool backup(void); - static bool restore(void); - - }; - - - - - diff --git a/update/src/checkVersion.cpp b/update/src/checkVersion.cpp deleted file mode 100644 index 0fccd07..0000000 --- a/update/src/checkVersion.cpp +++ /dev/null @@ -1,182 +0,0 @@ - - -#include "checkVersion.h" - -using namespace std; - - - - CheckVersion::CheckVersion() - { - //reset(); - } - - void CheckVersion::checkRefresh() - { - reset(); - checkLocal(); - checkApi(); - if(!(localDictVersion == -1 || dictVersion == -1 || localPlayerVersion == -1 || playerVersion == -1)) - { - vstatus = 0; - if(localDictVersion < dictVersion && localPlayerVersion < playerVersion) - vstatus=1; - else if(localPlayerVersion < playerVersion) - vstatus = 1; - else if(localDictVersion < dictVersion) - vstatus = 2; - } - else - vstatus = -1; - - } - - - - -void find_and_replace(string& source, string const& find, string const& replace) -{ - for(string::size_type i = 0; (i = source.find(find, i)) != string::npos;) - { - source.replace(i, find.length(), replace); - i += replace.length(); - } -} - - -void CheckVersion::checkLocal() -{ - - int result = 0; - string line; - ifstream myfile ("c:\\vlibras-libs\\update\\updateVersion.xml"); - - if (myfile.is_open()) - { - while ( getline(myfile,line) ) - { - if(strstr(line.c_str(),"")) - { - string version; - int ia = line.find("")+19; - int ib = line.find("")-23; - version = line.substr(ia,ib); - dictCallVersion = version; - find_and_replace(version,".",""); - find_and_replace(version,"_",""); - find_and_replace(version," ",""); - localDictVersion = atoi(version.c_str()); - } - else if(strstr(line.c_str(),"")) - { - string version; - int ia = line.find("")+15; - int ib = line.find("")-19; - version = line.substr(ia,ib); - find_and_replace(version,".",""); - find_and_replace(version,"_",""); - find_and_replace(version," ",""); - localPlayerVersion = atoi(version.c_str()); - } - - } - - myfile.close(); - - } - - - } - -void CheckVersion::checkApi() -{ - -cout << "dictCallVersion ====> " << dictCallVersion<< endl; -string url = "http://vlibras.lavid.ufpb.br/api/dicionario/"; -url.append(dictCallVersion); -url.append("?type=windows"); - HRESULT hr = URLDownloadToFile ( NULL, _T(url.c_str()), _T("c:\\vlibras-libs\\update\\netVersion.xml"), 0, NULL ); - if(SUCCEEDED(hr)){ - - string line; - ifstream myfile ("c:\\vlibras-libs\\update\\netVersion.xml"); - if (myfile.is_open()) - { - while ( getline(myfile,line) ) - { - if(strstr(line.c_str(),"")) - { - string version; - int ia = line.find("")+19; - int ib = line.find("")-23; - version = line.substr(ia,ib); - dictVersionFull = version; - find_and_replace(version,".",""); - find_and_replace(version,"_",""); - find_and_replace(version," ",""); - dictVersion = atoi(version.c_str()); - } - else if(strstr(line.c_str(),"")) - { - string version; - int ia = line.find("")+15; - int ib = line.find("")-19; - version = line.substr(ia,ib); - playerVersionFull = version; - find_and_replace(version,".",""); - find_and_replace(version,"_",""); - find_and_replace(version," ",""); - playerVersion = atoi(version.c_str()); - - } - else if(strstr(line.c_str(),"")) - { - string version; - int ia = line.find("")+11; - int ib = line.find("")-15; - version = line.substr(ia,ib); - playerUrl = version; - } - else if(strstr(line.c_str(),"")) - { - string version; - int ia = line.find("")+15; - int ib = line.find("")-19; - version = line.substr(ia,ib); - dictUrl = version; - } - } - myfile.close(); - } - - - } - -} - - -void CheckVersion::reset() - { - playerVersion = -1; - dictVersion = -1; - localPlayerVersion = -1; - localDictVersion = -1; - playerUrl = ""; - dictUrl = ""; - vstatus = -1; - } - -//return -// -1 se erro -//0 se não necessita de atualização -// 1 se tiver para player -// 2 se dicionario - - - - - - - - - diff --git a/update/src/janelaAtualizacao.cpp b/update/src/janelaAtualizacao.cpp deleted file mode 100644 index 7fa91e6..0000000 --- a/update/src/janelaAtualizacao.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "janelaAtualizacao.h" -#include "Util.h" - - -JanelaAtualizacao::JanelaAtualizacao() -{ - initializeComponent(); -} - -void JanelaAtualizacao::initializeComponent() -{ - - this->downloading = true; - this->Size = System::Drawing::Size(500, 250); - this->progressBar1 = (gcnew ProgressBar()); - this->btOK = (gcnew Button()); - this->lbInfDownload = (gcnew Label()); - this->lbInformacao = (gcnew Label()); - this->Name = "Vlibras-Desktop-Update"; - this->Text = "Atualização - Vlibras-Desktop"; - this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog; - this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; - //this->ControlBox = false; - this->MaximizeBox = false; - this->BackColor = Drawing::Color::White; - //this->MinimizeBox = false; - //this->BackgroundImage = Image::FromFile("c:\\vlibras-libs\\image\\background.png"); - //this->Opacity = 0.97; - Drawing::Icon^ IC = gcnew Drawing::Icon("c:\\vlibras-libs\\icons\\icon_vlibras.ico"); - this->Icon = IC; - this->SuspendLayout(); - //this->FormBorderStyle = ::FormBorderStyle::None; - this->FormClosing += gcnew FormClosingEventHandler(this, &JanelaAtualizacao::XFormClosing); - - // progressBar1 - // - this->progressBar1->Location = Point(7, 85); - this->progressBar1->Name = "progressBar1"; - this->progressBar1->Size = System::Drawing::Size(470, 30); - //this->progressBar1->TabIndex = 0; - this->progressBar1->Minimum = 0; - this->progressBar1->Maximum = 100; - //this->progressBar1->Style = ProgressBarStyle::Marquee; - //progressBar1->Visible = false; - //progressBar1->Enabled = false; - // - - // - this->lbInformacao->Location = Point(7, 15); - this->lbInformacao->Name = "label"; - this->lbInformacao->Size = System::Drawing::Size(470, 23); - this->lbInformacao->BackColor = Drawing::Color::Transparent; - //this->lbInformacao->ForeColor=Drawing::Color::White; - - // - this->lbInfDownload->Location = Point(7, 120); - this->lbInfDownload->Name = "labelDownload"; - this->lbInfDownload->Size = System::Drawing::Size(470, 23); - this->lbInfDownload->BackColor = Drawing::Color::Transparent; - //this->lbInfDownload->Font = gcnew System::Drawing::Font("Arial", 12); - //this->lbInfDownload->ForeColor=Drawing::Color::White; - - - // btOK - // - - this->btOK->Location = Point(390, this->Bottom-80); - this->btOK->Name = "btOK"; - this->btOK->Size = System::Drawing::Size(80, 30); - this->btOK->TabIndex = 1; - this->btOK->Text = "OK"; - this->btOK->UseVisualStyleBackColor = true; - this->btOK->Click += gcnew EventHandler(this, &JanelaAtualizacao::btOKevent); - //this->btOK - // - - // - //this->Controls->Add(this->topo); - this->Controls->Add(this->lbInformacao); - this->Controls->Add(this->lbInfDownload); - this->Controls->Add(this->progressBar1); - this->Controls->Add(this->btOK); - this->btOK->Enabled = false; - //this->Controls->Add(this->richTextBox1); - - //this->ResumeLayout(false); - -} - -void JanelaAtualizacao::setInfoWhite(String^ info) -{ - this->lbInformacao->Location = Point(7, 20); - this->lbInformacao->Font = gcnew System::Drawing::Font("Serif", 12); - this->lbInformacao->Text = info; - //this->lbInformacao->ForeColor=Drawing::Color::White; - this->lbInformacao->TextAlign = ContentAlignment::MiddleCenter; - -} - -void JanelaAtualizacao::setInfoGreen(String^ info) -{ - this->lbInformacao->Location = Point(7, 75); - this->lbInformacao->Font = gcnew System::Drawing::Font("Arial", 15); - this->lbInformacao->Text = info; - this->lbInformacao->ForeColor=Drawing::Color::Green; - this->lbInformacao->TextAlign = ContentAlignment::MiddleCenter; - -} -void JanelaAtualizacao::setInfoRed(String^ info) -{ - this->lbInformacao->Location = Point(7, 75); - this->lbInformacao->Font = gcnew System::Drawing::Font("Arial", 15); - this->lbInformacao->Text = info; - this->lbInformacao->ForeColor=Drawing::Color::Red; - this->lbInformacao->TextAlign = ContentAlignment::MiddleCenter; - -} - - - - -void JanelaAtualizacao::btOKevent(Object^ sender, EventArgs^ e) -{ - - this->Close(); - -} - - - -void JanelaAtualizacao::start() -{ - -} - - -void JanelaAtualizacao::EnableButton() -{ - btOK->Enabled = true; -} - - -void JanelaAtualizacao::XFormClosing(Object^ sender, FormClosingEventArgs^ e) -{ - -} - - - - - \ No newline at end of file diff --git a/update/src/pyVlibrasUpdate.cpp b/update/src/pyVlibrasUpdate.cpp new file mode 100644 index 0000000..3c2bb6a --- /dev/null +++ b/update/src/pyVlibrasUpdate.cpp @@ -0,0 +1,103 @@ + +/** +* \file pyVlibrasUpdate.cpp +* \authors Ezequiel Silva +* \date outubro 2015 +*/ + +#include "pyVlibrasUpdate.h" + + +void PyVlibrasUpdate::checkExe(char* strFunct, char* strstrParams) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + ULONG rc; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, strFunct); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, strstrParams); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) + { + return -1; + } + + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) + rc = 0; + + CloseHandle(ProcessInfo.hThread); + CloseHandle(ProcessInfo.hProcess); + + +} + +int PyVlibrasUpdate::install(char* strFunct, char* strstrParams) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, strFunct); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, strstrParams); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE,CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) + { + return -1; + } + + return -1; + +} + diff --git a/update/src/util.cpp b/update/src/util.cpp deleted file mode 100644 index a879f53..0000000 --- a/update/src/util.cpp +++ /dev/null @@ -1,286 +0,0 @@ -#include -#include "util.h" - - - -Util::Util(){ - //downloading = true; - //downloading = down; -} - -string Util::clrStringTostring(String^ strIn) -{ - - char cStr[256]; - - - sprintf(cStr, "%s", strIn); - string stlString(cStr); - - return stlString; -} - - void DownloadProgressCallback(Object^ sender, - DownloadProgressChangedEventArgs^ e) - { - // Displays the operation identifier, and the transfer progress. - Console::WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...", - (String ^)e->UserState, - e->BytesReceived, - e->TotalBytesToReceive, - e->ProgressPercentage); - } - - void DownloadFileCallBack2(Object^ sender, AsyncCompletedEventArgs^ args) - { - cout<<"Terminou de baixar"<< endl; - - } - - -bool Util::checkNet() -{ - - try - { - - WebRequest^ request = WebRequest::Create( "http://vlibras.lavid.ufpb.br" ); - - // If required by the server, set the credentials. - //request->Credentials = CredentialCache::DefaultCredentials; - - // Get the response. - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - - if (response->StatusDescription == "OK"){ - - return true; - } - return false; - response->Close(); - } - catch ( WebException^ e ) - { - return false; - } - -} - - -vector Util::checkVersion(bool atualize) -{ - XmlDocument^ xmlDoc; - XmlNodeList^ files; - XmlDocument^ xmlDocLocal; - XmlNodeList^ filesLocal; - vector updates; - vector localversion = localVersion(); - try - { - xmlDoc = (gcnew XmlDocument()); - xmlDocLocal = (gcnew XmlDocument()); - - - string url = "http://vlibras.lavid.ufpb.br/api/dicionario/"+localversion[3]+"?type=windows"; - WebRequest^ request = WebRequest::Create( gcnew String(url.c_str())); - // If required by the server, set the credentials. - request->Credentials = CredentialCache::DefaultCredentials; - // Get the response. - HttpWebResponse^ response = dynamic_cast(request->GetResponse()); - if (!(response->StatusDescription == "OK")) - goto erro; - // Get the stream containing content returned by the server. - Stream^ dataStream = response->GetResponseStream(); - // Open the stream using a StreamReader for easy access. - StreamReader^ reader = gcnew StreamReader( dataStream ); - // Read the content. - String^ responseFromServer = reader->ReadToEnd(); - xmlDoc->LoadXml(responseFromServer); - files = xmlDoc->GetElementsByTagName("version"); - - long numitems = files->Count; - - - - //for (int i=0;i0) - { - String^ playerVersion = files[0]["playerVersion"]->InnerText; - String^ dictionaryVersion = files[0]["dictionaryVersion"]->InnerText; - - if(String::Compare( playerVersion, gcnew String(localversion[1].c_str()))) - { - updates.push_back("playerVersion"); - updates.push_back(clrStringTostring(playerVersion)); - updates.push_back(clrStringTostring(files[0]["playerUrl"]->InnerText)); - } - if(String::Compare(dictionaryVersion,gcnew String(localversion[3].c_str()))) - { - updates.push_back("dictionaryVersion"); - updates.push_back(clrStringTostring(dictionaryVersion)); - updates.push_back(clrStringTostring(files[0]["dictionaryUrl"]->InnerText)); - } - - //if(atualize) - //saveNewXmlVersion(playerVersion,dictionaryVersion); - - } - - erro: - // Cleanup the streams and the response. - reader->Close(); - dataStream->Close(); - }catch(Exception^ e) - { - return updates; - } - - return updates; -} - - -vector Util::localVersion() -{ - XmlDocument^ xmlDocLocal; - XmlNodeList^ filesLocal; - vector updates; - try - { - xmlDocLocal = (gcnew XmlDocument()); - //xml version local - StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); - - String^ responseLocal = readerLocal->ReadToEnd(); - - xmlDocLocal->LoadXml(responseLocal); - - filesLocal = xmlDocLocal->GetElementsByTagName("version"); - - updates.push_back("playerVersion"); - String^ playerVersion = filesLocal[0]["playerVersion"]->InnerText; - updates.push_back(clrStringTostring(playerVersion)); - updates.push_back("dictionaryVersion"); - String^ dictionaryVersion = filesLocal[0]["dictionaryVersion"]->InnerText; - updates.push_back(clrStringTostring(dictionaryVersion)); - - // Cleanup the streams and the response. - readerLocal->Close(); - }catch(Exception^ e) - { - return updates; - } - - return updates; -} - - -string Util::Download(DownloadProgressChangedEventHandler^ dpch ,string url, string fileName) -{ - try - { - myWebClient = gcnew WebClient(); - Uri^ uri = gcnew Uri(gcnew String(url.c_str())); - myWebClient->DownloadProgressChanged += dpch; - myWebClient->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( DownloadFileCallBack2 ); - String^ outPath = gcnew String(("c:\\vlibras-libs\\update\\"+fileName).c_str()); - myWebClient->DownloadFileAsync(uri, outPath); - }catch (Exception^ e) - { - return "FALHA"; - } - - return "OK"; - } - - - - bool Util::saveNewXmlVersion(string playerVersion,string dictionaryVersion) - { - - XmlDocument^ xmlDocLocal; - XmlNodeList^ filesLocal; - vector updates; - try - { - xmlDocLocal = (gcnew XmlDocument()); - //xml version local - StreamReader^ readerLocal = gcnew StreamReader("c:\\vlibras-libs\\update\\updateVersion.xml"); - - String^ responseLocal = readerLocal->ReadToEnd(); - - xmlDocLocal->LoadXml(responseLocal); - - filesLocal = xmlDocLocal->GetElementsByTagName("version"); - - if(!playerVersion.empty()) - filesLocal[0]["playerVersion"]->InnerText = gcnew String(playerVersion.c_str()); - - if(!dictionaryVersion.empty()) - filesLocal[0]["dictionaryVersion"]->InnerText = gcnew String(dictionaryVersion.c_str()); - - - // Cleanup the streams and the response. - readerLocal->Close(); - - xmlDocLocal->Save("c:\\vlibras-libs\\update\\updateVersion.xml"); - }catch(Exception^ e) - { - - } - - return true; - } - - - bool Util::extractZip(string zipFile, string outPath) - { - try - { - String^ zipPath = gcnew String(zipFile.c_str()); - String^ extractPath = gcnew String(outPath.c_str()); - ZipFile::ExtractToDirectory(zipPath, extractPath); - - }catch(Exception^ e) - { - return false; - } - - return true; - } - -bool Util::backup() -{ - CHAR nome_atual[] = "c:\\vlibras-libs"; - // novo nome do diretório - CHAR nome_novo[] = "c:\\vlibras-libs-BK"; - - // renomear o diretório - if(MoveFile(nome_atual, nome_novo)){ - - } - else{ - return false; - } - return true; -} -bool Util::restore() -{ - CHAR nome_atual[] = "c:\\vlibras-libs-BK"; - // novo nome do diretório - CHAR nome_novo[] = "c:\\vlibras-libs"; - - // renomear o diretório - if(MoveFile(nome_atual, nome_novo)){ - return true; - } - else{ - return false; - //GetLastError() << endl; - } - return true; -} - - - - - \ No newline at end of file diff --git a/update/update-icon.ico b/update/update-icon.ico deleted file mode 100644 index 5dbdea4..0000000 Binary files a/update/update-icon.ico and /dev/null differ diff --git a/update/updatePython/DownloadFile.py b/update/updatePython/DownloadFile.py new file mode 100644 index 0000000..55de15a --- /dev/null +++ b/update/updatePython/DownloadFile.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import wx +from urllib2 import URLError +from urllib2 import HTTPError +import urllib2,os +import random +import time +from wx.lib.pubsub import pub +from threading import Thread + + + +class DownloadFile(): + + def __init__(self,url,nameFile): + self.url = url + self.nameFile = nameFile + self.downloading = True + + def start(self): + + file_name = self.nameFile + try: + u = urllib2.urlopen(self.url) + f = open(file_name, 'wb') + meta = u.info() + file_size = int(meta.getheaders("Content-Length")[0]) + + except: + + return False + + block_sz = 8192 + while self.downloading: + buffer = u.read(block_sz) + if not buffer: + self.downloading = False + f.write(buffer) + + return True + + + +class DownloadFile2(Thread): + + def __init__(self,url,nameFile): + self.url = url + self.nameFile = nameFile + self.downloading = True + Thread.__init__(self) + + + def stop(self): + self.downloading = False + + + def run(self): + + file_name = self.nameFile + try: + u = urllib2.urlopen(self.url) + f = open(file_name, 'wb') + meta = u.info() + file_size = int(meta.getheaders("Content-Length")[0]) + + except : + wx.CallAfter(pub.sendMessage, "erroDeConexao", msg="Falha na conexao") + self.downloading = False; + return False + + + file_size_dl = 0 + block_sz = 8192 + while self.downloading: + buffer = u.read(block_sz) + if not buffer: + break + + file_size_dl += len(buffer) + f.write(buffer) + status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size) + status = status + chr(8)*(len(status)+1) + + wx.CallAfter(pub.sendMessage, "updateProgress", msg=(file_size_dl * 100. / file_size)) + if (file_size_dl * 100. / file_size) >=100: + wx.CallAfter(pub.sendMessage, "downloadSucess", msg="Download realizado") diff --git a/update/updatePython/VlibrasCheckVersion.py b/update/updatePython/VlibrasCheckVersion.py new file mode 100644 index 0000000..57a6d35 --- /dev/null +++ b/update/updatePython/VlibrasCheckVersion.py @@ -0,0 +1,87 @@ +# -*- coding: cp1252 -*- +import json, zipfile, subprocess,urllib +from os import popen +import sys + +PATH_RESOURCE = 'c:/vlibras-libs/update/' +TXT_LOCAL_VERSION = PATH_RESOURCE+'version/version.txt' +JSON_LOCAL_NAME = PATH_RESOURCE+'version/version.json' +JSON_API_NAME = PATH_RESOURCE+'download/versionApi.json' +URL_REQUEST_API = 'http://150.165.205.94:8000/versionApi.json' + + + + +def check(): + + try: + + with open(JSON_LOCAL_NAME) as data_file: + json_data = json.load(data_file) + + my_dict_version_full = json_data['dictionaryVersion'].encode('utf-8') + my_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") + my_dict_version = my_dict_version_full.replace(".", "").replace("_", "") + + if(not downladFileApi(URL_REQUEST_API)): + return 'erro' + + with open(JSON_API_NAME) as data: + json_data = json.load(data) + + api_dict_version = json_data['dictionaryVersion'].encode('utf-8').replace(".", "").replace("_", "") + api_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") + url_download_player = json_data['playerUrl'].encode('utf-8') + url_download_dict = json_data['dictionaryUrl'].encode('utf-8') + + + if int(api_player_version) > int(my_player_version): + return url_download_player + + elif int(api_dict_version) > int(my_dict_version): + + return url_download_dict + + else: + return 'atualizado' + + except Exception, e: + print e + return 'erro' + + +def downladFileApi(_url): + try: + + urllib.urlretrieve (_url, JSON_API_NAME) + + return True + except Exception, e: + print e + return False + + + + +if __name__ == '__main__': + txt_local_version = open(TXT_LOCAL_VERSION, 'w') + result = check() + if result.endswith('.exe'): + txt_local_version.write('1') + elif result.endswith('.zip'): + txt_local_version.write('2') + elif (result == 'atualizado'): + txt_local_version.write('0') + else: + txt_local_version.write('-1') + + txt_local_version.close() + print result + + + + + + + + diff --git a/update/updatePython/VlibrasUpdate.py b/update/updatePython/VlibrasUpdate.py new file mode 100644 index 0000000..c735bdf --- /dev/null +++ b/update/updatePython/VlibrasUpdate.py @@ -0,0 +1,109 @@ +# -*- coding: cp1252 -*- +import json, zipfile, subprocess,urllib +from os import popen +from threading import Thread +from VlibrasUpdateInstall import* + +url_download_player ='' +url_download_dict ='' +PATH_RESOURCE = 'C:/vlibras-libs/update/' +JSON_LOCAL_NAME = 'version/version.json' +JSON_API_NAME = 'download/versionApi.json' +PLAYER_DICT_UPDATE_PATH = PATH_RESOURCE+'bin/vlibrasPlayerDictUp.exe ' +DICTIONARY_NAME = 'download/vlibras_dicionario.zip' +INSTALL_PLAYER_NAME = 'download/Vlibras_Up.exe' +URL_REQUEST_API = 'http://vlibras.lavid.ufpb.br/api/dicionario/' +DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles' + + + + + + +def checkVersion(): + +## try: +## +## with open(PATH_RESOURCE+JSON_LOCAL_NAME) as data_file: +## json_data = json.load(data_file) +## +## my_dict_version_full = json_data['dictionaryVersion'].encode('utf-8') +## my_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") +## my_dict_version = my_dict_version_full.replace(".", "").replace("_", "") +## +## if(not downladFileApi(URL_REQUEST_API+my_dict_version_full+'?type=linux')): +## return 'erro' +## +## with open(PATH_RESOURCE+JSON_API_NAME) as data: +## json_data = json.load(data) +## +## api_dict_version = json_data['dictionaryVersion'].encode('utf-8').replace(".", "").replace("_", "") +## api_player_version = json_data['playerVersion'].encode('utf-8').replace(".", "") +## url_download_player = json_data['playerUrl'].encode('utf-8') +## url_download_dict = json_data['dictionaryUrl'].encode('utf-8') +## +## +## if int(api_player_version) > int(my_player_version): +## return url_download_player +## +## elif int(api_dict_version) > int(my_dict_version): +## +## return url_download_dict +## +## else: +## return "atualizado" +## +## except: + + return "erro" + + +def downladFileApi(_url): + try: + + urllib.urlretrieve (_url, PATH_RESOURCE+JSON_API_NAME) + + return True + except: + return False + +def installPlayer(): + try: +## with open(PATH_RESOURCE+JSON_API_NAME) as data: +## json_data = json.load(data) + +## url_download_player = json_data['playerUrl'].encode('utf-8') + # install = CallInstall() + # install.start() + process = subprocess.Popen(["C:\\Python27\\python.exe", "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"]) +## update_json_file() + except Exception, e: + print e + return -1 + return 1 + +def installDict(): + try: +## install = CallInstall() +## install.start() + + process = subprocess.Popen(["C:\\Python27\\python.exe", "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"]) +## with open(PATH_RESOURCE+JSON_API_NAME) as data: +## json_data = json.load(data) +## url_download_dict = json_data['dictionaryUrl'].encode('utf-8') +## process = subprocess.Popen(PLAYER_DICT_UPDATE_PATH+url_download_dict) + except Exception, e: + print e + return -1 + return 1 + + +if __name__ == '__main__': + print installPlayer() + + + + + + + diff --git a/update/updatePython/VlibrasUpdateInstall.py b/update/updatePython/VlibrasUpdateInstall.py new file mode 100644 index 0000000..e794e6e --- /dev/null +++ b/update/updatePython/VlibrasUpdateInstall.py @@ -0,0 +1,212 @@ + +# -*- coding: utf-8 -*- + +import wx +import subprocess +import time +from wx.lib.pubsub import pub +from DownloadFile import * +from VlibrasCheckVersion import * +import zipfile + + + +PATH_RESOURCE = 'C:/vlibras-libs/update/' +DICTIONARY_NAME = 'download/vlibras_dicionario.zip' +INSTALL_PLAYER_NAME = 'download/Vlibras_Up.exe' +DICTIONARY_EXTRACT_PATH = 'C:/vlibras-libs/Player/VLibrasPlayer_Data/Bundles' + +class UpdateView(wx.Frame): + + def __init__(self,_downloadFile,_serv_type): + + self.serv_type = _serv_type + self.downloadFile = _downloadFile + style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX + wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(480,250)) + # Define o ícone para a janela + self.SetIcon(wx.Icon("c:/vlibras-libs/icons/icon_vlibras.ico", wx.BITMAP_TYPE_ICO)) + self.myPanel = wx.Panel(self, -1) + self.myPanel.SetBackgroundColour('#F5F5F5') +## btnOk = wx.Button(self.myPanel, label="OK",pos=(365, 180), size=(80, 25)) + btnCancel = wx.Button(self.myPanel, label="Cancelar",pos=(365, 180), size=(80, 25)) + self.myText = wx.StaticText(self.myPanel, -1, pos=(5,105)) + #self.myText.SetBackgroundColour('#123456') + self.myText.SetForegroundColour('#000000') + self.progress = wx.Gauge(self.myPanel, range=100,pos=(5,80),size=(463,25)) + self.Center() + + # Anexa um evento ao botão +## self.Bind(wx.EVT_BUTTON, self.onBtnOkClick, btnOk) + self.Bind(wx.EVT_BUTTON, self.onBtnCancelClick, btnCancel) + self.__close_callback = None + self.Bind(wx.EVT_CLOSE, self._when_closed) + + #registra listeners na classe DownloadFile + pub.subscribe(self.downloadSucess, "downloadSucess") + pub.subscribe(self.erroDeConexao, "erroDeConexao") + pub.subscribe(self.updateProgress, "updateProgress") + self.percentDownload = 0; + + + #inicia o download do arquivo + if(self.serv_type != ''): + self.downloadFile.start() + + def erroDeConexao(self, msg): + wx.MessageBox('Ocorreu um erro ao tentar fazer atualização. \n Por favor tente mais tarde.', 'Informação',wx.OK | wx.ICON_INFORMATION) + self.Destroy() + + def register_close_callback(self, callback): + self.__close_callback = callback + + def _when_closed(self, event): + self.OnCloseFrame(event); +## event.Skip() + + +## def onBtnOkClick(self, event): +## self.downloadFile.start() + + def onBtnCancelClick(self, event): + self.OnCloseFrame(event); + + + def downloadSucess(self, msg): + self.percentDownload = 100.0 + time.sleep( 2 ) + if (self.serv_type == 'dict'): + with zipfile.ZipFile(PATH_RESOURCE+DICTIONARY_NAME, "r") as z: + z.extractall(DICTIONARY_EXTRACT_PATH) + self.update_json_file() + self.ShowMessage('Vlibras Atualizado com sucesso!') + + else: + self.Hide() + process = subprocess.call(PATH_RESOURCE+INSTALL_PLAYER_NAME+' /SILENT /SUPPRESSMSGBOXES /NORESTART') + self.update_json_file() + self.ShowMessage('Vlibras Atualizado com sucesso!') + self.downloadFile.stop() + self.Destroy() + + + def updateProgress(self, msg): + value = msg + val = 'Baixando' + + self.percentDownload = value + self.myText.SetLabel(val) + self.progress.SetValue(value) + + def ShowMessage(self, mesagem): + wx.MessageBox(mesagem, 'Informação', + wx.OK | wx.ICON_INFORMATION) + def ShowMessageError(self, mesagem): + wx.MessageBox(mesagem, 'Informação', + wx.OK | wx.ICON_ERROR) + self.downloadFile.stop() + self.Destroy() + + + + + + # monitora a interação do usuário no botão de fechar + def OnCloseFrame(self, event): + if(self.percentDownload>= 100): + self.downloadFile.stop() + self.Destroy() + dialog = wx.MessageDialog(self, message = "Tem certeza que deseja cancelar a atualização?", caption = "Cancelar Atualização", + style = wx.YES_NO | wx.ICON_QUESTION) + response = dialog.ShowModal() + + if (response == wx.ID_YES): + self.downloadFile.stop() + + self.Destroy() + else: + event.StopPropagation() + + + # atualiza o json local com as informações da api + def update_json_file(self): + with open(PATH_RESOURCE+JSON_API_NAME) as data: + json_data = json.load(data) + + jsonFile = open(PATH_RESOURCE+JSON_LOCAL_NAME, "w+") + jsonFile.write(json.dumps(json_data)) + jsonFile.close() + + +class ShowInfo(wx.Frame): + + def __init__(self,_mesagem): + self.mesagem = _mesagem + style = wx.SYSTEM_MENU | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX + wx.Frame.__init__(self, None, title='Atualização do VLibras', style=style,size=(480,250)) + def ShowMessage(self): + wx.MessageBox(self.mesagem, 'Informação', + wx.OK | wx.ICON_INFORMATION) + def ShowMessageError(self): + wx.MessageBox(self.mesagem, 'Informação', + wx.OK | wx.ICON_ERROR) + + + + + +def installDictionary(_url): + app = wx.App(False) + downloadFile2 = DownloadFile2(_url, PATH_RESOURCE+DICTIONARY_NAME) + frame = UpdateView(downloadFile2,'dict') + frame.register_close_callback(lambda: True) + frame.Show() + app.MainLoop() + print _url + return 'OK' + +def installPlayer(_url): + app = wx.App(False) + downloadFile2 = DownloadFile2(_url, PATH_RESOURCE+INSTALL_PLAYER_NAME) + frame = UpdateView(downloadFile2,'player') + frame.register_close_callback(lambda: True) + frame.Show() + app.MainLoop() + print _url + return 'OK' + + +if __name__ == '__main__': + app = wx.App(False) + result = check() + if result.endswith('.zip'): + installDictionary(result) + elif result.endswith('.exe'): + installPlayer(result) + elif (result == 'atualizado'): +## up.Show() + ShowInfo('O VLibras já está atualizado!').ShowMessage() + else: +## up.Show() + ShowInfo('Ocorreu um erro ao tentar atualizar o VLibras!').ShowMessageError() + +## app.MainLoop() + + + +def initInstall(): + app = wx.App(False) + result = check() + if result.endswith('.zip'): + installDictionary(result) + elif result.endswith('.exe'): + installPlayer(result) + elif (result == 'atualizado'): +## up.Show() + ShowInfo('O VLibras já está atualizado!').ShowMessage() + else: +## up.Show() + ShowInfo('Ocorreu um erro ao tentar atualizar o VLibras!').ShowMessageError() + +## app.MainLoop() + diff --git a/update/vlibrasDictPlayerInstall.cpp b/update/vlibrasDictPlayerInstall.cpp new file mode 100644 index 0000000..f023da3 --- /dev/null +++ b/update/vlibrasDictPlayerInstall.cpp @@ -0,0 +1,61 @@ + + +#include //include all the basics + //string and other mapping macros + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nShowCmd) +{ + + STARTUPINFO StartupInfo; + PROCESS_INFORMATION ProcessInfo; + char Args[4096]; + char *pEnvCMD = NULL; + char *pDefaultCMD = "CMD.EXE"; + ULONG rc; + + memset(&StartupInfo, 0, sizeof(StartupInfo)); + StartupInfo.cb = sizeof(STARTUPINFO); + StartupInfo.dwFlags = STARTF_USESHOWWINDOW; + StartupInfo.wShowWindow = SW_HIDE; + + Args[0] = 0; + + pEnvCMD = getenv("COMSPEC"); + + if(pEnvCMD){ + + strcpy(Args, pEnvCMD); + } + else{ + strcpy(Args, pDefaultCMD); + } + + // "/c" option - Do the command then terminate the command window + strcat(Args, " /c "); + //the application you would like to run from the command window + strcat(Args, "c:\\Python27\\python.exe"); + strcat(Args, " "); + //the parameters passed to the application being run from the command window. + strcat(Args, "c:\\vlibras-libs\\update\\py\\VlibrasUpdateInstall.pyc"); + + if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, + CREATE_NEW_CONSOLE, + NULL, + NULL, + &StartupInfo, + &ProcessInfo)) + { + return GetLastError(); + } + + WaitForSingleObject(ProcessInfo.hProcess, INFINITE); + if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc)) + rc = 0; + + CloseHandle(ProcessInfo.hThread); + CloseHandle(ProcessInfo.hProcess); + + return 0; +} \ No newline at end of file diff --git a/update/vlibrasUpdate.cpp b/update/vlibrasUpdate.cpp deleted file mode 100644 index a8670aa..0000000 --- a/update/vlibrasUpdate.cpp +++ /dev/null @@ -1,172 +0,0 @@ - -#include -#include "util.h" -#include "janelaAtualizacao.h" -#include - -using namespace std; -using namespace System::Threading; -using namespace System::Windows::Forms; - -void atualizarProgresbar(Object^ sender, DownloadProgressChangedEventArgs^ e){ - - JanelaAtualizacao::progressBar1->Value= e->ProgressPercentage; - int kbr = e->BytesReceived/1024; - int kbtotal = e->TotalBytesToReceive/1024; - JanelaAtualizacao::lbInfDownload->Text = gcnew String(kbr+" kb ("+kbr/1024+" MB) Baixado de "+kbtotal+" kb ("+kbtotal/1024+" MB) | "+ e->ProgressPercentage+"%"); - - -} - - -public ref class UpdateBack -{ - JanelaAtualizacao^ j; - bool isSilence; - String^ playerVersion; - String^ dictionaryVersion; - -public: - UpdateBack(JanelaAtualizacao^ jan,bool __isSilence) - { - j = jan; - isSilence = __isSilence; - } - void start() - { - j->setInfoWhite("Estabelecendo conexão com o servidor..."); - //JanelaAtualizacao::progressBar1->Style = ProgressBarStyle::Marquee; - - - if(Util::checkNet()) - { - j->setInfoWhite("Verificando versão..."); - - vector versions = Util::checkVersion(true); - if(versions.size()>2) - { - - switch (versions.size()) - { - case 3: - if(versions[0]=="playerVersion") - { - installPlayer(versions[2],versions[1]); - } - else if(versions[0]=="dictionaryVersion") - { - installDicionario(versions[2],versions[1]); - - } - break; - case 6: - // if(versions[3]=="dictionaryVersion") - // { - // installDicionario(versions[5],versions[4]); - // //Util::extractZip() - // } - if(versions[0]=="playerVersion") - { - installPlayer(versions[2],versions[1]); - } - - break; - } - - } - else - { - JanelaAtualizacao::progressBar1->Visible = false; - j->setInfoGreen("Você já está com a versão mais atualizada!"); - j->EnableButton(); - } - - }else - { - JanelaAtualizacao::progressBar1->Visible = false; - j->setInfoRed("Não foi possível estabelecer conexão com o servidor!"); - - } - - if(isSilence) - j->Close(); - j->EnableButton(); - - } - - void installDicionario(string url, string version) - { - //JanelaAtualizacao::progressBar1->Style = ProgressBarStyle::Continuous; - //JanelaAtualizacao::progressBar1->Value=0; - Util::Download(gcnew DownloadProgressChangedEventHandler(atualizarProgresbar),url,"vlibrasDicionario.zip"); - j->setInfoWhite("Baixando nova versão do dicionário VLibras "); - while(JanelaAtualizacao::progressBar1->Value<100); - - j->setInfoWhite("Extraindo arquivos..."); - - //Sleep(3000); - Util::extractZip("C:\\vlibras-libs\\update\\vlibrasDicionario.zip","C:\\vlibras-libs\\Player\\VLibrasPlayer_Data\\Bundles"); - JanelaAtualizacao::progressBar1->Visible = false; - j->setInfoGreen("Atualização feita com sucesso!"); - Util::saveNewXmlVersion("",version); - j->EnableButton(); - } - - void installPlayer(string url, string version) - { - //j->EnableButton(); - //JanelaAtualizacao::progressBar1->Style = ProgressBarStyle::Continuous; - //JanelaAtualizacao::progressBar1->Value=0; - Util::Download(gcnew DownloadProgressChangedEventHandler(atualizarProgresbar),url,"vlibrasInstaller.exe"); - j->setInfoWhite("Baixando nova versão do Vlibras..."); - while(JanelaAtualizacao::progressBar1->Value<100); - - - - String^ installer = gcnew String("C:\\vlibras-libs\\update\\"); - installer+="vlibrasInstaller.exe"; - //Process::Start(installer); - System::Diagnostics::Process^ vlibrasinstall = gcnew System::Diagnostics::Process(); - vlibrasinstall->StartInfo->FileName = installer; - vlibrasinstall->StartInfo->Arguments = " /SILENT /SUPPRESSMSGBOXES /NORESTART "; - vlibrasinstall->Start(); - Util::saveNewXmlVersion(version,""); - j->Close(); - - } -}; - -[STAThread] -int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow) -{ - UpdateBack^ updateBack; - JanelaAtualizacao^ updateView = gcnew JanelaAtualizacao(); - - if(__argv[1] != NULL) - { - char* silen = "silence"; - if(*__argv[1] == *silen) - updateBack = gcnew UpdateBack(updateView,true); - else - updateBack = gcnew UpdateBack(updateView,false); - } - else - updateBack = gcnew UpdateBack(updateView,false); - - Application::EnableVisualStyles(); - - //Thread^ t2 = gcnew Thread(gcnew ThreadStart(updateView, &JanelaAtualizacao::start)); - //t2->Start(); - - Thread^ t3 = gcnew Thread(gcnew ThreadStart(updateBack, &UpdateBack::start)); - t3->Start(); - - - updateView->ShowDialog(); - t3->Abort(); - - //Application::Run(updateView); - - return 0; - } - -- libgit2 0.21.2