hxresmgr.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:21k
源码类别:

Symbian

开发平台:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: hxresmgr.cpp,v 1.7.28.1 2004/07/09 02:05:58 hubbe Exp $
  3.  * 
  4.  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  5.  * 
  6.  * The contents of this file, and the files included with this file,
  7.  * are subject to the current version of the RealNetworks Public
  8.  * Source License (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the current version of the RealNetworks Community
  11.  * Source License (the "RCSL") available at
  12.  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
  13.  * will apply. You may also obtain the license terms directly from
  14.  * RealNetworks.  You may not use this file except in compliance with
  15.  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
  16.  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  17.  * the rights, obligations and limitations governing use of the
  18.  * contents of the file.
  19.  * 
  20.  * Alternatively, the contents of this file may be used under the
  21.  * terms of the GNU General Public License Version 2 or later (the
  22.  * "GPL") in which case the provisions of the GPL are applicable
  23.  * instead of those above. If you wish to allow use of your version of
  24.  * this file only under the terms of the GPL, and not to allow others
  25.  * to use your version of this file under the terms of either the RPSL
  26.  * or RCSL, indicate your decision by deleting the provisions above
  27.  * and replace them with the notice and other provisions required by
  28.  * the GPL. If you do not delete the provisions above, a recipient may
  29.  * use your version of this file under the terms of any one of the
  30.  * RPSL, the RCSL or the GPL.
  31.  * 
  32.  * This file is part of the Helix DNA Technology. RealNetworks is the
  33.  * developer of the Original Code and owns the copyrights in the
  34.  * portions it created.
  35.  * 
  36.  * This file, and the files included with this file, is distributed
  37.  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  38.  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  39.  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  40.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  41.  * ENJOYMENT OR NON-INFRINGEMENT.
  42.  * 
  43.  * Technology Compatibility Kit Test Suite(s) Location:
  44.  *    http://www.helixcommunity.org/content/tck
  45.  * 
  46.  * Contributor(s):
  47.  * 
  48.  * ***** END LICENSE BLOCK ***** */
  49. #include "hxcom.h"
  50. #include "hlxclib/string.h"
  51. #include "hxtypes.h"
  52. #include "hxresult.h"
  53. #include "hxbuffer.h"
  54. #include "hxxres.h"
  55. #include "hxxrsmg.h"
  56. #include "dcoreres.h"
  57. #include "saerrs.h"
  58. #include "hxresmgr.h"
  59. /* This is the ONLY file that should be including hxerrors.h */
  60. #include "hxerrors.h"
  61. #if defined( _WIN32 ) || defined( _WINDOWS )
  62. #include "hlxclib/windows.h"
  63. #include "platform/win/rescode.h"
  64. #elif defined (_MACINTOSH)
  65. const short     RA_ERROR_STRINGS = 5000;
  66. const short     RA_MSG_STRINGS = 5001;
  67. #endif
  68. #include "hxheap.h"
  69. #ifdef _DEBUG
  70. #undef HX_THIS_FILE
  71. static const char HX_THIS_FILE[] = __FILE__;
  72. #endif
  73. #ifdef _WINDOWS
  74. extern HINSTANCE g_hInstance;
  75. #endif
  76. static struct errorStringTable
  77. {
  78.     HX_RESULT    m_ulErrorTag;
  79.     UINT32       m_ulErrorStringID;
  80. } const ErrorStringTable[] =
  81. {
  82.     {HXR_FAILED,                IDS_ERR_GENERAL_ERROR},                 // 1 "General error. An error occurred"
  83.     {HXR_OUTOFMEMORY,           IDS_ERR_MEMORY_ERROR},                  // 2 "Out of memory."
  84.     {HXR_INVALID_OPERATION,     IDS_ERR_INVALID_OPERATION},             // 3 "Invalid Operation."
  85.     // state errors/return values
  86.     {HXR_INVALID_PARAMETER,     IDS_ERR_INVALID_PARAMETER},             // 8 "Invalid parameter. Unable to process request."
  87.     {HXR_NOT_INITIALIZED,       IDS_ERR_NOT_INITIALIZED_ERROR},         // 10 "Not initialized."
  88.     // file errors
  89.     {HXR_INVALID_FILE,          IDS_ERR_INVALID_FILE},                  // 11 "This document is not a RealAudio document."
  90.     {HXR_INVALID_VERSION,       IDS_ERR_INVALID_VERSION},               // 12 "Invalid RealAudio file version number."
  91.     {HXR_DOC_MISSING,           IDS_ERR_DOC_MISSING_ERROR},             // 14 "Requested file not found. The link you followed may be outdated or inaccurate."
  92.     {HXR_BAD_FORMAT,            IDS_ERR_FORMAT_ERROR},                  // 15 "Unknown data format."
  93.     // server errors
  94.     {HXR_NET_SOCKET_INVALID,    IDS_ERR_NET_SOCKET_INVALID},            // 18 "Invalid socket error."
  95.     {HXR_NET_CONNECT,           IDS_ERR_NET_CONNECT_ERROR},             // 19 "An error occurred while trying to connect to the RealAudio Server."
  96.     {HXR_BIND,                  IDS_ERR_BIND_ERROR},                    // 20 "An error occurred binding to network socket."
  97.     {HXR_SOCKET_CREATE,         IDS_ERR_SOCKET_CREATE_ERROR},           // 21 "An error occurred while creating a network socket."
  98.     {HXR_INVALID_HOST,          IDS_ERR_INVALID_HOST},                  // 22 "Requested server is not valid."
  99.     {HXR_INVALID_PATH,          IDS_ERR_INVALID_PATH},                  // 23 "Requested URL is not valid."
  100.     {HXR_NET_READ,              IDS_ERR_NET_READ_ERROR},                // 24 "An error occurred while reading data from the network."
  101.     {HXR_NET_WRITE,             IDS_ERR_NET_WRITE_ERROR},               // 25 "An error occurred while writing data to the network."
  102.     {HXR_NET_UDP,               IDS_ERR_NET_UDP_ERROR},                 // 26 "Player cannot receive UDP data packets. You may wish to try the TCP data
  103.     {HXR_HTTP_CONNECT,          IDS_ERR_HTTP_CONNECT_ERROR},            // 25
  104.     //     option in the Network Preferences. You may also want to configure your player
  105.     //     to use a firewall proxy. Please contact your system adminstrator for more information."
  106.     {HXR_SERVER_TIMEOUT,        IDS_ERR_SERVER_TIMEOUT},                // 28 "Server timeout. Server not responding."
  107.     {HXR_SERVER_DISCONNECTED,   IDS_ERR_SERVER_DISCONNECTED},           // 29 "Server disconnected. The server may be too busy or not available at this time."
  108.     {HXR_DNR,                   IDS_ERR_DNR_ERROR},                     // 30 "Cannot resolve the requested network address."
  109.     {HXR_OPEN_DRIVER,           IDS_ERR_OPEN_DRIVER_ERROR},             // 31 "Cannot open the network drivers."
  110.     {HXR_BAD_SERVER,            IDS_ERR_BAD_SERVER_ERROR},              // 34 "This server is not using a recognized protocol."
  111.     {HXR_ADVANCED_SERVER,       IDS_ERR_ADVANCED_SERVER_ERROR},         // 35 "You need a newer client to access this server. Please upgrade."
  112.     {HXR_OLD_SERVER,            IDS_ERR_OLD_SERVER_ERROR},              // 36 "Connection closed. The host's version of the RealAudio Server is too old for this client."
  113.     {HXR_SERVER_ALERT,          IDS_ERR_SERVER_ALERT},                  // 45 "Server alert"
  114.     // decoder errors
  115.     {HXR_DEC_NOT_FOUND,         IDS_ERR_DEC_NOT_FOUND},                 // 38 "File compression not supported. Cannot locate the requested RealAudio decoder."
  116.     {HXR_DEC_INVALID,           IDS_ERR_DEC_INVALID},                   // 39 "Invalid decoder."
  117.     {HXR_DEC_TYPE_MISMATCH,     IDS_ERR_DEC_TYPE_MISMATCH},             // 40 "Decoder type mismatch. Cannot load the requested decoder."
  118.     {HXR_DEC_INIT_FAILED,       IDS_ERR_DEC_INIT_FAILED},               // 41 "Requested RealAudio Decoder cannot be found or cannot be used on this machine."
  119.     {HXR_DEC_NOT_INITED,        IDS_ERR_DEC_NOT_INITED},                // 42 "RealAudio Decoder was not initialized before attempting to use it."
  120.     {HXR_DEC_DECOMPRESS,        IDS_ERR_DEC_DECOMPRESS_ERROR},          // 43 "An error occurred during decoding."
  121.     {HXR_NO_CODECS,             IDS_ERR_NO_CODECS},                     // 87 "No RealAudio Codecs have been installed on your system."
  122.     // proxy errors
  123.     {HXR_PROXY,                 IDS_ERR_PROXY_ERROR},                   // 46 "Proxy status error"
  124.     {HXR_PROXY_RESPONSE,        IDS_ERR_PROXY_RESPONSE_ERROR},          // 47 "Proxy invalid response error"
  125.     {HXR_ADVANCED_PROXY,        IDS_ERR_ADVANCED_PROXY_ERROR},          // 48 "You need a newer client to access this proxy. Please upgrade."
  126.     {HXR_OLD_PROXY,             IDS_ERR_OLD_PROXY_ERROR},               // 49 "Connection closed. The proxy is too old for this client."
  127.     // audio errors
  128.     {HXR_AUDIO_DRIVER,          IDS_ERR_AUDIO_DRIVER_ERROR},            // 50 "Cannot open audio device."
  129.     // parsing errors
  130.     {HXR_INVALID_PROTOCOL,      IDS_ERR_INVALID_PROTOCOL_ERROR},        // 51 "Invalid protocol specified in URL."
  131.     {HXR_INVALID_URL_OPTION,    IDS_ERR_INVALID_URL_OPTION_ERROR},      // 52 "Invalid option specified in URL."
  132.     {HXR_INVALID_URL_HOST,      IDS_ERR_INVALID_URL_HOST},              // 53 "Invalid host string in requested URL."
  133.     {HXR_INVALID_URL_PATH,      IDS_ERR_INVALID_URL_PATH},              // 54 "Invalid resource path string in requested URL."
  134.     {HXR_GENERAL_NONET,         IDS_ERR_GENERAL_NONET},                 // 55 "Error locating Winsock Services."
  135.     // More errors
  136.     {HXR_PERFECTPLAY_NOT_SUPPORTED,     IDS_ERR_PERFECTPLAY_NOT_SUPPORTED},     // 75, Requested server does not support PerfectPlay.
  137.     {HXR_NO_LIVE_PERFECTPLAY,           IDS_ERR_NO_LIVE_PERFECTPLAY},           // 76, PerfectPlay not supported for live streams.
  138.     {HXR_PERFECTPLAY_NOT_ALLOWED,       IDS_ERR_PERFECTPLAY_NOT_ALLOWED},       // 78, PerfectPlay not allowed on this clip.
  139.     {HXR_MULTICAST_JOIN,                IDS_ERR_MULTICAST_JOIN_ERROR},          // 84, An error occured attempting to join multicast session.
  140.     {HXR_GENERAL_MULTICAST,             IDS_ERR_GENERAL_MULTICAST_ERROR},       // 85, An error occured accessing a multicast session.
  141.     {HXR_MULTICAST_UDP,                 IDS_ERR_MULTICAST_UDP_ERROR},           // 86 "Player cannot receive UDP data packets from multicast session.
  142.                                                                                 // You may wish to try the TCP data option in the Network Preferences.
  143.                                                                                 // You may also want to configure your player to use a firewall proxy.
  144.                                                                                 // Please contact your system adminstrator for more information."
  145.     {HXR_SLOW_MACHINE,                  IDS_ERR_SLOW_MACHINE},                  // 88 "Your machine does not have enough CPU power to play this file in real time."
  146.     {HXR_INVALID_HTTP_PROXY_HOST,       IDS_ERR_INVALID_HTTP_PROXY_HOST},       // 90 Invalid hostname for HTTP proxy.
  147.     {HXR_INVALID_METAFILE,              IDS_ERR_INVALID_METAFILE},              // 90 Invalid hostname for HTTP proxy.
  148.     {HXR_NO_FILEFORMAT,                 IDS_ERR_MISSING_COMPONENTS},            // Missing components
  149.     {HXR_NO_RENDERER,                   IDS_ERR_MISSING_COMPONENTS},            // Missing components
  150.     {HXR_MISSING_COMPONENTS,            IDS_ERR_MISSING_COMPONENTS},            // Missing components
  151.     {HXR_BAD_TRANSPORT,                 IDS_ERR_BAD_TRANSPORT},                 // 94 Transport not recognized
  152.     {HXR_NOT_AUTHORIZED,                IDS_ERR_NOT_AUTHORIZED},                // 95 Access Denied
  153.     {HXR_NOTENOUGH_BANDWIDTH,           IDS_ERR_NOTENOUGH_BANDWIDTH},
  154.     {HXR_RIGHTS_EXPIRED,                IDS_ERR_RIGHTS_EXPIRED},                // 1082 Digital Rights have expired.
  155.     {HXR_RESTORATION_COMPLETE,          IDS_ERR_RESTORATION_COMPLETE},          // restoration done.
  156.     {HXR_BACKUP_COMPLETE,               IDS_ERR_BACKUP_COMPLETE},               // backup done.
  157.     {HXR_TLC_NOT_CERTIFIED,             IDS_ERR_TLC_NOT_CERTIFIED},             // tlc not certified
  158.     {HXR_CORRUPTED_BACKUP_FILE,         IDS_ERR_CORRUPTED_BACKUP_FILE},         // corrupted backup file
  159.     {HXR_CHECK_RIGHTS,                  IDS_ERR_CHECK_RIGHTS},                  // Check for more Rights
  160.     {HXR_RESTORE_SERVER_DENIED,         IDS_ERR_RESTORE_SERVER_DENIED},         // Restoration Denial from server.
  161.     {HXR_DEBUGGER_DETECTED,             IDS_ERR_DEBUGGER_DETECTED},             // Debugger detected.
  162.     {HXR_RESTORE_SERVER_CONNECT,        IDS_ERR_RESTORE_SERVER_CONNECT},        // Cannot connect to Restore server .
  163.     {HXR_RESTORE_SERVER_TIMEOUT,        IDS_ERR_RESTORE_SERVER_TIMEOUT},        // Restore server timeout.
  164.     {HXR_REVOKE_SERVER_CONNECT,         IDS_ERR_REVOKE_SERVER_CONNECT},         // Cannot connect to Revoke server.
  165.     {HXR_REVOKE_SERVER_TIMEOUT,         IDS_ERR_REVOKE_SERVER_TIMEOUT},         // Revoke server timeout.
  166.     {HXR_UNSUPPORTED_VIDEO,             IDS_ERR_UNSUPPORTED_VIDEO},             // 105 "The file contains an unsupported video format"
  167.     {HXR_UNSUPPORTED_AUDIO,             IDS_ERR_UNSUPPORTED_AUDIO},             // 106 "The file contains an unsupported audio format"
  168.     {HXR_TRY_AUTOCONFIG,                IDS_ERR_TRY_AUTOCONFIG},                // 107 "AutoConfig needs to be performed"
  169.     {HXR_PROXY_DNR,                     IDS_ERR_PROXY_DNR_ERROR},               // 108 "Unable to locate proxy server. This proxy server does not have a DNS entry. Please check the proxy server name and try again"
  170.     {HXR_PROXY_NET_CONNECT,             IDS_ERR_PROXY_NET_CONNECT_ERROR},       // 109 "Connection to proxy server could not be established. You may be experiencing network problems."
  171.     {HXR_VIEW_SOURCE_NOCLIP,            IDS_ERR_VIEW_SOURCE_NOCLIP},            // 80 "No clip is avalible."
  172.     {HXR_VIEW_SOURCE_DISSABLED,         IDS_ERR_VIEW_SOURCE_DISSABLED},         // 81 "The provider of this content has not granted permission to view the source."
  173.     {HXR_VSRC_DISABLED,                 IDS_ERR_VSRC_DISABLED},                 // "Select More Info to learn about viewing clip source."
  174.     {HXR_VSRC_NOCLIP,                   IDS_ERR_VSRC_NOCLIP},                   // "Select More Info to learn about viewing clip source."
  175.     {HXR_WINDRAW_EXCEPTION,             IDS_ERR_WINDRAW_EXCEPTION},             // 98 "A windraw operation crashed."
  176.     {HXR_VIEW_RIGHTS_NODRM,             IDS_ERR_VIEW_RIGHTS_NODRM},
  177.     {HXR_VSRC_NODRM,                    IDS_ERR_VSRC_NODRM},
  178.     // server alerts
  179.     {HXR_SE_NO_ERROR,                     IDS_SE_NO_ERROR},
  180.     {HXR_SE_INVALID_VERSION,              IDS_SE_INVALID_VERSION},
  181.     {HXR_SE_INVALID_FORMAT,               IDS_SE_INVALID_FORMAT},
  182.     {HXR_SE_INVALID_BANDWIDTH,            IDS_SE_INVALID_BANDWIDTH},
  183.     {HXR_SE_INVALID_PATH,                 IDS_SE_INVALID_PATH},
  184.     {HXR_SE_UNKNOWN_PATH,                 IDS_SE_UNKNOWN_PATH},
  185.     {HXR_SE_INVALID_PROTOCOL,             IDS_SE_INVALID_PROTOCOL},
  186.     {HXR_SE_INVALID_PLAYER_ADDR,          IDS_SE_INVALID_PLAYER_ADDR},
  187.     {HXR_SE_LOCAL_STREAMS_PROHIBITED,     IDS_SE_LOCAL_STREAMS_PROHIBITED},
  188.     {HXR_SE_SERVER_FULL,                  IDS_SE_SERVER_FULL},
  189.     {HXR_SE_REMOTE_STREAMS_PROHIBITED,    IDS_SE_REMOTE_STREAMS_PROHIBITED},
  190.     {HXR_SE_EVENT_STREAMS_PROHIBITED,     IDS_SE_EVENT_STREAMS_PROHIBITED},
  191.     {HXR_SE_INVALID_HOST,                 IDS_SE_INVALID_HOST},
  192.     {HXR_SE_NO_CODEC,                     IDS_SE_NO_CODEC},
  193.     {HXR_SE_LIVEFILE_INVALID_BWN,         IDS_SE_LIVEFILE_INVALID_BWN},
  194.     {HXR_SE_UNABLE_TO_FULFILL,            IDS_SE_UNABLE_TO_FULFILL},
  195.     {HXR_SE_MULTICAST_DELIVERY_ONLY,      IDS_SE_MULTICAST_DELIVERY_ONLY},
  196.     {HXR_SE_LICENSE_EXCEEDED,             IDS_SE_LICENSE_EXCEEDED},
  197.     {HXR_SE_LICENSE_UNAVAILABLE,          IDS_SE_LICENSE_UNAVAILABLE},
  198.     {HXR_SE_INVALID_LOSS_CORRECTION,      IDS_SE_INVALID_LOSS_CORRECTION},
  199.     {HXR_SE_PROTOCOL_FAILURE,             IDS_SE_PROTOCOL_FAILURE},
  200.     {HXR_SE_REALVIDEO_STREAMS_PROHIBITED, IDS_SE_REALVIDEO_STREAMS_PROHIBITED},
  201.     {HXR_SE_REALAUDIO_STREAMS_PROHIBITED, IDS_SE_REALAUDIO_STREAMS_PROHIBITED},
  202.     {HXR_SE_DATATYPE_UNSUPPORTED,         IDS_SE_DATATYPE_UNSUPPORTED},
  203.     {HXR_SE_DATATYPE_UNLICENSED,          IDS_SE_DATATYPE_UNLICENSED},
  204.     {HXR_SE_RESTRICTED_PLAYER,            IDS_SE_RESTRICTED_PLAYER},
  205.     {HXR_SE_STREAM_INITIALIZING,          IDS_SE_STREAM_INITIALIZING},
  206.     {HXR_SE_INVALID_PLAYER,               IDS_SE_INVALID_PLAYER},
  207.     {HXR_SE_PLAYER_PLUS_ONLY,             IDS_SE_PLAYER_PLUS_ONLY},
  208.     {HXR_SE_NO_EMBEDDED_PLAYERS,          IDS_SE_NO_EMBEDDED_PLAYERS},
  209.     {HXR_SE_PNA_PROHIBITED,               IDS_SE_PNA_PROHIBITED},
  210.     {HXR_SE_AUTHENTICATION_UNSUPPORTED,   IDS_SE_AUTHENTICATION_UNSUPPORTED},
  211.     {HXR_SE_MAX_FAILED_AUTHENTICATIONS,   IDS_SE_MAX_FAILED_AUTHENTICATIONS},
  212.     {HXR_SE_AUTH_ACCESS_DENIED,           IDS_SE_AUTH_ACCESS_DENIED},
  213.     {HXR_SE_AUTH_UUID_READ_ONLY,          IDS_SE_AUTH_UUID_READ_ONLY},
  214.     {HXR_SE_AUTH_UUID_NOT_UNIQUE,         IDS_SE_AUTH_UUID_NOT_UNIQUE},
  215.     {HXR_SE_AUTH_NO_SUCH_USER,            IDS_SE_AUTH_NO_SUCH_USER},
  216.     {HXR_SE_AUTH_REGISTRATION_SUCCEEDED,  IDS_SE_AUTH_REGISTRATION_SUCCEEDED},
  217.     {HXR_SE_AUTH_REGISTRATION_FAILED,     IDS_SE_AUTH_REGISTRATION_FAILED},
  218.     {HXR_SE_AUTH_REGISTRATION_GUID_REQUIRED, IDS_SE_AUTH_REGISTRATION_GUID_REQUIRED},
  219.     {HXR_SE_AUTH_UNREGISTERED_PLAYER,     IDS_SE_AUTH_UNREGISTERED_PLAYER},
  220.     {HXR_SE_AUTH_TIME_EXPIRED,            IDS_SE_AUTH_TIME_EXPIRED},
  221.     {HXR_SE_AUTH_NO_TIME_LEFT,            IDS_SE_AUTH_NO_TIME_LEFT},
  222.     {HXR_SE_AUTH_ACCOUNT_LOCKED,          IDS_SE_AUTH_ACCOUNT_LOCKED},
  223.     {HXR_SE_AUTH_INVALID_SERVER_CFG,      IDS_SE_AUTH_INVALID_SERVER_CFG},
  224.     {HXR_SE_NO_MOBILE_DOWNLOAD,           IDS_SE_NO_MOBILE_DOWNLOAD},
  225.     {HXR_SE_NO_MORE_MULTI_ADDR,           IDS_SE_NO_MORE_MULTI_ADDR},
  226.     {HXR_PE_PROXY_MAX_CONNECTIONS,        IDS_PE_PROXY_MAX_CONNECTIONS},
  227.     {HXR_PE_PROXY_MAX_GW_BANDWIDTH,       IDS_PE_PROXY_MAX_GW_BANDWIDTH},
  228.     {HXR_PE_PROXY_MAX_BANDWIDTH,          IDS_PE_PROXY_MAX_BANDWIDTH},
  229.     {HXR_SE_BAD_LOADTEST_PASSWORD,        IDS_SE_BAD_LOADTEST_PASSWORD},
  230.     {HXR_SE_PNA_NOT_SUPPORTED,            IDS_SE_PNA_NOT_SUPPORTED},
  231.     {HXR_PE_PROXY_ORIGIN_DISCONNECTED,    IDS_PE_PROXY_ORIGIN_DISCONNECTED},
  232.     {HXR_SE_INTERNAL_ERROR,               IDS_SE_INTERNAL_ERROR}
  233. };
  234. /*
  235.  *      Class Constructor/Destructor
  236.  */
  237. CHXResMgr::CHXResMgr(IUnknown* pContext)
  238.             : m_pContext(NULL)
  239.             , m_pExternalResMgr(NULL)
  240.             , m_pExternalResRdr(NULL)
  241. {
  242.     m_pContext = pContext;
  243.     if (m_pContext)
  244.     {
  245.         m_pContext->AddRef();
  246.         if (HXR_OK != m_pContext->QueryInterface(IID_IHXExternalResourceManager,
  247.                                                  (void**)&m_pExternalResMgr))
  248.         {
  249.             m_pExternalResMgr = NULL;
  250.             goto cleanup;
  251.         }
  252.         if(HXR_OK != m_pExternalResMgr->CreateExternalResourceReader(
  253.                                         CORE_RESOURCE_SHORT_NAME, m_pExternalResRdr))
  254.         {
  255.             m_pExternalResRdr = NULL;
  256.             goto cleanup;
  257.         }
  258. #ifdef _WINDOWS
  259. #ifndef _WINCE
  260.         GetModuleFileName((HMODULE)g_hInstance, m_szDLLPath, sizeof(m_szDLLPath));
  261. #else
  262.         GetModuleFileName((HMODULE)g_hInstance, OS_STRING2(m_szDLLPath, sizeof(m_szDLLPath)), sizeof(m_szDLLPath));
  263. #endif
  264.         m_pExternalResRdr->SetDefaultResourceFile(m_szDLLPath);
  265. #endif /* _WINDOWS */
  266.     }
  267. cleanup:
  268.     return;
  269. }
  270. CHXResMgr::~CHXResMgr()
  271. {
  272.     HX_RELEASE(m_pExternalResRdr);
  273.     HX_RELEASE(m_pExternalResMgr);
  274.     HX_RELEASE(m_pContext);
  275. }
  276. /*
  277.  *      General Class Methods
  278.  */
  279. //      A member function for returning an error string that corresponds to an
  280. //      error Id.
  281. CHXBuffer* CHXResMgr::GetErrorString( HX_RESULT ErrId )
  282. {
  283.     CHXBuffer*  pBuffer = NULL;
  284.     const char* str = NULL;
  285.     BOOL        bFound = FALSE;
  286.     UINT32      ulErrorStringID = ErrorStringTable[0].m_ulErrorStringID;
  287.     for (int i = 0;
  288.         i < sizeof(ErrorStringTable) / sizeof(ErrorStringTable[0]);
  289.         ++i)
  290.     {
  291.         if(ErrorStringTable[i].m_ulErrorTag == ErrId)
  292.         {
  293.             ulErrorStringID = ErrorStringTable[i].m_ulErrorStringID;
  294.             bFound = TRUE;
  295.             break;
  296.         }
  297.     }
  298.     if (m_pExternalResRdr && bFound)
  299.     {
  300.         IHXXResource* pRes = m_pExternalResRdr->GetResource(HX_RT_STRING,
  301.                                                              ulErrorStringID);
  302.         if(pRes)
  303.         {
  304.             str = (const char*)pRes->ResourceData();
  305.             if (str)
  306.             {
  307.                 pBuffer = new CHXBuffer;
  308.                 pBuffer->AddRef();
  309.                 pBuffer->Set((UCHAR*)str, strlen(str) + 1);
  310.             }
  311.         }
  312.         HX_RELEASE(pRes);
  313.     }
  314.     return pBuffer;
  315. }
  316. CHXBuffer* CHXResMgr::GetMiscString(UINT32 ResourceId)
  317. {
  318.     CHXBuffer* pBuffer = NULL;
  319.     const char* str = NULL;
  320.     IHXXResource* pRes = m_pExternalResRdr->GetResource(HX_RT_STRING,
  321.                                                          ResourceId);
  322.     if(pRes)
  323.     {
  324.         str = (const char*)pRes->ResourceData();
  325.         if (str)
  326.         {
  327.             pBuffer = new CHXBuffer;
  328.             pBuffer->AddRef();
  329.             pBuffer->Set((UCHAR*)str, strlen(str) + 1);
  330.         }
  331.     }
  332.     HX_RELEASE(pRes);
  333.     return pBuffer;
  334. }