1 /* 2 * Copyright (C) 2008 Google (Roy Shea) 3 * 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. 8 * 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. 13 * 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 17 */ 18 19 #include "mstask_private.h" 20 #include "wine/debug.h" 21 22 WINE_DEFAULT_DEBUG_CHANNEL(mstask); 23 24 typedef struct 25 { 26 ITask ITask_iface; 27 IPersistFile IPersistFile_iface; 28 LONG ref; 29 LPWSTR taskName; 30 LPWSTR applicationName; 31 LPWSTR parameters; 32 LPWSTR comment; 33 DWORD maxRunTime; 34 LPWSTR accountName; 35 } TaskImpl; 36 37 static inline TaskImpl *impl_from_ITask(ITask *iface) 38 { 39 return CONTAINING_RECORD(iface, TaskImpl, ITask_iface); 40 } 41 42 static inline TaskImpl *impl_from_IPersistFile( IPersistFile *iface ) 43 { 44 return CONTAINING_RECORD(iface, TaskImpl, IPersistFile_iface); 45 } 46 47 static void TaskDestructor(TaskImpl *This) 48 { 49 TRACE("%p\n", This); 50 HeapFree(GetProcessHeap(), 0, This->accountName); 51 HeapFree(GetProcessHeap(), 0, This->comment); 52 HeapFree(GetProcessHeap(), 0, This->parameters); 53 HeapFree(GetProcessHeap(), 0, This->taskName); 54 HeapFree(GetProcessHeap(), 0, This); 55 InterlockedDecrement(&dll_ref); 56 } 57 58 static HRESULT WINAPI MSTASK_ITask_QueryInterface( 59 ITask* iface, 60 REFIID riid, 61 void **ppvObject) 62 { 63 TaskImpl * This = impl_from_ITask(iface); 64 65 TRACE("IID: %s\n", debugstr_guid(riid)); 66 if (ppvObject == NULL) 67 return E_POINTER; 68 69 if (IsEqualGUID(riid, &IID_IUnknown) || 70 IsEqualGUID(riid, &IID_ITask)) 71 { 72 *ppvObject = &This->ITask_iface; 73 ITask_AddRef(iface); 74 return S_OK; 75 } 76 else if (IsEqualGUID(riid, &IID_IPersistFile)) 77 { 78 *ppvObject = &This->IPersistFile_iface; 79 ITask_AddRef(iface); 80 return S_OK; 81 } 82 83 WARN("Unknown interface: %s\n", debugstr_guid(riid)); 84 *ppvObject = NULL; 85 return E_NOINTERFACE; 86 } 87 88 static ULONG WINAPI MSTASK_ITask_AddRef( 89 ITask* iface) 90 { 91 TaskImpl *This = impl_from_ITask(iface); 92 ULONG ref; 93 TRACE("\n"); 94 ref = InterlockedIncrement(&This->ref); 95 return ref; 96 } 97 98 static ULONG WINAPI MSTASK_ITask_Release( 99 ITask* iface) 100 { 101 TaskImpl * This = impl_from_ITask(iface); 102 ULONG ref; 103 TRACE("\n"); 104 ref = InterlockedDecrement(&This->ref); 105 if (ref == 0) 106 TaskDestructor(This); 107 return ref; 108 } 109 110 static HRESULT WINAPI MSTASK_ITask_CreateTrigger( 111 ITask* iface, 112 WORD *piNewTrigger, 113 ITaskTrigger **ppTrigger) 114 { 115 TRACE("(%p, %p, %p)\n", iface, piNewTrigger, ppTrigger); 116 return TaskTriggerConstructor((LPVOID *)ppTrigger); 117 } 118 119 static HRESULT WINAPI MSTASK_ITask_DeleteTrigger( 120 ITask* iface, 121 WORD iTrigger) 122 { 123 FIXME("(%p, %d): stub\n", iface, iTrigger); 124 return E_NOTIMPL; 125 } 126 127 static HRESULT WINAPI MSTASK_ITask_GetTriggerCount( 128 ITask* iface, 129 WORD *plCount) 130 { 131 FIXME("(%p, %p): stub\n", iface, plCount); 132 return E_NOTIMPL; 133 } 134 135 static HRESULT WINAPI MSTASK_ITask_GetTrigger( 136 ITask* iface, 137 WORD iTrigger, 138 ITaskTrigger **ppTrigger) 139 { 140 FIXME("(%p, %d, %p): stub\n", iface, iTrigger, ppTrigger); 141 return E_NOTIMPL; 142 } 143 144 static HRESULT WINAPI MSTASK_ITask_GetTriggerString( 145 ITask* iface, 146 WORD iTrigger, 147 LPWSTR *ppwszTrigger) 148 { 149 FIXME("(%p, %d, %p): stub\n", iface, iTrigger, ppwszTrigger); 150 return E_NOTIMPL; 151 } 152 153 static HRESULT WINAPI MSTASK_ITask_GetRunTimes( 154 ITask* iface, 155 const LPSYSTEMTIME pstBegin, 156 const LPSYSTEMTIME pstEnd, 157 WORD *pCount, 158 LPSYSTEMTIME *rgstTaskTimes) 159 { 160 FIXME("(%p, %p, %p, %p, %p): stub\n", iface, pstBegin, pstEnd, pCount, 161 rgstTaskTimes); 162 return E_NOTIMPL; 163 } 164 165 static HRESULT WINAPI MSTASK_ITask_GetNextRunTime( 166 ITask* iface, 167 SYSTEMTIME *pstNextRun) 168 { 169 FIXME("(%p, %p): stub\n", iface, pstNextRun); 170 return E_NOTIMPL; 171 } 172 173 static HRESULT WINAPI MSTASK_ITask_SetIdleWait( 174 ITask* iface, 175 WORD wIdleMinutes, 176 WORD wDeadlineMinutes) 177 { 178 FIXME("(%p, %d, %d): stub\n", iface, wIdleMinutes, wDeadlineMinutes); 179 return E_NOTIMPL; 180 } 181 182 static HRESULT WINAPI MSTASK_ITask_GetIdleWait( 183 ITask* iface, 184 WORD *pwIdleMinutes, 185 WORD *pwDeadlineMinutes) 186 { 187 FIXME("(%p, %p, %p): stub\n", iface, pwIdleMinutes, pwDeadlineMinutes); 188 return E_NOTIMPL; 189 } 190 191 static HRESULT WINAPI MSTASK_ITask_Run( 192 ITask* iface) 193 { 194 FIXME("(%p): stub\n", iface); 195 return E_NOTIMPL; 196 } 197 198 static HRESULT WINAPI MSTASK_ITask_Terminate( 199 ITask* iface) 200 { 201 FIXME("(%p): stub\n", iface); 202 return E_NOTIMPL; 203 } 204 205 static HRESULT WINAPI MSTASK_ITask_EditWorkItem( 206 ITask* iface, 207 HWND hParent, 208 DWORD dwReserved) 209 { 210 FIXME("(%p, %p, %d): stub\n", iface, hParent, dwReserved); 211 return E_NOTIMPL; 212 } 213 214 static HRESULT WINAPI MSTASK_ITask_GetMostRecentRunTime( 215 ITask* iface, 216 SYSTEMTIME *pstLastRun) 217 { 218 FIXME("(%p, %p): stub\n", iface, pstLastRun); 219 return E_NOTIMPL; 220 } 221 222 static HRESULT WINAPI MSTASK_ITask_GetStatus( 223 ITask* iface, 224 HRESULT *phrStatus) 225 { 226 FIXME("(%p, %p): stub\n", iface, phrStatus); 227 return E_NOTIMPL; 228 } 229 230 static HRESULT WINAPI MSTASK_ITask_GetExitCode( 231 ITask* iface, 232 DWORD *pdwExitCode) 233 { 234 FIXME("(%p, %p): stub\n", iface, pdwExitCode); 235 return E_NOTIMPL; 236 } 237 238 static HRESULT WINAPI MSTASK_ITask_SetComment( 239 ITask* iface, 240 LPCWSTR pwszComment) 241 { 242 DWORD n; 243 TaskImpl *This = impl_from_ITask(iface); 244 LPWSTR tmp_comment; 245 246 TRACE("(%p, %s)\n", iface, debugstr_w(pwszComment)); 247 248 /* Empty comment */ 249 if (pwszComment[0] == 0) 250 { 251 HeapFree(GetProcessHeap(), 0, This->comment); 252 This->comment = NULL; 253 return S_OK; 254 } 255 256 /* Set to pwszComment */ 257 n = (lstrlenW(pwszComment) + 1); 258 tmp_comment = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR)); 259 if (!tmp_comment) 260 return E_OUTOFMEMORY; 261 lstrcpyW(tmp_comment, pwszComment); 262 HeapFree(GetProcessHeap(), 0, This->comment); 263 This->comment = tmp_comment; 264 265 return S_OK; 266 } 267 268 static HRESULT WINAPI MSTASK_ITask_GetComment( 269 ITask* iface, 270 LPWSTR *ppwszComment) 271 { 272 DWORD n; 273 TaskImpl *This = impl_from_ITask(iface); 274 275 TRACE("(%p, %p)\n", iface, ppwszComment); 276 277 n = This->comment ? lstrlenW(This->comment) + 1 : 1; 278 *ppwszComment = CoTaskMemAlloc(n * sizeof(WCHAR)); 279 if (!*ppwszComment) 280 return E_OUTOFMEMORY; 281 282 if (!This->comment) 283 *ppwszComment[0] = 0; 284 else 285 lstrcpyW(*ppwszComment, This->comment); 286 287 return S_OK; 288 } 289 290 static HRESULT WINAPI MSTASK_ITask_SetCreator( 291 ITask* iface, 292 LPCWSTR pwszCreator) 293 { 294 FIXME("(%p, %p): stub\n", iface, pwszCreator); 295 return E_NOTIMPL; 296 } 297 298 static HRESULT WINAPI MSTASK_ITask_GetCreator( 299 ITask* iface, 300 LPWSTR *ppwszCreator) 301 { 302 FIXME("(%p, %p): stub\n", iface, ppwszCreator); 303 return E_NOTIMPL; 304 } 305 306 static HRESULT WINAPI MSTASK_ITask_SetWorkItemData( 307 ITask* iface, 308 WORD cBytes, 309 BYTE rgbData[]) 310 { 311 FIXME("(%p, %d, %p): stub\n", iface, cBytes, rgbData); 312 return E_NOTIMPL; 313 } 314 315 static HRESULT WINAPI MSTASK_ITask_GetWorkItemData( 316 ITask* iface, 317 WORD *pcBytes, 318 BYTE **ppBytes) 319 { 320 FIXME("(%p, %p, %p): stub\n", iface, pcBytes, ppBytes); 321 return E_NOTIMPL; 322 } 323 324 static HRESULT WINAPI MSTASK_ITask_SetErrorRetryCount( 325 ITask* iface, 326 WORD wRetryCount) 327 { 328 FIXME("(%p, %d): stub\n", iface, wRetryCount); 329 return E_NOTIMPL; 330 } 331 332 static HRESULT WINAPI MSTASK_ITask_GetErrorRetryCount( 333 ITask* iface, 334 WORD *pwRetryCount) 335 { 336 FIXME("(%p, %p): stub\n", iface, pwRetryCount); 337 return E_NOTIMPL; 338 } 339 340 static HRESULT WINAPI MSTASK_ITask_SetErrorRetryInterval( 341 ITask* iface, 342 WORD wRetryInterval) 343 { 344 FIXME("(%p, %d): stub\n", iface, wRetryInterval); 345 return E_NOTIMPL; 346 } 347 348 static HRESULT WINAPI MSTASK_ITask_GetErrorRetryInterval( 349 ITask* iface, 350 WORD *pwRetryInterval) 351 { 352 FIXME("(%p, %p): stub\n", iface, pwRetryInterval); 353 return E_NOTIMPL; 354 } 355 356 static HRESULT WINAPI MSTASK_ITask_SetFlags( 357 ITask* iface, 358 DWORD dwFlags) 359 { 360 FIXME("(%p, 0x%08x): stub\n", iface, dwFlags); 361 return E_NOTIMPL; 362 } 363 364 static HRESULT WINAPI MSTASK_ITask_GetFlags( 365 ITask* iface, 366 DWORD *pdwFlags) 367 { 368 FIXME("(%p, %p): stub\n", iface, pdwFlags); 369 return E_NOTIMPL; 370 } 371 372 static HRESULT WINAPI MSTASK_ITask_SetAccountInformation( 373 ITask* iface, 374 LPCWSTR pwszAccountName, 375 LPCWSTR pwszPassword) 376 { 377 DWORD n; 378 TaskImpl *This = impl_from_ITask(iface); 379 LPWSTR tmp_account_name; 380 381 TRACE("(%p, %s, %s): partial stub\n", iface, debugstr_w(pwszAccountName), 382 debugstr_w(pwszPassword)); 383 384 if (pwszPassword) 385 FIXME("Partial stub ignores passwords\n"); 386 387 n = (lstrlenW(pwszAccountName) + 1); 388 tmp_account_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR)); 389 if (!tmp_account_name) 390 return E_OUTOFMEMORY; 391 lstrcpyW(tmp_account_name, pwszAccountName); 392 HeapFree(GetProcessHeap(), 0, This->accountName); 393 This->accountName = tmp_account_name; 394 return S_OK; 395 } 396 397 static HRESULT WINAPI MSTASK_ITask_GetAccountInformation( 398 ITask* iface, 399 LPWSTR *ppwszAccountName) 400 { 401 DWORD n; 402 TaskImpl *This = impl_from_ITask(iface); 403 404 TRACE("(%p, %p): partial stub\n", iface, ppwszAccountName); 405 406 /* This implements the WinXP behavior when accountName has not yet 407 * set. Win2K behaves differently, returning SCHED_E_CANNOT_OPEN_TASK */ 408 if (!This->accountName) 409 return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); 410 411 n = (lstrlenW(This->accountName) + 1); 412 *ppwszAccountName = CoTaskMemAlloc(n * sizeof(WCHAR)); 413 if (!*ppwszAccountName) 414 return E_OUTOFMEMORY; 415 lstrcpyW(*ppwszAccountName, This->accountName); 416 return S_OK; 417 } 418 419 static HRESULT WINAPI MSTASK_ITask_SetApplicationName( 420 ITask* iface, 421 LPCWSTR pwszApplicationName) 422 { 423 DWORD n; 424 TaskImpl *This = impl_from_ITask(iface); 425 LPWSTR tmp_name; 426 427 TRACE("(%p, %s)\n", iface, debugstr_w(pwszApplicationName)); 428 429 /* Empty application name */ 430 if (pwszApplicationName[0] == 0) 431 { 432 HeapFree(GetProcessHeap(), 0, This->applicationName); 433 This->applicationName = NULL; 434 return S_OK; 435 } 436 437 /* Attempt to set pwszApplicationName to a path resolved application name */ 438 n = SearchPathW(NULL, pwszApplicationName, NULL, 0, NULL, NULL); 439 if (n) 440 { 441 tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR)); 442 if (!tmp_name) 443 return E_OUTOFMEMORY; 444 n = SearchPathW(NULL, pwszApplicationName, NULL, n, tmp_name, NULL); 445 if (n) 446 { 447 HeapFree(GetProcessHeap(), 0, This->applicationName); 448 This->applicationName = tmp_name; 449 return S_OK; 450 } 451 else 452 HeapFree(GetProcessHeap(), 0, tmp_name); 453 } 454 455 /* If unable to path resolve name, simply set to pwszApplicationName */ 456 n = (lstrlenW(pwszApplicationName) + 1); 457 tmp_name = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR)); 458 if (!tmp_name) 459 return E_OUTOFMEMORY; 460 lstrcpyW(tmp_name, pwszApplicationName); 461 HeapFree(GetProcessHeap(), 0, This->applicationName); 462 This->applicationName = tmp_name; 463 return S_OK; 464 } 465 466 static HRESULT WINAPI MSTASK_ITask_GetApplicationName( 467 ITask* iface, 468 LPWSTR *ppwszApplicationName) 469 { 470 DWORD n; 471 TaskImpl *This = impl_from_ITask(iface); 472 473 TRACE("(%p, %p)\n", iface, ppwszApplicationName); 474 475 n = This->applicationName ? lstrlenW(This->applicationName) + 1 : 1; 476 *ppwszApplicationName = CoTaskMemAlloc(n * sizeof(WCHAR)); 477 if (!*ppwszApplicationName) 478 return E_OUTOFMEMORY; 479 480 if (!This->applicationName) 481 *ppwszApplicationName[0] = 0; 482 else 483 lstrcpyW(*ppwszApplicationName, This->applicationName); 484 485 return S_OK; 486 } 487 488 static HRESULT WINAPI MSTASK_ITask_SetParameters( 489 ITask* iface, 490 LPCWSTR pwszParameters) 491 { 492 DWORD n; 493 TaskImpl *This = impl_from_ITask(iface); 494 LPWSTR tmp_parameters; 495 496 TRACE("(%p, %s)\n", iface, debugstr_w(pwszParameters)); 497 498 /* Empty parameter list */ 499 if (pwszParameters[0] == 0) 500 { 501 HeapFree(GetProcessHeap(), 0, This->parameters); 502 This->parameters = NULL; 503 return S_OK; 504 } 505 506 /* Set to pwszParameters */ 507 n = (lstrlenW(pwszParameters) + 1); 508 tmp_parameters = HeapAlloc(GetProcessHeap(), 0, n * sizeof(WCHAR)); 509 if (!tmp_parameters) 510 return E_OUTOFMEMORY; 511 lstrcpyW(tmp_parameters, pwszParameters); 512 HeapFree(GetProcessHeap(), 0, This->parameters); 513 This->parameters = tmp_parameters; 514 return S_OK; 515 } 516 517 static HRESULT WINAPI MSTASK_ITask_GetParameters( 518 ITask* iface, 519 LPWSTR *ppwszParameters) 520 { 521 DWORD n; 522 TaskImpl *This = impl_from_ITask(iface); 523 524 TRACE("(%p, %p)\n", iface, ppwszParameters); 525 526 n = This->parameters ? lstrlenW(This->parameters) + 1 : 1; 527 *ppwszParameters = CoTaskMemAlloc(n * sizeof(WCHAR)); 528 if (!*ppwszParameters) 529 return E_OUTOFMEMORY; 530 531 if (!This->parameters) 532 *ppwszParameters[0] = 0; 533 else 534 lstrcpyW(*ppwszParameters, This->parameters); 535 536 return S_OK; 537 } 538 539 static HRESULT WINAPI MSTASK_ITask_SetWorkingDirectory( 540 ITask* iface, 541 LPCWSTR pwszWorkingDirectory) 542 { 543 FIXME("(%p, %s): stub\n", iface, debugstr_w(pwszWorkingDirectory)); 544 return E_NOTIMPL; 545 } 546 547 static HRESULT WINAPI MSTASK_ITask_GetWorkingDirectory( 548 ITask* iface, 549 LPWSTR *ppwszWorkingDirectory) 550 { 551 FIXME("(%p, %p): stub\n", iface, ppwszWorkingDirectory); 552 return E_NOTIMPL; 553 } 554 555 static HRESULT WINAPI MSTASK_ITask_SetPriority( 556 ITask* iface, 557 DWORD dwPriority) 558 { 559 FIXME("(%p, 0x%08x): stub\n", iface, dwPriority); 560 return E_NOTIMPL; 561 } 562 563 static HRESULT WINAPI MSTASK_ITask_GetPriority( 564 ITask* iface, 565 DWORD *pdwPriority) 566 { 567 FIXME("(%p, %p): stub\n", iface, pdwPriority); 568 return E_NOTIMPL; 569 } 570 571 static HRESULT WINAPI MSTASK_ITask_SetTaskFlags( 572 ITask* iface, 573 DWORD dwFlags) 574 { 575 FIXME("(%p, 0x%08x): stub\n", iface, dwFlags); 576 return E_NOTIMPL; 577 } 578 579 static HRESULT WINAPI MSTASK_ITask_GetTaskFlags( 580 ITask* iface, 581 DWORD *pdwFlags) 582 { 583 FIXME("(%p, %p): stub\n", iface, pdwFlags); 584 return E_NOTIMPL; 585 } 586 587 static HRESULT WINAPI MSTASK_ITask_SetMaxRunTime( 588 ITask* iface, 589 DWORD dwMaxRunTime) 590 { 591 TaskImpl *This = impl_from_ITask(iface); 592 593 TRACE("(%p, %d)\n", iface, dwMaxRunTime); 594 595 This->maxRunTime = dwMaxRunTime; 596 return S_OK; 597 } 598 599 static HRESULT WINAPI MSTASK_ITask_GetMaxRunTime( 600 ITask* iface, 601 DWORD *pdwMaxRunTime) 602 { 603 TaskImpl *This = impl_from_ITask(iface); 604 605 TRACE("(%p, %p)\n", iface, pdwMaxRunTime); 606 607 *pdwMaxRunTime = This->maxRunTime; 608 return S_OK; 609 } 610 611 static HRESULT WINAPI MSTASK_IPersistFile_QueryInterface( 612 IPersistFile* iface, 613 REFIID riid, 614 void **ppvObject) 615 { 616 TaskImpl *This = impl_from_IPersistFile(iface); 617 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppvObject); 618 return ITask_QueryInterface(&This->ITask_iface, riid, ppvObject); 619 } 620 621 static ULONG WINAPI MSTASK_IPersistFile_AddRef( 622 IPersistFile* iface) 623 { 624 TaskImpl *This = impl_from_IPersistFile(iface); 625 ULONG ref; 626 TRACE("\n"); 627 ref = InterlockedIncrement(&This->ref); 628 return ref; 629 } 630 631 static ULONG WINAPI MSTASK_IPersistFile_Release( 632 IPersistFile* iface) 633 { 634 TaskImpl *This = impl_from_IPersistFile(iface); 635 ULONG ref; 636 TRACE("\n"); 637 ref = InterlockedDecrement(&This->ref); 638 if (ref == 0) 639 TaskDestructor(This); 640 return ref; 641 } 642 643 static HRESULT WINAPI MSTASK_IPersistFile_GetClassID( 644 IPersistFile* iface, 645 CLSID *pClassID) 646 { 647 FIXME("(%p, %p): stub\n", iface, pClassID); 648 return E_NOTIMPL; 649 } 650 651 static HRESULT WINAPI MSTASK_IPersistFile_IsDirty( 652 IPersistFile* iface) 653 { 654 FIXME("(%p): stub\n", iface); 655 return E_NOTIMPL; 656 } 657 658 static HRESULT WINAPI MSTASK_IPersistFile_Load( 659 IPersistFile* iface, 660 LPCOLESTR pszFileName, 661 DWORD dwMode) 662 { 663 FIXME("(%p, %p, 0x%08x): stub\n", iface, pszFileName, dwMode); 664 return E_NOTIMPL; 665 } 666 667 static HRESULT WINAPI MSTASK_IPersistFile_Save( 668 IPersistFile* iface, 669 LPCOLESTR pszFileName, 670 BOOL fRemember) 671 { 672 FIXME("(%p, %p, %d): stub\n", iface, pszFileName, fRemember); 673 WARN("Returning S_OK but not writing to disk: %s %d\n", 674 debugstr_w(pszFileName), fRemember); 675 return S_OK; 676 } 677 678 static HRESULT WINAPI MSTASK_IPersistFile_SaveCompleted( 679 IPersistFile* iface, 680 LPCOLESTR pszFileName) 681 { 682 FIXME("(%p, %p): stub\n", iface, pszFileName); 683 return E_NOTIMPL; 684 } 685 686 static HRESULT WINAPI MSTASK_IPersistFile_GetCurFile( 687 IPersistFile* iface, 688 LPOLESTR *ppszFileName) 689 { 690 FIXME("(%p, %p): stub\n", iface, ppszFileName); 691 return E_NOTIMPL; 692 } 693 694 695 static const ITaskVtbl MSTASK_ITaskVtbl = 696 { 697 MSTASK_ITask_QueryInterface, 698 MSTASK_ITask_AddRef, 699 MSTASK_ITask_Release, 700 MSTASK_ITask_CreateTrigger, 701 MSTASK_ITask_DeleteTrigger, 702 MSTASK_ITask_GetTriggerCount, 703 MSTASK_ITask_GetTrigger, 704 MSTASK_ITask_GetTriggerString, 705 MSTASK_ITask_GetRunTimes, 706 MSTASK_ITask_GetNextRunTime, 707 MSTASK_ITask_SetIdleWait, 708 MSTASK_ITask_GetIdleWait, 709 MSTASK_ITask_Run, 710 MSTASK_ITask_Terminate, 711 MSTASK_ITask_EditWorkItem, 712 MSTASK_ITask_GetMostRecentRunTime, 713 MSTASK_ITask_GetStatus, 714 MSTASK_ITask_GetExitCode, 715 MSTASK_ITask_SetComment, 716 MSTASK_ITask_GetComment, 717 MSTASK_ITask_SetCreator, 718 MSTASK_ITask_GetCreator, 719 MSTASK_ITask_SetWorkItemData, 720 MSTASK_ITask_GetWorkItemData, 721 MSTASK_ITask_SetErrorRetryCount, 722 MSTASK_ITask_GetErrorRetryCount, 723 MSTASK_ITask_SetErrorRetryInterval, 724 MSTASK_ITask_GetErrorRetryInterval, 725 MSTASK_ITask_SetFlags, 726 MSTASK_ITask_GetFlags, 727 MSTASK_ITask_SetAccountInformation, 728 MSTASK_ITask_GetAccountInformation, 729 MSTASK_ITask_SetApplicationName, 730 MSTASK_ITask_GetApplicationName, 731 MSTASK_ITask_SetParameters, 732 MSTASK_ITask_GetParameters, 733 MSTASK_ITask_SetWorkingDirectory, 734 MSTASK_ITask_GetWorkingDirectory, 735 MSTASK_ITask_SetPriority, 736 MSTASK_ITask_GetPriority, 737 MSTASK_ITask_SetTaskFlags, 738 MSTASK_ITask_GetTaskFlags, 739 MSTASK_ITask_SetMaxRunTime, 740 MSTASK_ITask_GetMaxRunTime 741 }; 742 743 static const IPersistFileVtbl MSTASK_IPersistFileVtbl = 744 { 745 MSTASK_IPersistFile_QueryInterface, 746 MSTASK_IPersistFile_AddRef, 747 MSTASK_IPersistFile_Release, 748 MSTASK_IPersistFile_GetClassID, 749 MSTASK_IPersistFile_IsDirty, 750 MSTASK_IPersistFile_Load, 751 MSTASK_IPersistFile_Save, 752 MSTASK_IPersistFile_SaveCompleted, 753 MSTASK_IPersistFile_GetCurFile 754 }; 755 756 HRESULT TaskConstructor(LPCWSTR pwszTaskName, LPVOID *ppObj) 757 { 758 TaskImpl *This; 759 int n; 760 761 TRACE("(%s, %p)\n", debugstr_w(pwszTaskName), ppObj); 762 763 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); 764 if (!This) 765 return E_OUTOFMEMORY; 766 767 This->ITask_iface.lpVtbl = &MSTASK_ITaskVtbl; 768 This->IPersistFile_iface.lpVtbl = &MSTASK_IPersistFileVtbl; 769 This->ref = 1; 770 n = (lstrlenW(pwszTaskName) + 1) * sizeof(WCHAR); 771 This->taskName = HeapAlloc(GetProcessHeap(), 0, n); 772 if (!This->taskName) 773 { 774 HeapFree(GetProcessHeap(), 0, This); 775 return E_OUTOFMEMORY; 776 } 777 lstrcpyW(This->taskName, pwszTaskName); 778 This->applicationName = NULL; 779 This->parameters = NULL; 780 This->comment = NULL; 781 This->accountName = NULL; 782 783 /* Default time is 3 days = 259200000 ms */ 784 This->maxRunTime = 259200000; 785 786 *ppObj = &This->ITask_iface; 787 InterlockedIncrement(&dll_ref); 788 return S_OK; 789 } 790