Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
3.5 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. UploadManager.cpp
  5. Abstract:
  6. This file contains the initialization portion of the Upload Manager
  7. Revision History:
  8. Davide Massarenti (Dmassare) 04/15/99
  9. created
  10. ******************************************************************************/
  11. #include "stdafx.h"
  12. #include <UploadManager_i.c>
  13. HRESULT QueueJob( LPCTSTR szSigClient,
  14. LPCTSTR szServer ,
  15. LPCTSTR szProvider ,
  16. LPCTSTR szUsername ,
  17. LPCTSTR szPassword ,
  18. LPCTSTR szFilename ,
  19. BOOL escalated )
  20. {
  21. __ULT_FUNC_ENTRY( "QueueJob" );
  22. HRESULT hr;
  23. CComPtr<IMPCUpload> mpcuRoot;
  24. CComPtr<IMPCUploadJob> mpcujJob;
  25. CComBSTR bstrTmp;
  26. DWORD fFlags;
  27. UL_MODE fMode;
  28. BOOL fQueue;
  29. long lPriority;
  30. if(escalated)
  31. {
  32. fFlags = 0;
  33. fMode = UL_FOREGROUND;
  34. fQueue = FALSE;
  35. lPriority = 100;
  36. }
  37. else
  38. {
  39. fFlags = UL_KEEP_LOG;
  40. fMode = UL_BACKGROUND;
  41. fQueue = TRUE;
  42. lPriority = 0;
  43. }
  44. if(FAILED(hr = CoCreateInstance( CLSID_MPCUpload, NULL, CLSCTX_SERVER, IID_IMPCUpload, (void**)&mpcuRoot )))
  45. {
  46. __ULT_TRACE_HRESULT(hr);
  47. __ULT_FUNC_LEAVE;
  48. }
  49. if(FAILED(hr = mpcuRoot->CreateJob( &mpcujJob )))
  50. {
  51. __ULT_TRACE_HRESULT(hr);
  52. __ULT_FUNC_LEAVE;
  53. }
  54. bstrTmp = szSigClient;
  55. if(FAILED(hr = mpcujJob->put_Sig( bstrTmp )))
  56. {
  57. __ULT_TRACE_HRESULT(hr);
  58. __ULT_FUNC_LEAVE;
  59. }
  60. bstrTmp = szServer;
  61. if(FAILED(hr = mpcujJob->put_Server( bstrTmp )))
  62. {
  63. __ULT_TRACE_HRESULT(hr);
  64. __ULT_FUNC_LEAVE;
  65. }
  66. bstrTmp = szProvider;
  67. if(FAILED(hr = mpcujJob->put_ProviderID( bstrTmp )))
  68. {
  69. __ULT_TRACE_HRESULT(hr);
  70. __ULT_FUNC_LEAVE;
  71. }
  72. if(szUsername)
  73. {
  74. bstrTmp = szUsername;
  75. if(FAILED(hr = mpcujJob->put_Username( bstrTmp )))
  76. {
  77. __ULT_TRACE_HRESULT(hr);
  78. __ULT_FUNC_LEAVE;
  79. }
  80. }
  81. if(szPassword)
  82. {
  83. bstrTmp = szPassword;
  84. if(FAILED(hr = mpcujJob->put_Password( bstrTmp )))
  85. {
  86. __ULT_TRACE_HRESULT(hr);
  87. __ULT_FUNC_LEAVE;
  88. }
  89. }
  90. if(FAILED(hr = mpcujJob->put_Flags( fFlags )))
  91. {
  92. __ULT_TRACE_HRESULT(hr);
  93. __ULT_FUNC_LEAVE;
  94. }
  95. if(FAILED(hr = mpcujJob->put_Mode( fMode )))
  96. {
  97. __ULT_TRACE_HRESULT(hr);
  98. __ULT_FUNC_LEAVE;
  99. }
  100. if(FAILED(hr = mpcujJob->put_Queue( fQueue )))
  101. {
  102. __ULT_TRACE_HRESULT(hr);
  103. __ULT_FUNC_LEAVE;
  104. }
  105. if(FAILED(hr = mpcujJob->put_Priority( lPriority )))
  106. {
  107. __ULT_TRACE_HRESULT(hr);
  108. __ULT_FUNC_LEAVE;
  109. }
  110. bstrTmp = szFilename;
  111. if(FAILED(hr = mpcujJob->GetDataFromFile( bstrTmp )))
  112. {
  113. __ULT_TRACE_HRESULT(hr);
  114. __ULT_FUNC_LEAVE;
  115. }
  116. if(FAILED(hr = mpcujJob->ActivateAsync()))
  117. {
  118. __ULT_TRACE_HRESULT(hr);
  119. __ULT_FUNC_LEAVE;
  120. }
  121. __ULT_FUNC_CLEANUP;
  122. __ULT_FUNC_EXIT(hr);
  123. }
  124. /////////////////////////////////////////////////////////////////////////////
  125. //
  126. extern "C" int WINAPI _tWinMain( HINSTANCE hInstance ,
  127. HINSTANCE hPrevInstance ,
  128. LPTSTR lpCmdLine ,
  129. int nShowCmd )
  130. {
  131. int nRet = 0;
  132. lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT
  133. #if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
  134. HRESULT hRes = CoInitializeEx( NULL, COINIT_MULTITHREADED );
  135. #else
  136. HRESULT hRes = CoInitialize( NULL );
  137. #endif
  138. _ASSERTE( SUCCEEDED(hRes) );
  139. CoUninitialize();
  140. return nRet;
  141. }