⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sitemgr.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	    pSUS->Release();
	}
	
	HX_RELEASE(pUser);
	HX_RELEASE(pSite);
    }
    else if(m_SitesToSUS.Lookup(pSite, (void*&)pSUS))
    {
	m_SitesToSUS.RemoveKey(pSite);
	pSite->GetUser(pUser);
	pSite->DetachUser();
	if(pUser && pSUS)
	{
	    pSUS->DestroySiteUser(pUser);
	    pSUS->Release();
	}
	HX_RELEASE(pUser);
	HX_RELEASE(pSite);
    }
}

/************************************************************************
 *  Method:
 *    CHXSiteManager::UnhookAll
 */
void 
CHXSiteManager::UnhookAll()
{
     m_bInUnHookAll = TRUE;

    /*
     * To unhook all the items we simple run through the site users
     * we created, ask them for their site, tell the site to detach
     * from the user, and tell the site user supplier to destroy the
     * site user. That's simple enough...
     */
    CHXMapPtrToPtr::Iterator ndxSite = m_SitesToSUS.Begin();

    for (;  ndxSite != m_SitesToSUS.End(); ++ndxSite)
    {
	IHXSite*		pSite = (IHXSite*)ndxSite.get_key();
	IHXSiteUserSupplier*	pSUS  = (IHXSiteUserSupplier*)(*ndxSite);
	IHXSiteUser*		pUser = NULL;

	pSite->GetUser(pUser);
	/*
	 * Now actually unhook the site to the site user!
	 *
	 * NOTE: The IHXSite is responsible for calling the
	 *	     IHXSiteUser::DetachSite() method.
	 *
	 * NOTE: If this is a layout site user than it will
	 *	     destroy the child sites in responses to the
	 *	     DetachSite() method call.
	 */
	pSite->DetachUser();

	if (pSUS)
	{
	    if (pUser)
	    {
		pSUS->DestroySiteUser(pUser);
	    }

	    pSUS->Release();
	}
	
	HX_RELEASE(pUser);
	HX_RELEASE(pSite);
    }
    m_SitesToSUS.RemoveAll();

    CleanupPendingValues();
    m_bInUnHookAll = FALSE;
}


/************************************************************************
 *  Method:
 *    CHXSiteManager::HookupSingleSiteByLSGNameWithString
 */
BOOL 
CHXSiteManager::HookupSingleSiteByLSGNameWithString
(
    IHXSiteUser*	    pSU,
    char*		    pActualString,
    BOOL		    bIsPersistent
)
{
    BOOL res = FALSE;
    
    if(bIsPersistent)
    {
	res = HookupSingleSiteByStringHelper(pActualString,m_PersistentLSGNamesToLists,pSU,bIsPersistent);
	if(!res)
	{
	    // check for existence of string in non-persistent list, then move it if it exists
	    void* pVoid = NULL;
	    if(m_LSGNamesToLists.Lookup(pActualString, pVoid))
	    {
		m_LSGNamesToLists.RemoveKey(pActualString);
		m_PersistentLSGNamesToLists.SetAt(pActualString, pVoid);
		res = HookupSingleSiteByStringHelper(pActualString,m_PersistentLSGNamesToLists,
		    pSU,bIsPersistent);
	    }
	}
    }
    else
    {
	res = HookupSingleSiteByStringHelper(pActualString,m_LSGNamesToLists,pSU,bIsPersistent);
    }
    return res;
}


/************************************************************************
 *  Method:
 *    CHXSiteManager::HookupSingleSiteByLSGName
 */
BOOL 
CHXSiteManager::HookupSingleSiteByLSGName
(
    IHXSiteUser*	    pSU,
    IHXValues*		    pProps,
    BOOL		    bIsPersistent
)
{
    IHXBuffer*	    pValue = NULL;
    char*	    pActualString = NULL;
    HRESULT	    hresTemp;

    /*
     * This method is responsible for fully hooking up the
     * site user supplier with any and all sites associate with
     * it's LSG name. NOTE: The Properties passed in are those
     * of this site user supplier, so first thing is to map from
     * the appropriate property to the collection of sites having
     * that property. This is the same as the process for determining
     * availability.
     */
    hresTemp = pProps->GetPropertyCString("name",pValue);
    HX_ASSERT(HXR_OK == hresTemp);
    pActualString = (char*)pValue->GetBuffer();

    CHXSiteUserProxy* pProxy = new CHXSiteUserProxy(this,
	pSU, pActualString);
    pProxy->AddRef();

    BOOL res = HookupSingleSiteByLSGNameWithString(pProxy, pActualString, bIsPersistent);

    // when it fails, save the pProxy & pValue for pending hookup
    // which is done later during AddSite()
    if (!res)
    {
	m_PendingValueToSUSingleLSG.SetAt(pValue, pProxy);
    }
    else
    {
        pValue->Release();
	pProxy->Release();	// now owned by hookup list
    }

    return res;
}


/************************************************************************
 *  Method:
 *    CHXSiteManager::HookupSingleSiteByPlayToFromWithString
 */
BOOL
CHXSiteManager::HookupSingleSiteByPlayToFromWithString
(
    IHXSiteUser*	    pSU,
    char*		    pActualString,
    BOOL		    bIsPersistent
)
{
    BOOL res = FALSE;
    if(bIsPersistent)
    {
	res = HookupSingleSiteByStringHelper(pActualString,m_PersistentChannelsToLists,pSU,bIsPersistent);
	if(!res)
	{
	    // check for existence of string in non-persistent list, then move it if it exists
	    void* pVoid = NULL;
	    if(m_ChannelsToLists.Lookup(pActualString, pVoid))
	    {
		m_ChannelsToLists.RemoveKey(pActualString);
		m_PersistentChannelsToLists.SetAt(pActualString, pVoid);
		res = HookupSingleSiteByStringHelper(pActualString,m_PersistentChannelsToLists,
		    pSU,bIsPersistent);
	    }
	}
    }
    else
    {
	res = HookupSingleSiteByStringHelper(pActualString,m_ChannelsToLists,pSU,bIsPersistent);
    }
    return res;
}

//////////////////////
// JEB: Add ret value 

/************************************************************************
 *  Method:
 *    CHXSiteManager::HookupSingleSiteByPlayToFrom
 */
BOOL
CHXSiteManager::HookupSingleSiteByPlayToFrom
(
    IHXSiteUser*	    pSU,
    IHXValues*		    pProps,
    BOOL		    bIsPersistent
)
{
    IHXBuffer*	    pValue = NULL;
    char*	    pActualString = NULL;
    HRESULT	    hresTemp;

    /*
     * The properties passed here are the properties of the
     * site user not the site. When associating by PlayToFrom
     * the site's "channel" property must match the site
     * users "playto" property. So we get the "playto" property
     * from the props and look it in our Channel list.
     */
    hresTemp = pProps->GetPropertyCString("playto",pValue);
    HX_ASSERT(HXR_OK == hresTemp);
    pActualString = (char*)pValue->GetBuffer();

    CHXSiteUserProxy* pProxy = new CHXSiteUserProxy(this,
	pSU, pActualString);
    pProxy->AddRef();

    BOOL res = HookupSingleSiteByPlayToFromWithString(pProxy, pActualString, bIsPersistent);
    // when it fails, save the pProxy & pValue for pending hookup
    // which is done later during AddSite()
    if (!res)
    {
	m_PendingValueToSUSinglePlayTo.SetAt(pValue, pProxy);
    }
    else
    {
	pProxy->Release();	// now owned by hookup list
        pValue->Release();
    }

    return res;
}

/************************************************************************
 *  Method:
 *    IHXSiteManager::HookupSingleSiteByStringHelper
 */
BOOL
CHXSiteManager::HookupSingleSiteByStringHelper
(
    const char*		    pString,
    CHXMapStringToOb&	    ByStringMap,
    IHXSiteUser*	    pSU,
    BOOL		    bIsPersistent
)
{
    void*			pVoid = NULL;
    CHXMapPtrToPtr*		pSiteCollection = NULL;
    CHXMapPtrToPtr::Iterator	ndxSite;
    IHXSite*			pSite = NULL;
    IHXSiteWindowed*		pSiteWindowed = NULL;
    IHXSiteUser*		pUser = pSU;
    BOOL			bWindowed = FALSE;
    BOOL			bNeedsWindowed = FALSE;

    /*
     * The basic data structure is as follows: A map is kept 
     * from names to "lists" of sites. We don't actually use
     * a list because we want to quickly detect if the item is
     * already in the list so we use a map for the sites as well.
     */

    /*
     * Find the list in the name to list map, if there is no
     * list in the map then we know it is surely not available.
     */
    if (!ByStringMap.Lookup(pString,pVoid))
    {
	/* We may get back site from the site supplier at a later time due to 
	 * asynchronous nature. Make this request pending and we will try 
	 * to HookupSingleSiteByStringHelper from within AddSite()
	 */
	return FALSE;
    }

    /*
     * Now that we have the collection of sites we want to actually
     * hook the site user supplier up to _THE_FIRST_ site in the collection.
     */
    pSiteCollection = (CHXMapPtrToPtr*)pVoid;

    ndxSite = pSiteCollection->Begin();

    pSite = (IHXSite*)(*ndxSite);

    /*
     * We need to find out if this site user needs windowed
     * sites. The first step is to determine if this is a
     * windowed site.
     */
    bWindowed = (HXR_OK == pSite->QueryInterface(
					IID_IHXSiteWindowed,
					(void**)&pSiteWindowed));

    HX_RELEASE(pSiteWindowed);
    
    /*
     * If the site user supplier needs windowed sites and this
     * site is windowed, or if the site user supplier can handle
     * windowless sites, then proceed.
     */
    bNeedsWindowed = pSU->NeedsWindowedSites();
    if (!bNeedsWindowed || (bNeedsWindowed && bWindowed))
    {

	/*
	 * Now actually hook up the site to the site user!
	 *
	 * NOTE: The IHXSite is responsible for calling the
	 *	     IHXSiteUser::AttachSite() method.
	 *
	 * NOTE: If this is a layout site user than it will
	 *	     create child site in response to the AttachSite()
	 *	     method call.
	 */
	pSite->AttachUser(pUser);

	/*
	 * We also record the site's that we have created users for
	 * here so that we can unhook everything the next time the
	 * layout is changed. We record the site user supplier
	 * that created the site user so that we can delete that user
	 * as well. NOTE: we shouldn't have already created this
	 * user!
	 */

	if(bIsPersistent)
	{
	    HX_ASSERT(!m_PersistentSitesToSUS.Lookup(pSite,pVoid));

	    /*
	     * NULL means no Site User supplier was provided.
	     */
	    m_PersistentSitesToSUS[pSite] = NULL;
	}
	else
	{
	    HX_ASSERT(!m_SitesToSUS.Lookup(pSite,pVoid));

	    /*
	     * NULL means no Site User supplier was provided.
	     */
	    m_SitesToSUS[pSite] = NULL;
	}
	pSite->AddRef();
    }

    return TRUE;
}

/************************************************************************
*	Method:
*	    CHXSiteManager::EventOccurred
*	Purpose:
*	  Pass the event to appropriate sites
*/
void 
CHXSiteManager::EventOccurred(HXxEvent* pEvent)
{
#if defined(_MACINTOSH) || defined(_MAC_UNIX)
    
    // xxxbobclark
    // first, try iterating through sites the old-fashioned way. If there are
    // any sites here then they'll be in the zm_SiteWindowedList list. If there
    // aren't, then try using the new pnvideo way.
    
    BOOL bHandledOldEvent = FALSE;
    
#if 0    /* XXX BOB PLEASE TAKE A LOOK */
    //determine which sites should get the event & send it over
    CHXSimpleList::Iterator ndxSite = CHXSiteWindowed::zm_SiteWindowedList.Begin();

    for (;  ndxSite != CHXSiteWindowed::zm_SiteWindowedList.End(); ++ndxSite)
    {
	zm_bWindowRemovedFromList = FALSE;

	CHXSiteWindowed* pSiteWindowed = (CHXSiteWindowed*)(*ndxSite);

	bHandledOldEvent = TRUE;
	
	pSiteWindowed->AddRef();
	pSiteWindowed->MacEventOccurred(pEvent);
	pSiteWindowed->Release();


	/* If a window was removed from this list, iterate again
	 * from the head. 
	 * This *hack* is to avoid O(n^2) processing of events. 
	 * It is required since a new URL may be opened from 
	 * within MacEventOccured() call resulting in 
	 * releasing one(or more) CHXSiteWindows.
	 * 
	 * Potential Problem: Same event may be given to the same 
	 * window more than once.
	 */
	if (zm_bWindowRemovedFromList)
	{
	    zm_bWindowRemovedFromList = FALSE;
	    ndxSite = CHXSiteWindowed::zm_SiteWindowedList.Begin();
	}
    }
#endif

    if (!bHandledOldEvent)
    {
	CHXSimpleList::Iterator siteManagerNdx = zm_SiteManagerList.Begin();
	for (; siteManagerNdx != zm_SiteManagerList.End(); ++siteManagerNdx)
	{
	    CHXSiteManager* pSiteManager = (CHXSiteManager*)(*siteManagerNdx);
	    CHXMapPtrToPtr::Iterator ndx = pSiteManager->m_MasterListOfSites.Begin();
	    for (; ndx != pSiteManager->m_MasterListOfSites.End(); ++ndx)
	    {
		IHXSite* pSite = (IHXSite*)ndx.get_key();

		IHXSiteWindowless* pSiteWindowless = NULL;
		if (pSite->QueryInterface(IID_IHXSiteWindowless, (void**)&pSiteWindowless) == HXR_OK)
		{
		    pSiteWindowless->EventOccurred(pEvent);
		    pSiteWindowless->Release();
		}
	    }
	}
    }
#endif
}

/*
 * CHXEventHookElement methods
 */

CHXEventHookElement::CHXEventHookElement
(
    IHXEventHook*  pHook,
    UINT16	    uLayer
) : m_pHook(pHook)
  , m_uLayer(uLayer)
{
    HX_ASSERT(m_pHook);
    m_pHook->AddRef();
}

CHXEventHookElement::~CHXEventHookElement()
{
    HX_RELEASE(m_pHook);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -