Refactored update checks into a separate thread, for better code reusability.

This commit is contained in:
LoRd_MuldeR 2013-11-17 21:53:28 +01:00
parent 3932df90f8
commit d5dcb9ad42
30 changed files with 1131 additions and 894 deletions

View File

@ -348,6 +348,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
<ClCompile Include="src\Registry_Decoder.cpp" />
<ClCompile Include="src\Registry_Encoder.cpp" />
<ClCompile Include="src\ShellIntegration.cpp" />
<ClCompile Include="src\Thread_CheckUpdate.cpp" />
<ClCompile Include="src\Thread_CPUObserver.cpp" />
<ClCompile Include="src\Thread_CueSplitter.cpp" />
<ClCompile Include="src\Thread_DiskObserver.cpp" />
@ -393,6 +394,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
<ClCompile Include="tmp\MOC_Registry_Decoder.cpp" />
<ClCompile Include="tmp\MOC_Registry_Encoder.cpp" />
<ClCompile Include="tmp\MOC_ShellIntegration.cpp" />
<ClCompile Include="tmp\MOC_Thread_CheckUpdate.cpp" />
<ClCompile Include="tmp\MOC_Thread_CPUObserver.cpp" />
<ClCompile Include="tmp\MOC_Thread_CueSplitter.cpp" />
<ClCompile Include="tmp\MOC_Thread_DiskObserver.cpp" />
@ -569,6 +571,17 @@ del "$(TargetDir)imageformats\q???d4.dll"
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
<ClInclude Include="src\JobObject.h" />
<CustomBuild Include="src\Thread_CheckUpdate.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">$(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
<ClInclude Include="src\Tools.h" />
<CustomBuild Include="src\Tool_WaveProperties.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)"</Command>

View File

@ -415,6 +415,12 @@
<ClCompile Include="src\Global_Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\Thread_CheckUpdate.cpp">
<Filter>Source Files\Threads</Filter>
</ClCompile>
<ClCompile Include="tmp\MOC_Thread_CheckUpdate.cpp">
<Filter>Generated Files\MOC</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Config.h">
@ -549,6 +555,9 @@
<ClInclude Include="etc\Prerequisites\strnatcmp\include\strnatcmp.h">
<Filter>Header Files\Misc\3rd Party</Filter>
</ClInclude>
<ClInclude Include="src\Thread_CheckUpdate.h">
<Filter>Header Files\Threads</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="gui\DropBox.ui">

View File

@ -3300,22 +3300,22 @@
<context>
<name>QApplication</name>
<message>
<location filename="../../src/Global_Win32.cpp" line="994"/>
<location filename="../../src/Global_Win32.cpp" line="1010"/>
<source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="936"/>
<location filename="../../src/Global_Win32.cpp" line="952"/>
<source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="941"/>
<location filename="../../src/Global_Win32.cpp" line="957"/>
<source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="953"/>
<location filename="../../src/Global_Win32.cpp" line="969"/>
<source>Executable &apos;%1&apos; requires Windows XP or later.</source>
<translation type="unfinished"></translation>
</message>
@ -3384,105 +3384,104 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="278"/>
<location filename="../../src/Dialog_Update.cpp" line="550"/>
<location filename="../../src/Dialog_Update.cpp" line="168"/>
<location filename="../../src/Dialog_Update.cpp" line="349"/>
<source>Build</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="279"/>
<location filename="../../src/Dialog_Update.cpp" line="169"/>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="387"/>
<location filename="../../src/Dialog_Update.cpp" line="278"/>
<source>Testing your internet connection, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="402"/>
<location filename="../../src/Dialog_Update.cpp" line="987"/>
<location filename="../../src/Dialog_Update.cpp" line="299"/>
<source>It appears that the computer currently is offline!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="405"/>
<location filename="../../src/Dialog_Update.cpp" line="990"/>
<location filename="../../src/Dialog_Update.cpp" line="300"/>
<location filename="../../src/Dialog_Update.cpp" line="305"/>
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="463"/>
<location filename="../../src/Dialog_Update.cpp" line="304"/>
<source>Network connectivity test has failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="466"/>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="480"/>
<location filename="../../src/Dialog_Update.cpp" line="281"/>
<source>Checking for new updates online, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="535"/>
<location filename="../../src/Dialog_Update.cpp" line="309"/>
<source>Failed to fetch update information from server!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="540"/>
<location filename="../../src/Dialog_Update.cpp" line="310"/>
<source>Sorry, the update server might be busy at this time. Plase try again later.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="552"/>
<location filename="../../src/Dialog_Update.cpp" line="348"/>
<source>More information available at:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="558"/>
<location filename="../../src/Dialog_Update.cpp" line="284"/>
<source>A new version of LameXP is available!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="560"/>
<location filename="../../src/Dialog_Update.cpp" line="275"/>
<source>Initializing, please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="285"/>
<source>We highly recommend all users to install this update as soon as possible.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="569"/>
<location filename="../../src/Dialog_Update.cpp" line="289"/>
<source>No new updates available at this time.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="571"/>
<location filename="../../src/Dialog_Update.cpp" line="290"/>
<source>Your version of LameXP is still up-to-date. Please check for updates regularly!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="580"/>
<location filename="../../src/Dialog_Update.cpp" line="294"/>
<source>Your version appears to be newer than the latest release.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="582"/>
<location filename="../../src/Dialog_Update.cpp" line="295"/>
<source>This usually indicates your are currently using a pre-release version of LameXP.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="871"/>
<location filename="../../src/Dialog_Update.cpp" line="377"/>
<source>Update is being downloaded, please be patient...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="918"/>
<location filename="../../src/Dialog_Update.cpp" line="423"/>
<source>Update ready to install. Applicaion will quit...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="926"/>
<location filename="../../src/Dialog_Update.cpp" line="431"/>
<source>Update failed. Please try again or download manually!</source>
<translation type="unfinished"></translation>
</message>

View File

@ -293,11 +293,11 @@
</message>
<message>
<source>BerliOS Developer</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<source>CodePlex</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
</context>
<context>
@ -2600,7 +2600,7 @@
</message>
<message>
<source>Executable &apos;%1&apos; requires Windows XP or later.</source>
<translation type="unfinished"></translation>
<translation>Programm &apos;%1&apos; benötigt Windows XP oder neuer.</translation>
</message>
</context>
<context>
@ -2667,10 +2667,6 @@
<source>Network connectivity test has failed!</source>
<translation>Test der Netzwerkverbindung fehlgeschlagen!</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>Bitte prüfen Sie Ihre Internetverbindung und versuchen Sie es dann noch einmal.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation>Suche online nach neuen Updates, bitte warten...</translation>
@ -2735,5 +2731,9 @@
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation>Aktivieren Sie Ihre Internetverbindung und versuchen Sie es dann noch einmal.</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation>Initialisiere, bitte warten...</translation>
</message>
</context>
</TS>

View File

@ -2670,10 +2670,6 @@
<source>Network connectivity test has failed!</source>
<translation>¡La prueba de conexión a internet ha fallado!</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>Por favor, asegúrese de que su conexión a internet funciona correctamente y vuelva a intentarlo.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation>Comprobando en busca de nuevas actualizaciones, espere por favor...</translation>
@ -2734,5 +2730,9 @@
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation>Por favor, asegurese de que tiene conexión a internet y vuelva a intentarlo.</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">Iniciando, espere por favor...</translation>
</message>
</context>
</TS>

View File

@ -2681,10 +2681,6 @@ Ouvrir le dossier récursivement...</translation>
<source>Network connectivity test has failed!</source>
<translation>Le test de connectivité réseau a échoué!</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>Assurez-vous que votre connexion internet fonctionne correctement et essayez à nouveau.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation>Vérification des nouvelles mises à jour en ligne, patientez...</translation>
@ -2745,5 +2741,9 @@ Ouvrir le dossier récursivement...</translation>
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation>Veuillez vous assurer que votre ordinateur est connecté à internet et essayez à nouveau.</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">Initialisation, patientez...</translation>
</message>
</context>
</TS>

View File

@ -2667,10 +2667,6 @@
<source>Network connectivity test has failed!</source>
<translation>Il test di connessione di rete è fallito!</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>Per favore assicurati che la tua connessione internet sia funzionante e prova ancora.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation>Ricerca di nuovi aggiornamenti in rete, attendere prego...</translation>
@ -2735,5 +2731,9 @@
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">Inizializzazione, attendere prego...</translation>
</message>
</context>
</TS>

View File

@ -2653,10 +2653,6 @@
<source>Network connectivity test has failed!</source>
<translation type="unfinished"> !</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation type="unfinished"> .</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation type="unfinished"> , ...</translation>
@ -2717,5 +2713,9 @@
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation type="unfinished"> .</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">, ...</translation>
</message>
</context>
</TS>

View File

@ -3337,22 +3337,22 @@
<context>
<name>QApplication</name>
<message>
<location filename="../../src/Global_Win32.cpp" line="994"/>
<location filename="../../src/Global_Win32.cpp" line="1010"/>
<source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
<translation type="unfinished">Plik wykonywalny &apos;%1&apos; nie działa w trybie kompatybilności z Windows.</translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="936"/>
<location filename="../../src/Global_Win32.cpp" line="952"/>
<source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
<translation type="unfinished">Plik wykonywalny &apos;%1&apos; wymaga Qt v%2, znaleziono jednak Qt v%3.</translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="941"/>
<location filename="../../src/Global_Win32.cpp" line="957"/>
<source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
<translation type="unfinished">Plik wykonywalny &quot;%1&quot; został skompilowany dla Qt &quot;%2&quot;, znaleziono &quot;%3&quot;.</translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="953"/>
<location filename="../../src/Global_Win32.cpp" line="969"/>
<source>Executable &apos;%1&apos; requires Windows XP or later.</source>
<translation type="unfinished"></translation>
</message>
@ -3421,105 +3421,104 @@
<translation type="unfinished">Zamknij</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="278"/>
<location filename="../../src/Dialog_Update.cpp" line="550"/>
<location filename="../../src/Dialog_Update.cpp" line="168"/>
<location filename="../../src/Dialog_Update.cpp" line="349"/>
<source>Build</source>
<translation type="unfinished">Build</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="279"/>
<location filename="../../src/Dialog_Update.cpp" line="169"/>
<source>Unknown</source>
<translation type="unfinished">Nieznana</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="387"/>
<location filename="../../src/Dialog_Update.cpp" line="278"/>
<source>Testing your internet connection, please wait...</source>
<translation type="unfinished">Testowanie połączenia internetowego, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="402"/>
<location filename="../../src/Dialog_Update.cpp" line="987"/>
<location filename="../../src/Dialog_Update.cpp" line="299"/>
<source>It appears that the computer currently is offline!</source>
<translation type="unfinished">LameXP wykrył brak dostępu do internetu!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="405"/>
<location filename="../../src/Dialog_Update.cpp" line="990"/>
<location filename="../../src/Dialog_Update.cpp" line="300"/>
<location filename="../../src/Dialog_Update.cpp" line="305"/>
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation type="unfinished">Upewnij się że komputer jest podłączony do internetu i spróbuj ponownie.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="463"/>
<location filename="../../src/Dialog_Update.cpp" line="304"/>
<source>Network connectivity test has failed!</source>
<translation type="unfinished">Test połączenia internetowego zakończony niepowodzeniem!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="466"/>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation type="unfinished">Upewnij się że połączenie internetowe działa prawidłowo i spróbuj ponownie.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="480"/>
<location filename="../../src/Dialog_Update.cpp" line="281"/>
<source>Checking for new updates online, please wait...</source>
<translation type="unfinished">Sprawdzanie aktualizacji online, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="535"/>
<location filename="../../src/Dialog_Update.cpp" line="309"/>
<source>Failed to fetch update information from server!</source>
<translation type="unfinished">Pobieranie informacji z serwera zakończone niepowodzeniem!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="540"/>
<location filename="../../src/Dialog_Update.cpp" line="310"/>
<source>Sorry, the update server might be busy at this time. Plase try again later.</source>
<translation type="unfinished">Serwer aktualizacji wydaje się nie odpowiadać w tej chwili. Prosze spróbować później.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="552"/>
<location filename="../../src/Dialog_Update.cpp" line="348"/>
<source>More information available at:</source>
<translation type="unfinished">Więcej informacji tutaj:</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="558"/>
<location filename="../../src/Dialog_Update.cpp" line="284"/>
<source>A new version of LameXP is available!</source>
<translation type="unfinished">Dostępna nowa wersja LameXP!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="560"/>
<location filename="../../src/Dialog_Update.cpp" line="275"/>
<source>Initializing, please wait...</source>
<translation type="unfinished">Inicjowanie, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="285"/>
<source>We highly recommend all users to install this update as soon as possible.</source>
<translation type="unfinished">Jest wysoce zalecane aby zainstalować aktualizację jak najszybciej.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="569"/>
<location filename="../../src/Dialog_Update.cpp" line="289"/>
<source>No new updates available at this time.</source>
<translation type="unfinished">Nie ma nowych aktualizacji w tej chwili.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="571"/>
<location filename="../../src/Dialog_Update.cpp" line="290"/>
<source>Your version of LameXP is still up-to-date. Please check for updates regularly!</source>
<translation type="unfinished">Posiadasz najnowszą wersję LameXP. Sprawdzaj aktualizacje regularnie!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="580"/>
<location filename="../../src/Dialog_Update.cpp" line="294"/>
<source>Your version appears to be newer than the latest release.</source>
<translation type="unfinished">Posiadasz nowszą wersję LameXP niż ostatnie wydanie.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="582"/>
<location filename="../../src/Dialog_Update.cpp" line="295"/>
<source>This usually indicates your are currently using a pre-release version of LameXP.</source>
<translation type="unfinished">To wskazuje na to, że posiadasz wersję alfa LameXP.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="871"/>
<location filename="../../src/Dialog_Update.cpp" line="377"/>
<source>Update is being downloaded, please be patient...</source>
<translation type="unfinished">Pobieranie aktualizacji w toku, prosze czekać...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="918"/>
<location filename="../../src/Dialog_Update.cpp" line="423"/>
<source>Update ready to install. Applicaion will quit...</source>
<translation type="unfinished">Aktualizacja gotowa do instalacji. Teraz program zostanie zamknięty...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="926"/>
<location filename="../../src/Dialog_Update.cpp" line="431"/>
<source>Update failed. Please try again or download manually!</source>
<translation type="unfinished">Aktualizacja zakończona niepowodzeniem. Prosze spróbować ponownie lub zainstalować ręcznie!</translation>
</message>

View File

@ -2695,10 +2695,6 @@
<source>Network connectivity test has failed!</source>
<translation type="unfinished">Нет соединения с сетью!</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation type="unfinished">Проверьте доступность интернет соединения и попробуйте снова.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation type="unfinished">Проверяю обновления, пожалуйста, подождите...</translation>
@ -2760,5 +2756,9 @@
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation type="unfinished">Пожалуйста, проверьте, что ваш компьютер подключен к интернету и попробуйте снова.</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">Инициализация, пожалуйста, подождите...</translation>
</message>
</context>
</TS>

View File

@ -3320,22 +3320,22 @@
<context>
<name>QApplication</name>
<message>
<location filename="../../src/Global_Win32.cpp" line="994"/>
<location filename="../../src/Global_Win32.cpp" line="1010"/>
<source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
<translation>EXE-filen &apos;%1&apos; stöder inte Windows kompatibilitetsläge.</translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="936"/>
<location filename="../../src/Global_Win32.cpp" line="952"/>
<source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
<translation>EXE-filen &apos;%1&apos; kräver Qt v%2, du har Qt v%3.</translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="941"/>
<location filename="../../src/Global_Win32.cpp" line="957"/>
<source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
<translation>EXE-filen &apos;%1&apos; är byggd för Qt &apos;%2&apos;, du har Qt &apos;%3&apos;.</translation>
</message>
<message>
<location filename="../../src/Global_Win32.cpp" line="953"/>
<location filename="../../src/Global_Win32.cpp" line="969"/>
<source>Executable &apos;%1&apos; requires Windows XP or later.</source>
<translation type="unfinished"></translation>
</message>
@ -3404,105 +3404,104 @@
<translation>Stäng</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="278"/>
<location filename="../../src/Dialog_Update.cpp" line="550"/>
<location filename="../../src/Dialog_Update.cpp" line="168"/>
<location filename="../../src/Dialog_Update.cpp" line="349"/>
<source>Build</source>
<translation>Build</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="279"/>
<location filename="../../src/Dialog_Update.cpp" line="169"/>
<source>Unknown</source>
<translation>Okänd</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="387"/>
<location filename="../../src/Dialog_Update.cpp" line="278"/>
<source>Testing your internet connection, please wait...</source>
<translation>Kontrollerar iInternetanslutningen, vänta...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="402"/>
<location filename="../../src/Dialog_Update.cpp" line="987"/>
<location filename="../../src/Dialog_Update.cpp" line="299"/>
<source>It appears that the computer currently is offline!</source>
<translation>Datorn verkar inte vara ansluten till Internet!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="405"/>
<location filename="../../src/Dialog_Update.cpp" line="990"/>
<location filename="../../src/Dialog_Update.cpp" line="300"/>
<location filename="../../src/Dialog_Update.cpp" line="305"/>
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation>Tillse att datorn är ansluten till Internet och försök igen.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="463"/>
<location filename="../../src/Dialog_Update.cpp" line="304"/>
<source>Network connectivity test has failed!</source>
<translation>Anslutningskontrollen misslyckades!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="466"/>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>Tillse att Internetuppkopplingen fungerar korrekt och försök igen.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="480"/>
<location filename="../../src/Dialog_Update.cpp" line="281"/>
<source>Checking for new updates online, please wait...</source>
<translation>Söker nya uppdateringar, vänta...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="535"/>
<location filename="../../src/Dialog_Update.cpp" line="309"/>
<source>Failed to fetch update information from server!</source>
<translation>Kunde inte hämta uppdateringsinformation från servern!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="540"/>
<location filename="../../src/Dialog_Update.cpp" line="310"/>
<source>Sorry, the update server might be busy at this time. Plase try again later.</source>
<translation>Uppdateringsservern kan vara upptagen. Försök senare.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="552"/>
<location filename="../../src/Dialog_Update.cpp" line="348"/>
<source>More information available at:</source>
<translation>Mer information hittas :</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="558"/>
<location filename="../../src/Dialog_Update.cpp" line="284"/>
<source>A new version of LameXP is available!</source>
<translation>En ny version av LameXP finns tillgänglig!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="560"/>
<location filename="../../src/Dialog_Update.cpp" line="275"/>
<source>Initializing, please wait...</source>
<translation type="unfinished">Initierar, vänta...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="285"/>
<source>We highly recommend all users to install this update as soon as possible.</source>
<translation>Vi rekommenderar alla användare att installera denna uppdatering snart som möjligt.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="569"/>
<location filename="../../src/Dialog_Update.cpp" line="289"/>
<source>No new updates available at this time.</source>
<translation>Det finns inga nya uppdateringar.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="571"/>
<location filename="../../src/Dialog_Update.cpp" line="290"/>
<source>Your version of LameXP is still up-to-date. Please check for updates regularly!</source>
<translation>Din version av LameXP är uppdaterad. Kontrollera regelbundet!</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="580"/>
<location filename="../../src/Dialog_Update.cpp" line="294"/>
<source>Your version appears to be newer than the latest release.</source>
<translation>Din version verkar vara nyare än senaste &apos;Release&apos;.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="582"/>
<location filename="../../src/Dialog_Update.cpp" line="295"/>
<source>This usually indicates your are currently using a pre-release version of LameXP.</source>
<translation>Det innebär normalt att du använder en beta-version av LameXP.</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="871"/>
<location filename="../../src/Dialog_Update.cpp" line="377"/>
<source>Update is being downloaded, please be patient...</source>
<translation>Uppdatering laddas ner, vänta...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="918"/>
<location filename="../../src/Dialog_Update.cpp" line="423"/>
<source>Update ready to install. Applicaion will quit...</source>
<translation>Uppdatering klar att installeras. Programmet kommer att avslutas...</translation>
</message>
<message>
<location filename="../../src/Dialog_Update.cpp" line="926"/>
<location filename="../../src/Dialog_Update.cpp" line="431"/>
<source>Update failed. Please try again or download manually!</source>
<translation>Uppdateringen misslyckades. Försök igen, eller ladda ner manuellt!</translation>
</message>

View File

@ -2652,10 +2652,6 @@
<source>Network connectivity test has failed!</source>
<translation> !</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>,.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation>,...</translation>
@ -2716,5 +2712,9 @@
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation> Internet,.</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">,...</translation>
</message>
</context>
</TS>

View File

@ -2689,10 +2689,6 @@
<source>Network connectivity test has failed!</source>
<translation>Збій перевірки мережевого з&apos;єднання!</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>Будь ласка, впевніться, що ваше інтернет-з&apos;єднання працює коректно і спробуйте знову.</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation>Йде перевірка оновлень онлайн, будь ласка, зачекайте...</translation>
@ -2753,5 +2749,9 @@
<source>Update failed. Please try again or download manually!</source>
<translation>Збій оновлення. Будь ласка, спробуйте ще раз або завантажте оновлення самостійно!</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">Ініціалізація, будь ласка, зачекайте...</translation>
</message>
</context>
</TS>

View File

@ -2652,10 +2652,6 @@
<source>Network connectivity test has failed!</source>
<translation> !</translation>
</message>
<message>
<source>Please make sure your internet connection is working properly and try again.</source>
<translation>,</translation>
</message>
<message>
<source>Checking for new updates online, please wait...</source>
<translation>线,...</translation>
@ -2716,5 +2712,9 @@
<source>Please make sure your computer is connected to the internet and try again.</source>
<translation> Internet,</translation>
</message>
<message>
<source>Initializing, please wait...</source>
<translation type="unfinished">,...</translation>
</message>
</context>
</TS>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 9
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 7
#define VER_LAMEXP_BUILD 1454
#define VER_LAMEXP_BUILD 1458
#define VER_LAMEXP_CONFG 1348
///////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@
class UpdateInfo;
class SettingsModel;
class QMovie;
class UpdateCheckThread;
//UIC forward declartion
namespace Ui {
@ -53,6 +54,11 @@ private slots:
void logButtonClicked(void);
void progressBarValueChanged(int value);
void threadStatusChanged(const int status);
void threadProgressChanged(const int progress);
void threadMessageLogged(const QString &message);
void threadFinished(void);
protected:
virtual void showEvent(QShowEvent *event);
virtual void closeEvent(QCloseEvent *event);
@ -65,24 +71,19 @@ protected:
private:
Ui::UpdateDialog *ui; //for Qt UIC
bool tryUpdateMirror(UpdateInfo *updateInfo, const QString &url);
bool getFile(const QString &url, const QString &outFile, unsigned int maxRedir = 5, bool *httpOk = NULL);
bool checkSignature(const QString &file, const QString &signature);
bool parseVersionInfo(const QString &file, UpdateInfo *updateInfo);
void testKnownWebSites(void);
const QString m_binaryUpdater;
UpdateInfo *m_updateInfo;
UpdateCheckThread *m_thread;
QStringList *m_logFile;
SettingsModel *m_settings;
QMovie *m_animator;
const QString m_binaryWGet;
const QString m_binaryGnuPG;
const QString m_binaryUpdater;
const QString m_binaryKeys;
unsigned long m_updaterProcess;
bool m_success;
bool m_updateReadyToInstall;
bool m_firstShow;
void testKnownHosts(void);
};

710
src/Thread_CheckUpdate.cpp Normal file
View File

@ -0,0 +1,710 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version, but always including the *additional*
// restrictions defined in the "License.txt" file.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#include "Thread_CheckUpdate.h"
#include "Global.h"
#include <QStringList>
#include <QFile>
#include <QFileInfo>
#include <QProcess>
#include <QUrl>
#include <QEventLoop>
#include <QTimer>
///////////////////////////////////////////////////////////////////////////////
// CONSTANTS
///////////////////////////////////////////////////////////////////////////////
static const char *header_id = "!Update";
static const char *section_id = "LameXP";
static const char *mirror_url_postfix[] =
{
"update.ver",
"update_beta.ver",
NULL
};
static const char *update_mirrors_prim[] =
{
"http://muldersoft.com/",
"http://mulder.bplaced.net/",
"http://mulder.cwsurf.de/",
"http://mulder.6te.net/",
"http://mulder.webuda.com/",
"http://mulder.byethost13.com/",
"http://muldersoft.kilu.de/",
"http://muldersoft.zxq.net/",
"http://lamexp.sourceforge.net/",
"http://lamexp.berlios.de/",
"http://lordmulder.github.com/LameXP/",
"http://lord_mulder.bitbucket.org/",
"http://www.tricksoft.de/",
NULL
};
static const char *update_mirrors_back[] =
{
"http://mplayer.savedonthe.net/",
NULL
};
static const char *known_hosts[] = //Taken form: http://www.alexa.com/topsites !!!
{
"http://www.163.com/",
"http://www.ac3filter.net/",
"http://www.amazon.com/",
"http://www.aol.com/",
"http://www.apache.org/",
"http://www.apple.com/",
"http://www.adobe.com/",
"http://www.avidemux.org/",
"http://www.babylon.com/",
"http://www.baidu.com/",
"http://www.bbc.co.uk/",
"http://www.berlios.de/",
"http://www.bing.com/",
"http://www.cnet.com/",
"http://cnzz.com/",
"http://codecs.com/",
"http://www.codeplex.com/",
"http://qt.digia.com/",
"http://www.ebay.com/",
"http://www.equation.com/",
"http://fc2.com/",
"http://www.ffmpeg.org/",
"http://www.flickr.com/",
"http://blog.gitorious.org/",
"http://git-scm.com/",
"http://www.gnome.org/",
"http://www.gnu.org/",
"http://go.com/",
"http://code.google.com/",
"http://www.heise.de/",
"http://www.huffingtonpost.co.uk/",
"http://www.iana.org/",
"http://www.imdb.com/",
"http://www.imgburn.com/",
"http://imgur.com/",
"http://en.jd.com/",
"http://mirrors.kernel.org/",
"http://www.libav.org/",
"http://www.linkedin.com/about-us",
"http://www.livedoor.com/",
"http://www.livejournal.com/",
"http://mail.ru/",
"http://www.mediafire.com/",
"http://www.mozilla.org/en-US/",
"http://mplayerhq.hu/",
"http://www.msn.com/?st=1",
"http://oss.netfarm.it/",
"http://www.nytimes.com/",
"http://www.opera.com/",
"http://www.portablefreeware.com/",
"http://qt-project.org/",
"http://www.quakelive.com/",
"http://www.seamonkey-project.org/",
"http://www.sina.com.cn/",
"http://www.sohu.com/",
"http://www.soso.com/",
"http://sourceforge.net/",
"http://www.spiegel.de/",
"http://tdm-gcc.tdragon.net/",
"http://www.tdrsmusic.com/",
"http://www.ubuntu.com/",
"http://status.twitter.com/",
"http://www.uol.com.br/",
"http://www.videohelp.com/",
"http://www.videolan.org/",
"http://www.weibo.com/",
"http://www.wikipedia.org/",
"http://www.winamp.com/",
"http://wordpress.com/",
"http://us.yahoo.com/",
"http://www.yandex.ru/",
"http://www.youtube.com/",
"http://www.zedo.com/",
"http://ffmpeg.zeranoe.com/",
NULL
};
static const int MIN_CONNSCORE = 8;
static const int VERSION_INFO_EXPIRES_MONTHS = 6;
static char *USER_AGENT_STR = "Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111106 IceCat/7.0.1";
//Helper function
static int getMaxProgress(void)
{
int counter = MIN_CONNSCORE + 2;
for(int i = 0; update_mirrors_prim[i]; i++) counter++;
for(int i = 0; update_mirrors_back[i]; i++) counter++;
return counter;
}
////////////////////////////////////////////////////////////
// Update Info Class
////////////////////////////////////////////////////////////
UpdateInfo::UpdateInfo(void)
{
resetInfo();
}
void UpdateInfo::resetInfo(void)
{
m_buildNo = 0;
m_buildDate.setDate(1900, 1, 1);
m_downloadSite.clear();
m_downloadAddress.clear();
m_downloadFilename.clear();
m_downloadFilecode.clear();
}
////////////////////////////////////////////////////////////
// Constructor & Destructor
////////////////////////////////////////////////////////////
UpdateCheckThread::UpdateCheckThread(const bool betaUpdates, const bool testMode)
:
m_updateInfo(new UpdateInfo()),
m_betaUpdates(betaUpdates),
m_testMode(testMode),
m_binaryWGet(lamexp_lookup_tool("wget.exe")),
m_binaryGnuPG(lamexp_lookup_tool("gpgv.exe")),
m_binaryKeys(lamexp_lookup_tool("gpgv.gpg")),
m_maxProgress(getMaxProgress())
{
m_success = false;
m_status = UpdateStatus_NotStartedYet;
m_progress = 0;
if(m_binaryWGet.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryKeys.isEmpty())
{
THROW("Tools not initialized correctly!");
}
}
UpdateCheckThread::~UpdateCheckThread(void)
{
delete m_updateInfo;
}
////////////////////////////////////////////////////////////
// Protected functions
////////////////////////////////////////////////////////////
void UpdateCheckThread::run(void)
{
qDebug("Update checker thread started!");
try
{
m_testMode ? testKnownHosts() : checkForUpdates();
}
catch(const std::exception &error)
{
fflush(stdout); fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
lamexp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
fflush(stdout); fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
lamexp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
qDebug("Update checker thread completed.");
}
void UpdateCheckThread::checkForUpdates(void)
{
// ----- Initialization ----- //
m_success = false;
m_updateInfo->resetInfo();
setProgress(0);
// ----- Test Internet Connection ----- //
int connectionScore = 0;
log("Checking internet connection...");
setStatus(UpdateStatus_CheckingConnection);
const int networkStatus = lamexp_network_status();
if(networkStatus == lamexp_network_non)
{
log("", "Operating system reports that the computer is currently offline !!!");
setProgress(m_maxProgress);
setStatus(UpdateStatus_ErrorNoConnection);
return;
}
setProgress(1);
// ----- Test Known Hosts Connectivity ----- //
QStringList hostList;
for(int i = 0; known_hosts[i]; i++)
{
hostList << QString::fromLatin1(known_hosts[i]);
}
lamexp_seed_rand();
while(!hostList.isEmpty())
{
QString currentHost = hostList.takeAt(lamexp_rand() % hostList.count());
if(connectionScore < MIN_CONNSCORE)
{
log("", "Testing host:", currentHost);
QString outFile = QString("%1/%2.htm").arg(lamexp_temp_folder2(), lamexp_rand_str());
bool httpOk = false;
if(getFile(currentHost, outFile, 0, &httpOk))
{
connectionScore++;
setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
lamexp_sleep(64);
}
if(httpOk)
{
connectionScore++;
setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
lamexp_sleep(64);
}
QFile::remove(outFile);
}
}
if(connectionScore < MIN_CONNSCORE)
{
setProgress(m_maxProgress);
setStatus(UpdateStatus_ErrorConnectionTestFailed);
return;
}
// ----- Build Mirror List ----- //
log("", "----", "", "Checking for updates online...");
setStatus(UpdateStatus_FetchingUpdates);
QStringList mirrorList;
for(int index = 0; update_mirrors_prim[index]; index++)
{
mirrorList << QString::fromLatin1(update_mirrors_prim[index]);
}
lamexp_seed_rand();
if(const int len = mirrorList.count())
{
const int rounds = len * 1097;
for(int i = 0; i < rounds; i++)
{
mirrorList.swap(i % len, lamexp_rand() % len);
}
}
for(int index = 0; update_mirrors_back[index]; index++)
{
mirrorList << QString::fromLatin1(update_mirrors_back[index]);
}
// ----- Fetch Update Info From Server ----- //
while(!mirrorList.isEmpty())
{
QString currentMirror = mirrorList.takeFirst();
setProgress(m_progress + 1);
if(!m_success)
{
if(tryUpdateMirror(m_updateInfo, currentMirror))
{
m_success = true;
}
}
else
{
lamexp_sleep(64);
}
}
setProgress(m_maxProgress);
if(m_success)
{
if(m_updateInfo->m_buildNo > lamexp_version_build())
{
setStatus(UpdateStatus_CompletedUpdateAvailable);
}
else if(m_updateInfo->m_buildNo == lamexp_version_build())
{
setStatus(UpdateStatus_CompletedNoUpdates);
}
else
{
setStatus(UpdateStatus_CompletedNewVersionOlder);
}
}
else
{
setStatus(UpdateStatus_ErrorFetchUpdateInfo);
}
}
void UpdateCheckThread::testKnownHosts(void)
{
QStringList hostList;
for(int i = 0; known_hosts[i]; i++)
{
hostList << QString::fromLatin1(known_hosts[i]);
}
qDebug("\n[Known Hosts]");
log("Testing all known hosts...", "", "---");
int hostCount = hostList.count();
while(!hostList.isEmpty())
{
QString currentHost = hostList.takeFirst();
qDebug("Testing: %s", currentHost.toLatin1().constData());
log("", "Testing:", currentHost, "");
QString outFile = QString("%1/%2.htm").arg(lamexp_temp_folder2(), lamexp_rand_str());
bool httpOk = false;
if(!getFile(currentHost, outFile, 0, &httpOk))
{
if(httpOk)
{
qWarning("\nConnectivity test was SLOW on the following site:\n%s\n", currentHost.toLatin1().constData());
}
else
{
qWarning("\nConnectivity test FAILED on the following site:\n%s\n", currentHost.toLatin1().constData());
}
}
log("", "---");
QFile::remove(outFile);
}
}
////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS
////////////////////////////////////////////////////////////
void UpdateCheckThread::setStatus(const int status)
{
if(m_status != status)
{
m_status = status;
emit statusChanged(status);
}
}
void UpdateCheckThread::setProgress(const int progress)
{
if(m_progress != progress)
{
m_progress = progress;
emit progressChanged(progress);
}
}
void UpdateCheckThread::log(const QString &str1, const QString &str2, const QString &str3, const QString &str4)
{
if(!str1.isNull()) emit messageLogged(str1);
if(!str2.isNull()) emit messageLogged(str2);
if(!str3.isNull()) emit messageLogged(str3);
if(!str4.isNull()) emit messageLogged(str4);
}
bool UpdateCheckThread::tryUpdateMirror(UpdateInfo *updateInfo, const QString &url)
{
bool success = false;
log("", "Trying mirror:", url);
QString randPart = lamexp_rand_str();
QString outFileVersionInfo = QString("%1/%2.ver").arg(lamexp_temp_folder2(), randPart);
QString outFileSignature = QString("%1/%2.sig").arg(lamexp_temp_folder2(), randPart);
log("", "Downloading update info:");
bool ok1 = getFile(QString("%1%2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileVersionInfo);
log("", "Downloading signature:");
bool ok2 = getFile(QString("%1%2.sig").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileSignature);
if(ok1 && ok2)
{
log("", "Download okay, checking signature:");
if(checkSignature(outFileVersionInfo, outFileSignature))
{
log("", "Signature okay, parsing info:");
success = parseVersionInfo(outFileVersionInfo, updateInfo);
}
else
{
log("", "Bad signature, take care!");
}
}
else
{
log("", "Download has failed!");
}
QFile::remove(outFileVersionInfo);
QFile::remove(outFileSignature);
return success;
}
bool UpdateCheckThread::getFile(const QString &url, const QString &outFile, unsigned int maxRedir, bool *httpOk)
{
QFileInfo output(outFile);
output.setCaching(false);
if(httpOk) *httpOk = false;
if(output.exists())
{
QFile::remove(output.canonicalFilePath());
if(output.exists())
{
return false;
}
}
QProcess process;
lamexp_init_process(process, output.absolutePath());
QStringList args;
args << "--no-cache" << "--no-dns-cache" << QString().sprintf("--max-redirect=%u", maxRedir);
args << QString("--referer=%1://%2/").arg(QUrl(url).scheme(), QUrl(url).host()) << "-U" << USER_AGENT_STR;
args << "-O" << output.fileName() << url;
QEventLoop loop;
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)), &loop, SLOT(quit()));
connect(&process, SIGNAL(readyRead()), &loop, SLOT(quit()));
QTimer timer;
timer.setSingleShot(true);
timer.setInterval(25000);
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
const QRegExp httpResponseOK("200 OK$");
process.start(m_binaryWGet, args);
if(!process.waitForStarted())
{
return false;
}
timer.start();
while(process.state() == QProcess::Running)
{
loop.exec();
bool bTimeOut = (!timer.isActive());
while(process.canReadLine())
{
QString line = QString::fromLatin1(process.readLine()).simplified();
if(line.contains(httpResponseOK))
{
line.append(" [OK]");
if(httpOk) *httpOk = true;
}
log(line);
}
if(bTimeOut)
{
qWarning("WGet process timed out <-- killing!");
process.kill();
process.waitForFinished();
log("!!! TIMEOUT !!!");
return false;
}
}
timer.stop();
timer.disconnect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
log(QString().sprintf("Exited with code %d", process.exitCode()));
return (process.exitCode() == 0) && output.exists() && output.isFile();
}
bool UpdateCheckThread::checkSignature(const QString &file, const QString &signature)
{
if(QFileInfo(file).absolutePath().compare(QFileInfo(signature).absolutePath(), Qt::CaseInsensitive) != 0)
{
qWarning("CheckSignature: File and signature should be in same folder!");
return false;
}
if(QFileInfo(file).absolutePath().compare(QFileInfo(m_binaryKeys).absolutePath(), Qt::CaseInsensitive) != 0)
{
qWarning("CheckSignature: File and keyring should be in same folder!");
return false;
}
QProcess process;
lamexp_init_process(process, QFileInfo(file).absolutePath());
QEventLoop loop;
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
connect(&process, SIGNAL(finished(int,QProcess::ExitStatus)), &loop, SLOT(quit()));
connect(&process, SIGNAL(readyRead()), &loop, SLOT(quit()));
process.start(m_binaryGnuPG, QStringList() << "--homedir" << "." << "--keyring" << QFileInfo(m_binaryKeys).fileName() << QFileInfo(signature).fileName() << QFileInfo(file).fileName());
if(!process.waitForStarted())
{
return false;
}
while(process.state() == QProcess::Running)
{
loop.exec();
while(process.canReadLine())
{
log(QString::fromLatin1(process.readLine()).simplified());
}
}
log(QString().sprintf("Exited with code %d", process.exitCode()));
return (process.exitCode() == 0);
}
bool UpdateCheckThread::parseVersionInfo(const QString &file, UpdateInfo *updateInfo)
{
QRegExp value("^(\\w+)=(.+)$");
QRegExp section("^\\[(.+)\\]$");
QDate updateInfoDate;
updateInfo->resetInfo();
QFile data(file);
if(!data.open(QIODevice::ReadOnly))
{
qWarning("Cannot open update info file for reading!");
return false;
}
bool inHeader = false;
bool inSection = false;
while(!data.atEnd())
{
QString line = QString::fromLatin1(data.readLine()).trimmed();
if(section.indexIn(line) >= 0)
{
log(QString("Sec: [%1]").arg(section.cap(1)));
inSection = (section.cap(1).compare(section_id, Qt::CaseInsensitive) == 0);
inHeader = (section.cap(1).compare(header_id, Qt::CaseInsensitive) == 0);
continue;
}
if(inSection && (value.indexIn(line) >= 0))
{
log(QString("Val: '%1' ==> '%2").arg(value.cap(1), value.cap(2)));
if(value.cap(1).compare("BuildNo", Qt::CaseInsensitive) == 0)
{
bool ok = false;
unsigned int temp = value.cap(2).toUInt(&ok);
if(ok) updateInfo->m_buildNo = temp;
}
else if(value.cap(1).compare("BuildDate", Qt::CaseInsensitive) == 0)
{
QDate temp = QDate::fromString(value.cap(2).trimmed(), Qt::ISODate);
if(temp.isValid()) updateInfo->m_buildDate = temp;
}
else if(value.cap(1).compare("DownloadSite", Qt::CaseInsensitive) == 0)
{
updateInfo->m_downloadSite = value.cap(2).trimmed();
}
else if(value.cap(1).compare("DownloadAddress", Qt::CaseInsensitive) == 0)
{
updateInfo->m_downloadAddress = value.cap(2).trimmed();
}
else if(value.cap(1).compare("DownloadFilename", Qt::CaseInsensitive) == 0)
{
updateInfo->m_downloadFilename = value.cap(2).trimmed();
}
else if(value.cap(1).compare("DownloadFilecode", Qt::CaseInsensitive) == 0)
{
updateInfo->m_downloadFilecode = value.cap(2).trimmed();
}
}
if(inHeader && (value.indexIn(line) >= 0))
{
log(QString("Val: '%1' ==> '%2").arg(value.cap(1), value.cap(2)));
if(value.cap(1).compare("TimestampCreated", Qt::CaseInsensitive) == 0)
{
QDate temp = QDate::fromString(value.cap(2).trimmed(), Qt::ISODate);
if(temp.isValid()) updateInfoDate = temp;
}
}
}
if(!updateInfoDate.isValid())
{
updateInfo->resetInfo();
log("WARNING: Version info timestamp is missing!");
return false;
}
else if(updateInfoDate.addMonths(VERSION_INFO_EXPIRES_MONTHS) < lamexp_current_date_safe())
{
updateInfo->resetInfo();
log(QString::fromLatin1("WARNING: This version info has expired at %1!").arg(updateInfoDate.addMonths(VERSION_INFO_EXPIRES_MONTHS).toString(Qt::ISODate)));
return false;
}
else if(lamexp_current_date_safe() < updateInfoDate)
{
log("Version info is from the future, take care!");
qWarning("Version info is from the future, take care!");
}
bool complete = true;
if(!(updateInfo->m_buildNo > 0)) complete = false;
if(!(updateInfo->m_buildDate.year() >= 2010)) complete = false;
if(updateInfo->m_downloadSite.isEmpty()) complete = false;
if(updateInfo->m_downloadAddress.isEmpty()) complete = false;
if(updateInfo->m_downloadFilename.isEmpty()) complete = false;
if(updateInfo->m_downloadFilecode.isEmpty()) complete = false;
if(!complete)
{
log("WARNING: Version info is incomplete!");
}
return complete;
}
////////////////////////////////////////////////////////////
// SLOTS
////////////////////////////////////////////////////////////
/*NONE*/
////////////////////////////////////////////////////////////
// EVENTS
////////////////////////////////////////////////////////////
/*NONE*/

108
src/Thread_CheckUpdate.h Normal file
View File

@ -0,0 +1,108 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version, but always including the *additional*
// restrictions defined in the "License.txt" file.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QThread>
#include <QDate>
///////////////////////////////////////////////////////////////////////////////
class UpdateInfo
{
public:
UpdateInfo(void);
void resetInfo(void);
unsigned int m_buildNo;
QDate m_buildDate;
QString m_downloadSite;
QString m_downloadAddress;
QString m_downloadFilename;
QString m_downloadFilecode;
};
///////////////////////////////////////////////////////////////////////////////
class UpdateCheckThread : public QThread
{
Q_OBJECT
public:
enum
{
UpdateStatus_NotStartedYet = 0,
UpdateStatus_CheckingConnection = 1,
UpdateStatus_FetchingUpdates = 2,
UpdateStatus_CompletedUpdateAvailable = 3,
UpdateStatus_CompletedNoUpdates = 4,
UpdateStatus_CompletedNewVersionOlder = 5,
UpdateStatus_ErrorNoConnection = 6,
UpdateStatus_ErrorConnectionTestFailed = 7,
UpdateStatus_ErrorFetchUpdateInfo = 8
}
update_status_t;
UpdateCheckThread(const bool betaUpdates, const bool testMode = false);
~UpdateCheckThread(void);
const int getUpdateStatus(void) const { return m_status; }
const bool getSuccess(void) const { return m_success; };
const int getMaximumProgress(void) const { return m_maxProgress; };
const int getCurrentProgress(void) const { return m_progress; };
const UpdateInfo *getUpdateInfo(void) const { return m_updateInfo; }
protected:
void run(void);
void checkForUpdates(void);
void testKnownHosts(void);
signals:
void statusChanged(const int status);
void progressChanged(const int progress);
void messageLogged(const QString &text);
private:
const int m_maxProgress;
UpdateInfo *const m_updateInfo;
const bool m_betaUpdates;
const bool m_testMode;
const QString m_binaryWGet;
const QString m_binaryGnuPG;
const QString m_binaryKeys;
volatile bool m_success;
int m_status;
int m_progress;
inline void setStatus(const int status);
inline void setProgress(const int progress);
inline void log(const QString &str1, const QString &str2 = QString(), const QString &str3 = QString(), const QString &str4 = QString());
bool getFile(const QString &url, const QString &outFile, unsigned int maxRedir = 5, bool *httpOk = NULL);
bool tryUpdateMirror(UpdateInfo *updateInfo, const QString &url);
bool checkSignature(const QString &file, const QString &signature);
bool parseVersionInfo(const QString &file, UpdateInfo *updateInfo);
};