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.

160 lines
4.8 KiB

  1. // DlgProviders.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ConfigTest.h"
  5. #include "DlgProviders.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. typedef unsigned long ULONG_PTR, *PULONG_PTR;
  12. typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
  13. #include "..\..\..\inc\fxsapip.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CDlgProviders dialog
  16. CDlgProviders::CDlgProviders(HANDLE hFax, CWnd* pParent /*=NULL*/)
  17. : CDialog(CDlgProviders::IDD, pParent), m_hFax (hFax)
  18. {
  19. //{{AFX_DATA_INIT(CDlgProviders)
  20. m_cstrNumProviders = _T("0");
  21. //}}AFX_DATA_INIT
  22. }
  23. void CDlgProviders::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CDlgProviders)
  27. DDX_Control(pDX, IDC_FSPS, m_lstFSPs);
  28. DDX_Text(pDX, IDC_NUMFSP, m_cstrNumProviders);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CDlgProviders, CDialog)
  32. //{{AFX_MSG_MAP(CDlgProviders)
  33. ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CDlgProviders message handlers
  38. void CDlgProviders::OnRefresh()
  39. {
  40. PFAX_DEVICE_PROVIDER_INFO pFSPs;
  41. DWORD dwNumFSPs;
  42. CString cs;
  43. m_lstFSPs.DeleteAllItems();
  44. if (!FaxEnumerateProviders (m_hFax, &pFSPs, &dwNumFSPs))
  45. {
  46. CString cs;
  47. cs.Format ("Failed while calling FaxEnumerateProviders (%ld)", GetLastError());
  48. AfxMessageBox (cs, MB_OK | MB_ICONHAND);
  49. return;
  50. }
  51. for (DWORD dw = 0; dw < dwNumFSPs; dw++)
  52. {
  53. int iIndex = m_lstFSPs.InsertItem (0, pFSPs[dw].lpctstrFriendlyName);
  54. m_lstFSPs.SetItemText (iIndex, 1, pFSPs[dw].lpctstrImageName);
  55. m_lstFSPs.SetItemText (iIndex, 2, pFSPs[dw].lpctstrProviderName);
  56. m_lstFSPs.SetItemText (iIndex, 3, pFSPs[dw].lpctstrGUID);
  57. cs.Format ("%08x", pFSPs[dw].dwCapabilities);
  58. m_lstFSPs.SetItemText (iIndex, 4, cs);
  59. if (pFSPs[dw].Version.bValid)
  60. {
  61. //
  62. // Version info exists
  63. //
  64. cs.Format ("%ld.%ld.%ld.%ld (%s)",
  65. pFSPs[dw].Version.wMajorVersion,
  66. pFSPs[dw].Version.wMinorVersion,
  67. pFSPs[dw].Version.wMajorBuildNumber,
  68. pFSPs[dw].Version.wMinorBuildNumber,
  69. (pFSPs[dw].Version.dwFlags & FAX_VER_FLAG_CHECKED) ? "checked" : "free");
  70. }
  71. else
  72. {
  73. cs = "<no version data>";
  74. }
  75. m_lstFSPs.SetItemText (iIndex, 5, cs);
  76. switch (pFSPs[dw].Status)
  77. {
  78. case FAX_PROVIDER_STATUS_SUCCESS:
  79. cs = "Success";
  80. break;
  81. case FAX_PROVIDER_STATUS_BAD_GUID:
  82. cs = "Bad GUID";
  83. break;
  84. case FAX_PROVIDER_STATUS_BAD_VERSION:
  85. cs = "Bad API version";
  86. break;
  87. case FAX_PROVIDER_STATUS_SERVER_ERROR:
  88. cs = "Internal server error";
  89. break;
  90. case FAX_PROVIDER_STATUS_CANT_LOAD:
  91. cs = "Can't load";
  92. break;
  93. case FAX_PROVIDER_STATUS_CANT_LINK:
  94. cs = "Can't link";
  95. break;
  96. case FAX_PROVIDER_STATUS_CANT_INIT:
  97. cs = "Can't init";
  98. break;
  99. default:
  100. ASSERT (FALSE);
  101. break;
  102. }
  103. m_lstFSPs.SetItemText (iIndex, 6, cs);
  104. cs.Format ("%ld", pFSPs[dw].dwLastError);
  105. m_lstFSPs.SetItemText (iIndex, 7, cs);
  106. }
  107. m_cstrNumProviders.Format ("%ld", dwNumFSPs);
  108. UpdateData (FALSE);
  109. FaxFreeBuffer (LPVOID(pFSPs));
  110. }
  111. BOOL CDlgProviders::OnInitDialog()
  112. {
  113. CDialog::OnInitDialog();
  114. m_lstFSPs.InsertColumn (0, "Friendly name");
  115. m_lstFSPs.InsertColumn (1, "Image name");
  116. m_lstFSPs.InsertColumn (2, "Provider name");
  117. m_lstFSPs.InsertColumn (3, "GUID");
  118. m_lstFSPs.InsertColumn (4, "Capabilities");
  119. m_lstFSPs.InsertColumn (5, "Version");
  120. m_lstFSPs.InsertColumn (6, "Load status");
  121. m_lstFSPs.InsertColumn (7, "Load error code");
  122. CHeaderCtrl* pHeader = (CHeaderCtrl*)m_lstFSPs.GetDlgItem(0);
  123. DWORD dwCount = pHeader->GetItemCount();
  124. for (DWORD col = 0; col <= dwCount; col++)
  125. {
  126. m_lstFSPs.SetColumnWidth(col, LVSCW_AUTOSIZE);
  127. int wc1 = m_lstFSPs.GetColumnWidth(col);
  128. m_lstFSPs.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
  129. int wc2 = m_lstFSPs.GetColumnWidth(col);
  130. int wc = max(20,max(wc1,wc2));
  131. m_lstFSPs.SetColumnWidth(col,wc);
  132. }
  133. OnRefresh();
  134. return TRUE; // return TRUE unless you set the focus to a control
  135. // EXCEPTION: OCX Property Pages should return FALSE
  136. }