taskschd: Add initial implementation of ITaskDefinition::put_XmlText.
This commit is contained in:
parent
433598c10b
commit
e29f64533f
|
@ -1,5 +1,5 @@
|
|||
MODULE = taskschd.dll
|
||||
IMPORTS = advapi32 oleaut32
|
||||
IMPORTS = oleaut32 ole32 advapi32 xmllite
|
||||
|
||||
C_SRCS = \
|
||||
folder.c \
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "winbase.h"
|
||||
#include "initguid.h"
|
||||
#include "objbase.h"
|
||||
#include "xmllite.h"
|
||||
#include "taskschd.h"
|
||||
#include "taskschd_private.h"
|
||||
|
||||
|
@ -756,10 +757,248 @@ static HRESULT WINAPI TaskDefinition_get_XmlText(ITaskDefinition *iface, BSTR *x
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const WCHAR Task[] = {'T','a','s','k',0};
|
||||
static const WCHAR version[] = {'v','e','r','s','i','o','n',0};
|
||||
static const WCHAR v1_0[] = {'1','.','0',0};
|
||||
static const WCHAR v1_1[] = {'1','.','1',0};
|
||||
static const WCHAR v1_2[] = {'1','.','2',0};
|
||||
static const WCHAR v1_3[] = {'1','.','3',0};
|
||||
static const WCHAR xmlns[] = {'x','m','l','n','s',0};
|
||||
static const WCHAR task_ns[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','w','i','n','d','o','w','s','/','2','0','0','4','/','0','2','/','m','i','t','/','t','a','s','k',0};
|
||||
static const WCHAR RegistrationInfo[] = {'R','e','g','i','s','t','r','a','t','i','o','n','I','n','f','o',0};
|
||||
static const WCHAR Settings[] = {'S','e','t','t','i','n','g','s',0};
|
||||
static const WCHAR Triggers[] = {'T','r','i','g','g','e','r','s',0};
|
||||
static const WCHAR Principals[] = {'P','r','i','n','c','i','p','a','l','s',0};
|
||||
static const WCHAR Actions[] = {'A','c','t','i','o','n','s',0};
|
||||
|
||||
static HRESULT read_triggers(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
FIXME("stub\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT read_principals(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
FIXME("stub\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT read_actions(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
FIXME("stub\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT read_settings(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
FIXME("stub\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT read_registration_info(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
FIXME("stub\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT read_task_attributes(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
HRESULT hr;
|
||||
ITaskSettings *taskset;
|
||||
const WCHAR *name;
|
||||
const WCHAR *value;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
hr = ITaskDefinition_get_Settings(taskdef, &taskset);
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
hr = IXmlReader_MoveToFirstAttribute(reader);
|
||||
|
||||
while (hr == S_OK)
|
||||
{
|
||||
hr = IXmlReader_GetLocalName(reader, &name, NULL);
|
||||
if (hr != S_OK) break;
|
||||
|
||||
hr = IXmlReader_GetValue(reader, &value, NULL);
|
||||
if (hr != S_OK) break;
|
||||
|
||||
TRACE("%s=%s\n", debugstr_w(name), debugstr_w(value));
|
||||
|
||||
if (!lstrcmpW(name, version))
|
||||
{
|
||||
TASK_COMPATIBILITY compatibility = TASK_COMPATIBILITY_V2;
|
||||
|
||||
if (!lstrcmpW(value, v1_0))
|
||||
compatibility = TASK_COMPATIBILITY_AT;
|
||||
else if (!lstrcmpW(value, v1_1))
|
||||
compatibility = TASK_COMPATIBILITY_V1;
|
||||
else if (!lstrcmpW(value, v1_2))
|
||||
compatibility = TASK_COMPATIBILITY_V2;
|
||||
else if (!lstrcmpW(value, v1_3))
|
||||
compatibility = TASK_COMPATIBILITY_V2_1;
|
||||
else
|
||||
FIXME("unknown version %s\n", debugstr_w(value));
|
||||
|
||||
ITaskSettings_put_Compatibility(taskset, compatibility);
|
||||
}
|
||||
else if (!lstrcmpW(name, xmlns))
|
||||
{
|
||||
if (lstrcmpW(value, task_ns))
|
||||
FIXME("unknown namespace %s\n", debugstr_w(value));
|
||||
}
|
||||
else
|
||||
FIXME("unhandled Task attribute %s\n", debugstr_w(name));
|
||||
|
||||
hr = IXmlReader_MoveToNextAttribute(reader);
|
||||
}
|
||||
|
||||
ITaskSettings_Release(taskset);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT read_task(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
HRESULT hr;
|
||||
XmlNodeType type;
|
||||
const WCHAR *name;
|
||||
|
||||
while (IXmlReader_Read(reader, &type) == S_OK)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case XmlNodeType_EndElement:
|
||||
hr = IXmlReader_GetLocalName(reader, &name, NULL);
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
TRACE("/%s\n", debugstr_w(name));
|
||||
|
||||
if (!lstrcmpW(name, Task))
|
||||
return S_OK;
|
||||
|
||||
break;
|
||||
|
||||
case XmlNodeType_Element:
|
||||
hr = IXmlReader_GetLocalName(reader, &name, NULL);
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
TRACE("Element: %s\n", debugstr_w(name));
|
||||
|
||||
if (!lstrcmpW(name, RegistrationInfo))
|
||||
hr = read_registration_info(reader, taskdef);
|
||||
else if (!lstrcmpW(name, Settings))
|
||||
hr = read_settings(reader, taskdef);
|
||||
else if (!lstrcmpW(name, Triggers))
|
||||
hr = read_triggers(reader, taskdef);
|
||||
else if (!lstrcmpW(name, Principals))
|
||||
hr = read_principals(reader, taskdef);
|
||||
else if (!lstrcmpW(name, Actions))
|
||||
hr = read_actions(reader, taskdef);
|
||||
else
|
||||
FIXME("unhandled Task element %s\n", debugstr_w(name));
|
||||
|
||||
if (hr != S_OK) return hr;
|
||||
break;
|
||||
|
||||
case XmlNodeType_Comment:
|
||||
case XmlNodeType_Whitespace:
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("unhandled Task node type %d\n", type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WARN("Task was not terminated\n");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
static HRESULT read_xml(IXmlReader *reader, ITaskDefinition *taskdef)
|
||||
{
|
||||
HRESULT hr;
|
||||
XmlNodeType type;
|
||||
const WCHAR *name;
|
||||
|
||||
while (IXmlReader_Read(reader, &type) == S_OK)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case XmlNodeType_XmlDeclaration:
|
||||
TRACE("XmlDeclaration\n");
|
||||
break;
|
||||
|
||||
case XmlNodeType_Element:
|
||||
hr = IXmlReader_GetLocalName(reader, &name, NULL);
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
TRACE("Element: %s\n", debugstr_w(name));
|
||||
|
||||
if (!lstrcmpW(name, Task))
|
||||
{
|
||||
hr = read_task_attributes(reader, taskdef);
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
return read_task(reader, taskdef);
|
||||
}
|
||||
else
|
||||
FIXME("unhandled XML element %s\n", debugstr_w(name));
|
||||
|
||||
break;
|
||||
|
||||
case XmlNodeType_Comment:
|
||||
case XmlNodeType_Whitespace:
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("unhandled XML node type %d\n", type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WARN("Task definition was not found\n");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI TaskDefinition_put_XmlText(ITaskDefinition *iface, BSTR xml)
|
||||
{
|
||||
FIXME("%p,%p: stub\n", iface, xml);
|
||||
return E_NOTIMPL;
|
||||
HRESULT hr;
|
||||
IStream *stream;
|
||||
IXmlReader *reader;
|
||||
HGLOBAL hmem;
|
||||
void *buf;
|
||||
|
||||
TRACE("%p,%s\n", iface, debugstr_w(xml));
|
||||
|
||||
hmem = GlobalAlloc(0, lstrlenW(xml) * sizeof(WCHAR));
|
||||
if (!hmem) return E_OUTOFMEMORY;
|
||||
|
||||
buf = GlobalLock(hmem);
|
||||
memcpy(buf, xml, lstrlenW(xml) * sizeof(WCHAR));
|
||||
GlobalUnlock(hmem);
|
||||
|
||||
hr = CreateStreamOnHGlobal(hmem, TRUE, &stream);
|
||||
if (hr != S_OK)
|
||||
{
|
||||
GlobalFree(hmem);
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
|
||||
if (hr != S_OK)
|
||||
{
|
||||
IStream_Release(stream);
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
|
||||
if (hr == S_OK)
|
||||
hr = read_xml(reader, iface);
|
||||
|
||||
IXmlReader_Release(reader);
|
||||
IStream_Release(stream);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static const ITaskDefinitionVtbl TaskDefinition_vtbl =
|
||||
|
|
|
@ -734,7 +734,6 @@ static void test_GetTask(void)
|
|||
MultiByteToWideChar(CP_ACP, 0, xml1, -1, xmlW, sizeof(xmlW)/sizeof(xmlW[0]));
|
||||
|
||||
hr = ITaskFolder_RegisterTask(root, Wine_Task1, xmlW, TASK_CREATE, v_null, v_null, TASK_LOGON_NONE, v_null, NULL);
|
||||
todo_wine
|
||||
ok(hr == S_OK, "RegisterTask error %#x\n", hr);
|
||||
|
||||
hr = ITaskFolder_RegisterTask(root, Wine_Task1, xmlW, TASK_CREATE, v_null, v_null, TASK_LOGON_NONE, v_null, &task1);
|
||||
|
@ -742,10 +741,7 @@ todo_wine
|
|||
ok(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr);
|
||||
|
||||
hr = ITaskFolder_RegisterTask(root, Wine_Task1, xmlW, TASK_CREATE_OR_UPDATE, v_null, v_null, TASK_LOGON_NONE, v_null, &task1);
|
||||
todo_wine
|
||||
ok(hr == S_OK, "RegisterTask error %#x\n", hr);
|
||||
/* FIXME: Remove once implemented */
|
||||
if (hr != S_OK) goto failed;
|
||||
|
||||
hr = IRegisteredTask_get_Name(task1, NULL);
|
||||
todo_wine
|
||||
|
|
Loading…
Reference in New Issue