chxavmediafolderinfo.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:4k
源码类别:
Symbian
开发平台:
Visual C++
- /************************************************************************
- * chxavmediafolderinfo.cpp
- * ------------------------
- *
- * Synopsis:
- * encapsulates info for a given folder being displayed in the file view window
- *
- * Target:
- * Symbian OS
- *
- *
- * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- *****************************************************************************/
- // Symbian includes...
- #include <bautils.h>
- // Helix includes...
- #include "hxassert.h"
- // Include from this project...
- #include "chxavfileutil.h"
- #include "chxavmediafolderinfo.h"
- ///////////////////////////////////
- // ctor
- CHXAvMediaFolderInfo::CHXAvMediaFolderInfo()
- {
- }
- ///////////////////////////////////
- // dtor
- CHXAvMediaFolderInfo::~CHXAvMediaFolderInfo()
- {
- }
- ///////////////////////////////////
- // update drive info
- //
- // return flags indicating if drive state has changed since last - mostly
- // for checking mounting/unmounting of drive (removable mmc)
- //
- TUint32 CHXAvMediaFolderInfo::UpdateDriveInfoCheckState()
- {
- CHXAvFile::DriveInfo oldInfo = m_driveInfo;
- m_driveInfo = CHXAvFile::GetDriveInfo(*m_spRootPath);
- TUint32 flags(0);
- if(m_driveInfo.state != oldInfo.state)
- {
- flags |= STATE_CHANGED;
- }
- if( oldInfo.volInfo.iUniqueID != m_driveInfo.volInfo.iUniqueID)
- {
- flags |= VOLID_CHANGED;
- }
- return flags;
- }
- ///////////////////////////////////
- // mainly for checking cases where current path is externally deleted/renamed
- bool CHXAvMediaFolderInfo::IsCurrentPathValid() const
- {
- TFileName* pPath = CHXAvFile::AllocFileNameL(GetRoot(), GetCurrentPath(), CHXAvFile::ntFolder);
- AUTO_PUSH_POP_DEL(pPath);
- return CHXAvFile::PathExists(*pPath);
- }
- ///////////////////////////////////
- // path relative to root
- void CHXAvMediaFolderInfo::SetCurrentPathL(const TDesC& path)
- {
- if( path != KNullDesC )
- {
- m_spCurrentPath = path.AllocL();
- }
- else
- {
- m_spCurrentPath = CHXAvUtil::KPathSep().AllocL();
- }
- }
- ///////////////////////////////////
- //
- void CHXAvMediaFolderInfo::InitL(const TDesC& rootPath, PathCreateType pathType)
- {
- m_spRootPath = rootPath.AllocL();
- if( PATH_ENSURE == pathType )
- {
- // we leave if path cannot be created (in case where it does not exist)
- RFs& fs = CCoeEnv::Static()->FsSession();
- BaflUtils::EnsurePathExistsL(fs, *m_spRootPath);
- }
- SetCurrentPathL(KNullDesC);
- UpdateDriveInfo();
- }
- ////////////////////////////////////////////////////
- //
- // allocate descriptive text for this folder; mainly
- // for single-line list text
- //
- HBufC* CHXAvMediaFolderInfo::AllocListDescriptionL() const
- {
- HBufC* pbuff = 0;
- if( IsMmcFolder() && m_driveInfo.bVolInfoValid
- && m_driveInfo.volInfo.iName.Length() > 0)
- {
- pbuff = m_driveInfo.volInfo.iName.AllocL();
- }
- else
- {
- TInt resId = -1;
- switch(m_driveInfo.state)
- {
- case CHXAvFile::dsAccessible:
- resId = IsMmcFolder() ? R_AVP_QUERY_LIST_TEXT_MMC_MEMORY : R_AVP_QUERY_LIST_TEXT_PHONE_MEMORY;
- break;
- case CHXAvFile::dsLocked:
- // only mmc can be locked
- HX_ASSERT(IsMmcFolder());
- resId = R_AVP_QUERY_LIST_TEXT_MMC_MEMORY; //R_CFD_QTN_MEMC_MMC_LOCKED;
- break;
- default:
- // only mmc may be unavailable or otherwise not accessible
- HX_ASSERT(IsMmcFolder());
- resId = R_AVP_QUERY_LIST_TEXT_MMC_MEMORY; //R_CFD_QTN_MEMC_MMC_UNAVAILABLE;
- break;
- }
- pbuff = CEikonEnv::Static()->AllocReadResourceL(resId);
- }
- return pbuff;
- }