Commit f429c818 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

mstask: Implement ITaskScheduler::AddWorkItem().

parent bf635fd4
......@@ -331,13 +331,30 @@ static HRESULT WINAPI MSTASK_ITaskScheduler_NewWorkItem(
return TaskConstructor(This->service, task_name, (ITask **)task);
}
static HRESULT WINAPI MSTASK_ITaskScheduler_AddWorkItem(
ITaskScheduler* iface,
LPCWSTR pwszTaskName,
IScheduledWorkItem *pWorkItem)
static HRESULT WINAPI MSTASK_ITaskScheduler_AddWorkItem(ITaskScheduler *iface, LPCWSTR name, IScheduledWorkItem *item)
{
FIXME("%p, %s, %p: stub\n", iface, debugstr_w(pwszTaskName), pWorkItem);
return E_NOTIMPL;
static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 };
static const WCHAR jobW[] = { '.','j','o','b',0 };
WCHAR task_name[MAX_PATH];
IPersistFile *pfile;
HRESULT hr;
TRACE("%p, %s, %p\n", iface, debugstr_w(name), item);
if (strchrW(name, '.')) return E_INVALIDARG;
GetWindowsDirectoryW(task_name, MAX_PATH);
lstrcatW(task_name, tasksW);
lstrcatW(task_name, name);
lstrcatW(task_name, jobW);
hr = IScheduledWorkItem_QueryInterface(item, &IID_IPersistFile, (void **)&pfile);
if (hr == S_OK)
{
hr = IPersistFile_Save(pfile, task_name, TRUE);
IPersistFile_Release(pfile);
}
return hr;
}
static HRESULT WINAPI MSTASK_ITaskScheduler_IsOfType(
......
......@@ -343,30 +343,23 @@ static void test_task_storage(void)
ok(task2 == (ITask *)0xdeadbeef, "task should not be set to NULL\n");
hr = ITaskScheduler_AddWorkItem(scheduler, Task1, (IScheduledWorkItem *)task);
todo_wine
ok(hr == S_OK, "AddWorkItem error %#x\n", hr);
curfile = get_task_curfile(task);
todo_wine
ok(file_exists(curfile), "curfile should exist\n");
hr = ITaskScheduler_AddWorkItem(scheduler, Task1, (IScheduledWorkItem *)task);
todo_wine
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "wrong error %#x\n", hr);
curfile = get_task_curfile(task);
todo_wine
ok(file_exists(curfile), "curfile should exist\n");
ITask_Release(task);
task = NULL;
hr = ITaskScheduler_Activate(scheduler, Task1, &IID_ITask, (IUnknown **)&task);
todo_wine
ok(hr == S_OK, "Activate error %#x\n", hr);
todo_wine
ok(task != NULL, "task should not be set to NULL\n");
if (task == NULL) goto fail;
curfile2 = get_task_curfile(task);
ok(file_exists(curfile2), "curfile2 should exist\n");
......@@ -380,7 +373,6 @@ todo_wine
CoTaskMemFree(curfile);
ITask_Release(task);
fail:
ITaskScheduler_Release(scheduler);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment