mtpdataproviders/mtppictbridgedp/src/cmtppictbridgeenumerator.cpp
changeset 49 c20dd21d1eb4
parent 18 1b39655331a3
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    29 #include "mmtppictbridgeenumeratorcallback.h"
    29 #include "mmtppictbridgeenumeratorcallback.h"
    30 #include "ptpdef.h"
    30 #include "ptpdef.h"
    31 #include "cmtpdataprovidercontroller.h"
    31 #include "cmtpdataprovidercontroller.h"
    32 #include <mtp/cmtptypefile.h>
    32 #include <mtp/cmtptypefile.h>
    33 #include <pathinfo.h>
    33 #include <pathinfo.h>
       
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "cmtppictbridgeenumeratorTraces.h"
       
    37 #endif
       
    38 
    34 
    39 
    35 //==================================================================
    40 //==================================================================
    36 // 
    41 // 
    37 //==================================================================  
    42 //==================================================================  
    38 CMTPPictBridgeEnumerator* CMTPPictBridgeEnumerator::NewL(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback)
    43 CMTPPictBridgeEnumerator* CMTPPictBridgeEnumerator::NewL(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback)
    55 //==================================================================
    60 //==================================================================
    56 // 
    61 // 
    57 //==================================================================  
    62 //==================================================================  
    58 void CMTPPictBridgeEnumerator::ConstructL()
    63 void CMTPPictBridgeEnumerator::ConstructL()
    59     {
    64     {
    60     __FLOG_OPEN(KMTPSubsystem, KComponent);
    65     OstTraceFunctionEntry0( CMTPPICTBRIDGEENUMERATOR_CONSTRUCTL_ENTRY );
    61     __FLOG(_L8(">> CMTPPictBridgeEnumerator::ConstructL"));
       
    62     iSingletons.OpenL();
    66     iSingletons.OpenL();
    63     __FLOG(_L8("<< CMTPPictBridgeEnumerator::ConstructL"));
    67     OstTraceFunctionExit0( CMTPPICTBRIDGEENUMERATOR_CONSTRUCTL_EXIT );
    64     }
    68     }
    65 
    69 
    66 /**
    70 /**
    67 destructor
    71 destructor
    68 */    
    72 */    
    69 CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator()
    73 CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator()
    70     {
    74     {
    71     __FLOG(_L8(">> CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator"));
    75     OstTraceFunctionEntry0( CMTPPICTBRIDGEENUMERATOR_CMTPPICTBRIDGEENUMERATOR_DES_ENTRY );
    72     // we keep the persistent handle
    76     // we keep the persistent handle
    73     iSingletons.Close();
    77     iSingletons.Close();
    74     __FLOG(_L8("<< CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator"));
    78     OstTraceFunctionExit0( CMTPPICTBRIDGEENUMERATOR_CMTPPICTBRIDGEENUMERATOR_DES_EXIT );
    75 	__FLOG_CLOSE;
       
    76     }
    79     }
    77 
    80 
    78 // --------------------------------------------------------------------------
    81 // --------------------------------------------------------------------------
    79 //
    82 //
    80 // --------------------------------------------------------------------------
    83 // --------------------------------------------------------------------------
    95 // --------------------------------------------------------------------------
    98 // --------------------------------------------------------------------------
    96 // 
    99 // 
    97 // --------------------------------------------------------------------------
   100 // --------------------------------------------------------------------------
    98 void CMTPPictBridgeEnumerator::EnumerateObjectsL(TUint32 aStorageId)
   101 void CMTPPictBridgeEnumerator::EnumerateObjectsL(TUint32 aStorageId)
    99     {
   102     {
   100     __FLOG(_L8(">> CMTPPictBridgeEnumerator::EnumerateObjectsL"));
   103     OstTraceFunctionEntry0( CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL_ENTRY );
   101     const TUint storageId(iFramework.StorageMgr().DefaultStorageId());
   104     const TUint storageId(iFramework.StorageMgr().DefaultStorageId());
   102 
   105 
   103     if ((aStorageId==KMTPStorageAll) || (aStorageId==storageId))
   106     if ((aStorageId==KMTPStorageAll) || (aStorageId==storageId))
   104         {
   107         {
   105         MMTPObjectMgr& objectMgr=iFramework.ObjectMgr();
   108         MMTPObjectMgr& objectMgr=iFramework.ObjectMgr();
   106 
   109 
   107         //delete the files which maybe impact printing
   110         //delete the files which maybe impact printing
   108         TFileName        fullPath;        
   111         TFileName        fullPath;        
   109 		fullPath = PathInfo::PhoneMemoryRootPath();
   112 		fullPath = PathInfo::PhoneMemoryRootPath();
   110 		fullPath.Append(KHostDiscovery);
   113 		fullPath.Append(KHostDiscovery);
   111 		__FLOG_VA((_L16("full path is %S "), &fullPath));
   114 		OstTraceExt1( TRACE_NORMAL, CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );
   112 		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   115 		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   113 		iFramework.Fs().Delete(fullPath);
   116 		iFramework.Fs().Delete(fullPath);
   114 		
   117 		
   115 		fullPath = PathInfo::PhoneMemoryRootPath();
   118 		fullPath = PathInfo::PhoneMemoryRootPath();
   116 		fullPath.Append(KHostRequest);
   119 		fullPath.Append(KHostRequest);
   117 		__FLOG_VA((_L16("full path is %S "), &fullPath));
   120 	    OstTraceExt1( TRACE_NORMAL, DUP1_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );
   118 		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   121 		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   119 		iFramework.Fs().Delete(fullPath);
   122 		iFramework.Fs().Delete(fullPath);
   120 		
   123 		
   121 		fullPath = PathInfo::PhoneMemoryRootPath();
   124 		fullPath = PathInfo::PhoneMemoryRootPath();
   122 		fullPath.Append(KHostResponse);
   125 		fullPath.Append(KHostResponse);
   123 		__FLOG_VA((_L16("full path is %S "), &fullPath));
   126         OstTraceExt1( TRACE_NORMAL, DUP2_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );		
   124 		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   127 		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   125 		iFramework.Fs().Delete(fullPath);
   128 		iFramework.Fs().Delete(fullPath);
   126 		
   129 		
   127         // enumerate device discovery file (create if not exist)
   130         // enumerate device discovery file (create if not exist)
   128 
   131 
   129         RFile rf;
   132         RFile rf;
   130         CleanupClosePushL(rf);
   133         CleanupClosePushL(rf);
   131         fullPath = PathInfo::PhoneMemoryRootPath();
   134         fullPath = PathInfo::PhoneMemoryRootPath();
   132         fullPath.Append(KDeviceDiscovery);
   135         fullPath.Append(KDeviceDiscovery);
   133         __FLOG_VA((_L16("full path is %S "), &fullPath));
   136         OstTraceExt1( TRACE_NORMAL, DUP3_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );                
   134         iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   137         iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
   135         iFramework.Fs().Delete(fullPath);
   138         iFramework.Fs().Delete(fullPath);
   136         
   139         
   137         rf.Create(iFramework.Fs(), fullPath, EFileWrite);
   140         rf.Create(iFramework.Fs(), fullPath, EFileWrite);
   138         TTime time;
   141         TTime time;
   143         CMTPObjectMetaData* objectP = CMTPObjectMetaData::NewLC(iSingletons.DpController().FileDpId(), EMTPFormatCodeScript, storageId, fullPath);
   146         CMTPObjectMetaData* objectP = CMTPObjectMetaData::NewLC(iSingletons.DpController().FileDpId(), EMTPFormatCodeScript, storageId, fullPath);
   144 
   147 
   145         objectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
   148         objectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
   146 	    objectMgr.InsertObjectL(*objectP);
   149 	    objectMgr.InsertObjectL(*objectP);
   147 	    iDpsDiscoveryHandle = objectP->Uint( CMTPObjectMetaData::EHandle );
   150 	    iDpsDiscoveryHandle = objectP->Uint( CMTPObjectMetaData::EHandle );
   148 	    __FLOG_VA((_L8("added discovery file iDpsDiscoveryHandle is 0x%08X"), iDpsDiscoveryHandle));
   151 	    OstTrace1( TRACE_NORMAL, DUP4_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, 
       
   152 	            "added discovery file iDpsDiscoveryHandle is 0x%08X", iDpsDiscoveryHandle );
   149 
   153 
   150         CleanupStack::PopAndDestroy(objectP);
   154         CleanupStack::PopAndDestroy(objectP);
   151         }
   155         }
   152 		iCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone);
   156 		iCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone);
   153 
   157 
   154     __FLOG(_L8("<< CMTPPictBridgeEnumerator::EnumerateObjectsL"));
   158     OstTraceFunctionExit0( CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL_EXIT );
   155     }
   159     }
   156 
   160