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/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(taskschd
);
38 IDailyTrigger IDailyTrigger_iface
;
41 WCHAR
*start_boundary
;
45 static inline DailyTrigger
*impl_from_IDailyTrigger(IDailyTrigger
*iface
)
47 return CONTAINING_RECORD(iface
, DailyTrigger
, IDailyTrigger_iface
);
50 static HRESULT WINAPI
DailyTrigger_QueryInterface(IDailyTrigger
*iface
, REFIID riid
, void **ppv
)
52 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
54 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
56 if(IsEqualGUID(&IID_IUnknown
, riid
) ||
57 IsEqualGUID(&IID_IDispatch
, riid
) ||
58 IsEqualGUID(&IID_ITrigger
, riid
) ||
59 IsEqualGUID(&IID_IDailyTrigger
, riid
))
61 *ppv
= &This
->IDailyTrigger_iface
;
65 FIXME("unsupported riid %s\n", debugstr_guid(riid
));
70 IUnknown_AddRef((IUnknown
*)*ppv
);
74 static ULONG WINAPI
DailyTrigger_AddRef(IDailyTrigger
*iface
)
76 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
77 LONG ref
= InterlockedIncrement(&This
->ref
);
79 TRACE("(%p) ref=%ld\n", This
, ref
);
84 static ULONG WINAPI
DailyTrigger_Release(IDailyTrigger
*iface
)
86 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
87 LONG ref
= InterlockedDecrement(&This
->ref
);
89 TRACE("(%p) ref=%ld\n", This
, ref
);
93 TRACE("destroying %p\n", iface
);
94 heap_free(This
->start_boundary
);
101 static HRESULT WINAPI
DailyTrigger_GetTypeInfoCount(IDailyTrigger
*iface
, UINT
*count
)
103 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
104 FIXME("(%p)->(%p)\n", This
, count
);
108 static HRESULT WINAPI
DailyTrigger_GetTypeInfo(IDailyTrigger
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
110 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
111 FIXME("(%p)->(%u %lu %p)\n", This
, index
, lcid
, info
);
115 static HRESULT WINAPI
DailyTrigger_GetIDsOfNames(IDailyTrigger
*iface
, REFIID riid
, LPOLESTR
*names
,
116 UINT count
, LCID lcid
, DISPID
*dispid
)
118 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
119 FIXME("(%p)->(%s %p %u %lu %p)\n", This
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
123 static HRESULT WINAPI
DailyTrigger_Invoke(IDailyTrigger
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
124 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
126 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
127 FIXME("(%p)->(%ld %s %lx %x %p %p %p %p)\n", This
, dispid
, debugstr_guid(riid
), lcid
, flags
,
128 params
, result
, excepinfo
, argerr
);
132 static HRESULT WINAPI
DailyTrigger_get_Type(IDailyTrigger
*iface
, TASK_TRIGGER_TYPE2
*type
)
134 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
135 FIXME("(%p)->(%p)\n", This
, type
);
139 static HRESULT WINAPI
DailyTrigger_get_Id(IDailyTrigger
*iface
, BSTR
*id
)
141 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
142 FIXME("(%p)->(%p)\n", This
, id
);
146 static HRESULT WINAPI
DailyTrigger_put_Id(IDailyTrigger
*iface
, BSTR id
)
148 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
149 FIXME("(%p)->(%s)\n", This
, debugstr_w(id
));
153 static HRESULT WINAPI
DailyTrigger_get_Repetition(IDailyTrigger
*iface
, IRepetitionPattern
**repeat
)
155 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
156 FIXME("(%p)->(%p)\n", This
, repeat
);
160 static HRESULT WINAPI
DailyTrigger_put_Repetition(IDailyTrigger
*iface
, IRepetitionPattern
*repeat
)
162 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
163 FIXME("(%p)->(%p)\n", This
, repeat
);
167 static HRESULT WINAPI
DailyTrigger_get_ExecutionTimeLimit(IDailyTrigger
*iface
, BSTR
*limit
)
169 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
170 FIXME("(%p)->(%p)\n", This
, limit
);
174 static HRESULT WINAPI
DailyTrigger_put_ExecutionTimeLimit(IDailyTrigger
*iface
, BSTR limit
)
176 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
177 FIXME("(%p)->(%s)\n", This
, debugstr_w(limit
));
181 static HRESULT WINAPI
DailyTrigger_get_StartBoundary(IDailyTrigger
*iface
, BSTR
*start
)
183 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
185 TRACE("(%p)->(%p)\n", This
, start
);
187 if (!start
) return E_POINTER
;
189 if (!This
->start_boundary
) *start
= NULL
;
190 else if (!(*start
= SysAllocString(This
->start_boundary
))) return E_OUTOFMEMORY
;
195 static HRESULT WINAPI
DailyTrigger_put_StartBoundary(IDailyTrigger
*iface
, BSTR start
)
197 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
200 TRACE("(%p)->(%s)\n", This
, debugstr_w(start
));
202 if (start
&& !(str
= heap_strdupW(start
))) return E_OUTOFMEMORY
;
203 heap_free(This
->start_boundary
);
204 This
->start_boundary
= str
;
209 static HRESULT WINAPI
DailyTrigger_get_EndBoundary(IDailyTrigger
*iface
, BSTR
*end
)
211 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
212 FIXME("(%p)->(%p)\n", This
, end
);
216 static HRESULT WINAPI
DailyTrigger_put_EndBoundary(IDailyTrigger
*iface
, BSTR end
)
218 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
219 FIXME("(%p)->(%s)\n", This
, debugstr_w(end
));
223 static HRESULT WINAPI
DailyTrigger_get_Enabled(IDailyTrigger
*iface
, VARIANT_BOOL
*enabled
)
225 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
227 TRACE("(%p)->(%p)\n", This
, enabled
);
229 if (!enabled
) return E_POINTER
;
231 *enabled
= This
->enabled
? VARIANT_TRUE
: VARIANT_FALSE
;
235 static HRESULT WINAPI
DailyTrigger_put_Enabled(IDailyTrigger
*iface
, VARIANT_BOOL enabled
)
237 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
239 TRACE("(%p)->(%x)\n", This
, enabled
);
241 This
->enabled
= !!enabled
;
245 static HRESULT WINAPI
DailyTrigger_get_DaysInterval(IDailyTrigger
*iface
, short *days
)
247 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
249 TRACE("(%p)->(%p)\n", This
, days
);
251 *days
= This
->interval
;
255 static HRESULT WINAPI
DailyTrigger_put_DaysInterval(IDailyTrigger
*iface
, short days
)
257 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
259 TRACE("(%p)->(%d)\n", This
, days
);
264 This
->interval
= days
;
268 static HRESULT WINAPI
DailyTrigger_get_RandomDelay(IDailyTrigger
*iface
, BSTR
*pRandomDelay
)
270 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
271 FIXME("(%p)->(%p)\n", This
, pRandomDelay
);
275 static HRESULT WINAPI
DailyTrigger_put_RandomDelay(IDailyTrigger
*iface
, BSTR randomDelay
)
277 DailyTrigger
*This
= impl_from_IDailyTrigger(iface
);
278 FIXME("(%p)->(%s)\n", This
, debugstr_w(randomDelay
));
282 static const IDailyTriggerVtbl DailyTrigger_vtbl
= {
283 DailyTrigger_QueryInterface
,
285 DailyTrigger_Release
,
286 DailyTrigger_GetTypeInfoCount
,
287 DailyTrigger_GetTypeInfo
,
288 DailyTrigger_GetIDsOfNames
,
290 DailyTrigger_get_Type
,
293 DailyTrigger_get_Repetition
,
294 DailyTrigger_put_Repetition
,
295 DailyTrigger_get_ExecutionTimeLimit
,
296 DailyTrigger_put_ExecutionTimeLimit
,
297 DailyTrigger_get_StartBoundary
,
298 DailyTrigger_put_StartBoundary
,
299 DailyTrigger_get_EndBoundary
,
300 DailyTrigger_put_EndBoundary
,
301 DailyTrigger_get_Enabled
,
302 DailyTrigger_put_Enabled
,
303 DailyTrigger_get_DaysInterval
,
304 DailyTrigger_put_DaysInterval
,
305 DailyTrigger_get_RandomDelay
,
306 DailyTrigger_put_RandomDelay
309 static HRESULT
DailyTrigger_create(ITrigger
**trigger
)
311 DailyTrigger
*daily_trigger
;
313 daily_trigger
= heap_alloc(sizeof(*daily_trigger
));
315 return E_OUTOFMEMORY
;
317 daily_trigger
->IDailyTrigger_iface
.lpVtbl
= &DailyTrigger_vtbl
;
318 daily_trigger
->ref
= 1;
319 daily_trigger
->interval
= 1;
320 daily_trigger
->start_boundary
= NULL
;
321 daily_trigger
->enabled
= TRUE
;
323 *trigger
= (ITrigger
*)&daily_trigger
->IDailyTrigger_iface
;
329 ITriggerCollection ITriggerCollection_iface
;
331 } trigger_collection
;
333 static inline trigger_collection
*impl_from_ITriggerCollection(ITriggerCollection
*iface
)
335 return CONTAINING_RECORD(iface
, trigger_collection
, ITriggerCollection_iface
);
338 static HRESULT WINAPI
TriggerCollection_QueryInterface(ITriggerCollection
*iface
, REFIID riid
, void **ppv
)
340 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
342 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
344 if(IsEqualGUID(&IID_IUnknown
, riid
) ||
345 IsEqualGUID(&IID_IDispatch
, riid
) ||
346 IsEqualGUID(&IID_ITriggerCollection
, riid
)) {
347 *ppv
= &This
->ITriggerCollection_iface
;
349 FIXME("unimplemented interface %s\n", debugstr_guid(riid
));
351 return E_NOINTERFACE
;
354 IUnknown_AddRef((IUnknown
*)*ppv
);
358 static ULONG WINAPI
TriggerCollection_AddRef(ITriggerCollection
*iface
)
360 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
361 LONG ref
= InterlockedIncrement(&This
->ref
);
363 TRACE("(%p) ref=%ld\n", This
, ref
);
368 static ULONG WINAPI
TriggerCollection_Release(ITriggerCollection
*iface
)
370 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
371 LONG ref
= InterlockedDecrement(&This
->ref
);
373 TRACE("(%p) ref=%ld\n", This
, ref
);
381 static HRESULT WINAPI
TriggerCollection_GetTypeInfoCount(ITriggerCollection
*iface
, UINT
*count
)
383 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
384 FIXME("(%p)->(%p)\n", This
, count
);
388 static HRESULT WINAPI
TriggerCollection_GetTypeInfo(ITriggerCollection
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
390 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
391 FIXME("(%p)->(%u %lu %p)\n", This
, index
, lcid
, info
);
395 static HRESULT WINAPI
TriggerCollection_GetIDsOfNames(ITriggerCollection
*iface
, REFIID riid
, LPOLESTR
*names
,
396 UINT count
, LCID lcid
, DISPID
*dispid
)
398 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
399 FIXME("(%p)->(%s %p %u %lu %p)\n", This
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
403 static HRESULT WINAPI
TriggerCollection_Invoke(ITriggerCollection
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
404 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
406 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
407 FIXME("(%p)->(%ld %s %lx %x %p %p %p %p)\n", This
, dispid
, debugstr_guid(riid
), lcid
, flags
,
408 params
, result
, excepinfo
, argerr
);
412 static HRESULT WINAPI
TriggerCollection_get_Count(ITriggerCollection
*iface
, LONG
*count
)
414 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
415 FIXME("(%p)->(%p)\n", This
, count
);
419 static HRESULT WINAPI
TriggerCollection_get_Item(ITriggerCollection
*iface
, LONG index
, ITrigger
**trigger
)
421 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
422 FIXME("(%p)->(%ld %p)\n", This
, index
, trigger
);
426 static HRESULT WINAPI
TriggerCollection_get__NewEnum(ITriggerCollection
*iface
, IUnknown
**penum
)
428 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
429 FIXME("(%p)->(%p)\n", This
, penum
);
433 static HRESULT WINAPI
TriggerCollection_Create(ITriggerCollection
*iface
, TASK_TRIGGER_TYPE2 type
, ITrigger
**trigger
)
435 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
437 TRACE("(%p)->(%d %p)\n", This
, type
, trigger
);
440 case TASK_TRIGGER_DAILY
:
441 return DailyTrigger_create(trigger
);
443 FIXME("Unimplemented type %d\n", type
);
450 static HRESULT WINAPI
TriggerCollection_Remove(ITriggerCollection
*iface
, VARIANT index
)
452 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
453 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&index
));
457 static HRESULT WINAPI
TriggerCollection_Clear(ITriggerCollection
*iface
)
459 trigger_collection
*This
= impl_from_ITriggerCollection(iface
);
460 FIXME("(%p)\n", This
);
464 static const ITriggerCollectionVtbl TriggerCollection_vtbl
= {
465 TriggerCollection_QueryInterface
,
466 TriggerCollection_AddRef
,
467 TriggerCollection_Release
,
468 TriggerCollection_GetTypeInfoCount
,
469 TriggerCollection_GetTypeInfo
,
470 TriggerCollection_GetIDsOfNames
,
471 TriggerCollection_Invoke
,
472 TriggerCollection_get_Count
,
473 TriggerCollection_get_Item
,
474 TriggerCollection_get__NewEnum
,
475 TriggerCollection_Create
,
476 TriggerCollection_Remove
,
477 TriggerCollection_Clear
482 IRegistrationInfo IRegistrationInfo_iface
;
484 WCHAR
*description
, *author
, *version
, *date
, *documentation
, *uri
, *source
;
487 static inline registration_info
*impl_from_IRegistrationInfo(IRegistrationInfo
*iface
)
489 return CONTAINING_RECORD(iface
, registration_info
, IRegistrationInfo_iface
);
492 static ULONG WINAPI
RegistrationInfo_AddRef(IRegistrationInfo
*iface
)
494 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
495 return InterlockedIncrement(®info
->ref
);
498 static ULONG WINAPI
RegistrationInfo_Release(IRegistrationInfo
*iface
)
500 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
501 LONG ref
= InterlockedDecrement(®info
->ref
);
505 TRACE("destroying %p\n", iface
);
506 heap_free(reginfo
->description
);
507 heap_free(reginfo
->author
);
508 heap_free(reginfo
->version
);
509 heap_free(reginfo
->date
);
510 heap_free(reginfo
->documentation
);
511 heap_free(reginfo
->uri
);
512 heap_free(reginfo
->source
);
519 static HRESULT WINAPI
RegistrationInfo_QueryInterface(IRegistrationInfo
*iface
, REFIID riid
, void **obj
)
521 if (!riid
|| !obj
) return E_INVALIDARG
;
523 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
525 if (IsEqualGUID(riid
, &IID_IRegistrationInfo
) ||
526 IsEqualGUID(riid
, &IID_IDispatch
) ||
527 IsEqualGUID(riid
, &IID_IUnknown
))
529 IRegistrationInfo_AddRef(iface
);
534 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
536 return E_NOINTERFACE
;
539 static HRESULT WINAPI
RegistrationInfo_GetTypeInfoCount(IRegistrationInfo
*iface
, UINT
*count
)
541 FIXME("%p,%p: stub\n", iface
, count
);
545 static HRESULT WINAPI
RegistrationInfo_GetTypeInfo(IRegistrationInfo
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
547 FIXME("%p,%u,%lu,%p: stub\n", iface
, index
, lcid
, info
);
551 static HRESULT WINAPI
RegistrationInfo_GetIDsOfNames(IRegistrationInfo
*iface
, REFIID riid
, LPOLESTR
*names
,
552 UINT count
, LCID lcid
, DISPID
*dispid
)
554 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
558 static HRESULT WINAPI
RegistrationInfo_Invoke(IRegistrationInfo
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
559 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
561 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
562 params
, result
, excepinfo
, argerr
);
566 static HRESULT WINAPI
RegistrationInfo_get_Description(IRegistrationInfo
*iface
, BSTR
*description
)
568 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
570 TRACE("%p,%p\n", iface
, description
);
572 if (!description
) return E_POINTER
;
574 if (!reginfo
->description
) *description
= NULL
;
575 else if (!(*description
= SysAllocString(reginfo
->description
))) return E_OUTOFMEMORY
;
580 static HRESULT WINAPI
RegistrationInfo_put_Description(IRegistrationInfo
*iface
, BSTR description
)
582 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
585 TRACE("%p,%s\n", iface
, debugstr_w(description
));
587 if (description
&& !(str
= heap_strdupW(description
))) return E_OUTOFMEMORY
;
588 heap_free(reginfo
->description
);
589 reginfo
->description
= str
;
593 static HRESULT WINAPI
RegistrationInfo_get_Author(IRegistrationInfo
*iface
, BSTR
*author
)
595 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
597 TRACE("%p,%p\n", iface
, author
);
599 if (!author
) return E_POINTER
;
601 if (!reginfo
->author
) *author
= NULL
;
602 else if (!(*author
= SysAllocString(reginfo
->author
))) return E_OUTOFMEMORY
;
607 static HRESULT WINAPI
RegistrationInfo_put_Author(IRegistrationInfo
*iface
, BSTR author
)
609 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
612 TRACE("%p,%s\n", iface
, debugstr_w(author
));
614 if (author
&& !(str
= heap_strdupW(author
))) return E_OUTOFMEMORY
;
615 heap_free(reginfo
->author
);
616 reginfo
->author
= str
;
620 static HRESULT WINAPI
RegistrationInfo_get_Version(IRegistrationInfo
*iface
, BSTR
*version
)
622 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
624 TRACE("%p,%p\n", iface
, version
);
626 if (!version
) return E_POINTER
;
628 if (!reginfo
->version
) *version
= NULL
;
629 else if (!(*version
= SysAllocString(reginfo
->version
))) return E_OUTOFMEMORY
;
634 static HRESULT WINAPI
RegistrationInfo_put_Version(IRegistrationInfo
*iface
, BSTR version
)
636 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
639 TRACE("%p,%s\n", iface
, debugstr_w(version
));
641 if (version
&& !(str
= heap_strdupW(version
))) return E_OUTOFMEMORY
;
642 heap_free(reginfo
->version
);
643 reginfo
->version
= str
;
647 static HRESULT WINAPI
RegistrationInfo_get_Date(IRegistrationInfo
*iface
, BSTR
*date
)
649 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
651 TRACE("%p,%p\n", iface
, date
);
653 if (!date
) return E_POINTER
;
655 if (!reginfo
->date
) *date
= NULL
;
656 else if (!(*date
= SysAllocString(reginfo
->date
))) return E_OUTOFMEMORY
;
661 static HRESULT WINAPI
RegistrationInfo_put_Date(IRegistrationInfo
*iface
, BSTR date
)
663 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
666 TRACE("%p,%s\n", iface
, debugstr_w(date
));
668 if (date
&& !(str
= heap_strdupW(date
))) return E_OUTOFMEMORY
;
669 heap_free(reginfo
->date
);
674 static HRESULT WINAPI
RegistrationInfo_get_Documentation(IRegistrationInfo
*iface
, BSTR
*doc
)
676 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
678 TRACE("%p,%p\n", iface
, doc
);
680 if (!doc
) return E_POINTER
;
682 if (!reginfo
->documentation
) *doc
= NULL
;
683 else if (!(*doc
= SysAllocString(reginfo
->documentation
))) return E_OUTOFMEMORY
;
688 static HRESULT WINAPI
RegistrationInfo_put_Documentation(IRegistrationInfo
*iface
, BSTR doc
)
690 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
693 TRACE("%p,%s\n", iface
, debugstr_w(doc
));
695 if (doc
&& !(str
= heap_strdupW(doc
))) return E_OUTOFMEMORY
;
696 heap_free(reginfo
->documentation
);
697 reginfo
->documentation
= str
;
701 static HRESULT WINAPI
RegistrationInfo_get_XmlText(IRegistrationInfo
*iface
, BSTR
*xml
)
703 FIXME("%p,%p: stub\n", iface
, xml
);
707 static HRESULT WINAPI
RegistrationInfo_put_XmlText(IRegistrationInfo
*iface
, BSTR xml
)
709 FIXME("%p,%s: stub\n", iface
, debugstr_w(xml
));
713 static HRESULT WINAPI
RegistrationInfo_get_URI(IRegistrationInfo
*iface
, BSTR
*uri
)
715 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
717 TRACE("%p,%p\n", iface
, uri
);
719 if (!uri
) return E_POINTER
;
721 if (!reginfo
->uri
) *uri
= NULL
;
722 else if (!(*uri
= SysAllocString(reginfo
->uri
))) return E_OUTOFMEMORY
;
727 static HRESULT WINAPI
RegistrationInfo_put_URI(IRegistrationInfo
*iface
, BSTR uri
)
729 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
732 TRACE("%p,%s\n", iface
, debugstr_w(uri
));
734 if (uri
&& !(str
= heap_strdupW(uri
))) return E_OUTOFMEMORY
;
735 heap_free(reginfo
->uri
);
740 static HRESULT WINAPI
RegistrationInfo_get_SecurityDescriptor(IRegistrationInfo
*iface
, VARIANT
*sddl
)
742 FIXME("%p,%p: stub\n", iface
, sddl
);
746 static HRESULT WINAPI
RegistrationInfo_put_SecurityDescriptor(IRegistrationInfo
*iface
, VARIANT sddl
)
748 FIXME("%p,%s: stub\n", iface
, debugstr_variant(&sddl
));
752 static HRESULT WINAPI
RegistrationInfo_get_Source(IRegistrationInfo
*iface
, BSTR
*source
)
754 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
756 TRACE("%p,%p\n", iface
, source
);
758 if (!source
) return E_POINTER
;
760 if (!reginfo
->source
) *source
= NULL
;
761 else if (!(*source
= SysAllocString(reginfo
->source
))) return E_OUTOFMEMORY
;
766 static HRESULT WINAPI
RegistrationInfo_put_Source(IRegistrationInfo
*iface
, BSTR source
)
768 registration_info
*reginfo
= impl_from_IRegistrationInfo(iface
);
771 TRACE("%p,%s\n", iface
, debugstr_w(source
));
773 if (source
&& !(str
= heap_strdupW(source
))) return E_OUTOFMEMORY
;
774 heap_free(reginfo
->source
);
775 reginfo
->source
= str
;
779 static const IRegistrationInfoVtbl RegistrationInfo_vtbl
=
781 RegistrationInfo_QueryInterface
,
782 RegistrationInfo_AddRef
,
783 RegistrationInfo_Release
,
784 RegistrationInfo_GetTypeInfoCount
,
785 RegistrationInfo_GetTypeInfo
,
786 RegistrationInfo_GetIDsOfNames
,
787 RegistrationInfo_Invoke
,
788 RegistrationInfo_get_Description
,
789 RegistrationInfo_put_Description
,
790 RegistrationInfo_get_Author
,
791 RegistrationInfo_put_Author
,
792 RegistrationInfo_get_Version
,
793 RegistrationInfo_put_Version
,
794 RegistrationInfo_get_Date
,
795 RegistrationInfo_put_Date
,
796 RegistrationInfo_get_Documentation
,
797 RegistrationInfo_put_Documentation
,
798 RegistrationInfo_get_XmlText
,
799 RegistrationInfo_put_XmlText
,
800 RegistrationInfo_get_URI
,
801 RegistrationInfo_put_URI
,
802 RegistrationInfo_get_SecurityDescriptor
,
803 RegistrationInfo_put_SecurityDescriptor
,
804 RegistrationInfo_get_Source
,
805 RegistrationInfo_put_Source
808 static HRESULT
RegistrationInfo_create(IRegistrationInfo
**obj
)
810 registration_info
*reginfo
;
812 reginfo
= heap_alloc_zero(sizeof(*reginfo
));
813 if (!reginfo
) return E_OUTOFMEMORY
;
815 reginfo
->IRegistrationInfo_iface
.lpVtbl
= &RegistrationInfo_vtbl
;
817 *obj
= ®info
->IRegistrationInfo_iface
;
819 TRACE("created %p\n", *obj
);
826 ITaskSettings ITaskSettings_iface
;
828 WCHAR
*restart_interval
;
829 WCHAR
*execution_time_limit
;
830 WCHAR
*delete_expired_task_after
;
833 TASK_INSTANCES_POLICY policy
;
834 TASK_COMPATIBILITY compatibility
;
835 BOOL allow_on_demand_start
;
836 BOOL stop_if_going_on_batteries
;
837 BOOL disallow_start_if_on_batteries
;
838 BOOL allow_hard_terminate
;
839 BOOL start_when_available
;
840 BOOL run_only_if_network_available
;
843 BOOL run_only_if_idle
;
847 static inline TaskSettings
*impl_from_ITaskSettings(ITaskSettings
*iface
)
849 return CONTAINING_RECORD(iface
, TaskSettings
, ITaskSettings_iface
);
852 static ULONG WINAPI
TaskSettings_AddRef(ITaskSettings
*iface
)
854 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
855 return InterlockedIncrement(&taskset
->ref
);
858 static ULONG WINAPI
TaskSettings_Release(ITaskSettings
*iface
)
860 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
861 LONG ref
= InterlockedDecrement(&taskset
->ref
);
865 TRACE("destroying %p\n", iface
);
866 heap_free(taskset
->restart_interval
);
867 heap_free(taskset
->execution_time_limit
);
868 heap_free(taskset
->delete_expired_task_after
);
875 static HRESULT WINAPI
TaskSettings_QueryInterface(ITaskSettings
*iface
, REFIID riid
, void **obj
)
877 if (!riid
|| !obj
) return E_INVALIDARG
;
879 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
881 if (IsEqualGUID(riid
, &IID_ITaskSettings
) ||
882 IsEqualGUID(riid
, &IID_IDispatch
) ||
883 IsEqualGUID(riid
, &IID_IUnknown
))
885 ITaskSettings_AddRef(iface
);
890 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
892 return E_NOINTERFACE
;
895 static HRESULT WINAPI
TaskSettings_GetTypeInfoCount(ITaskSettings
*iface
, UINT
*count
)
897 FIXME("%p,%p: stub\n", iface
, count
);
901 static HRESULT WINAPI
TaskSettings_GetTypeInfo(ITaskSettings
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
903 FIXME("%p,%u,%lu,%p: stub\n", iface
, index
, lcid
, info
);
907 static HRESULT WINAPI
TaskSettings_GetIDsOfNames(ITaskSettings
*iface
, REFIID riid
, LPOLESTR
*names
,
908 UINT count
, LCID lcid
, DISPID
*dispid
)
910 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
914 static HRESULT WINAPI
TaskSettings_Invoke(ITaskSettings
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
915 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
917 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
918 params
, result
, excepinfo
, argerr
);
922 static HRESULT WINAPI
TaskSettings_get_AllowDemandStart(ITaskSettings
*iface
, VARIANT_BOOL
*allow
)
924 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
926 TRACE("%p,%p\n", iface
, allow
);
928 if (!allow
) return E_POINTER
;
930 *allow
= taskset
->allow_on_demand_start
? VARIANT_TRUE
: VARIANT_FALSE
;
935 static HRESULT WINAPI
TaskSettings_put_AllowDemandStart(ITaskSettings
*iface
, VARIANT_BOOL allow
)
937 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
939 TRACE("%p,%d\n", iface
, allow
);
941 taskset
->allow_on_demand_start
= !!allow
;
946 static HRESULT WINAPI
TaskSettings_get_RestartInterval(ITaskSettings
*iface
, BSTR
*interval
)
948 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
950 TRACE("%p,%p\n", iface
, interval
);
952 if (!interval
) return E_POINTER
;
954 if (!taskset
->restart_interval
)
960 if (!taskset
->restart_interval
) *interval
= NULL
;
961 else if (!(*interval
= SysAllocString(taskset
->restart_interval
))) return E_OUTOFMEMORY
;
966 static HRESULT WINAPI
TaskSettings_put_RestartInterval(ITaskSettings
*iface
, BSTR interval
)
968 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
971 TRACE("%p,%s\n", iface
, debugstr_w(interval
));
973 if (interval
&& !(str
= heap_strdupW(interval
))) return E_OUTOFMEMORY
;
974 heap_free(taskset
->restart_interval
);
975 taskset
->restart_interval
= str
;
980 static HRESULT WINAPI
TaskSettings_get_RestartCount(ITaskSettings
*iface
, INT
*count
)
982 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
984 TRACE("%p,%p\n", iface
, count
);
986 if (!count
) return E_POINTER
;
988 *count
= taskset
->restart_count
;
993 static HRESULT WINAPI
TaskSettings_put_RestartCount(ITaskSettings
*iface
, INT count
)
995 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
997 TRACE("%p,%d\n", iface
, count
);
999 taskset
->restart_count
= count
;
1004 static HRESULT WINAPI
TaskSettings_get_MultipleInstances(ITaskSettings
*iface
, TASK_INSTANCES_POLICY
*policy
)
1006 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1008 TRACE("%p,%p\n", iface
, policy
);
1010 if (!policy
) return E_POINTER
;
1012 *policy
= taskset
->policy
;
1017 static HRESULT WINAPI
TaskSettings_put_MultipleInstances(ITaskSettings
*iface
, TASK_INSTANCES_POLICY policy
)
1019 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1021 TRACE("%p,%d\n", iface
, policy
);
1023 taskset
->policy
= policy
;
1028 static HRESULT WINAPI
TaskSettings_get_StopIfGoingOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL
*stop
)
1030 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1032 TRACE("%p,%p\n", iface
, stop
);
1034 if (!stop
) return E_POINTER
;
1036 *stop
= taskset
->stop_if_going_on_batteries
? VARIANT_TRUE
: VARIANT_FALSE
;
1041 static HRESULT WINAPI
TaskSettings_put_StopIfGoingOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL stop
)
1043 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1045 TRACE("%p,%d\n", iface
, stop
);
1047 taskset
->stop_if_going_on_batteries
= !!stop
;
1052 static HRESULT WINAPI
TaskSettings_get_DisallowStartIfOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL
*disallow
)
1054 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1056 TRACE("%p,%p\n", iface
, disallow
);
1058 if (!disallow
) return E_POINTER
;
1060 *disallow
= taskset
->disallow_start_if_on_batteries
? VARIANT_TRUE
: VARIANT_FALSE
;
1065 static HRESULT WINAPI
TaskSettings_put_DisallowStartIfOnBatteries(ITaskSettings
*iface
, VARIANT_BOOL disallow
)
1067 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1069 TRACE("%p,%d\n", iface
, disallow
);
1071 taskset
->disallow_start_if_on_batteries
= !!disallow
;
1076 static HRESULT WINAPI
TaskSettings_get_AllowHardTerminate(ITaskSettings
*iface
, VARIANT_BOOL
*allow
)
1078 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1080 TRACE("%p,%p\n", iface
, allow
);
1082 if (!allow
) return E_POINTER
;
1084 *allow
= taskset
->allow_hard_terminate
? VARIANT_TRUE
: VARIANT_FALSE
;
1089 static HRESULT WINAPI
TaskSettings_put_AllowHardTerminate(ITaskSettings
*iface
, VARIANT_BOOL allow
)
1091 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1093 TRACE("%p,%d\n", iface
, allow
);
1095 taskset
->allow_hard_terminate
= !!allow
;
1100 static HRESULT WINAPI
TaskSettings_get_StartWhenAvailable(ITaskSettings
*iface
, VARIANT_BOOL
*start
)
1102 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1104 TRACE("%p,%p\n", iface
, start
);
1106 if (!start
) return E_POINTER
;
1108 *start
= taskset
->start_when_available
? VARIANT_TRUE
: VARIANT_FALSE
;
1113 static HRESULT WINAPI
TaskSettings_put_StartWhenAvailable(ITaskSettings
*iface
, VARIANT_BOOL start
)
1115 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1117 TRACE("%p,%d\n", iface
, start
);
1119 taskset
->start_when_available
= !!start
;
1124 static HRESULT WINAPI
TaskSettings_get_XmlText(ITaskSettings
*iface
, BSTR
*xml
)
1126 FIXME("%p,%p: stub\n", iface
, xml
);
1130 static HRESULT WINAPI
TaskSettings_put_XmlText(ITaskSettings
*iface
, BSTR xml
)
1132 FIXME("%p,%s: stub\n", iface
, debugstr_w(xml
));
1136 static HRESULT WINAPI
TaskSettings_get_RunOnlyIfNetworkAvailable(ITaskSettings
*iface
, VARIANT_BOOL
*run
)
1138 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1140 TRACE("%p,%p\n", iface
, run
);
1142 if (!run
) return E_POINTER
;
1144 *run
= taskset
->run_only_if_network_available
? VARIANT_TRUE
: VARIANT_FALSE
;
1149 static HRESULT WINAPI
TaskSettings_put_RunOnlyIfNetworkAvailable(ITaskSettings
*iface
, VARIANT_BOOL run
)
1151 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1153 TRACE("%p,%d\n", iface
, run
);
1155 taskset
->run_only_if_network_available
= !!run
;
1160 static HRESULT WINAPI
TaskSettings_get_ExecutionTimeLimit(ITaskSettings
*iface
, BSTR
*limit
)
1162 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1164 TRACE("%p,%p\n", iface
, limit
);
1166 if (!limit
) return E_POINTER
;
1168 if (!taskset
->execution_time_limit
)
1174 if (!taskset
->execution_time_limit
) *limit
= NULL
;
1175 else if (!(*limit
= SysAllocString(taskset
->execution_time_limit
))) return E_OUTOFMEMORY
;
1180 static HRESULT WINAPI
TaskSettings_put_ExecutionTimeLimit(ITaskSettings
*iface
, BSTR limit
)
1182 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1185 TRACE("%p,%s\n", iface
, debugstr_w(limit
));
1187 if (limit
&& !(str
= heap_strdupW(limit
))) return E_OUTOFMEMORY
;
1188 heap_free(taskset
->execution_time_limit
);
1189 taskset
->execution_time_limit
= str
;
1194 static HRESULT WINAPI
TaskSettings_get_Enabled(ITaskSettings
*iface
, VARIANT_BOOL
*enabled
)
1196 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1198 TRACE("%p,%p\n", iface
, enabled
);
1200 if (!enabled
) return E_POINTER
;
1202 *enabled
= taskset
->enabled
? VARIANT_TRUE
: VARIANT_FALSE
;
1207 static HRESULT WINAPI
TaskSettings_put_Enabled(ITaskSettings
*iface
, VARIANT_BOOL enabled
)
1209 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1211 TRACE("%p,%d\n", iface
, enabled
);
1213 taskset
->enabled
= !!enabled
;
1218 static HRESULT WINAPI
TaskSettings_get_DeleteExpiredTaskAfter(ITaskSettings
*iface
, BSTR
*delay
)
1220 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1222 TRACE("%p,%p\n", iface
, delay
);
1224 if (!delay
) return E_POINTER
;
1226 if (!taskset
->delete_expired_task_after
) *delay
= NULL
;
1227 else if (!(*delay
= SysAllocString(taskset
->delete_expired_task_after
))) return E_OUTOFMEMORY
;
1232 static HRESULT WINAPI
TaskSettings_put_DeleteExpiredTaskAfter(ITaskSettings
*iface
, BSTR delay
)
1234 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1237 TRACE("%p,%s\n", iface
, debugstr_w(delay
));
1239 if (delay
&& !(str
= heap_strdupW(delay
))) return E_OUTOFMEMORY
;
1240 heap_free(taskset
->delete_expired_task_after
);
1241 taskset
->delete_expired_task_after
= str
;
1246 static HRESULT WINAPI
TaskSettings_get_Priority(ITaskSettings
*iface
, INT
*priority
)
1248 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1250 TRACE("%p,%p\n", iface
, priority
);
1252 if (!priority
) return E_POINTER
;
1254 *priority
= taskset
->priority
;
1259 static HRESULT WINAPI
TaskSettings_put_Priority(ITaskSettings
*iface
, INT priority
)
1261 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1263 TRACE("%p,%d\n", iface
, priority
);
1265 taskset
->priority
= priority
;
1270 static HRESULT WINAPI
TaskSettings_get_Compatibility(ITaskSettings
*iface
, TASK_COMPATIBILITY
*level
)
1272 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1274 TRACE("%p,%p\n", iface
, level
);
1276 if (!level
) return E_POINTER
;
1278 *level
= taskset
->compatibility
;
1283 static HRESULT WINAPI
TaskSettings_put_Compatibility(ITaskSettings
*iface
, TASK_COMPATIBILITY level
)
1285 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1287 TRACE("%p,%d\n", iface
, level
);
1289 taskset
->compatibility
= level
;
1294 static HRESULT WINAPI
TaskSettings_get_Hidden(ITaskSettings
*iface
, VARIANT_BOOL
*hidden
)
1296 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1298 TRACE("%p,%p\n", iface
, hidden
);
1300 if (!hidden
) return E_POINTER
;
1302 *hidden
= taskset
->hidden
? VARIANT_TRUE
: VARIANT_FALSE
;
1307 static HRESULT WINAPI
TaskSettings_put_Hidden(ITaskSettings
*iface
, VARIANT_BOOL hidden
)
1309 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1311 TRACE("%p,%d\n", iface
, hidden
);
1313 taskset
->hidden
= !!hidden
;
1318 static HRESULT WINAPI
TaskSettings_get_IdleSettings(ITaskSettings
*iface
, IIdleSettings
**settings
)
1320 FIXME("%p,%p: stub\n", iface
, settings
);
1324 static HRESULT WINAPI
TaskSettings_put_IdleSettings(ITaskSettings
*iface
, IIdleSettings
*settings
)
1326 FIXME("%p,%p: stub\n", iface
, settings
);
1330 static HRESULT WINAPI
TaskSettings_get_RunOnlyIfIdle(ITaskSettings
*iface
, VARIANT_BOOL
*run
)
1332 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1334 TRACE("%p,%p\n", iface
, run
);
1336 if (!run
) return E_POINTER
;
1338 *run
= taskset
->run_only_if_idle
? VARIANT_TRUE
: VARIANT_FALSE
;
1343 static HRESULT WINAPI
TaskSettings_put_RunOnlyIfIdle(ITaskSettings
*iface
, VARIANT_BOOL run
)
1345 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1347 TRACE("%p,%d\n", iface
, run
);
1349 taskset
->run_only_if_idle
= !!run
;
1354 static HRESULT WINAPI
TaskSettings_get_WakeToRun(ITaskSettings
*iface
, VARIANT_BOOL
*wake
)
1356 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1358 TRACE("%p,%p\n", iface
, wake
);
1360 if (!wake
) return E_POINTER
;
1362 *wake
= taskset
->wake_to_run
? VARIANT_TRUE
: VARIANT_FALSE
;
1367 static HRESULT WINAPI
TaskSettings_put_WakeToRun(ITaskSettings
*iface
, VARIANT_BOOL wake
)
1369 TaskSettings
*taskset
= impl_from_ITaskSettings(iface
);
1371 TRACE("%p,%d\n", iface
, wake
);
1373 taskset
->wake_to_run
= !!wake
;
1378 static HRESULT WINAPI
TaskSettings_get_NetworkSettings(ITaskSettings
*iface
, INetworkSettings
**settings
)
1380 FIXME("%p,%p: stub\n", iface
, settings
);
1384 static HRESULT WINAPI
TaskSettings_put_NetworkSettings(ITaskSettings
*iface
, INetworkSettings
*settings
)
1386 FIXME("%p,%p: stub\n", iface
, settings
);
1390 static const ITaskSettingsVtbl TaskSettings_vtbl
=
1392 TaskSettings_QueryInterface
,
1393 TaskSettings_AddRef
,
1394 TaskSettings_Release
,
1395 TaskSettings_GetTypeInfoCount
,
1396 TaskSettings_GetTypeInfo
,
1397 TaskSettings_GetIDsOfNames
,
1398 TaskSettings_Invoke
,
1399 TaskSettings_get_AllowDemandStart
,
1400 TaskSettings_put_AllowDemandStart
,
1401 TaskSettings_get_RestartInterval
,
1402 TaskSettings_put_RestartInterval
,
1403 TaskSettings_get_RestartCount
,
1404 TaskSettings_put_RestartCount
,
1405 TaskSettings_get_MultipleInstances
,
1406 TaskSettings_put_MultipleInstances
,
1407 TaskSettings_get_StopIfGoingOnBatteries
,
1408 TaskSettings_put_StopIfGoingOnBatteries
,
1409 TaskSettings_get_DisallowStartIfOnBatteries
,
1410 TaskSettings_put_DisallowStartIfOnBatteries
,
1411 TaskSettings_get_AllowHardTerminate
,
1412 TaskSettings_put_AllowHardTerminate
,
1413 TaskSettings_get_StartWhenAvailable
,
1414 TaskSettings_put_StartWhenAvailable
,
1415 TaskSettings_get_XmlText
,
1416 TaskSettings_put_XmlText
,
1417 TaskSettings_get_RunOnlyIfNetworkAvailable
,
1418 TaskSettings_put_RunOnlyIfNetworkAvailable
,
1419 TaskSettings_get_ExecutionTimeLimit
,
1420 TaskSettings_put_ExecutionTimeLimit
,
1421 TaskSettings_get_Enabled
,
1422 TaskSettings_put_Enabled
,
1423 TaskSettings_get_DeleteExpiredTaskAfter
,
1424 TaskSettings_put_DeleteExpiredTaskAfter
,
1425 TaskSettings_get_Priority
,
1426 TaskSettings_put_Priority
,
1427 TaskSettings_get_Compatibility
,
1428 TaskSettings_put_Compatibility
,
1429 TaskSettings_get_Hidden
,
1430 TaskSettings_put_Hidden
,
1431 TaskSettings_get_IdleSettings
,
1432 TaskSettings_put_IdleSettings
,
1433 TaskSettings_get_RunOnlyIfIdle
,
1434 TaskSettings_put_RunOnlyIfIdle
,
1435 TaskSettings_get_WakeToRun
,
1436 TaskSettings_put_WakeToRun
,
1437 TaskSettings_get_NetworkSettings
,
1438 TaskSettings_put_NetworkSettings
1441 static HRESULT
TaskSettings_create(ITaskSettings
**obj
)
1443 TaskSettings
*taskset
;
1445 taskset
= heap_alloc(sizeof(*taskset
));
1446 if (!taskset
) return E_OUTOFMEMORY
;
1448 taskset
->ITaskSettings_iface
.lpVtbl
= &TaskSettings_vtbl
;
1450 /* set the defaults */
1451 taskset
->restart_interval
= NULL
;
1452 taskset
->execution_time_limit
= heap_strdupW(L
"PT72H");
1453 taskset
->delete_expired_task_after
= NULL
;
1454 taskset
->restart_count
= 0;
1455 taskset
->priority
= 7;
1456 taskset
->policy
= TASK_INSTANCES_IGNORE_NEW
;
1457 taskset
->compatibility
= TASK_COMPATIBILITY_V2
;
1458 taskset
->allow_on_demand_start
= TRUE
;
1459 taskset
->stop_if_going_on_batteries
= TRUE
;
1460 taskset
->disallow_start_if_on_batteries
= TRUE
;
1461 taskset
->allow_hard_terminate
= TRUE
;
1462 taskset
->start_when_available
= FALSE
;
1463 taskset
->run_only_if_network_available
= FALSE
;
1464 taskset
->enabled
= TRUE
;
1465 taskset
->hidden
= FALSE
;
1466 taskset
->run_only_if_idle
= FALSE
;
1467 taskset
->wake_to_run
= FALSE
;
1469 *obj
= &taskset
->ITaskSettings_iface
;
1471 TRACE("created %p\n", *obj
);
1478 IPrincipal IPrincipal_iface
;
1482 static inline Principal
*impl_from_IPrincipal(IPrincipal
*iface
)
1484 return CONTAINING_RECORD(iface
, Principal
, IPrincipal_iface
);
1487 static ULONG WINAPI
Principal_AddRef(IPrincipal
*iface
)
1489 Principal
*principal
= impl_from_IPrincipal(iface
);
1490 return InterlockedIncrement(&principal
->ref
);
1493 static ULONG WINAPI
Principal_Release(IPrincipal
*iface
)
1495 Principal
*principal
= impl_from_IPrincipal(iface
);
1496 LONG ref
= InterlockedDecrement(&principal
->ref
);
1500 TRACE("destroying %p\n", iface
);
1501 heap_free(principal
);
1507 static HRESULT WINAPI
Principal_QueryInterface(IPrincipal
*iface
, REFIID riid
, void **obj
)
1509 if (!riid
|| !obj
) return E_INVALIDARG
;
1511 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
1513 if (IsEqualGUID(riid
, &IID_IPrincipal
) ||
1514 IsEqualGUID(riid
, &IID_IDispatch
) ||
1515 IsEqualGUID(riid
, &IID_IUnknown
))
1517 IPrincipal_AddRef(iface
);
1522 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
1524 return E_NOINTERFACE
;
1527 static HRESULT WINAPI
Principal_GetTypeInfoCount(IPrincipal
*iface
, UINT
*count
)
1529 FIXME("%p,%p: stub\n", iface
, count
);
1533 static HRESULT WINAPI
Principal_GetTypeInfo(IPrincipal
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
1535 FIXME("%p,%u,%lu,%p: stub\n", iface
, index
, lcid
, info
);
1539 static HRESULT WINAPI
Principal_GetIDsOfNames(IPrincipal
*iface
, REFIID riid
, LPOLESTR
*names
,
1540 UINT count
, LCID lcid
, DISPID
*dispid
)
1542 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1546 static HRESULT WINAPI
Principal_Invoke(IPrincipal
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
1547 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
1549 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
1550 params
, result
, excepinfo
, argerr
);
1554 static HRESULT WINAPI
Principal_get_Id(IPrincipal
*iface
, BSTR
*id
)
1556 FIXME("%p,%p: stub\n", iface
, id
);
1560 static HRESULT WINAPI
Principal_put_Id(IPrincipal
*iface
, BSTR id
)
1562 FIXME("%p,%s: stub\n", iface
, debugstr_w(id
));
1566 static HRESULT WINAPI
Principal_get_DisplayName(IPrincipal
*iface
, BSTR
*name
)
1568 FIXME("%p,%p: stub\n", iface
, name
);
1572 static HRESULT WINAPI
Principal_put_DisplayName(IPrincipal
*iface
, BSTR name
)
1574 FIXME("%p,%s: stub\n", iface
, debugstr_w(name
));
1578 static HRESULT WINAPI
Principal_get_UserId(IPrincipal
*iface
, BSTR
*user_id
)
1580 FIXME("%p,%p: stub\n", iface
, user_id
);
1584 static HRESULT WINAPI
Principal_put_UserId(IPrincipal
*iface
, BSTR user_id
)
1586 FIXME("%p,%s: stub\n", iface
, debugstr_w(user_id
));
1590 static HRESULT WINAPI
Principal_get_LogonType(IPrincipal
*iface
, TASK_LOGON_TYPE
*logon_type
)
1592 FIXME("%p,%p: stub\n", iface
, logon_type
);
1596 static HRESULT WINAPI
Principal_put_LogonType(IPrincipal
*iface
, TASK_LOGON_TYPE logon_type
)
1598 FIXME("%p,%u: stub\n", iface
, logon_type
);
1602 static HRESULT WINAPI
Principal_get_GroupId(IPrincipal
*iface
, BSTR
*group_id
)
1604 FIXME("%p,%p: stub\n", iface
, group_id
);
1608 static HRESULT WINAPI
Principal_put_GroupId(IPrincipal
*iface
, BSTR group_id
)
1610 FIXME("%p,%s: stub\n", iface
, debugstr_w(group_id
));
1614 static HRESULT WINAPI
Principal_get_RunLevel(IPrincipal
*iface
, TASK_RUNLEVEL_TYPE
*run_level
)
1616 FIXME("%p,%p: stub\n", iface
, run_level
);
1620 static HRESULT WINAPI
Principal_put_RunLevel(IPrincipal
*iface
, TASK_RUNLEVEL_TYPE run_level
)
1622 FIXME("%p,%u: stub\n", iface
, run_level
);
1626 static const IPrincipalVtbl Principal_vtbl
=
1628 Principal_QueryInterface
,
1631 Principal_GetTypeInfoCount
,
1632 Principal_GetTypeInfo
,
1633 Principal_GetIDsOfNames
,
1637 Principal_get_DisplayName
,
1638 Principal_put_DisplayName
,
1639 Principal_get_UserId
,
1640 Principal_put_UserId
,
1641 Principal_get_LogonType
,
1642 Principal_put_LogonType
,
1643 Principal_get_GroupId
,
1644 Principal_put_GroupId
,
1645 Principal_get_RunLevel
,
1646 Principal_put_RunLevel
1649 static HRESULT
Principal_create(IPrincipal
**obj
)
1651 Principal
*principal
;
1653 principal
= heap_alloc(sizeof(*principal
));
1654 if (!principal
) return E_OUTOFMEMORY
;
1656 principal
->IPrincipal_iface
.lpVtbl
= &Principal_vtbl
;
1659 *obj
= &principal
->IPrincipal_iface
;
1661 TRACE("created %p\n", *obj
);
1668 IExecAction IExecAction_iface
;
1676 static inline ExecAction
*impl_from_IExecAction(IExecAction
*iface
)
1678 return CONTAINING_RECORD(iface
, ExecAction
, IExecAction_iface
);
1681 static ULONG WINAPI
ExecAction_AddRef(IExecAction
*iface
)
1683 ExecAction
*action
= impl_from_IExecAction(iface
);
1684 return InterlockedIncrement(&action
->ref
);
1687 static ULONG WINAPI
ExecAction_Release(IExecAction
*iface
)
1689 ExecAction
*action
= impl_from_IExecAction(iface
);
1690 LONG ref
= InterlockedDecrement(&action
->ref
);
1694 TRACE("destroying %p\n", iface
);
1695 heap_free(action
->path
);
1696 heap_free(action
->directory
);
1697 heap_free(action
->args
);
1698 heap_free(action
->id
);
1705 static HRESULT WINAPI
ExecAction_QueryInterface(IExecAction
*iface
, REFIID riid
, void **obj
)
1707 if (!riid
|| !obj
) return E_INVALIDARG
;
1709 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
1711 if (IsEqualGUID(riid
, &IID_IExecAction
) ||
1712 IsEqualGUID(riid
, &IID_IAction
) ||
1713 IsEqualGUID(riid
, &IID_IDispatch
) ||
1714 IsEqualGUID(riid
, &IID_IUnknown
))
1716 IExecAction_AddRef(iface
);
1721 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
1723 return E_NOINTERFACE
;
1726 static HRESULT WINAPI
ExecAction_GetTypeInfoCount(IExecAction
*iface
, UINT
*count
)
1728 FIXME("%p,%p: stub\n", iface
, count
);
1732 static HRESULT WINAPI
ExecAction_GetTypeInfo(IExecAction
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
1734 FIXME("%p,%u,%lu,%p: stub\n", iface
, index
, lcid
, info
);
1738 static HRESULT WINAPI
ExecAction_GetIDsOfNames(IExecAction
*iface
, REFIID riid
, LPOLESTR
*names
,
1739 UINT count
, LCID lcid
, DISPID
*dispid
)
1741 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1745 static HRESULT WINAPI
ExecAction_Invoke(IExecAction
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
1746 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
1748 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
1749 params
, result
, excepinfo
, argerr
);
1753 static HRESULT WINAPI
ExecAction_get_Id(IExecAction
*iface
, BSTR
*id
)
1755 ExecAction
*action
= impl_from_IExecAction(iface
);
1757 TRACE("%p,%p\n", iface
, id
);
1759 if (!id
) return E_POINTER
;
1761 if (!action
->id
) *id
= NULL
;
1762 else if (!(*id
= SysAllocString(action
->id
))) return E_OUTOFMEMORY
;
1767 static HRESULT WINAPI
ExecAction_put_Id(IExecAction
*iface
, BSTR id
)
1769 ExecAction
*action
= impl_from_IExecAction(iface
);
1772 TRACE("%p,%s\n", iface
, debugstr_w(id
));
1774 if (id
&& !(str
= heap_strdupW((id
)))) return E_OUTOFMEMORY
;
1775 heap_free(action
->id
);
1781 static HRESULT WINAPI
ExecAction_get_Type(IExecAction
*iface
, TASK_ACTION_TYPE
*type
)
1783 TRACE("%p,%p\n", iface
, type
);
1785 if (!type
) return E_POINTER
;
1787 *type
= TASK_ACTION_EXEC
;
1792 static HRESULT WINAPI
ExecAction_get_Path(IExecAction
*iface
, BSTR
*path
)
1794 ExecAction
*action
= impl_from_IExecAction(iface
);
1796 TRACE("%p,%p\n", iface
, path
);
1798 if (!path
) return E_POINTER
;
1800 if (!action
->path
) *path
= NULL
;
1801 else if (!(*path
= SysAllocString(action
->path
))) return E_OUTOFMEMORY
;
1806 static HRESULT WINAPI
ExecAction_put_Path(IExecAction
*iface
, BSTR path
)
1808 ExecAction
*action
= impl_from_IExecAction(iface
);
1811 TRACE("%p,%s\n", iface
, debugstr_w(path
));
1813 if (path
&& !(str
= heap_strdupW((path
)))) return E_OUTOFMEMORY
;
1814 heap_free(action
->path
);
1820 static HRESULT WINAPI
ExecAction_get_Arguments(IExecAction
*iface
, BSTR
*arguments
)
1822 ExecAction
*action
= impl_from_IExecAction(iface
);
1824 TRACE("%p,%p\n", iface
, arguments
);
1826 if (!arguments
) return E_POINTER
;
1828 if (!action
->args
) *arguments
= NULL
;
1829 else if (!(*arguments
= SysAllocString(action
->args
))) return E_OUTOFMEMORY
;
1834 static HRESULT WINAPI
ExecAction_put_Arguments(IExecAction
*iface
, BSTR arguments
)
1836 ExecAction
*action
= impl_from_IExecAction(iface
);
1839 TRACE("%p,%s\n", iface
, debugstr_w(arguments
));
1841 if (arguments
&& !(str
= heap_strdupW((arguments
)))) return E_OUTOFMEMORY
;
1842 heap_free(action
->args
);
1848 static HRESULT WINAPI
ExecAction_get_WorkingDirectory(IExecAction
*iface
, BSTR
*directory
)
1850 ExecAction
*action
= impl_from_IExecAction(iface
);
1852 TRACE("%p,%p\n", iface
, directory
);
1854 if (!directory
) return E_POINTER
;
1856 if (!action
->directory
) *directory
= NULL
;
1857 else if (!(*directory
= SysAllocString(action
->directory
))) return E_OUTOFMEMORY
;
1862 static HRESULT WINAPI
ExecAction_put_WorkingDirectory(IExecAction
*iface
, BSTR directory
)
1864 ExecAction
*action
= impl_from_IExecAction(iface
);
1867 TRACE("%p,%s\n", iface
, debugstr_w(directory
));
1869 if (directory
&& !(str
= heap_strdupW((directory
)))) return E_OUTOFMEMORY
;
1870 heap_free(action
->directory
);
1871 action
->directory
= str
;
1876 static const IExecActionVtbl Action_vtbl
=
1878 ExecAction_QueryInterface
,
1881 ExecAction_GetTypeInfoCount
,
1882 ExecAction_GetTypeInfo
,
1883 ExecAction_GetIDsOfNames
,
1887 ExecAction_get_Type
,
1888 ExecAction_get_Path
,
1889 ExecAction_put_Path
,
1890 ExecAction_get_Arguments
,
1891 ExecAction_put_Arguments
,
1892 ExecAction_get_WorkingDirectory
,
1893 ExecAction_put_WorkingDirectory
1896 static HRESULT
ExecAction_create(IExecAction
**obj
)
1900 action
= heap_alloc(sizeof(*action
));
1901 if (!action
) return E_OUTOFMEMORY
;
1903 action
->IExecAction_iface
.lpVtbl
= &Action_vtbl
;
1905 action
->path
= NULL
;
1906 action
->directory
= NULL
;
1907 action
->args
= NULL
;
1910 *obj
= &action
->IExecAction_iface
;
1912 TRACE("created %p\n", *obj
);
1919 IActionCollection IActionCollection_iface
;
1923 static inline Actions
*impl_from_IActionCollection(IActionCollection
*iface
)
1925 return CONTAINING_RECORD(iface
, Actions
, IActionCollection_iface
);
1928 static ULONG WINAPI
Actions_AddRef(IActionCollection
*iface
)
1930 Actions
*actions
= impl_from_IActionCollection(iface
);
1931 return InterlockedIncrement(&actions
->ref
);
1934 static ULONG WINAPI
Actions_Release(IActionCollection
*iface
)
1936 Actions
*actions
= impl_from_IActionCollection(iface
);
1937 LONG ref
= InterlockedDecrement(&actions
->ref
);
1941 TRACE("destroying %p\n", iface
);
1948 static HRESULT WINAPI
Actions_QueryInterface(IActionCollection
*iface
, REFIID riid
, void **obj
)
1950 if (!riid
|| !obj
) return E_INVALIDARG
;
1952 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
1954 if (IsEqualGUID(riid
, &IID_IActionCollection
) ||
1955 IsEqualGUID(riid
, &IID_IDispatch
) ||
1956 IsEqualGUID(riid
, &IID_IUnknown
))
1958 IActionCollection_AddRef(iface
);
1963 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
1965 return E_NOINTERFACE
;
1968 static HRESULT WINAPI
Actions_GetTypeInfoCount(IActionCollection
*iface
, UINT
*count
)
1970 FIXME("%p,%p: stub\n", iface
, count
);
1974 static HRESULT WINAPI
Actions_GetTypeInfo(IActionCollection
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
1976 FIXME("%p,%u,%lu,%p: stub\n", iface
, index
, lcid
, info
);
1980 static HRESULT WINAPI
Actions_GetIDsOfNames(IActionCollection
*iface
, REFIID riid
, LPOLESTR
*names
,
1981 UINT count
, LCID lcid
, DISPID
*dispid
)
1983 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1987 static HRESULT WINAPI
Actions_Invoke(IActionCollection
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
1988 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
1990 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
1991 params
, result
, excepinfo
, argerr
);
1995 static HRESULT WINAPI
Actions_get_Count(IActionCollection
*iface
, LONG
*count
)
1997 FIXME("%p,%p: stub\n", iface
, count
);
2001 static HRESULT WINAPI
Actions_get_Item(IActionCollection
*iface
, LONG index
, IAction
**action
)
2003 FIXME("%p,%ld,%p: stub\n", iface
, index
, action
);
2007 static HRESULT WINAPI
Actions_get__NewEnum(IActionCollection
*iface
, IUnknown
**penum
)
2009 FIXME("%p,%p: stub\n", iface
, penum
);
2013 static HRESULT WINAPI
Actions_get_XmlText(IActionCollection
*iface
, BSTR
*xml
)
2015 FIXME("%p,%p: stub\n", iface
, xml
);
2019 static HRESULT WINAPI
Actions_put_XmlText(IActionCollection
*iface
, BSTR xml
)
2021 FIXME("%p,%s: stub\n", iface
, debugstr_w(xml
));
2025 static HRESULT WINAPI
Actions_Create(IActionCollection
*iface
, TASK_ACTION_TYPE type
, IAction
**action
)
2027 TRACE("%p,%u,%p\n", iface
, type
, action
);
2031 case TASK_ACTION_EXEC
:
2032 return ExecAction_create((IExecAction
**)action
);
2035 FIXME("unimplemented type %u\n", type
);
2040 static HRESULT WINAPI
Actions_Remove(IActionCollection
*iface
, VARIANT index
)
2042 FIXME("%p,%s: stub\n", iface
, debugstr_variant(&index
));
2046 static HRESULT WINAPI
Actions_Clear(IActionCollection
*iface
)
2048 FIXME("%p: stub\n", iface
);
2052 static HRESULT WINAPI
Actions_get_Context(IActionCollection
*iface
, BSTR
*ctx
)
2054 FIXME("%p,%p: stub\n", iface
, ctx
);
2058 static HRESULT WINAPI
Actions_put_Context(IActionCollection
*iface
, BSTR ctx
)
2060 FIXME("%p,%s: stub\n", iface
, debugstr_w(ctx
));
2064 static const IActionCollectionVtbl Actions_vtbl
=
2066 Actions_QueryInterface
,
2069 Actions_GetTypeInfoCount
,
2070 Actions_GetTypeInfo
,
2071 Actions_GetIDsOfNames
,
2075 Actions_get__NewEnum
,
2076 Actions_get_XmlText
,
2077 Actions_put_XmlText
,
2081 Actions_get_Context
,
2085 static HRESULT
Actions_create(IActionCollection
**obj
)
2089 actions
= heap_alloc(sizeof(*actions
));
2090 if (!actions
) return E_OUTOFMEMORY
;
2092 actions
->IActionCollection_iface
.lpVtbl
= &Actions_vtbl
;
2095 *obj
= &actions
->IActionCollection_iface
;
2097 TRACE("created %p\n", *obj
);
2104 ITaskDefinition ITaskDefinition_iface
;
2106 IRegistrationInfo
*reginfo
;
2107 ITaskSettings
*taskset
;
2108 ITriggerCollection
*triggers
;
2109 IPrincipal
*principal
;
2110 IActionCollection
*actions
;
2113 static inline TaskDefinition
*impl_from_ITaskDefinition(ITaskDefinition
*iface
)
2115 return CONTAINING_RECORD(iface
, TaskDefinition
, ITaskDefinition_iface
);
2118 static ULONG WINAPI
TaskDefinition_AddRef(ITaskDefinition
*iface
)
2120 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2121 return InterlockedIncrement(&taskdef
->ref
);
2124 static ULONG WINAPI
TaskDefinition_Release(ITaskDefinition
*iface
)
2126 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2127 LONG ref
= InterlockedDecrement(&taskdef
->ref
);
2131 TRACE("destroying %p\n", iface
);
2133 if (taskdef
->reginfo
)
2134 IRegistrationInfo_Release(taskdef
->reginfo
);
2135 if (taskdef
->taskset
)
2136 ITaskSettings_Release(taskdef
->taskset
);
2137 if (taskdef
->triggers
)
2138 ITriggerCollection_Release(taskdef
->triggers
);
2139 if (taskdef
->principal
)
2140 IPrincipal_Release(taskdef
->principal
);
2141 if (taskdef
->actions
)
2142 IActionCollection_Release(taskdef
->actions
);
2150 static HRESULT WINAPI
TaskDefinition_QueryInterface(ITaskDefinition
*iface
, REFIID riid
, void **obj
)
2152 if (!riid
|| !obj
) return E_INVALIDARG
;
2154 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
2156 if (IsEqualGUID(riid
, &IID_ITaskDefinition
) ||
2157 IsEqualGUID(riid
, &IID_IDispatch
) ||
2158 IsEqualGUID(riid
, &IID_IUnknown
))
2160 ITaskDefinition_AddRef(iface
);
2165 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
2167 return E_NOINTERFACE
;
2170 static HRESULT WINAPI
TaskDefinition_GetTypeInfoCount(ITaskDefinition
*iface
, UINT
*count
)
2172 FIXME("%p,%p: stub\n", iface
, count
);
2176 static HRESULT WINAPI
TaskDefinition_GetTypeInfo(ITaskDefinition
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
2178 FIXME("%p,%u,%lu,%p: stub\n", iface
, index
, lcid
, info
);
2182 static HRESULT WINAPI
TaskDefinition_GetIDsOfNames(ITaskDefinition
*iface
, REFIID riid
, LPOLESTR
*names
,
2183 UINT count
, LCID lcid
, DISPID
*dispid
)
2185 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2189 static HRESULT WINAPI
TaskDefinition_Invoke(ITaskDefinition
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
2190 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
2192 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
2193 params
, result
, excepinfo
, argerr
);
2197 static HRESULT WINAPI
TaskDefinition_get_RegistrationInfo(ITaskDefinition
*iface
, IRegistrationInfo
**info
)
2199 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2202 TRACE("%p,%p\n", iface
, info
);
2204 if (!info
) return E_POINTER
;
2206 if (!taskdef
->reginfo
)
2208 hr
= RegistrationInfo_create(&taskdef
->reginfo
);
2209 if (hr
!= S_OK
) return hr
;
2212 IRegistrationInfo_AddRef(taskdef
->reginfo
);
2213 *info
= taskdef
->reginfo
;
2218 static HRESULT WINAPI
TaskDefinition_put_RegistrationInfo(ITaskDefinition
*iface
, IRegistrationInfo
*info
)
2220 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2222 TRACE("%p,%p\n", iface
, info
);
2224 if (!info
) return E_POINTER
;
2226 if (taskdef
->reginfo
)
2227 IRegistrationInfo_Release(taskdef
->reginfo
);
2229 IRegistrationInfo_AddRef(info
);
2230 taskdef
->reginfo
= info
;
2235 static HRESULT WINAPI
TaskDefinition_get_Triggers(ITaskDefinition
*iface
, ITriggerCollection
**triggers
)
2237 TaskDefinition
*This
= impl_from_ITaskDefinition(iface
);
2239 TRACE("%p,%p\n", This
, triggers
);
2241 if (!This
->triggers
)
2243 trigger_collection
*collection
;
2245 collection
= heap_alloc(sizeof(*collection
));
2246 if (!collection
) return E_OUTOFMEMORY
;
2248 collection
->ITriggerCollection_iface
.lpVtbl
= &TriggerCollection_vtbl
;
2249 collection
->ref
= 1;
2250 This
->triggers
= &collection
->ITriggerCollection_iface
;
2253 ITriggerCollection_AddRef(*triggers
= This
->triggers
);
2257 static HRESULT WINAPI
TaskDefinition_put_Triggers(ITaskDefinition
*iface
, ITriggerCollection
*triggers
)
2259 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2261 TRACE("%p,%p\n", iface
, triggers
);
2263 if (!triggers
) return E_POINTER
;
2265 if (taskdef
->triggers
)
2266 ITriggerCollection_Release(taskdef
->triggers
);
2268 ITriggerCollection_AddRef(triggers
);
2269 taskdef
->triggers
= triggers
;
2274 static HRESULT WINAPI
TaskDefinition_get_Settings(ITaskDefinition
*iface
, ITaskSettings
**settings
)
2276 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2279 TRACE("%p,%p\n", iface
, settings
);
2281 if (!settings
) return E_POINTER
;
2283 if (!taskdef
->taskset
)
2285 hr
= TaskSettings_create(&taskdef
->taskset
);
2286 if (hr
!= S_OK
) return hr
;
2289 ITaskSettings_AddRef(taskdef
->taskset
);
2290 *settings
= taskdef
->taskset
;
2295 static HRESULT WINAPI
TaskDefinition_put_Settings(ITaskDefinition
*iface
, ITaskSettings
*settings
)
2297 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2299 TRACE("%p,%p\n", iface
, settings
);
2301 if (!settings
) return E_POINTER
;
2303 if (taskdef
->taskset
)
2304 ITaskSettings_Release(taskdef
->taskset
);
2306 ITaskSettings_AddRef(settings
);
2307 taskdef
->taskset
= settings
;
2312 static HRESULT WINAPI
TaskDefinition_get_Data(ITaskDefinition
*iface
, BSTR
*data
)
2314 FIXME("%p,%p: stub\n", iface
, data
);
2318 static HRESULT WINAPI
TaskDefinition_put_Data(ITaskDefinition
*iface
, BSTR data
)
2320 FIXME("%p,%p: stub\n", iface
, data
);
2324 static HRESULT WINAPI
TaskDefinition_get_Principal(ITaskDefinition
*iface
, IPrincipal
**principal
)
2326 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2329 TRACE("%p,%p\n", iface
, principal
);
2331 if (!principal
) return E_POINTER
;
2333 if (!taskdef
->principal
)
2335 hr
= Principal_create(&taskdef
->principal
);
2336 if (hr
!= S_OK
) return hr
;
2339 IPrincipal_AddRef(taskdef
->principal
);
2340 *principal
= taskdef
->principal
;
2345 static HRESULT WINAPI
TaskDefinition_put_Principal(ITaskDefinition
*iface
, IPrincipal
*principal
)
2347 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2349 TRACE("%p,%p\n", iface
, principal
);
2351 if (!principal
) return E_POINTER
;
2353 if (taskdef
->principal
)
2354 IPrincipal_Release(taskdef
->principal
);
2356 IPrincipal_AddRef(principal
);
2357 taskdef
->principal
= principal
;
2362 static HRESULT WINAPI
TaskDefinition_get_Actions(ITaskDefinition
*iface
, IActionCollection
**actions
)
2364 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2367 TRACE("%p,%p\n", iface
, actions
);
2369 if (!actions
) return E_POINTER
;
2371 if (!taskdef
->actions
)
2373 hr
= Actions_create(&taskdef
->actions
);
2374 if (hr
!= S_OK
) return hr
;
2377 IActionCollection_AddRef(taskdef
->actions
);
2378 *actions
= taskdef
->actions
;
2383 static HRESULT WINAPI
TaskDefinition_put_Actions(ITaskDefinition
*iface
, IActionCollection
*actions
)
2385 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2387 TRACE("%p,%p\n", iface
, actions
);
2389 if (!actions
) return E_POINTER
;
2391 if (taskdef
->actions
)
2392 IActionCollection_Release(taskdef
->actions
);
2394 IActionCollection_AddRef(actions
);
2395 taskdef
->actions
= actions
;
2400 static int xml_indent
;
2402 static inline void push_indent(void)
2407 static inline void pop_indent(void)
2412 static inline HRESULT
write_stringW(IStream
*stream
, const WCHAR
*str
)
2414 return IStream_Write(stream
, str
, lstrlenW(str
) * sizeof(WCHAR
), NULL
);
2417 static void write_indent(IStream
*stream
)
2420 for (i
= 0; i
< xml_indent
; i
+= 2)
2421 write_stringW(stream
, L
" ");
2424 static inline HRESULT
write_empty_element(IStream
*stream
, const WCHAR
*name
)
2426 write_indent(stream
);
2427 write_stringW(stream
, L
"<");
2428 write_stringW(stream
, name
);
2429 return write_stringW(stream
, L
"/>\n");
2432 static inline HRESULT
write_element(IStream
*stream
, const WCHAR
*name
)
2434 write_indent(stream
);
2435 write_stringW(stream
, L
"<");
2436 write_stringW(stream
, name
);
2437 return write_stringW(stream
, L
">\n");
2440 static inline HRESULT
write_element_end(IStream
*stream
, const WCHAR
*name
)
2442 write_indent(stream
);
2443 write_stringW(stream
, L
"</");
2444 write_stringW(stream
, name
);
2445 return write_stringW(stream
, L
">\n");
2448 static inline HRESULT
write_text_value(IStream
*stream
, const WCHAR
*name
, const WCHAR
*value
)
2450 write_indent(stream
);
2451 write_stringW(stream
, L
"<");
2452 write_stringW(stream
, name
);
2453 write_stringW(stream
, L
">");
2454 write_stringW(stream
, value
);
2455 write_stringW(stream
, L
"</");
2456 write_stringW(stream
, name
);
2457 return write_stringW(stream
, L
">\n");
2460 static HRESULT
write_task_attributes(IStream
*stream
, ITaskDefinition
*taskdef
)
2463 ITaskSettings
*taskset
;
2464 TASK_COMPATIBILITY level
;
2465 const WCHAR
*compatibility
;
2467 hr
= ITaskDefinition_get_Settings(taskdef
, &taskset
);
2468 if (hr
!= S_OK
) return hr
;
2470 hr
= ITaskSettings_get_Compatibility(taskset
, &level
);
2471 if (hr
!= S_OK
) level
= TASK_COMPATIBILITY_V2_1
;
2473 ITaskSettings_Release(taskset
);
2477 case TASK_COMPATIBILITY_AT
:
2478 compatibility
= L
"1.0";
2480 case TASK_COMPATIBILITY_V1
:
2481 compatibility
= L
"1.1";
2483 case TASK_COMPATIBILITY_V2
:
2484 compatibility
= L
"1.2";
2487 compatibility
= L
"1.3";
2491 write_stringW(stream
, L
"<Task version=\"");
2492 write_stringW(stream
, compatibility
);
2493 write_stringW(stream
, L
"\" xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">");
2494 return write_stringW(stream
, L
"\n");
2497 static HRESULT
write_registration_info(IStream
*stream
, IRegistrationInfo
*reginfo
)
2504 return write_empty_element(stream
, L
"RegistrationInfo");
2506 hr
= write_element(stream
, L
"RegistrationInfo");
2507 if (hr
!= S_OK
) return hr
;
2511 hr
= IRegistrationInfo_get_Source(reginfo
, &bstr
);
2512 if (hr
== S_OK
&& bstr
)
2514 hr
= write_text_value(stream
, L
"Source", bstr
);
2515 SysFreeString(bstr
);
2516 if (hr
!= S_OK
) return hr
;
2518 hr
= IRegistrationInfo_get_Date(reginfo
, &bstr
);
2519 if (hr
== S_OK
&& bstr
)
2521 hr
= write_text_value(stream
, L
"Date", bstr
);
2522 SysFreeString(bstr
);
2523 if (hr
!= S_OK
) return hr
;
2525 hr
= IRegistrationInfo_get_Author(reginfo
, &bstr
);
2526 if (hr
== S_OK
&& bstr
)
2528 hr
= write_text_value(stream
, L
"Author", bstr
);
2529 SysFreeString(bstr
);
2530 if (hr
!= S_OK
) return hr
;
2532 hr
= IRegistrationInfo_get_Version(reginfo
, &bstr
);
2533 if (hr
== S_OK
&& bstr
)
2535 hr
= write_text_value(stream
, L
"Version", bstr
);
2536 SysFreeString(bstr
);
2537 if (hr
!= S_OK
) return hr
;
2539 hr
= IRegistrationInfo_get_Description(reginfo
, &bstr
);
2540 if (hr
== S_OK
&& bstr
)
2542 hr
= write_text_value(stream
, L
"Description", bstr
);
2543 SysFreeString(bstr
);
2544 if (hr
!= S_OK
) return hr
;
2546 hr
= IRegistrationInfo_get_Documentation(reginfo
, &bstr
);
2547 if (hr
== S_OK
&& bstr
)
2549 hr
= write_text_value(stream
, L
"Documentation", bstr
);
2550 SysFreeString(bstr
);
2551 if (hr
!= S_OK
) return hr
;
2553 hr
= IRegistrationInfo_get_URI(reginfo
, &bstr
);
2554 if (hr
== S_OK
&& bstr
)
2556 hr
= write_text_value(stream
, L
"URI", bstr
);
2557 SysFreeString(bstr
);
2558 if (hr
!= S_OK
) return hr
;
2560 hr
= IRegistrationInfo_get_SecurityDescriptor(reginfo
, &var
);
2563 if (V_VT(&var
) == VT_BSTR
)
2565 hr
= write_text_value(stream
, L
"SecurityDescriptor", V_BSTR(&var
));
2567 if (hr
!= S_OK
) return hr
;
2570 FIXME("SecurityInfo variant type %d is not supported\n", V_VT(&var
));
2575 return write_element_end(stream
, L
"RegistrationInfo");
2578 static HRESULT
write_principal(IStream
*stream
, IPrincipal
*principal
)
2582 TASK_LOGON_TYPE logon
;
2583 TASK_RUNLEVEL_TYPE level
;
2586 return write_empty_element(stream
, L
"Principals");
2588 hr
= write_element(stream
, L
"Principals");
2589 if (hr
!= S_OK
) return hr
;
2593 hr
= IPrincipal_get_Id(principal
, &bstr
);
2596 write_indent(stream
);
2597 write_stringW(stream
, L
"<Principal id=\"");
2598 write_stringW(stream
, bstr
);
2599 write_stringW(stream
, L
"\">\n");
2600 SysFreeString(bstr
);
2603 write_element(stream
, L
"Principal");
2607 hr
= IPrincipal_get_GroupId(principal
, &bstr
);
2610 hr
= write_text_value(stream
, L
"GroupId", bstr
);
2611 SysFreeString(bstr
);
2612 if (hr
!= S_OK
) return hr
;
2614 hr
= IPrincipal_get_DisplayName(principal
, &bstr
);
2617 hr
= write_text_value(stream
, L
"DisplayName", bstr
);
2618 SysFreeString(bstr
);
2619 if (hr
!= S_OK
) return hr
;
2621 hr
= IPrincipal_get_UserId(principal
, &bstr
);
2622 if (hr
== S_OK
&& lstrlenW(bstr
))
2624 hr
= write_text_value(stream
, L
"UserId", bstr
);
2625 SysFreeString(bstr
);
2626 if (hr
!= S_OK
) return hr
;
2628 hr
= IPrincipal_get_RunLevel(principal
, &level
);
2631 const WCHAR
*level_str
= NULL
;
2635 case TASK_RUNLEVEL_HIGHEST
:
2636 level_str
= L
"HighestAvailable";
2638 case TASK_RUNLEVEL_LUA
:
2639 level_str
= L
"LeastPrivilege";
2642 FIXME("Principal run level %d\n", level
);
2648 hr
= write_text_value(stream
, L
"RunLevel", level_str
);
2649 if (hr
!= S_OK
) return hr
;
2652 hr
= IPrincipal_get_LogonType(principal
, &logon
);
2655 const WCHAR
*logon_str
= NULL
;
2659 case TASK_LOGON_PASSWORD
:
2660 logon_str
= L
"Password";
2662 case TASK_LOGON_S4U
:
2665 case TASK_LOGON_INTERACTIVE_TOKEN
:
2666 logon_str
= L
"InteractiveToken";
2669 FIXME("Principal logon type %d\n", logon
);
2675 hr
= write_text_value(stream
, L
"LogonType", logon_str
);
2676 if (hr
!= S_OK
) return hr
;
2681 write_element_end(stream
, L
"Principal");
2684 return write_element_end(stream
, L
"Principals");
2687 static HRESULT
write_settings(IStream
*stream
, ITaskSettings
*settings
)
2690 return write_empty_element(stream
, L
"Settings");
2696 static HRESULT
write_triggers(IStream
*stream
, ITriggerCollection
*triggers
)
2699 return write_empty_element(stream
, L
"Triggers");
2705 static HRESULT
write_actions(IStream
*stream
, IActionCollection
*actions
)
2709 write_element(stream
, L
"Actions");
2711 write_empty_element(stream
, L
"Exec");
2713 return write_element_end(stream
, L
"Actions");
2720 static HRESULT WINAPI
TaskDefinition_get_XmlText(ITaskDefinition
*iface
, BSTR
*xml
)
2722 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
2728 TRACE("%p,%p\n", iface
, xml
);
2730 hmem
= GlobalAlloc(GMEM_MOVEABLE
| GMEM_NODISCARD
, 16);
2731 if (!hmem
) return E_OUTOFMEMORY
;
2733 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, &stream
);
2740 hr
= write_task_attributes(stream
, &taskdef
->ITaskDefinition_iface
);
2741 if (hr
!= S_OK
) goto failed
;
2745 hr
= write_registration_info(stream
, taskdef
->reginfo
);
2746 if (hr
!= S_OK
) goto failed
;
2748 hr
= write_triggers(stream
, taskdef
->triggers
);
2749 if (hr
!= S_OK
) goto failed
;
2751 hr
= write_principal(stream
, taskdef
->principal
);
2752 if (hr
!= S_OK
) goto failed
;
2754 hr
= write_settings(stream
, taskdef
->taskset
);
2755 if (hr
!= S_OK
) goto failed
;
2757 hr
= write_actions(stream
, taskdef
->actions
);
2758 if (hr
!= S_OK
) goto failed
;
2762 write_element_end(stream
, L
"Task");
2763 IStream_Write(stream
, "\0\0", 2, NULL
);
2765 p
= GlobalLock(hmem
);
2766 *xml
= SysAllocString(p
);
2769 IStream_Release(stream
);
2771 return *xml
? S_OK
: E_OUTOFMEMORY
;
2774 IStream_Release(stream
);
2778 static HRESULT
read_text_value(IXmlReader
*reader
, WCHAR
**value
)
2783 while (IXmlReader_Read(reader
, &type
) == S_OK
)
2787 case XmlNodeType_Text
:
2788 hr
= IXmlReader_GetValue(reader
, (const WCHAR
**)value
, NULL
);
2789 if (hr
!= S_OK
) return hr
;
2790 TRACE("%s\n", debugstr_w(*value
));
2793 case XmlNodeType_Whitespace
:
2794 case XmlNodeType_Comment
:
2798 FIXME("unexpected node type %d\n", type
);
2806 static HRESULT
read_variantbool_value(IXmlReader
*reader
, VARIANT_BOOL
*vbool
)
2811 hr
= read_text_value(reader
, &value
);
2812 if (hr
!= S_OK
) return hr
;
2814 if (!lstrcmpW(value
, L
"true"))
2815 *vbool
= VARIANT_TRUE
;
2816 else if (!lstrcmpW(value
, L
"false"))
2817 *vbool
= VARIANT_FALSE
;
2820 WARN("unexpected bool value %s\n", debugstr_w(value
));
2821 return SCHED_E_INVALIDVALUE
;
2827 static HRESULT
read_int_value(IXmlReader
*reader
, int *int_val
)
2832 hr
= read_text_value(reader
, &value
);
2833 if (hr
!= S_OK
) return hr
;
2835 *int_val
= wcstol(value
, NULL
, 10);
2840 static HRESULT
read_triggers(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
2846 static HRESULT
read_principal_attributes(IXmlReader
*reader
, IPrincipal
*principal
)
2852 hr
= IXmlReader_MoveToFirstAttribute(reader
);
2856 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2857 if (hr
!= S_OK
) break;
2859 hr
= IXmlReader_GetValue(reader
, &value
, NULL
);
2860 if (hr
!= S_OK
) break;
2862 TRACE("%s=%s\n", debugstr_w(name
), debugstr_w(value
));
2864 if (!lstrcmpW(name
, L
"id"))
2865 IPrincipal_put_Id(principal
, (BSTR
)value
);
2867 FIXME("unhandled Principal attribute %s\n", debugstr_w(name
));
2869 hr
= IXmlReader_MoveToNextAttribute(reader
);
2875 static HRESULT
read_principal(IXmlReader
*reader
, IPrincipal
*principal
)
2882 if (IXmlReader_IsEmptyElement(reader
))
2884 TRACE("Principal is empty\n");
2888 read_principal_attributes(reader
, principal
);
2890 while (IXmlReader_Read(reader
, &type
) == S_OK
)
2894 case XmlNodeType_EndElement
:
2895 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2896 if (hr
!= S_OK
) return hr
;
2898 TRACE("/%s\n", debugstr_w(name
));
2900 if (!lstrcmpW(name
, L
"Principal"))
2905 case XmlNodeType_Element
:
2906 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2907 if (hr
!= S_OK
) return hr
;
2909 TRACE("Element: %s\n", debugstr_w(name
));
2911 if (!lstrcmpW(name
, L
"UserId"))
2913 hr
= read_text_value(reader
, &value
);
2915 IPrincipal_put_UserId(principal
, value
);
2917 else if (!lstrcmpW(name
, L
"LogonType"))
2919 hr
= read_text_value(reader
, &value
);
2922 TASK_LOGON_TYPE logon
= TASK_LOGON_NONE
;
2924 if (!lstrcmpW(value
, L
"InteractiveToken"))
2925 logon
= TASK_LOGON_INTERACTIVE_TOKEN
;
2927 FIXME("unhandled LogonType %s\n", debugstr_w(value
));
2929 IPrincipal_put_LogonType(principal
, logon
);
2932 else if (!lstrcmpW(name
, L
"RunLevel"))
2934 hr
= read_text_value(reader
, &value
);
2937 TASK_RUNLEVEL_TYPE level
= TASK_RUNLEVEL_LUA
;
2939 if (!lstrcmpW(value
, L
"LeastPrivilege"))
2940 level
= TASK_RUNLEVEL_LUA
;
2942 FIXME("unhandled RunLevel %s\n", debugstr_w(value
));
2944 IPrincipal_put_RunLevel(principal
, level
);
2948 FIXME("unhandled Principal element %s\n", debugstr_w(name
));
2952 case XmlNodeType_Whitespace
:
2953 case XmlNodeType_Comment
:
2957 FIXME("unhandled Principal node type %d\n", type
);
2962 WARN("Principal was not terminated\n");
2966 static HRESULT
read_principals(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
2972 if (IXmlReader_IsEmptyElement(reader
))
2974 TRACE("Principals is empty\n");
2978 while (IXmlReader_Read(reader
, &type
) == S_OK
)
2982 case XmlNodeType_EndElement
:
2983 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2984 if (hr
!= S_OK
) return hr
;
2986 TRACE("/%s\n", debugstr_w(name
));
2988 if (!lstrcmpW(name
, L
"Principals"))
2993 case XmlNodeType_Element
:
2994 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
2995 if (hr
!= S_OK
) return hr
;
2997 TRACE("Element: %s\n", debugstr_w(name
));
2999 if (!lstrcmpW(name
, L
"Principal"))
3001 IPrincipal
*principal
;
3003 hr
= ITaskDefinition_get_Principal(taskdef
, &principal
);
3004 if (hr
!= S_OK
) return hr
;
3005 hr
= read_principal(reader
, principal
);
3006 IPrincipal_Release(principal
);
3009 FIXME("unhandled Principals element %s\n", debugstr_w(name
));
3013 case XmlNodeType_Whitespace
:
3014 case XmlNodeType_Comment
:
3018 FIXME("unhandled Principals node type %d\n", type
);
3023 WARN("Principals was not terminated\n");
3027 static HRESULT
read_actions(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3033 static HRESULT
read_idle_settings(IXmlReader
*reader
, ITaskSettings
*taskset
)
3039 static HRESULT
read_settings(IXmlReader
*reader
, ITaskSettings
*taskset
)
3045 VARIANT_BOOL bool_val
;
3048 if (IXmlReader_IsEmptyElement(reader
))
3050 TRACE("Settings is empty\n");
3054 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3058 case XmlNodeType_EndElement
:
3059 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3060 if (hr
!= S_OK
) return hr
;
3062 TRACE("/%s\n", debugstr_w(name
));
3064 if (!lstrcmpW(name
, L
"Settings"))
3069 case XmlNodeType_Element
:
3070 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3071 if (hr
!= S_OK
) return hr
;
3073 TRACE("Element: %s\n", debugstr_w(name
));
3075 if (!lstrcmpW(name
, L
"MultipleInstancesPolicy"))
3077 hr
= read_text_value(reader
, &value
);
3080 int_val
= TASK_INSTANCES_IGNORE_NEW
;
3082 if (!lstrcmpW(value
, L
"IgnoreNew"))
3083 int_val
= TASK_INSTANCES_IGNORE_NEW
;
3085 FIXME("unhandled MultipleInstancesPolicy %s\n", debugstr_w(value
));
3087 ITaskSettings_put_MultipleInstances(taskset
, int_val
);
3090 else if (!lstrcmpW(name
, L
"DisallowStartIfOnBatteries"))
3092 hr
= read_variantbool_value(reader
, &bool_val
);
3093 if (hr
!= S_OK
) return hr
;
3094 ITaskSettings_put_DisallowStartIfOnBatteries(taskset
, bool_val
);
3096 else if (!lstrcmpW(name
, L
"AllowStartOnDemand"))
3098 hr
= read_variantbool_value(reader
, &bool_val
);
3099 if (hr
!= S_OK
) return hr
;
3100 ITaskSettings_put_AllowDemandStart(taskset
, bool_val
);
3102 else if (!lstrcmpW(name
, L
"StopIfGoingOnBatteries"))
3104 hr
= read_variantbool_value(reader
, &bool_val
);
3105 if (hr
!= S_OK
) return hr
;
3106 ITaskSettings_put_StopIfGoingOnBatteries(taskset
, bool_val
);
3108 else if (!lstrcmpW(name
, L
"AllowHardTerminate"))
3110 hr
= read_variantbool_value(reader
, &bool_val
);
3111 if (hr
!= S_OK
) return hr
;
3112 ITaskSettings_put_AllowHardTerminate(taskset
, bool_val
);
3114 else if (!lstrcmpW(name
, L
"StartWhenAvailable"))
3116 hr
= read_variantbool_value(reader
, &bool_val
);
3117 if (hr
!= S_OK
) return hr
;
3118 ITaskSettings_put_StartWhenAvailable(taskset
, bool_val
);
3120 else if (!lstrcmpW(name
, L
"RunOnlyIfNetworkAvailable"))
3122 hr
= read_variantbool_value(reader
, &bool_val
);
3123 if (hr
!= S_OK
) return hr
;
3124 ITaskSettings_put_RunOnlyIfNetworkAvailable(taskset
, bool_val
);
3126 else if (!lstrcmpW(name
, L
"Enabled"))
3128 hr
= read_variantbool_value(reader
, &bool_val
);
3129 if (hr
!= S_OK
) return hr
;
3130 ITaskSettings_put_Enabled(taskset
, bool_val
);
3132 else if (!lstrcmpW(name
, L
"Hidden"))
3134 hr
= read_variantbool_value(reader
, &bool_val
);
3135 if (hr
!= S_OK
) return hr
;
3136 ITaskSettings_put_Hidden(taskset
, bool_val
);
3138 else if (!lstrcmpW(name
, L
"RunOnlyIfIdle"))
3140 hr
= read_variantbool_value(reader
, &bool_val
);
3141 if (hr
!= S_OK
) return hr
;
3142 ITaskSettings_put_RunOnlyIfIdle(taskset
, bool_val
);
3144 else if (!lstrcmpW(name
, L
"WakeToRun"))
3146 hr
= read_variantbool_value(reader
, &bool_val
);
3147 if (hr
!= S_OK
) return hr
;
3148 ITaskSettings_put_WakeToRun(taskset
, bool_val
);
3150 else if (!lstrcmpW(name
, L
"ExecutionTimeLimit"))
3152 hr
= read_text_value(reader
, &value
);
3154 ITaskSettings_put_ExecutionTimeLimit(taskset
, value
);
3156 else if (!lstrcmpW(name
, L
"Priority"))
3158 hr
= read_int_value(reader
, &int_val
);
3160 ITaskSettings_put_Priority(taskset
, int_val
);
3162 else if (!lstrcmpW(name
, L
"IdleSettings"))
3164 hr
= read_idle_settings(reader
, taskset
);
3165 if (hr
!= S_OK
) return hr
;
3168 FIXME("unhandled Settings element %s\n", debugstr_w(name
));
3172 case XmlNodeType_Whitespace
:
3173 case XmlNodeType_Comment
:
3177 FIXME("unhandled Settings node type %d\n", type
);
3182 WARN("Settings was not terminated\n");
3183 return SCHED_E_MALFORMEDXML
;
3186 static HRESULT
read_registration_info(IXmlReader
*reader
, IRegistrationInfo
*info
)
3193 if (IXmlReader_IsEmptyElement(reader
))
3195 TRACE("RegistrationInfo is empty\n");
3199 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3203 case XmlNodeType_EndElement
:
3204 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3205 if (hr
!= S_OK
) return hr
;
3207 TRACE("/%s\n", debugstr_w(name
));
3209 if (!lstrcmpW(name
, L
"RegistrationInfo"))
3214 case XmlNodeType_Element
:
3215 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3216 if (hr
!= S_OK
) return hr
;
3218 TRACE("Element: %s\n", debugstr_w(name
));
3220 if (!lstrcmpW(name
, L
"Author"))
3222 hr
= read_text_value(reader
, &value
);
3224 IRegistrationInfo_put_Author(info
, value
);
3226 else if (!lstrcmpW(name
, L
"Description"))
3228 hr
= read_text_value(reader
, &value
);
3230 IRegistrationInfo_put_Description(info
, value
);
3232 else if (!lstrcmpW(name
, L
"Version"))
3234 hr
= read_text_value(reader
, &value
);
3236 IRegistrationInfo_put_Version(info
, value
);
3238 else if (!lstrcmpW(name
, L
"Date"))
3240 hr
= read_text_value(reader
, &value
);
3242 IRegistrationInfo_put_Date(info
, value
);
3244 else if (!lstrcmpW(name
, L
"Documentation"))
3246 hr
= read_text_value(reader
, &value
);
3248 IRegistrationInfo_put_Documentation(info
, value
);
3250 else if (!lstrcmpW(name
, L
"URI"))
3252 hr
= read_text_value(reader
, &value
);
3254 IRegistrationInfo_put_URI(info
, value
);
3256 else if (!lstrcmpW(name
, L
"Source"))
3258 hr
= read_text_value(reader
, &value
);
3260 IRegistrationInfo_put_Source(info
, value
);
3263 FIXME("unhandled RegistrationInfo element %s\n", debugstr_w(name
));
3267 case XmlNodeType_Whitespace
:
3268 case XmlNodeType_Comment
:
3272 FIXME("unhandled RegistrationInfo node type %d\n", type
);
3277 WARN("RegistrationInfo was not terminated\n");
3278 return SCHED_E_MALFORMEDXML
;
3281 static HRESULT
read_task_attributes(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3284 ITaskSettings
*taskset
;
3287 BOOL xmlns_ok
= FALSE
;
3291 hr
= ITaskDefinition_get_Settings(taskdef
, &taskset
);
3292 if (hr
!= S_OK
) return hr
;
3294 hr
= IXmlReader_MoveToFirstAttribute(reader
);
3298 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3299 if (hr
!= S_OK
) break;
3301 hr
= IXmlReader_GetValue(reader
, &value
, NULL
);
3302 if (hr
!= S_OK
) break;
3304 TRACE("%s=%s\n", debugstr_w(name
), debugstr_w(value
));
3306 if (!lstrcmpW(name
, L
"version"))
3308 TASK_COMPATIBILITY compatibility
= TASK_COMPATIBILITY_V2
;
3310 if (!lstrcmpW(value
, L
"1.0"))
3311 compatibility
= TASK_COMPATIBILITY_AT
;
3312 else if (!lstrcmpW(value
, L
"1.1"))
3313 compatibility
= TASK_COMPATIBILITY_V1
;
3314 else if (!lstrcmpW(value
, L
"1.2"))
3315 compatibility
= TASK_COMPATIBILITY_V2
;
3316 else if (!lstrcmpW(value
, L
"1.3"))
3317 compatibility
= TASK_COMPATIBILITY_V2_1
;
3319 FIXME("unknown version %s\n", debugstr_w(value
));
3321 ITaskSettings_put_Compatibility(taskset
, compatibility
);
3323 else if (!lstrcmpW(name
, L
"xmlns"))
3325 if (lstrcmpW(value
, L
"http://schemas.microsoft.com/windows/2004/02/mit/task"))
3327 FIXME("unknown namespace %s\n", debugstr_w(value
));
3333 FIXME("unhandled Task attribute %s\n", debugstr_w(name
));
3335 hr
= IXmlReader_MoveToNextAttribute(reader
);
3338 ITaskSettings_Release(taskset
);
3339 return xmlns_ok
? S_OK
: SCHED_E_NAMESPACE
;
3342 static HRESULT
read_task(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3348 if (IXmlReader_IsEmptyElement(reader
))
3350 TRACE("Task is empty\n");
3354 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3358 case XmlNodeType_EndElement
:
3359 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3360 if (hr
!= S_OK
) return hr
;
3362 TRACE("/%s\n", debugstr_w(name
));
3364 if (!lstrcmpW(name
, L
"Task"))
3369 case XmlNodeType_Element
:
3370 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3371 if (hr
!= S_OK
) return hr
;
3373 TRACE("Element: %s\n", debugstr_w(name
));
3375 if (!lstrcmpW(name
, L
"RegistrationInfo"))
3377 IRegistrationInfo
*info
;
3379 hr
= ITaskDefinition_get_RegistrationInfo(taskdef
, &info
);
3380 if (hr
!= S_OK
) return hr
;
3381 hr
= read_registration_info(reader
, info
);
3382 IRegistrationInfo_Release(info
);
3384 else if (!lstrcmpW(name
, L
"Settings"))
3386 ITaskSettings
*taskset
;
3388 hr
= ITaskDefinition_get_Settings(taskdef
, &taskset
);
3389 if (hr
!= S_OK
) return hr
;
3390 hr
= read_settings(reader
, taskset
);
3391 ITaskSettings_Release(taskset
);
3393 else if (!lstrcmpW(name
, L
"Triggers"))
3394 hr
= read_triggers(reader
, taskdef
);
3395 else if (!lstrcmpW(name
, L
"Principals"))
3396 hr
= read_principals(reader
, taskdef
);
3397 else if (!lstrcmpW(name
, L
"Actions"))
3398 hr
= read_actions(reader
, taskdef
);
3400 FIXME("unhandled Task element %s\n", debugstr_w(name
));
3402 if (hr
!= S_OK
) return hr
;
3405 case XmlNodeType_Comment
:
3406 case XmlNodeType_Whitespace
:
3410 FIXME("unhandled Task node type %d\n", type
);
3415 WARN("Task was not terminated\n");
3416 return SCHED_E_MALFORMEDXML
;
3419 static HRESULT
read_xml(IXmlReader
*reader
, ITaskDefinition
*taskdef
)
3425 while (IXmlReader_Read(reader
, &type
) == S_OK
)
3429 case XmlNodeType_XmlDeclaration
:
3430 TRACE("XmlDeclaration\n");
3433 case XmlNodeType_Element
:
3434 hr
= IXmlReader_GetLocalName(reader
, &name
, NULL
);
3435 if (hr
!= S_OK
) return hr
;
3437 TRACE("Element: %s\n", debugstr_w(name
));
3439 if (!lstrcmpW(name
, L
"Task"))
3441 hr
= read_task_attributes(reader
, taskdef
);
3442 if (hr
!= S_OK
) return hr
;
3444 return read_task(reader
, taskdef
);
3447 FIXME("unhandled XML element %s\n", debugstr_w(name
));
3451 case XmlNodeType_Comment
:
3452 case XmlNodeType_Whitespace
:
3456 FIXME("unhandled XML node type %d\n", type
);
3461 WARN("Task definition was not found\n");
3462 return SCHED_E_MALFORMEDXML
;
3465 static HRESULT WINAPI
TaskDefinition_put_XmlText(ITaskDefinition
*iface
, BSTR xml
)
3467 TaskDefinition
*taskdef
= impl_from_ITaskDefinition(iface
);
3474 TRACE("%p,%s\n", iface
, debugstr_w(xml
));
3476 if (!xml
) return E_INVALIDARG
;
3478 hmem
= GlobalAlloc(0, lstrlenW(xml
) * sizeof(WCHAR
));
3479 if (!hmem
) return E_OUTOFMEMORY
;
3481 buf
= GlobalLock(hmem
);
3482 memcpy(buf
, xml
, lstrlenW(xml
) * sizeof(WCHAR
));
3485 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, &stream
);
3492 hr
= CreateXmlReader(&IID_IXmlReader
, (void **)&reader
, NULL
);
3495 IStream_Release(stream
);
3499 hr
= IXmlReader_SetInput(reader
, (IUnknown
*)stream
);
3502 if (taskdef
->reginfo
)
3504 IRegistrationInfo_Release(taskdef
->reginfo
);
3505 taskdef
->reginfo
= NULL
;
3507 if (taskdef
->taskset
)
3509 ITaskSettings_Release(taskdef
->taskset
);
3510 taskdef
->taskset
= NULL
;
3512 if (taskdef
->triggers
)
3514 ITriggerCollection_Release(taskdef
->triggers
);
3515 taskdef
->triggers
= NULL
;
3517 if (taskdef
->principal
)
3519 IPrincipal_Release(taskdef
->principal
);
3520 taskdef
->principal
= NULL
;
3522 if (taskdef
->actions
)
3524 IActionCollection_Release(taskdef
->actions
);
3525 taskdef
->actions
= NULL
;
3528 hr
= read_xml(reader
, iface
);
3531 IXmlReader_Release(reader
);
3532 IStream_Release(stream
);
3537 static const ITaskDefinitionVtbl TaskDefinition_vtbl
=
3539 TaskDefinition_QueryInterface
,
3540 TaskDefinition_AddRef
,
3541 TaskDefinition_Release
,
3542 TaskDefinition_GetTypeInfoCount
,
3543 TaskDefinition_GetTypeInfo
,
3544 TaskDefinition_GetIDsOfNames
,
3545 TaskDefinition_Invoke
,
3546 TaskDefinition_get_RegistrationInfo
,
3547 TaskDefinition_put_RegistrationInfo
,
3548 TaskDefinition_get_Triggers
,
3549 TaskDefinition_put_Triggers
,
3550 TaskDefinition_get_Settings
,
3551 TaskDefinition_put_Settings
,
3552 TaskDefinition_get_Data
,
3553 TaskDefinition_put_Data
,
3554 TaskDefinition_get_Principal
,
3555 TaskDefinition_put_Principal
,
3556 TaskDefinition_get_Actions
,
3557 TaskDefinition_put_Actions
,
3558 TaskDefinition_get_XmlText
,
3559 TaskDefinition_put_XmlText
3562 HRESULT
TaskDefinition_create(ITaskDefinition
**obj
)
3564 TaskDefinition
*taskdef
;
3566 taskdef
= heap_alloc_zero(sizeof(*taskdef
));
3567 if (!taskdef
) return E_OUTOFMEMORY
;
3569 taskdef
->ITaskDefinition_iface
.lpVtbl
= &TaskDefinition_vtbl
;
3571 *obj
= &taskdef
->ITaskDefinition_iface
;
3573 TRACE("created %p\n", *obj
);
3580 ITaskService ITaskService_iface
;
3584 WCHAR comp_name
[MAX_COMPUTERNAME_LENGTH
+ 1];
3587 static inline TaskService
*impl_from_ITaskService(ITaskService
*iface
)
3589 return CONTAINING_RECORD(iface
, TaskService
, ITaskService_iface
);
3592 static ULONG WINAPI
TaskService_AddRef(ITaskService
*iface
)
3594 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3595 return InterlockedIncrement(&task_svc
->ref
);
3598 static ULONG WINAPI
TaskService_Release(ITaskService
*iface
)
3600 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3601 LONG ref
= InterlockedDecrement(&task_svc
->ref
);
3605 TRACE("destroying %p\n", iface
);
3606 heap_free(task_svc
);
3612 static HRESULT WINAPI
TaskService_QueryInterface(ITaskService
*iface
, REFIID riid
, void **obj
)
3614 if (!riid
|| !obj
) return E_INVALIDARG
;
3616 TRACE("%p,%s,%p\n", iface
, debugstr_guid(riid
), obj
);
3618 if (IsEqualGUID(riid
, &IID_ITaskService
) ||
3619 IsEqualGUID(riid
, &IID_IDispatch
) ||
3620 IsEqualGUID(riid
, &IID_IUnknown
))
3622 ITaskService_AddRef(iface
);
3627 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
3629 return E_NOINTERFACE
;
3632 static HRESULT WINAPI
TaskService_GetTypeInfoCount(ITaskService
*iface
, UINT
*count
)
3634 FIXME("%p,%p: stub\n", iface
, count
);
3638 static HRESULT WINAPI
TaskService_GetTypeInfo(ITaskService
*iface
, UINT index
, LCID lcid
, ITypeInfo
**info
)
3640 FIXME("%p,%u,%lu,%p: stub\n", iface
, index
, lcid
, info
);
3644 static HRESULT WINAPI
TaskService_GetIDsOfNames(ITaskService
*iface
, REFIID riid
, LPOLESTR
*names
,
3645 UINT count
, LCID lcid
, DISPID
*dispid
)
3647 FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3651 static HRESULT WINAPI
TaskService_Invoke(ITaskService
*iface
, DISPID dispid
, REFIID riid
, LCID lcid
, WORD flags
,
3652 DISPPARAMS
*params
, VARIANT
*result
, EXCEPINFO
*excepinfo
, UINT
*argerr
)
3654 FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface
, dispid
, debugstr_guid(riid
), lcid
, flags
,
3655 params
, result
, excepinfo
, argerr
);
3659 static HRESULT WINAPI
TaskService_GetFolder(ITaskService
*iface
, BSTR path
, ITaskFolder
**folder
)
3661 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3663 TRACE("%p,%s,%p\n", iface
, debugstr_w(path
), folder
);
3665 if (!folder
) return E_POINTER
;
3667 if (!task_svc
->connected
)
3668 return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
);
3670 return TaskFolder_create(path
, NULL
, folder
, FALSE
);
3673 static HRESULT WINAPI
TaskService_GetRunningTasks(ITaskService
*iface
, LONG flags
, IRunningTaskCollection
**tasks
)
3675 FIXME("%p,%lx,%p: stub\n", iface
, flags
, tasks
);
3679 static HRESULT WINAPI
TaskService_NewTask(ITaskService
*iface
, DWORD flags
, ITaskDefinition
**definition
)
3681 TRACE("%p,%lx,%p\n", iface
, flags
, definition
);
3683 if (!definition
) return E_POINTER
;
3686 FIXME("unsupported flags %lx\n", flags
);
3688 return TaskDefinition_create(definition
);
3691 static inline BOOL
is_variant_null(const VARIANT
*var
)
3693 return V_VT(var
) == VT_EMPTY
|| V_VT(var
) == VT_NULL
||
3694 (V_VT(var
) == VT_BSTR
&& (V_BSTR(var
) == NULL
|| !*V_BSTR(var
)));
3697 static HRESULT
start_schedsvc(void)
3699 SC_HANDLE scm
, service
;
3700 SERVICE_STATUS_PROCESS status
;
3701 ULONGLONG start_time
;
3702 HRESULT hr
= SCHED_E_SERVICE_NOT_RUNNING
;
3704 TRACE("Trying to start Schedule service\n");
3706 scm
= OpenSCManagerW(NULL
, NULL
, 0);
3707 if (!scm
) return SCHED_E_SERVICE_NOT_INSTALLED
;
3709 service
= OpenServiceW(scm
, L
"Schedule", SERVICE_START
| SERVICE_QUERY_STATUS
);
3712 if (StartServiceW(service
, 0, NULL
) || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING
)
3714 start_time
= GetTickCount64();
3719 if (!QueryServiceStatusEx(service
, SC_STATUS_PROCESS_INFO
, (BYTE
*)&status
, sizeof(status
), &dummy
))
3721 WARN("failed to query scheduler status (%lu)\n", GetLastError());
3725 if (status
.dwCurrentState
== SERVICE_RUNNING
)
3731 if (GetTickCount64() - start_time
> 30000) break;
3734 } while (status
.dwCurrentState
== SERVICE_START_PENDING
);
3736 if (status
.dwCurrentState
!= SERVICE_RUNNING
)
3737 WARN("scheduler failed to start %lu\n", status
.dwCurrentState
);
3740 WARN("failed to start scheduler service (%lu)\n", GetLastError());
3742 CloseServiceHandle(service
);
3745 WARN("failed to open scheduler service (%lu)\n", GetLastError());
3747 CloseServiceHandle(scm
);
3751 static HRESULT WINAPI
TaskService_Connect(ITaskService
*iface
, VARIANT server
, VARIANT user
, VARIANT domain
, VARIANT password
)
3753 static WCHAR ncalrpc
[] = L
"ncalrpc";
3754 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3755 WCHAR comp_name
[MAX_COMPUTERNAME_LENGTH
+ 1];
3758 RPC_WSTR binding_str
;
3759 extern handle_t schrpc_handle
;
3761 TRACE("%p,%s,%s,%s,%s\n", iface
, debugstr_variant(&server
), debugstr_variant(&user
),
3762 debugstr_variant(&domain
), debugstr_variant(&password
));
3764 if (!is_variant_null(&user
) || !is_variant_null(&domain
) || !is_variant_null(&password
))
3765 FIXME("user/domain/password are ignored\n");
3767 len
= ARRAY_SIZE(comp_name
);
3768 if (!GetComputerNameW(comp_name
, &len
))
3769 return HRESULT_FROM_WIN32(GetLastError());
3771 if (!is_variant_null(&server
))
3773 const WCHAR
*server_name
;
3775 if (V_VT(&server
) != VT_BSTR
)
3777 FIXME("server variant type %d is not supported\n", V_VT(&server
));
3778 return HRESULT_FROM_WIN32(ERROR_BAD_NETPATH
);
3781 /* skip UNC prefix if any */
3782 server_name
= V_BSTR(&server
);
3783 if (server_name
[0] == '\\' && server_name
[1] == '\\')
3786 if (wcsicmp(server_name
, comp_name
))
3788 FIXME("connection to remote server %s is not supported\n", debugstr_w(V_BSTR(&server
)));
3789 return HRESULT_FROM_WIN32(ERROR_BAD_NETPATH
);
3793 hr
= start_schedsvc();
3794 if (hr
!= S_OK
) return hr
;
3796 hr
= RpcStringBindingComposeW(NULL
, ncalrpc
, NULL
, NULL
, NULL
, &binding_str
);
3797 if (hr
!= RPC_S_OK
) return hr
;
3798 hr
= RpcBindingFromStringBindingW(binding_str
, &schrpc_handle
);
3799 RpcStringFreeW(&binding_str
);
3800 if (hr
!= RPC_S_OK
) return hr
;
3802 /* Make sure that the connection works */
3803 hr
= SchRpcHighestVersion(&task_svc
->version
);
3804 if (hr
!= S_OK
) return hr
;
3806 TRACE("server version %#lx\n", task_svc
->version
);
3808 lstrcpyW(task_svc
->comp_name
, comp_name
);
3809 task_svc
->connected
= TRUE
;
3814 static HRESULT WINAPI
TaskService_get_Connected(ITaskService
*iface
, VARIANT_BOOL
*connected
)
3816 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3818 TRACE("%p,%p\n", iface
, connected
);
3820 if (!connected
) return E_POINTER
;
3822 *connected
= task_svc
->connected
? VARIANT_TRUE
: VARIANT_FALSE
;
3827 static HRESULT WINAPI
TaskService_get_TargetServer(ITaskService
*iface
, BSTR
*server
)
3829 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3831 TRACE("%p,%p\n", iface
, server
);
3833 if (!server
) return E_POINTER
;
3835 if (!task_svc
->connected
)
3836 return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
);
3838 *server
= SysAllocString(task_svc
->comp_name
);
3839 if (!*server
) return E_OUTOFMEMORY
;
3844 static HRESULT WINAPI
TaskService_get_ConnectedUser(ITaskService
*iface
, BSTR
*user
)
3846 FIXME("%p,%p: stub\n", iface
, user
);
3850 static HRESULT WINAPI
TaskService_get_ConnectedDomain(ITaskService
*iface
, BSTR
*domain
)
3852 FIXME("%p,%p: stub\n", iface
, domain
);
3856 static HRESULT WINAPI
TaskService_get_HighestVersion(ITaskService
*iface
, DWORD
*version
)
3858 TaskService
*task_svc
= impl_from_ITaskService(iface
);
3860 TRACE("%p,%p\n", iface
, version
);
3862 if (!version
) return E_POINTER
;
3864 if (!task_svc
->connected
)
3865 return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
);
3867 *version
= task_svc
->version
;
3872 static const ITaskServiceVtbl TaskService_vtbl
=
3874 TaskService_QueryInterface
,
3876 TaskService_Release
,
3877 TaskService_GetTypeInfoCount
,
3878 TaskService_GetTypeInfo
,
3879 TaskService_GetIDsOfNames
,
3881 TaskService_GetFolder
,
3882 TaskService_GetRunningTasks
,
3883 TaskService_NewTask
,
3884 TaskService_Connect
,
3885 TaskService_get_Connected
,
3886 TaskService_get_TargetServer
,
3887 TaskService_get_ConnectedUser
,
3888 TaskService_get_ConnectedDomain
,
3889 TaskService_get_HighestVersion
3892 HRESULT
TaskService_create(void **obj
)
3894 TaskService
*task_svc
;
3896 task_svc
= heap_alloc(sizeof(*task_svc
));
3897 if (!task_svc
) return E_OUTOFMEMORY
;
3899 task_svc
->ITaskService_iface
.lpVtbl
= &TaskService_vtbl
;
3901 task_svc
->connected
= FALSE
;
3902 *obj
= &task_svc
->ITaskService_iface
;
3904 TRACE("created %p\n", *obj
);
3909 void __RPC_FAR
*__RPC_USER
MIDL_user_allocate(SIZE_T n
)
3911 return HeapAlloc(GetProcessHeap(), 0, n
);
3914 void __RPC_USER
MIDL_user_free(void __RPC_FAR
*p
)
3916 HeapFree(GetProcessHeap(), 0, p
);