From 4745785f049fb2e9f62322f0c50abda34e91d030 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Fri, 17 Apr 2015 12:37:08 +0000 Subject: [PATCH] [RAPPS] free cached entries and some other improvements patch by Ismael Ferreras Morezuelas aka swyter CORE-9060 svn path=/trunk/; revision=67224 --- .../base/applications/rapps/CreateCabFile.sh | 4 +-- reactos/base/applications/rapps/available.c | 20 +++++++++++++- reactos/base/applications/rapps/lang/es-ES.rc | 8 +++--- reactos/base/applications/rapps/misc.c | 21 +++------------ reactos/base/applications/rapps/rapps.h | 1 + reactos/base/applications/rapps/winmain.c | 26 ++++--------------- 6 files changed, 34 insertions(+), 46 deletions(-) diff --git a/reactos/base/applications/rapps/CreateCabFile.sh b/reactos/base/applications/rapps/CreateCabFile.sh index 5c668551846..adb4e706bb4 100755 --- a/reactos/base/applications/rapps/CreateCabFile.sh +++ b/reactos/base/applications/rapps/CreateCabFile.sh @@ -2,8 +2,8 @@ cd rapps mkdir utf16 for i in $(find -type f); do - ../../../../output-MinGW-i386/host-tools/tools/utf16le.exe $i utf16/$i + ../../../host-tools/tools/utf16le $i utf16/$i done cd .. -../../../output-MinGW-i386/host-tools/tools/cabman/cabman -M mszip -S rappmgr.cab rapps/utf16/*.txt +../../host-tools/tools/cabman/cabman -M mszip -S rappmgr.cab rapps/utf16/*.txt rm -r rapps/uft16 \ No newline at end of file diff --git a/reactos/base/applications/rapps/available.c b/reactos/base/applications/rapps/available.c index 54d255c4698..114ebcf4e0c 100644 --- a/reactos/base/applications/rapps/available.c +++ b/reactos/base/applications/rapps/available.c @@ -246,7 +246,7 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc) skip_if_cached: - if (Info->Category == -1) + if (Info->Category == FALSE) continue; if (EnumType != Info->Category && EnumType != ENUM_ALL_AVAILABLE) @@ -277,4 +277,22 @@ skip_if_cached: FindClose(hFind); return TRUE; +} + +VOID FreeCachedAvailableEntries(VOID) +{ + PAPPLICATION_INFO Info; + + /* loop and deallocate all the cached app infos in the list */ + for (pCachedEntry = CachedEntriesHead.Flink; pCachedEntry != &CachedEntriesHead;) + { + Info = CONTAINING_RECORD(pCachedEntry, APPLICATION_INFO, List); + + /* grab a reference to the next linked entry before getting rid of the current one */ + pCachedEntry = pCachedEntry->Flink; + + /* flush them down the toilet :D */ + RemoveEntryList(&Info->List); + HeapFree(GetProcessHeap(), 0, Info); + } } \ No newline at end of file diff --git a/reactos/base/applications/rapps/lang/es-ES.rc b/reactos/base/applications/rapps/lang/es-ES.rc index 188fd61308b..7791062a79e 100644 --- a/reactos/base/applications/rapps/lang/es-ES.rc +++ b/reactos/base/applications/rapps/lang/es-ES.rc @@ -194,10 +194,10 @@ BEGIN IDS_AVAILABLEFORINST "Disponible para su instalación" IDS_UPDATES "Actualizaciones" IDS_APPLICATIONS "Aplicaciones" - IDS_CHOOSE_FOLDER_TEXT "Seleccione una carpeta donde se descargarán los programas:" - IDS_CHOOSE_FOLDER_ERROR "¡La carpeta especificada no existe!" + IDS_CHOOSE_FOLDER_TEXT "Seleccione una carpeta de donde se descargarán los programas:" + IDS_CHOOSE_FOLDER_ERROR "La carpeta especificada no existe." IDS_APP_REG_REMOVE "¿Está seguro de querer borrar del Registro los datos de instalación del programa?" IDS_INFORMATION "Información" - IDS_UNABLE_TO_DOWNLOAD "Unable to download the package! Address not found!" - IDS_UNABLE_TO_REMOVE "¡No se pudieron borrar del Registro los datos de instalación del programa!" + IDS_UNABLE_TO_DOWNLOAD "No se pudo descargar el paquete. No se ha encontrado la dirección de Internet." + IDS_UNABLE_TO_REMOVE "No se pudieron borrar del Registro los datos de instalación del programa." END diff --git a/reactos/base/applications/rapps/misc.c b/reactos/base/applications/rapps/misc.c index e51480e0423..e8d05ec881d 100644 --- a/reactos/base/applications/rapps/misc.c +++ b/reactos/base/applications/rapps/misc.c @@ -414,12 +414,8 @@ LPWSTR GetINIFullPath(LPCWSTR lpFileName) UINT ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPCWSTR lpFileName) { PWSTR lpFullFileName = GetINIFullPath(lpFileName); - LPSTR lpRequiredBuf = HeapAlloc(GetProcessHeap(), 0, nSize); DWORD dwResult; - if (!lpRequiredBuf) - return FALSE; - /* we don't have cached section strings for the current system language, create them */ if(bCachedSectionStatus == FALSE) { @@ -457,7 +453,7 @@ UINT ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPC lpFullFileName); if (dwResult != 0) - goto skip; + return TRUE; /* 2nd - if they weren't present check for neutral sub-langs/ generic translations (e.g. "Section.0a") */ dwResult = GetPrivateProfileStringW(szCachedINISectionLocaleNeutral, @@ -468,7 +464,7 @@ UINT ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPC lpFullFileName); if (dwResult != 0) - goto skip; + return TRUE; /* 3rd - if they weren't present fallback to standard english strings (just "Section") */ dwResult = GetPrivateProfileStringW(L"Section", @@ -478,18 +474,7 @@ UINT ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPC nSize, lpFullFileName); - if (dwResult == 0) - { - HeapFree(GetProcessHeap(), 0, lpRequiredBuf); - return FALSE; - } - -skip: - - /* get rid of the dynamically allocated ANSI buffer */ - HeapFree(GetProcessHeap(), 0, lpRequiredBuf); - - return TRUE; + return (dwResult != 0 ? TRUE : FALSE); } UINT ParserGetInt(LPCWSTR lpKeyName, LPCWSTR lpFileName) diff --git a/reactos/base/applications/rapps/rapps.h b/reactos/base/applications/rapps/rapps.h index b636e46e6e3..d92eafed56a 100644 --- a/reactos/base/applications/rapps/rapps.h +++ b/reactos/base/applications/rapps/rapps.h @@ -125,6 +125,7 @@ typedef BOOL (CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info); BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc); BOOL ShowAvailableAppInfo(INT Index); BOOL UpdateAppsDB(VOID); +VOID FreeCachedAvailableEntries(VOID); /* installdlg.c */ BOOL InstallApplication(INT Index); diff --git a/reactos/base/applications/rapps/winmain.c b/reactos/base/applications/rapps/winmain.c index 62d8b8cc27e..164277ebb8f 100644 --- a/reactos/base/applications/rapps/winmain.c +++ b/reactos/base/applications/rapps/winmain.c @@ -147,21 +147,6 @@ EnumInstalledAppProc(INT ItemIndex, LPWSTR lpName, PINSTALLED_INFO Info) return TRUE; } -VOID -FreeAvailableAppList(VOID) -{ - INT Count = ListView_GetItemCount(hListView) - 1; - PVOID Info; - - while (Count >= 0) - { - Info = ListViewGetlParam(Count); - if (Info) - HeapFree(GetProcessHeap(), 0, Info); - Count--; - } -} - BOOL CALLBACK EnumAvailableAppProc(PAPPLICATION_INFO Info) @@ -202,9 +187,6 @@ UpdateApplicationsList(INT EnumType) if (IS_INSTALLED_ENUM(SelectedEnumType)) FreeInstalledAppList(); - /* FIXME: reenable when caching is fixed */ - /* else if (IS_AVAILABLE_ENUM(SelectedEnumType)) - FreeAvailableAppList(); */ (VOID) ListView_DeleteAllItems(hListView); @@ -887,11 +869,13 @@ MainWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) FreeLogs(); - if (IS_AVAILABLE_ENUM(SelectedEnumType)) - FreeAvailableAppList(); + FreeCachedAvailableEntries(); + if (IS_INSTALLED_ENUM(SelectedEnumType)) FreeInstalledAppList(); - if (hImageTreeView) ImageList_Destroy(hImageTreeView); + + if (hImageTreeView) + ImageList_Destroy(hImageTreeView); PostQuitMessage(0); return 0;