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

📄 storage.cpp

📁 基于EP7312的MP3播放器源代码,包括MCU和PC端代码.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    // Success.
    //
    return(S_OK);
}

//****************************************************************************
//
// The IMDSPStorage::GetStorageGlobals method, which returns the
// IMDSPStorageGlobals interface which provides access to global information
// about the storage medium.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::GetStorageGlobals(IMDSPStorageGlobals **ppStorageGlobals)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If we were passed a NULL pointer, then return a failure.
    //
    if(!ppStorageGlobals)
    {
        return(E_INVALIDARG);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // Get the storage globals object for this drive/file.
    //
    *ppStorageGlobals = g_MaverickInfo.GetStorageGlobals(m_ulDrive);

    //
    // Success.
    //
    return(*ppStorageGlobals ? S_OK : E_FAIL);
}

//****************************************************************************
//
// The IMDSPStorage::SendOpaqueCommand method, which sends an unmodified
// command to this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::SendOpaqueCommand(OPAQUECOMMAND *pCommand)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support any opaque commands at this time.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPStorage::SetAttribute method, which sets the attributes of this
// storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::SetAttributes(DWORD dwAttributes, _WAVEFORMATEX *pFormat)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If we were passed a NULL pointer, then return a failure.
    //
    if(pFormat)
    {
        return(E_INVALIDARG);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not allow the attributes of the files to be modified, so simply
    // return success.
    //
    return(S_OK);
}

//****************************************************************************
//
// The IMDSPObjectInfo::GetLastPlayPosition method, which returns the last
// play position of this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::GetLastPlayPosition(DWORD *pdwLastPos)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If we were passed a NULL pointer, then return a failure.
    //
    if(!pdwLastPos)
    {
        return(E_INVALIDARG);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support returning the last play position.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPObjectInfo::GetLongestPlayPosition method, which returns the
// longest play position of this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::GetLongestPlayPosition(DWORD *pdwLongestPos)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If we were passed a NULL pointer, then return a failure.
    //
    if(!pdwLongestPos)
    {
        return(E_INVALIDARG);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support returning the longest play position.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPObjectInfo::GetPlayLength method, which returns the play length of
// this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::GetPlayLength(DWORD *pdwLength)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If we were passed a NULL pointer, then return a failure.
    //
    if(!pdwLength)
    {
        return(E_INVALIDARG);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support returning the play length.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPObjectInfo::GetPlayOffset method, which returns the current play
// offset of this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::GetPlayOffset(DWORD *pdwOffset)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If we were passed a NULL pointer, then return a failure.
    //
    if(!pdwOffset)
    {
        return(E_INVALIDARG);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support returning the play offset.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPObjectInfo::GetTotalLength method, which returns the total play
// length of this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::GetTotalLength(DWORD *pdwLength)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If we were passed a NULL pointer, then return a failure.
    //
    if(!pdwLength)
    {
        return(E_INVALIDARG);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support returning the total length.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPObjectInfo::SetPlayLength method, which sets the play length of
// this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::SetPlayLength(DWORD dwLength)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support setting the play length.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPObjectInfo::SetPlayOffset method, which sets the current play
// offset of this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::SetPlayOffset(DWORD dwOffset)
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We do not support setting the play offset.
    //
    return(WMDM_E_NOTSUPPORTED);
}

//****************************************************************************
//
// The IMDSPObject::Close method, which closes this storage object.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::Close()
{
    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        return(S_FALSE);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // If this storage object is not opened, then return a failure.
    //
    if(!m_bIsOpen)
    {
        return(E_FAIL);
    }

    //
    // Close the file.
    //
    Maverick_Close();

    //
    // Indicate that this storage object is no longer opened.
    //
    m_bIsOpen = FALSE;

    //
    // Refresh the Maverick info database.
    //
    g_MaverickInfo.Refresh(m_ulDrive);

    //
    // Success.
    //
    return(S_OK);
}

//****************************************************************************
//
// The IMDSPObject::Delete method, which deletes this storage object from the
// storage medium.
//
//****************************************************************************
STDMETHODIMP
CMDSPStorage::Delete(UINT fuMode, IWMDMProgress *pProgress)
{
    HRESULT hr;

    //
    // If there is a progress object, then initialize it now.
    //
    if(pProgress)
    {
        //
        // Indicate that the delete is beginning.
        //
        pProgress->Begin(100);
    }

    //
    // If we do not have a secure channel server object, then return a failure.
    //
    if(!g_pAppSCServer)
    {
        if(pProgress)
        {
            pProgress->Progress(100);
            pProgress->End();
        }
        return(E_FAIL);
    }

    //
    // If we are not authenticated, then return a failure.
    //
    if(!(g_pAppSCServer->fIsAuthenticated()))
    {
        if(pProgress)
        {
            pProgress->Progress(100);
            pProgress->End();
        }
        return(WMDM_E_NOTCERTIFIED);
    }

    //
    // If this storage object has been deleted, then return a failure.
    //
    if(!m_pwcName[0])
    {
        if(pProgress)
        {
            pProgress->Progress(100);
            pProgress->End();
        }
        return(WMDM_E_INTERFACEDEAD);
    }

    //
    // We can not delete the root storage.
    //
    if(m_bIsRoot)
    {
        if(pProgress)
        {
            pProgress->Progress(100);
            pProgress->End();
        }
        return(E_FAIL);
    }

    //
    // If this file is currently opened, then we need to close it now.
    //
    if(m_bIsOpen)
    {
        //
        // Close this file.
        //
        Maverick_Close();

        //
        // Inidicate that this file is closed.
        //
        m_bIsOpen = FALSE;
    }

    //
    // Delete this file.
    //
    if(Maverick_Delete(m_ulDrive, m_pwcName) == 1)
    {
        //
        // Remove any Audible meta-data associated with this file.
        //
        RemoveAudibleMetaData(m_ulDrive, m_pwcName);

        //
        // Indicate that this file has been deleted.
        //
        m_pwcName[0] = '\0';

        //
        // Refresh the Maverick info database.
        //
        g_MaverickInfo.Refresh(m_ulDrive);

        //
        // The delete was successful.
        //
        hr = S_OK;
    }
    else
    {
        //
        // The delete failed.
        //

⌨️ 快捷键说明

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