Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/mstask/task_scheduler.c | 29 +++++++++++++++++++++++------ dlls/mstask/tests/task_scheduler.c | 8 -------- 2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/dlls/mstask/task_scheduler.c b/dlls/mstask/task_scheduler.c index dd6eaf6b38..c890cb6472 100644 --- a/dlls/mstask/task_scheduler.c +++ b/dlls/mstask/task_scheduler.c @@ -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( diff --git a/dlls/mstask/tests/task_scheduler.c b/dlls/mstask/tests/task_scheduler.c index fbee5ecb66..8482972e9b 100644 --- a/dlls/mstask/tests/task_scheduler.c +++ b/dlls/mstask/tests/task_scheduler.c @@ -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); }