Roy Shea : mstask: Implemented (Set|Get)Comment.

Alexandre Julliard julliard at winehq.org
Fri Aug 22 04:43:59 CDT 2008


Module: wine
Branch: master
Commit: 37708b1e5c9923817384f5d51b9bd5e887d956a9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=37708b1e5c9923817384f5d51b9bd5e887d956a9

Author: Roy Shea <royshea at gmail.com>
Date:   Thu Aug 21 13:05:43 2008 -0700

mstask: Implemented (Set|Get)Comment.

---

 dlls/mstask/mstask_private.h |    1 +
 dlls/mstask/task.c           |   46 ++++++++++++++++++++++++++++++++++++++---
 dlls/mstask/tests/task.c     |   22 ++++++++++----------
 3 files changed, 54 insertions(+), 15 deletions(-)

diff --git a/dlls/mstask/mstask_private.h b/dlls/mstask/mstask_private.h
index 8920707..05e7b0c 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 235c5fc..149869a 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 7d1b44d..349b110 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);
     }




More information about the wine-cvs mailing list