Author: tfaber
Date: Sat Jan 18 13:07:59 2014
New Revision: 61672
URL:
http://svn.reactos.org/svn/reactos?rev=61672&view=rev
Log:
[RAPPS]
- Store settings in HKEY_CURRENT_USER
- Correctly show the main window if UpdateAtStart is enabled
- Improve error handling
Modified:
trunk/reactos/base/applications/rapps/available.c
trunk/reactos/base/applications/rapps/misc.c
trunk/reactos/base/applications/rapps/parser.c
trunk/reactos/base/applications/rapps/richedit.c
trunk/reactos/base/applications/rapps/winmain.c
Modified: trunk/reactos/base/applications/rapps/available.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/av…
==============================================================================
--- trunk/reactos/base/applications/rapps/available.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps/available.c [iso-8859-1] Sat Jan 18 13:07:59
2014
@@ -47,6 +47,7 @@
WCHAR szPath[MAX_PATH];
WCHAR szTmp[MAX_PATH];
HRESULT hr;
+ BOOL result = TRUE;
if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0])))
return FALSE;
@@ -57,11 +58,7 @@
if (FAILED(hr))
return FALSE;
- if (GetFileAttributesW(szCabPath) != INVALID_FILE_ATTRIBUTES)
- {
- if (!DeleteFileW(szCabPath))
- return FALSE;
- }
+ result = result && DeleteFileW(szCabPath);
hr = StringCbCatW(szPath, sizeof(szPath), L"\\rapps\\");
if (FAILED(hr))
@@ -75,24 +72,21 @@
hFind = FindFirstFileW(szSearchPath, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
- return TRUE;
+ return result;
do
{
hr = StringCbPrintfW(szTmp, sizeof(szTmp),
L"%ls%ls",
szPath, FindFileData.cFileName);
- if (FAILED(hr) || !DeleteFileW(szTmp))
- {
- FindClose(hFind);
- return FALSE;
- }
- }
- while (FindNextFileW(hFind, &FindFileData) != 0);
+ if (FAILED(hr))
+ continue;
+ result = result && DeleteFileW(szTmp);
+ } while (FindNextFileW(hFind, &FindFileData) != 0);
FindClose(hFind);
- return TRUE;
+ return result;
}
@@ -145,9 +139,7 @@
HRESULT hr;
if (!GetStorageDirectory(szPath, sizeof(szPath) / sizeof(szPath[0])))
- {
- return FALSE;
- }
+ return FALSE;
hr = StringCbPrintfW(szCabPath, sizeof(szCabPath),
L"%ls\\rappmgr.cab",
@@ -167,11 +159,6 @@
{
return FALSE;
}
-
- GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE, szLocale, sizeof(szLocale) /
sizeof(WCHAR));
- hr = StringCbCatW(szSectionLocale, sizeof(szSectionLocale), szLocale);
- if (FAILED(hr))
- return FALSE;
hr = StringCbCatW(szPath, sizeof(szPath), L"*.txt");
if (FAILED(hr))
@@ -188,6 +175,16 @@
if (hFind == INVALID_HANDLE_VALUE)
return FALSE;
}
+
+ if (!GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE,
+ szLocale, sizeof(szLocale) / sizeof(WCHAR)))
+ {
+ return FALSE;
+ }
+
+ hr = StringCbCatW(szSectionLocale, sizeof(szSectionLocale), szLocale);
+ if (FAILED(hr))
+ return FALSE;
#define GET_STRING1(a, b) \
if (!ParserGetString(szSectionLocale, a, b, MAX_PATH, FindFileData.cFileName)) \
@@ -223,8 +220,7 @@
GET_STRING2(L"CDPath", Info.szCDPath);
if (!lpEnumProc(Info)) break;
- }
- while (FindNextFileW(hFind, &FindFileData) != 0);
+ } while (FindNextFileW(hFind, &FindFileData) != 0);
FindClose(hFind);
Modified: trunk/reactos/base/applications/rapps/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/mi…
==============================================================================
--- trunk/reactos/base/applications/rapps/misc.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps/misc.c [iso-8859-1] Sat Jan 18 13:07:59 2014
@@ -113,7 +113,7 @@
{
HRESULT hr;
- if(OpenClipboard(NULL))
+ if (OpenClipboard(NULL))
{
HGLOBAL ClipBuffer;
WCHAR *Buffer;
@@ -122,7 +122,7 @@
EmptyClipboard();
cchBuffer = wcslen(lpszText) + 1;
ClipBuffer = GlobalAlloc(GMEM_DDESHARE, cchBuffer * sizeof(WCHAR));
- Buffer = (WCHAR*)GlobalLock(ClipBuffer);
+ Buffer = GlobalLock(ClipBuffer);
hr = StringCchCopyW(Buffer, cchBuffer, lpszText);
GlobalUnlock(ClipBuffer);
Modified: trunk/reactos/base/applications/rapps/parser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/pa…
==============================================================================
--- trunk/reactos/base/applications/rapps/parser.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps/parser.c [iso-8859-1] Sat Jan 18 13:07:59 2014
@@ -489,7 +489,7 @@
if (!create) return NULL;
cch = wcslen(section_name) + 1;
*section = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(SECTION, name) + cch *
sizeof(WCHAR));
- if(*section == NULL) return NULL;
+ if (*section == NULL) return NULL;
StringCchCopyW((*section)->name, cch, section_name);
(*section)->next = NULL;
cch = wcslen(key_name) + 1;
@@ -562,11 +562,15 @@
ItemsArray[i]->encoding = ENCODING_UTF8;
}
- GetStorageDirectory(szDir, sizeof(szDir) / sizeof(szDir[0]));
-
- StringCbPrintfW(buffer, sizeof(buffer),
- L"%ls\\rapps\\%ls",
- szDir, filename);
+ if (!GetStorageDirectory(szDir, sizeof(szDir) / sizeof(szDir[0])))
+ return FALSE;
+
+ if (FAILED(StringCbPrintfW(buffer, sizeof(buffer),
+ L"%ls\\rapps\\%ls",
+ szDir, filename)))
+ {
+ return FALSE;
+ }
hFile = CreateFileW(buffer, GENERIC_READ | (write_access ? GENERIC_WRITE : 0),
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
Modified: trunk/reactos/base/applications/rapps/richedit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/ri…
==============================================================================
--- trunk/reactos/base/applications/rapps/richedit.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps/richedit.c [iso-8859-1] Sat Jan 18 13:07:59
2014
@@ -23,10 +23,10 @@
{
if (pLink) HeapFree(GetProcessHeap(), 0, pLink);
- pLink = (PWSTR) HeapAlloc(GetProcessHeap(),
- 0,
- (max(Link->chrg.cpMin, Link->chrg.cpMax) -
- min(Link->chrg.cpMin, Link->chrg.cpMax) + 1)
* sizeof(WCHAR));
+ pLink = HeapAlloc(GetProcessHeap(),
+ 0,
+ (max(Link->chrg.cpMin, Link->chrg.cpMax) -
+ min(Link->chrg.cpMin, Link->chrg.cpMax) + 1) *
sizeof(WCHAR));
if (!pLink)
{
/* TODO: Error message */
Modified: trunk/reactos/base/applications/rapps/winmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/wi…
==============================================================================
--- trunk/reactos/base/applications/rapps/winmain.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps/winmain.c [iso-8859-1] Sat Jan 18 13:07:59 2014
@@ -40,7 +40,7 @@
HKEY hKey;
DWORD dwSize;
- if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\ReactOS\\rapps", 0,
KEY_READ, &hKey) == ERROR_SUCCESS)
+ if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0,
KEY_READ, &hKey) == ERROR_SUCCESS)
{
dwSize = sizeof(SETTINGS_INFO);
if (RegQueryValueExW(hKey, L"Settings", NULL, NULL,
(LPBYTE)&SettingsInfo, &dwSize) == ERROR_SUCCESS)
@@ -73,7 +73,7 @@
SettingsInfo.Maximized = (IsZoomed(hwnd) || (wp.flags &
WPF_RESTORETOMAXIMIZED));
}
- if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\ReactOS\\rapps", 0,
NULL,
+ if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0,
NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
{
RegSetValueExW(hKey, L"Settings", 0, REG_BINARY,
(LPBYTE)&SettingsInfo, sizeof(SETTINGS_INFO));
@@ -115,10 +115,10 @@
Index = ListViewAddItem(ItemIndex, 0, lpName, (LPARAM)ItemInfo);
/* Get version info */
- GetApplicationString((HKEY)ItemInfo->hSubKey, L"DisplayVersion",
szText);
+ GetApplicationString(ItemInfo->hSubKey, L"DisplayVersion", szText);
ListView_SetItemText(hListView, Index, 1, szText);
/* Get comments */
- GetApplicationString((HKEY)ItemInfo->hSubKey, L"Comments", szText);
+ GetApplicationString(ItemInfo->hSubKey, L"Comments", szText);
ListView_SetItemText(hListView, Index, 2, szText);
return TRUE;
@@ -538,8 +538,6 @@
if (!InitControls(hwnd))
PostMessage(hwnd, WM_CLOSE, 0, 0);
- if (SettingsInfo.bUpdateAtStart)
- UpdateAppsDB();
break;
case WM_COMMAND:
@@ -843,8 +841,11 @@
if (!hMainWnd) goto Exit;
/* Show it */
- ShowWindow(hMainWnd, SW_SHOW);
+ ShowWindow(hMainWnd, nShowCmd);
UpdateWindow(hMainWnd);
+
+ if (SettingsInfo.bUpdateAtStart)
+ UpdateAppsDB();
/* Message Loop */
while (GetMessage(&Msg, NULL, 0, 0))