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.

106 lines
2.6 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. ////////////////////////////////////////////////////////
  23. // ErrorInfo.cpp
  24. //
  25. #include "stdafx.h"
  26. #include "TapiDialer.h"
  27. #include "AVTapi.h"
  28. #include "ErrorInfo.h"
  29. CErrorInfo::CErrorInfo()
  30. {
  31. Init( 0, 0 );
  32. }
  33. CErrorInfo::CErrorInfo( UINT nOperation, UINT nDetails )
  34. {
  35. Init( nOperation, nDetails );
  36. }
  37. void CErrorInfo::Init( UINT nOperation, UINT nDetails )
  38. {
  39. m_bstrOperation = NULL;
  40. m_bstrDetails = NULL;
  41. if ( !nOperation ) nOperation = IDS_ER_GENERAL_OPERATION;
  42. set_Operation( nOperation );
  43. if ( !nDetails ) nDetails = IDS_ER_GENERAL_DETAILS;
  44. set_Details( nDetails );
  45. m_hr = S_OK;
  46. }
  47. CErrorInfo::~CErrorInfo()
  48. {
  49. CComPtr<IAVTapi> pAVTapi;
  50. if ( FAILED(m_hr) && SUCCEEDED(_Module.get_AVTapi(&pAVTapi)) )
  51. {
  52. Commit();
  53. // Notify the application of the problem
  54. pAVTapi->fire_ErrorNotify( (long *) this );
  55. }
  56. SysFreeString( m_bstrOperation );
  57. SysFreeString( m_bstrDetails );
  58. }
  59. void CErrorInfo::set_Operation( UINT nIDS )
  60. {
  61. m_nOperation = nIDS;
  62. }
  63. void CErrorInfo::set_Details( UINT nIDS )
  64. {
  65. m_nDetails = nIDS;
  66. }
  67. void CErrorInfo::Commit()
  68. {
  69. // Translate error code to equivalent strings
  70. USES_CONVERSION;
  71. TCHAR szText[512];
  72. if ( m_nOperation )
  73. {
  74. LoadString( _Module.GetResourceInstance(), m_nOperation, szText, ARRAYSIZE(szText) );
  75. SysReAllocString( &m_bstrOperation, T2COLE(szText) );
  76. }
  77. if ( m_nDetails )
  78. {
  79. LoadString( _Module.GetResourceInstance(), m_nDetails, szText, ARRAYSIZE(szText) );
  80. SysReAllocString( &m_bstrDetails, T2COLE(szText) );
  81. }
  82. }
  83. HRESULT CErrorInfo::set_hr( HRESULT hr )
  84. {
  85. m_hr = hr;
  86. return hr;
  87. }