[PATCH 1/8] taskschd: Implement ExecAction::put_Id and ExecAction::get_Id.

Dmitry Timoshkov dmitry at baikal.ru
Fri Mar 30 03:57:55 CDT 2018


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/taskschd/task.c            | 27 +++++++++++++++++++++++----
 dlls/taskschd/tests/scheduler.c | 24 ++++++++++++++++++++++--
 2 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c
index 1b6a7015ee..19546c0d71 100644
--- a/dlls/taskschd/task.c
+++ b/dlls/taskschd/task.c
@@ -1679,6 +1679,7 @@ typedef struct
     WCHAR *path;
     WCHAR *directory;
     WCHAR *args;
+    WCHAR *id;
 } ExecAction;
 
 static inline ExecAction *impl_from_IExecAction(IExecAction *iface)
@@ -1703,6 +1704,7 @@ static ULONG WINAPI ExecAction_Release(IExecAction *iface)
         heap_free(action->path);
         heap_free(action->directory);
         heap_free(action->args);
+        heap_free(action->id);
         heap_free(action);
     }
 
@@ -1759,14 +1761,30 @@ static HRESULT WINAPI ExecAction_Invoke(IExecAction *iface, DISPID dispid, REFII
 
 static HRESULT WINAPI ExecAction_get_Id(IExecAction *iface, BSTR *id)
 {
-    FIXME("%p,%p: stub\n", iface, id);
-    return E_NOTIMPL;
+    ExecAction *action = impl_from_IExecAction(iface);
+
+    TRACE("%p,%p\n", iface, id);
+
+    if (!id) return E_POINTER;
+
+    if (!action->id) *id = NULL;
+    else if (!(*id = SysAllocString(action->id))) return E_OUTOFMEMORY;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ExecAction_put_Id(IExecAction *iface, BSTR id)
 {
-    FIXME("%p,%s: stub\n", iface, debugstr_w(id));
-    return E_NOTIMPL;
+    ExecAction *action = impl_from_IExecAction(iface);
+    WCHAR *str = NULL;
+
+    TRACE("%p,%s\n", iface, debugstr_w(id));
+
+    if (id && !(str = heap_strdupW((id)))) return E_OUTOFMEMORY;
+    heap_free(action->id);
+    action->id = str;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI ExecAction_get_Type(IExecAction *iface, TASK_ACTION_TYPE *type)
@@ -1896,6 +1914,7 @@ static HRESULT ExecAction_create(IExecAction **obj)
     action->path = NULL;
     action->directory = NULL;
     action->args = NULL;
+    action->id = NULL;
 
     *obj = &action->IExecAction_iface;
 
diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c
index 80bc1c9034..c0f691a53d 100644
--- a/dlls/taskschd/tests/scheduler.c
+++ b/dlls/taskschd/tests/scheduler.c
@@ -1306,12 +1306,13 @@ static void create_action(ITaskDefinition *taskdef)
     static WCHAR task1_exe[] = { 't','a','s','k','1','.','e','x','e',0 };
     static WCHAR workdir[] = { 'w','o','r','k','d','i','r',0 };
     static WCHAR args[] = { 'a','r','g','u','m','e','n','s',0 };
+    static WCHAR comment[] = { 'c','o','m','m','e','n','t',0 };
     HRESULT hr;
     IActionCollection *actions;
     IAction *action;
     IExecAction *exec_action;
     TASK_ACTION_TYPE type;
-    BSTR path;
+    BSTR path, str;
 
     hr = ITaskDefinition_get_Actions(taskdef, NULL);
     ok(hr == E_POINTER, "got %#x\n", hr);
@@ -1384,7 +1385,7 @@ static void create_action(ITaskDefinition *taskdef)
     ok(hr == S_OK, "put_Arguments error %#x\n", hr);
 
     hr = IExecAction_put_Arguments(exec_action, args);
-    ok(hr == S_OK, "put_WorkingDirectory error %#x\n", hr);
+    ok(hr == S_OK, "put_Arguments error %#x\n", hr);
 
     path = NULL;
     hr = IExecAction_get_Arguments(exec_action, &path);
@@ -1393,6 +1394,25 @@ static void create_action(ITaskDefinition *taskdef)
     ok(!lstrcmpW(path, args), "got %s\n", wine_dbgstr_w(path));
     SysFreeString(path);
 
+
+    str = (BSTR)0xdeadbeef;
+    hr = IExecAction_get_Id(exec_action, &str);
+    ok(hr == S_OK, "get_Id error %#x\n", hr);
+    ok(str == NULL, "id should be NULL\n");
+
+    hr = IExecAction_put_Id(exec_action, NULL);
+    ok(hr == S_OK, "put_Id error %#x\n", hr);
+
+    hr = IExecAction_put_Id(exec_action, comment);
+    ok(hr == S_OK, "put_Id error %#x\n", hr);
+
+    str = NULL;
+    hr = IExecAction_get_Id(exec_action, &str);
+    ok(hr == S_OK, "get_Id error %#x\n", hr);
+    ok(str != NULL, "should not be NULL\n");
+    ok(!lstrcmpW(str, comment), "got %s\n", wine_dbgstr_w(str));
+    SysFreeString(str);
+
     IExecAction_Release(exec_action);
     IAction_Release(action);
     IActionCollection_Release(actions);
-- 
2.16.2




More information about the wine-devel mailing list