ReactOS 0.4.16-dev-297-gc569aee
task_trigger.c File Reference
#include <stdarg.h>
#include "winternl.h"
#include "mstask_private.h"
#include "wine/debug.h"
Include dependency graph for task_trigger.c:

Go to the source code of this file.

Classes

struct  TaskTriggerImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (mstask)
 
static TaskTriggerImplimpl_from_ITaskTrigger (ITaskTrigger *iface)
 
static HRESULT WINAPI MSTASK_ITaskTrigger_QueryInterface (ITaskTrigger *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI MSTASK_ITaskTrigger_AddRef (ITaskTrigger *iface)
 
static ULONG WINAPI MSTASK_ITaskTrigger_Release (ITaskTrigger *iface)
 
static HRESULT WINAPI MSTASK_ITaskTrigger_SetTrigger (ITaskTrigger *iface, const PTASK_TRIGGER pTrigger)
 
static HRESULT WINAPI MSTASK_ITaskTrigger_GetTrigger (ITaskTrigger *iface, PTASK_TRIGGER pTrigger)
 
static HRESULT WINAPI MSTASK_ITaskTrigger_GetTriggerString (ITaskTrigger *iface, LPWSTR *ppwszTrigger)
 
HRESULT TaskTriggerConstructor (LPVOID *ppObj)
 

Variables

static const ITaskTriggerVtbl MSTASK_ITaskTriggerVtbl
 

Function Documentation

◆ impl_from_ITaskTrigger()

static TaskTriggerImpl * impl_from_ITaskTrigger ( ITaskTrigger iface)
inlinestatic

Definition at line 33 of file task_trigger.c.

34{
35 return CONTAINING_RECORD(iface, TaskTriggerImpl, ITaskTrigger_iface);
36}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by MSTASK_ITaskTrigger_AddRef(), MSTASK_ITaskTrigger_GetTrigger(), MSTASK_ITaskTrigger_QueryInterface(), MSTASK_ITaskTrigger_Release(), and MSTASK_ITaskTrigger_SetTrigger().

◆ MSTASK_ITaskTrigger_AddRef()

static ULONG WINAPI MSTASK_ITaskTrigger_AddRef ( ITaskTrigger iface)
static

Definition at line 62 of file task_trigger.c.

64{
66 ULONG ref;
67 TRACE("\n");
69 return ref;
70}
#define InterlockedIncrement
Definition: armddk.h:53
static TaskTriggerImpl * impl_from_ITaskTrigger(ITaskTrigger *iface)
Definition: task_trigger.c:33
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ MSTASK_ITaskTrigger_GetTrigger()

static HRESULT WINAPI MSTASK_ITaskTrigger_GetTrigger ( ITaskTrigger iface,
PTASK_TRIGGER  pTrigger 
)
static

Definition at line 196 of file task_trigger.c.

199{
201
202 TRACE("(%p, %p)\n", iface, pTrigger);
203
204 /* Native implementation doesn't verify equivalent cbTriggerSize fields */
205
206 /* Copy relevant fields of the structure */
207 pTrigger->cbTriggerSize = This->triggerCond.cbTriggerSize;
208 pTrigger->Reserved1 = 0;
209 pTrigger->wBeginYear = This->triggerCond.wBeginYear;
210 pTrigger->wBeginMonth = This->triggerCond.wBeginMonth;
211 pTrigger->wBeginDay = This->triggerCond.wBeginDay;
212 pTrigger->wEndYear = This->triggerCond.wEndYear;
213 pTrigger->wEndMonth = This->triggerCond.wEndMonth;
214 pTrigger->wEndDay = This->triggerCond.wEndDay;
215 pTrigger->wStartHour = This->triggerCond.wStartHour;
216 pTrigger->wStartMinute = This->triggerCond.wStartMinute;
217 pTrigger->MinutesDuration = This->triggerCond.MinutesDuration;
218 pTrigger->MinutesInterval = This->triggerCond.MinutesInterval;
219 pTrigger->rgFlags = This->triggerCond.rgFlags;
220 pTrigger->TriggerType = This->triggerCond.TriggerType;
221 switch (This->triggerCond.TriggerType)
222 {
223 case TASK_TIME_TRIGGER_DAILY:
224 pTrigger->Type.Daily.DaysInterval =
225 This->triggerCond.Type.Daily.DaysInterval;
226 break;
227 case TASK_TIME_TRIGGER_WEEKLY:
228 pTrigger->Type.Weekly.WeeksInterval =
229 This->triggerCond.Type.Weekly.WeeksInterval;
230 pTrigger->Type.Weekly.rgfDaysOfTheWeek =
231 This->triggerCond.Type.Weekly.rgfDaysOfTheWeek;
232 break;
233 case TASK_TIME_TRIGGER_MONTHLYDATE:
234 pTrigger->Type.MonthlyDate.rgfDays =
235 This->triggerCond.Type.MonthlyDate.rgfDays;
236 pTrigger->Type.MonthlyDate.rgfMonths =
237 This->triggerCond.Type.MonthlyDate.rgfMonths;
238 break;
239 case TASK_TIME_TRIGGER_MONTHLYDOW:
240 pTrigger->Type.MonthlyDOW.wWhichWeek =
241 This->triggerCond.Type.MonthlyDOW.wWhichWeek;
242 pTrigger->Type.MonthlyDOW.rgfDaysOfTheWeek =
243 This->triggerCond.Type.MonthlyDOW.rgfDaysOfTheWeek;
244 pTrigger->Type.MonthlyDOW.rgfMonths =
245 This->triggerCond.Type.MonthlyDOW.rgfMonths;
246 break;
247 case TASK_TIME_TRIGGER_ONCE:
248 case TASK_EVENT_TRIGGER_ON_IDLE:
249 case TASK_EVENT_TRIGGER_AT_SYSTEMSTART:
250 case TASK_EVENT_TRIGGER_AT_LOGON:
251 default:
252 break;
253 }
254 pTrigger->Reserved2 = 0;
255 pTrigger->wRandomMinutesInterval = 0;
256 return S_OK;
257}
#define S_OK
Definition: intsafe.h:52

◆ MSTASK_ITaskTrigger_GetTriggerString()

static HRESULT WINAPI MSTASK_ITaskTrigger_GetTriggerString ( ITaskTrigger iface,
LPWSTR ppwszTrigger 
)
static

Definition at line 259 of file task_trigger.c.

262{
263 FIXME("Not implemented\n");
264 return E_NOTIMPL;
265}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ MSTASK_ITaskTrigger_QueryInterface()

static HRESULT WINAPI MSTASK_ITaskTrigger_QueryInterface ( ITaskTrigger iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 38 of file task_trigger.c.

42{
44
45 TRACE("IID: %s\n", debugstr_guid(riid));
46 if (ppvObject == NULL)
47 return E_POINTER;
48
50 IsEqualGUID(riid, &IID_ITaskTrigger))
51 {
52 *ppvObject = &This->ITaskTrigger_iface;
53 ITaskTrigger_AddRef(iface);
54 return S_OK;
55 }
56
57 WARN("Unknown interface: %s\n", debugstr_guid(riid));
58 *ppvObject = NULL;
59 return E_NOINTERFACE;
60}
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365

◆ MSTASK_ITaskTrigger_Release()

static ULONG WINAPI MSTASK_ITaskTrigger_Release ( ITaskTrigger iface)
static

Definition at line 72 of file task_trigger.c.

74{
76 ULONG ref;
77 TRACE("\n");
79 if (ref == 0)
80 {
83 }
84 return ref;
85}
#define InterlockedDecrement
Definition: armddk.h:52
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
LONG dll_ref
Definition: mstask_main.c:31

◆ MSTASK_ITaskTrigger_SetTrigger()

static HRESULT WINAPI MSTASK_ITaskTrigger_SetTrigger ( ITaskTrigger iface,
const PTASK_TRIGGER  pTrigger 
)
static

Definition at line 87 of file task_trigger.c.

90{
92 TIME_FIELDS field_time;
93 LARGE_INTEGER sys_time;
94 TASK_TRIGGER tmp_trigger_cond;
95
96 TRACE("(%p, %p)\n", iface, pTrigger);
97
98 /* Verify valid structure size */
99 if (pTrigger->cbTriggerSize != sizeof(*pTrigger))
100 return E_INVALIDARG;
101 tmp_trigger_cond.cbTriggerSize = pTrigger->cbTriggerSize;
102
103 /* Reserved field must be zero */
104 tmp_trigger_cond.Reserved1 = 0;
105
106 /* Verify and set valid start date and time */
107 memset(&field_time, 0, sizeof(field_time));
108 field_time.Year = pTrigger->wBeginYear;
109 field_time.Month = pTrigger->wBeginMonth;
110 field_time.Day = pTrigger->wBeginDay;
111 field_time.Hour = pTrigger->wStartHour;
112 field_time.Minute = pTrigger->wStartMinute;
113 if (!RtlTimeFieldsToTime(&field_time, &sys_time))
114 return E_INVALIDARG;
115 tmp_trigger_cond.wBeginYear = pTrigger->wBeginYear;
116 tmp_trigger_cond.wBeginMonth = pTrigger->wBeginMonth;
117 tmp_trigger_cond.wBeginDay = pTrigger->wBeginDay;
118 tmp_trigger_cond.wStartHour = pTrigger->wStartHour;
119 tmp_trigger_cond.wStartMinute = pTrigger->wStartMinute;
120
121 /* Verify valid end date if TASK_TRIGGER_FLAG_HAS_END_DATE flag is set */
122 if (pTrigger->rgFlags & TASK_TRIGGER_FLAG_HAS_END_DATE)
123 {
124 memset(&field_time, 0, sizeof(field_time));
125 field_time.Year = pTrigger->wEndYear;
126 field_time.Month = pTrigger->wEndMonth;
127 field_time.Day = pTrigger->wEndDay;
128 if (!RtlTimeFieldsToTime(&field_time, &sys_time))
129 return E_INVALIDARG;
130 }
131
132 /* Set valid end date independent of TASK_TRIGGER_FLAG_HAS_END_DATE flag */
133 tmp_trigger_cond.wEndYear = pTrigger->wEndYear;
134 tmp_trigger_cond.wEndMonth = pTrigger->wEndMonth;
135 tmp_trigger_cond.wEndDay = pTrigger->wEndDay;
136
137 /* Verify duration and interval pair */
138 if (pTrigger->MinutesDuration <= pTrigger->MinutesInterval &&
139 pTrigger->MinutesInterval > 0)
140 return E_INVALIDARG;
141 tmp_trigger_cond.MinutesDuration = pTrigger->MinutesDuration;
142 tmp_trigger_cond.MinutesInterval = pTrigger->MinutesInterval;
143
144 /* Copy over flags */
145 tmp_trigger_cond.rgFlags = pTrigger->rgFlags;
146
147 /* Set TriggerType dependent fields of Type union */
148 tmp_trigger_cond.TriggerType = pTrigger->TriggerType;
149 switch (pTrigger->TriggerType)
150 {
151 case TASK_TIME_TRIGGER_DAILY:
152 tmp_trigger_cond.Type.Daily.DaysInterval =
153 pTrigger->Type.Daily.DaysInterval;
154 break;
155 case TASK_TIME_TRIGGER_WEEKLY:
156 tmp_trigger_cond.Type.Weekly.WeeksInterval =
157 pTrigger->Type.Weekly.WeeksInterval;
158 tmp_trigger_cond.Type.Weekly.rgfDaysOfTheWeek =
159 pTrigger->Type.Weekly.rgfDaysOfTheWeek;
160 break;
161 case TASK_TIME_TRIGGER_MONTHLYDATE:
162 tmp_trigger_cond.Type.MonthlyDate.rgfDays =
163 pTrigger->Type.MonthlyDate.rgfDays;
164 tmp_trigger_cond.Type.MonthlyDate.rgfMonths =
165 pTrigger->Type.MonthlyDate.rgfMonths;
166 break;
167 case TASK_TIME_TRIGGER_MONTHLYDOW:
168 tmp_trigger_cond.Type.MonthlyDOW.wWhichWeek =
169 pTrigger->Type.MonthlyDOW.wWhichWeek;
170 tmp_trigger_cond.Type.MonthlyDOW.rgfDaysOfTheWeek =
171 pTrigger->Type.MonthlyDOW.rgfDaysOfTheWeek;
172 tmp_trigger_cond.Type.MonthlyDOW.rgfMonths =
173 pTrigger->Type.MonthlyDOW.rgfMonths;
174 break;
175 case TASK_TIME_TRIGGER_ONCE:
176 case TASK_EVENT_TRIGGER_ON_IDLE:
177 case TASK_EVENT_TRIGGER_AT_SYSTEMSTART:
178 case TASK_EVENT_TRIGGER_AT_LOGON:
179 default:
180 tmp_trigger_cond.Type = This->triggerCond.Type;
181 break;
182 }
183
184 /* Reserved field must be zero */
185 tmp_trigger_cond.Reserved2 = 0;
186
187 /* wRandomMinutesInterval not currently used and is initialized to zero */
188 tmp_trigger_cond.wRandomMinutesInterval = 0;
189
190 /* Update object copy of triggerCond */
191 This->triggerCond = tmp_trigger_cond;
192
193 return S_OK;
194}
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOLEAN RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)
#define memset(x, y, z)
Definition: compat.h:39

◆ TaskTriggerConstructor()

HRESULT TaskTriggerConstructor ( LPVOID ppObj)

Definition at line 277 of file task_trigger.c.

278{
281 TRACE("(%p)\n", ppObj);
282
283 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
284 if (!This)
285 return E_OUTOFMEMORY;
286
287 This->ITaskTrigger_iface.lpVtbl = &MSTASK_ITaskTriggerVtbl;
288 This->ref = 1;
289
290 /* Most fields of triggerCond default to zero. Initialize other
291 * fields to default values. */
292 memset(&This->triggerCond, 0, sizeof(TASK_TRIGGER));
294 This->triggerCond.cbTriggerSize = sizeof(This->triggerCond);
295 This->triggerCond.wBeginYear = time.wYear;
296 This->triggerCond.wBeginMonth = time.wMonth;
297 This->triggerCond.wBeginDay = time.wDay;
298 This->triggerCond.wStartHour = time.wHour;
299 This->triggerCond.wStartMinute = time.wMinute;
300 This->triggerCond.rgFlags = TASK_TRIGGER_FLAG_DISABLED;
301 This->triggerCond.TriggerType = TASK_TIME_TRIGGER_DAILY,
302 This->triggerCond.Type.Daily.DaysInterval = 1;
303
304 *ppObj = &This->ITaskTrigger_iface;
306 return S_OK;
307}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define HeapAlloc
Definition: compat.h:733
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
static const ITaskTriggerVtbl MSTASK_ITaskTriggerVtbl
Definition: task_trigger.c:267
__u16 time
Definition: mkdosfs.c:8

Referenced by MSTASK_ITask_CreateTrigger().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( mstask  )

Variable Documentation

◆ MSTASK_ITaskTriggerVtbl

const ITaskTriggerVtbl MSTASK_ITaskTriggerVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI MSTASK_ITaskTrigger_GetTrigger(ITaskTrigger *iface, PTASK_TRIGGER pTrigger)
Definition: task_trigger.c:196
static HRESULT WINAPI MSTASK_ITaskTrigger_GetTriggerString(ITaskTrigger *iface, LPWSTR *ppwszTrigger)
Definition: task_trigger.c:259
static ULONG WINAPI MSTASK_ITaskTrigger_AddRef(ITaskTrigger *iface)
Definition: task_trigger.c:62
static ULONG WINAPI MSTASK_ITaskTrigger_Release(ITaskTrigger *iface)
Definition: task_trigger.c:72
static HRESULT WINAPI MSTASK_ITaskTrigger_SetTrigger(ITaskTrigger *iface, const PTASK_TRIGGER pTrigger)
Definition: task_trigger.c:87
static HRESULT WINAPI MSTASK_ITaskTrigger_QueryInterface(ITaskTrigger *iface, REFIID riid, void **ppvObject)
Definition: task_trigger.c:38

Definition at line 267 of file task_trigger.c.

Referenced by TaskTriggerConstructor().