diff --git a/dlls/mstask/mstask_private.h b/dlls/mstask/mstask_private.h index 89207071b74..05e7b0c8c0f 100644 --- a/dlls/mstask/mstask_private.h +++ b/dlls/mstask/mstask_private.h @@ -60,6 +60,7 @@ typedef struct LPWSTR taskName; LPWSTR applicationName; LPWSTR parameters; + LPWSTR comment; } TaskImpl; extern HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj); diff --git a/dlls/mstask/task.c b/dlls/mstask/task.c index 235c5fc90f6..149869a0184 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->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); diff --git a/dlls/mstask/tests/task.c b/dlls/mstask/tests/task.c index 7d1b44dea0f..349b110d82f 100644 --- a/dlls/mstask/tests/task.c +++ b/dlls/mstask/tests/task.c @@ -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); }