Roy Shea : mstask: Implemented partial stub for (Set|Get)AccountInformation .
Alexandre Julliard
julliard at winehq.org
Fri Aug 22 04:44:01 CDT 2008
Module: wine
Branch: master
Commit: f208025228852d2286ffcd8de7ba880216413d16
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f208025228852d2286ffcd8de7ba880216413d16
Author: Roy Shea <royshea at gmail.com>
Date: Thu Aug 21 13:07:00 2008 -0700
mstask: Implemented partial stub for (Set|Get)AccountInformation.
---
dlls/mstask/mstask_private.h | 1 +
dlls/mstask/task.c | 39 +++++++++++++++++++++++++++++++++++----
dlls/mstask/tests/task.c | 28 +++++++++++++++-------------
3 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/dlls/mstask/mstask_private.h b/dlls/mstask/mstask_private.h
index 998bb71..71a675e 100644
--- a/dlls/mstask/mstask_private.h
+++ b/dlls/mstask/mstask_private.h
@@ -62,6 +62,7 @@ typedef struct
LPWSTR parameters;
LPWSTR comment;
DWORD maxRunTime;
+ LPWSTR accountName;
} TaskImpl;
extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj);
diff --git a/dlls/mstask/task.c b/dlls/mstask/task.c
index 707b943..2c70ef5 100644
--- a/dlls/mstask/task.c
+++ b/dlls/mstask/task.c
@@ -29,6 +29,7 @@ static inline TaskImpl *impl_from_IPersistFile( IPersistFile *iface )
static void TaskDestructor(TaskImpl *This)
{
TRACE("%p\n", This);
+ HeapFree(GetProcessHeap(), 0, This->accountName);
HeapFree(GetProcessHeap(), 0, This->comment);
HeapFree(GetProcessHeap(), 0, This->parameters);
HeapFree(GetProcessHeap(), 0, This->taskName);
@@ -355,17 +356,46 @@ static HRESULT WINAPI MSTASK_ITask_SetAccountInformation(
LPCWSTR pwszAccountName,
LPCWSTR pwszPassword)
{
- FIXME("(%p, %s, %s): stub\n", iface, debugstr_w(pwszAccountName),
+ DWORD n;
+ TaskImpl *This = (TaskImpl *)iface;
+ LPWSTR tmp_account_name;
+
+ TRACE("(%p, %s, %s): partial stub\n", iface, debugstr_w(pwszAccountName),
debugstr_w(pwszPassword));
- return E_NOTIMPL;
+
+ if (pwszPassword)
+ FIXME("Partial stub ignores passwords\n");
+
+ n = (lstrlenW(pwszAccountName) + 1);
+ tmp_account_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
+ if (!tmp_account_name)
+ return E_OUTOFMEMORY;
+ lstrcpyW(tmp_account_name, pwszAccountName);
+ HeapFree(GetProcessHeap(), 0, This->accountName);
+ This->accountName = tmp_account_name;
+ return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_GetAccountInformation(
ITask* iface,
LPWSTR *ppwszAccountName)
{
- FIXME("(%p, %p): stub\n", iface, ppwszAccountName);
- return E_NOTIMPL;
+ DWORD n;
+ TaskImpl *This = (TaskImpl *)iface;
+
+ TRACE("(%p, %p): partial stub\n", iface, ppwszAccountName);
+
+ /* This implements the WinXP behavior when accountName has not yet
+ * set. Win2K behaves differently, returning SCHED_E_CANNOT_OPEN_TASK */
+ if (!This->accountName)
+ return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
+
+ n = (lstrlenW(This->accountName) + 1);
+ *ppwszAccountName = CoTaskMemAlloc(n * sizeof(WCHAR));
+ if (!*ppwszAccountName)
+ return E_OUTOFMEMORY;
+ lstrcpyW(*ppwszAccountName, This->accountName);
+ return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_SetApplicationName(
@@ -728,6 +758,7 @@ HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
This->applicationName = NULL;
This->parameters = NULL;
This->comment = NULL;
+ This->accountName = NULL;
/* Default time is 3 days = 259200000 ms */
This->maxRunTime = 259200000;
diff --git a/dlls/mstask/tests/task.c b/dlls/mstask/tests/task.c
index 8dfa675..9e4dfe2 100644
--- a/dlls/mstask/tests/task.c
+++ b/dlls/mstask/tests/task.c
@@ -434,6 +434,8 @@ static void test_SetAccountInformation_GetAccountInformation(void)
LPWSTR account_name;
const WCHAR dummy_account_name[] = {'N', 'o', 'S', 'u', 'c', 'h',
'A', 'c', 'c', 'o', 'u', 'n', 't', 0};
+ const WCHAR dummy_account_name_b[] = {'N', 'o', 'S', 'u', 'c', 'h',
+ 'A', 'c', 'c', 'o', 'u', 'n', 't', 'B', 0};
setup = setup_task();
ok(setup, "Failed to setup test_task\n");
@@ -447,20 +449,20 @@ static void test_SetAccountInformation_GetAccountInformation(void)
hres = ITask_GetAccountInformation(test_task, &account_name);
/* WinXP returns HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND): 0x80070002 but
* Win2K returns SCHED_E_CANNOT_OPEN_TASK: 0x8004130d */
- todo_wine ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
+ ok(hres == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
hres == SCHED_E_CANNOT_OPEN_TASK,
"Unset account name generated: 0x%08x\n", hres);
/* Attempt to set to a dummy account without a password */
/* This test passes on WinXP but fails on Win2K */
hres = ITask_SetAccountInformation(test_task, dummy_account_name, NULL);
- todo_wine ok(hres == S_OK,
+ ok(hres == S_OK,
"Failed setting dummy account with no password: %08x\n", hres);
hres = ITask_GetAccountInformation(test_task, &account_name);
- todo_wine ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
+ ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
if (hres == S_OK)
{
- todo_wine ok(!lstrcmpW(account_name, dummy_account_name),
+ ok(!lstrcmpW(account_name, dummy_account_name),
"Got %s, expected %s\n", dbgstr_w(account_name),
dbgstr_w(dummy_account_name));
CoTaskMemFree(account_name);
@@ -468,28 +470,28 @@ static void test_SetAccountInformation_GetAccountInformation(void)
/* Attempt to set to a dummy account with a (invalid) password */
/* This test passes on WinXP but fails on Win2K */
- hres = ITask_SetAccountInformation(test_task, dummy_account_name,
- dummy_account_name);
- todo_wine ok(hres == S_OK,
+ hres = ITask_SetAccountInformation(test_task, dummy_account_name_b,
+ dummy_account_name_b);
+ ok(hres == S_OK,
"Failed setting dummy account with password: %08x\n", hres);
hres = ITask_GetAccountInformation(test_task, &account_name);
- todo_wine ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
+ ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
if (hres == S_OK)
{
- todo_wine ok(!lstrcmpW(account_name, dummy_account_name),
+ ok(!lstrcmpW(account_name, dummy_account_name_b),
"Got %s, expected %s\n", dbgstr_w(account_name),
- dbgstr_w(dummy_account_name));
+ dbgstr_w(dummy_account_name_b));
CoTaskMemFree(account_name);
}
/* Attempt to set to the local system account */
hres = ITask_SetAccountInformation(test_task, empty, NULL);
- todo_wine ok(hres == S_OK, "Failed setting system account: %08x\n", hres);
+ ok(hres == S_OK, "Failed setting system account: %08x\n", hres);
hres = ITask_GetAccountInformation(test_task, &account_name);
- todo_wine ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
+ ok(hres == S_OK, "GetAccountInformation failed: %08x\n", hres);
if (hres == S_OK)
{
- todo_wine ok(!lstrcmpW(account_name, empty),
+ ok(!lstrcmpW(account_name, empty),
"Got %s, expected empty string\n", dbgstr_w(account_name));
CoTaskMemFree(account_name);
}
More information about the wine-cvs
mailing list