taskschd: Make ITaskFolder::CreateFolder, ITaskFolder::GetFolder and ITaskFolder::DeleteFolder use the RPC API.
This commit is contained in:
parent
3b63733bcb
commit
39e972b573
|
@ -25,6 +25,7 @@
|
|||
#include "winreg.h"
|
||||
#include "objbase.h"
|
||||
#include "taskschd.h"
|
||||
#include "schrpc.h"
|
||||
#include "taskschd_private.h"
|
||||
|
||||
#include "wine/unicode.h"
|
||||
|
@ -273,9 +274,47 @@ static HRESULT WINAPI TaskFolder_CreateFolder(ITaskFolder *iface, BSTR path, VAR
|
|||
return hr;
|
||||
}
|
||||
|
||||
static WCHAR *get_full_path(const WCHAR *parent, const WCHAR *path)
|
||||
{
|
||||
static const WCHAR bslash[] = { '\\', 0 };
|
||||
WCHAR *folder_path;
|
||||
int len = 0;
|
||||
|
||||
if (path) len = strlenW(path);
|
||||
|
||||
if (parent) len += strlenW(parent);
|
||||
|
||||
/* +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)
|
||||
strcpyW(folder_path, parent);
|
||||
|
||||
if (path && *path)
|
||||
{
|
||||
len = strlenW(folder_path);
|
||||
if (!len || folder_path[len - 1] != '\\')
|
||||
strcatW(folder_path, bslash);
|
||||
|
||||
while (*path == '\\') path++;
|
||||
strcatW(folder_path, path);
|
||||
}
|
||||
|
||||
len = strlenW(folder_path);
|
||||
if (!len)
|
||||
strcatW(folder_path, bslash);
|
||||
|
||||
return folder_path;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI TaskFolder_DeleteFolder(ITaskFolder *iface, BSTR name, LONG flags)
|
||||
{
|
||||
TaskFolder *folder = impl_from_ITaskFolder(iface);
|
||||
WCHAR *folder_path;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("%p,%s,%x\n", iface, debugstr_w(name), flags);
|
||||
|
||||
|
@ -284,6 +323,13 @@ static HRESULT WINAPI TaskFolder_DeleteFolder(ITaskFolder *iface, BSTR name, LON
|
|||
if (flags)
|
||||
FIXME("unsupported flags %x\n", flags);
|
||||
|
||||
folder_path = get_full_path(folder->path, name);
|
||||
if (!folder_path) return E_OUTOFMEMORY;
|
||||
|
||||
hr = SchRpcDelete(folder_path, 0);
|
||||
heap_free(folder_path);
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
return reg_delete_folder(folder->path, name);
|
||||
}
|
||||
|
||||
|
@ -403,43 +449,50 @@ static const ITaskFolderVtbl TaskFolder_vtbl =
|
|||
|
||||
HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **obj, BOOL create)
|
||||
{
|
||||
static const WCHAR bslash[] = { '\\', 0 };
|
||||
TaskFolder *folder;
|
||||
WCHAR *folder_path;
|
||||
int len = 0;
|
||||
HRESULT hr;
|
||||
HKEY hfolder;
|
||||
|
||||
if (path)
|
||||
{
|
||||
len = strlenW(path);
|
||||
int len = strlenW(path);
|
||||
if (len && path[len - 1] == '\\') return ERROR_INVALID_NAME;
|
||||
}
|
||||
|
||||
if (parent) len += strlenW(parent);
|
||||
|
||||
/* +1 if parent is not '\' terminated */
|
||||
folder_path = heap_alloc((len + 2) * sizeof(WCHAR));
|
||||
folder_path = get_full_path(parent, path);
|
||||
if (!folder_path) return E_OUTOFMEMORY;
|
||||
|
||||
folder_path[0] = 0;
|
||||
|
||||
if (parent)
|
||||
strcpyW(folder_path, parent);
|
||||
|
||||
if (path && *path)
|
||||
if (create)
|
||||
{
|
||||
len = strlenW(folder_path);
|
||||
if (!len || folder_path[len - 1] != '\\')
|
||||
strcatW(folder_path, bslash);
|
||||
hr = SchRpcCreateFolder(folder_path, NULL, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD start_index, count, i;
|
||||
TASK_NAMES names;
|
||||
|
||||
while (*path == '\\') path++;
|
||||
strcatW(folder_path, path);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
len = strlenW(folder_path);
|
||||
if (!len)
|
||||
strcatW(folder_path, bslash);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
heap_free(folder_path);
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = create ? reg_create_folder(folder_path, &hfolder) : reg_open_folder(folder_path, &hfolder);
|
||||
if (hr)
|
||||
|
|
|
@ -341,7 +341,6 @@ todo_wine
|
|||
ITaskFolder_Release(subfolder);
|
||||
|
||||
hr = ITaskFolder_DeleteFolder(folder, Wine, 0);
|
||||
todo_wine
|
||||
ok(hr == HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY), "expected ERROR_DIR_NOT_EMPTY, got %#x\n", hr);
|
||||
|
||||
hr = ITaskFolder_DeleteFolder(folder, Wine_Folder1_Folder2, 0);
|
||||
|
|
Loading…
Reference in New Issue