2 * Copyright 2013 Dmitry Timoshkov
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "taskschd_private.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(taskschd
);
39 IDailyTrigger IDailyTrigger_iface
;
42 WCHAR
*start_boundary
;
46 static inline DailyTrigger
*impl_from_IDailyTrigger(IDailyTrigger
*iface
)
48 return CONTAINING_RECORD(iface
, DailyTrigger
, IDailyTrigger_iface
);
51 static HRESULT WINAPI
DailyTrigger_QueryInterface(IDailyTrigger
*iface
, REFIID riid
, void **ppv
)
53 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
55 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
57 if(IsEqualGUID(&IID_IUnknown
, riid
) ||
58 IsEqualGUID(&IID_IDispatch
, riid
) ||
59 IsEqualGUID(&IID_ITrigger
, riid
) ||
60 IsEqualGUID(&IID_IDailyTrigger
, riid
))
62 *ppv
= &This
->IDailyTrigger_iface
;
66 FIXME("unsupported riid %s\n", debugstr_guid(riid
));
71 IUnknown_AddRef((IUnknown
*)*ppv
);
75 static ULONG WINAPI
DailyTrigger_AddRef(IDailyTrigger
*iface
)
77 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
78 LONG ref
= InterlockedIncrement(&This
->ref
);
80 TRACE("(%p) ref=%d\n", This
, ref
);
85 static ULONG WINAPI
DailyTrigger_Release(IDailyTrigger
*iface
)
87 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
88 LONG ref
= InterlockedDecrement(&This
->ref
);
90 TRACE("(%p) ref=%d\n", This
, ref
);
94 TRACE("destroying %p\n", iface
);
95 heap_free(This
->start_boundary
);
102 static HRESULT WINAPI
DailyTrigger_GetTypeInfoCount(IDailyTrigger
*iface
, UINT
*count
)
104 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
105 FIXME("(%p)->(%p)\n", This
, count
);
109 static HRESULT WINAPI
DailyTrigger_GetTypeInfo(IDailyTrigger
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
111 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
112 FIXME("(%p)->(%u %u %p)\n", This
, index
, lcid
, info
);
116 static HRESULT WINAPI
DailyTrigger_GetIDsOfNames(IDailyTrigger
*iface
, REFIID riid
, LPOLESTR
*names
,
117 UINT count
, LCID lcid
, DISPID
*dispid
)
119 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
120 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
124 static HRESULT WINAPI
DailyTrigger_Invoke(IDailyTrigger
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
125 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
127 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
128 FIXME("(%p)->(%d %s %x %x %p %p %p %p)\n", This
, dispid
, debugstr_guid(riid
), lcid
, flags
,
129 params
, result
, excepinfo
, argerr
);
133 static HRESULT WINAPI
DailyTrigger_get_Type(IDailyTrigger
*iface
, TASK_TRIGGER_TYPE2
*type
)
135 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
136 FIXME("(%p)->(%p)\n", This
, type
);
140 static HRESULT WINAPI
DailyTrigger_get_Id(IDailyTrigger
*iface
, BSTR
*id
)
142 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
143 FIXME("(%p)->(%p)\n", This
, id
);
147 static HRESULT WINAPI
DailyTrigger_put_Id(IDailyTrigger
*iface
, BSTR id
)
149 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
150 FIXME("(%p)->(%s)\n", This
, debugstr_w(id
));
154 static HRESULT WINAPI
DailyTrigger_get_Repetition(IDailyTrigger
*iface
, IRepetitionPattern
**repeat
)
156 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
157 FIXME("(%p)->(%p)\n", This
, repeat
);
161 static HRESULT WINAPI
DailyTrigger_put_Repetition(IDailyTrigger
*iface
, IRepetitionPattern
*repeat
)
163 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
164 FIXME("(%p)->(%p)\n", This
, repeat
);
168 static HRESULT WINAPI
DailyTrigger_get_ExecutionTimeLimit(IDailyTrigger
*iface
, BSTR
*limit
)
170 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
171 FIXME("(%p)->(%p)\n", This
, limit
);
175 static HRESULT WINAPI
DailyTrigger_put_ExecutionTimeLimit(IDailyTrigger
*iface
, BSTR limit
)
177 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
178 FIXME("(%p)->(%s)\n", This
, debugstr_w(limit
));
182 static HRESULT WINAPI
DailyTrigger_get_StartBoundary(IDailyTrigger
*iface
, BSTR
*start
)
184 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
186 TRACE("(%p)->(%p)\n", This
, start
);
188 if (!start
) return E_POINTER
;
190 if (!This
->start_boundary
) *start
= NULL
;
191 else if (!(*start
= SysAllocString(This
->start_boundary
))) return E_OUTOFMEMORY
;
196 static HRESULT WINAPI
DailyTrigger_put_StartBoundary(IDailyTrigger
*iface
, BSTR start
)
198 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
201 TRACE("(%p)->(%s)\n", This
, debugstr_w(start
));
203 if (start
&& !(str
= heap_strdupW(start
))) return E_OUTOFMEMORY
;
204 heap_free(This
->start_boundary
);
205 This
->start_boundary
= str
;
210 static HRESULT WINAPI
DailyTrigger_get_EndBoundary(IDailyTrigger
*iface
, BSTR
*end
)
212 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
213 FIXME("(%p)->(%p)\n", This
, end
);
217 static HRESULT WINAPI
DailyTrigger_put_EndBoundary(IDailyTrigger
*iface
, BSTR end
)
219 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
220 FIXME("(%p)->(%s)\n", This
, debugstr_w(end
));
224 static HRESULT WINAPI
DailyTrigger_get_Enabled(IDailyTrigger
*iface
, VARIANT_BOOL
*enabled
)
226 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
228 TRACE("(%p)->(%p)\n", This
, enabled
);
230 if (!enabled
) return E_POINTER
;
232 *enabled
= This
->enabled
? VARIANT_TRUE
: VARIANT_FALSE
;
236 static HRESULT WINAPI
DailyTrigger_put_Enabled(IDailyTrigger
*iface
, VARIANT_BOOL enabled
)
238 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
240 TRACE("(%p)->(%x)\n", This
, enabled
);
242 This
->enabled
= enabled
? TRUE
: FALSE
;
246 static HRESULT WINAPI
DailyTrigger_get_DaysInterval(IDailyTrigger
*iface
, short *days
)
248 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
250 TRACE("(%p)->(%p)\n", This
, days
);
252 *days
= This
->interval
;
256 static HRESULT WINAPI
DailyTrigger_put_DaysInterval(IDailyTrigger
*iface
, short days
)
258 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
260 TRACE("(%p)->(%d)\n", This
, days
);
265 This
->interval
= days
;
269 static HRESULT WINAPI
DailyTrigger_get_RandomDelay(IDailyTrigger
*iface
, BSTR
*pRandomDelay
)
271 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
272 FIXME("(%p)->(%p)\n", This
, pRandomDelay
);
276 static HRESULT WINAPI
DailyTrigger_put_RandomDelay(IDailyTrigger
*iface
, BSTR randomDelay
)
278 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
279 FIXME("(%p)->(%s)\n", This
, debugstr_w(randomDelay
));
283 static const IDailyTriggerVtbl DailyTrigger_vtbl
= {
284 DailyTrigger_QueryInterface
,
286 DailyTrigger_Release
,
287 DailyTrigger_GetTypeInfoCount
,
288 DailyTrigger_GetTypeInfo
,
289 DailyTrigger_GetIDsOfNames
,
291 DailyTrigger_get_Type
,
294 DailyTrigger_get_Repetition
,
295 DailyTrigger_put_Repetition
,
296 DailyTrigger_get_ExecutionTimeLimit
,
297 DailyTrigger_put_ExecutionTimeLimit
,
298 DailyTrigger_get_StartBoundary
,
299 DailyTrigger_put_StartBoundary
,
300 DailyTrigger_get_EndBoundary
,
301 DailyTrigger_put_EndBoundary
,
302 DailyTrigger_get_Enabled
,
303 DailyTrigger_put_Enabled
,
304 DailyTrigger_get_DaysInterval
,
305 DailyTrigger_put_DaysInterval
,
306 DailyTrigger_get_RandomDelay
,
307 DailyTrigger_put_RandomDelay
310 static HRESULT
DailyTrigger_create(ITrigger
**trigger
)
312 DailyTrigger
*daily_trigger
;
314 daily_trigger
= heap_alloc(sizeof(*daily_trigger
));
316 return E_OUTOFMEMORY
;
318 daily_trigger
->IDailyTrigger_iface
.lpVtbl
= &DailyTrigger_vtbl
;
319 daily_trigger
->ref
= 1;
320 daily_trigger
->interval
= 1;
321 daily_trigger
->start_boundary
= NULL
;
322 daily_trigger
->enabled
= TRUE
;
324 *trigger
= (ITrigger
*)&daily_trigger
->IDailyTrigger_iface
;
330 ITriggerCollection ITriggerCollection_iface
;
332 } trigger_collection
;
334 static inline trigger_collection
*impl_from_ITriggerCollection(ITriggerCollection
*iface
)
336 return CONTAINING_RECORD(iface
, trigger_collection
, ITriggerCollection_iface
);
339 static HRESULT WINAPI
TriggerCollection_QueryInterface(ITriggerCollection
*iface
, REFIID riid
, void **ppv
)
341 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
343 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
345 if(IsEqualGUID(&IID_IUnknown
, riid
) ||
346 IsEqualGUID(&IID_IDispatch
, riid
) ||
347 IsEqualGUID(&IID_ITriggerCollection
, riid
)) {
348 *ppv
= &This
->ITriggerCollection_iface
;
350 FIXME("unimplemented interface %s\n", debugstr_guid(riid
));
352 return E_NOINTERFACE
;
355 IUnknown_AddRef((IUnknown
*)*ppv
);
359 static ULONG WINAPI
TriggerCollection_AddRef(ITriggerCollection
*iface
)
361 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
362 LONG ref
= InterlockedIncrement(&This
->ref
);
364 TRACE("(%p) ref=%d\n", This
, ref
);
369 static ULONG WINAPI
TriggerCollection_Release(ITriggerCollection
*iface
)
371 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
372 LONG ref
= InterlockedDecrement(&This
->ref
);
374 TRACE("(%p) ref=%d\n", This
, ref
);
382 static HRESULT WINAPI
TriggerCollection_GetTypeInfoCount(ITriggerCollection
*iface
, UINT
*count
)
384 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
385 FIXME("(%p)->(%p)\n", This
, count
);
389 static HRESULT WINAPI
TriggerCollection_GetTypeInfo(ITriggerCollection
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
391 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
392 FIXME("(%p)->(%u %u %p)\n", This
, index
, lcid
, info
);
396 static HRESULT WINAPI
TriggerCollection_GetIDsOfNames(ITriggerCollection
*iface
, REFIID riid
, LPOLESTR
*names
,
397 UINT count
, LCID lcid
, DISPID
*dispid
)
399 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
400 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
404 static HRESULT WINAPI
TriggerCollection_Invoke(ITriggerCollection
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
405 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
407 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
408 FIXME("(%p)->(%d %s %x %x %p %p %p %p)\n", This
, dispid
, debugstr_guid(riid
), lcid
, flags
,
409 params
, result
, excepinfo
, argerr
);
413 static HRESULT WINAPI
TriggerCollection_get_Count(ITriggerCollection
*iface
, LONG
*count
)
415 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
416 FIXME("(%p)->(%p)\n", This
, count
);
420 static HRESULT WINAPI
TriggerCollection_get_Item(ITriggerCollection
*iface
, LONG index
, ITrigger
**trigger
)
422 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
423 FIXME("(%p)->(%d %p)\n", This
, index
, trigger
);
427 static HRESULT WINAPI
TriggerCollection_get__NewEnum(ITriggerCollection
*iface
, IUnknown
**penum
)
429 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
430 FIXME("(%p)->(%p)\n", This
, penum
);
434 static HRESULT WINAPI
TriggerCollection_Create(ITriggerCollection
*iface
, TASK_TRIGGER_TYPE2 type
, ITrigger
**trigger
)
436 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
438 TRACE("(%p)->(%d %p)\n", This
, type
, trigger
);
441 case TASK_TRIGGER_DAILY
:
442 return DailyTrigger_create(trigger
);
444 FIXME("Unimplemented type %d\n", type
);
451 static HRESULT WINAPI
TriggerCollection_Remove(ITriggerCollection
*iface
, VARIANT index
)
453 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
454 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&index
));
458 static HRESULT WINAPI
TriggerCollection_Clear(ITriggerCollection
*iface
)
460 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
461 FIXME("(%p)\n", This
);
465 static const ITriggerCollectionVtbl TriggerCollection_vtbl
= {
466 TriggerCollection_QueryInterface
,
467 TriggerCollection_AddRef
,
468 TriggerCollection_Release
,
469 TriggerCollection_GetTypeInfoCount
,
470 TriggerCollection_GetTypeInfo
,
471 TriggerCollection_GetIDsOfNames
,
472 TriggerCollection_Invoke
,
473 TriggerCollection_get_Count
,
474 TriggerCollection_get_Item
,
475 TriggerCollection_get__NewEnum
,
476 TriggerCollection_Create
,
477 TriggerCollection_Remove
,
478 TriggerCollection_Clear
483 IRegistrationInfo IRegistrationInfo_iface
;
485 WCHAR
*description
, *author
, *version
, *date
, *documentation
, *uri
, *source
;
488 static inline registration_info
*impl_from_IRegistrationInfo(IRegistrationInfo
*iface
)
490 return CONTAINING_RECORD(iface
, registration_info
, IRegistrationInfo_iface
);
493 static ULONG WINAPI
RegistrationInfo_AddRef(IRegistrationInfo
*iface
)
495 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
496 return InterlockedIncrement(®info
->ref
);
499 static ULONG WINAPI
RegistrationInfo_Release(IRegistrationInfo
*iface
)
501 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
502 LONG ref
= InterlockedDecrement(®info
->ref
);
506 TRACE("destroying %p\n", iface
);
507 heap_free(reginfo
->description
);
508 heap_free(reginfo
->author
);
509 heap_free(reginfo
->version
);
510 heap_free(reginfo
->date
);
511 heap_free(reginfo
->documentation
);
512 heap_free(reginfo
->uri
);
513 heap_free(reginfo
->source
);
520 static HRESULT WINAPI
RegistrationInfo_QueryInterface(IRegistrationInfo
*iface
, REFIID riid
, void **obj
)
522 if (!riid
|| !obj
) return E_INVALIDARG
;
524 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
526 if (IsEqualGUID(riid
, &IID_IRegistrationInfo
) ||
527 IsEqualGUID(riid
, &IID_IDispatch
) ||
528 IsEqualGUID(riid
, &IID_IUnknown
))
530 IRegistrationInfo_AddRef(iface
);
535 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
537 return E_NOINTERFACE
;
540 static HRESULT WINAPI
RegistrationInfo_GetTypeInfoCount(IRegistrationInfo
*iface
, UINT
*count
)
542 FIXME("%p,%p: stub\n", iface
, count
);
546 static HRESULT WINAPI
RegistrationInfo_GetTypeInfo(IRegistrationInfo
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
548 FIXME("%p,%u,%u,%p: stub\n", iface
, index
, lcid
, info
);
552 static HRESULT WINAPI
RegistrationInfo_GetIDsOfNames(IRegistrationInfo
*iface
, REFIID riid
, LPOLESTR
*names
,
553 UINT count
, LCID lcid
, DISPID
*dispid
)
555 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
559 static HRESULT WINAPI
RegistrationInfo_Invoke(IRegistrationInfo
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
560 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
562 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
563 params
, result
, excepinfo
, argerr
);
567 static HRESULT WINAPI
RegistrationInfo_get_Description(IRegistrationInfo
*iface
, BSTR
*description
)
569 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
571 TRACE("%p,%p\n", iface
, description
);
573 if (!description
) return E_POINTER
;
575 if (!reginfo
->description
) *description
= NULL
;
576 else if (!(*description
= SysAllocString(reginfo
->description
))) return E_OUTOFMEMORY
;
581 static HRESULT WINAPI
RegistrationInfo_put_Description(IRegistrationInfo
*iface
, BSTR description
)
583 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
585 TRACE("%p,%s\n", iface
, debugstr_w(description
));
587 if (!description
) return E_INVALIDARG
;
589 heap_free(reginfo
->description
);
590 reginfo
->description
= heap_strdupW(description
);
591 /* FIXME: update XML on the server side */
592 return reginfo
->description
? S_OK
: E_OUTOFMEMORY
;
595 static HRESULT WINAPI
RegistrationInfo_get_Author(IRegistrationInfo
*iface
, BSTR
*author
)
597 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
599 TRACE("%p,%p\n", iface
, author
);
601 if (!author
) return E_POINTER
;
603 if (!reginfo
->author
) *author
= NULL
;
604 else if (!(*author
= SysAllocString(reginfo
->author
))) return E_OUTOFMEMORY
;
609 static HRESULT WINAPI
RegistrationInfo_put_Author(IRegistrationInfo
*iface
, BSTR author
)
611 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
613 TRACE("%p,%s\n", iface
, debugstr_w(author
));
615 if (!author
) return E_INVALIDARG
;
617 heap_free(reginfo
->author
);
618 reginfo
->author
= heap_strdupW(author
);
619 /* FIXME: update XML on the server side */
620 return reginfo
->author
? S_OK
: E_OUTOFMEMORY
;
623 static HRESULT WINAPI
RegistrationInfo_get_Version(IRegistrationInfo
*iface
, BSTR
*version
)
625 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
627 TRACE("%p,%p\n", iface
, version
);
629 if (!version
) return E_POINTER
;
631 if (!reginfo
->version
) *version
= NULL
;
632 else if (!(*version
= SysAllocString(reginfo
->version
))) return E_OUTOFMEMORY
;
637 static HRESULT WINAPI
RegistrationInfo_put_Version(IRegistrationInfo
*iface
, BSTR version
)
639 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
641 TRACE("%p,%s\n", iface
, debugstr_w(version
));
643 if (!version
) return E_INVALIDARG
;
645 heap_free(reginfo
->version
);
646 reginfo
->version
= heap_strdupW(version
);
647 /* FIXME: update XML on the server side */
648 return reginfo
->version
? S_OK
: E_OUTOFMEMORY
;
651 static HRESULT WINAPI
RegistrationInfo_get_Date(IRegistrationInfo
*iface
, BSTR
*date
)
653 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
655 TRACE("%p,%p\n", iface
, date
);
657 if (!date
) return E_POINTER
;
659 if (!reginfo
->date
) *date
= NULL
;
660 else if (!(*date
= SysAllocString(reginfo
->date
))) return E_OUTOFMEMORY
;
665 static HRESULT WINAPI
RegistrationInfo_put_Date(IRegistrationInfo
*iface
, BSTR date
)
667 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
669 TRACE("%p,%s\n", iface
, debugstr_w(date
));
671 if (!date
) return E_INVALIDARG
;
673 heap_free(reginfo
->date
);
674 reginfo
->date
= heap_strdupW(date
);
675 /* FIXME: update XML on the server side */
676 return reginfo
->date
? S_OK
: E_OUTOFMEMORY
;
679 static HRESULT WINAPI
RegistrationInfo_get_Documentation(IRegistrationInfo
*iface
, BSTR
*doc
)
681 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
683 TRACE("%p,%p\n", iface
, doc
);
685 if (!doc
) return E_POINTER
;
687 if (!reginfo
->documentation
) *doc
= NULL
;
688 else if (!(*doc
= SysAllocString(reginfo
->documentation
))) return E_OUTOFMEMORY
;
693 static HRESULT WINAPI
RegistrationInfo_put_Documentation(IRegistrationInfo
*iface
, BSTR doc
)
695 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
697 TRACE("%p,%s\n", iface
, debugstr_w(doc
));
699 if (!doc
) return E_INVALIDARG
;
701 heap_free(reginfo
->documentation
);
702 reginfo
->documentation
= heap_strdupW(doc
);
703 /* FIXME: update XML on the server side */
704 return reginfo
->documentation
? S_OK
: E_OUTOFMEMORY
;
707 static HRESULT WINAPI
RegistrationInfo_get_XmlText(IRegistrationInfo
*iface
, BSTR
*xml
)
709 FIXME("%p,%p: stub\n", iface
, xml
);
713 static HRESULT WINAPI
RegistrationInfo_put_XmlText(IRegistrationInfo
*iface
, BSTR xml
)
715 FIXME("%p,%s: stub\n", iface
, debugstr_w(xml
));
719 static HRESULT WINAPI
RegistrationInfo_get_URI(IRegistrationInfo
*iface
, BSTR
*uri
)
721 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
723 TRACE("%p,%p\n", iface
, uri
);
725 if (!uri
) return E_POINTER
;
727 if (!reginfo
->uri
) *uri
= NULL
;
728 else if (!(*uri
= SysAllocString(reginfo
->uri
))) return E_OUTOFMEMORY
;
733 static HRESULT WINAPI
RegistrationInfo_put_URI(IRegistrationInfo
*iface
, BSTR uri
)
735 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
737 TRACE("%p,%s\n", iface
, debugstr_w(uri
));
739 if (!uri
) return E_INVALIDARG
;
741 heap_free(reginfo
->uri
);
742 reginfo
->uri
= heap_strdupW(uri
);
743 /* FIXME: update XML on the server side */
744 return reginfo
->uri
? S_OK
: E_OUTOFMEMORY
;
747 static HRESULT WINAPI
RegistrationInfo_get_SecurityDescriptor(IRegistrationInfo
*iface
, VARIANT
*sddl
)
749 FIXME("%p,%p: stub\n", iface
, sddl
);
753 static HRESULT WINAPI
RegistrationInfo_put_SecurityDescriptor(IRegistrationInfo
*iface
, VARIANT sddl
)
755 FIXME("%p,%s: stub\n", iface
, debugstr_variant(&sddl
));
759 static HRESULT WINAPI
RegistrationInfo_get_Source(IRegistrationInfo
*iface
, BSTR
*source
)
761 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
763 TRACE("%p,%p\n", iface
, source
);
765 if (!source
) return E_POINTER
;
767 if (!reginfo
->source
) *source
= NULL
;
768 else if (!(*source
= SysAllocString(reginfo
->source
))) return E_OUTOFMEMORY
;
773 static HRESULT WINAPI
RegistrationInfo_put_Source(IRegistrationInfo
*iface
, BSTR source
)
775 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
777 TRACE("%p,%s\n", iface
, debugstr_w(source
));
779 if (!source
) return E_INVALIDARG
;
781 heap_free(reginfo
->source
);
782 reginfo
->source
= heap_strdupW(source
);
783 /* FIXME: update XML on the server side */
784 return reginfo
->source
? S_OK
: E_OUTOFMEMORY
;
787 static const IRegistrationInfoVtbl RegistrationInfo_vtbl
=
789 RegistrationInfo_QueryInterface
,
790 RegistrationInfo_AddRef
,
791 RegistrationInfo_Release
,
792 RegistrationInfo_GetTypeInfoCount
,
793 RegistrationInfo_GetTypeInfo
,
794 RegistrationInfo_GetIDsOfNames
,
795 RegistrationInfo_Invoke
,
796 RegistrationInfo_get_Description
,
797 RegistrationInfo_put_Description
,
798 RegistrationInfo_get_Author
,
799 RegistrationInfo_put_Author
,
800 RegistrationInfo_get_Version
,
801 RegistrationInfo_put_Version
,
802 RegistrationInfo_get_Date
,
803 RegistrationInfo_put_Date
,
804 RegistrationInfo_get_Documentation
,
805 RegistrationInfo_put_Documentation
,
806 RegistrationInfo_get_XmlText
,
807 RegistrationInfo_put_XmlText
,
808 RegistrationInfo_get_URI
,
809 RegistrationInfo_put_URI
,
810 RegistrationInfo_get_SecurityDescriptor
,
811 RegistrationInfo_put_SecurityDescriptor
,
812 RegistrationInfo_get_Source
,
813 RegistrationInfo_put_Source
816 static HRESULT
RegistrationInfo_create(IRegistrationInfo
**obj
)
818 registration_info
*reginfo
;
820 reginfo
= heap_alloc_zero(sizeof(*reginfo
));
821 if (!reginfo
) return E_OUTOFMEMORY
;
823 reginfo
->IRegistrationInfo_iface
.lpVtbl
= &RegistrationInfo_vtbl
;
825 *obj
= ®info
->IRegistrationInfo_iface
;
827 TRACE("created %p\n", *obj
);
834 ITaskSettings ITaskSettings_iface
;
836 WCHAR
*restart_interval
;
837 WCHAR
*execution_time_limit
;
838 WCHAR
*delete_expired_task_after
;
841 TASK_INSTANCES_POLICY policy
;
842 TASK_COMPATIBILITY compatibility
;
843 BOOL allow_on_demand_start
;
844 BOOL stop_if_going_on_batteries
;
845 BOOL disallow_start_if_on_batteries
;
846 BOOL allow_hard_terminate
;
847 BOOL start_when_available
;
848 BOOL run_only_if_network_available
;
851 BOOL run_only_if_idle
;
855 static inline TaskSettings
*impl_from_ITaskSettings(ITaskSettings
*iface
)
857 return CONTAINING_RECORD(iface
, TaskSettings
, ITaskSettings_iface
);
860 static ULONG WINAPI
TaskSettings_AddRef(ITaskSettings
*iface
)
862 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
863 return InterlockedIncrement(&taskset
->ref
);
866 static ULONG WINAPI
TaskSettings_Release(ITaskSettings
*iface
)
868 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
869 LONG ref
= InterlockedDecrement(&taskset
->ref
);
873 TRACE("destroying %p\n", iface
);
874 heap_free(taskset
->restart_interval
);
875 heap_free(taskset
->execution_time_limit
);
876 heap_free(taskset
->delete_expired_task_after
);
883 static HRESULT WINAPI
TaskSettings_QueryInterface(ITaskSettings
*iface
, REFIID riid
, void **obj
)
885 if (!riid
|| !obj
) return E_INVALIDARG
;
887 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
889 if (IsEqualGUID(riid
, &IID_ITaskSettings
) ||
890 IsEqualGUID(riid
, &IID_IDispatch
) ||
891 IsEqualGUID(riid
, &IID_IUnknown
))
893 ITaskSettings_AddRef(iface
);
898 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
900 return E_NOINTERFACE
;
903 static HRESULT WINAPI
TaskSettings_GetTypeInfoCount(ITaskSettings
*iface
, UINT
*count
)
905 FIXME("%p,%p: stub\n", iface
, count
);
909 static HRESULT WINAPI
TaskSettings_GetTypeInfo(ITaskSettings
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
911 FIXME("%p,%u,%u,%p: stub\n", iface
, index
, lcid
, info
);
915 static HRESULT WINAPI
TaskSettings_GetIDsOfNames(ITaskSettings
*iface
, REFIID riid
, LPOLESTR
*names
,
916 UINT count
, LCID lcid
, DISPID
*dispid
)
918 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
922 static HRESULT WINAPI
TaskSettings_Invoke(ITaskSettings
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
923 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
925 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
926 params
, result
, excepinfo
, argerr
);
930 static HRESULT WINAPI
TaskSettings_get_AllowDemandStart(ITaskSettings
*iface
, VARIANT_BOOL
*allow
)
932 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
934 TRACE("%p,%p\n", iface
, allow
);
936 if (!allow
) return E_POINTER
;
938 *allow
= taskset
->allow_on_demand_start
? VARIANT_TRUE
: VARIANT_FALSE
;
943 static HRESULT WINAPI
TaskSettings_put_AllowDemandStart(ITaskSettings
*iface
, VARIANT_BOOL allow
)
945 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
947 TRACE("%p,%d\n", iface
, allow
);
949 taskset
->allow_on_demand_start
= allow
? TRUE
: FALSE
;
954 static HRESULT WINAPI
TaskSettings_get_RestartInterval(ITaskSettings
*iface
, BSTR
*interval
)
956 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
958 TRACE("%p,%p\n", iface
, interval
);
960 if (!interval
) return E_POINTER
;
962 if (!taskset
->restart_interval
)
968 if (!taskset
->restart_interval
) *interval
= NULL
;
969 else if (!(*interval
= SysAllocString(taskset
->restart_interval
))) return E_OUTOFMEMORY
;
974 static HRESULT WINAPI
TaskSettings_put_RestartInterval(ITaskSettings
*iface
, BSTR interval
)
976 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
979 TRACE("%p,%s\n", iface
, debugstr_w(interval
));
981 if (interval
&& !(str
= heap_strdupW(interval
))) return E_OUTOFMEMORY
;
982 heap_free(taskset
->restart_interval
);
983 taskset
->restart_interval
= str
;
988 static HRESULT WINAPI
TaskSettings_get_RestartCount(ITaskSettings
*iface
, INT
*count
)
990 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
992 TRACE("%p,%p\n", iface
, count
);
994 if (!count
) return E_POINTER
;
996 *count
= taskset
->restart_count
;
1001 static HRESULT WINAPI
TaskSettings_put_RestartCount(ITaskSettings
*iface
, INT count
)
1003 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1005 TRACE("%p,%d\n", iface
, count
);
1007 taskset
->restart_count
= count
;
1012 static HRESULT WINAPI
TaskSettings_get_MultipleInstances(ITaskSettings
*iface
, TASK_INSTANCES_POLICY
*policy
)
1014 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1016 TRACE("%p,%p\n", iface
, policy
);
1018 if (!policy
) return E_POINTER
;
1020 *policy
= taskset
->policy
;
1025 static HRESULT WINAPI
TaskSettings_put_MultipleInstances(ITaskSettings
*iface
, TASK_INSTANCES_POLICY policy
)
1027 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1029 TRACE("%p,%d\n", iface
, policy
);
1031 taskset
->policy
= policy
;
1036 static HRESULT WINAPI
TaskSettings_get_StopIfGoingOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL
*stop
)
1038 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1040 TRACE("%p,%p\n", iface
, stop
);
1042 if (!stop
) return E_POINTER
;
1044 *stop
= taskset
->stop_if_going_on_batteries
? VARIANT_TRUE
: VARIANT_FALSE
;
1049 static HRESULT WINAPI
TaskSettings_put_StopIfGoingOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL stop
)
1051 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1053 TRACE("%p,%d\n", iface
, stop
);
1055 taskset
->stop_if_going_on_batteries
= stop
? TRUE
: FALSE
;
1060 static HRESULT WINAPI
TaskSettings_get_DisallowStartIfOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL
*disallow
)
1062 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1064 TRACE("%p,%p\n", iface
, disallow
);
1066 if (!disallow
) return E_POINTER
;
1068 *disallow
= taskset
->disallow_start_if_on_batteries
? VARIANT_TRUE
: VARIANT_FALSE
;
1073 static HRESULT WINAPI
TaskSettings_put_DisallowStartIfOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL disallow
)
1075 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1077 TRACE("%p,%d\n", iface
, disallow
);
1079 taskset
->disallow_start_if_on_batteries
= disallow
? TRUE
: FALSE
;
1084 static HRESULT WINAPI
TaskSettings_get_AllowHardTerminate(ITaskSettings
*iface
, VARIANT_BOOL
*allow
)
1086 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1088 TRACE("%p,%p\n", iface
, allow
);
1090 if (!allow
) return E_POINTER
;
1092 *allow
= taskset
->allow_hard_terminate
? VARIANT_TRUE
: VARIANT_FALSE
;
1097 static HRESULT WINAPI
TaskSettings_put_AllowHardTerminate(ITaskSettings
*iface
, VARIANT_BOOL allow
)
1099 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1101 TRACE("%p,%d\n", iface
, allow
);
1103 taskset
->allow_hard_terminate
= allow
? TRUE
: FALSE
;
1108 static HRESULT WINAPI
TaskSettings_get_StartWhenAvailable(ITaskSettings
*iface
, VARIANT_BOOL
*start
)
1110 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1112 TRACE("%p,%p\n", iface
, start
);
1114 if (!start
) return E_POINTER
;
1116 *start
= taskset
->start_when_available
? VARIANT_TRUE
: VARIANT_FALSE
;
1121 static HRESULT WINAPI
TaskSettings_put_StartWhenAvailable(ITaskSettings
*iface
, VARIANT_BOOL start
)
1123 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1125 TRACE("%p,%d\n", iface
, start
);
1127 taskset
->start_when_available
= start
? TRUE
: FALSE
;
1132 static HRESULT WINAPI
TaskSettings_get_XmlText(ITaskSettings
*iface
, BSTR
*xml
)
1134 FIXME("%p,%p: stub\n", iface
, xml
);
1138 static HRESULT WINAPI
TaskSettings_put_XmlText(ITaskSettings
*iface
, BSTR xml
)
1140 FIXME("%p,%s: stub\n", iface
, debugstr_w(xml
));
1144 static HRESULT WINAPI
TaskSettings_get_RunOnlyIfNetworkAvailable(ITaskSettings
*iface
, VARIANT_BOOL
*run
)
1146 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1148 TRACE("%p,%p\n", iface
, run
);
1150 if (!run
) return E_POINTER
;
1152 *run
= taskset
->run_only_if_network_available
? VARIANT_TRUE
: VARIANT_FALSE
;
1157 static HRESULT WINAPI
TaskSettings_put_RunOnlyIfNetworkAvailable(ITaskSettings
*iface
, VARIANT_BOOL run
)
1159 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1161 TRACE("%p,%d\n", iface
, run
);
1163 taskset
->run_only_if_network_available
= run
? TRUE
: FALSE
;
1168 static HRESULT WINAPI
TaskSettings_get_ExecutionTimeLimit(ITaskSettings
*iface
, BSTR
*limit
)
1170 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1172 TRACE("%p,%p\n", iface
, limit
);
1174 if (!limit
) return E_POINTER
;
1176 if (!taskset
->execution_time_limit
)
1182 if (!taskset
->execution_time_limit
) *limit
= NULL
;
1183 else if (!(*limit
= SysAllocString(taskset
->execution_time_limit
))) return E_OUTOFMEMORY
;
1188 static HRESULT WINAPI
TaskSettings_put_ExecutionTimeLimit(ITaskSettings
*iface
, BSTR limit
)
1190 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1193 TRACE("%p,%s\n", iface
, debugstr_w(limit
));
1195 if (limit
&& !(str
= heap_strdupW(limit
))) return E_OUTOFMEMORY
;
1196 heap_free(taskset
->execution_time_limit
);
1197 taskset
->execution_time_limit
= str
;
1202 static HRESULT WINAPI
TaskSettings_get_Enabled(ITaskSettings
*iface
, VARIANT_BOOL
*enabled
)
1204 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1206 TRACE("%p,%p\n", iface
, enabled
);
1208 if (!enabled
) return E_POINTER
;
1210 *enabled
= taskset
->enabled
? VARIANT_TRUE
: VARIANT_FALSE
;
1215 static HRESULT WINAPI
TaskSettings_put_Enabled(ITaskSettings
*iface
, VARIANT_BOOL enabled
)
1217 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1219 TRACE("%p,%d\n", iface
, enabled
);
1221 taskset
->enabled
= enabled
? TRUE
: FALSE
;
1226 static HRESULT WINAPI
TaskSettings_get_DeleteExpiredTaskAfter(ITaskSettings
*iface
, BSTR
*delay
)
1228 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1230 TRACE("%p,%p\n", iface
, delay
);
1232 if (!delay
) return E_POINTER
;
1234 if (!taskset
->delete_expired_task_after
) *delay
= NULL
;
1235 else if (!(*delay
= SysAllocString(taskset
->delete_expired_task_after
))) return E_OUTOFMEMORY
;
1240 static HRESULT WINAPI
TaskSettings_put_DeleteExpiredTaskAfter(ITaskSettings
*iface
, BSTR delay
)
1242 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1245 TRACE("%p,%s\n", iface
, debugstr_w(delay
));
1247 if (delay
&& !(str
= heap_strdupW(delay
))) return E_OUTOFMEMORY
;
1248 heap_free(taskset
->delete_expired_task_after
);
1249 taskset
->delete_expired_task_after
= str
;
1254 static HRESULT WINAPI
TaskSettings_get_Priority(ITaskSettings
*iface
, INT
*priority
)
1256 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1258 TRACE("%p,%p\n", iface
, priority
);
1260 if (!priority
) return E_POINTER
;
1262 *priority
= taskset
->priority
;
1267 static HRESULT WINAPI
TaskSettings_put_Priority(ITaskSettings
*iface
, INT priority
)
1269 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1271 TRACE("%p,%d\n", iface
, priority
);
1273 taskset
->priority
= priority
;
1278 static HRESULT WINAPI
TaskSettings_get_Compatibility(ITaskSettings
*iface
, TASK_COMPATIBILITY
*level
)
1280 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1282 TRACE("%p,%p\n", iface
, level
);
1284 if (!level
) return E_POINTER
;
1286 *level
= taskset
->compatibility
;
1291 static HRESULT WINAPI
TaskSettings_put_Compatibility(ITaskSettings
*iface
, TASK_COMPATIBILITY level
)
1293 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1295 TRACE("%p,%d\n", iface
, level
);
1297 taskset
->compatibility
= level
;
1302 static HRESULT WINAPI
TaskSettings_get_Hidden(ITaskSettings
*iface
, VARIANT_BOOL
*hidden
)
1304 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1306 TRACE("%p,%p\n", iface
, hidden
);
1308 if (!hidden
) return E_POINTER
;
1310 *hidden
= taskset
->hidden
? VARIANT_TRUE
: VARIANT_FALSE
;
1315 static HRESULT WINAPI
TaskSettings_put_Hidden(ITaskSettings
*iface
, VARIANT_BOOL hidden
)
1317 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1319 TRACE("%p,%d\n", iface
, hidden
);
1321 taskset
->hidden
= hidden
? TRUE
: FALSE
;
1326 static HRESULT WINAPI
TaskSettings_get_IdleSettings(ITaskSettings
*iface
, IIdleSettings
**settings
)
1328 FIXME("%p,%p: stub\n", iface
, settings
);
1332 static HRESULT WINAPI
TaskSettings_put_IdleSettings(ITaskSettings
*iface
, IIdleSettings
*settings
)
1334 FIXME("%p,%p: stub\n", iface
, settings
);
1338 static HRESULT WINAPI
TaskSettings_get_RunOnlyIfIdle(ITaskSettings
*iface
, VARIANT_BOOL
*run
)
1340 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1342 TRACE("%p,%p\n", iface
, run
);
1344 if (!run
) return E_POINTER
;
1346 *run
= taskset
->run_only_if_idle
? VARIANT_TRUE
: VARIANT_FALSE
;
1351 static HRESULT WINAPI
TaskSettings_put_RunOnlyIfIdle(ITaskSettings
*iface
, VARIANT_BOOL run
)
1353 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1355 TRACE("%p,%d\n", iface
, run
);
1357 taskset
->run_only_if_idle
= run
? TRUE
: FALSE
;
1362 static HRESULT WINAPI
TaskSettings_get_WakeToRun(ITaskSettings
*iface
, VARIANT_BOOL
*wake
)
1364 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1366 TRACE("%p,%p\n", iface
, wake
);
1368 if (!wake
) return E_POINTER
;
1370 *wake
= taskset
->wake_to_run
? VARIANT_TRUE
: VARIANT_FALSE
;
1375 static HRESULT WINAPI
TaskSettings_put_WakeToRun(ITaskSettings
*iface
, VARIANT_BOOL wake
)
1377 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1379 TRACE("%p,%d\n", iface
, wake
);
1381 taskset
->wake_to_run
= wake
? TRUE
: FALSE
;
1386 static HRESULT WINAPI
TaskSettings_get_NetworkSettings(ITaskSettings
*iface
, INetworkSettings
**settings
)
1388 FIXME("%p,%p: stub\n", iface
, settings
);
1392 static HRESULT WINAPI
TaskSettings_put_NetworkSettings(ITaskSettings
*iface
, INetworkSettings
*settings
)
1394 FIXME("%p,%p: stub\n", iface
, settings
);
1398 static const ITaskSettingsVtbl TaskSettings_vtbl
=
1400 TaskSettings_QueryInterface
,
1401 TaskSettings_AddRef
,
1402 TaskSettings_Release
,
1403 TaskSettings_GetTypeInfoCount
,
1404 TaskSettings_GetTypeInfo
,
1405 TaskSettings_GetIDsOfNames
,
1406 TaskSettings_Invoke
,
1407 TaskSettings_get_AllowDemandStart
,
1408 TaskSettings_put_AllowDemandStart
,
1409 TaskSettings_get_RestartInterval
,
1410 TaskSettings_put_RestartInterval
,
1411 TaskSettings_get_RestartCount
,
1412 TaskSettings_put_RestartCount
,
1413 TaskSettings_get_MultipleInstances
,
1414 TaskSettings_put_MultipleInstances
,
1415 TaskSettings_get_StopIfGoingOnBatteries
,
1416 TaskSettings_put_StopIfGoingOnBatteries
,
1417 TaskSettings_get_DisallowStartIfOnBatteries
,
1418 TaskSettings_put_DisallowStartIfOnBatteries
,
1419 TaskSettings_get_AllowHardTerminate
,
1420 TaskSettings_put_AllowHardTerminate
,
1421 TaskSettings_get_StartWhenAvailable
,
1422 TaskSettings_put_StartWhenAvailable
,
1423 TaskSettings_get_XmlText
,
1424 TaskSettings_put_XmlText
,
1425 TaskSettings_get_RunOnlyIfNetworkAvailable
,
1426 TaskSettings_put_RunOnlyIfNetworkAvailable
,
1427 TaskSettings_get_ExecutionTimeLimit
,
1428 TaskSettings_put_ExecutionTimeLimit
,
1429 TaskSettings_get_Enabled
,
1430 TaskSettings_put_Enabled
,
1431 TaskSettings_get_DeleteExpiredTaskAfter
,
1432 TaskSettings_put_DeleteExpiredTaskAfter
,
1433 TaskSettings_get_Priority
,
1434 TaskSettings_put_Priority
,
1435 TaskSettings_get_Compatibility
,
1436 TaskSettings_put_Compatibility
,
1437 TaskSettings_get_Hidden
,
1438 TaskSettings_put_Hidden
,
1439 TaskSettings_get_IdleSettings
,
1440 TaskSettings_put_IdleSettings
,
1441 TaskSettings_get_RunOnlyIfIdle
,
1442 TaskSettings_put_RunOnlyIfIdle
,
1443 TaskSettings_get_WakeToRun
,
1444 TaskSettings_put_WakeToRun
,
1445 TaskSettings_get_NetworkSettings
,
1446 TaskSettings_put_NetworkSettings
1449 static HRESULT
TaskSettings_create(ITaskSettings
**obj
)
1451 static const WCHAR exec_time_limit
[] = { 'P','T','7','2','H',0 };
1452 TaskSettings
*taskset
;
1454 taskset
= heap_alloc(sizeof(*taskset
));
1455 if (!taskset
) return E_OUTOFMEMORY
;
1457 taskset
->ITaskSettings_iface
.lpVtbl
= &TaskSettings_vtbl
;
1459 /* set the defaults */
1460 taskset
->restart_interval
= NULL
;
1461 taskset
->execution_time_limit
= heap_strdupW(exec_time_limit
);
1462 taskset
->delete_expired_task_after
= NULL
;
1463 taskset
->restart_count
= 0;
1464 taskset
->priority
= 7;
1465 taskset
->policy
= TASK_INSTANCES_IGNORE_NEW
;
1466 taskset
->compatibility
= TASK_COMPATIBILITY_V2
;
1467 taskset
->allow_on_demand_start
= TRUE
;
1468 taskset
->stop_if_going_on_batteries
= TRUE
;
1469 taskset
->disallow_start_if_on_batteries
= TRUE
;
1470 taskset
->allow_hard_terminate
= TRUE
;
1471 taskset
->start_when_available
= FALSE
;
1472 taskset
->run_only_if_network_available
= FALSE
;
1473 taskset
->enabled
= TRUE
;
1474 taskset
->hidden
= FALSE
;
1475 taskset
->run_only_if_idle
= FALSE
;
1476 taskset
->wake_to_run
= FALSE
;
1478 *obj
= &taskset
->ITaskSettings_iface
;
1480 TRACE("created %p\n", *obj
);
1487 IPrincipal IPrincipal_iface
;
1491 static inline Principal
*impl_from_IPrincipal(IPrincipal
*iface
)
1493 return CONTAINING_RECORD(iface
, Principal
, IPrincipal_iface
);
1496 static ULONG WINAPI
Principal_AddRef(IPrincipal
*iface
)
1498 Principal
*principal
= impl_from_IPrincipal(iface
);
1499 return InterlockedIncrement(&principal
->ref
);
1502 static ULONG WINAPI
Principal_Release(IPrincipal
*iface
)
1504 Principal
*principal
= impl_from_IPrincipal(iface
);
1505 LONG ref
= InterlockedDecrement(&principal
->ref
);
1509 TRACE("destroying %p\n", iface
);
1510 heap_free(principal
);
1516 static HRESULT WINAPI
Principal_QueryInterface(IPrincipal
*iface
, REFIID riid
, void **obj
)
1518 if (!riid
|| !obj
) return E_INVALIDARG
;
1520 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
1522 if (IsEqualGUID(riid
, &IID_IPrincipal
) ||
1523 IsEqualGUID(riid
, &IID_IDispatch
) ||
1524 IsEqualGUID(riid
, &IID_IUnknown
))
1526 IPrincipal_AddRef(iface
);
1531 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
1533 return E_NOINTERFACE
;
1536 static HRESULT WINAPI
Principal_GetTypeInfoCount(IPrincipal
*iface
, UINT
*count
)
1538 FIXME("%p,%p: stub\n", iface
, count
);
1542 static HRESULT WINAPI
Principal_GetTypeInfo(IPrincipal
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
1544 FIXME("%p,%u,%u,%p: stub\n", iface
, index
, lcid
, info
);
1548 static HRESULT WINAPI
Principal_GetIDsOfNames(IPrincipal
*iface
, REFIID riid
, LPOLESTR
*names
,
1549 UINT count
, LCID lcid
, DISPID
*dispid
)
1551 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1555 static HRESULT WINAPI
Principal_Invoke(IPrincipal
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
1556 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
1558 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
1559 params
, result
, excepinfo
, argerr
);
1563 static HRESULT WINAPI
Principal_get_Id(IPrincipal
*iface
, BSTR
*id
)
1565 FIXME("%p,%p: stub\n", iface
, id
);
1569 static HRESULT WINAPI
Principal_put_Id(IPrincipal
*iface
, BSTR id
)
1571 FIXME("%p,%s: stub\n", iface
, debugstr_w(id
));
1575 static HRESULT WINAPI
Principal_get_DisplayName(IPrincipal
*iface
, BSTR
*name
)
1577 FIXME("%p,%p: stub\n", iface
, name
);
1581 static HRESULT WINAPI
Principal_put_DisplayName(IPrincipal
*iface
, BSTR name
)
1583 FIXME("%p,%s: stub\n", iface
, debugstr_w(name
));
1587 static HRESULT WINAPI
Principal_get_UserId(IPrincipal
*iface
, BSTR
*user_id
)
1589 FIXME("%p,%p: stub\n", iface
, user_id
);
1593 static HRESULT WINAPI
Principal_put_UserId(IPrincipal
*iface
, BSTR user_id
)
1595 FIXME("%p,%s: stub\n", iface
, debugstr_w(user_id
));
1599 static HRESULT WINAPI
Principal_get_LogonType(IPrincipal
*iface
, TASK_LOGON_TYPE
*logon_type
)
1601 FIXME("%p,%p: stub\n", iface
, logon_type
);
1605 static HRESULT WINAPI
Principal_put_LogonType(IPrincipal
*iface
, TASK_LOGON_TYPE logon_type
)
1607 FIXME("%p,%u: stub\n", iface
, logon_type
);
1611 static HRESULT WINAPI
Principal_get_GroupId(IPrincipal
*iface
, BSTR
*group_id
)
1613 FIXME("%p,%p: stub\n", iface
, group_id
);
1617 static HRESULT WINAPI
Principal_put_GroupId(IPrincipal
*iface
, BSTR group_id
)
1619 FIXME("%p,%s: stub\n", iface
, debugstr_w(group_id
));
1623 static HRESULT WINAPI
Principal_get_RunLevel(IPrincipal
*iface
, TASK_RUNLEVEL_TYPE
*run_level
)
1625 FIXME("%p,%p: stub\n", iface
, run_level
);
1629 static HRESULT WINAPI
Principal_put_RunLevel(IPrincipal
*iface
, TASK_RUNLEVEL_TYPE run_level
)
1631 FIXME("%p,%u: stub\n", iface
, run_level
);
1635 static const IPrincipalVtbl Principal_vtbl
=
1637 Principal_QueryInterface
,
1640 Principal_GetTypeInfoCount
,
1641 Principal_GetTypeInfo
,
1642 Principal_GetIDsOfNames
,
1646 Principal_get_DisplayName
,
1647 Principal_put_DisplayName
,
1648 Principal_get_UserId
,
1649 Principal_put_UserId
,
1650 Principal_get_LogonType
,
1651 Principal_put_LogonType
,
1652 Principal_get_GroupId
,
1653 Principal_put_GroupId
,
1654 Principal_get_RunLevel
,
1655 Principal_put_RunLevel
1658 static HRESULT
Principal_create(IPrincipal
**obj
)
1660 Principal
*principal
;
1662 principal
= heap_alloc(sizeof(*principal
));
1663 if (!principal
) return E_OUTOFMEMORY
;
1665 principal
->IPrincipal_iface
.lpVtbl
= &Principal_vtbl
;
1668 *obj
= &principal
->IPrincipal_iface
;
1670 TRACE("created %p\n", *obj
);
1677 IExecAction IExecAction_iface
;
1682 static inline ExecAction
*impl_from_IExecAction(IExecAction
*iface
)
1684 return CONTAINING_RECORD(iface
, ExecAction
, IExecAction_iface
);
1687 static ULONG WINAPI
ExecAction_AddRef(IExecAction
*iface
)
1689 ExecAction
*action
= impl_from_IExecAction(iface
);
1690 return InterlockedIncrement(&action
->ref
);
1693 static ULONG WINAPI
ExecAction_Release(IExecAction
*iface
)
1695 ExecAction
*action
= impl_from_IExecAction(iface
);
1696 LONG ref
= InterlockedDecrement(&action
->ref
);
1700 TRACE("destroying %p\n", iface
);
1701 heap_free(action
->path
);
1708 static HRESULT WINAPI
ExecAction_QueryInterface(IExecAction
*iface
, REFIID riid
, void **obj
)
1710 if (!riid
|| !obj
) return E_INVALIDARG
;
1712 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
1714 if (IsEqualGUID(riid
, &IID_IExecAction
) ||
1715 IsEqualGUID(riid
, &IID_IAction
) ||
1716 IsEqualGUID(riid
, &IID_IDispatch
) ||
1717 IsEqualGUID(riid
, &IID_IUnknown
))
1719 IExecAction_AddRef(iface
);
1724 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
1726 return E_NOINTERFACE
;
1729 static HRESULT WINAPI
ExecAction_GetTypeInfoCount(IExecAction
*iface
, UINT
*count
)
1731 FIXME("%p,%p: stub\n", iface
, count
);
1735 static HRESULT WINAPI
ExecAction_GetTypeInfo(IExecAction
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
1737 FIXME("%p,%u,%u,%p: stub\n", iface
, index
, lcid
, info
);
1741 static HRESULT WINAPI
ExecAction_GetIDsOfNames(IExecAction
*iface
, REFIID riid
, LPOLESTR
*names
,
1742 UINT count
, LCID lcid
, DISPID
*dispid
)
1744 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1748 static HRESULT WINAPI
ExecAction_Invoke(IExecAction
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
1749 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
1751 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
1752 params
, result
, excepinfo
, argerr
);
1756 static HRESULT WINAPI
ExecAction_get_Id(IExecAction
*iface
, BSTR
*id
)
1758 FIXME("%p,%p: stub\n", iface
, id
);
1762 static HRESULT WINAPI
ExecAction_put_Id(IExecAction
*iface
, BSTR id
)
1764 FIXME("%p,%s: stub\n", iface
, debugstr_w(id
));
1768 static HRESULT WINAPI
ExecAction_get_Type(IExecAction
*iface
, TASK_ACTION_TYPE
*type
)
1770 TRACE("%p,%p\n", iface
, type
);
1772 if (!type
) return E_POINTER
;
1774 *type
= TASK_ACTION_EXEC
;
1779 static HRESULT WINAPI
ExecAction_get_Path(IExecAction
*iface
, BSTR
*path
)
1781 ExecAction
*action
= impl_from_IExecAction(iface
);
1783 TRACE("%p,%p\n", iface
, path
);
1785 if (!path
) return E_POINTER
;
1787 if (!action
->path
) *path
= NULL
;
1788 else if (!(*path
= SysAllocString(action
->path
))) return E_OUTOFMEMORY
;
1793 static HRESULT WINAPI
ExecAction_put_Path(IExecAction
*iface
, BSTR path
)
1795 ExecAction
*action
= impl_from_IExecAction(iface
);
1798 TRACE("%p,%s\n", iface
, debugstr_w(path
));
1800 if (path
&& !(str
= heap_strdupW((path
)))) return E_OUTOFMEMORY
;
1801 heap_free(action
->path
);
1807 static HRESULT WINAPI
ExecAction_get_Arguments(IExecAction
*iface
, BSTR
*arguments
)
1809 FIXME("%p,%p: stub\n", iface
, arguments
);
1813 static HRESULT WINAPI
ExecAction_put_Arguments(IExecAction
*iface
, BSTR arguments
)
1815 FIXME("%p,%s: stub\n", iface
, debugstr_w(arguments
));
1819 static HRESULT WINAPI
ExecAction_get_WorkingDirectory(IExecAction
*iface
, BSTR
*directory
)
1821 FIXME("%p,%p: stub\n", iface
, directory
);
1825 static HRESULT WINAPI
ExecAction_put_WorkingDirectory(IExecAction
*iface
, BSTR directory
)
1827 FIXME("%p,%s: stub\n", iface
, debugstr_w(directory
));
1831 static const IExecActionVtbl Action_vtbl
=
1833 ExecAction_QueryInterface
,
1836 ExecAction_GetTypeInfoCount
,
1837 ExecAction_GetTypeInfo
,
1838 ExecAction_GetIDsOfNames
,
1842 ExecAction_get_Type
,
1843 ExecAction_get_Path
,
1844 ExecAction_put_Path
,
1845 ExecAction_get_Arguments
,
1846 ExecAction_put_Arguments
,
1847 ExecAction_get_WorkingDirectory
,
1848 ExecAction_put_WorkingDirectory
1851 static HRESULT
ExecAction_create(IExecAction
**obj
)
1855 action
= heap_alloc(sizeof(*action
));
1856 if (!action
) return E_OUTOFMEMORY
;
1858 action
->IExecAction_iface
.lpVtbl
= &Action_vtbl
;
1860 action
->path
= NULL
;
1862 *obj
= &action
->IExecAction_iface
;
1864 TRACE("created %p\n", *obj
);
1871 IActionCollection IActionCollection_iface
;
1875 static inline Actions
*impl_from_IActionCollection(IActionCollection
*iface
)
1877 return CONTAINING_RECORD(iface
, Actions
, IActionCollection_iface
);
1880 static ULONG WINAPI
Actions_AddRef(IActionCollection
*iface
)
1882 Actions
*actions
= impl_from_IActionCollection(iface
);
1883 return InterlockedIncrement(&actions
->ref
);
1886 static ULONG WINAPI
Actions_Release(IActionCollection
*iface
)
1888 Actions
*actions
= impl_from_IActionCollection(iface
);
1889 LONG ref
= InterlockedDecrement(&actions
->ref
);
1893 TRACE("destroying %p\n", iface
);
1900 static HRESULT WINAPI
Actions_QueryInterface(IActionCollection
*iface
, REFIID riid
, void **obj
)
1902 if (!riid
|| !obj
) return E_INVALIDARG
;
1904 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
1906 if (IsEqualGUID(riid
, &IID_IActionCollection
) ||
1907 IsEqualGUID(riid
, &IID_IDispatch
) ||
1908 IsEqualGUID(riid
, &IID_IUnknown
))
1910 IActionCollection_AddRef(iface
);
1915 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
1917 return E_NOINTERFACE
;
1920 static HRESULT WINAPI
Actions_GetTypeInfoCount(IActionCollection
*iface
, UINT
*count
)
1922 FIXME("%p,%p: stub\n", iface
, count
);
1926 static HRESULT WINAPI
Actions_GetTypeInfo(IActionCollection
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
1928 FIXME("%p,%u,%u,%p: stub\n", iface
, index
, lcid
, info
);
1932 static HRESULT WINAPI
Actions_GetIDsOfNames(IActionCollection
*iface
, REFIID riid
, LPOLESTR
*names
,
1933 UINT count
, LCID lcid
, DISPID
*dispid
)
1935 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1939 static HRESULT WINAPI
Actions_Invoke(IActionCollection
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
1940 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
1942 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
1943 params
, result
, excepinfo
, argerr
);
1947 static HRESULT WINAPI
Actions_get_Count(IActionCollection
*iface
, LONG
*count
)
1949 FIXME("%p,%p: stub\n", iface
, count
);
1953 static HRESULT WINAPI
Actions_get_Item(IActionCollection
*iface
, LONG index
, IAction
**action
)
1955 FIXME("%p,%d,%p: stub\n", iface
, index
, action
);
1959 static HRESULT WINAPI
Actions_get__NewEnum(IActionCollection
*iface
, IUnknown
**penum
)
1961 FIXME("%p,%p: stub\n", iface
, penum
);
1965 static HRESULT WINAPI
Actions_get_XmlText(IActionCollection
*iface
, BSTR
*xml
)
1967 FIXME("%p,%p: stub\n", iface
, xml
);
1971 static HRESULT WINAPI
Actions_put_XmlText(IActionCollection
*iface
, BSTR xml
)
1973 FIXME("%p,%s: stub\n", iface
, debugstr_w(xml
));
1977 static HRESULT WINAPI
Actions_Create(IActionCollection
*iface
, TASK_ACTION_TYPE type
, IAction
**action
)
1979 TRACE("%p,%u,%p\n", iface
, type
, action
);
1983 case TASK_ACTION_EXEC
:
1984 return ExecAction_create((IExecAction
**)action
);
1987 FIXME("unimplemented type %u\n", type
);
1992 static HRESULT WINAPI
Actions_Remove(IActionCollection
*iface
, VARIANT index
)
1994 FIXME("%p,%s: stub\n", iface
, debugstr_variant(&index
));
1998 static HRESULT WINAPI
Actions_Clear(IActionCollection
*iface
)
2000 FIXME("%p: stub\n", iface
);
2004 static HRESULT WINAPI
Actions_get_Context(IActionCollection
*iface
, BSTR
*ctx
)
2006 FIXME("%p,%p: stub\n", iface
, ctx
);
2010 static HRESULT WINAPI
Actions_put_Context(IActionCollection
*iface
, BSTR ctx
)
2012 FIXME("%p,%s: stub\n", iface
, debugstr_w(ctx
));
2016 static const IActionCollectionVtbl Actions_vtbl
=
2018 Actions_QueryInterface
,
2021 Actions_GetTypeInfoCount
,
2022 Actions_GetTypeInfo
,
2023 Actions_GetIDsOfNames
,
2027 Actions_get__NewEnum
,
2028 Actions_get_XmlText
,
2029 Actions_put_XmlText
,
2033 Actions_get_Context
,
2037 static HRESULT
Actions_create(IActionCollection
**obj
)
2041 actions
= heap_alloc(sizeof(*actions
));
2042 if (!actions
) return E_OUTOFMEMORY
;
2044 actions
->IActionCollection_iface
.lpVtbl
= &Actions_vtbl
;
2047 *obj
= &actions
->IActionCollection_iface
;
2049 TRACE("created %p\n", *obj
);
2056 ITaskDefinition ITaskDefinition_iface
;
2058 IRegistrationInfo
*reginfo
;
2059 ITaskSettings
*taskset
;
2060 ITriggerCollection
*triggers
;
2061 IPrincipal
*principal
;
2062 IActionCollection
*actions
;
2065 static inline TaskDefinition
*impl_from_ITaskDefinition(ITaskDefinition
*iface
)
2067 return CONTAINING_RECORD(iface
, TaskDefinition
, ITaskDefinition_iface
);
2070 static ULONG WINAPI
TaskDefinition_AddRef(ITaskDefinition
*iface
)
2072 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2073 return InterlockedIncrement(&taskdef
->ref
);
2076 static ULONG WINAPI
TaskDefinition_Release(ITaskDefinition
*iface
)
2078 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2079 LONG ref
= InterlockedDecrement(&taskdef
->ref
);
2083 TRACE("destroying %p\n", iface
);
2085 if (taskdef
->reginfo
)
2086 IRegistrationInfo_Release(taskdef
->reginfo
);
2087 if (taskdef
->taskset
)
2088 ITaskSettings_Release(taskdef
->taskset
);
2089 if (taskdef
->triggers
)
2090 ITriggerCollection_Release(taskdef
->triggers
);
2091 if (taskdef
->principal
)
2092 IPrincipal_Release(taskdef
->principal
);
2093 if (taskdef
->actions
)
2094 IActionCollection_Release(taskdef
->actions
);
2102 static HRESULT WINAPI
TaskDefinition_QueryInterface(ITaskDefinition
*iface
, REFIID riid
, void **obj
)
2104 if (!riid
|| !obj
) return E_INVALIDARG
;
2106 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
2108 if (IsEqualGUID(riid
, &IID_ITaskDefinition
) ||
2109 IsEqualGUID(riid
, &IID_IDispatch
) ||
2110 IsEqualGUID(riid
, &IID_IUnknown
))
2112 ITaskDefinition_AddRef(iface
);
2117 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
2119 return E_NOINTERFACE
;
2122 static HRESULT WINAPI
TaskDefinition_GetTypeInfoCount(ITaskDefinition
*iface
, UINT
*count
)
2124 FIXME("%p,%p: stub\n", iface
, count
);
2128 static HRESULT WINAPI
TaskDefinition_GetTypeInfo(ITaskDefinition
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
2130 FIXME("%p,%u,%u,%p: stub\n", iface
, index
, lcid
, info
);
2134 static HRESULT WINAPI
TaskDefinition_GetIDsOfNames(ITaskDefinition
*iface
, REFIID riid
, LPOLESTR
*names
,
2135 UINT count
, LCID lcid
, DISPID
*dispid
)
2137 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2141 static HRESULT WINAPI
TaskDefinition_Invoke(ITaskDefinition
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
2142 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
2144 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
2145 params
, result
, excepinfo
, argerr
);
2149 static HRESULT WINAPI
TaskDefinition_get_RegistrationInfo(ITaskDefinition
*iface
, IRegistrationInfo
**info
)
2151 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2154 TRACE("%p,%p\n", iface
, info
);
2156 if (!info
) return E_POINTER
;
2158 if (!taskdef
->reginfo
)
2160 hr
= RegistrationInfo_create(&taskdef
->reginfo
);
2161 if (hr
!= S_OK
) return hr
;
2164 IRegistrationInfo_AddRef(taskdef
->reginfo
);
2165 *info
= taskdef
->reginfo
;
2170 static HRESULT WINAPI
TaskDefinition_put_RegistrationInfo(ITaskDefinition
*iface
, IRegistrationInfo
*info
)
2172 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2174 TRACE("%p,%p\n", iface
, info
);
2176 if (!info
) return E_POINTER
;
2178 if (taskdef
->reginfo
)
2179 IRegistrationInfo_Release(taskdef
->reginfo
);
2181 IRegistrationInfo_AddRef(info
);
2182 taskdef
->reginfo
= info
;
2187 static HRESULT WINAPI
TaskDefinition_get_Triggers(ITaskDefinition
*iface
, ITriggerCollection
**triggers
)
2189 TaskDefinition
*This
= impl_from_ITaskDefinition(iface
);
2191 TRACE("%p,%p\n", This
, triggers
);
2193 if (!This
->triggers
)
2195 trigger_collection
*collection
;
2197 collection
= heap_alloc(sizeof(*collection
));
2198 if (!collection
) return E_OUTOFMEMORY
;
2200 collection
->ITriggerCollection_iface
.lpVtbl
= &TriggerCollection_vtbl
;
2201 collection
->ref
= 1;
2202 This
->triggers
= &collection
->ITriggerCollection_iface
;
2205 ITriggerCollection_AddRef(*triggers
= This
->triggers
);
2209 static HRESULT WINAPI
TaskDefinition_put_Triggers(ITaskDefinition
*iface
, ITriggerCollection
*triggers
)
2211 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2213 TRACE("%p,%p\n", iface
, triggers
);
2215 if (!triggers
) return E_POINTER
;
2217 if (taskdef
->triggers
)
2218 ITriggerCollection_Release(taskdef
->triggers
);
2220 ITriggerCollection_AddRef(triggers
);
2221 taskdef
->triggers
= triggers
;
2226 static HRESULT WINAPI
TaskDefinition_get_Settings(ITaskDefinition
*iface
, ITaskSettings
**settings
)
2228 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2231 TRACE("%p,%p\n", iface
, settings
);
2233 if (!settings
) return E_POINTER
;
2235 if (!taskdef
->taskset
)
2237 hr
= TaskSettings_create(&taskdef
->taskset
);
2238 if (hr
!= S_OK
) return hr
;
2241 ITaskSettings_AddRef(taskdef
->taskset
);
2242 *settings
= taskdef
->taskset
;
2247 static HRESULT WINAPI
TaskDefinition_put_Settings(ITaskDefinition
*iface
, ITaskSettings
*settings
)
2249 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2251 TRACE("%p,%p\n", iface
, settings
);
2253 if (!settings
) return E_POINTER
;
2255 if (taskdef
->taskset
)
2256 ITaskSettings_Release(taskdef
->taskset
);
2258 ITaskSettings_AddRef(settings
);
2259 taskdef
->taskset
= settings
;
2264 static HRESULT WINAPI
TaskDefinition_get_Data(ITaskDefinition
*iface
, BSTR
*data
)
2266 FIXME("%p,%p: stub\n", iface
, data
);
2270 static HRESULT WINAPI
TaskDefinition_put_Data(ITaskDefinition
*iface
, BSTR data
)
2272 FIXME("%p,%p: stub\n", iface
, data
);
2276 static HRESULT WINAPI
TaskDefinition_get_Principal(ITaskDefinition
*iface
, IPrincipal
**principal
)
2278 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2281 TRACE("%p,%p\n", iface
, principal
);
2283 if (!principal
) return E_POINTER
;
2285 if (!taskdef
->principal
)
2287 hr
= Principal_create(&taskdef
->principal
);
2288 if (hr
!= S_OK
) return hr
;
2291 IPrincipal_AddRef(taskdef
->principal
);
2292 *principal
= taskdef
->principal
;
2297 static HRESULT WINAPI
TaskDefinition_put_Principal(ITaskDefinition
*iface
, IPrincipal
*principal
)
2299 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2301 TRACE("%p,%p\n", iface
, principal
);
2303 if (!principal
) return E_POINTER
;
2305 if (taskdef
->principal
)
2306 IPrincipal_Release(taskdef
->principal
);
2308 IPrincipal_AddRef(principal
);
2309 taskdef
->principal
= principal
;
2314 static HRESULT WINAPI
TaskDefinition_get_Actions(ITaskDefinition
*iface
, IActionCollection
**actions
)
2316 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2319 TRACE("%p,%p\n", iface
, actions
);
2321 if (!actions
) return E_POINTER
;
2323 if (!taskdef
->actions
)
2325 hr
= Actions_create(&taskdef
->actions
);
2326 if (hr
!= S_OK
) return hr
;
2329 IActionCollection_AddRef(taskdef
->actions
);
2330 *actions
= taskdef
->actions
;
2335 static HRESULT WINAPI
TaskDefinition_put_Actions(ITaskDefinition
*iface
, IActionCollection
*actions
)
2337 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2339 TRACE("%p,%p\n", iface
, actions
);
2341 if (!actions
) return E_POINTER
;
2343 if (taskdef
->actions
)
2344 IActionCollection_Release(taskdef
->actions
);
2346 IActionCollection_AddRef(actions
);
2347 taskdef
->actions
= actions
;
2352 static const WCHAR Task
[] = {'T','a','s','k',0};
2353 static const WCHAR version
[] = {'v','e','r','s','i','o','n',0};
2354 static const WCHAR v1_0
[] = {'1','.','0',0};
2355 static const WCHAR v1_1
[] = {'1','.','1',0};
2356 static const WCHAR v1_2
[] = {'1','.','2',0};
2357 static const WCHAR v1_3
[] = {'1','.','3',0};
2358 static const WCHAR xmlns
[] = {'x','m','l','n','s',0};
2359 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};
2360 static const WCHAR RegistrationInfo
[] = {'R','e','g','i','s','t','r','a','t','i','o','n','I','n','f','o',0};
2361 static const WCHAR Author
[] = {'A','u','t','h','o','r',0};
2362 static const WCHAR Description
[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
2363 static const WCHAR Source
[] = {'S','o','u','r','c','e',0};
2364 static const WCHAR Date
[] = {'D','a','t','e',0};
2365 static const WCHAR Version
[] = {'V','e','r','s','i','o','n',0};
2366 static const WCHAR Documentation
[] = {'D','o','c','u','m','e','n','t','a','t','i','o','n',0};
2367 static const WCHAR URI
[] = {'U','R','I',0};
2368 static const WCHAR SecurityDescriptor
[] = {'S','e','c','u','r','i','t','y','D','e','s','c','r','i','p','t','o','r',0};
2369 static const WCHAR Settings
[] = {'S','e','t','t','i','n','g','s',0};
2370 static const WCHAR Triggers
[] = {'T','r','i','g','g','e','r','s',0};
2371 static const WCHAR Principals
[] = {'P','r','i','n','c','i','p','a','l','s',0};
2372 static const WCHAR principalW
[] = {'P','r','i','n','c','i','p','a','l',0};
2373 static const WCHAR id
[] = {'i','d',0};
2374 static const WCHAR UserId
[] = {'U','s','e','r','I','d',0};
2375 static const WCHAR LogonType
[] = {'L','o','g','o','n','T','y','p','e',0};
2376 static const WCHAR GroupId
[] = {'G','r','o','u','p','I','d',0};
2377 static const WCHAR DisplayName
[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
2378 static const WCHAR HighestAvailable
[] = {'H','i','g','h','e','s','t','A','v','a','i','l','a','b','l','e',0};
2379 static const WCHAR Password
[] = {'P','a','s','s','w','o','r','d',0};
2380 static const WCHAR S4U
[] = {'S','4','U',0};
2381 static const WCHAR InteractiveToken
[] = {'I','n','t','e','r','a','c','t','i','v','e','T','o','k','e','n',0};
2382 static const WCHAR RunLevel
[] = {'R','u','n','L','e','v','e','l',0};
2383 static const WCHAR LeastPrivilege
[] = {'L','e','a','s','t','P','r','i','v','i','l','e','g','e',0};
2384 static const WCHAR actionsW
[] = {'A','c','t','i','o','n','s',0};
2385 static const WCHAR Exec
[] = {'E','x','e','c',0};
2386 static const WCHAR MultipleInstancesPolicy
[] = {'M','u','l','t','i','p','l','e','I','n','s','t','a','n','c','e','s','P','o','l','i','c','y',0};
2387 static const WCHAR IgnoreNew
[] = {'I','g','n','o','r','e','N','e','w',0};
2388 static const WCHAR DisallowStartIfOnBatteries
[] = {'D','i','s','a','l','l','o','w','S','t','a','r','t','I','f','O','n','B','a','t','t','e','r','i','e','s',0};
2389 static const WCHAR AllowStartOnDemand
[] = {'A','l','l','o','w','S','t','a','r','t','O','n','D','e','m','a','n','d',0};
2390 static const WCHAR StopIfGoingOnBatteries
[] = {'S','t','o','p','I','f','G','o','i','n','g','O','n','B','a','t','t','e','r','i','e','s',0};
2391 static const WCHAR AllowHardTerminate
[] = {'A','l','l','o','w','H','a','r','d','T','e','r','m','i','n','a','t','e',0};
2392 static const WCHAR StartWhenAvailable
[] = {'S','t','a','r','t','W','h','e','n','A','v','a','i','l','a','b','l','e',0};
2393 static const WCHAR RunOnlyIfNetworkAvailable
[] = {'R','u','n','O','n','l','y','I','f','N','e','t','w','o','r','k','A','v','a','i','l','a','b','l','e',0};
2394 static const WCHAR Enabled
[] = {'E','n','a','b','l','e','d',0};
2395 static const WCHAR Hidden
[] = {'H','i','d','d','e','n',0};
2396 static const WCHAR RunOnlyIfIdle
[] = {'R','u','n','O','n','l','y','I','f','I','d','l','e',0};
2397 static const WCHAR WakeToRun
[] = {'W','a','k','e','T','o','R','u','n',0};
2398 static const WCHAR ExecutionTimeLimit
[] = {'E','x','e','c','u','t','i','o','n','T','i','m','e','L','i','m','i','t',0};
2399 static const WCHAR Priority
[] = {'P','r','i','o','r','i','t','y',0};
2400 static const WCHAR IdleSettings
[] = {'I','d','l','e','S','e','t','t','i','n','g','s',0};
2402 static int xml_indent
;
2404 static inline void push_indent(void)
2409 static inline void pop_indent(void)
2414 static inline HRESULT
write_stringW(IStream
*stream
, const WCHAR
*str
)
2416 return IStream_Write(stream
, str
, lstrlenW(str
) * sizeof(WCHAR
), NULL
);
2419 static void write_indent(IStream
*stream
)
2421 static const WCHAR spacesW
[] = {' ',' ',0};
2423 for (i
= 0; i
< xml_indent
; i
+= 2)
2424 write_stringW(stream
, spacesW
);
2427 static const WCHAR start_element
[] = {'<',0};
2428 static const WCHAR start_end_element
[] = {'<','/',0};
2429 static const WCHAR close_element
[] = {'>',0};
2430 static const WCHAR end_empty_element
[] = {'/','>',0};
2431 static const WCHAR eol
[] = {'\n',0};
2432 static const WCHAR spaceW
[] = {' ',0};
2433 static const WCHAR equalW
[] = {'=',0};
2434 static const WCHAR quoteW
[] = {'"',0};
2436 static inline HRESULT
write_empty_element(IStream
*stream
, const WCHAR
*name
)
2438 write_indent(stream
);
2439 write_stringW(stream
, start_element
);
2440 write_stringW(stream
, name
);
2441 write_stringW(stream
, end_empty_element
);
2442 return write_stringW(stream
, eol
);
2445 static inline HRESULT
write_element(IStream
*stream
, const WCHAR
*name
)
2447 write_indent(stream
);
2448 write_stringW(stream
, start_element
);
2449 write_stringW(stream
, name
);
2450 write_stringW(stream
, close_element
);
2451 return write_stringW(stream
, eol
);
2454 static inline HRESULT
write_element_end(IStream
*stream
, const WCHAR
*name
)
2456 write_indent(stream
);
2457 write_stringW(stream
, start_end_element
);
2458 write_stringW(stream
, name
);
2459 write_stringW(stream
, close_element
);
2460 return write_stringW(stream
, eol
);
2463 static inline HRESULT
write_text_value(IStream
*stream
, const WCHAR
*name
, const WCHAR
*value
)
2465 write_indent(stream
);
2466 write_stringW(stream
, start_element
);
2467 write_stringW(stream
, name
);
2468 write_stringW(stream
, close_element
);
2469 write_stringW(stream
, value
);
2470 write_stringW(stream
, start_end_element
);
2471 write_stringW(stream
, name
);
2472 write_stringW(stream
, close_element
);
2473 return write_stringW(stream
, eol
);
2476 static HRESULT
write_task_attributes(IStream
*stream
, ITaskDefinition
*taskdef
)
2479 ITaskSettings
*taskset
;
2480 TASK_COMPATIBILITY level
;
2481 const WCHAR
*compatibility
;
2483 hr
= ITaskDefinition_get_Settings(taskdef
, &taskset
);
2484 if (hr
!= S_OK
) return hr
;
2486 hr
= ITaskSettings_get_Compatibility(taskset
, &level
);
2487 if (hr
!= S_OK
) level
= TASK_COMPATIBILITY_V2_1
;
2489 ITaskSettings_Release(taskset
);
2493 case TASK_COMPATIBILITY_AT
:
2494 compatibility
= v1_0
;
2496 case TASK_COMPATIBILITY_V1
:
2497 compatibility
= v1_1
;
2499 case TASK_COMPATIBILITY_V2
:
2500 compatibility
= v1_2
;
2503 compatibility
= v1_3
;
2507 write_stringW(stream
, start_element
);
2508 write_stringW(stream
, Task
);
2509 write_stringW(stream
, spaceW
);
2510 write_stringW(stream
, version
);
2511 write_stringW(stream
, equalW
);
2512 write_stringW(stream
, quoteW
);
2513 write_stringW(stream
, compatibility
);
2514 write_stringW(stream
, quoteW
);
2515 write_stringW(stream
, spaceW
);
2516 write_stringW(stream
, xmlns
);
2517 write_stringW(stream
, equalW
);
2518 write_stringW(stream
, quoteW
);
2519 write_stringW(stream
, task_ns
);
2520 write_stringW(stream
, quoteW
);
2521 write_stringW(stream
, close_element
);
2522 return write_stringW(stream
, eol
);
2525 static HRESULT
write_registration_info(IStream
*stream
, IRegistrationInfo
*reginfo
)
2532 return write_empty_element(stream
, RegistrationInfo
);
2534 hr
= write_element(stream
, RegistrationInfo
);
2535 if (hr
!= S_OK
) return hr
;
2539 hr
= IRegistrationInfo_get_Source(reginfo
, &bstr
);
2540 if (hr
== S_OK
&& bstr
)
2542 hr
= write_text_value(stream
, Source
, bstr
);
2543 SysFreeString(bstr
);
2544 if (hr
!= S_OK
) return hr
;
2546 hr
= IRegistrationInfo_get_Date(reginfo
, &bstr
);
2547 if (hr
== S_OK
&& bstr
)
2549 hr
= write_text_value(stream
, Date
, bstr
);
2550 SysFreeString(bstr
);
2551 if (hr
!= S_OK
) return hr
;
2553 hr
= IRegistrationInfo_get_Author(reginfo
, &bstr
);
2554 if (hr
== S_OK
&& bstr
)
2556 hr
= write_text_value(stream
, Author
, bstr
);
2557 SysFreeString(bstr
);
2558 if (hr
!= S_OK
) return hr
;
2560 hr
= IRegistrationInfo_get_Version(reginfo
, &bstr
);
2561 if (hr
== S_OK
&& bstr
)
2563 hr
= write_text_value(stream
, Version
, bstr
);
2564 SysFreeString(bstr
);
2565 if (hr
!= S_OK
) return hr
;
2567 hr
= IRegistrationInfo_get_Description(reginfo
, &bstr
);
2568 if (hr
== S_OK
&& bstr
)
2570 hr
= write_text_value(stream
, Description
, bstr
);
2571 SysFreeString(bstr
);
2572 if (hr
!= S_OK
) return hr
;
2574 hr
= IRegistrationInfo_get_Documentation(reginfo
, &bstr
);
2575 if (hr
== S_OK
&& bstr
)
2577 hr
= write_text_value(stream
, Documentation
, bstr
);
2578 SysFreeString(bstr
);
2579 if (hr
!= S_OK
) return hr
;
2581 hr
= IRegistrationInfo_get_URI(reginfo
, &bstr
);
2582 if (hr
== S_OK
&& bstr
)
2584 hr
= write_text_value(stream
, URI
, bstr
);
2585 SysFreeString(bstr
);
2586 if (hr
!= S_OK
) return hr
;
2588 hr
= IRegistrationInfo_get_SecurityDescriptor(reginfo
, &var
);
2591 if (V_VT(&var
) == VT_BSTR
)
2593 hr
= write_text_value(stream
, SecurityDescriptor
, V_BSTR(&var
));
2595 if (hr
!= S_OK
) return hr
;
2598 FIXME("SecurityInfo variant type %d is not supported\n", V_VT(&var
));
2603 return write_element_end(stream
, RegistrationInfo
);
2606 static HRESULT
write_principal(IStream
*stream
, IPrincipal
*principal
)
2610 TASK_LOGON_TYPE logon
;
2611 TASK_RUNLEVEL_TYPE level
;
2614 return write_empty_element(stream
, Principals
);
2616 hr
= write_element(stream
, Principals
);
2617 if (hr
!= S_OK
) return hr
;
2621 hr
= IPrincipal_get_Id(principal
, &bstr
);
2624 write_indent(stream
);
2625 write_stringW(stream
, start_element
);
2626 write_stringW(stream
, principalW
);
2627 write_stringW(stream
, spaceW
);
2628 write_stringW(stream
, id
);
2629 write_stringW(stream
, equalW
);
2630 write_stringW(stream
, quoteW
);
2631 write_stringW(stream
, bstr
);
2632 write_stringW(stream
, quoteW
);
2633 write_stringW(stream
, close_element
);
2634 write_stringW(stream
, eol
);
2635 SysFreeString(bstr
);
2638 write_element(stream
, principalW
);
2642 hr
= IPrincipal_get_GroupId(principal
, &bstr
);
2645 hr
= write_text_value(stream
, GroupId
, bstr
);
2646 SysFreeString(bstr
);
2647 if (hr
!= S_OK
) return hr
;
2649 hr
= IPrincipal_get_DisplayName(principal
, &bstr
);
2652 hr
= write_text_value(stream
, DisplayName
, bstr
);
2653 SysFreeString(bstr
);
2654 if (hr
!= S_OK
) return hr
;
2656 hr
= IPrincipal_get_UserId(principal
, &bstr
);
2657 if (hr
== S_OK
&& lstrlenW(bstr
))
2659 hr
= write_text_value(stream
, UserId
, bstr
);
2660 SysFreeString(bstr
);
2661 if (hr
!= S_OK
) return hr
;
2663 hr
= IPrincipal_get_RunLevel(principal
, &level
);
2666 const WCHAR
*level_str
= NULL
;
2670 case TASK_RUNLEVEL_HIGHEST
:
2671 level_str
= HighestAvailable
;
2673 case TASK_RUNLEVEL_LUA
:
2674 level_str
= LeastPrivilege
;
2677 FIXME("Principal run level %d\n", level
);
2683 hr
= write_text_value(stream
, RunLevel
, level_str
);
2684 if (hr
!= S_OK
) return hr
;
2687 hr
= IPrincipal_get_LogonType(principal
, &logon
);
2690 const WCHAR
*logon_str
= NULL
;
2694 case TASK_LOGON_PASSWORD
:
2695 logon_str
= Password
;
2697 case TASK_LOGON_S4U
:
2700 case TASK_LOGON_INTERACTIVE_TOKEN
:
2701 logon_str
= InteractiveToken
;
2704 FIXME("Principal logon type %d\n", logon
);
2710 hr
= write_text_value(stream
, LogonType
, logon_str
);
2711 if (hr
!= S_OK
) return hr
;
2716 write_element_end(stream
, principalW
);
2719 return write_element_end(stream
, Principals
);
2722 static HRESULT
write_settings(IStream
*stream
, ITaskSettings
*settings
)
2725 return write_empty_element(stream
, Settings
);
2731 static HRESULT
write_triggers(IStream
*stream
, ITriggerCollection
*triggers
)
2734 return write_empty_element(stream
, Triggers
);
2740 static HRESULT
write_actions(IStream
*stream
, IActionCollection
*actions
)
2744 write_element(stream
, actionsW
);
2746 write_empty_element(stream
, Exec
);
2748 return write_element_end(stream
, actionsW
);
2755 static HRESULT WINAPI
TaskDefinition_get_XmlText(ITaskDefinition
*iface
, BSTR
*xml
)
2757 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2763 TRACE("%p,%p\n", iface
, xml
);
2765 hmem
= GlobalAlloc(GMEM_MOVEABLE
| GMEM_NODISCARD
, 16);
2766 if (!hmem
) return E_OUTOFMEMORY
;
2768 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, &stream
);
2775 hr
= write_task_attributes(stream
, &taskdef
->ITaskDefinition_iface
);
2776 if (hr
!= S_OK
) goto failed
;
2780 hr
= write_registration_info(stream
, taskdef
->reginfo
);
2781 if (hr
!= S_OK
) goto failed
;
2783 hr
= write_triggers(stream
, taskdef
->triggers
);
2784 if (hr
!= S_OK
) goto failed
;
2786 hr
= write_principal(stream
, taskdef
->principal
);
2787 if (hr
!= S_OK
) goto failed
;
2789 hr
= write_settings(stream
, taskdef
->taskset
);
2790 if (hr
!= S_OK
) goto failed
;
2792 hr
= write_actions(stream
, taskdef
->actions
);
2793 if (hr
!= S_OK
) goto failed
;
2797 write_element_end(stream
, Task
);
2798 IStream_Write(stream
, "\0\0", 2, NULL
);
2800 p
= GlobalLock(hmem
);
2801 *xml
= SysAllocString(p
);
2804 IStream_Release(stream
);
2806 return *xml
? S_OK
: E_OUTOFMEMORY
;
2809 IStream_Release(stream
);
2813 static HRESULT
read_text_value(IXmlReader
*reader
, WCHAR
**value
)
2818 while (IXmlReader_Read(reader
, &type
) == S_OK
)
2822 case XmlNodeType_Text
:
2823 hr
= IXmlReader_GetValue(reader
, (const WCHAR
**)value
, NULL
);
2824 if (hr
!= S_OK
) return hr
;
2825 TRACE("%s\n", debugstr_w(*value
));
2828 case XmlNodeType_Whitespace
:
2829 case XmlNodeType_Comment
:
2833 FIXME("unexpected node type %d\n", type
);
2841 static HRESULT
read_variantbool_value(IXmlReader
*reader
, VARIANT_BOOL
*vbool
)
2843 static const WCHAR trueW
[] = {'t','r','u','e',0};
2844 static const WCHAR falseW
[] = {'f','a','l','s','e',0};
2848 hr
= read_text_value(reader
, &value
);
2849 if (hr
!= S_OK
) return hr
;
2851 if (!lstrcmpW(value
, trueW
))
2852 *vbool
= VARIANT_TRUE
;
2853 else if (!lstrcmpW(value
, falseW
))
2854 *vbool
= VARIANT_FALSE
;
2857 WARN("unexpected bool value %s\n", debugstr_w(value
));
2858 return SCHED_E_INVALIDVALUE
;
2864 static HRESULT
read_int_value(IXmlReader
*reader
, int *int_val
)
2869 hr
= read_text_value(reader
, &value
);
2870 if (hr
!= S_OK
) return hr
;
2872 *int_val
= strtolW(value
, NULL
, 10);
2877 static HRESULT
read_triggers(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
2883 static HRESULT
read_principal_attributes(IXmlReader
*reader
, IPrincipal
*principal
)
2889 hr
= IXmlReader_MoveToFirstAttribute(reader
);
2893 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2894 if (hr
!= S_OK
) break;
2896 hr
= IXmlReader_GetValue(reader
, &value
, NULL
);
2897 if (hr
!= S_OK
) break;
2899 TRACE("%s=%s\n", debugstr_w(name
), debugstr_w(value
));
2901 if (!lstrcmpW(name
, id
))
2902 IPrincipal_put_Id(principal
, (BSTR
)value
);
2904 FIXME("unhandled Principal attribute %s\n", debugstr_w(name
));
2906 hr
= IXmlReader_MoveToNextAttribute(reader
);
2912 static HRESULT
read_principal(IXmlReader
*reader
, IPrincipal
*principal
)
2919 if (IXmlReader_IsEmptyElement(reader
))
2921 TRACE("Principal is empty\n");
2925 read_principal_attributes(reader
, principal
);
2927 while (IXmlReader_Read(reader
, &type
) == S_OK
)
2931 case XmlNodeType_EndElement
:
2932 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2933 if (hr
!= S_OK
) return hr
;
2935 TRACE("/%s\n", debugstr_w(name
));
2937 if (!lstrcmpW(name
, principalW
))
2942 case XmlNodeType_Element
:
2943 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2944 if (hr
!= S_OK
) return hr
;
2946 TRACE("Element: %s\n", debugstr_w(name
));
2948 if (!lstrcmpW(name
, UserId
))
2950 hr
= read_text_value(reader
, &value
);
2952 IPrincipal_put_UserId(principal
, value
);
2954 else if (!lstrcmpW(name
, LogonType
))
2956 hr
= read_text_value(reader
, &value
);
2959 TASK_LOGON_TYPE logon
= TASK_LOGON_NONE
;
2961 if (!lstrcmpW(value
, InteractiveToken
))
2962 logon
= TASK_LOGON_INTERACTIVE_TOKEN
;
2964 FIXME("unhandled LogonType %s\n", debugstr_w(value
));
2966 IPrincipal_put_LogonType(principal
, logon
);
2969 else if (!lstrcmpW(name
, RunLevel
))
2971 hr
= read_text_value(reader
, &value
);
2974 TASK_RUNLEVEL_TYPE level
= TASK_RUNLEVEL_LUA
;
2976 if (!lstrcmpW(value
, LeastPrivilege
))
2977 level
= TASK_RUNLEVEL_LUA
;
2979 FIXME("unhandled RunLevel %s\n", debugstr_w(value
));
2981 IPrincipal_put_RunLevel(principal
, level
);
2985 FIXME("unhandled Principal element %s\n", debugstr_w(name
));
2989 case XmlNodeType_Whitespace
:
2990 case XmlNodeType_Comment
:
2994 FIXME("unhandled Principal node type %d\n", type
);
2999 WARN("Principal was not terminated\n");
3003 static HRESULT
read_principals(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3009 if (IXmlReader_IsEmptyElement(reader
))
3011 TRACE("Principals is empty\n");
3015 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3019 case XmlNodeType_EndElement
:
3020 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3021 if (hr
!= S_OK
) return hr
;
3023 TRACE("/%s\n", debugstr_w(name
));
3025 if (!lstrcmpW(name
, Principals
))
3030 case XmlNodeType_Element
:
3031 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3032 if (hr
!= S_OK
) return hr
;
3034 TRACE("Element: %s\n", debugstr_w(name
));
3036 if (!lstrcmpW(name
, principalW
))
3038 IPrincipal
*principal
;
3040 hr
= ITaskDefinition_get_Principal(taskdef
, &principal
);
3041 if (hr
!= S_OK
) return hr
;
3042 hr
= read_principal(reader
, principal
);
3043 IPrincipal_Release(principal
);
3046 FIXME("unhandled Principals element %s\n", debugstr_w(name
));
3050 case XmlNodeType_Whitespace
:
3051 case XmlNodeType_Comment
:
3055 FIXME("unhandled Principals node type %d\n", type
);
3060 WARN("Principals was not terminated\n");
3064 static HRESULT
read_actions(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3070 static HRESULT
read_idle_settings(IXmlReader
*reader
, ITaskSettings
*taskset
)
3076 static HRESULT
read_settings(IXmlReader
*reader
, ITaskSettings
*taskset
)
3082 VARIANT_BOOL bool_val
;
3085 if (IXmlReader_IsEmptyElement(reader
))
3087 TRACE("Settings is empty\n");
3091 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3095 case XmlNodeType_EndElement
:
3096 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3097 if (hr
!= S_OK
) return hr
;
3099 TRACE("/%s\n", debugstr_w(name
));
3101 if (!lstrcmpW(name
, Settings
))
3106 case XmlNodeType_Element
:
3107 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3108 if (hr
!= S_OK
) return hr
;
3110 TRACE("Element: %s\n", debugstr_w(name
));
3112 if (!lstrcmpW(name
, MultipleInstancesPolicy
))
3114 hr
= read_text_value(reader
, &value
);
3117 int_val
= TASK_INSTANCES_IGNORE_NEW
;
3119 if (!lstrcmpW(value
, IgnoreNew
))
3120 int_val
= TASK_INSTANCES_IGNORE_NEW
;
3122 FIXME("unhandled MultipleInstancesPolicy %s\n", debugstr_w(value
));
3124 ITaskSettings_put_MultipleInstances(taskset
, int_val
);
3127 else if (!lstrcmpW(name
, DisallowStartIfOnBatteries
))
3129 hr
= read_variantbool_value(reader
, &bool_val
);
3130 if (hr
!= S_OK
) return hr
;
3131 ITaskSettings_put_DisallowStartIfOnBatteries(taskset
, bool_val
);
3133 else if (!lstrcmpW(name
, AllowStartOnDemand
))
3135 hr
= read_variantbool_value(reader
, &bool_val
);
3136 if (hr
!= S_OK
) return hr
;
3137 ITaskSettings_put_AllowDemandStart(taskset
, bool_val
);
3139 else if (!lstrcmpW(name
, StopIfGoingOnBatteries
))
3141 hr
= read_variantbool_value(reader
, &bool_val
);
3142 if (hr
!= S_OK
) return hr
;
3143 ITaskSettings_put_StopIfGoingOnBatteries(taskset
, bool_val
);
3145 else if (!lstrcmpW(name
, AllowHardTerminate
))
3147 hr
= read_variantbool_value(reader
, &bool_val
);
3148 if (hr
!= S_OK
) return hr
;
3149 ITaskSettings_put_AllowHardTerminate(taskset
, bool_val
);
3151 else if (!lstrcmpW(name
, StartWhenAvailable
))
3153 hr
= read_variantbool_value(reader
, &bool_val
);
3154 if (hr
!= S_OK
) return hr
;
3155 ITaskSettings_put_StartWhenAvailable(taskset
, bool_val
);
3157 else if (!lstrcmpW(name
, RunOnlyIfNetworkAvailable
))
3159 hr
= read_variantbool_value(reader
, &bool_val
);
3160 if (hr
!= S_OK
) return hr
;
3161 ITaskSettings_put_RunOnlyIfNetworkAvailable(taskset
, bool_val
);
3163 else if (!lstrcmpW(name
, Enabled
))
3165 hr
= read_variantbool_value(reader
, &bool_val
);
3166 if (hr
!= S_OK
) return hr
;
3167 ITaskSettings_put_Enabled(taskset
, bool_val
);
3169 else if (!lstrcmpW(name
, Hidden
))
3171 hr
= read_variantbool_value(reader
, &bool_val
);
3172 if (hr
!= S_OK
) return hr
;
3173 ITaskSettings_put_Hidden(taskset
, bool_val
);
3175 else if (!lstrcmpW(name
, RunOnlyIfIdle
))
3177 hr
= read_variantbool_value(reader
, &bool_val
);
3178 if (hr
!= S_OK
) return hr
;
3179 ITaskSettings_put_RunOnlyIfIdle(taskset
, bool_val
);
3181 else if (!lstrcmpW(name
, WakeToRun
))
3183 hr
= read_variantbool_value(reader
, &bool_val
);
3184 if (hr
!= S_OK
) return hr
;
3185 ITaskSettings_put_WakeToRun(taskset
, bool_val
);
3187 else if (!lstrcmpW(name
, ExecutionTimeLimit
))
3189 hr
= read_text_value(reader
, &value
);
3191 ITaskSettings_put_ExecutionTimeLimit(taskset
, value
);
3193 else if (!lstrcmpW(name
, Priority
))
3195 hr
= read_int_value(reader
, &int_val
);
3197 ITaskSettings_put_Priority(taskset
, int_val
);
3199 else if (!lstrcmpW(name
, IdleSettings
))
3201 hr
= read_idle_settings(reader
, taskset
);
3202 if (hr
!= S_OK
) return hr
;
3205 FIXME("unhandled Settings element %s\n", debugstr_w(name
));
3209 case XmlNodeType_Whitespace
:
3210 case XmlNodeType_Comment
:
3214 FIXME("unhandled Settings node type %d\n", type
);
3219 WARN("Settings was not terminated\n");
3220 return SCHED_E_MALFORMEDXML
;
3223 static HRESULT
read_registration_info(IXmlReader
*reader
, IRegistrationInfo
*info
)
3230 if (IXmlReader_IsEmptyElement(reader
))
3232 TRACE("RegistrationInfo is empty\n");
3236 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3240 case XmlNodeType_EndElement
:
3241 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3242 if (hr
!= S_OK
) return hr
;
3244 TRACE("/%s\n", debugstr_w(name
));
3246 if (!lstrcmpW(name
, RegistrationInfo
))
3251 case XmlNodeType_Element
:
3252 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3253 if (hr
!= S_OK
) return hr
;
3255 TRACE("Element: %s\n", debugstr_w(name
));
3257 if (!lstrcmpW(name
, Author
))
3259 hr
= read_text_value(reader
, &value
);
3261 IRegistrationInfo_put_Author(info
, value
);
3263 else if (!lstrcmpW(name
, Description
))
3265 hr
= read_text_value(reader
, &value
);
3267 IRegistrationInfo_put_Description(info
, value
);
3270 FIXME("unhandled RegistrationInfo element %s\n", debugstr_w(name
));
3274 case XmlNodeType_Whitespace
:
3275 case XmlNodeType_Comment
:
3279 FIXME("unhandled RegistrationInfo node type %d\n", type
);
3284 WARN("RegistrationInfo was not terminated\n");
3285 return SCHED_E_MALFORMEDXML
;
3288 static HRESULT
read_task_attributes(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3291 ITaskSettings
*taskset
;
3294 BOOL xmlns_ok
= FALSE
;
3298 hr
= ITaskDefinition_get_Settings(taskdef
, &taskset
);
3299 if (hr
!= S_OK
) return hr
;
3301 hr
= IXmlReader_MoveToFirstAttribute(reader
);
3305 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3306 if (hr
!= S_OK
) break;
3308 hr
= IXmlReader_GetValue(reader
, &value
, NULL
);
3309 if (hr
!= S_OK
) break;
3311 TRACE("%s=%s\n", debugstr_w(name
), debugstr_w(value
));
3313 if (!lstrcmpW(name
, version
))
3315 TASK_COMPATIBILITY compatibility
= TASK_COMPATIBILITY_V2
;
3317 if (!lstrcmpW(value
, v1_0
))
3318 compatibility
= TASK_COMPATIBILITY_AT
;
3319 else if (!lstrcmpW(value
, v1_1
))
3320 compatibility
= TASK_COMPATIBILITY_V1
;
3321 else if (!lstrcmpW(value
, v1_2
))
3322 compatibility
= TASK_COMPATIBILITY_V2
;
3323 else if (!lstrcmpW(value
, v1_3
))
3324 compatibility
= TASK_COMPATIBILITY_V2_1
;
3326 FIXME("unknown version %s\n", debugstr_w(value
));
3328 ITaskSettings_put_Compatibility(taskset
, compatibility
);
3330 else if (!lstrcmpW(name
, xmlns
))
3332 if (lstrcmpW(value
, task_ns
))
3334 FIXME("unknown namespace %s\n", debugstr_w(value
));
3340 FIXME("unhandled Task attribute %s\n", debugstr_w(name
));
3342 hr
= IXmlReader_MoveToNextAttribute(reader
);
3345 ITaskSettings_Release(taskset
);
3346 return xmlns_ok
? S_OK
: SCHED_E_NAMESPACE
;
3349 static HRESULT
read_task(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3355 if (IXmlReader_IsEmptyElement(reader
))
3357 TRACE("Task is empty\n");
3361 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3365 case XmlNodeType_EndElement
:
3366 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3367 if (hr
!= S_OK
) return hr
;
3369 TRACE("/%s\n", debugstr_w(name
));
3371 if (!lstrcmpW(name
, Task
))
3376 case XmlNodeType_Element
:
3377 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3378 if (hr
!= S_OK
) return hr
;
3380 TRACE("Element: %s\n", debugstr_w(name
));
3382 if (!lstrcmpW(name
, RegistrationInfo
))
3384 IRegistrationInfo
*info
;
3386 hr
= ITaskDefinition_get_RegistrationInfo(taskdef
, &info
);
3387 if (hr
!= S_OK
) return hr
;
3388 hr
= read_registration_info(reader
, info
);
3389 IRegistrationInfo_Release(info
);
3391 else if (!lstrcmpW(name
, Settings
))
3393 ITaskSettings
*taskset
;
3395 hr
= ITaskDefinition_get_Settings(taskdef
, &taskset
);
3396 if (hr
!= S_OK
) return hr
;
3397 hr
= read_settings(reader
, taskset
);
3398 ITaskSettings_Release(taskset
);
3400 else if (!lstrcmpW(name
, Triggers
))
3401 hr
= read_triggers(reader
, taskdef
);
3402 else if (!lstrcmpW(name
, Principals
))
3403 hr
= read_principals(reader
, taskdef
);
3404 else if (!lstrcmpW(name
, actionsW
))
3405 hr
= read_actions(reader
, taskdef
);
3407 FIXME("unhandled Task element %s\n", debugstr_w(name
));
3409 if (hr
!= S_OK
) return hr
;
3412 case XmlNodeType_Comment
:
3413 case XmlNodeType_Whitespace
:
3417 FIXME("unhandled Task node type %d\n", type
);
3422 WARN("Task was not terminated\n");
3423 return SCHED_E_MALFORMEDXML
;
3426 static HRESULT
read_xml(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3432 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3436 case XmlNodeType_XmlDeclaration
:
3437 TRACE("XmlDeclaration\n");
3440 case XmlNodeType_Element
:
3441 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3442 if (hr
!= S_OK
) return hr
;
3444 TRACE("Element: %s\n", debugstr_w(name
));
3446 if (!lstrcmpW(name
, Task
))
3448 hr
= read_task_attributes(reader
, taskdef
);
3449 if (hr
!= S_OK
) return hr
;
3451 return read_task(reader
, taskdef
);
3454 FIXME("unhandled XML element %s\n", debugstr_w(name
));
3458 case XmlNodeType_Comment
:
3459 case XmlNodeType_Whitespace
:
3463 FIXME("unhandled XML node type %d\n", type
);
3468 WARN("Task definition was not found\n");
3469 return SCHED_E_MALFORMEDXML
;
3472 static HRESULT WINAPI
TaskDefinition_put_XmlText(ITaskDefinition
*iface
, BSTR xml
)
3474 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
3481 TRACE("%p,%s\n", iface
, debugstr_w(xml
));
3483 if (!xml
) return E_INVALIDARG
;
3485 hmem
= GlobalAlloc(0, lstrlenW(xml
) * sizeof(WCHAR
));
3486 if (!hmem
) return E_OUTOFMEMORY
;
3488 buf
= GlobalLock(hmem
);
3489 memcpy(buf
, xml
, lstrlenW(xml
) * sizeof(WCHAR
));
3492 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, &stream
);
3499 hr
= CreateXmlReader(&IID_IXmlReader
, (void **)&reader
, NULL
);
3502 IStream_Release(stream
);
3506 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
3509 if (taskdef
->reginfo
)
3511 IRegistrationInfo_Release(taskdef
->reginfo
);
3512 taskdef
->reginfo
= NULL
;
3514 if (taskdef
->taskset
)
3516 ITaskSettings_Release(taskdef
->taskset
);
3517 taskdef
->taskset
= NULL
;
3519 if (taskdef
->triggers
)
3521 ITriggerCollection_Release(taskdef
->triggers
);
3522 taskdef
->triggers
= NULL
;
3524 if (taskdef
->principal
)
3526 IPrincipal_Release(taskdef
->principal
);
3527 taskdef
->principal
= NULL
;
3529 if (taskdef
->actions
)
3531 IActionCollection_Release(taskdef
->actions
);
3532 taskdef
->actions
= NULL
;
3535 hr
= read_xml(reader
, iface
);
3538 IXmlReader_Release(reader
);
3539 IStream_Release(stream
);
3544 static const ITaskDefinitionVtbl TaskDefinition_vtbl
=
3546 TaskDefinition_QueryInterface
,
3547 TaskDefinition_AddRef
,
3548 TaskDefinition_Release
,
3549 TaskDefinition_GetTypeInfoCount
,
3550 TaskDefinition_GetTypeInfo
,
3551 TaskDefinition_GetIDsOfNames
,
3552 TaskDefinition_Invoke
,
3553 TaskDefinition_get_RegistrationInfo
,
3554 TaskDefinition_put_RegistrationInfo
,
3555 TaskDefinition_get_Triggers
,
3556 TaskDefinition_put_Triggers
,
3557 TaskDefinition_get_Settings
,
3558 TaskDefinition_put_Settings
,
3559 TaskDefinition_get_Data
,
3560 TaskDefinition_put_Data
,
3561 TaskDefinition_get_Principal
,
3562 TaskDefinition_put_Principal
,
3563 TaskDefinition_get_Actions
,
3564 TaskDefinition_put_Actions
,
3565 TaskDefinition_get_XmlText
,
3566 TaskDefinition_put_XmlText
3569 HRESULT
TaskDefinition_create(ITaskDefinition
**obj
)
3571 TaskDefinition
*taskdef
;
3573 taskdef
= heap_alloc_zero(sizeof(*taskdef
));
3574 if (!taskdef
) return E_OUTOFMEMORY
;
3576 taskdef
->ITaskDefinition_iface
.lpVtbl
= &TaskDefinition_vtbl
;
3578 *obj
= &taskdef
->ITaskDefinition_iface
;
3580 TRACE("created %p\n", *obj
);
3587 ITaskService ITaskService_iface
;
3591 WCHAR comp_name
[MAX_COMPUTERNAME_LENGTH
+ 1];
3594 static inline TaskService
*impl_from_ITaskService(ITaskService
*iface
)
3596 return CONTAINING_RECORD(iface
, TaskService
, ITaskService_iface
);
3599 static ULONG WINAPI
TaskService_AddRef(ITaskService
*iface
)
3601 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3602 return InterlockedIncrement(&task_svc
->ref
);
3605 static ULONG WINAPI
TaskService_Release(ITaskService
*iface
)
3607 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3608 LONG ref
= InterlockedDecrement(&task_svc
->ref
);
3612 TRACE("destroying %p\n", iface
);
3613 heap_free(task_svc
);
3619 static HRESULT WINAPI
TaskService_QueryInterface(ITaskService
*iface
, REFIID riid
, void **obj
)
3621 if (!riid
|| !obj
) return E_INVALIDARG
;
3623 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
3625 if (IsEqualGUID(riid
, &IID_ITaskService
) ||
3626 IsEqualGUID(riid
, &IID_IDispatch
) ||
3627 IsEqualGUID(riid
, &IID_IUnknown
))
3629 ITaskService_AddRef(iface
);
3634 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
3636 return E_NOINTERFACE
;
3639 static HRESULT WINAPI
TaskService_GetTypeInfoCount(ITaskService
*iface
, UINT
*count
)
3641 FIXME("%p,%p: stub\n", iface
, count
);
3645 static HRESULT WINAPI
TaskService_GetTypeInfo(ITaskService
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
3647 FIXME("%p,%u,%u,%p: stub\n", iface
, index
, lcid
, info
);
3651 static HRESULT WINAPI
TaskService_GetIDsOfNames(ITaskService
*iface
, REFIID riid
, LPOLESTR
*names
,
3652 UINT count
, LCID lcid
, DISPID
*dispid
)
3654 FIXME("%p,%s,%p,%u,%u,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3658 static HRESULT WINAPI
TaskService_Invoke(ITaskService
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
3659 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
3661 FIXME("%p,%d,%s,%04x,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
3662 params
, result
, excepinfo
, argerr
);
3666 static HRESULT WINAPI
TaskService_GetFolder(ITaskService
*iface
, BSTR path
, ITaskFolder
**folder
)
3668 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3670 TRACE("%p,%s,%p\n", iface
, debugstr_w(path
), folder
);
3672 if (!folder
) return E_POINTER
;
3674 if (!task_svc
->connected
)
3675 return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
);
3677 return TaskFolder_create(path
, NULL
, folder
, FALSE
);
3680 static HRESULT WINAPI
TaskService_GetRunningTasks(ITaskService
*iface
, LONG flags
, IRunningTaskCollection
**tasks
)
3682 FIXME("%p,%x,%p: stub\n", iface
, flags
, tasks
);
3686 static HRESULT WINAPI
TaskService_NewTask(ITaskService
*iface
, DWORD flags
, ITaskDefinition
**definition
)
3688 TRACE("%p,%x,%p\n", iface
, flags
, definition
);
3690 if (!definition
) return E_POINTER
;
3693 FIXME("unsupported flags %x\n", flags
);
3695 return TaskDefinition_create(definition
);
3698 static inline BOOL
is_variant_null(const VARIANT
*var
)
3700 return V_VT(var
) == VT_EMPTY
|| V_VT(var
) == VT_NULL
||
3701 (V_VT(var
) == VT_BSTR
&& (V_BSTR(var
) == NULL
|| !*V_BSTR(var
)));
3704 static HRESULT
start_schedsvc(void)
3706 static const WCHAR scheduleW
[] = { 'S','c','h','e','d','u','l','e',0 };
3707 SC_HANDLE scm
, service
;
3708 SERVICE_STATUS_PROCESS status
;
3709 ULONGLONG start_time
;
3710 HRESULT hr
= SCHED_E_SERVICE_NOT_RUNNING
;
3712 TRACE("Trying to start %s service\n", debugstr_w(scheduleW
));
3714 scm
= OpenSCManagerW(NULL
, NULL
, 0);
3715 if (!scm
) return SCHED_E_SERVICE_NOT_INSTALLED
;
3717 service
= OpenServiceW(scm
, scheduleW
, SERVICE_START
| SERVICE_QUERY_STATUS
);
3720 if (StartServiceW(service
, 0, NULL
) || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING
)
3722 start_time
= GetTickCount64();
3727 if (!QueryServiceStatusEx(service
, SC_STATUS_PROCESS_INFO
, (BYTE
*)&status
, sizeof(status
), &dummy
))
3729 WARN("failed to query scheduler status (%u)\n", GetLastError());
3733 if (status
.dwCurrentState
== SERVICE_RUNNING
)
3739 if (GetTickCount64() - start_time
> 30000) break;
3742 } while (status
.dwCurrentState
== SERVICE_START_PENDING
);
3744 if (status
.dwCurrentState
!= SERVICE_RUNNING
)
3745 WARN("scheduler failed to start %u\n", status
.dwCurrentState
);
3748 WARN("failed to start scheduler service (%u)\n", GetLastError());
3750 CloseServiceHandle(service
);
3753 WARN("failed to open scheduler service (%u)\n", GetLastError());
3755 CloseServiceHandle(scm
);
3759 static HRESULT WINAPI
TaskService_Connect(ITaskService
*iface
, VARIANT server
, VARIANT user
, VARIANT domain
, VARIANT password
)
3761 static WCHAR ncalrpc
[] = { 'n','c','a','l','r','p','c',0 };
3762 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3763 WCHAR comp_name
[MAX_COMPUTERNAME_LENGTH
+ 1];
3766 RPC_WSTR binding_str
;
3767 extern handle_t rpc_handle
;
3769 TRACE("%p,%s,%s,%s,%s\n", iface
, debugstr_variant(&server
), debugstr_variant(&user
),
3770 debugstr_variant(&domain
), debugstr_variant(&password
));
3772 if (!is_variant_null(&user
) || !is_variant_null(&domain
) || !is_variant_null(&password
))
3773 FIXME("user/domain/password are ignored\n");
3775 len
= sizeof(comp_name
)/sizeof(comp_name
[0]);
3776 if (!GetComputerNameW(comp_name
, &len
))
3777 return HRESULT_FROM_WIN32(GetLastError());
3779 if (!is_variant_null(&server
))
3781 const WCHAR
*server_name
;
3783 if (V_VT(&server
) != VT_BSTR
)
3785 FIXME("server variant type %d is not supported\n", V_VT(&server
));
3786 return HRESULT_FROM_WIN32(ERROR_BAD_NETPATH
);
3789 /* skip UNC prefix if any */
3790 server_name
= V_BSTR(&server
);
3791 if (server_name
[0] == '\\' && server_name
[1] == '\\')
3794 if (strcmpiW(server_name
, comp_name
))
3796 FIXME("connection to remote server %s is not supported\n", debugstr_w(V_BSTR(&server
)));
3797 return HRESULT_FROM_WIN32(ERROR_BAD_NETPATH
);
3801 hr
= start_schedsvc();
3802 if (hr
!= S_OK
) return hr
;
3804 hr
= RpcStringBindingComposeW(NULL
, ncalrpc
, NULL
, NULL
, NULL
, &binding_str
);
3805 if (hr
!= RPC_S_OK
) return hr
;
3806 hr
= RpcBindingFromStringBindingW(binding_str
, &rpc_handle
);
3807 RpcStringFreeW(&binding_str
);
3808 if (hr
!= RPC_S_OK
) return hr
;
3810 /* Make sure that the connection works */
3811 hr
= SchRpcHighestVersion(&task_svc
->version
);
3812 if (hr
!= S_OK
) return hr
;
3814 TRACE("server version %#x\n", task_svc
->version
);
3816 strcpyW(task_svc
->comp_name
, comp_name
);
3817 task_svc
->connected
= TRUE
;
3822 static HRESULT WINAPI
TaskService_get_Connected(ITaskService
*iface
, VARIANT_BOOL
*connected
)
3824 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3826 TRACE("%p,%p\n", iface
, connected
);
3828 if (!connected
) return E_POINTER
;
3830 *connected
= task_svc
->connected
? VARIANT_TRUE
: VARIANT_FALSE
;
3835 static HRESULT WINAPI
TaskService_get_TargetServer(ITaskService
*iface
, BSTR
*server
)
3837 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3839 TRACE("%p,%p\n", iface
, server
);
3841 if (!server
) return E_POINTER
;
3843 if (!task_svc
->connected
)
3844 return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
);
3846 *server
= SysAllocString(task_svc
->comp_name
);
3847 if (!*server
) return E_OUTOFMEMORY
;
3852 static HRESULT WINAPI
TaskService_get_ConnectedUser(ITaskService
*iface
, BSTR
*user
)
3854 FIXME("%p,%p: stub\n", iface
, user
);
3858 static HRESULT WINAPI
TaskService_get_ConnectedDomain(ITaskService
*iface
, BSTR
*domain
)
3860 FIXME("%p,%p: stub\n", iface
, domain
);
3864 static HRESULT WINAPI
TaskService_get_HighestVersion(ITaskService
*iface
, DWORD
*version
)
3866 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3868 TRACE("%p,%p\n", iface
, version
);
3870 if (!version
) return E_POINTER
;
3872 if (!task_svc
->connected
)
3873 return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
);
3875 *version
= task_svc
->version
;
3880 static const ITaskServiceVtbl TaskService_vtbl
=
3882 TaskService_QueryInterface
,
3884 TaskService_Release
,
3885 TaskService_GetTypeInfoCount
,
3886 TaskService_GetTypeInfo
,
3887 TaskService_GetIDsOfNames
,
3889 TaskService_GetFolder
,
3890 TaskService_GetRunningTasks
,
3891 TaskService_NewTask
,
3892 TaskService_Connect
,
3893 TaskService_get_Connected
,
3894 TaskService_get_TargetServer
,
3895 TaskService_get_ConnectedUser
,
3896 TaskService_get_ConnectedDomain
,
3897 TaskService_get_HighestVersion
3900 HRESULT
TaskService_create(void **obj
)
3902 TaskService
*task_svc
;
3904 task_svc
= heap_alloc(sizeof(*task_svc
));
3905 if (!task_svc
) return E_OUTOFMEMORY
;
3907 task_svc
->ITaskService_iface
.lpVtbl
= &TaskService_vtbl
;
3909 task_svc
->connected
= FALSE
;
3910 *obj
= &task_svc
->ITaskService_iface
;
3912 TRACE("created %p\n", *obj
);
3917 void __RPC_FAR
*__RPC_USER
MIDL_user_allocate(SIZE_T n
)
3919 return HeapAlloc(GetProcessHeap(), 0, n
);
3922 void __RPC_USER
MIDL_user_free(void __RPC_FAR
*p
)
3924 HeapFree(GetProcessHeap(), 0, p
);