mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedpconfigmgr.cpp
changeset 49 c20dd21d1eb4
parent 31 a26669f87b46
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    18 
    18 
    19 #include <mtp/mmtpdataproviderconfig.h>
    19 #include <mtp/mmtpdataproviderconfig.h>
    20 #include <mtp/mmtpdataproviderframework.h>
    20 #include <mtp/mmtpdataproviderframework.h>
    21 #include <102827af.rsg>
    21 #include <102827af.rsg>
    22 #include "cmtpdevicedpconfigmgr.h"
    22 #include "cmtpdevicedpconfigmgr.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "cmtpdevicedpconfigmgrTraces.h"
       
    26 #endif
       
    27 
    23 
    28 
    24 enum PanicReason
    29 enum PanicReason
    25 {
    30 {
    26 CMTPDeviceDpConfigMgrPanic = -1,
    31 CMTPDeviceDpConfigMgrPanic = -1,
    27 };
    32 };
    29 _LIT(KPanicInvalidInt, "Panic is due to invalid Integer");
    34 _LIT(KPanicInvalidInt, "Panic is due to invalid Integer");
    30 _LIT(KPanicinvalidRssConfigParam, "Panic is due to invalid RSS Config Param");
    35 _LIT(KPanicinvalidRssConfigParam, "Panic is due to invalid RSS Config Param");
    31 #endif 
    36 #endif 
    32 
    37 
    33 // Class constants.
    38 // Class constants.
    34 __FLOG_STMT(_LIT8(KComponent,"DeviceDpConfigMgr");)
       
    35 
    39 
    36 CMTPDeviceDpConfigMgr* CMTPDeviceDpConfigMgr::NewL(MMTPDataProviderFramework& aFramework)
    40 CMTPDeviceDpConfigMgr* CMTPDeviceDpConfigMgr::NewL(MMTPDataProviderFramework& aFramework)
    37 	{
    41 	{
    38 	CMTPDeviceDpConfigMgr* self = new (ELeave) CMTPDeviceDpConfigMgr(aFramework);
    42 	CMTPDeviceDpConfigMgr* self = new (ELeave) CMTPDeviceDpConfigMgr(aFramework);
    39 	CleanupStack::PushL(self);
    43 	CleanupStack::PushL(self);
    47 	{
    51 	{
    48 	}
    52 	}
    49 	
    53 	
    50 void CMTPDeviceDpConfigMgr::ConstructL()
    54 void CMTPDeviceDpConfigMgr::ConstructL()
    51 	{
    55 	{
    52 	__FLOG_OPEN(KMTPSubsystem, KComponent);
    56 	OstTraceFunctionEntry0( CMTPDEVICEDPCONFIGMGR_CONSTRUCTL_ENTRY );
    53     __FLOG(_L8("ConstructL - Entry"));
       
    54     
    57     
    55 	iResourceId = iFramework.DataProviderConfig().UintValue(MMTPDataProviderConfig::EOpaqueResource);
    58 	iResourceId = iFramework.DataProviderConfig().UintValue(MMTPDataProviderConfig::EOpaqueResource);
    56 	
    59 	
    57 	RResourceFile resFile;
    60 	RResourceFile resFile;
    58 	CleanupClosePushL(resFile);
    61 	CleanupClosePushL(resFile);
    69 	// Do not read exclusion_list to conserve memory
    72 	// Do not read exclusion_list to conserve memory
    70 	// - instead read it in dynamically when requested	
    73 	// - instead read it in dynamically when requested	
    71 	CleanupStack::PopAndDestroy(res);
    74 	CleanupStack::PopAndDestroy(res);
    72 	CleanupStack::PopAndDestroy(&resFile);
    75 	CleanupStack::PopAndDestroy(&resFile);
    73 	
    76 	
    74 	__FLOG(_L8("ConstructL - Exit"));
    77 	OstTraceFunctionExit0( CMTPDEVICEDPCONFIGMGR_CONSTRUCTL_EXIT );
    75 	}
    78 	}
    76 	
    79 	
    77 CMTPDeviceDpConfigMgr::~CMTPDeviceDpConfigMgr()
    80 CMTPDeviceDpConfigMgr::~CMTPDeviceDpConfigMgr()
    78 	{
    81 	{
    79 	__FLOG_CLOSE;
       
    80 	}
    82 	}
    81 	
    83 	
    82 #ifdef _DEBUG
    84 #ifdef _DEBUG
    83 TUint CMTPDeviceDpConfigMgr::UintValueL(TParameter aParam) const
    85 TUint CMTPDeviceDpConfigMgr::UintValueL(TParameter aParam) const
    84 #else
    86 #else
   122 	return exclusionList;
   124 	return exclusionList;
   123 	}
   125 	}
   124 
   126 
   125 void CMTPDeviceDpConfigMgr::GetDriveInfoL(TInt aDriveNo, TDes& aVolumeName, TDes& aRootDirPath)
   127 void CMTPDeviceDpConfigMgr::GetDriveInfoL(TInt aDriveNo, TDes& aVolumeName, TDes& aRootDirPath)
   126 	{
   128 	{
   127 	__FLOG(_L8("GetDriveInfoL - Entry"));
   129 	OstTraceFunctionEntry0( CMTPDEVICEDPCONFIGMGR_GETDRIVEINFOL_ENTRY );
   128 	RResourceFile resFile;
   130 	RResourceFile resFile;
   129 	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
   131 	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
   130 	CleanupClosePushL(resFile);
   132 	CleanupClosePushL(resFile);
   131 	HBufC8* dataBuffer=resFile.AllocReadLC(DRIVES);
   133 	HBufC8* dataBuffer=resFile.AllocReadLC(DRIVES);
   132 	
   134 	
   133 	TResourceReader reader;
   135 	TResourceReader reader;
   134 	reader.SetBuffer(dataBuffer);
   136 	reader.SetBuffer(dataBuffer);
   135 	TInt maxDrives = reader.ReadInt16();
   137 	TInt maxDrives = reader.ReadInt16();
   136 	__FLOG_VA((_L8("aDriveNo = %d"), aDriveNo));
   138 	OstTrace1(TRACE_NORMAL, CMTPDEVICEDPCONFIGMGR_GETDRIVEINFOL, "aDriveNo = %d", aDriveNo);
   137 	TBool found = EFalse;
   139 	TBool found = EFalse;
   138 	for(TInt driveIndex = 0; driveIndex < maxDrives; driveIndex++)
   140 	for(TInt driveIndex = 0; driveIndex < maxDrives; driveIndex++)
   139 		{
   141 		{
   140 		TInt driveNumber = reader.ReadInt16();
   142 		TInt driveNumber = reader.ReadInt16();
   141 		TPtrC volumeName = reader.ReadTPtrC();
   143 		TPtrC volumeName = reader.ReadTPtrC();
   142 		TPtrC rootDirName = reader.ReadTPtrC();
   144 		TPtrC rootDirName = reader.ReadTPtrC();
   143 
   145 
   144 		if(driveNumber ==  aDriveNo)
   146 		if(driveNumber ==  aDriveNo)
   145 			{
   147 			{
   146 			found = ETrue;
   148 			found = ETrue;
   147 			__FLOG_VA((_L8("Found the drive! Drive Number = %d"), driveNumber));
   149 			OstTrace1(TRACE_NORMAL, DUP1_CMTPDEVICEDPCONFIGMGR_GETDRIVEINFOL, 
       
   150 			        "Found the drive! Drive Number = %d", driveNumber);
   148 			if ((KMaxFileName > volumeName.Length()) && 
   151 			if ((KMaxFileName > volumeName.Length()) && 
   149 			    (KMaxFileName > rootDirName.Length())
   152 			    (KMaxFileName > rootDirName.Length())
   150 			    )
   153 			    )
   151 				{
   154 				{
   152 				aVolumeName = volumeName;
   155 				aVolumeName = volumeName;
   153 				aRootDirPath = rootDirName;
   156 				aRootDirPath = rootDirName;
   154 				}
   157 				}
   155 			else
   158 			else
   156 				{
   159 				{
   157 				__FLOG(_L8("VolumeName or RootDirName length is more than KMaxFileName"));
   160 	            OstTrace0(TRACE_NORMAL, DUP2_CMTPDEVICEDPCONFIGMGR_GETDRIVEINFOL, 
       
   161 	                    "VolumeName or RootDirName length is more than KMaxFileName");
   158 				// volumeName and/or rootDirName specified in resource file is too lengthy.
   162 				// volumeName and/or rootDirName specified in resource file is too lengthy.
   159 				User::Leave(KErrArgument);
   163 				User::Leave(KErrArgument);
   160 				}			
   164 				}			
   161 			break;
   165 			break;
   162 			}
   166 			}
   163 		}
   167 		}
   164 	
   168 	
   165 	if (!found)
   169 	if (!found)
   166 		{
   170 		{
   167 		__FLOG_VA((_L8("No match in resource file for Drive Number = %d"), aDriveNo));
   171         OstTrace1(TRACE_NORMAL, DUP3_CMTPDEVICEDPCONFIGMGR_GETDRIVEINFOL, 
       
   172                   "No match in resource file for Drive Number = %d", aDriveNo);
   168 		// Matching drive number was not found in resource file.
   173 		// Matching drive number was not found in resource file.
   169 		User::Leave(KErrNotFound);
   174 		User::Leave(KErrNotFound);
   170 		}
   175 		}
   171 		
   176 		
   172 	CleanupStack::PopAndDestroy(dataBuffer);
   177 	CleanupStack::PopAndDestroy(dataBuffer);
   173 	CleanupStack::PopAndDestroy(&resFile);
   178 	CleanupStack::PopAndDestroy(&resFile);
   174 	__FLOG(_L8("GetDriveInfoL - Exit"));
   179 	OstTraceFunctionExit0( CMTPDEVICEDPCONFIGMGR_GETDRIVEINFOL_EXIT );
   175 	}
   180 	}
   176 
   181 
   177 void CMTPDeviceDpConfigMgr::GetFriendlyVolumeNameL(TInt aDriveNo, TDes& aVolumeName)
   182 void CMTPDeviceDpConfigMgr::GetFriendlyVolumeNameL(TInt aDriveNo, TDes& aVolumeName)
   178 	{
   183 	{
   179 	__FLOG(_L8("GetFriendlyVolumeNameL - Entry"));
   184 	OstTraceFunctionEntry0( CMTPDEVICEDPCONFIGMGR_GETFRIENDLYVOLUMENAMEL_ENTRY );
   180 	RBuf rootDirPath;
   185 	RBuf rootDirPath;
   181 	rootDirPath.CreateL(KMaxFileName);
   186 	rootDirPath.CreateL(KMaxFileName);
   182 	rootDirPath.CleanupClosePushL();
   187 	rootDirPath.CleanupClosePushL();
   183 	GetDriveInfoL(aDriveNo, aVolumeName, rootDirPath);
   188 	GetDriveInfoL(aDriveNo, aVolumeName, rootDirPath);
   184 	CleanupStack::PopAndDestroy();
   189 	CleanupStack::PopAndDestroy();
   185 	__FLOG(_L8("GetFriendlyVolumeNameL - Exit"));
   190 	OstTraceFunctionExit0( CMTPDEVICEDPCONFIGMGR_GETFRIENDLYVOLUMENAMEL_EXIT );
   186 	}
   191 	}
   187 
   192 
   188 void CMTPDeviceDpConfigMgr::GetRootDirPathL(TInt aDriveNo, TDes& aRootDirPath)
   193 void CMTPDeviceDpConfigMgr::GetRootDirPathL(TInt aDriveNo, TDes& aRootDirPath)
   189 	{
   194 	{
   190 	__FLOG(_L8("GetRootDirPathL - Entry"));
   195 	OstTraceFunctionEntry0( CMTPDEVICEDPCONFIGMGR_GETROOTDIRPATHL_ENTRY );
   191 	RBuf volumeName;
   196 	RBuf volumeName;
   192 	volumeName.CreateL(KMaxFileName);
   197 	volumeName.CreateL(KMaxFileName);
   193 	volumeName.CleanupClosePushL();
   198 	volumeName.CleanupClosePushL();
   194 	GetDriveInfoL(aDriveNo, volumeName, aRootDirPath);
   199 	GetDriveInfoL(aDriveNo, volumeName, aRootDirPath);
   195 	CleanupStack::PopAndDestroy();
   200 	CleanupStack::PopAndDestroy();
   196 	__FLOG(_L8("GetRootDirPathL - Exit"));
   201 	OstTraceFunctionExit0( CMTPDEVICEDPCONFIGMGR_GETROOTDIRPATHL_EXIT );
   197 	}
   202 	}
   198 
   203 
   199 /**
   204 /**
   200   *This method is to get the ordered format from the rss file
   205   *This method is to get the ordered format from the rss file
   201   *
   206   *
   202   *@param aOrderInfoArray : is an array for storing ordered formats(out param).
   207   *@param aOrderInfoArray : is an array for storing ordered formats(out param).
   203   * 
   208   * 
   204   */
   209   */
   205  void CMTPDeviceDpConfigMgr::GetRssConfigInfoArrayL(RArray<TUint>& aOrderInfoArray, TDevDPConfigRSSParams aParam)
   210  void CMTPDeviceDpConfigMgr::GetRssConfigInfoArrayL(RArray<TUint>& aOrderInfoArray, TDevDPConfigRSSParams aParam)
   206 	{
   211 	{
   207 	__FLOG(_L8("GetOrderedFormatInfo - Entry"));
   212 	OstTraceFunctionEntry0( CMTPDEVICEDPCONFIGMGR_GETRSSCONFIGINFOARRAYL_ENTRY );
   208 	RResourceFile resFile;
   213 	RResourceFile resFile;
   209 	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
   214 	resFile.OpenL(iFramework.Fs(), iFramework.DataProviderConfig().DesCValue(MMTPDataProviderConfig::EResourceFileName));
   210 	CleanupClosePushL(resFile);
   215 	CleanupClosePushL(resFile);
   211 	HBufC8* dataBuffer = NULL;
   216 	HBufC8* dataBuffer = NULL;
   212 	
   217 	
   227 		}
   232 		}
   228 
   233 
   229 	TResourceReader reader;
   234 	TResourceReader reader;
   230 	reader.SetBuffer(dataBuffer);
   235 	reader.SetBuffer(dataBuffer);
   231 	TInt noOfElem = reader.ReadInt16();
   236 	TInt noOfElem = reader.ReadInt16();
   232 	//rewind to the begening else desc array can not read value.
   237 	//rewind to the beginning else desc array can not read value.
   233 	reader.Rewind(sizeof(TInt16));
   238 	reader.Rewind(sizeof(TInt16));
   234 	if(0 != noOfElem)	
   239 	if(0 != noOfElem)	
   235 	{
   240 	{
   236 	CDesCArrayFlat* formatArray = reader.ReadDesCArrayL();
   241 	CDesCArrayFlat* formatArray = reader.ReadDesCArrayL();
   237 	CleanupStack::PushL(formatArray);
   242 	CleanupStack::PushL(formatArray);
   247 		//panic in debug mode invalid string is provaided
   252 		//panic in debug mode invalid string is provaided
   248 		__ASSERT_DEBUG((errorCode == KErrNone), User::Panic(KPanicInvalidInt, CMTPDeviceDpConfigMgrPanic));
   253 		__ASSERT_DEBUG((errorCode == KErrNone), User::Panic(KPanicInvalidInt, CMTPDeviceDpConfigMgrPanic));
   249 
   254 
   250 		if(errorCode )
   255 		if(errorCode )
   251 			{
   256 			{
   252 			 __FLOG(_L8("ERROR !!!Invalid entry in the config.rss file "));
   257 			 OstTrace0(TRACE_ERROR, CMTPDEVICEDPCONFIGMGR_GETRSSCONFIGINFOARRAYL, 
       
   258 			         "ERROR !!!Invalid entry in the config.rss file ");
   253 			}
   259 			}
   254 		else
   260 		else
   255 			{
   261 			{
   256 			//Ignore the duplicate value.
   262 			//Ignore the duplicate value.
   257 			if( aOrderInfoArray.Find(formatInt) == KErrNotFound )
   263 			if( aOrderInfoArray.Find(formatInt) == KErrNotFound )
   267 	}
   273 	}
   268 	else
   274 	else
   269 	{
   275 	{
   270 	CleanupStack::PopAndDestroy(dataBuffer);
   276 	CleanupStack::PopAndDestroy(dataBuffer);
   271 	CleanupStack::PopAndDestroy(&resFile);	
   277 	CleanupStack::PopAndDestroy(&resFile);	
       
   278 	OstTrace0( TRACE_ERROR, DUP1_CMTPDEVICEDPCONFIGMGR_GETRSSCONFIGINFOARRAYL, "resource file contains zero element" );
   272 	User::Leave(KErrArgument);	
   279 	User::Leave(KErrArgument);	
   273 	}
   280 	}
   274 
   281 
   275 	__FLOG(_L8("GetOrderedFormatInfo -  Exit"));
   282 	OstTraceFunctionExit0( CMTPDEVICEDPCONFIGMGR_GETRSSCONFIGINFOARRAYL_EXIT );
   276 	}
   283 	}
   277 
   284