2014-01-17 09:59:49 +01:00
|
|
|
/*
|
|
|
|
* 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"
|
2014-01-20 08:04:16 +01:00
|
|
|
#include "winreg.h"
|
2014-01-17 09:59:49 +01:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "taskschd.h"
|
2014-04-07 06:14:19 +02:00
|
|
|
#include "schrpc.h"
|
2014-01-17 09:59:49 +01:00
|
|
|
#include "taskschd_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(taskschd);
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ITaskFolder ITaskFolder_iface;
|
|
|
|
LONG ref;
|
2014-01-17 10:00:08 +01:00
|
|
|
WCHAR *path;
|
2014-01-17 09:59:49 +01:00
|
|
|
} TaskFolder;
|
|
|
|
|
|
|
|
static inline TaskFolder *impl_from_ITaskFolder(ITaskFolder *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, TaskFolder, ITaskFolder_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TaskFolder_AddRef(ITaskFolder *iface)
|
|
|
|
{
|
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
return InterlockedIncrement(&folder->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI TaskFolder_Release(ITaskFolder *iface)
|
|
|
|
{
|
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&folder->ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
|
|
|
TRACE("destroying %p\n", iface);
|
2014-01-28 03:54:36 +01:00
|
|
|
heap_free(folder->path);
|
|
|
|
heap_free(folder);
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_QueryInterface(ITaskFolder *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_ITaskFolder) ||
|
|
|
|
IsEqualGUID(riid, &IID_IDispatch) ||
|
|
|
|
IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
ITaskFolder_AddRef(iface);
|
|
|
|
*obj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
|
2014-02-05 07:09:11 +01:00
|
|
|
*obj = NULL;
|
2014-01-17 09:59:49 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_GetTypeInfoCount(ITaskFolder *iface, UINT *count)
|
|
|
|
{
|
|
|
|
FIXME("%p,%p: stub\n", iface, count);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_GetTypeInfo(ITaskFolder *iface, UINT index, LCID lcid, ITypeInfo **info)
|
|
|
|
{
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("%p,%u,%lu,%p: stub\n", iface, index, lcid, info);
|
2014-01-17 09:59:49 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_GetIDsOfNames(ITaskFolder *iface, REFIID riid, LPOLESTR *names,
|
|
|
|
UINT count, LCID lcid, DISPID *dispid)
|
|
|
|
{
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
|
2014-01-17 09:59:49 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_Invoke(ITaskFolder *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
|
|
|
|
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
|
|
|
|
{
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
|
2014-01-17 09:59:49 +01:00
|
|
|
params, result, excepinfo, argerr);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_get_Name(ITaskFolder *iface, BSTR *name)
|
|
|
|
{
|
2014-01-20 08:05:50 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
const WCHAR *p_name;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", iface, name);
|
|
|
|
|
|
|
|
if (!name) return E_POINTER;
|
|
|
|
|
2019-06-24 10:10:24 +02:00
|
|
|
p_name = wcsrchr(folder->path, '\\');
|
2014-01-20 08:05:50 +01:00
|
|
|
if (!p_name)
|
|
|
|
p_name = folder->path;
|
|
|
|
else
|
|
|
|
if (p_name[1] != 0) p_name++;
|
|
|
|
|
|
|
|
*name = SysAllocString(p_name);
|
|
|
|
if (!*name) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return S_OK;
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_get_Path(ITaskFolder *iface, BSTR *path)
|
|
|
|
{
|
2014-01-17 10:00:08 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", iface, path);
|
|
|
|
|
|
|
|
if (!path) return E_POINTER;
|
|
|
|
|
|
|
|
*path = SysAllocString(folder->path);
|
|
|
|
if (!*path) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return S_OK;
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
2014-01-20 08:06:28 +01:00
|
|
|
static HRESULT WINAPI TaskFolder_GetFolder(ITaskFolder *iface, BSTR path, ITaskFolder **new_folder)
|
2014-01-17 09:59:49 +01:00
|
|
|
{
|
2014-01-20 08:06:28 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
|
|
|
|
TRACE("%p,%s,%p\n", iface, debugstr_w(path), folder);
|
|
|
|
|
|
|
|
if (!path) return E_INVALIDARG;
|
|
|
|
if (!new_folder) return E_POINTER;
|
|
|
|
|
2014-01-20 08:07:46 +01:00
|
|
|
return TaskFolder_create(folder->path, path, new_folder, FALSE);
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_GetFolders(ITaskFolder *iface, LONG flags, ITaskFolderCollection **folders)
|
|
|
|
{
|
2014-01-28 03:54:29 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
|
2022-02-18 09:17:22 +01:00
|
|
|
TRACE("%p,%lx,%p: stub\n", iface, flags, folders);
|
2014-01-28 03:54:29 +01:00
|
|
|
|
2014-02-05 07:08:32 +01:00
|
|
|
if (!folders) return E_POINTER;
|
|
|
|
|
2014-01-28 03:54:29 +01:00
|
|
|
if (flags)
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("unsupported flags %lx\n", flags);
|
2014-01-28 03:54:29 +01:00
|
|
|
|
|
|
|
return TaskFolderCollection_create(folder->path, folders);
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
2014-01-20 08:07:46 +01:00
|
|
|
static inline BOOL is_variant_null(const VARIANT *var)
|
2014-01-17 09:59:49 +01:00
|
|
|
{
|
2014-01-20 08:07:46 +01:00
|
|
|
return V_VT(var) == VT_EMPTY || V_VT(var) == VT_NULL ||
|
|
|
|
(V_VT(var) == VT_BSTR && (V_BSTR(var) == NULL || !*V_BSTR(var)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_CreateFolder(ITaskFolder *iface, BSTR path, VARIANT sddl, ITaskFolder **new_folder)
|
|
|
|
{
|
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
ITaskFolder *tmp_folder = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%s,%s,%p\n", iface, debugstr_w(path), debugstr_variant(&sddl), folder);
|
|
|
|
|
|
|
|
if (!path) return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!new_folder) new_folder = &tmp_folder;
|
|
|
|
|
|
|
|
if (!is_variant_null(&sddl))
|
|
|
|
FIXME("security descriptor %s is ignored\n", debugstr_variant(&sddl));
|
|
|
|
|
|
|
|
hr = TaskFolder_create(folder->path, path, new_folder, TRUE);
|
|
|
|
if (tmp_folder)
|
|
|
|
ITaskFolder_Release(tmp_folder);
|
|
|
|
|
|
|
|
return hr;
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
2014-04-08 08:49:23 +02:00
|
|
|
WCHAR *get_full_path(const WCHAR *parent, const WCHAR *path)
|
2014-04-07 06:14:19 +02:00
|
|
|
{
|
|
|
|
WCHAR *folder_path;
|
|
|
|
int len = 0;
|
|
|
|
|
2019-06-24 10:10:24 +02:00
|
|
|
if (path) len = lstrlenW(path);
|
2014-04-07 06:14:19 +02:00
|
|
|
|
2019-06-24 10:10:24 +02:00
|
|
|
if (parent) len += lstrlenW(parent);
|
2014-04-07 06:14:19 +02:00
|
|
|
|
|
|
|
/* +1 if parent is not '\' terminated */
|
|
|
|
folder_path = heap_alloc((len + 2) * sizeof(WCHAR));
|
|
|
|
if (!folder_path) return NULL;
|
|
|
|
|
|
|
|
folder_path[0] = 0;
|
|
|
|
|
|
|
|
if (parent)
|
2019-06-24 10:10:24 +02:00
|
|
|
lstrcpyW(folder_path, parent);
|
2014-04-07 06:14:19 +02:00
|
|
|
|
|
|
|
if (path && *path)
|
|
|
|
{
|
2019-06-24 10:10:24 +02:00
|
|
|
len = lstrlenW(folder_path);
|
2014-04-07 06:14:19 +02:00
|
|
|
if (!len || folder_path[len - 1] != '\\')
|
2020-11-17 00:55:17 +01:00
|
|
|
lstrcatW(folder_path, L"\\");
|
2014-04-07 06:14:19 +02:00
|
|
|
|
|
|
|
while (*path == '\\') path++;
|
2019-06-24 10:10:24 +02:00
|
|
|
lstrcatW(folder_path, path);
|
2014-04-07 06:14:19 +02:00
|
|
|
}
|
|
|
|
|
2019-06-24 10:10:24 +02:00
|
|
|
len = lstrlenW(folder_path);
|
2014-04-07 06:14:19 +02:00
|
|
|
if (!len)
|
2020-11-17 00:55:17 +01:00
|
|
|
lstrcatW(folder_path, L"\\");
|
2014-04-07 06:14:19 +02:00
|
|
|
|
|
|
|
return folder_path;
|
|
|
|
}
|
|
|
|
|
2014-01-17 09:59:49 +01:00
|
|
|
static HRESULT WINAPI TaskFolder_DeleteFolder(ITaskFolder *iface, BSTR name, LONG flags)
|
|
|
|
{
|
2014-01-20 08:04:58 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
2014-04-07 06:14:19 +02:00
|
|
|
WCHAR *folder_path;
|
|
|
|
HRESULT hr;
|
2014-01-20 08:04:58 +01:00
|
|
|
|
2022-02-18 09:17:22 +01:00
|
|
|
TRACE("%p,%s,%lx\n", iface, debugstr_w(name), flags);
|
2014-01-20 08:04:58 +01:00
|
|
|
|
2014-01-28 03:54:24 +01:00
|
|
|
if (!name || !*name) return E_ACCESSDENIED;
|
|
|
|
|
2014-01-20 08:04:58 +01:00
|
|
|
if (flags)
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("unsupported flags %lx\n", flags);
|
2014-01-20 08:04:58 +01:00
|
|
|
|
2014-04-07 06:14:19 +02:00
|
|
|
folder_path = get_full_path(folder->path, name);
|
|
|
|
if (!folder_path) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = SchRpcDelete(folder_path, 0);
|
|
|
|
heap_free(folder_path);
|
2014-04-07 06:14:41 +02:00
|
|
|
return hr;
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
2014-02-11 08:18:58 +01:00
|
|
|
static HRESULT WINAPI TaskFolder_GetTask(ITaskFolder *iface, BSTR name, IRegisteredTask **task)
|
2014-01-17 09:59:49 +01:00
|
|
|
{
|
2014-02-11 08:18:58 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
2014-04-08 08:49:23 +02:00
|
|
|
ITaskDefinition *taskdef;
|
|
|
|
HRESULT hr;
|
2014-02-11 08:18:58 +01:00
|
|
|
|
|
|
|
TRACE("%p,%s,%p\n", iface, debugstr_w(name), task);
|
2014-01-31 09:21:27 +01:00
|
|
|
|
|
|
|
if (!task) return E_POINTER;
|
|
|
|
|
2014-04-08 08:49:23 +02:00
|
|
|
hr = TaskDefinition_create(&taskdef);
|
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
|
|
|
|
hr = RegisteredTask_create(folder->path, name, taskdef, 0, 0, task, FALSE);
|
|
|
|
if (hr != S_OK)
|
|
|
|
ITaskDefinition_Release(taskdef);
|
|
|
|
return hr;
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_GetTasks(ITaskFolder *iface, LONG flags, IRegisteredTaskCollection **tasks)
|
|
|
|
{
|
2014-02-05 07:10:00 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
|
2022-02-18 09:17:22 +01:00
|
|
|
TRACE("%p,%lx,%p: stub\n", iface, flags, tasks);
|
2014-02-05 07:10:00 +01:00
|
|
|
|
|
|
|
if (!tasks) return E_POINTER;
|
|
|
|
|
|
|
|
return RegisteredTaskCollection_create(folder->path, tasks);
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_DeleteTask(ITaskFolder *iface, BSTR name, LONG flags)
|
|
|
|
{
|
2014-04-08 08:49:17 +02:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
WCHAR *folder_path;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-18 09:17:22 +01:00
|
|
|
TRACE("%p,%s,%lx\n", iface, debugstr_w(name), flags);
|
2014-04-08 08:49:17 +02:00
|
|
|
|
|
|
|
if (!name || !*name) return E_ACCESSDENIED;
|
|
|
|
|
|
|
|
if (flags)
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("unsupported flags %lx\n", flags);
|
2014-04-08 08:49:17 +02:00
|
|
|
|
|
|
|
folder_path = get_full_path(folder->path, name);
|
|
|
|
if (!folder_path) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = SchRpcDelete(folder_path, 0);
|
|
|
|
heap_free(folder_path);
|
|
|
|
return hr;
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
2014-02-11 08:18:58 +01:00
|
|
|
static HRESULT WINAPI TaskFolder_RegisterTask(ITaskFolder *iface, BSTR name, BSTR xml, LONG flags,
|
2014-01-17 09:59:49 +01:00
|
|
|
VARIANT user, VARIANT password, TASK_LOGON_TYPE logon,
|
|
|
|
VARIANT sddl, IRegisteredTask **task)
|
2014-02-17 06:10:04 +01:00
|
|
|
{
|
2014-04-08 08:49:23 +02:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
IRegisteredTask *regtask = NULL;
|
2014-02-17 06:10:04 +01:00
|
|
|
ITaskDefinition *taskdef;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-18 09:17:22 +01:00
|
|
|
TRACE("%p,%s,%s,%lx,%s,%s,%d,%s,%p\n", iface, debugstr_w(name), debugstr_w(xml), flags,
|
2014-02-17 06:10:04 +01:00
|
|
|
debugstr_variant(&user), debugstr_variant(&password), logon, debugstr_variant(&sddl), task);
|
|
|
|
|
2014-02-27 08:53:44 +01:00
|
|
|
if (!xml) return HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER);
|
|
|
|
|
2014-04-08 08:49:23 +02:00
|
|
|
if (!task) task = ®task;
|
|
|
|
|
2014-02-17 06:10:04 +01:00
|
|
|
hr = TaskDefinition_create(&taskdef);
|
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
|
|
|
|
hr = ITaskDefinition_put_XmlText(taskdef, xml);
|
|
|
|
if (hr == S_OK)
|
2014-04-08 08:49:23 +02:00
|
|
|
hr = RegisteredTask_create(folder->path, name, taskdef, flags, logon, task, TRUE);
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
ITaskDefinition_Release(taskdef);
|
|
|
|
|
|
|
|
if (regtask)
|
|
|
|
IRegisteredTask_Release(regtask);
|
2014-02-17 06:10:04 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_RegisterTaskDefinition(ITaskFolder *iface, BSTR name, ITaskDefinition *definition, LONG flags,
|
|
|
|
VARIANT user, VARIANT password, TASK_LOGON_TYPE logon,
|
|
|
|
VARIANT sddl, IRegisteredTask **task)
|
2014-01-17 09:59:49 +01:00
|
|
|
{
|
2014-02-11 08:18:58 +01:00
|
|
|
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
|
|
|
IRegisteredTask *regtask = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("%p,%s,%p,%lx,%s,%s,%d,%s,%p: stub\n", iface, debugstr_w(name), definition, flags,
|
2014-01-17 09:59:49 +01:00
|
|
|
debugstr_variant(&user), debugstr_variant(&password), logon, debugstr_variant(&sddl), task);
|
2014-02-11 08:18:58 +01:00
|
|
|
|
|
|
|
if (!is_variant_null(&sddl))
|
|
|
|
FIXME("security descriptor %s is ignored\n", debugstr_variant(&sddl));
|
|
|
|
|
|
|
|
if (!is_variant_null(&user) || !is_variant_null(&password))
|
|
|
|
FIXME("user/password are ignored\n");
|
|
|
|
|
|
|
|
if (!task) task = ®task;
|
|
|
|
|
2014-04-08 08:49:23 +02:00
|
|
|
ITaskDefinition_AddRef(definition);
|
|
|
|
hr = RegisteredTask_create(folder->path, name, definition, flags, logon, task, TRUE);
|
|
|
|
if (hr != S_OK)
|
|
|
|
ITaskDefinition_Release(definition);
|
2014-02-11 08:18:58 +01:00
|
|
|
|
|
|
|
if (regtask)
|
|
|
|
IRegisteredTask_Release(regtask);
|
|
|
|
|
|
|
|
return hr;
|
2014-01-17 09:59:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_GetSecurityDescriptor(ITaskFolder *iface, LONG info, BSTR *sddl)
|
|
|
|
{
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("%p,%lx,%p: stub\n", iface, info, sddl);
|
2014-01-17 09:59:49 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TaskFolder_SetSecurityDescriptor(ITaskFolder *iface, BSTR sddl, LONG flags)
|
|
|
|
{
|
2022-02-18 09:17:22 +01:00
|
|
|
FIXME("%p,%s,%lx: stub\n", iface, debugstr_w(sddl), flags);
|
2014-01-17 09:59:49 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ITaskFolderVtbl TaskFolder_vtbl =
|
|
|
|
{
|
|
|
|
TaskFolder_QueryInterface,
|
|
|
|
TaskFolder_AddRef,
|
|
|
|
TaskFolder_Release,
|
|
|
|
TaskFolder_GetTypeInfoCount,
|
|
|
|
TaskFolder_GetTypeInfo,
|
|
|
|
TaskFolder_GetIDsOfNames,
|
|
|
|
TaskFolder_Invoke,
|
|
|
|
TaskFolder_get_Name,
|
|
|
|
TaskFolder_get_Path,
|
|
|
|
TaskFolder_GetFolder,
|
|
|
|
TaskFolder_GetFolders,
|
|
|
|
TaskFolder_CreateFolder,
|
|
|
|
TaskFolder_DeleteFolder,
|
|
|
|
TaskFolder_GetTask,
|
|
|
|
TaskFolder_GetTasks,
|
|
|
|
TaskFolder_DeleteTask,
|
|
|
|
TaskFolder_RegisterTask,
|
|
|
|
TaskFolder_RegisterTaskDefinition,
|
|
|
|
TaskFolder_GetSecurityDescriptor,
|
|
|
|
TaskFolder_SetSecurityDescriptor
|
|
|
|
};
|
|
|
|
|
2014-01-20 08:07:46 +01:00
|
|
|
HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **obj, BOOL create)
|
2014-01-17 09:59:49 +01:00
|
|
|
{
|
|
|
|
TaskFolder *folder;
|
2014-01-17 10:00:08 +01:00
|
|
|
WCHAR *folder_path;
|
2014-01-20 08:04:16 +01:00
|
|
|
HRESULT hr;
|
2014-01-17 10:00:08 +01:00
|
|
|
|
|
|
|
if (path)
|
|
|
|
{
|
2019-06-24 10:10:24 +02:00
|
|
|
int len = lstrlenW(path);
|
2016-09-13 17:46:10 +02:00
|
|
|
if (len && path[len - 1] == '\\') return HRESULT_FROM_WIN32(ERROR_INVALID_NAME);
|
2014-01-17 10:00:08 +01:00
|
|
|
}
|
|
|
|
|
2014-04-07 06:14:19 +02:00
|
|
|
folder_path = get_full_path(parent, path);
|
2014-01-17 10:00:08 +01:00
|
|
|
if (!folder_path) return E_OUTOFMEMORY;
|
|
|
|
|
2014-04-07 06:14:19 +02:00
|
|
|
if (create)
|
2014-01-17 10:00:08 +01:00
|
|
|
{
|
2014-04-07 06:14:19 +02:00
|
|
|
hr = SchRpcCreateFolder(folder_path, NULL, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD start_index, count, i;
|
|
|
|
TASK_NAMES names;
|
|
|
|
|
|
|
|
start_index = 0;
|
|
|
|
names = NULL;
|
|
|
|
hr = SchRpcEnumFolders(folder_path, 0, &start_index, 0, &count, &names);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
MIDL_user_free(names[i]);
|
|
|
|
MIDL_user_free(names);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
|
|
|
|
hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
|
|
|
|
}
|
2014-01-17 10:00:08 +01:00
|
|
|
}
|
2014-01-17 09:59:49 +01:00
|
|
|
|
2014-04-07 06:14:19 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
heap_free(folder_path);
|
|
|
|
return hr;
|
|
|
|
}
|
2014-01-20 08:07:46 +01:00
|
|
|
|
2014-01-28 03:54:36 +01:00
|
|
|
folder = heap_alloc(sizeof(*folder));
|
2014-01-17 10:00:08 +01:00
|
|
|
if (!folder)
|
|
|
|
{
|
2014-01-28 03:54:36 +01:00
|
|
|
heap_free(folder_path);
|
2014-01-17 10:00:08 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2014-01-17 09:59:49 +01:00
|
|
|
|
|
|
|
folder->ITaskFolder_iface.lpVtbl = &TaskFolder_vtbl;
|
|
|
|
folder->ref = 1;
|
2014-01-17 10:00:08 +01:00
|
|
|
folder->path = folder_path;
|
2014-01-17 09:59:49 +01:00
|
|
|
*obj = &folder->ITaskFolder_iface;
|
|
|
|
|
|
|
|
TRACE("created %p\n", *obj);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|