chxavmediafolderinfo.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:4k
源码类别:

Symbian

开发平台:

Visual C++

  1. /************************************************************************
  2.  * chxavmediafolderinfo.cpp
  3.  * ------------------------
  4.  *
  5.  * Synopsis:
  6.  * encapsulates info for a given folder being displayed in the file view window
  7.  *
  8.  * Target:
  9.  * Symbian OS
  10.  *
  11.  *
  12.  * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
  13.  *
  14.  *****************************************************************************/
  15. // Symbian includes...
  16. #include <bautils.h>
  17. // Helix includes...
  18. #include "hxassert.h"
  19. // Include from this project...
  20. #include "chxavfileutil.h"
  21. #include "chxavmediafolderinfo.h"
  22. ///////////////////////////////////
  23. // ctor
  24. CHXAvMediaFolderInfo::CHXAvMediaFolderInfo()
  25. {
  26. }
  27. ///////////////////////////////////
  28. // dtor
  29. CHXAvMediaFolderInfo::~CHXAvMediaFolderInfo()
  30. {
  31. }
  32. ///////////////////////////////////
  33. // update drive info
  34. //
  35. // return flags indicating if drive state has changed since last - mostly
  36. // for checking mounting/unmounting of drive (removable mmc)
  37. //
  38. TUint32 CHXAvMediaFolderInfo::UpdateDriveInfoCheckState()
  39. {
  40.     CHXAvFile::DriveInfo oldInfo = m_driveInfo;
  41.     m_driveInfo = CHXAvFile::GetDriveInfo(*m_spRootPath);
  42.     TUint32 flags(0);
  43.     if(m_driveInfo.state != oldInfo.state)
  44.     {
  45.         flags |= STATE_CHANGED;
  46.     }
  47.     if( oldInfo.volInfo.iUniqueID != m_driveInfo.volInfo.iUniqueID)
  48.     {
  49.         flags |= VOLID_CHANGED;
  50.     }
  51.     
  52.     return flags;
  53. }
  54. ///////////////////////////////////
  55. // mainly for checking cases where current path is externally deleted/renamed
  56. bool CHXAvMediaFolderInfo::IsCurrentPathValid() const
  57. {    
  58.     TFileName* pPath = CHXAvFile::AllocFileNameL(GetRoot(), GetCurrentPath(), CHXAvFile::ntFolder);
  59.     AUTO_PUSH_POP_DEL(pPath);
  60.     return CHXAvFile::PathExists(*pPath);
  61. }
  62. ///////////////////////////////////
  63. // path relative to root
  64. void CHXAvMediaFolderInfo::SetCurrentPathL(const TDesC& path)
  65. {
  66.     if( path != KNullDesC )
  67.     {
  68.         m_spCurrentPath = path.AllocL();
  69.     }
  70.     else
  71.     {
  72.         m_spCurrentPath = CHXAvUtil::KPathSep().AllocL();
  73.     }
  74. }
  75. ///////////////////////////////////
  76. //
  77. void CHXAvMediaFolderInfo::InitL(const TDesC& rootPath, PathCreateType pathType)
  78. {
  79.     m_spRootPath = rootPath.AllocL();
  80.     
  81.     if( PATH_ENSURE == pathType )
  82.     {
  83.         // we leave if path cannot be created (in case where it does not exist)
  84.         RFs& fs = CCoeEnv::Static()->FsSession();
  85.         BaflUtils::EnsurePathExistsL(fs, *m_spRootPath);
  86.     }
  87.     SetCurrentPathL(KNullDesC);
  88.     UpdateDriveInfo();    
  89. }
  90. ////////////////////////////////////////////////////
  91. //
  92. // allocate descriptive text for this folder; mainly 
  93. // for single-line list text
  94. //
  95. HBufC* CHXAvMediaFolderInfo::AllocListDescriptionL() const
  96. {
  97.     HBufC* pbuff = 0;
  98.     if( IsMmcFolder() && m_driveInfo.bVolInfoValid 
  99.         && m_driveInfo.volInfo.iName.Length() > 0)
  100.     {
  101.         pbuff = m_driveInfo.volInfo.iName.AllocL();
  102.     }
  103.     else
  104.     {
  105.         TInt resId = -1;
  106.         switch(m_driveInfo.state)
  107.         {
  108.         case CHXAvFile::dsAccessible:
  109.             resId = IsMmcFolder() ? R_AVP_QUERY_LIST_TEXT_MMC_MEMORY : R_AVP_QUERY_LIST_TEXT_PHONE_MEMORY;
  110.             break;
  111.         case CHXAvFile::dsLocked:
  112.             // only mmc can be locked
  113.             HX_ASSERT(IsMmcFolder());
  114.             resId = R_AVP_QUERY_LIST_TEXT_MMC_MEMORY; //R_CFD_QTN_MEMC_MMC_LOCKED;
  115.             break;
  116.         default:
  117.             // only mmc may be unavailable or otherwise not accessible
  118.             HX_ASSERT(IsMmcFolder());
  119.             resId = R_AVP_QUERY_LIST_TEXT_MMC_MEMORY; //R_CFD_QTN_MEMC_MMC_UNAVAILABLE;
  120.             break;
  121.         }
  122.         pbuff = CEikonEnv::Static()->AllocReadResourceL(resId);
  123.     }
  124.     return pbuff;
  125. }