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.

310 lines
9.2 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: DVDRect.cpp */
  4. /* Description: Implementation of CDVDRect */
  5. /* Author: David Janecek */
  6. /*************************************************************************/
  7. #include "stdafx.h"
  8. #include "MSWebDVD.h"
  9. #include "DVDRect.h"
  10. #include <errors.h>
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDVDRect
  13. /*************************************************************************/
  14. /* Function: get_x */
  15. /*************************************************************************/
  16. STDMETHODIMP CDVDRect::get_x(long *pVal){
  17. HRESULT hr = S_OK;
  18. try {
  19. if(NULL == pVal){
  20. throw(E_POINTER);
  21. }/* end of if statement */
  22. *pVal = m_x;
  23. }
  24. catch(HRESULT hrTmp){
  25. hr = hrTmp;
  26. }/* end of catch statement */
  27. catch(...){
  28. hr = E_UNEXPECTED;
  29. }/* end of catch statement */
  30. return HandleError(hr);
  31. }/* end of function get_x */
  32. /*************************************************************************/
  33. /* Function: put_x */
  34. /*************************************************************************/
  35. STDMETHODIMP CDVDRect::put_x(long newVal){
  36. HRESULT hr = S_OK;
  37. try {
  38. m_x = newVal;
  39. }
  40. catch(HRESULT hrTmp){
  41. hr = hrTmp;
  42. }/* end of catch statement */
  43. catch(...){
  44. hr = E_UNEXPECTED;
  45. }/* end of catch statement */
  46. return HandleError(hr);
  47. }/* end of function put_x */
  48. /*************************************************************************/
  49. /* Function: get_y */
  50. /*************************************************************************/
  51. STDMETHODIMP CDVDRect::get_y(long *pVal){
  52. HRESULT hr = S_OK;
  53. try {
  54. if(NULL == pVal){
  55. throw(E_POINTER);
  56. }/* end of if statement */
  57. *pVal = m_y;
  58. }
  59. catch(HRESULT hrTmp){
  60. hr = hrTmp;
  61. }/* end of catch statement */
  62. catch(...){
  63. hr = E_UNEXPECTED;
  64. }/* end of catch statement */
  65. return HandleError(hr);
  66. }/* end of function get_y */
  67. /*************************************************************************/
  68. /* Function: put_y */
  69. /*************************************************************************/
  70. STDMETHODIMP CDVDRect::put_y(long newVal){
  71. HRESULT hr = S_OK;
  72. try {
  73. m_y = newVal;
  74. }
  75. catch(HRESULT hrTmp){
  76. hr = hrTmp;
  77. }/* end of catch statement */
  78. catch(...){
  79. hr = E_UNEXPECTED;
  80. }/* end of catch statement */
  81. return HandleError(hr);
  82. }/* end of function put_y */
  83. /*************************************************************************/
  84. /* Function: get_Width */
  85. /*************************************************************************/
  86. STDMETHODIMP CDVDRect::get_Width(long *pVal){
  87. HRESULT hr = S_OK;
  88. try {
  89. if(NULL == pVal){
  90. throw(E_POINTER);
  91. }/* end of if statement */
  92. *pVal = m_lWidth;
  93. }
  94. catch(HRESULT hrTmp){
  95. hr = hrTmp;
  96. }/* end of catch statement */
  97. catch(...){
  98. hr = E_UNEXPECTED;
  99. }/* end of catch statement */
  100. return HandleError(hr);
  101. }/* end of function get_Width */
  102. /*************************************************************************/
  103. /* Function: put_Width */
  104. /*************************************************************************/
  105. STDMETHODIMP CDVDRect::put_Width(long newVal){
  106. HRESULT hr = S_OK;
  107. try {
  108. if(newVal <= 0){
  109. throw(E_INVALIDARG);
  110. }/* end of if statement */
  111. m_lWidth = newVal;
  112. }
  113. catch(HRESULT hrTmp){
  114. hr = hrTmp;
  115. }/* end of catch statement */
  116. catch(...){
  117. hr = E_UNEXPECTED;
  118. }/* end of catch statement */
  119. return HandleError(hr);
  120. }/* end of function put_Width */
  121. /*************************************************************************/
  122. /* Function: get_Height */
  123. /*************************************************************************/
  124. STDMETHODIMP CDVDRect::get_Height(long *pVal){
  125. HRESULT hr = S_OK;
  126. try {
  127. if(NULL == pVal){
  128. throw(E_POINTER);
  129. }/* end of if statement */
  130. *pVal = m_lHeight;
  131. }
  132. catch(HRESULT hrTmp){
  133. hr = hrTmp;
  134. }/* end of catch statement */
  135. catch(...){
  136. hr = E_UNEXPECTED;
  137. }/* end of catch statement */
  138. return HandleError(hr);
  139. }/* end of function get_Height */
  140. /*************************************************************************/
  141. /* Function: put_Height */
  142. /*************************************************************************/
  143. STDMETHODIMP CDVDRect::put_Height(long newVal){
  144. HRESULT hr = S_OK;
  145. try {
  146. if(newVal <= 0){
  147. throw(E_INVALIDARG);
  148. }/* end of if statement */
  149. m_lHeight = newVal;
  150. }
  151. catch(HRESULT hrTmp){
  152. hr = hrTmp;
  153. }/* end of catch statement */
  154. catch(...){
  155. hr = E_UNEXPECTED;
  156. }/* end of catch statement */
  157. return HandleError(hr);
  158. }/* end of function put_Height */
  159. /*************************************************************************/
  160. /* Function: GetInterfaceSafetyOptions */
  161. /* Description: For support of security model in IE */
  162. /* This control is safe since it does not write to HD. */
  163. /*************************************************************************/
  164. STDMETHODIMP CDVDRect::GetInterfaceSafetyOptions(REFIID /*riid*/,
  165. DWORD* pdwSupportedOptions,
  166. DWORD* pdwEnabledOptions){
  167. HRESULT hr = S_OK;
  168. if(!pdwSupportedOptions || !pdwEnabledOptions){
  169. return E_POINTER;
  170. }
  171. *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
  172. *pdwEnabledOptions = *pdwSupportedOptions;
  173. return(hr);
  174. }/* end of function GetInterfaceSafetyOptions */
  175. /*************************************************************************/
  176. /* Function: SetInterfaceSafetyOptions */
  177. /* Description: For support of security model in IE */
  178. /*************************************************************************/
  179. STDMETHODIMP CDVDRect::SetInterfaceSafetyOptions(REFIID /*riid*/,
  180. DWORD /* dwSupportedOptions */,
  181. DWORD /* pdwEnabledOptions */){
  182. return (S_OK);
  183. }/* end of function SetInterfaceSafetyOptions */
  184. /*************************************************************************/
  185. /* Function: InterfaceSupportsErrorInfo */
  186. /*************************************************************************/
  187. STDMETHODIMP CDVDRect::InterfaceSupportsErrorInfo(REFIID riid){
  188. static const IID* arr[] = {
  189. &IID_IDVDRect,
  190. };
  191. for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++){
  192. if (InlineIsEqualGUID(*arr[i], riid))
  193. return S_OK;
  194. }/* end of for loop */
  195. return S_FALSE;
  196. }/* end of function InterfaceSupportsErrorInfo */
  197. /*************************************************************************/
  198. /* Function: HandleError */
  199. /* Description: Gets Error Description, so we can suppor IError Info. */
  200. /*************************************************************************/
  201. HRESULT CDVDRect::HandleError(HRESULT hr){
  202. try {
  203. if(FAILED(hr)){
  204. // Ensure that the string is Null Terminated
  205. TCHAR strError[MAX_ERROR_TEXT_LEN+1];
  206. ZeroMemory(strError, MAX_ERROR_TEXT_LEN+1);
  207. if(AMGetErrorText(hr , strError , MAX_ERROR_TEXT_LEN)){
  208. USES_CONVERSION;
  209. Error(T2W(strError));
  210. }
  211. else {
  212. ATLTRACE(TEXT("Unhandled Error Code \n")); // please add it
  213. ATLASSERT(FALSE);
  214. }/* end of if statement */
  215. }/* end of if statement */
  216. }/* end of try statement */
  217. catch(HRESULT hrTmp){
  218. hr = hrTmp;
  219. }/* end of catch statement */
  220. catch(...){
  221. // keep the hr same
  222. }/* end of catch statement */
  223. return (hr);
  224. }/* end of function HandleError */
  225. /*************************************************************************/
  226. /* End of file: DVDRect.cpp */
  227. /*************************************************************************/