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

📄 contentdirectoryservice.cpp

📁 Windows CE 6.0 Server 源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
{
    return S_OK;
}


STDMETHODIMP ContentDirectoryServiceImpl::get_A_ARG_TYPE_URI(BSTR* pA_ARG_TYPE_URI)
{
    return S_OK;
}



STDMETHODIMP ContentDirectoryServiceImpl::get_SearchCapabilities(BSTR* pSearchCapabilities)
{
    if(!pSearchCapabilities)
        return E_POINTER;

    if(!m_pContentDirectory)
        return m_ErrReport.ReportError(ERROR_AV_UPNP_ACTION_FAILED);


    // Setup arguments for call to IContentDirectory
    wstring strSearchCapabilities;

    // Make the call
    const DWORD retPFC = m_pContentDirectory->GetSearchCapabilities(&strSearchCapabilities);
    if(SUCCESS_AV != retPFC)
        return m_ErrReport.ReportError(retPFC);

    // Set out arg
    *pSearchCapabilities = SysAllocString(strSearchCapabilities);
    if(!*pSearchCapabilities)
        return m_ErrReport.ReportError(ERROR_AV_OOM);
    

    return S_OK;
}


STDMETHODIMP ContentDirectoryServiceImpl::get_SortCapabilities(BSTR* pSortCapabilities)
{
    if(!pSortCapabilities)
        return E_POINTER;

    if(!m_pContentDirectory)
        return m_ErrReport.ReportError(ERROR_AV_UPNP_ACTION_FAILED);


    // Setup arguments for call to IContentDirectory
    wstring strSortCapabilities;

    // Make the call
    const DWORD retPFC = m_pContentDirectory->GetSortCapabilities(&strSortCapabilities);
    if(SUCCESS_AV != retPFC)
        return m_ErrReport.ReportError(retPFC);

    // Set out arg
    *pSortCapabilities = SysAllocString(strSortCapabilities);
    if(!*pSortCapabilities)
        return m_ErrReport.ReportError(ERROR_AV_OOM);
    

    return S_OK;
}


STDMETHODIMP ContentDirectoryServiceImpl::get_SystemUpdateID(unsigned long* pSystemUpdateID)
{
    if(!pSystemUpdateID)
        return E_POINTER;

    if(!m_pContentDirectory)
        return m_ErrReport.ReportError(ERROR_AV_UPNP_ACTION_FAILED);

    const DWORD retPFC = m_pContentDirectory->GetSystemUpdateID(pSystemUpdateID);
    
    if(SUCCESS_AV != retPFC)
        return m_ErrReport.ReportError(retPFC);

    return S_OK;
}


STDMETHODIMP ContentDirectoryServiceImpl::get_ContainerUpdateIDs(BSTR* pContainerUpdateIDs)
{
    // Though "ContentDirectory:1 Service Template Version 1.01", p18, s2.5.21 states ctrl points should use this variable
    // only for eventing, we implement it to allow ce's upnp to get the value when we do an IUPnPEventSink->OnStateChanged(),
    // and do not disallow ctrl points getting if they wish
    
    ce::gate<ce::critical_section> csEventsLock(m_csEvents);

    wstring strValue;
    
    for(ContainerUpdateIDsMap::iterator it = m_mapContainerUpdateIDs.begin(), itEnd = m_mapContainerUpdateIDs.end(); it != itEnd; ++it)
    {
        if(!strValue.empty())
            strValue += AVDCPListDelimiter;
        
        strValue += it->first;
        strValue += AVDCPListDelimiter;
        strValue += it->second;
    }
    
    *pContainerUpdateIDs = SysAllocString(strValue);
    
    if(!*pContainerUpdateIDs)
        return m_ErrReport.ReportError(ERROR_AV_OOM);

    return S_OK;
}



STDMETHODIMP ContentDirectoryServiceImpl::GetSearchCapabilities(BSTR* pSearchCaps)
{
    return get_SearchCapabilities(pSearchCaps);
}


STDMETHODIMP ContentDirectoryServiceImpl::GetSortCapabilities(BSTR* pSortCaps)
{
    return get_SortCapabilities(pSortCaps);
}


STDMETHODIMP ContentDirectoryServiceImpl::GetSystemUpdateID(unsigned long* pId)
{
    return get_SystemUpdateID(pId);
}


STDMETHODIMP ContentDirectoryServiceImpl::Browse(BSTR           ObjectID,
                                                 BSTR           BrowseFlag,
                                                 BSTR           Filter,
                                                 unsigned long  StartingIndex,
                                                 unsigned long  RequestedCount,
                                                 BSTR           SortCriteria,
                                                 BSTR*          pResult,
                                                 unsigned long* pNumberReturned,
                                                 unsigned long* pTotalMatches,
                                                 unsigned long* pUpdateID)
{
    if(!pResult || !pNumberReturned || !pTotalMatches || !pUpdateID)
        return E_POINTER;

    if(!m_pContentDirectory)
        return m_ErrReport.ReportError(ERROR_AV_UPNP_ACTION_FAILED);


    // Setup arguments common to both ICD::Browse calls for call to IContentDirectory
    wstring strObjectID, strBrowseFlag, strFilter;
    wstring strResult;
    
    if(   !strObjectID.assign(ObjectID,     SysStringLen(ObjectID))
       || !strBrowseFlag.assign(BrowseFlag, SysStringLen(BrowseFlag))
       || !strFilter.assign(Filter,         SysStringLen(Filter))   )
        return m_ErrReport.ReportError(ERROR_AV_OOM);


    // Decide whether to call BrowseMetadata or BrowseChildren, setup function-specific args, and call

    LPCWSTR pszBrowseFlag_Metadata       = L"BrowseMetadata",
            pszBrowseFlag_DirectChildren = L"BrowseDirectChildren";

    if(strBrowseFlag == pszBrowseFlag_Metadata)
    {
        // Make the call
        const DWORD retPFC = m_pContentDirectory->BrowseMetadata(strObjectID, strFilter, &strResult, pUpdateID);
        if(SUCCESS_AV != retPFC)
            return m_ErrReport.ReportError(retPFC);

        // Set NumberReturned and TotalMatches to one, "ContentDirectory:1 Service Template Version 1.01", p23, table 2.7.4.2
        *pNumberReturned = 1;
        *pTotalMatches   = 1;
    }
    else if(strBrowseFlag == pszBrowseFlag_DirectChildren)
    {
        // Setup argument
        wstring strSortCriteria;
        if(!strSortCriteria.assign(SortCriteria, SysStringLen(SortCriteria)))
            return m_ErrReport.ReportError(ERROR_AV_OOM);
 

        // Make the call
        const DWORD retPFC = m_pContentDirectory->BrowseChildren(strObjectID,
                                                                 strFilter,
                                                                 StartingIndex,
                                                                 RequestedCount,
                                                                 strSortCriteria,
                                                                 &strResult,
                                                                 pNumberReturned,
                                                                 pTotalMatches,
                                                                 pUpdateID);
        if(SUCCESS_AV != retPFC)
            return m_ErrReport.ReportError(retPFC);
    }
    else
    {
        // Invalid BrowseFlag
        return m_ErrReport.ReportError(ERROR_AV_UPNP_CD_REQUEST_FAILED);
    }

    
    // Set out args
    *pResult = SysAllocString(strResult);
    if(!*pResult)
        return m_ErrReport.ReportError(ERROR_AV_OOM);
    

    return S_OK;
}


STDMETHODIMP ContentDirectoryServiceImpl::Search(BSTR          ContainerID,
                                                 BSTR          SearchCriteria,
                                                 BSTR          Filter,
                                                 unsigned long StartingIndex,
                                                 unsigned long RequestedCount,
                                                 BSTR          SortCriteria,
                                                 BSTR*          pResult,
                                                 unsigned long* pNumberReturned,
                                                 unsigned long* pTotalMatches,
                                                 unsigned long* pUpdateID)
{
    if(!pResult || !pNumberReturned || !pTotalMatches || !pUpdateID)
        return E_POINTER;

    if(!m_pContentDirectory)
        return m_ErrReport.ReportError(ERROR_AV_UPNP_ACTION_FAILED);


    // Setup arguments for call to IContentDirectory
    wstring strContainerID, strSearchCriteria, strFilter, strSortCriteria;
    wstring strResult;

    if(   !strContainerID.assign(ContainerID,       SysStringLen(ContainerID))
       || !strSearchCriteria.assign(SearchCriteria, SysStringLen(SearchCriteria))
       || !strFilter.assign(Filter,                 SysStringLen(Filter))
       || !strSortCriteria.assign(SortCriteria,     SysStringLen(SortCriteria))   )
        return m_ErrReport.ReportError(ERROR_AV_OOM);


    // Make the call
    const DWORD retPFC = m_pContentDirectory->Search(strContainerID,
                                                     strSearchCriteria,
                                                     strFilter,
                                                     StartingIndex,
                                                     RequestedCount,
                                                     strSortCriteria,
                                                     &strResult,
                                                     pNumberReturned,
                                                     pTotalMatches,
                                                     pUpdateID);
    if(SUCCESS_AV != retPFC)
        return m_ErrReport.ReportError(retPFC);


    // Set out arg
    *pResult = SysAllocString(strResult);
    if(!*pResult)
        return m_ErrReport.ReportError(ERROR_AV_OOM);
    

    return S_OK;
}


STDMETHODIMP ContentDirectoryServiceImpl::CreateObject(BSTR ContainerID,
                                                       BSTR Elements,
                                                       BSTR* pObjectID,
                                                       BSTR* pResult)
{
    if(!pObjectID || !pResult)
        return E_POINTER;

    if(!m_pContentDirectory)
        return m_ErrReport.ReportError(ERROR_AV_UPNP_ACTION_FAILED);


    // Setup arguments for call to IContentDirectory
    wstring strContainerID, strElements;
    wstring strObjectID, strResult;

    if(   !strContainerID.assign(ContainerID, SysStringLen(ContainerID))
       || !strElements.assign(Elements, SysStringLen(Elements))   )
        return m_ErrReport.ReportError(ERROR_AV_OOM);


    // Make the call
    const DWORD retPFC = m_pContentDirectory->CreateObject(strContainerID, strElements, &strObjectID, &strResult);
    if(SUCCESS_AV != retPFC)
        return m_ErrReport.ReportError(retPFC);


    // Set out args
    if(   !(*pObjectID = SysAllocString(strObjectID))
        ||!(*pResult   = SysAllocString(strResult))   ) 
        return m_ErrReport.ReportError(ERROR_AV_OOM);
    

    return S_OK;
}


STDMETHODIMP ContentDirectoryServiceImpl::DestroyObject(BSTR ObjectID)
{
    if(!m_pContentDirectory)
        return m_ErrReport.ReportError(ERROR_AV_UPNP_ACTION_FAILED);


    // Setup arguments to call to IContentDirectory
    wstring strObjectID;
    if(!strObjectID.assign(ObjectID, SysStringLen(ObjectID)))
        return m_ErrReport.ReportError(ERROR_AV_OOM);


    // Make the call
    const DWORD retPFC = m_pContentDirectory->DestroyObject(strObjectID);
    if(SUCCESS_AV != retPFC)
        return m_ErrReport.ReportError(retPFC);
    

    return S_OK;
}

⌨️ 快捷键说明

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