[2/2] taskschd: Add IRegisteredTaskCollection stub implementation.

Dmitry Timoshkov dmitry at baikal.ru
Fri Jan 31 02:21:32 CST 2014


---
 dlls/taskschd/Makefile.in          |   1 +
 dlls/taskschd/folder.c             |   9 ++-
 dlls/taskschd/regtask_collection.c | 161 +++++++++++++++++++++++++++++++++++++
 dlls/taskschd/taskschd_private.h   |   1 +
 4 files changed, 170 insertions(+), 2 deletions(-)
 create mode 100644 dlls/taskschd/regtask_collection.c

diff --git a/dlls/taskschd/Makefile.in b/dlls/taskschd/Makefile.in
index a1835fc..c85da9b 100644
--- a/dlls/taskschd/Makefile.in
+++ b/dlls/taskschd/Makefile.in
@@ -5,6 +5,7 @@ C_SRCS = \
 	folder.c \
 	folder_collection.c \
 	regtask.c \
+	regtask_collection.c \
 	task.c \
 	taskschd.c
 
diff --git a/dlls/taskschd/folder.c b/dlls/taskschd/folder.c
index 8d8a1a3..e5baf7b 100644
--- a/dlls/taskschd/folder.c
+++ b/dlls/taskschd/folder.c
@@ -295,8 +295,13 @@ static HRESULT WINAPI TaskFolder_GetTask(ITaskFolder *iface, BSTR path, IRegiste
 
 static HRESULT WINAPI TaskFolder_GetTasks(ITaskFolder *iface, LONG flags, IRegisteredTaskCollection **tasks)
 {
-    FIXME("%p,%x,%p: stub\n", iface, flags, tasks);
-    return E_NOTIMPL;
+    TaskFolder *folder = impl_from_ITaskFolder(iface);
+
+    TRACE("%p,%x,%p: stub\n", iface, flags, tasks);
+
+    if (!tasks) return E_POINTER;
+
+    return RegisteredTaskCollection_create(folder->path, tasks);
 }
 
 static HRESULT WINAPI TaskFolder_DeleteTask(ITaskFolder *iface, BSTR name, LONG flags)
diff --git a/dlls/taskschd/regtask_collection.c b/dlls/taskschd/regtask_collection.c
new file mode 100644
index 0000000..b034d40
--- /dev/null
+++ b/dlls/taskschd/regtask_collection.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2014 Dmitry Timoshkov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "taskschd.h"
+#include "taskschd_private.h"
+
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(taskschd);
+
+typedef struct
+{
+    IRegisteredTaskCollection IRegisteredTaskCollection_iface;
+    LONG ref;
+    WCHAR *path;
+} RegisteredTaskCollection;
+
+static inline RegisteredTaskCollection *impl_from_IRegisteredTaskCollection(IRegisteredTaskCollection *iface)
+{
+    return CONTAINING_RECORD(iface, RegisteredTaskCollection, IRegisteredTaskCollection_iface);
+}
+
+static ULONG WINAPI regtasks_AddRef(IRegisteredTaskCollection *iface)
+{
+    RegisteredTaskCollection *regtasks = impl_from_IRegisteredTaskCollection(iface);
+    return InterlockedIncrement(&regtasks->ref);
+}
+
+static ULONG WINAPI regtasks_Release(IRegisteredTaskCollection *iface)
+{
+    RegisteredTaskCollection *regtasks = impl_from_IRegisteredTaskCollection(iface);
+    LONG ref = InterlockedDecrement(&regtasks->ref);
+
+    if (!ref)
+    {
+        TRACE("destroying %p\n", iface);
+        heap_free(regtasks->path);
+        heap_free(regtasks);
+    }
+
+    return ref;
+}
+
+static HRESULT WINAPI regtasks_QueryInterface(IRegisteredTaskCollection *iface, REFIID riid, void **obj)
+{
+    if (!riid || !obj) return E_INVALIDARG;
+
+    TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
+
+    if (IsEqualGUID(riid, &IID_IRegisteredTaskCollection) ||
+        IsEqualGUID(riid, &IID_IDispatch) ||
+        IsEqualGUID(riid, &IID_IUnknown))
+    {
+        IRegisteredTaskCollection_AddRef(iface);
+        *obj = iface;
+        return S_OK;
+    }
+
+    FIXME("interface %s is not implemented\n", debugstr_guid(riid));
+    *obj = NULL;
+    return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI regtasks_GetTypeInfoCount(IRegisteredTaskCollection *iface, UINT *count)
+{
+    FIXME("%p,%p: stub\n", iface, count);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI regtasks_GetTypeInfo(IRegisteredTaskCollection *iface, UINT index, LCID lcid, ITypeInfo **info)
+{
+    FIXME("%p,%u,%u,%p: stub\n", iface, index, lcid, info);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI regtasks_GetIDsOfNames(IRegisteredTaskCollection *iface, REFIID riid, LPOLESTR *names,
+                                                UINT count, LCID lcid, DISPID *dispid)
+{
+    FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI regtasks_Invoke(IRegisteredTaskCollection *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
+                                         DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
+{
+    FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
+          params, result, excepinfo, argerr);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI regtasks_get_Count(IRegisteredTaskCollection *iface, LONG *count)
+{
+    FIXME("%p,%p: stub\n", iface, count);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI regtasks_get_Item(IRegisteredTaskCollection *iface, VARIANT index, IRegisteredTask **regtask)
+{
+    FIXME("%p,%s,%p: stub\n", iface, debugstr_variant(&index), regtask);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI regtasks_get__NewEnum(IRegisteredTaskCollection *iface, IUnknown **penum)
+{
+    FIXME("%p,%p: stub\n", iface, penum);
+    return E_NOTIMPL;
+}
+
+static const IRegisteredTaskCollectionVtbl RegisteredTaskCollection_vtbl =
+{
+    regtasks_QueryInterface,
+    regtasks_AddRef,
+    regtasks_Release,
+    regtasks_GetTypeInfoCount,
+    regtasks_GetTypeInfo,
+    regtasks_GetIDsOfNames,
+    regtasks_Invoke,
+    regtasks_get_Count,
+    regtasks_get_Item,
+    regtasks_get__NewEnum
+};
+
+HRESULT RegisteredTaskCollection_create(const WCHAR *path, IRegisteredTaskCollection **obj)
+{
+    RegisteredTaskCollection *regtasks;
+
+    regtasks = heap_alloc(sizeof(*regtasks));
+    if (!regtasks) return E_OUTOFMEMORY;
+
+    regtasks->IRegisteredTaskCollection_iface.lpVtbl = &RegisteredTaskCollection_vtbl;
+    regtasks->ref = 1;
+    regtasks->path = heap_strdupW(path);
+    *obj = &regtasks->IRegisteredTaskCollection_iface;
+
+    TRACE("created %p\n", *obj);
+
+    return S_OK;
+}
diff --git a/dlls/taskschd/taskschd_private.h b/dlls/taskschd/taskschd_private.h
index b1f5ff9..df15903 100644
--- a/dlls/taskschd/taskschd_private.h
+++ b/dlls/taskschd/taskschd_private.h
@@ -22,6 +22,7 @@ HRESULT TaskService_create(void **obj) DECLSPEC_HIDDEN;
 HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **obj, BOOL create) DECLSPEC_HIDDEN;
 HRESULT TaskFolderCollection_create(const WCHAR *path, ITaskFolderCollection **obj) DECLSPEC_HIDDEN;
 HRESULT RegisteredTask_create(const WCHAR *path, IRegisteredTask **obj) DECLSPEC_HIDDEN;
+HRESULT RegisteredTaskCollection_create(const WCHAR *path, IRegisteredTaskCollection **obj) DECLSPEC_HIDDEN;
 
 const char *debugstr_variant(const VARIANT *v) DECLSPEC_HIDDEN;
 
-- 
1.8.5.3




More information about the wine-patches mailing list