Leaked source code of windows server 2003
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.

150 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. async.c
  5. Abstract:
  6. Functions for asynch send wizard actions
  7. Environment:
  8. Windows XP fax driver user interface
  9. Revision History:
  10. 02/05/96 -davidx-
  11. Created it.
  12. mm/dd/yy -author-
  13. description
  14. --*/
  15. #include "faxui.h"
  16. #include "tapiutil.h"
  17. #include "faxsendw.h"
  18. DWORD
  19. AsyncWizardThread(
  20. PBYTE param
  21. )
  22. /*++
  23. Routine Description:
  24. Do some agonizingly slow tasks asynchronously so the wizard seems faster to the user.
  25. Arguments:
  26. none.
  27. Return Value:
  28. not used.
  29. --*/
  30. {
  31. PWIZARDUSERMEM pWizardUserMem = (PWIZARDUSERMEM) param;
  32. HANDLE FaxHandle = NULL;
  33. PFAX_TAPI_LINECOUNTRY_LIST pLineCountryList = NULL;
  34. DWORD dwRights = 0;
  35. DWORD dwFaxQueueState = 0;
  36. DWORD dwRecipientsLimit = 0; // default to no limit (backwards compatibility).
  37. Assert(pWizardUserMem);
  38. InitTapi ();
  39. if (!SetEvent(pWizardUserMem->hTAPIEvent))
  40. {
  41. Error(("Can't set hTAPIEvent. ec = 0x%X", GetLastError()));
  42. }
  43. if (FaxConnectFaxServer(pWizardUserMem->lptstrServerName,&FaxHandle))
  44. {
  45. if (!FaxAccessCheckEx (FaxHandle, MAXIMUM_ALLOWED, &dwRights))
  46. {
  47. dwRights = 0;
  48. Error(("FaxAccessCheckEx: failed. ec = 0X%x\n",GetLastError()));
  49. }
  50. pWizardUserMem->dwRights = dwRights;
  51. pWizardUserMem->dwSupportedReceipts = 0;
  52. if(!FaxGetReceiptsOptions(FaxHandle, &pWizardUserMem->dwSupportedReceipts))
  53. {
  54. Error(("FaxGetReceiptsOptions: failed. ec = 0X%x\n",GetLastError()));
  55. }
  56. if (!FaxGetQueueStates(FaxHandle,&dwFaxQueueState) )
  57. {
  58. dwFaxQueueState = 0;
  59. Error(("FaxGetQueueStates: failed. ec = 0X%x\n",GetLastError()));
  60. }
  61. pWizardUserMem->dwQueueStates = dwFaxQueueState;
  62. if (!FaxGetRecipientsLimit(FaxHandle,&dwRecipientsLimit) )
  63. {
  64. Error(("dwRecipientsLimit: failed. ec = 0X%x\n",GetLastError()));
  65. }
  66. pWizardUserMem->dwRecipientsLimit = dwRecipientsLimit;
  67. if (!FaxGetCountryList(FaxHandle,&pLineCountryList))
  68. {
  69. Verbose(("Can't get a country list from the server %s",
  70. pWizardUserMem->lptstrServerName));
  71. }
  72. else
  73. {
  74. Assert(pWizardUserMem->pCountryList==NULL);
  75. pWizardUserMem->pCountryList = pLineCountryList;
  76. }
  77. if (FaxHandle)
  78. {
  79. if (!FaxClose(FaxHandle))
  80. {
  81. Verbose(("Can't close the fax handle %x",FaxHandle));
  82. }
  83. }
  84. }
  85. else
  86. {
  87. Verbose(("Can't connect to the fax server %s",pWizardUserMem->lptstrServerName));
  88. }
  89. if (!SetEvent(pWizardUserMem->hCountryListEvent))
  90. {
  91. Error(("Can't set hCountryListEvent. ec = 0x%X",GetLastError()));
  92. }
  93. //
  94. // use server coverpages (may startup fax service, which is slow)
  95. //
  96. pWizardUserMem->ServerCPOnly = UseServerCp(pWizardUserMem->lptstrServerName);
  97. if (!SetEvent(pWizardUserMem->hCPEvent))
  98. {
  99. Error(("Can't set hCPEvent. ec = 0x%X",GetLastError()));
  100. }
  101. #ifdef FAX_SCAN_ENABLED
  102. //
  103. // look for twain stuff
  104. //
  105. if (!(pWizardUserMem->dwFlags & FSW_USE_SCANNER) ){
  106. pWizardUserMem->TwainAvail = FALSE;
  107. } else {
  108. pWizardUserMem->TwainAvail = InitializeTwain(pWizardUserMem);
  109. }
  110. if (!SetEvent(pWizardUserMem->hTwainEvent))
  111. {
  112. Error(("Can't set hTwainEvent. ec = 0x%X",GetLastError()));
  113. }
  114. #endif // FAX_SCAN_ENABLED
  115. return ERROR_SUCCESS;
  116. }