mstask: Implemented (Set|Get)ApplicationName.

oldstable
Roy Shea 2008-08-21 01:09:18 -07:00 committed by Alexandre Julliard
parent 67631163ff
commit ca73655124
4 changed files with 77 additions and 22 deletions

View File

@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = mstask.dll
IMPORTS = uuid kernel32
IMPORTS = uuid ole32 kernel32
C_SRCS = \
factory.c \

View File

@ -58,6 +58,7 @@ typedef struct
const IPersistFileVtbl *persistVtbl;
LONG ref;
LPWSTR taskName;
LPWSTR applicationName;
} TaskImpl;
extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj);

View File

@ -323,16 +323,69 @@ static HRESULT WINAPI MSTASK_ITask_SetApplicationName(
ITask* iface,
LPCWSTR pwszApplicationName)
{
FIXME("(%p, %s): stub\n", iface, debugstr_w(pwszApplicationName));
return E_NOTIMPL;
DWORD n;
TaskImpl *This = (TaskImpl *)iface;
LPWSTR tmp_name;
TRACE("(%p, %s)\n", iface, debugstr_w(pwszApplicationName));
/* Empty application name */
if (pwszApplicationName[0] == 0)
{
HeapFree(GetProcessHeap(), 0, This->applicationName);
This->applicationName = NULL;
return S_OK;
}
/* Attempt to set pwszApplicationName to a path resolved application name */
n = SearchPathW(NULL, pwszApplicationName, NULL, 0, NULL, NULL);
if (n)
{
tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
if (!tmp_name)
return E_OUTOFMEMORY;
n = SearchPathW(NULL, pwszApplicationName, NULL, n, tmp_name, NULL);
if (n)
{
HeapFree(GetProcessHeap(), 0, This->applicationName);
This->applicationName = tmp_name;
return S_OK;
}
else
HeapFree(GetProcessHeap(), 0, tmp_name);
}
/* If unable to path resolve name, simply set to pwszApplicationName */
n = (lstrlenW(pwszApplicationName) + 1);
tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
if (!tmp_name)
return E_OUTOFMEMORY;
lstrcpyW(tmp_name, pwszApplicationName);
HeapFree(GetProcessHeap(), 0, This->applicationName);
This->applicationName = tmp_name;
return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_GetApplicationName(
ITask* iface,
LPWSTR *ppwszApplicationName)
{
FIXME("(%p, %p): stub\n", iface, ppwszApplicationName);
return E_NOTIMPL;
DWORD n;
TaskImpl *This = (TaskImpl *)iface;
TRACE("(%p, %p)\n", iface, ppwszApplicationName);
n = This->applicationName ? lstrlenW(This->applicationName) + 1 : 1;
*ppwszApplicationName = CoTaskMemAlloc(n * sizeof(WCHAR));
if (!*ppwszApplicationName)
return E_OUTOFMEMORY;
if (!This->applicationName)
*ppwszApplicationName[0] = 0;
else
lstrcpyW(*ppwszApplicationName, This->applicationName);
return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_SetParameters(
@ -571,6 +624,7 @@ HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
return E_OUTOFMEMORY;
}
lstrcpyW(This->taskName, pwszTaskName);
This->applicationName = NULL;
*ppObj = &This->lpVtbl;
InterlockedIncrement(&dll_ref);

View File

@ -118,10 +118,10 @@ static void test_SetApplicationName_GetApplicationName(void)
/* Attempt getting before setting application name */
hres = ITask_GetApplicationName(test_task, &stored_name);
todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
todo_wine ok(!lstrcmpW(stored_name, empty),
ok(!lstrcmpW(stored_name, empty),
"Got %s, expected empty string\n", dbgstr_w(stored_name));
CoTaskMemFree(stored_name);
}
@ -129,14 +129,14 @@ static void test_SetApplicationName_GetApplicationName(void)
/* Set application name to a non-existent application and then get
* the application name that is actually stored */
hres = ITask_SetApplicationName(test_task, non_application_name);
todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n",
ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(non_application_name), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(non_application_name);
todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
@ -144,14 +144,14 @@ static void test_SetApplicationName_GetApplicationName(void)
/* Set a valid application name with program type extension and then
* get the stored name */
hres = ITask_SetApplicationName(test_task, notepad_exe);
todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n",
ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(notepad_exe), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(notepad_exe);
todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
@ -159,13 +159,13 @@ static void test_SetApplicationName_GetApplicationName(void)
/* Set a valid application name without program type extension and
* then get the stored name */
hres = ITask_SetApplicationName(test_task, notepad);
todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(notepad), hres);
ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(notepad), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(notepad);
todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
@ -174,26 +174,26 @@ static void test_SetApplicationName_GetApplicationName(void)
* to a non-existant application and then get the name that is
* actually stored */
hres = ITask_SetApplicationName(test_task, non_application_name);
todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n",
ok(hres == S_OK, "Failed setting name %s: %08x\n",
dbgstr_w(non_application_name), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
full_name = path_resolve_name(non_application_name);
todo_wine ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
ok(!lstrcmpW(stored_name, full_name), "Got %s, expected %s\n",
dbgstr_w(stored_name), dbgstr_w(full_name));
CoTaskMemFree(stored_name);
}
/* Clear application name */
hres = ITask_SetApplicationName(test_task, empty);
todo_wine ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(empty), hres);
ok(hres == S_OK, "Failed setting name %s: %08x\n", dbgstr_w(empty), hres);
hres = ITask_GetApplicationName(test_task, &stored_name);
todo_wine ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
ok(hres == S_OK, "GetApplicationName failed: %08x\n", hres);
if (hres == S_OK)
{
todo_wine ok(!lstrcmpW(stored_name, empty),
ok(!lstrcmpW(stored_name, empty),
"Got %s, expected empty string\n", dbgstr_w(stored_name));
CoTaskMemFree(stored_name);
}