mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp
changeset 49 c20dd21d1eb4
parent 29 3ae5cb0b4c02
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    29 #include "cmtpdevicedatastore.h"
    29 #include "cmtpdevicedatastore.h"
    30 #include "cmtpframeworkconfig.h"
    30 #include "cmtpframeworkconfig.h"
    31 #include "mmtpenumerationcallback.h"
    31 #include "mmtpenumerationcallback.h"
    32 #include "mtpdevdppanic.h"
    32 #include "mtpdevdppanic.h"
    33 #include "mtpdevicedpconst.h"
    33 #include "mtpdevicedpconst.h"
       
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "cmtpdevicedatastoreTraces.h"
       
    37 #endif
       
    38 
    34 
    39 
    35 // Class constants.
    40 // Class constants.
    36 __FLOG_STMT(_LIT8(KComponent,"DeviceDataStore");)
       
    37 
    41 
    38 _LIT( KFileName, "z:\\private\\102827a2\\mtpdevice.ico");
    42 _LIT( KFileName, "z:\\private\\102827a2\\mtpdevice.ico");
    39 
    43 
    40 
    44 
    41 // Device property datastore constants.
    45 // Device property datastore constants.
    96 /**
   100 /**
    97 Destructor.
   101 Destructor.
    98 */
   102 */
    99 CMTPDeviceDataStore::~CMTPDeviceDataStore()
   103 CMTPDeviceDataStore::~CMTPDeviceDataStore()
   100     {
   104     {
   101     __FLOG(_L8("~CMTPDeviceDataStore - Entry"));
   105     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_CMTPDEVICEDATASTORE_DES_ENTRY );
   102     Cancel();
   106     Cancel();
   103     delete iDeviceFriendlyNameDefault;
   107     delete iDeviceFriendlyNameDefault;
   104     delete iSyncPartnerNameDefault;
   108     delete iSyncPartnerNameDefault;
   105     delete iDeviceFriendlyName;
   109     delete iDeviceFriendlyName;
   106     delete iSynchronisationPartner;
   110     delete iSynchronisationPartner;
   111     delete iDateTime;
   115     delete iDateTime;
   112     iDeviceVersion.Close();
   116     iDeviceVersion.Close();
   113     iSerialNumber.Close();
   117     iSerialNumber.Close();
   114     iSingletons.Close();
   118     iSingletons.Close();
   115     iMTPExtensions.Close();
   119     iMTPExtensions.Close();
   116     __FLOG(_L8("~CMTPDeviceDataStore - Exit"));
   120     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_CMTPDEVICEDATASTORE_DES_EXIT );
   117     __FLOG_CLOSE;
       
   118     }
   121     }
   119 
   122 
   120 /**
   123 /**
   121 Check to see if a request such as BatteryLevel is currently
   124 Check to see if a request such as BatteryLevel is currently
   122 pending for processing. If so it's not advisable to make another
   125 pending for processing. If so it's not advisable to make another
   130 	return IsActive();
   133 	return IsActive();
   131 	}
   134 	}
   132 
   135 
   133 void CMTPDeviceDataStore::BatteryLevelL(TRequestStatus& aStatus, TUint& aBatteryLevel)
   136 void CMTPDeviceDataStore::BatteryLevelL(TRequestStatus& aStatus, TUint& aBatteryLevel)
   134     {
   137     {
   135     __FLOG(_L8("BatteryLevel - Entry"));
   138     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_BATTERYLEVELL_ENTRY );
   136 
   139 
   137 	if (RequestPending())
   140 	if (RequestPending())
   138 		{
   141 		{
   139 		// We are already reading battery level
   142 		// We are already reading battery level
   140 		// leave so we don't set ourselves active twice
   143 		// leave so we don't set ourselves active twice
       
   144         OstTrace0( TRACE_ERROR, CMTPDEVICEDATASTORE_BATTERYLEVELL, "already reading battery level, no need to set active twice" );
   141 		User::Leave(KErrInUse);
   145 		User::Leave(KErrInUse);
   142 		}
   146 		}
   143 
   147 
   144     iPendingStatus = &aStatus;
   148     iPendingStatus = &aStatus;
   145 	SetRequestPending(*iPendingStatus);
   149 	SetRequestPending(*iPendingStatus);
   154     else
   158     else
   155         {
   159         {
   156         aBatteryLevel = KMTPDefaultBatteryLevel;
   160         aBatteryLevel = KMTPDefaultBatteryLevel;
   157     	SetRequestComplete(*iPendingStatus, KErrNone);
   161     	SetRequestComplete(*iPendingStatus, KErrNone);
   158         }
   162         }
   159     __FLOG(_L8("BatteryLevel - Exit"));
   163     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_BATTERYLEVELL_EXIT );
   160     }
   164     }
   161 
   165 
   162 /**
   166 /**
   163 Provides the MTP device friendly name.
   167 Provides the MTP device friendly name.
   164 @return The MTP device friendly name.
   168 @return The MTP device friendly name.
   165 */
   169 */
   166 const TDesC& CMTPDeviceDataStore::DeviceFriendlyName() const
   170 const TDesC& CMTPDeviceDataStore::DeviceFriendlyName() const
   167     {
   171     {
   168     __FLOG(_L8("DeviceFriendlyName - Entry"));
   172     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_DEVICEFRIENDLYNAME_ENTRY );
   169     __FLOG(_L8("DeviceFriendlyName - Exit"));
   173     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_DEVICEFRIENDLYNAME_EXIT );
   170     return iDeviceFriendlyName->StringChars();
   174     return iDeviceFriendlyName->StringChars();
   171     }
   175     }
   172 
   176 
   173 /**
   177 /**
   174 Provides the default MTP device friendly name.
   178 Provides the default MTP device friendly name.
   175 @return The default MTP device friendly name.
   179 @return The default MTP device friendly name.
   176 */
   180 */
   177 const TDesC& CMTPDeviceDataStore::DeviceFriendlyNameDefault() const
   181 const TDesC& CMTPDeviceDataStore::DeviceFriendlyNameDefault() const
   178     {
   182     {
   179     __FLOG(_L8("DeviceFriendlyNameDefault - Entry"));
   183     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_DEVICEFRIENDLYNAMEDEFAULT_ENTRY );
   180     __FLOG(_L8("DeviceFriendlyNameDefault - Exit"));
   184     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_DEVICEFRIENDLYNAMEDEFAULT_EXIT );
   181     return *iDeviceFriendlyNameDefault;
   185     return *iDeviceFriendlyNameDefault;
   182     }
   186     }
   183 
   187 
   184 /**
   188 /**
   185 Provides the device firmware version identifier
   189 Provides the device firmware version identifier
   186 @return The device firmware version identifier .
   190 @return The device firmware version identifier .
   187 */
   191 */
   188 const TDesC& CMTPDeviceDataStore::DeviceVersion() const
   192 const TDesC& CMTPDeviceDataStore::DeviceVersion() const
   189     {
   193     {
   190     __FLOG(_L8("DeviceVersion - Entry"));
   194     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_DEVICEVERSION_ENTRY );
   191     __FLOG(_L8("DeviceVersion - Exit"));
   195     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_DEVICEVERSION_EXIT );
   192     return iDeviceVersion;
   196     return iDeviceVersion;
   193     }
   197     }
   194 
   198 
   195 /**
   199 /**
   196 Provides the device manufacturer name.
   200 Provides the device manufacturer name.
   197 @return The device manufacturer name.
   201 @return The device manufacturer name.
   198 */
   202 */
   199 const TDesC& CMTPDeviceDataStore::Manufacturer() const
   203 const TDesC& CMTPDeviceDataStore::Manufacturer() const
   200     {
   204     {
   201     __FLOG(_L8("Manufacturer - Entry"));
   205     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_MANUFACTURER_ENTRY );
   202     __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
   206     __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
   203     __FLOG(_L8("Manufacturer - Exit"));
   207     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_MANUFACTURER_EXIT );
   204     return iPhoneIdV1.iManufacturer;
   208     return iPhoneIdV1.iManufacturer;
   205     }
   209     }
   206 
   210 
   207 /**
   211 /**
   208 Provides the device model identifier.
   212 Provides the device model identifier.
   209 @return The device model identifier.
   213 @return The device model identifier.
   210 */
   214 */
   211 const TDesC& CMTPDeviceDataStore::Model() const
   215 const TDesC& CMTPDeviceDataStore::Model() const
   212     {
   216     {
   213     __FLOG(_L8("Model - Entry"));
   217     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_MODEL_ENTRY );
   214     __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
   218     __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
   215     __FLOG(_L8("Model - Exit"));
   219     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_MODEL_EXIT );
   216     return iPhoneIdV1.iModel;
   220     return iPhoneIdV1.iModel;
   217     }
   221     }
   218 
   222 
   219 /**
   223 /**
   220 Provides the MTP Vendor Extension string.
   224 Provides the MTP Vendor Extension string.
   221 @return The MTP Vendor Extension string.
   225 @return The MTP Vendor Extension string.
   222 */
   226 */
   223 const TDesC& CMTPDeviceDataStore::MTPExtensions() const
   227 const TDesC& CMTPDeviceDataStore::MTPExtensions() const
   224     {
   228     {
   225     __FLOG(_L8("MTPExtensions - Entry"));
   229     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_MTPEXTENSIONS_ENTRY );
   226     __FLOG(_L8("MTPExtensions - Exit"));
   230     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_MTPEXTENSIONS_EXIT );
   227     return iMTPExtensions;
   231     return iMTPExtensions;
   228     }
   232     }
   229 
   233 
   230 /**
   234 /**
   231 Provides the device serial number.
   235 Provides the device serial number.
   232 @return The device serial number.
   236 @return The device serial number.
   233 */
   237 */
   234 const TDesC& CMTPDeviceDataStore::SerialNumber() const
   238 const TDesC& CMTPDeviceDataStore::SerialNumber() const
   235     {
   239     {
   236     __FLOG(_L8("SerialNumber - Entry"));
   240     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SERIALNUMBER_ENTRY );
   237     __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
   241     __ASSERT_DEBUG(Enumerated(), Panic(EMTPDevDpInvalidState));
   238     __FLOG(_L8("SerialNumber - Exit"));
   242     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SERIALNUMBER_EXIT );
   239     return iPhoneIdV1.iSerialNumber;
   243     return iPhoneIdV1.iSerialNumber;
   240     }
   244     }
   241 
   245 
   242 /**
   246 /**
   243 Provides the MTP synchronisation partner name.
   247 Provides the MTP synchronisation partner name.
   244 @return The MTP synchronisation partner name.
   248 @return The MTP synchronisation partner name.
   245 */
   249 */
   246 const TDesC& CMTPDeviceDataStore::SynchronisationPartner() const
   250 const TDesC& CMTPDeviceDataStore::SynchronisationPartner() const
   247     {
   251     {
   248     __FLOG(_L8("SynchronisationPartner - Entry"));
   252     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SYNCHRONISATIONPARTNER_ENTRY );
   249     __FLOG(_L8("SynchronisationPartner - Exit"));
   253     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SYNCHRONISATIONPARTNER_EXIT );
   250     return iSynchronisationPartner->StringChars();
   254     return iSynchronisationPartner->StringChars();
   251     }
   255     }
   252 
   256 
   253 /**
   257 /**
   254 Provides the default MTP synchronisation partner name.
   258 Provides the default MTP synchronisation partner name.
   255 @return The default MTP synchronisation partner name.
   259 @return The default MTP synchronisation partner name.
   256 */
   260 */
   257 const TDesC& CMTPDeviceDataStore::SynchronisationPartnerDefault() const
   261 const TDesC& CMTPDeviceDataStore::SynchronisationPartnerDefault() const
   258     {
   262     {
   259     __FLOG(_L8("SynchronisationPartnerDefault - Entry"));
   263     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SYNCHRONISATIONPARTNERDEFAULT_ENTRY );
   260     __FLOG(_L8("SynchronisationPartnerDefault - Exit"));
   264     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SYNCHRONISATIONPARTNERDEFAULT_EXIT );
   261     return *iSyncPartnerNameDefault;
   265     return *iSyncPartnerNameDefault;
   262     }
   266     }
   263 
   267 
   264 /**
   268 /**
   265 Sets the MTP device friendly name.
   269 Sets the MTP device friendly name.
   266 @param aName The new MTP device friendly name.
   270 @param aName The new MTP device friendly name.
   267 @leave One of the system wide error codes, if a processing failure occurs.
   271 @leave One of the system wide error codes, if a processing failure occurs.
   268 */
   272 */
   269 void CMTPDeviceDataStore::SetDeviceFriendlyNameL(const TDesC& aName)
   273 void CMTPDeviceDataStore::SetDeviceFriendlyNameL(const TDesC& aName)
   270     {
   274     {
   271     __FLOG(_L8("SetDeviceFriendlyNameL - Entry"));
   275     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SETDEVICEFRIENDLYNAMEL_ENTRY );
   272     iDeviceFriendlyName->SetL(aName);
   276     iDeviceFriendlyName->SetL(aName);
   273     StoreL();
   277     StoreL();
   274     __FLOG(_L8("SetDeviceFriendlyNameL - Exit"));
   278     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SETDEVICEFRIENDLYNAMEL_EXIT );
   275     }
   279     }
   276 
   280 
   277 /**
   281 /**
   278 Sets the synchronisation partner name.
   282 Sets the synchronisation partner name.
   279 @param aName The new MTP synchronisation partner name.
   283 @param aName The new MTP synchronisation partner name.
   280 @leave One of the system wide error codes, if a processing failure occurs.
   284 @leave One of the system wide error codes, if a processing failure occurs.
   281 */
   285 */
   282 void CMTPDeviceDataStore::SetSynchronisationPartnerL(const TDesC& aName)
   286 void CMTPDeviceDataStore::SetSynchronisationPartnerL(const TDesC& aName)
   283     {
   287     {
   284     __FLOG(_L8("SetSynchronisationPartnerL - Entry"));
   288     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SETSYNCHRONISATIONPARTNERL_ENTRY );
   285     iSynchronisationPartner->SetL(aName);
   289     iSynchronisationPartner->SetL(aName);
   286     StoreL();
   290     StoreL();
   287     __FLOG(_L8("SetSynchronisationPartnerL - Exit"));
   291     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SETSYNCHRONISATIONPARTNERL_EXIT );
   288     }
   292     }
   289 
   293 
   290 /**
   294 /**
   291 Initiates the MTP device data provider's device information data store
   295 Initiates the MTP device data provider's device information data store
   292 enumeration sequence. The sequence is concluded when ObjectEnumerationCompleteL
   296 enumeration sequence. The sequence is concluded when ObjectEnumerationCompleteL
   295 @param aCallback Callback to be called when enumeration completes.
   299 @param aCallback Callback to be called when enumeration completes.
   296 @leave One of the system wide error codes, if a processing failure occurs.
   300 @leave One of the system wide error codes, if a processing failure occurs.
   297 */
   301 */
   298 void CMTPDeviceDataStore::StartEnumerationL(TUint32 aStorageId, MMTPEnumerationCallback& aCallback)
   302 void CMTPDeviceDataStore::StartEnumerationL(TUint32 aStorageId, MMTPEnumerationCallback& aCallback)
   299     {
   303     {
   300     __FLOG(_L8("StartEnumerationL - Entry"));
   304     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_STARTENUMERATIONL_ENTRY );
   301     if (State() != EUndefined)
   305     if (State() != EUndefined)
   302         {
   306         {
   303         aCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone);
   307         aCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone);
   304         }
   308         }
   305     else
   309     else
   306         {
   310         {
   307         iStorageId = aStorageId;
   311         iStorageId = aStorageId;
   308         iCallback = &aCallback;
   312         iCallback = &aCallback;
   309         Schedule(EEnumeratingDevicePropertyStore);
   313         Schedule(EEnumeratingDevicePropertyStore);
   310         }
   314         }
   311     __FLOG(_L8("StartEnumerationL - Exit"));
   315     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_STARTENUMERATIONL_EXIT );
   312     }
   316     }
   313 
   317 
   314 void CMTPDeviceDataStore::DoCancel()
   318 void CMTPDeviceDataStore::DoCancel()
   315     {
   319     {
   316     __FLOG(_L8("DoCancel - Entry"));
   320     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_DOCANCEL_ENTRY );
   317     if (iTelephony)
   321     if (iTelephony)
   318         {
   322         {
   319         switch (State())
   323         switch (State())
   320             {
   324             {
   321         case EEnumeratingPhoneId:
   325         case EEnumeratingPhoneId:
   329         default:
   333         default:
   330             // Nothing to do.
   334             // Nothing to do.
   331             break;
   335             break;
   332             }
   336             }
   333         }
   337         }
   334     __FLOG(_L8("DoCancel - Exit"));
   338     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_DOCANCEL_EXIT );
   335     }
   339     }
   336 
   340 
   337 /**
   341 /**
   338 Handles leaves occurring in RunL.
   342 Handles leaves occurring in RunL.
   339 @param aError leave error code
   343 @param aError leave error code
   340 @return KErrNone
   344 @return KErrNone
   341 */
   345 */
   342 TInt CMTPDeviceDataStore::RunError(TInt aError)
   346 TInt CMTPDeviceDataStore::RunError(TInt aError)
   343     {
   347     {
   344     __FLOG(_L8("RunError - Entry"));
   348     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_RUNERROR_ENTRY );
   345     __FLOG_VA((_L8("Error = %d, State = %d"), aError, State()));
   349     OstTraceExt2(TRACE_NORMAL, CMTPDEVICEDATASTORE_RUNERROR, 
       
   350             "Error = %d, State = %d", aError, (TInt)State());
   346 	aError = aError;	// suppress compiler warning
   351 	aError = aError;	// suppress compiler warning
   347 
   352 
   348     switch (State())
   353     switch (State())
   349         {
   354         {
   350     case EEnumeratingDevicePropertyStore:
   355     case EEnumeratingDevicePropertyStore:
   372     default:
   377     default:
   373         __DEBUG_ONLY(Panic(EMTPDevDpInvalidState));
   378         __DEBUG_ONLY(Panic(EMTPDevDpInvalidState));
   374         break;
   379         break;
   375         }
   380         }
   376 
   381 
   377     __FLOG(_L8("RunError - Exit"));
   382     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_RUNERROR_EXIT );
   378     return KErrNone;
   383     return KErrNone;
   379     }
   384     }
   380 
   385 
   381 void CMTPDeviceDataStore::RunL()
   386 void CMTPDeviceDataStore::RunL()
   382     {
   387     {
   383     __FLOG(_L8("RunL - Entry"));
   388     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_RUNL_ENTRY );
   384     switch (State())
   389     switch (State())
   385         {
   390         {
   386     case EEnumeratingDevicePropertyStore:
   391     case EEnumeratingDevicePropertyStore:
   387         RestoreL();
   392         RestoreL();
   388         Schedule(EEnumeratingDeviceVersion);
   393         Schedule(EEnumeratingDeviceVersion);
   475     case EUndefined:
   480     case EUndefined:
   476     default:
   481     default:
   477         __DEBUG_ONLY(Panic(EMTPDevDpInvalidState));
   482         __DEBUG_ONLY(Panic(EMTPDevDpInvalidState));
   478         break;
   483         break;
   479         }
   484         }
   480     __FLOG(_L8("RunL - Exit"));
   485     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_RUNL_EXIT );
   481     }
   486     }
   482 
   487 
   483 /**
   488 /**
   484 Constructor.
   489 Constructor.
   485 @param aConnectionMgr The MTP connection manager interface.
   490 @param aConnectionMgr The MTP connection manager interface.
   489 	iBatteryInfoV1Pckg(iBatteryInfoV1),
   494 	iBatteryInfoV1Pckg(iBatteryInfoV1),
   490 	iPhoneIdV1Pckg(iPhoneIdV1),
   495 	iPhoneIdV1Pckg(iPhoneIdV1),
   491 	iIsConnectMac(EFalse),
   496 	iIsConnectMac(EFalse),
   492 	iHasPendingRequest(EFalse)
   497 	iHasPendingRequest(EFalse)
   493     {
   498     {
       
   499     OstTraceFunctionEntry0( DUP1_CMTPDEVICEDATASTORE_CMTPDEVICEDATASTORE_ENTRY );
   494     CActiveScheduler::Add(this);
   500     CActiveScheduler::Add(this);
       
   501     OstTraceFunctionExit0( DUP1_CMTPDEVICEDATASTORE_CMTPDEVICEDATASTORE_EXIT );
   495     }
   502     }
   496 
   503 
   497 /**
   504 /**
   498 Second phase constructor.
   505 Second phase constructor.
   499 */
   506 */
   500 void CMTPDeviceDataStore::ConstructL()
   507 void CMTPDeviceDataStore::ConstructL()
   501     {
   508     {
   502     __FLOG_OPEN(KMTPSubsystem, KComponent);
   509     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_CONSTRUCTL_ENTRY );
   503     __FLOG(_L8("ConstructL - Entry"));
       
   504     iSingletons.OpenL();
   510     iSingletons.OpenL();
   505 
   511 
   506     /*
   512     /*
   507     Set the default values.
   513     Set the default values.
   508 
   514 
   543    iDateTime = CMTPTypeString::NewL(dateTimeString);
   549    iDateTime = CMTPTypeString::NewL(dateTimeString);
   544 
   550 
   545    //11 Device Icon property, Load the icon into Auint Atrray
   551    //11 Device Icon property, Load the icon into Auint Atrray
   546    LoadDeviceIconL();
   552    LoadDeviceIconL();
   547 
   553 
   548     __FLOG(_L8("ConstructL - Exit"));
   554     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_CONSTRUCTL_EXIT );
   549     }
   555     }
   550 
   556 
   551 /**
   557 /**
   552 Indicates if the device information data store is in the EEnumerated state.
   558 Indicates if the device information data store is in the EEnumerated state.
   553 @return ETrue if the device data store state is enumerated, otherwiese EFalse.
   559 @return ETrue if the device data store state is enumerated, otherwiese EFalse.
   554 */
   560 */
   555 TBool CMTPDeviceDataStore::Enumerated() const
   561 TBool CMTPDeviceDataStore::Enumerated() const
   556     {
   562     {
   557     __FLOG(_L8("Enumerated - Entry"));
   563     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_ENUMERATED_ENTRY );
   558     TInt32 state(State());
   564     TInt32 state(State());
   559     __FLOG(_L8("Enumerated - Exit"));
   565     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_ENUMERATED_EXIT );
   560     return (state & EEnumerated);
   566     return (state & EEnumerated);
   561     }
   567     }
   562 
   568 
   563 /**
   569 /**
   564 Externalizes device properties to the device property store.
   570 Externalizes device properties to the device property store.
   565 @param aWriteStream the stream to externalize the device properties
   571 @param aWriteStream the stream to externalize the device properties
   566 @leave One of the system wide error codes, if a processing failure occurs.
   572 @leave One of the system wide error codes, if a processing failure occurs.
   567 */
   573 */
   568 void CMTPDeviceDataStore::ExternalizeL(RWriteStream& aWriteStream) const
   574 void CMTPDeviceDataStore::ExternalizeL(RWriteStream& aWriteStream) const
   569     {
   575     {
   570     __FLOG(_L8("ExternalizeL - Entry"));
   576     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_EXTERNALIZEL_ENTRY );
   571     aWriteStream.WriteInt32L(KMTPDevicePropertyStoreVersion);
   577     aWriteStream.WriteInt32L(KMTPDevicePropertyStoreVersion);
   572     aWriteStream << DeviceFriendlyName();
   578     aWriteStream << DeviceFriendlyName();
   573     aWriteStream << SynchronisationPartner();
   579     aWriteStream << SynchronisationPartner();
   574     __FLOG(_L8("ExternalizeL - Exit"));
   580     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_EXTERNALIZEL_EXIT );
   575     }
   581     }
   576 
   582 
   577 /**
   583 /**
   578 Internalises device properties from the device property store.
   584 Internalises device properties from the device property store.
   579 @param aReadStream The device property store input data stream.
   585 @param aReadStream The device property store input data stream.
   580 @leave One of the system wide error codes, if a processing failure occurs.
   586 @leave One of the system wide error codes, if a processing failure occurs.
   581 */
   587 */
   582 void CMTPDeviceDataStore::InternalizeL(RReadStream& aReadStream)
   588 void CMTPDeviceDataStore::InternalizeL(RReadStream& aReadStream)
   583     {
   589     {
   584     __FLOG(_L8("InternalizeL - Entry"));
   590     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_INTERNALIZEL_ENTRY );
   585     RBuf buf;
   591     RBuf buf;
   586     buf.CleanupClosePushL();
   592     buf.CleanupClosePushL();
   587 
   593 
   588     /*
   594     /*
   589     Read the device property store version. This is present for future
   595     Read the device property store version. This is present for future
   600     buf.CreateL(aReadStream, KMTPMaxStringCharactersLength);
   606     buf.CreateL(aReadStream, KMTPMaxStringCharactersLength);
   601     iSynchronisationPartner->SetL(buf);
   607     iSynchronisationPartner->SetL(buf);
   602     buf.Close();
   608     buf.Close();
   603 
   609 
   604     CleanupStack::Pop();  //buf
   610     CleanupStack::Pop();  //buf
   605     __FLOG(_L8("InternalizeL - Exit"));
   611     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_INTERNALIZEL_EXIT );
   606     }
   612     }
   607 
   613 
   608 /**
   614 /**
   609 Provides the full pathname of the device property store.
   615 Provides the full pathname of the device property store.
   610 @return The full pathname of the device property store.
   616 @return The full pathname of the device property store.
   611 */
   617 */
   612 const TDesC& CMTPDeviceDataStore::PropertyStoreName()
   618 const TDesC& CMTPDeviceDataStore::PropertyStoreName()
   613     {
   619     {
   614     __FLOG(_L8("PropertyStoreName - Entry"));
   620     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_PROPERTYSTORENAME_ENTRY );
   615     if (iPropertyStoreName.Length() == 0)
   621     if (iPropertyStoreName.Length() == 0)
   616         {
   622         {
   617         iSingletons.Fs().PrivatePath(iPropertyStoreName);
   623         iSingletons.Fs().PrivatePath(iPropertyStoreName);
   618         iPropertyStoreName.Insert(0, KMTPDevicePropertyStoreDrive);
   624         iPropertyStoreName.Insert(0, KMTPDevicePropertyStoreDrive);
   619         iPropertyStoreName.Append(KMTPNoBackupFolder);
   625         iPropertyStoreName.Append(KMTPNoBackupFolder);
   620         iPropertyStoreName.Append(KMTPDevicePropertyStoreFileName);
   626         iPropertyStoreName.Append(KMTPDevicePropertyStoreFileName);
   621         }
   627         }
   622 
   628 
   623     __FLOG(_L8("PropertyStoreName - Exit"));
   629     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_PROPERTYSTORENAME_EXIT );
   624     return iPropertyStoreName;
   630     return iPropertyStoreName;
   625     }
   631     }
   626 
   632 
   627 /**
   633 /**
   628 Query all dps for the MTP Vendor extensions set.
   634 Query all dps for the MTP Vendor extensions set.
   629 @return ETrue if finished querying all the dps, otherwise EFalse.
   635 @return ETrue if finished querying all the dps, otherwise EFalse.
   630 */
   636 */
   631 void CMTPDeviceDataStore::AppendMTPExtensionSetsL(TBool& aCompleted)
   637 void CMTPDeviceDataStore::AppendMTPExtensionSetsL(TBool& aCompleted)
   632     {
   638     {
   633     __FLOG(_L8("AppendMTPExtensionSetsL - Entry"));
   639     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_APPENDMTPEXTENSIONSETSL_ENTRY );
   634 	CMTPDataProviderController& dps(iSingletons.DpController());
   640 	CMTPDataProviderController& dps(iSingletons.DpController());
   635 	const TInt count = Min<TInt>(iCurrentDpIndex + KExtensionSetIterationRunLength, dps.Count());
   641 	const TInt count = Min<TInt>(iCurrentDpIndex + KExtensionSetIterationRunLength, dps.Count());
   636 	aCompleted = EFalse;
   642 	aCompleted = EFalse;
   637 	CDesCArraySeg* extensions = new (ELeave) CDesCArraySeg(KExtensionSetGranularity);
   643 	CDesCArraySeg* extensions = new (ELeave) CDesCArraySeg(KExtensionSetGranularity);
   638 	CleanupStack::PushL(extensions);
   644 	CleanupStack::PushL(extensions);
   646 		for (TInt i = 0; i < n; i++)
   652 		for (TInt i = 0; i < n; i++)
   647 			{
   653 			{
   648 			len += (*extensions)[i].Length() + KMTPVendorExtensionSetDelimiter().Length();
   654 			len += (*extensions)[i].Length() + KMTPVendorExtensionSetDelimiter().Length();
   649 			if (len > KMTPMaxStringCharactersLength)
   655 			if (len > KMTPMaxStringCharactersLength)
   650 				{
   656 				{
   651 				__FLOG(_L8("MTP Extensions set exceeded the maximum MTP String length"));
   657 				OstTrace0(TRACE_WARNING, CMTPDEVICEDATASTORE_APPENDMTPEXTENSIONSETSL,
       
   658 				        "MTP Extensions set exceeded the maximum MTP String length");
   652 				// End querying dps when the extension set exceeds the maximum mtp string length.
   659 				// End querying dps when the extension set exceeds the maximum mtp string length.
   653 				aCompleted = ETrue;
   660 				aCompleted = ETrue;
   654 				break;
   661 				break;
   655 				}
   662 				}
   656 			else
   663 			else
   670 	if(!aCompleted && iCurrentDpIndex >= dps.Count())
   677 	if(!aCompleted && iCurrentDpIndex >= dps.Count())
   671 		{
   678 		{
   672 		aCompleted = ETrue;
   679 		aCompleted = ETrue;
   673 		}
   680 		}
   674 
   681 
   675 	__FLOG(_L8("AppendMTPExtensionSetsL - Exit"));
   682     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_APPENDMTPEXTENSIONSETSL_EXIT );
   676     }
   683     }
   677 
   684 
   678 /**
   685 /**
   679 Loads device properties from the device property store.
   686 Loads device properties from the device property store.
   680 @leave One of the system wide error codes, if a processing failure occurs.
   687 @leave One of the system wide error codes, if a processing failure occurs.
   681 */
   688 */
   682 void CMTPDeviceDataStore::RestoreL()
   689 void CMTPDeviceDataStore::RestoreL()
   683     {
   690     {
   684     __FLOG(_L8("RestoreL - Entry"));
   691     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_RESTOREL_ENTRY );
   685     RFs& fs(iSingletons.Fs());
   692     RFs& fs(iSingletons.Fs());
   686     if(BaflUtils::FileExists(fs, PropertyStoreName()))
   693     if(BaflUtils::FileExists(fs, PropertyStoreName()))
   687         {
   694         {
   688         CFileStore* store(CDirectFileStore::OpenLC(fs, PropertyStoreName(), EFileRead));
   695         CFileStore* store(CDirectFileStore::OpenLC(fs, PropertyStoreName(), EFileRead));
   689         RStoreReadStream instream;
   696         RStoreReadStream instream;
   690         instream.OpenLC(*store, store->Root());
   697         instream.OpenLC(*store, store->Root());
   691         InternalizeL(instream);
   698         InternalizeL(instream);
   692         CleanupStack::PopAndDestroy(2, store); // instream, store
   699         CleanupStack::PopAndDestroy(2, store); // instream, store
   693         }
   700         }
   694     __FLOG(_L8("RestoreL - Exit"));
   701     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_RESTOREL_EXIT );
   695     }
   702     }
   696 
   703 
   697 /**
   704 /**
   698 Schedules the device information data store to transition to the specified state.
   705 Schedules the device information data store to transition to the specified state.
   699 @param aState The new data stream state.
   706 @param aState The new data stream state.
   700 */
   707 */
   701 void CMTPDeviceDataStore::Schedule(TInt32 aState)
   708 void CMTPDeviceDataStore::Schedule(TInt32 aState)
   702     {
   709     {
   703     __FLOG(_L8("Schedule - Entry"));
   710     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SCHEDULE_ENTRY );
   704     SetState(aState);
   711     SetState(aState);
   705     SetRequestPending(iStatus);
   712     SetRequestPending(iStatus);
   706     SetActive();
   713     SetActive();
   707     SetRequestComplete(iStatus,KErrNone);
   714     SetRequestComplete(iStatus,KErrNone);
   708     __FLOG(_L8("Schedule - Exit"));
   715     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SCHEDULE_EXIT );
   709     }
   716     }
   710 
   717 
   711 /**
   718 /**
   712 Completes the supplied asynchronous request completion status.
   719 Completes the supplied asynchronous request completion status.
   713 */
   720 */
   714 void CMTPDeviceDataStore::SetRequestComplete(TRequestStatus& aRequest, TUint aErr)
   721 void CMTPDeviceDataStore::SetRequestComplete(TRequestStatus& aRequest, TUint aErr)
   715     {
   722     {
   716     __FLOG(_L8("CompleteRequest - Entry"));
   723     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SETREQUESTCOMPLETE_ENTRY );
   717     TRequestStatus* status(&aRequest);
   724     TRequestStatus* status(&aRequest);
   718     User::RequestComplete(status, aErr);
   725     User::RequestComplete(status, aErr);
   719     __FLOG(_L8("CompleteRequest - Exit"));
   726     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SETREQUESTCOMPLETE_EXIT );
   720     }
   727     }
   721 
   728 
   722 
   729 
   723 /**
   730 /**
   724 Initialises the supplied asynchronous request completion status.
   731 Initialises the supplied asynchronous request completion status.
   725 */
   732 */
   726 void CMTPDeviceDataStore::SetRequestPending(TRequestStatus& aRequest)
   733 void CMTPDeviceDataStore::SetRequestPending(TRequestStatus& aRequest)
   727     {
   734     {
   728     __FLOG(_L8("SetRequestPending - Entry"));
   735     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SETREQUESTPENDING_ENTRY );
   729     aRequest = KRequestPending;
   736     aRequest = KRequestPending;
   730     __FLOG(_L8("SetRequestPending - Exit"));
   737     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SETREQUESTPENDING_EXIT );
   731     }
   738     }
   732 
   739 
   733 /**
   740 /**
   734 Sets the device information data store state variable.
   741 Sets the device information data store state variable.
   735 @param aState The new data stream state.
   742 @param aState The new data stream state.
   736 */
   743 */
   737 void CMTPDeviceDataStore::SetState(TInt32 aState)
   744 void CMTPDeviceDataStore::SetState(TInt32 aState)
   738     {
   745     {
   739     __FLOG(_L8("SetState - Entry"));
   746     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SETSTATE_ENTRY );
   740     iState = ((EEnumerated & iState) | aState);
   747     iState = ((EEnumerated & iState) | aState);
   741     __FLOG_VA((_L8("State set to 0x%08X"), iState));
   748     OstTrace1(TRACE_NORMAL, CMTPDEVICEDATASTORE_SETSTATE, 
   742     __FLOG(_L8("SetState - Exit"));
   749             "State set to 0x%08X", iState);
       
   750     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SETSTATE_EXIT );
   743     }
   751     }
   744 
   752 
   745 /**
   753 /**
   746 Provides the device information data store state variable value.
   754 Provides the device information data store state variable value.
   747 @return The device information data store state variable value.
   755 @return The device information data store state variable value.
   748 */
   756 */
   749 TInt32 CMTPDeviceDataStore::State() const
   757 TInt32 CMTPDeviceDataStore::State() const
   750     {
   758     {
   751     __FLOG(_L8("State - Entry"));
   759     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_STATE_ENTRY );
   752     __FLOG_VA((_L8("State = 0x%08X"), iState));
   760     OstTrace1(TRACE_NORMAL, CMTPDEVICEDATASTORE_STATE, 
   753     __FLOG(_L8("State - Exit"));
   761             "State = 0x%08X", iState);    
       
   762     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_STATE_EXIT );
   754     return iState;
   763     return iState;
   755     }
   764     }
   756 
   765 
   757 /**
   766 /**
   758 Stores device properties in the device property store.
   767 Stores device properties in the device property store.
   759 @leave One of the system wide error codes, if a processing failure occurs.
   768 @leave One of the system wide error codes, if a processing failure occurs.
   760 */
   769 */
   761 void CMTPDeviceDataStore::StoreL()
   770 void CMTPDeviceDataStore::StoreL()
   762     {
   771     {
   763     __FLOG(_L8("StoreL - Entry"));
   772     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_STOREL_ENTRY );
   764     CFileStore* store(CDirectFileStore::ReplaceLC(iSingletons.Fs(), PropertyStoreName(), EFileWrite));
   773     CFileStore* store(CDirectFileStore::ReplaceLC(iSingletons.Fs(), PropertyStoreName(), EFileWrite));
   765     store->SetTypeL(KDirectFileStoreLayoutUid);
   774     store->SetTypeL(KDirectFileStoreLayoutUid);
   766     RStoreWriteStream outstream;
   775     RStoreWriteStream outstream;
   767     TStreamId id = outstream.CreateLC(*store);
   776     TStreamId id = outstream.CreateLC(*store);
   768     ExternalizeL(outstream);
   777     ExternalizeL(outstream);
   769     outstream.CommitL();
   778     outstream.CommitL();
   770     CleanupStack::PopAndDestroy(&outstream);
   779     CleanupStack::PopAndDestroy(&outstream);
   771     store->SetRootL(id);
   780     store->SetRootL(id);
   772     store->CommitL();
   781     store->CommitL();
   773     CleanupStack::PopAndDestroy(store);
   782     CleanupStack::PopAndDestroy(store);
   774     __FLOG(_L8("StoreL - Exit"));
   783     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_STOREL_EXIT );
   775     }
   784     }
   776 
   785 
   777 /**
   786 /**
   778 Formats the specified serial number as a valid MTP Serial Number string. The
   787 Formats the specified serial number as a valid MTP Serial Number string. The
   779 MTP specification recommends that the serial number always be represented as
   788 MTP specification recommends that the serial number always be represented as
   780 exactly 32 characters, with leading zeros as required.
   789 exactly 32 characters, with leading zeros as required.
   781 */
   790 */
   782 void CMTPDeviceDataStore::StoreFormattedSerialNumber(const TDesC& aSerialNo)
   791 void CMTPDeviceDataStore::StoreFormattedSerialNumber(const TDesC& aSerialNo)
   783     {
   792     {
   784     __FLOG(_L8("FormatSerialNumber - Entry"));
   793     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_STOREFORMATTEDSERIALNUMBER_ENTRY );
   785     TBuf<KMTPSerialNumberLength> formatted;
   794     TBuf<KMTPSerialNumberLength> formatted;
   786     if (aSerialNo.Length() < KMTPSerialNumberLength)
   795     if (aSerialNo.Length() < KMTPSerialNumberLength)
   787         {
   796         {
   788         formatted = aSerialNo;
   797         formatted = aSerialNo;
   789         }
   798         }
   797         }
   806         }
   798 
   807 
   799     // Store the formatted serial number.
   808     // Store the formatted serial number.
   800     iPhoneIdV1.iSerialNumber = formatted;
   809     iPhoneIdV1.iSerialNumber = formatted;
   801 
   810 
   802     __FLOG(_L8("FormatSerialNumber - Exit"));
   811     OstTraceFunctionExit0( CMTPDEVICEDATASTORE_STOREFORMATTEDSERIALNUMBER_EXIT );
   803     }
   812     }
   804 
   813 
   805 /**
   814 /**
   806 * Get method for Session initiator version info(0xD406).
   815 * Get method for Session initiator version info(0xD406).
   807 *
   816 *
   808 * @return TDesC& : session initiator version info
   817 * @return TDesC& : session initiator version info
   809 */
   818 */
   810 const TDesC& CMTPDeviceDataStore::SessionInitiatorVersionInfo() const
   819 const TDesC& CMTPDeviceDataStore::SessionInitiatorVersionInfo() const
   811 	{
   820 	{
   812 	__FLOG(_L8("SessionInitiatorVersionInfo - Entry:Exit"));
   821 	OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SESSIONINITIATORVERSIONINFO_ENTRY );
       
   822 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SESSIONINITIATORVERSIONINFO_EXIT );
   813 	return iSessionInitiatorVersionInfo->StringChars();
   823 	return iSessionInitiatorVersionInfo->StringChars();
   814 	}
   824 	}
   815 
   825 
   816 /**
   826 /**
   817 * Get method for Session initiator version info Default value.
   827 * Get method for Session initiator version info Default value.
   818 *
   828 *
   819 * @return TDesC& : session initiator version info default.
   829 * @return TDesC& : session initiator version info default.
   820 */
   830 */
   821 const TDesC& CMTPDeviceDataStore::SessionInitiatorVersionInfoDefault() const
   831 const TDesC& CMTPDeviceDataStore::SessionInitiatorVersionInfoDefault() const
   822 	{
   832 	{
   823 	__FLOG(_L8("SessionInitiatorVersionInfoDefault - Entry:Exit"));
   833 	OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SESSIONINITIATORVERSIONINFODEFAULT_ENTRY );
       
   834 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SESSIONINITIATORVERSIONINFODEFAULT_EXIT );
   824 	return KDefaultSessionInitiatorVersionInfo;
   835 	return KDefaultSessionInitiatorVersionInfo;
   825 	}
   836 	}
   826 
   837 
   827 /**
   838 /**
   828 * Set method for Session initiator version info(0xD406).
   839 * Set method for Session initiator version info(0xD406).
   829 *
   840 *
   830 * @Param TDesC& : session initiator version info from the initiator
   841 * @Param TDesC& : session initiator version info from the initiator
   831 */
   842 */
   832 void CMTPDeviceDataStore::SetSessionInitiatorVersionInfoL(const TDesC& aVerInfo)
   843 void CMTPDeviceDataStore::SetSessionInitiatorVersionInfoL(const TDesC& aVerInfo)
   833 	{
   844 	{
   834 	 __FLOG(_L8("SetDeviceFriendlyNameL - Entry"));
   845 	 OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SETSESSIONINITIATORVERSIONINFOL_ENTRY );
   835 	 iSessionInitiatorVersionInfo->SetL(aVerInfo);
   846 	 iSessionInitiatorVersionInfo->SetL(aVerInfo);
   836 	 StoreL();
   847 	 StoreL();
   837 	 __FLOG(_L8("SetDeviceFriendlyNameL - Exit"));
   848 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SETSESSIONINITIATORVERSIONINFOL_EXIT );
   838 	}
   849 	}
   839 
   850 
   840 /**
   851 /**
   841 * Get method for PerceivedDeviceTypeDefault(0x00000000	Generic).
   852 * Get method for PerceivedDeviceTypeDefault(0x00000000	Generic).
   842 *
   853 *
   843 * @return TUint32: return value for PerceivedDeviceTypeDefault
   854 * @return TUint32: return value for PerceivedDeviceTypeDefault
   844 */
   855 */
   845 TUint32 CMTPDeviceDataStore::PerceivedDeviceTypeDefault() const
   856 TUint32 CMTPDeviceDataStore::PerceivedDeviceTypeDefault() const
   846 	{
   857 	{
   847 	__FLOG(_L8("SessionInitiatorVersionInfoDefault - Entry:Exit"));
   858 	OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_PERCEIVEDDEVICETYPEDEFAULT_ENTRY );
       
   859 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_PERCEIVEDDEVICETYPEDEFAULT_EXIT );
   848 	return DefaultPerceivedDeviceType;
   860 	return DefaultPerceivedDeviceType;
   849 	}
   861 	}
   850 
   862 
   851 /**
   863 /**
   852 * Get method for PerceivedDeviceType(0x00000003 Mobile Handset).
   864 * Get method for PerceivedDeviceType(0x00000003 Mobile Handset).
   860 * 0x00000006	Audio Recorder.
   872 * 0x00000006	Audio Recorder.
   861 * @return TUint32: return value for PerceivedDeviceType.
   873 * @return TUint32: return value for PerceivedDeviceType.
   862 */
   874 */
   863 TUint32 CMTPDeviceDataStore::PerceivedDeviceType() const
   875 TUint32 CMTPDeviceDataStore::PerceivedDeviceType() const
   864 	{
   876 	{
   865 	__FLOG(_L8("SessionInitiatorVersionInfo - Entry:Exit"));
   877 	OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_PERCEIVEDDEVICETYPE_ENTRY );
       
   878 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_PERCEIVEDDEVICETYPE_Exit );
   866 	return iPerceivedDeviceType.Value();
   879 	return iPerceivedDeviceType.Value();
   867 	}
   880 	}
   868 
   881 
   869 /**
   882 /**
   870 * Get method for Date time.
   883 * Get method for Date time.
   871 * @return TDesC: const date time string YYYYMMDDThhmmss.s
   884 * @return TDesC: const date time string YYYYMMDDThhmmss.s
   872 **/
   885 **/
   873 const TDesC& CMTPDeviceDataStore::DateTimeL()
   886 const TDesC& CMTPDeviceDataStore::DateTimeL()
   874 	{
   887 	{
   875 	__FLOG(_L8("DateTime - Entry:Exit"));
   888 	OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_DATETIMEL_ENTRY );
   876 	TBuf<30> dateTimeString;
   889 	TBuf<30> dateTimeString;
   877 	DateTimeToStringL(dateTimeString);
   890 	DateTimeToStringL(dateTimeString);
   878 	iDateTime->SetL(dateTimeString);
   891 	iDateTime->SetL(dateTimeString);
   879 	__FLOG(_L8("DateTime -Exit"));
   892 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_DATETIMEL_EXIT );
   880 	return iDateTime->StringChars();
   893 	return iDateTime->StringChars();
   881 	}
   894 	}
   882 
   895 
   883 /**
   896 /**
   884 * This method to set the date time on MTP device
   897 * This method to set the date time on MTP device
   888 *@Param aDateTime : Date time string.
   901 *@Param aDateTime : Date time string.
   889 * Some modification need to be done on this method(minor change).
   902 * Some modification need to be done on this method(minor change).
   890 **/
   903 **/
   891 TInt CMTPDeviceDataStore::SetDateTimeL(const TDesC& aDateTime )
   904 TInt CMTPDeviceDataStore::SetDateTimeL(const TDesC& aDateTime )
   892     {
   905     {
   893     __FLOG(_L8("SetDateTime - Entry"));
   906     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_SETDATETIMEL_ENTRY );
   894     TBuf<30> dateTime;
   907     TBuf<30> dateTime;
   895     TInt offset = User::UTCOffset().Int();
   908     TInt offset = User::UTCOffset().Int();
   896 	//get actul time to set, offset  + ,- or UTC and offset from UTC in seconds.
   909 	//get actul time to set, offset  + ,- or UTC and offset from UTC in seconds.
   897     TInt errorCode = ValidateString(aDateTime, dateTime, offset);
   910     TInt errorCode = ValidateString(aDateTime, dateTime, offset);
   898     if(KErrNone == errorCode)
   911     if(KErrNone == errorCode)
   908 	   	{
   921 	   	{
   909                   //if date time is YYYYMMDDTHHMMSS.S or append with 'Z' then
   922                   //if date time is YYYYMMDDTHHMMSS.S or append with 'Z' then
   910 		  TTimeIntervalSeconds utcOffset(offset);
   923 		  TTimeIntervalSeconds utcOffset(offset);
   911         	  // Subtract seconds ahead, to get to UTC timezone
   924         	  // Subtract seconds ahead, to get to UTC timezone
   912          	  tt -= utcOffset;
   925          	  tt -= utcOffset;
   913         	  __FLOG(_L8("Setting UTC time"));
   926         	  OstTrace0( TRACE_NORMAL, DUP1_CMTPDEVICEDATASTORE_SETDATETIMEL, 
       
   927         	          "Setting UTC time" );
   914         	  errorCode = User::SetUTCTime(tt);
   928         	  errorCode = User::SetUTCTime(tt);
   915                   __FLOG_STMT(TBuf<30> readable;)
   929         #ifdef OST_TRACE_COMPILER_IN_USE
   916         	  __FLOG_STMT(tt.FormatL(readable, _L("%F%Y%M%DT%H%T%SZ"));)
   930         	  TBuf<30> readable;
   917         	  __FLOG_1(_L("Time now: %S"), &readable);
   931         	  tt.FormatL(readable, _L("%F%Y%M%DT%H%T%SZ"));
       
   932         #endif
       
   933               OstTraceExt1( TRACE_NORMAL, DUP2_CMTPDEVICEDATASTORE_SETDATETIMEL, 
       
   934                       "Time now: %S", readable);                  
   918                 }
   935                 }
   919         }
   936         }
   920         __FLOG_1(_L8("SetDateTime - Exit %d"), errorCode);
   937     
   921 
   938     OstTrace1(TRACE_NORMAL, CMTPDEVICEDATASTORE_SETDATETIMEL, "Exit %d", errorCode);
   922 	return errorCode;
   939 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_SETDATETIMEL_EXIT );
       
   940 		return errorCode;
   923     }
   941     }
   924 
   942 
   925 
   943 
   926 /**
   944 /**
   927 *This method will create a string that is compatible for MTP datet time .
   945 *This method will create a string that is compatible for MTP datet time .
   929 * yet but that can be done easly. one more function can be implemented
   947 * yet but that can be done easly. one more function can be implemented
   930 * for appending 0s
   948 * for appending 0s
   931 **/
   949 **/
   932 void CMTPDeviceDataStore::DateTimeToStringL(TDes& aDateTime)
   950 void CMTPDeviceDataStore::DateTimeToStringL(TDes& aDateTime)
   933     {
   951     {
   934     __FLOG(_L8("DateTimeToString - Entry"));
   952     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_DATETIMETOSTRINGL_ENTRY );
   935     //get home time and convert it to string
   953     //get home time and convert it to string
   936     TTime tt;
   954     TTime tt;
   937     tt.UniversalTime();    
   955     tt.UniversalTime();    
   938     _LIT(KFormat,"%F%Y%M%DT%H%T%SZ");
   956     _LIT(KFormat,"%F%Y%M%DT%H%T%SZ");
   939     tt.FormatL(aDateTime, KFormat);
   957     tt.FormatL(aDateTime, KFormat);
   940     __FLOG(_L8("DateTimeToString - Exit"));
   958 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_DATETIMETOSTRINGL_EXIT );
   941 	}
   959 	}
   942 
   960 
   943 /**
   961 /**
   944 *This method will convert MTP date time format ("YYYYMMDDThhmmss.s")to
   962 *This method will convert MTP date time format ("YYYYMMDDThhmmss.s")to
   945 *TTime time format YYYYMMDD:hhmmss.ssssss. Right now microsecond part is
   963 *TTime time format YYYYMMDD:hhmmss.ssssss. Right now microsecond part is
   946 * not implemented.
   964 * not implemented.
   947 **/
   965 **/
   948 void CMTPDeviceDataStore::StringToDateTimeL(TDes& aDateTime )
   966 void CMTPDeviceDataStore::StringToDateTimeL(TDes& aDateTime )
   949 	{
   967 	{
   950     __FLOG(_L8("StringToDateTime - Entry"));
   968     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_STRINGTODATETIMEL_ENTRY );
   951 	TBuf<30> newTime;
   969 	TBuf<30> newTime;
   952 	_LIT(KDlemMTP,"T");
   970 	_LIT(KDlemMTP,"T");
   953 	_LIT(KDlemTTime,":");
   971 	_LIT(KDlemTTime,":");
   954 	TInt pos = aDateTime.Find(KDlemMTP)	;
   972 	TInt pos = aDateTime.Find(KDlemMTP)	;
   955 	if((KErrNotFound != pos) && (KPosDelemT == pos))
   973 	if((KErrNotFound != pos) && (KPosDelemT == pos))
   976 		newTime.Append(aDateTime.Mid(pos + 1));
   994 		newTime.Append(aDateTime.Mid(pos + 1));
   977 		aDateTime.Copy(newTime);
   995 		aDateTime.Copy(newTime);
   978 		}
   996 		}
   979 	else
   997 	else
   980 		{
   998 		{
       
   999         OstTraceExt1( TRACE_ERROR, DUP1_CMTPDEVICEDATASTORE_STRINGTODATETIMEL, 
       
  1000                 "wrong argument, can't convert string %S to datetime", aDateTime); 
   981         User::Leave( KErrArgument );
  1001         User::Leave( KErrArgument );
   982 		}
  1002 		}
   983         __FLOG_1(_L("Processed DateTime: %S"), &aDateTime);	
  1003         OstTraceExt1(TRACE_NORMAL, CMTPDEVICEDATASTORE_STRINGTODATETIMEL,
   984 	__FLOG(_L8("StringToDateTime - Exit"));
  1004                 "Processed DateTime: %S", aDateTime);
       
  1005 	OstTraceFunctionExit0( CMTPDEVICEDATASTORE_STRINGTODATETIMEL_EXIT );
   985 	}
  1006 	}
   986 
  1007 
   987 /**
  1008 /**
   988 *This method to validate the incoming date time string
  1009 *This method to validate the incoming date time string
   989 *Any incoming string from intiator supposed to be either  YYYYMMDDThhmmss.s
  1010 *Any incoming string from intiator supposed to be either  YYYYMMDDThhmmss.s
   992 *2.based on the carector and its position.
  1013 *2.based on the carector and its position.
   993 *char allowded are 'Z', 'T', '.','+' and '-'
  1014 *char allowded are 'Z', 'T', '.','+' and '-'
   994 */
  1015 */
   995 TInt CMTPDeviceDataStore::ValidateString(const TDesC& aDateTimeStr, TDes& aDateTime, TInt &aOffsetVal)
  1016 TInt CMTPDeviceDataStore::ValidateString(const TDesC& aDateTimeStr, TDes& aDateTime, TInt &aOffsetVal)
   996 	{
  1017 	{
   997         __FLOG(_L8("ValidateString - Entry"));
  1018     OstTraceFunctionEntry0( CMTPDEVICEDATASTORE_VALIDATESTRING_ENTRY );
   998         __FLOG_1(_L("Supplied date: %S"), &aDateTimeStr);
  1019     OstTraceExt1(TRACE_NORMAL, CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1020             "Supplied date: %S", aDateTimeStr);
   999 	_LIT(KDlemMTP,"T");
  1021 	_LIT(KDlemMTP,"T");
  1000 	TInt errCode = KErrNone;
  1022 	TInt errCode = KErrNone;
  1001 	TInt pos = aDateTimeStr.Find(KDlemMTP);
  1023 	TInt pos = aDateTimeStr.Find(KDlemMTP);
  1002         TInt nullCharPos = aDateTimeStr.Locate('\0');
  1024         TInt nullCharPos = aDateTimeStr.Locate('\0');
  1003 	if ( KErrNotFound != nullCharPos )
  1025 	if ( KErrNotFound != nullCharPos )
  1011 
  1033 
  1012 	//1.validation is done based on minimum length of the string and pos
  1034 	//1.validation is done based on minimum length of the string and pos
  1013 	if((KErrNotFound ==  pos )	|| (aDateTimeStr.Length() > KMaxDateTimeLength) ||
  1035 	if((KErrNotFound ==  pos )	|| (aDateTimeStr.Length() > KMaxDateTimeLength) ||
  1014 	    (aDateTimeStr.Length() < KMinDateTimeLength) || pos != KPosDelemT)
  1036 	    (aDateTimeStr.Length() < KMinDateTimeLength) || pos != KPosDelemT)
  1015 		{
  1037 		{
  1016                 __FLOG_2(_L8("Invalid. pos: %d, len: %d"), pos, aDateTimeStr.Length());
  1038         OstTraceExt2(TRACE_NORMAL, DUP1_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1039                 "Invalid. pos: %d, len: %d", pos, aDateTimeStr.Length());
  1017 		errCode = KErrGeneral;
  1040 		errCode = KErrGeneral;
  1018 		}
  1041 		}
  1019 	else
  1042 	else
  1020 		{
  1043 		{
  1021 		//validation based on the carector and its position.
  1044 		//validation based on the carector and its position.
  1028 				{
  1051 				{
  1029 				case 'T':
  1052 				case 'T':
  1030 				case 't':
  1053 				case 't':
  1031 				if(i != pos)
  1054 				if(i != pos)
  1032 					{
  1055 					{
  1033                                         __FLOG_1(_L8("Invalid. 'T' encountered at offset %d"), i);
  1056                     OstTrace1(TRACE_NORMAL, DUP2_CMTPDEVICEDATASTORE_VALIDATESTRING,
  1034 					//error char at rong position
  1057                             "Invalid. 'T' encountered at offset %d", i);
       
  1058                     //error char at rong position
  1035 					errCode = KErrGeneral;
  1059 					errCode = KErrGeneral;
  1036 					}//else fine
  1060 					}//else fine
  1037 				break;
  1061 				break;
  1038 				case 'Z':
  1062 				case 'Z':
  1039 				case 'z':
  1063 				case 'z':
  1040 					aOffsetVal = 0;
  1064 					aOffsetVal = 0;
  1041                                         aDateTime.Copy(aDateTimeStr.Mid(0, i));
  1065                                         aDateTime.Copy(aDateTimeStr.Mid(0, i));
  1042 					//error char at wrong position
  1066 					//error char at wrong position
  1043 					if(i <KMinDateTimeLength)
  1067 					if(i <KMinDateTimeLength)
  1044 						{
  1068 						{
  1045                                                 __FLOG_1(_L8("Invalid. 'Z' encountered at offset %d"), i);
  1069                         OstTrace1(TRACE_NORMAL, DUP3_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1070                                 "Invalid. 'Z' encountered at offset %d", i);                        
  1046 						//error char at wrong position
  1071 						//error char at wrong position
  1047 						errCode = KErrGeneral;
  1072 						errCode = KErrGeneral;
  1048 						}//else fine
  1073 						}//else fine
  1049 					break;
  1074 					break;
  1050 				case '+':
  1075 				case '+':
  1051 				case '-':
  1076 				case '-':
  1052 					if(i < KMinDateTimeLength)
  1077 					if(i < KMinDateTimeLength)
  1053 						{
  1078 						{
  1054 						//error char at wrong position
  1079 						//error char at wrong position
  1055 						errCode = KErrGeneral;
  1080 						errCode = KErrGeneral;
  1056                                                 __FLOG_1(_L8("Invalid. '+/-' encountered at offset %d"), i);
  1081                         OstTrace1(TRACE_NORMAL, DUP4_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1082                                 "Invalid. '+/-' encountered at offset %d", i);  
  1057 						break;
  1083 						break;
  1058 						}
  1084 						}
  1059 					else
  1085 					else
  1060 						{
  1086 						{
  1061 						const TInt KHoursDigits = 2;
  1087 						const TInt KHoursDigits = 2;
  1072                                                 TLex minuteOffsetLex(aDateTimeStr.Mid(i+KHoursDigits+1, KMinutesDigits));
  1098                                                 TLex minuteOffsetLex(aDateTimeStr.Mid(i+KHoursDigits+1, KMinutesDigits));
  1073                                                 minuteOffsetLex.Val(minuteOffset);
  1099                                                 minuteOffsetLex.Val(minuteOffset);
  1074 						if ((hourOffset > 23) || (minuteOffset > 59))
  1100 						if ((hourOffset > 23) || (minuteOffset > 59))
  1075                                                      {
  1101                                                      {
  1076                                                      errCode = KErrGeneral;
  1102                                                      errCode = KErrGeneral;
  1077                                                      __FLOG_2(_L8("Invalid. Hour(%d) or Minute(%d) offset out of range."), hourOffset, minuteOffset);
  1103                                                      OstTraceExt2(TRACE_NORMAL, DUP5_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1104                                                              "Invalid. Hour(%d) or Minute(%d) offset out of range.", hourOffset, minuteOffset); 
  1078                                                      break;
  1105                                                      break;
  1079                                                      }
  1106                                                      }
  1080 
  1107 
  1081                                                      
  1108                                                      
  1082                                                 aOffsetVal = (hourOffset * KSecondsPerHour) + (minuteOffset * KSecondsPerMinute);
  1109                                                 aOffsetVal = (hourOffset * KSecondsPerHour) + (minuteOffset * KSecondsPerMinute);
  1083                                                 if ('-' == aDateTimeStr[i])
  1110                                                 if ('-' == aDateTimeStr[i])
  1084 							{
  1111 							{
  1085 					                aOffsetVal = -aOffsetVal;
  1112 					                aOffsetVal = -aOffsetVal;
  1086 							}
  1113 							}
  1087                                                 __FLOG_1(_L8("Info: Timezone offset %d seconds"), aOffsetVal);	
  1114                                                 OstTrace1(TRACE_NORMAL, DUP6_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1115                                                         "Info: Timezone offset %d seconds", aOffsetVal);  
  1088 						}
  1116 						}
  1089 
  1117 
  1090 					break;
  1118 					break;
  1091 				case '.':
  1119 				case '.':
  1092 				case '\0':
  1120 				case '\0':
  1093 				if(i < KMinDateTimeLength)
  1121 				if(i < KMinDateTimeLength)
  1094 					{
  1122 					{
  1095 					//error char at wrong position
  1123 					//error char at wrong position
  1096 					errCode = KErrGeneral;
  1124 					errCode = KErrGeneral;
  1097                                         __FLOG_1(_L8("Invalid. '.' or NULL at offset %d"), i);
  1125                     OstTrace1(TRACE_NORMAL, DUP7_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1126                             "Invalid. '.' or NULL at offset %d", i); 
  1098 					}
  1127 					}
  1099 				break;
  1128 				break;
  1100 				default :
  1129 				default :
  1101 				//wrong char
  1130 				//wrong char
  1102 				errCode = KErrGeneral;
  1131 				errCode = KErrGeneral;
  1103                                 __FLOG_2(_L8("Invalid. Character %04x at offset %d"), aDateTimeStr[i], i);
  1132                 OstTraceExt2(TRACE_NORMAL, DUP8_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1133                         "Invalid. Character %04x at offset %d", aDateTimeStr[i], i); 
  1104 				break;
  1134 				break;
  1105 				}
  1135 				}
  1106 		}
  1136 		}
  1107 		if(KErrNone != errCode)
  1137 		if(KErrNone != errCode)
  1108 			{
  1138 			{
  1109 		        __FLOG_2(_L("Processed date: %S, TimeZone: %ds ahead"), &aDateTimeStr, aOffsetVal);
  1139             OstTraceExt2(TRACE_NORMAL, DUP9_CMTPDEVICEDATASTORE_VALIDATESTRING,
  1110                         __FLOG_1(_L8("ValidateString - Exit %d"), errCode);
  1140                     "Processed date: %S, TimeZone: %ds ahead", aDateTimeStr, aOffsetVal); 
       
  1141             OstTrace1(TRACE_NORMAL, DUP10_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1142                     "ValidateString - Exit %d", errCode); 
       
  1143 			OstTraceFunctionExit0( CMTPDEVICEDATASTORE_VALIDATESTRING_EXIT );
  1111 			return errCode;
  1144 			return errCode;
  1112 			}
  1145 			}
  1113 		}
  1146 		}
  1114 	}
  1147 	}
  1115 	__FLOG_2(_L("Processed date: %S, TimeZone: %ds ahead"), &aDateTimeStr, aOffsetVal);
  1148     OstTraceExt2(TRACE_NORMAL, DUP11_CMTPDEVICEDATASTORE_VALIDATESTRING,
  1116         __FLOG_1(_L8("ValidateString - Exit %d"), errCode);
  1149             "Processed date: %S, TimeZone: %ds ahead", aDateTimeStr, aOffsetVal); 
       
  1150     OstTrace1(TRACE_NORMAL, DUP12_CMTPDEVICEDATASTORE_VALIDATESTRING,
       
  1151             "ValidateString - Exit %d", errCode);         
       
  1152 	OstTraceFunctionExit0( DUP1_CMTPDEVICEDATASTORE_VALIDATESTRING_EXIT );
  1117 	return errCode;
  1153 	return errCode;
  1118 	}
  1154 	}
  1119 
  1155 
  1120 /**
  1156 /**
  1121 *This method is to load/Store the deviceIcon to the  CMTPTypeArray iDeviceIcon
  1157 *This method is to load/Store the deviceIcon to the  CMTPTypeArray iDeviceIcon