Ejemplo n.º 1
0
int DLLAccessClient::open(const char* dllName, 
			  UINT16 nLibType, 
			  IUnknown* pContext)
{
    HX_RESULT status;
    int retVal = DLLAccess::NO_LOAD;
    IHXCommonClassFactory* pCCF = NULL;

    HX_RELEASE(m_pDllAccessServer);

    status = pContext->QueryInterface(IID_IHXCommonClassFactory,
				      (void**) &pCCF);
    if (SUCCEEDED(status))
    {
	pCCF->CreateInstance(CLSID_IHXDllAccess,
			     (void**) &m_pDllAccessServer);
    }

    HX_RELEASE(pCCF);

    if (m_pDllAccessServer)
    {
	if (SUCCEEDED(m_pDllAccessServer->Open(dllName, nLibType)))
	{
	    retVal = DLLAccess::DLL_OK;
	}
    }
    
    return retVal;
}
Ejemplo n.º 2
0
void CHXPrefList::SetPreferences(IUnknown* pContext)
{
    IHXPreferences* pPrefs = NULL;
    IHXCommonClassFactory* pCCF = NULL;

    if (pContext &&
        (HXR_OK == pContext->QueryInterface(IID_IHXPreferences,
                                            (void**)&pPrefs)) &&
        (HXR_OK == pContext->QueryInterface(IID_IHXCommonClassFactory,
                                            (void**)&pCCF)))
    {
        CHXSimpleList::Iterator itr = m_prefInfo.Begin();
        
        for(; itr != m_prefInfo.End(); ++itr)
        {
            CHXPrefInfo* pInfo = (CHXPrefInfo*)(*itr);
            
            IHXBuffer* pBuf = NULL;
            
            if ((HXR_OK == pCCF->CreateInstance(CLSID_IHXBuffer,
                                                (void**)&pBuf)) &&
                (HXR_OK == pBuf->Set((const unsigned char*)pInfo->Value(),
                                     strlen(pInfo->Value()))))
            {
                pPrefs->WritePref(pInfo->Key(), pBuf);
            }

            HX_RELEASE(pBuf);
        }
    }

    HX_RELEASE(pPrefs);
    HX_RELEASE(pCCF);
}
Ejemplo n.º 3
0
HX_RESULT PlayerDriver::createThread(IHXThread** ppThread)
{
    HX_RESULT retVal = HXR_FAIL;
    IHXCommonClassFactory* pCCF = NULL;

    if ( m_pContext && ppThread )
        m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF);

    if (pCCF)
    {
        pCCF->CreateInstance(CLSID_IHXThread, (void**)ppThread);
        if ( *ppThread )
        {
            retVal= HXR_OK;
        }
        HX_RELEASE(pCCF);
    }
    return retVal;
}
Ejemplo n.º 4
0
void HelixPlayer::setValue(QString const& name, QVariant const& value)
{
    IHXPreferences *preferences;
    IHXCommonClassFactory *factory;

    m_player->QueryInterface( IID_IHXPreferences, (void**)&preferences );
    m_player->QueryInterface( IID_IHXCommonClassFactory, (void**)&factory );

    IHXBuffer *buffer;
    factory->CreateInstance( CLSID_IHXBuffer, (void**)&buffer );

    QString s = value.toString();
    buffer->Set( (const UCHAR*)s.toLatin1().data(), s.length() );

    preferences->WritePref(name.toLatin1().constData(), buffer );
    HX_RELEASE( buffer );

    HX_RELEASE( factory );
    HX_RELEASE( preferences );
}
Ejemplo n.º 5
0
void PlayerDriver::SetConfig(const char* pPropName, UINT16 bValue)
{
    IHXCommonClassFactory* pCCF = NULL;
    m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF);
    if (pCCF)
    {
	IHXValues* pValues = NULL;
	pCCF->CreateInstance(CLSID_IHXValues, (void**)&pValues);
	if (pValues)
	{
	    pValues->SetPropertyULONG32(pPropName, bValue);
	    if (m_pClientState)
	    {
		m_pClientState->SetConfig(pValues);
	    }
	    HX_RELEASE(pValues);
	}
	HX_RELEASE(pCCF);
    }
}
Ejemplo n.º 6
0
// Each DLL must call HXEnableLogging() at least once
//
void HXEnableLogging(IUnknown* pContext)
{
    if (pContext && !g_pLogSystem)
    {
#if defined(HELIX_FEATURE_CORE_LOG)
        HX_RESULT res = HXR_FAIL;
        res = pContext->QueryInterface(IID_IHXTLogSystem, (void**)&g_pLogSystem);
        if (SUCCEEDED(res))
        {
            res = DoLogWriterInit();
        }
#else
        IHXCommonClassFactory* pCCF = NULL;
        pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) &pCCF);
        if (pCCF)
        {
            pCCF->CreateInstance(CLSID_IHXDllAccess, (void**) &g_pDllAccess);
            if (g_pDllAccess)
            {
                // Create the dll name
                // MAXDLLSUFFIXLEN is defined in hxtlogutil.h
                char szDLLName[3 + HXLOG_MAXDLLSUFFIXLEN + 1];  /* Flawfinder: ignore */
                strcpy(szDLLName, "log"); /* Flawfinder: ignore */
                strcat(szDLLName, HXLOG_DLLSUFFIX); /* Flawfinder: ignore */

                // Attempt to get the RMAGetLogSystemInterface entry point
                g_pDllAccess->Open(szDLLName, HXDLLTYPE_PLUGIN);
                if(g_pDllAccess->IsOpen())
                {
                    FPCREATELOGSYSTEMINTERFACE fpCreateLogSystem =
                        (FPCREATELOGSYSTEMINTERFACE)(g_pDllAccess->GetSymbol("RMACreateLogSystem"));
                    DoLogSystemInterfaceInit(fpCreateLogSystem, pContext);
                }
            }
            HX_RELEASE(pCCF);
        }
#endif
    }
}
Ejemplo n.º 7
0
// HXScheduler...
HXScheduler::HXScheduler(IUnknown* pContext) :
     m_lRefCount (0)
    ,m_pScheduler(0)
    ,m_bUseDeferredTask(TRUE)
    ,m_pInterruptTimeScheduler(0)
    ,m_pInterruptTimeOnlyScheduler(0)
    ,m_pID(0)
    ,m_pContext(pContext)
    ,m_bLocked(FALSE)
    ,m_ulLastUpdateTime(0)
    ,m_pCoreMutex(NULL)
    ,m_bIsInterruptEnabled(FALSE)
    ,m_headTime(0)
    ,m_interruptHeadTime(0)
    ,m_interruptOnlyHeadTime(0)
    ,m_ulSystemNextDueTime(0)
    ,m_ulInterruptNextDueTime(0)
    ,m_ulInterruptOnlyNextDueTime(0)
    ,m_bImmediatesPending(0)

#if defined(_WIN32) || defined(THREADS_SUPPORTED)
    ,m_pAsyncTimer(0)
#endif 
    ,m_pTimeline(0)
    ,m_ulCurrentGranularity(0)
    ,m_pWaitEvent(NULL)
    ,m_bWaitPending(FALSE)
    ,m_bWaitedEventFired(FALSE)
    ,m_ulThreadID(0)
{
    m_pID			= new CHXID(100);
    m_pScheduler		= new ClientPQ(pContext, m_pID);
    m_pInterruptTimeScheduler	= new ClientPQ(pContext, m_pID);
    m_pInterruptTimeOnlyScheduler = new ClientPQ(pContext, m_pID);

    (void) gettimeofday(&m_CurrentTimeVal, 0);
    m_ulLastUpdateTime = HX_GET_TICKCOUNT();

    // Create event that wil be used for scheduler waiting operation
    if (m_pContext)
    {
	IHXCommonClassFactory* pCCF = NULL;

	m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) &pCCF);
	if (pCCF)
	{
	    pCCF->CreateInstance(IID_IHXEvent, (void**) &m_pWaitEvent);
	}

	if (m_pWaitEvent)
	{
	    if (FAILED(m_pWaitEvent->Init("Scheduler_Wait", FALSE)))
	    {
		HX_RELEASE(m_pWaitEvent);
	    }
	}

	HX_RELEASE(pCCF);
    }

    m_ulThreadID = HXGetCurrentThreadID();

}
Ejemplo n.º 8
0
STDMETHODIMP
HXCommonClassFactory::CreateInstance
(
    REFCLSID    /*IN*/  rclsid,
    void**      /*OUT*/ ppUnknown
)
{
    if (IsEqualCLSID(rclsid, CLSID_IHXBuffer))
    {
        *ppUnknown = (IUnknown*)(IHXBuffer*)(new ServerBuffer(TRUE));
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXPacket))
    {
        if (!g_bFastMallocAll && !g_bFastMalloc)
            *ppUnknown = (IUnknown*)(IHXPacket*)(new ServerPacket(TRUE));
        else
            *ppUnknown = (IUnknown*)(IHXPacket*)(new(m_pMemCache)
                ServerPacket(TRUE));
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXRTPPacket))
    {
        if (!g_bFastMallocAll && !g_bFastMalloc)
            *ppUnknown = (IUnknown*)(IHXRTPPacket*)(new ServerRTPPacket(TRUE));
        else
            *ppUnknown = (IUnknown*)(IHXRTPPacket*)(new(m_pMemCache)
                ServerRTPPacket(TRUE));
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXValues))
    {
        *ppUnknown = (IUnknown*)(IHXValues*)(new CHXHeader());
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXValues2))
    {
        *ppUnknown = (IUnknown*)(IHXValues2*)(new CHXHeader());
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXFileSystemManager))
    {
        *ppUnknown = (IUnknown*)(IHXFileSystemManager*)(new FSManager(m_proc));
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if(IsEqualCLSID(rclsid, CLSID_IHXPluginGroupEnumerator))
    {
        *ppUnknown = (IUnknown*)(IHXPluginGroupEnumerator*)
            (new CHXPluginGroupEnumerator(m_proc->pc->plugin_handler));
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXFragmentedBuffer))
    {
	*ppUnknown = (IUnknown*)(IHXFragmentedBuffer*)(new CHXFragmentedBuffer((IUnknown*)(IHXCommonClassFactory*)this));
	((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXKeyValueList))
    {
        *ppUnknown = (IUnknown*)(IHXKeyValueList*)(new CKeyValueList());
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualIID(rclsid, CLSID_IHXSourceFinderObject))
    {
        *ppUnknown = (IUnknown*)(IHXSourceFinderObject*)(new CServerSourceFinder(m_proc));
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXHTTPPostObject))
    {
        CHXHTTPPostObject* pObject = CHXHTTPPostObject::CreateObject();
        *ppUnknown = (IUnknown*) (IHXHTTPPostObject*) pObject;
        ((IUnknown*)*ppUnknown)->AddRef();
        pObject->InitObject(m_proc->pc->server_context);
        return HXR_OK;
    }
    else if(IsEqualCLSID(rclsid, CLSID_IHXRequest))
    {
        *ppUnknown = (IUnknown*)(IHXRequest*)(new CHXRequest());
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXMutex))
    {
        *ppUnknown = (IUnknown*)(IHXMutex*)(new Mutex());
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXFastFileFactory))
    {
        *ppUnknown = (IUnknown*)(IHXFastFileFactory*)
            (new FastFileFactory(m_proc->pc->server_context));
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXFastFileFactory2))
    {
        *ppUnknown = (IUnknown*)(IHXFastFileFactory2*)
            (new FastFileFactory(m_proc->pc->server_context));
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXQoSSignal))
    {
        *ppUnknown = (IUnknown*)(IHXQoSSignal*)(new QoSSignal());
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if (IsEqualCLSID(rclsid, CLSID_IHXList))
    {
        IHXFastAlloc* pAlloc = NULL;
        m_proc->pc->server_context->QueryInterface(IID_IHXFastAlloc,
            (void**)&pAlloc);

        *ppUnknown = (IUnknown*)(IHXList*)(new CHXList(pAlloc));
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else if(IsEqualCLSID(rclsid, IID_IHXPacketOrderer))
    {
        *ppUnknown = (IUnknown*)(IHXPacketOrderer*)(new CPacketOrderShim());
        ((IUnknown*)*ppUnknown)->AddRef();
        return HXR_OK;
    }
    else
    {
        // Try the factory plugins
        PluginHandler* pPluginHandler = m_proc->pc->plugin_handler;

        *ppUnknown = NULL;

        if(pPluginHandler)
        {
            PluginHandler::Factory* pFactories;
            PluginHandler::Plugin*  pPlugin;

            CHXSimpleList::Iterator i;

            pFactories = pPluginHandler->m_factory_handler;
            for(i = pFactories->m_pPlugins->Begin();
                i != pFactories->m_pPlugins->End();
                ++i)
            {
                IUnknown* pInstance = 0;
                pPlugin = (PluginHandler::Plugin*)(*i);
                pPlugin->GetInstance(&pInstance);

                if(pInstance)
                {
                    HX_RESULT res;
                    IHXPlugin* pFPlugin = 0;
                    res = pInstance->QueryInterface(IID_IHXPlugin,
                                                    (void**)&pFPlugin);
                    if(res == HXR_OK)
                    {
                        IHXCommonClassFactory* pClassFactory;
                        IUnknown* pContext;

                        m_proc->pc->server_context->QueryInterface(
                            IID_IUnknown,
                            (void**)&pContext);

                        pFPlugin->InitPlugin(pContext);
                        pFPlugin->Release();
                        pContext->Release();
                        res = pInstance->QueryInterface(
                            IID_IHXCommonClassFactory,
                            (void**)&pClassFactory);
                        if(HXR_OK == res)
                        {
                            res = pClassFactory->CreateInstance(rclsid,
                                                               ppUnknown);
                            if(HXR_OK != res)
                                *ppUnknown = NULL;
                            pClassFactory->Release();
                        }
                    }
                    pInstance->Release();
                    pPlugin->ReleaseInstance();
                    if(*ppUnknown)
                    {
                        return HXR_OK;
                    }
                }
            }
        }
    }

    *ppUnknown = NULL;
    return HXR_NOINTERFACE;
}
Ejemplo n.º 9
0
IHXValues*
DataRevertController::InflateConvertHeader(IHXBuffer* pInflate)
{
    IHXValues* pNewHeader = NULL;
    IHXCommonClassFactory* pCCF;
    
    m_pContext->QueryInterface(IID_IHXCommonClassFactory,
	    (void**)&pCCF);
    
    pCCF->CreateInstance(CLSID_IHXValues, (void**)&pNewHeader);
    ULONG32 ul;
    IHXBuffer* pBuffer;
    const char* p;
    IHXBuffer* pTemp;
    ULONG32 ulTemp;

    pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pTemp);
    UINT32 limit = pInflate->GetSize();
    UINT32 i = 0;
    p = (const char*)pInflate->GetBuffer();
    while (i < pInflate->GetSize() - 5)
    {
	if (p[i] == 'u')
	{
	    i++;
	    ulTemp = getlong((UINT8*) &(p[i]));
	    i += 4;
	    if (i + ulTemp > limit)
	    {
		goto error;
	    }
	    pTemp->SetSize(ulTemp + 1);
	    memcpy((char *)pTemp->GetBuffer(), &(p[i]), ulTemp); /* Flawfinder: ignore */
	    ((char*)pTemp->GetBuffer())[ulTemp] = 0;
	    i += ulTemp;
	    if (i + 4 > limit)
	    {
		goto error;
	    }
	    ul = getlong((UINT8*) &(p[i]));
	    i += 4;
	    pNewHeader->SetPropertyULONG32((char*)pTemp->GetBuffer(), ul);
	}
	else if (p[i] == 's' || p[i] == 'b')
	{
	    int at = i;
	    i++;
	    ulTemp = getlong((UINT8*) &(p[i]));
	    i += 4;
	    if (i + ulTemp > limit)
	    {
		goto error;
	    }
	    pTemp->SetSize(ulTemp + 1);
	    memcpy((char*)pTemp->GetBuffer(), &(p[i]), ulTemp); /* Flawfinder: ignore */
	    ((char*)pTemp->GetBuffer())[ulTemp] = 0;
	    i += ulTemp;
	    if (i + 4 > limit)
	    {
		goto error;
	    }
	    ulTemp = getlong((UINT8*) &(p[i]));
	    i += 4;
	    if (i + ulTemp > limit)
	    {
		goto error;
	    }
	    pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pBuffer);
	    pBuffer->SetSize(ulTemp);
	    memcpy((char*)pBuffer->GetBuffer(), &(p[i]), ulTemp); /* Flawfinder: ignore */

	    if (p[at] == 's')
	    {
		pNewHeader->SetPropertyCString((const char*)pTemp->GetBuffer(),
						pBuffer);
	    }
	    else
	    {
		pNewHeader->SetPropertyBuffer((const char*)pTemp->GetBuffer(),
						pBuffer);
	    }
	    pBuffer->Release();
	    i+= ulTemp;
	}
	else
	{
	    goto error;
	}
    }
    if (i != pInflate->GetSize())
    {
	goto error;
    }
    
    goto exit;
    
error:;

    
exit:;

    HX_RELEASE(pTemp);
    HX_RELEASE(pCCF);
    
    return pNewHeader;
}
Ejemplo n.º 10
0
STDMETHODIMP CHashAuthenticatorBase::SetConfiguration(IHXValues* pConfig)
{
    HX_RESULT theErr = HXR_OK;

    if (!m_pContext || !pConfig)
    {
	HX_ASSERT(0);
	return HXR_UNEXPECTED;
    }

    if (!m_pRealm)
    {
	pConfig->GetPropertyCString("Realm", m_pRealm);
    }

    if (!m_pDatabaseID)
    {
	    pConfig->GetPropertyCString("DatabaseID", m_pDatabaseID);

	    if (m_pDatabaseID)
	    {
	        //   IHXDatabaseManager - decides which db to use
	        //   IHXAuthenticationDBManager - controls access to one db
	        IUnknown*                punkDbMgr = NULL;
	        IHXDatabaseManager*     pDbMgr = NULL;
	        IUnknown*                pDatabase = NULL;
	        IHXCommonClassFactory*  pFactory = NULL;

	        m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void **)&pFactory);
            if (pFactory)
            {
    	        pFactory->CreateInstance(CLSID_CHXDatabaseManager, (void**)&punkDbMgr);
            }
            if (punkDbMgr)
            {
	            punkDbMgr->QueryInterface(IID_IHXDatabaseManager, (void**)&pDbMgr);
            }
            if (pDbMgr)
            {
	            pDbMgr->GetInstanceFromID(m_pDatabaseID, pDatabase);
            }
            if (pDatabase)
            {
	            pDatabase->QueryInterface(IID_IHXAuthenticationDBAccess, (void**)&m_pAuthDBAccess);
	            pDatabase->QueryInterface(IID_IHXAuthenticationDBManager, (void**)&m_pAuthDBManager);
            }
            else
            {
                theErr = HXR_FAIL;
            }

            HX_ASSERT(pFactory);
            HX_ASSERT(punkDbMgr);
            HX_ASSERT(pDbMgr);
            HX_ASSERT(pDatabase);

	        HX_RELEASE(punkDbMgr);
	        HX_RELEASE(pDbMgr);
	        HX_RELEASE(pDatabase);
	        HX_RELEASE(pFactory);
	    }
    }

    return HXR_OK;
}
Ejemplo n.º 11
0
HX_RESULT PlayerDriver::SetupPlaybackEngine()
{
	printf("HelixOverWebkit [%s] [%s] [%d]\n", __FILE__, __FUNCTION__, __LINE__);
    HX_RESULT retVal = HXR_OK;

    // get IHXMediaPlatform
    if (!m_pMediaPlatform)
    {
        retVal = HXMediaPlatformObj::CreateMediaPlatform(m_pMediaPlatform);
        if (FAILED(retVal))
        {
            //cout << "Can not load helix media platform." << endl;
			printf("HelixOverWebkit [%s] [%s] [%d] Can not load helix media platform\n", __FILE__, __FUNCTION__, __LINE__);
        }
    }

    // Get IUnknown* context from the media platform
    if (SUCCEEDED(retVal) && !m_pContext)
    {
        retVal = m_pMediaPlatform->QueryInterface(IID_IUnknown, (void**) &m_pContext);
        if (FAILED(retVal))
        {
            //cout << "QueryInterface for IUnknown failed.";
			printf("HelixOverWebkit [%s] [%s] [%d] QueryInterface for IUnknown failed\n", __FILE__, __FUNCTION__, __LINE__);
        }
    }

    // Get CCF for creating engine
    IHXCommonClassFactory* pCCF = NULL;
    if (SUCCEEDED(retVal))
    {
        retVal = m_pMediaPlatform->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF);
        if (FAILED(retVal))
        {
            //cout << "QueryInterface for IHXCommonClassFactory failed.";
			printf("HelixOverWebkit [%s] [%s] [%d] QueryInterface for IHXCommonClassFactory failed\n", __FILE__, __FUNCTION__, __LINE__);
        }
    }

    // Create client engine
    if (SUCCEEDED(retVal))
    {
        {
            retVal = pCCF->CreateInstance(CLSID_IHXClientEngine, (void**)&m_pClientEngine);
        }
	if (FAILED(retVal))
        {
            //cout << "Can not create IHXClientEngine via m_pMediaPlatform." << endl;
			printf("HelixOverWebkit [%s] [%s] [%d] Can not create IHXClientEngine via m_pMediaPlatform.\n", __FILE__, __FUNCTION__, __LINE__);
            HXMediaPlatformObj::ResetMediaPlatformNoDelay();
        }
        HX_RELEASE(pCCF);
    }

    if (SUCCEEDED(retVal))
    {
        m_pClientEngine->QueryInterface(IID_IHXPreferences, (void**)&m_pPreferences);
    }

     // Create player
    if (SUCCEEDED(retVal))
    {
        retVal = m_pClientEngine->CreatePlayer(m_pHXPlayer);
        if (FAILED(retVal))
        {
            //cout << "Cannot create player";
			printf("HelixOverWebkit [%s] [%s] [%d] Cannot create player\n", __FILE__, __FUNCTION__, __LINE__);
        }
    }

    // Create client context
    // TODO: context and errorsink
    if (SUCCEEDED(retVal))
    {
        m_pWebkitContext = new WebkitClientContext();
        if (m_pWebkitContext)
        {
            HX_ADDREF(m_pWebkitContext);
            m_pWebkitContext->Init(m_pHXPlayer, m_pMediaPlayer);
        }
        else
        {
			printf("HelixOverWebkit [%s] [%s] [%d] Cannot create client context\n", __FILE__, __FUNCTION__, __LINE__);
            retVal = HXR_FAIL;
        }
    }

    // Make client context available to the player
    if (SUCCEEDED(retVal))
    {
        IUnknown* pUnk = NULL;
        m_pWebkitContext->QueryInterface(IID_IUnknown, (void**)&pUnk);
        if (pUnk)
        			{
            m_pHXPlayer->SetClientContext(pUnk);
            HX_RELEASE(pUnk);
        			}
        else
        			{
        			printf("HelixOverWebkit [%s] [%s] [%d] Cannot create client context\n", __FILE__, __FUNCTION__, __LINE__);
            retVal = HXR_FAIL;
        			}
    }

    // Set error sink
	/*
    if (SUCCEEDED(retVal))
    {
        IHXErrorSinkControl* pErrorSinkControl = NULL;
        IHXErrorSink* pErrorSink = NULL;
        m_pHXPlayer->QueryInterface(IID_IHXErrorSinkControl, (void**) &pErrorSinkControl);
        m_pWebkitContext->QueryInterface(IID_IHXErrorSink, (void**) &pErrorSink);
        if (pErrorSinkControl && pErrorSink)
        {
            pErrorSinkControl->AddErrorSink(pErrorSink, HXLOG_EMERG, HXLOG_INFO);
        }
        else
        {
            //cout << "Cannot set error sink";
            retVal = HXR_FAIL;
        }

        HX_RELEASE(pErrorSinkControl);
        HX_RELEASE(pErrorSink);
    }
	*/

    // Obtain player client state interface
    if (SUCCEEDED(retVal))
    {
        retVal = m_pHXPlayer->QueryInterface(IID_IHXClientState, (void**)&m_pClientState);
        if (FAILED(retVal))
        {
            //cout << "can not get IHXClientState";
			printf("HelixOverWebkit [%s] [%s] [%d] can not get IHXClientState\n", __FILE__, __FUNCTION__, __LINE__);
        }
    }
	printf("HelixOverWebkit [%s] [%s] [%d]\n", __FILE__, __FUNCTION__, __LINE__);

    // Get scheduler
    if (SUCCEEDED(retVal) && !m_pScheduler)
    {
        retVal = m_pMediaPlatform->QueryInterface(IID_IHXScheduler, (void**)&m_pScheduler);
        if (FAILED(retVal))
        {
            //cout << "QueryInterface for IID_IHXScheduler failed.";
			printf("HelixOverWebkit [%s] [%s] [%d] QueryInterface for IID_IHXScheduler failed.\n", __FILE__, __FUNCTION__, __LINE__);
        }
    }

    if (SUCCEEDED(retVal) && !m_pCommandsProcessCallback)
    {
        m_pCommandsProcessCallback = new CHXGenericCallback((void*) this, CommandsProcessCallbackFunc);
        if (m_pCommandsProcessCallback)
        {
            m_pCommandsProcessCallback->AddRef();
        }
        else
        {
            //cout << "Create CHXGenericCallback failed.";
			printf("HelixOverWebkit [%s] [%s] [%d] Create CHXGenericCallback failed.\n", __FILE__, __FUNCTION__, __LINE__);
            retVal = HXR_FAIL;
        }
    }

	printf("HelixOverWebkit [%s] [%s] [%d]\n", __FILE__, __FUNCTION__, __LINE__);
    if (FAILED(retVal))
    {
        CleanupPlaybackEngine();
        m_LastError = retVal;
    }
    else
    {
        m_Init = 0;
    }
	printf("HelixOverWebkit [%s] [%s] [%d]\n setupplaybackengine ends retVal %x\n", __FILE__, __FUNCTION__, __LINE__, retVal);
    if (retVal != HXR_OK)
    	return false;
}
Ejemplo n.º 12
0
STDMETHODIMP HXCloakedV2TCPSocket::ResponseReady( HX_RESULT res, IHXRequest* pRequestResponse)
{
    IHXCommonClassFactory* pCCF       = NULL;
    IHXRegistry*           pRegistry  = NULL;
    IHXValues*             pHeaders   = NULL;
    const char*            pName      = NULL;
    IHXBuffer*             pBuf       = NULL;
    CHXString              key        = "";
    IHXBuffer*             pTmpBuffer = NULL;

    if( SUCCEEDED(res) )
    {
        //Extract the authentication info, again, this is a real waste to just
        //get a username password. See comment in _DoProxyAuthentication.
        res = m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF);
        if( SUCCEEDED(res) )
        {
            res = m_pContext->QueryInterface(IID_IHXRegistry, (void**)&pRegistry);
            if( SUCCEEDED(res) )
            {
                res = pRequestResponse->GetRequestHeaders(pHeaders);
                if( SUCCEEDED(res) )
                {
                    res = pHeaders->GetFirstPropertyCString(pName, pBuf);
                    while( SUCCEEDED(res) && pBuf )
                    {
                        if( !strcasecmp(pName, "Proxy-Authorization") )
                        {
                            CHXString  key = "proxy-authentication.http:";
                            key += m_pszProxyName;
                            key += ":";
                            res = pRegistry->GetStrByName( "proxy-authentication.http.realm.recent",
                                                           pTmpBuffer);
                            if( SUCCEEDED(res) )
                            {
                                key += CHXString((const char*)pTmpBuffer->GetBuffer(),
                                                 pTmpBuffer->GetSize());
                            }
                            HX_RELEASE(pTmpBuffer);

                            res = pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pTmpBuffer);
                            if( SUCCEEDED(res) )
                            {
                                pTmpBuffer->Set(pBuf->GetBuffer(), pBuf->GetSize());
                                
                                UINT32 regid = pRegistry->GetId((const char*)key);
                                if (!regid)
                                {
                                    pRegistry->AddStr((const char*)key, pTmpBuffer);
                                }
                                else
                                {
                                    pRegistry->SetStrByName((const char*)key, pTmpBuffer);
                                }
                            }
                            HX_RELEASE(pTmpBuffer);
                            break;
                        }

                        // get next header name value line
                        HX_RELEASE(pBuf);
                        res = pHeaders->GetNextPropertyCString(pName, pBuf);
                    }
                    HX_RELEASE(pBuf);
                    HX_RELEASE(pHeaders);
                }
            }
            HX_RELEASE(pRegistry);
        }
        HX_RELEASE(pCCF);
    }
    
    HX_RELEASE(pRequestResponse);

    //We need to start over connting again....
    m_CloakingState = csDisconnected;
    if( m_pTCPSocket)
    {
        m_pTCPSocket->Close();
        HX_RELEASE(m_pTCPSocket);
    }
    
    res = m_pNetworkServices->CreateSocket(&m_pTCPSocket);
    if(m_pTCPSocket && SUCCEEDED(res) )
    {
        res = m_pTCPSocket->SetResponse(this);
        if( SUCCEEDED(res) )
        {
            res = m_pTCPSocket->Init(m_family, m_type, m_protocol);
            m_pTCPSocket->SetOption( HX_SOCKOPT_APP_BUFFER_TYPE,
                                     HX_SOCKBUF_DEFAULT);
            m_pTCPSocket->SelectEvents(HX_SOCK_EVENT_READ|
                                       HX_SOCK_EVENT_CONNECT|
                                       HX_SOCK_EVENT_CLOSE);
        
            res = m_pTCPSocket->ConnectToOne(m_pDestAddr);
        }
    }

    return res;
}
Ejemplo n.º 13
0
HX_RESULT HXCloakedV2TCPSocket::_DoProxyAuthentication(HTTPResponseMessage* pMess)
{
    HX_RESULT                  res              = HXR_FAIL;
    IHXCommonClassFactory*     pCCF             = NULL;
    CHXString                  getStr           = "";
    IHXKeyValueList*           pRespHeaders     = NULL;
    MIMEHeaderValue*           pHeaderValue     = NULL;
    MIMEHeader*                pHeader          = NULL;
    CHXString                  strHeader        = "";
    CHXString                  strTemp          = "";
    IHXBuffer*                 pBuffer          = NULL;
    IHXRequest*                pRequest         = NULL;
    IHXValues*                 pValues          = NULL;             
    IHXClientAuthConversation* pClientAuth      = NULL;
    IUnknown*                  pUnkConfig       = NULL;
    IHXObjectConfiguration*    pConfig          = NULL;


    //////////////////////
    //
    // XXXgfw I really don't think we need all this authentication
    // garbage.  It really seems we only need to TLC to just give us a
    // dialog to do a user/pass request. It sure seems like this code
    // below is way overkill. Just check out ResponseReady(), the only
    // thing is needs from all this is just that one string. Oh well,
    // until I have time to figure out exactly how this all works (all
    // the calls through the core and into the TLC from here) I will
    // just leave it like the original cloaking.
    //
    //////////////////////
    
    res = m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF);
    if( SUCCEEDED(res) )
    {
        //pRequest will be freed in the ResponseReady() method.
        res = pCCF->CreateInstance(CLSID_IHXRequest, (void**)&pRequest);
        if( SUCCEEDED(res) )
        {
            getStr = _GenerateGetRequest();
            pRequest->SetURL((const char*)getStr); //Always returns HXR_OK;
            
            res = pCCF->CreateInstance(CLSID_IHXKeyValueList, (void**)&pRespHeaders);
            if( SUCCEEDED(res) )
            {
                
                pHeader = pMess->getFirstHeader();
                while (pHeader)
                {
                    pHeaderValue = pHeader->getFirstHeaderValue();
                    strHeader = "";
                    while( pHeaderValue )
                    {
                        pHeaderValue->asString(strTemp);
                        strHeader += strTemp;
                        pHeaderValue = pHeader->getNextHeaderValue();
                        if (pHeaderValue)
                        {
                            strHeader += ", ";
                        }
                    }
                    pBuffer = NULL;
                    CHXBuffer::FromCharArray((const char*)strHeader, &pBuffer);
                    if( pBuffer )
                    {
                        pRespHeaders->AddKeyValue(pHeader->name(), pBuffer);
                    }
                    HX_RELEASE(pBuffer);
                    pHeader = pMess->getNextHeader();
                }

                pValues = NULL;
                if (HXR_OK == pRespHeaders->QueryInterface(IID_IHXValues, (void**)&pValues))
                {
                    pRequest->SetResponseHeaders(pValues);
                }
                HX_RELEASE(pValues);
            }

            HX_RELEASE(pRespHeaders);

            if (HXR_OK == pRequest->GetResponseHeaders(pValues))
            {
                res = pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pBuffer);
                if (SUCCEEDED(res))
                {
                    pBuffer->Set((UCHAR*)m_pszProxyName, strlen(m_pszProxyName)+1);
                    pValues->SetPropertyCString("_server", pBuffer);
                    HX_RELEASE(pBuffer);
                }

                // Add the protocol to the response headers because TLC needs it
                if (SUCCEEDED(pCCF->CreateInstance(CLSID_IHXBuffer, (void**)&pBuffer)))
                {
                    pBuffer->Set((UCHAR*)"http", strlen("http") + 1);
                    pValues->SetPropertyCString("_protocol", pBuffer);
                    HX_RELEASE(pBuffer);
                }

                HX_RELEASE(pValues);
            }

            //We now need a CCF from the cloaking context, not our core's context.
            HX_RELEASE(pCCF);


            res = m_pCloakContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF);
            if(SUCCEEDED(res))
            {
                res = pCCF->CreateInstance( CLSID_CHXClientAuthenticator, (void**)&pUnkConfig );
                if(SUCCEEDED(res))
                {
                    res = pUnkConfig->QueryInterface(IID_IHXClientAuthConversation, 
                                                     (void**)&pClientAuth);
                    if (SUCCEEDED(res))
                    {
                        res = pUnkConfig->QueryInterface(IID_IHXObjectConfiguration,
                                                         (void**)&pConfig);
                        if (SUCCEEDED(res))
                        {
                            pConfig->SetContext(m_pCloakContext);
                            HX_RELEASE(pConfig);
                        }

                        if ( pClientAuth && !pClientAuth->IsDone() )
                        {
                            HX_ASSERT(pRequest);
                            //After this if/else, we continue in ResponseReady() after
                            //the TLC calls us back.
                            if (pRequest)
                            {
                                res = pClientAuth->MakeResponse(this, pRequest);
                            }
                            else
                            {
                                // Auth Failed!
                                pClientAuth->Authenticated(FALSE);
                                res = HXR_NOT_AUTHORIZED;
                                res = ResponseReady(res, pRequest);
                            }
                        }
                    }
                    HX_RELEASE(pUnkConfig);
                }
                HX_RELEASE(pCCF);
            }
        }
    }

    //We return this in all cases. the connection will be started over in
    //the ResponseReady() method.
    res = HXR_NOT_AUTHORIZED;
    return res;
}