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.

219 lines
6.5 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  2. // AdminDlg.cpp : implementation file
  3. //
  4. #include "stdafx.h"
  5. #include "override.h"
  6. #include "COptDlg.h"
  7. #include "resource.hm"
  8. extern DWORD g_helpIDArray[][2];
  9. extern int g_helpIDArraySize;
  10. /////////////////////////////////////////////////////////////////////////////
  11. // COverrideDlg dialog
  12. COverrideDlg::COverrideDlg(IMSWebDVD* pDvd)
  13. {
  14. m_pDvd = pDvd;
  15. }
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CAdminDlg message handlers
  18. LRESULT COverrideDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  19. {
  20. HWND ctlAdminPasswd = GetDlgItem(IDC_EDIT_PASSWORD);
  21. ::SendMessage(ctlAdminPasswd, EM_LIMITTEXT, MAX_PASSWD, 0);
  22. HWND staticRateHigh = GetDlgItem(IDC_STATIC_RATE_HIGH);
  23. long lPlayerLevel = -1;
  24. HRESULT hr = m_pDvd->GetPlayerParentalLevel(&lPlayerLevel);
  25. if (SUCCEEDED(hr)) {
  26. TCHAR strRateHigh[MAX_PATH];
  27. LPTSTR strRateHighTmp = LoadStringFromRes(IDS_INI_RATE_HIGH);
  28. LPTSTR strPlayerLevel = NULL;
  29. switch (lPlayerLevel) {
  30. case LEVEL_G:
  31. strPlayerLevel = LoadStringFromRes(IDS_INI_RATE_G);
  32. break;
  33. case LEVEL_PG:
  34. strPlayerLevel = LoadStringFromRes(IDS_INI_RATE_PG);
  35. break;
  36. case LEVEL_PG13:
  37. strPlayerLevel = LoadStringFromRes(IDS_INI_RATE_PG13);
  38. break;
  39. case LEVEL_R:
  40. strPlayerLevel = LoadStringFromRes(IDS_INI_RATE_R);
  41. break;
  42. default:
  43. strPlayerLevel = LoadStringFromRes(IDS_INI_RATE_ADULT);
  44. break;
  45. }
  46. wsprintf(strRateHigh, strRateHighTmp, strPlayerLevel);
  47. delete[] strRateHighTmp;
  48. delete[] strPlayerLevel;
  49. ::SetWindowText(staticRateHigh, strRateHigh);
  50. }
  51. HWND ctlList = GetDlgItem(IDC_COMBO_RATE);
  52. if (m_reason == PG_OVERRIDE_CONTENT) {
  53. ::EnableWindow(ctlList, FALSE);
  54. }
  55. else if (m_reason == PG_OVERRIDE_DVDNAV) {
  56. #if 0
  57. long contentLevels;
  58. HRESULT hr = m_pDvd->GetTitleParentalLevels(1, &contentLevels);
  59. if (SUCCEEDED(hr)) {
  60. lPlayerLevel = GetPlayerLevelRequired(contentLevels);
  61. }
  62. else
  63. #endif
  64. {
  65. lPlayerLevel = LEVEL_ADULT;
  66. }
  67. }
  68. COptionsDlg::pg_InitRateList(ctlList, lPlayerLevel);
  69. return TRUE;
  70. }
  71. LRESULT COverrideDlg::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  72. {
  73. USES_CONVERSION;
  74. if (!m_pDvd)
  75. return 0;
  76. HWND ctlPassword = GetDlgItem(IDC_EDIT_PASSWORD);
  77. TCHAR szPassword[MAX_PASSWD];
  78. ::GetWindowText(ctlPassword, szPassword, MAX_PASSWD);
  79. HRESULT hr = S_OK;
  80. if (m_reason == PG_OVERRIDE_CONTENT) {
  81. hr = m_pDvd->AcceptParentalLevelChange(VARIANT_TRUE, NULL, T2OLE(szPassword));
  82. if (hr == E_ACCESSDENIED){
  83. DVDMessageBox(m_hWnd, IDS_PASSWORD_INCORRECT);
  84. ::SetWindowText(ctlPassword, _T(""));
  85. ::SetFocus(ctlPassword);
  86. return 1;
  87. }
  88. }
  89. else if (m_reason == PG_OVERRIDE_DVDNAV) {
  90. HWND ctlList = GetDlgItem(IDC_COMBO_RATE);
  91. long level = (long) ::SendMessage(ctlList, CB_GETCURSEL, 0, 0) ;
  92. TCHAR szRate[MAX_RATE];
  93. ::SendMessage(ctlList, CB_GETLBTEXT, level, (LPARAM)szRate);
  94. // Setting the player level without saving in the ini file
  95. m_pDvd->Stop();
  96. HRESULT hr = m_pDvd->SelectParentalLevel(COptionsDlg::pg_GetLevel(szRate), NULL, T2OLE(szPassword));
  97. if (hr == E_ACCESSDENIED){
  98. DVDMessageBox(m_hWnd, IDS_PASSWORD_INCORRECT);
  99. ::SetWindowText(ctlPassword, _T(""));
  100. ::SetFocus(ctlPassword);
  101. return hr;
  102. }
  103. if (FAILED(hr)) {
  104. ::SetWindowText(ctlPassword, _T(""));
  105. ::SetFocus(ctlPassword);
  106. DVDMessageBox(m_hWnd, IDS_RATE_CHANGE_FAIL);
  107. return hr;
  108. }
  109. m_pDvd->Play();
  110. }
  111. EndDialog(wID);
  112. return 0;
  113. }
  114. /*************************************************************/
  115. /* Name: OnHelp
  116. /* Description: Display help message for a control
  117. /*************************************************************/
  118. LRESULT COverrideDlg::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  119. {
  120. HELPINFO *lphi = (LPHELPINFO) lParam;
  121. HWND hwnd = (HWND) lphi->hItemHandle;
  122. DWORD_PTR contextId = lphi->dwContextId;
  123. if (contextId != 0) {
  124. if (contextId >= HIDOK)
  125. ::WinHelp(m_hWnd, TEXT("windows.hlp"), HELP_CONTEXTPOPUP, contextId);
  126. else
  127. ::WinHelp(m_hWnd, TEXT("dvdplay.hlp"), HELP_CONTEXTPOPUP, contextId);
  128. }
  129. return 0;
  130. }
  131. /*************************************************************/
  132. /* Name: OnContextMenu
  133. /* Description: Display help message for a control
  134. /*************************************************************/
  135. LRESULT COverrideDlg::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  136. {
  137. bHandled = TRUE;
  138. HWND hwnd = (HWND) wParam;
  139. DWORD controlId = ::GetDlgCtrlID(hwnd);
  140. POINT pt;
  141. pt.x = GET_X_LPARAM(lParam);
  142. pt.y = GET_Y_LPARAM(lParam);
  143. if (controlId == 0) {
  144. ::ScreenToClient(hwnd, &pt);
  145. hwnd = ::ChildWindowFromPoint(hwnd, pt);
  146. controlId = ::GetDlgCtrlID(hwnd);
  147. }
  148. for (int i=0; i<g_helpIDArraySize; i++) {
  149. if (controlId && controlId == g_helpIDArray[i][0]) {
  150. if (controlId <= IDC_APPLY)
  151. ::WinHelp(hwnd, TEXT("windows.hlp"), HELP_CONTEXTMENU, (DWORD_PTR)g_helpIDArray);
  152. else
  153. ::WinHelp(hwnd, TEXT("dvdplay.hlp"), HELP_CONTEXTMENU, (DWORD_PTR)g_helpIDArray);
  154. }
  155. }
  156. return 0;
  157. }
  158. LRESULT COverrideDlg::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  159. {
  160. if (m_pDvd)
  161. m_pDvd->AcceptParentalLevelChange(VARIANT_FALSE, NULL, L"");
  162. EndDialog(wID);
  163. DVDMessageBox(m_hWnd, IDS_RATE_TOO_LOW, NULL, MB_OK|MB_HELP);
  164. return 0;
  165. }
  166. long COverrideDlg::GetPlayerLevelRequired(long contentLevels)
  167. {
  168. if (contentLevels & DVD_PARENTAL_LEVEL_8)
  169. return LEVEL_ADULT;
  170. else if (contentLevels & DVD_PARENTAL_LEVEL_7)
  171. return LEVEL_NC17;
  172. else if (contentLevels & DVD_PARENTAL_LEVEL_6)
  173. return LEVEL_R;
  174. else if (contentLevels & DVD_PARENTAL_LEVEL_5)
  175. return LEVEL_R;
  176. else if (contentLevels & DVD_PARENTAL_LEVEL_4)
  177. return LEVEL_PG13;
  178. else if (contentLevels & DVD_PARENTAL_LEVEL_3)
  179. return LEVEL_PG;
  180. else if (contentLevels & DVD_PARENTAL_LEVEL_2)
  181. return LEVEL_PG;
  182. else
  183. return LEVEL_G;
  184. }