hxresmgr.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:20k
源码类别:

Symbian

开发平台:

C/C++

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