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
4.4 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997 Active Voice Corporation. All Rights Reserved.
  4. //
  5. // Active Agent(r) and Unified Communications(tm) are trademarks of Active Voice Corporation.
  6. //
  7. // Other brand and product names used herein are trademarks of their respective owners.
  8. //
  9. // The entire program and user interface including the structure, sequence, selection,
  10. // and arrangement of the dialog, the exclusively "yes" and "no" choices represented
  11. // by "1" and "2," and each dialog message are protected by copyrights registered in
  12. // the United States and by international treaties.
  13. //
  14. // Protected by one or more of the following United States patents: 5,070,526, 5,488,650,
  15. // 5,434,906, 5,581,604, 5,533,102, 5,568,540, 5,625,676, 5,651,054.
  16. //
  17. // Active Voice Corporation
  18. // Seattle, Washington
  19. // USA
  20. //
  21. /////////////////////////////////////////////////////////////////////////////////////////
  22. // DlgAddConfServer.cpp : Implementation of CDlgAddConfServer
  23. #include "stdafx.h"
  24. #include "TapiDialer.h"
  25. #include "AVTapi.h"
  26. #include "DlgAddCSvr.h"
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CDlgAddConfServer
  29. IMPLEMENT_MY_HELP(CDlgAddConfServer)
  30. CDlgAddConfServer::CDlgAddConfServer()
  31. {
  32. m_bstrLocation = m_bstrServer = NULL;
  33. }
  34. CDlgAddConfServer::~CDlgAddConfServer()
  35. {
  36. SysFreeString( m_bstrLocation );
  37. SysFreeString( m_bstrServer );
  38. }
  39. void CDlgAddConfServer::UpdateData( bool bSaveAndValidate )
  40. {
  41. USES_CONVERSION;
  42. if ( bSaveAndValidate )
  43. {
  44. // Retrieve data
  45. SysFreeString( m_bstrServer );
  46. GetDlgItemText( IDC_EDT_NAME, m_bstrServer );
  47. }
  48. else
  49. {
  50. LoadDefaultServers( GetDlgItem(IDC_EDT_NAME) );
  51. // Set any default text the author specified, otherwise select the first item in
  52. // the list box
  53. if ( m_bstrServer && SysStringLen(m_bstrServer) )
  54. {
  55. SetDlgItemText( IDC_EDT_NAME, OLE2CT(m_bstrServer) );
  56. }
  57. else if ( SendDlgItemMessage(IDC_EDT_NAME, CB_GETCOUNT, 0, 0) >= 0 )
  58. {
  59. SendDlgItemMessage( IDC_EDT_NAME, CB_SETCURSEL, 0, 0 );
  60. SendDlgItemMessage( IDC_EDT_NAME, CB_SETEDITSEL, 0, MAKELPARAM(0, -1) );
  61. }
  62. ::EnableWindow( GetDlgItem(IDC_BTN_ADD_ILS_SERVER), (BOOL) (::GetWindowTextLength(GetDlgItem(IDC_EDT_NAME)) > 0) );
  63. }
  64. }
  65. LRESULT CDlgAddConfServer::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  66. {
  67. UpdateData( false );
  68. return true; // Let the system set the focus
  69. }
  70. LRESULT CDlgAddConfServer::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  71. {
  72. UpdateData( true );
  73. EndDialog(IDOK);
  74. return 0;
  75. }
  76. LRESULT CDlgAddConfServer::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  77. {
  78. EndDialog(wID);
  79. return 0;
  80. }
  81. LRESULT CDlgAddConfServer::OnEdtNameChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  82. {
  83. ::EnableWindow( GetDlgItem(IDC_BTN_ADD_ILS_SERVER), (BOOL) (::GetWindowTextLength(GetDlgItem(IDC_EDT_NAME)) > 0) );
  84. return 0;
  85. }
  86. void CDlgAddConfServer::LoadDefaultServers( HWND hWndList )
  87. {
  88. USES_CONVERSION;
  89. _ASSERT( hWndList );
  90. if ( !hWndList ) return;
  91. // Load the default servers into the dialog
  92. CComPtr<IAVTapi> pAVTapi;
  93. if ( SUCCEEDED(_Module.get_AVTapi(&pAVTapi)) )
  94. {
  95. IConfExplorer *pIConfExplorer;
  96. if ( SUCCEEDED(pAVTapi->get_ConfExplorer(&pIConfExplorer)) )
  97. {
  98. ITRendezvous *pITRend;
  99. if ( SUCCEEDED(pIConfExplorer->get_ITRendezvous((IUnknown **) &pITRend)) )
  100. {
  101. IEnumDirectory *pEnum = NULL;
  102. if ( SUCCEEDED(pITRend->EnumerateDefaultDirectories(&pEnum)) && pEnum )
  103. {
  104. ITDirectory *pDir = NULL;
  105. while ( (pEnum->Next(1, &pDir, NULL) == S_OK) && pDir )
  106. {
  107. // Look for ILS servers
  108. DIRECTORY_TYPE nDirType;
  109. if ( SUCCEEDED(pDir->get_DirectoryType(&nDirType)) && (nDirType == DT_ILS) )
  110. {
  111. BSTR bstrName = NULL;
  112. pDir->get_DisplayName( &bstrName );
  113. if ( bstrName && SysStringLen(bstrName) )
  114. ::SendMessage( hWndList, CB_ADDSTRING, 0, (LPARAM) OLE2CT(bstrName) );
  115. SysFreeString( bstrName );
  116. }
  117. pDir->Release();
  118. pDir = NULL;
  119. }
  120. pEnum->Release();
  121. }
  122. pITRend->Release();
  123. }
  124. pIConfExplorer->Release();
  125. }
  126. }
  127. }
  128. LRESULT CDlgAddConfServer::OnSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  129. {
  130. bHandled = false;
  131. ::EnableWindow( GetDlgItem(IDC_BTN_ADD_ILS_SERVER), true );
  132. return 0;
  133. }