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

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 "hxnetutil.h"
  36. #include "hxprefs.h"  // IHXPreferences
  37. #include "ihxpckts.h" // IHXBuffer
  38. #include "hxcore.h"   // IHXClientEngine
  39. #if defined(HELIX_FEATURE_PREFERENCES)
  40. #include "hxprefs.h"
  41. #include "hxprefutil.h"
  42. #endif /* HELIX_FEATURE_PREFERENCES */
  43. #include <stdlib.h>
  44. HX_RESULT ConvertNetworkError(HX_RESULT theErr)
  45. {
  46.     HX_RESULT lResult = theErr;
  47.     if (!IS_SERVER_ALERT(theErr))
  48.     {
  49.         switch(theErr)
  50.         {
  51.             case HXR_AT_INTERRUPT:                      // mask out these errors
  52.             case HXR_WOULD_BLOCK:
  53.             case HXR_NO_DATA:
  54.             case HXR_OK:
  55.                 lResult = HXR_OK;
  56.                 break;
  57.             case HXR_DNR:
  58.             case HXR_DOC_MISSING:
  59.             case HXR_OUTOFMEMORY:
  60.             case HXR_ADVANCED_SERVER:
  61.             case HXR_BAD_SERVER:
  62.             case HXR_OLD_SERVER:
  63.             case HXR_INVALID_FILE:
  64.             case HXR_REDIRECTION:
  65.             case HXR_PROXY:
  66.             case HXR_PROXY_RESPONSE:
  67.             case HXR_ADVANCED_PROXY:
  68.             case HXR_OLD_PROXY:
  69.             case HXR_PERFECTPLAY_NOT_SUPPORTED:
  70.             case HXR_NO_LIVE_PERFECTPLAY:
  71.             case HXR_PERFECTPLAY_NOT_ALLOWED:
  72.             case HXR_NET_SOCKET_INVALID:
  73.             case HXR_GENERAL_NONET:
  74.             case HXR_BLOCK_CANCELED:
  75.             case HXR_MSG_TOOLARGE:
  76.             case HXR_SERVER_DISCONNECTED:
  77.             case HXR_BAD_TRANSPORT:
  78.                 break;
  79.             default:
  80.                 lResult = HXR_SERVER_DISCONNECTED;
  81.                 break;
  82.         }
  83.     }
  84.     return lResult;
  85. }
  86. #if defined( _UNIX )
  87. BOOL ReadNetworkThreadingPref( IUnknown* pContext )
  88. {
  89. #if defined(_SOLARIS) // XXXNH: solaris network threading is currently buggy
  90.     static BOOL bNetworkThreading = FALSE;
  91. #else
  92.     static BOOL bNetworkThreading = TRUE;
  93. #endif
  94.     
  95. #if defined(HELIX_FEATURE_PREFERENCES)
  96.     
  97.     static BOOL bNeedToLoad       = TRUE;
  98.     if( bNeedToLoad && NULL!=pContext)
  99.     {
  100.         IHXPreferences* pPreferences = NULL;
  101.         bNeedToLoad = FALSE;
  102.         pContext->QueryInterface(IID_IHXPreferences, (void **)&pPreferences);
  103.         IHXBuffer *pBuffer = NULL;
  104.         if( NULL!=pPreferences )
  105.         {
  106.             if (ReadPrefBOOL(pPreferences, "NetworkThreading", bNetworkThreading) != HXR_OK)
  107.             {
  108.                 //XXXGFW HACK!! REMOVE AFTER RNC
  109.                 //Pref was not found. It defaults to ON now so lets see if we
  110.                 //are running under a player. If not, turn it off.
  111.                 IHXClientEngine* pEngine = NULL;
  112.                 if(HXR_OK == pContext->QueryInterface(IID_IHXClientEngine, (void**)&pEngine))
  113.                 {
  114.                     //We have client Engine. Do nothing.
  115.                     HX_RELEASE( pEngine );
  116.                 }
  117.                 else
  118.                 {
  119.                     //We don't have a client engine. Turn off threading...
  120.                     bNetworkThreading = FALSE;
  121.                 }
  122.             }
  123.             HX_RELEASE( pPreferences );
  124.         } // NULL!=pPreferences
  125.     }//bNeedToLoad && NULL!=pContext
  126. #endif /* HELIX_FEATURE_PREFERENCES */
  127.     return bNetworkThreading;
  128. }
  129. #endif