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.

189 lines
4.9 KiB

  1. // InternetPropertyPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "olecnfg.h"
  5. #include "inetppg.h"
  6. #include "util.h"
  7. #include <tchar.h>
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CInternetPropertyPage property page
  15. IMPLEMENT_DYNCREATE(CInternetPropertyPage, CPropertyPage)
  16. CInternetPropertyPage::CInternetPropertyPage() : CPropertyPage(CInternetPropertyPage::IDD)
  17. {
  18. //{{AFX_DATA_INIT(CInternetPropertyPage)
  19. m_bAllowAccess = FALSE;
  20. m_bAllowInternet = FALSE;
  21. m_bAllowLaunch = FALSE;
  22. //}}AFX_DATA_INIT
  23. m_bAllowInternet = m_bAllowLaunch = m_bAllowAccess = FALSE;
  24. m_bCanModify = TRUE;
  25. }
  26. CInternetPropertyPage::~CInternetPropertyPage()
  27. {
  28. }
  29. void PASCAL DDX_Enable(CDataExchange* pDX, int nIDC, BOOL bEnable)
  30. {
  31. HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
  32. :: EnableWindow(hWndCtrl,bEnable);
  33. }
  34. void CInternetPropertyPage::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CPropertyPage::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CInternetPropertyPage)
  38. DDX_Control(pDX, IDC_ALLOWLAUNCH, m_chkLaunch);
  39. DDX_Control(pDX, IDC_ALLOWINTERNET, m_chkInternet);
  40. DDX_Control(pDX, IDC_ALLOWACCESS, m_chkAccess);
  41. DDX_Check(pDX, IDC_ALLOWACCESS, m_bAllowAccess);
  42. DDX_Check(pDX, IDC_ALLOWINTERNET, m_bAllowInternet);
  43. DDX_Check(pDX, IDC_ALLOWLAUNCH, m_bAllowLaunch);
  44. //}}AFX_DATA_MAP
  45. DDX_Enable(pDX, IDC_ALLOWLAUNCH, m_bAllowInternet);
  46. DDX_Enable(pDX, IDC_ALLOWACCESS, m_bAllowInternet);
  47. }
  48. BEGIN_MESSAGE_MAP(CInternetPropertyPage, CPropertyPage)
  49. //{{AFX_MSG_MAP(CInternetPropertyPage)
  50. ON_BN_CLICKED(IDC_ALLOWINTERNET, OnAllowInternet)
  51. ON_BN_CLICKED(IDC_ALLOWACCESS, OnAllowaccess)
  52. ON_BN_CLICKED(IDC_ALLOWLAUNCH, OnAllowlaunch)
  53. ON_WM_HELPINFO()
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CInternetPropertyPage message handlers
  58. //+-------------------------------------------------------------------------
  59. //
  60. // Member: CInternetPropertyPage::InitData
  61. //
  62. // Synopsis: Method to initialise options
  63. //
  64. // Arguments: None
  65. //
  66. // Returns: Nothing
  67. //
  68. // Algorithm: N/A
  69. //
  70. // History: 02-Dec-96 Ronans Created
  71. //
  72. //--------------------------------------------------------------------------
  73. void CInternetPropertyPage::InitData(CString AppName, HKEY hkAppID)
  74. {
  75. // read internet permissions data from the registry
  76. ASSERT(hkAppID != NULL);
  77. TCHAR szInternetPermission[128];
  78. DWORD dwBufferSize = 128 * sizeof(TCHAR);
  79. DWORD dwType = REG_SZ;
  80. LONG lErr = RegQueryValueEx(hkAppID,
  81. TEXT("DcomHttpPermission"),
  82. 0,
  83. &dwType,
  84. (LPBYTE)szInternetPermission,
  85. &dwBufferSize);
  86. if (lErr == ERROR_SUCCESS)
  87. {
  88. if (dwBufferSize != 0)
  89. {
  90. TCHAR *pszToken = _tcstok(szInternetPermission, TEXT(" "));
  91. // parse retrieved value
  92. while (pszToken != NULL)
  93. {
  94. if (_tcsicmp(pszToken, TEXT("LAUNCH")) == 0)
  95. {
  96. m_bAllowLaunch = TRUE;
  97. m_bAllowInternet = TRUE;
  98. }
  99. else if (_tcsicmp(pszToken, TEXT("ACCESS")) == 0)
  100. {
  101. m_bAllowAccess = TRUE;
  102. m_bAllowInternet = TRUE;
  103. }
  104. else if (_tcsicmp(pszToken, TEXT("NONE")) == 0)
  105. {
  106. m_bAllowAccess = FALSE;
  107. m_bAllowInternet = FALSE;
  108. m_bAllowInternet = FALSE;
  109. }
  110. pszToken = _tcstok(NULL, TEXT(" "));
  111. }
  112. }
  113. }
  114. else
  115. // nt 4.0 returns ERROR_FILE_NOT_FOUND if no value is found
  116. if ((lErr != ERROR_SUCCESS) && (lErr != ERROR_FILE_NOT_FOUND))
  117. {
  118. m_bCanModify = FALSE;
  119. g_util.PostErrorMessage();
  120. }
  121. SetModified(FALSE);
  122. m_bChanged = FALSE;
  123. }
  124. void CInternetPropertyPage::OnAllowInternet()
  125. {
  126. m_bChanged = TRUE;
  127. UpdateData(TRUE);
  128. SetModified(TRUE);
  129. }
  130. void CInternetPropertyPage::OnAllowaccess()
  131. {
  132. m_bChanged = TRUE;
  133. UpdateData(TRUE);
  134. SetModified(TRUE);
  135. }
  136. void CInternetPropertyPage::OnAllowlaunch()
  137. {
  138. m_bChanged = TRUE;
  139. UpdateData(TRUE);
  140. SetModified(TRUE);
  141. }
  142. BOOL CInternetPropertyPage::OnHelpInfo(HELPINFO* pHelpInfo)
  143. {
  144. /*
  145. if(-1 != pHelpInfo->iCtrlId)
  146. {
  147. WORD hiWord = 0x8000 | CGeneralPropertyPage::IDD;
  148. WORD loWord = pHelpInfo->iCtrlId;
  149. DWORD dwLong = MAKELONG(loWord,hiWord);
  150. WinHelp(dwLong, HELP_CONTEXTPOPUP);
  151. return TRUE;
  152. }
  153. else
  154. */
  155. {
  156. return CPropertyPage::OnHelpInfo(pHelpInfo);
  157. }
  158. }