mstask: Implement ITaskScheduler::AddWorkItem().

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2018-04-25 11:34:52 +08:00 committed by Alexandre Julliard
parent bf635fd4f7
commit f429c8188b
2 changed files with 23 additions and 14 deletions

View File

@ -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(

View File

@ -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);
}