Commit 37708b1e authored by Roy Shea's avatar Roy Shea Committed by Alexandre Julliard

mstask: Implemented (Set|Get)Comment.

parent 2f95e512
......@@ -60,6 +60,7 @@ typedef struct
LPWSTR taskName;
LPWSTR applicationName;
LPWSTR parameters;
LPWSTR comment;
} TaskImpl;
extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj);
......
......@@ -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->comment);
HeapFree(GetProcessHeap(), 0, This->parameters);
HeapFree(GetProcessHeap(), 0, This->taskName);
HeapFree(GetProcessHeap(), 0, This);
......@@ -219,16 +220,52 @@ static HRESULT WINAPI MSTASK_ITask_SetComment(
ITask* iface,
LPCWSTR pwszComment)
{
FIXME("(%p, %s): stub\n", iface, debugstr_w(pwszComment));
return E_NOTIMPL;
DWORD n;
TaskImpl *This = (TaskImpl *)iface;
LPWSTR tmp_comment;
TRACE("(%p, %s)\n", iface, debugstr_w(pwszComment));
/* Empty comment */
if (pwszComment[0] == 0)
{
HeapFree(GetProcessHeap(), 0, This->comment);
This->comment = NULL;
return S_OK;
}
/* Set to pwszComment */
n = (lstrlenW(pwszComment) + 1);
tmp_comment = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR));
if (!tmp_comment)
return E_OUTOFMEMORY;
lstrcpyW(tmp_comment, pwszComment);
HeapFree(GetProcessHeap(), 0, This->comment);
This->comment = tmp_comment;
return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_GetComment(
ITask* iface,
LPWSTR *ppwszComment)
{
FIXME("(%p, %p): stub\n", iface, ppwszComment);
return E_NOTIMPL;
DWORD n;
TaskImpl *This = (TaskImpl *)iface;
TRACE("(%p, %p)\n", iface, ppwszComment);
n = This->comment ? lstrlenW(This->comment) + 1 : 1;
*ppwszComment = CoTaskMemAlloc(n * sizeof(WCHAR));
if (!*ppwszComment)
return E_OUTOFMEMORY;
if (!This->comment)
*ppwszComment[0] = 0;
else
lstrcpyW(*ppwszComment, This->comment);
return S_OK;
}
static HRESULT WINAPI MSTASK_ITask_SetCreator(
......@@ -682,6 +719,7 @@ HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj)
lstrcpyW(This->taskName, pwszTaskName);
This->applicationName = NULL;
This->parameters = NULL;
This->comment = NULL;
*ppObj = &This->lpVtbl;
InterlockedIncrement(&dll_ref);
......
......@@ -319,49 +319,49 @@ static void test_SetComment_GetComment(void)
/* Get comment before setting it*/
hres = ITask_GetComment(test_task, &comment);
todo_wine ok(hres == S_OK, "GetComment failed: %08x\n", hres);
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
if (hres == S_OK)
{
todo_wine ok(!lstrcmpW(comment, empty),
ok(!lstrcmpW(comment, empty),
"Got %s, expected empty string\n", dbgstr_w(comment));
CoTaskMemFree(comment);
}
/* Set comment to a simple string */
hres = ITask_SetComment(test_task, comment_a);
todo_wine ok(hres == S_OK, "Failed setting comment %s: %08x\n",
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
dbgstr_w(comment_a), hres);
hres = ITask_GetComment(test_task, &comment);
todo_wine ok(hres == S_OK, "GetComment failed: %08x\n", hres);
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
if (hres == S_OK)
{
todo_wine ok(!lstrcmpW(comment, comment_a), "Got %s, expected %s\n",
ok(!lstrcmpW(comment, comment_a), "Got %s, expected %s\n",
dbgstr_w(comment), dbgstr_w(comment_a));
CoTaskMemFree(comment);
}
/* Update comment to a different simple string */
hres = ITask_SetComment(test_task, comment_b);
todo_wine ok(hres == S_OK, "Failed setting comment %s: %08x\n",
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
dbgstr_w(comment_b), hres);
hres = ITask_GetComment(test_task, &comment);
todo_wine ok(hres == S_OK, "GetComment failed: %08x\n", hres);
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
if (hres == S_OK)
{
todo_wine ok(!lstrcmpW(comment, comment_b), "Got %s, expected %s\n",
ok(!lstrcmpW(comment, comment_b), "Got %s, expected %s\n",
dbgstr_w(comment), dbgstr_w(comment_b));
CoTaskMemFree(comment);
}
/* Clear comment */
hres = ITask_SetComment(test_task, empty);
todo_wine ok(hres == S_OK, "Failed setting comment %s: %08x\n",
ok(hres == S_OK, "Failed setting comment %s: %08x\n",
dbgstr_w(empty), hres);
hres = ITask_GetComment(test_task, &comment);
todo_wine ok(hres == S_OK, "GetComment failed: %08x\n", hres);
ok(hres == S_OK, "GetComment failed: %08x\n", hres);
if (hres == S_OK)
{
todo_wine ok(!lstrcmpW(comment, empty),
ok(!lstrcmpW(comment, empty),
"Got %s, expected empty string\n", dbgstr_w(comment));
CoTaskMemFree(comment);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment