14 * Description: Handles monitored file creations, modifications and deletions.* |
14 * Description: Handles monitored file creations, modifications and deletions.* |
15 */ |
15 */ |
16 |
16 |
17 #include <collate.h> |
17 #include <collate.h> |
18 #include <mdeobject.h> |
18 #include <mdeobject.h> |
|
19 #include <pathinfo.h> |
19 |
20 |
20 #include "fileeventhandlerao.h" |
21 #include "fileeventhandlerao.h" |
21 #include "harvesterlog.h" |
22 #include "harvesterlog.h" |
22 #include "fsutil.h" |
23 #include "fsutil.h" |
23 #include "mdeconstants.h" |
24 #include "mdeconstants.h" |
81 } |
82 } |
82 error = iFs.Connect(); |
83 error = iFs.Connect(); |
83 User::LeaveIfError( error ); |
84 User::LeaveIfError( error ); |
84 |
85 |
85 TRAP( error, ReadCacheSizeFromCenrepL() ); |
86 TRAP( error, ReadCacheSizeFromCenrepL() ); |
|
87 |
86 if ( error == KErrNone ) |
88 if ( error == KErrNone ) |
87 { |
89 { |
88 iQueue.Reserve( iCacheSize ); |
90 iQueue.Reserve( iCacheSize ); |
89 } |
91 } |
90 |
92 |
91 iEventArray = new (ELeave) CArrayFixSeg< TMdsFSPStatus >( KMaxEventsGranularity ); |
93 iEventArray = new (ELeave) CArrayFixSeg< TMdsFSPStatus >( KMaxEventsGranularity ); |
|
94 |
|
95 TFileName phoneRoot = PathInfo::PhoneMemoryRootPath(); |
|
96 TFileName mmcRoot = PathInfo::MemoryCardRootPath(); |
|
97 |
|
98 TFileName images = PathInfo::ImagesPath(); |
|
99 |
|
100 TFileName phoneImagePath( phoneRoot ); |
|
101 phoneImagePath.Append( images ); |
|
102 iPhoneImagesPath = phoneImagePath.AllocL(); |
|
103 |
|
104 TFileName mmcImagePath( mmcRoot ); |
|
105 mmcImagePath.Append( images ); |
|
106 iMmcImagesPath = mmcImagePath.Right( mmcImagePath.Length() - 1 ).AllocL(); |
|
107 |
|
108 TFileName videos = PathInfo::VideosPath(); |
|
109 |
|
110 TFileName phoneVideoPath( phoneRoot ); |
|
111 phoneVideoPath.Append( videos ); |
|
112 iPhoneVideosPath = phoneVideoPath.AllocL(); |
|
113 |
|
114 TFileName mmcVideoPath( mmcRoot ); |
|
115 mmcVideoPath.Append( videos ); |
|
116 iMmcVideosPath = mmcVideoPath.Right( mmcVideoPath.Length() - 1 ).AllocL(); |
|
117 |
|
118 TFileName sounds = PathInfo::SoundsPath(); |
|
119 |
|
120 TFileName phoneSoundPath( phoneRoot ); |
|
121 phoneSoundPath.Append( sounds ); |
|
122 iPhoneSoundsPath = phoneSoundPath.AllocL(); |
|
123 |
|
124 TFileName mmcSoundPath( mmcRoot ); |
|
125 mmcSoundPath.Append( sounds ); |
|
126 iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL(); |
92 } |
127 } |
93 |
128 |
94 // --------------------------------------------------------------------------- |
129 // --------------------------------------------------------------------------- |
95 // CFileEventHandlerAO::~CFileEventHandlerAO() |
130 // CFileEventHandlerAO::~CFileEventHandlerAO() |
96 // --------------------------------------------------------------------------- |
131 // --------------------------------------------------------------------------- |
102 Cancel(); |
137 Cancel(); |
103 |
138 |
104 iFs.Close(); |
139 iFs.Close(); |
105 |
140 |
106 delete iMapper; |
141 delete iMapper; |
|
142 iMapper = NULL; |
|
143 |
107 delete iMoveTimer; |
144 delete iMoveTimer; |
|
145 iMoveTimer = NULL; |
|
146 |
108 delete iFolderRenamer; |
147 delete iFolderRenamer; |
|
148 iFolderRenamer = NULL; |
109 |
149 |
110 delete iEventArray; |
150 delete iEventArray; |
|
151 iEventArray = NULL; |
111 |
152 |
112 iQueue.ResetAndDestroy(); |
153 iQueue.ResetAndDestroy(); |
113 iQueue.Close(); |
154 iQueue.Close(); |
114 |
155 |
115 iUriArray.ResetAndDestroy(); |
156 iUriArray.ResetAndDestroy(); |
116 iUriArray.Close(); |
157 iUriArray.Close(); |
|
158 |
|
159 delete iPhoneImagesPath; |
|
160 iPhoneImagesPath = NULL; |
|
161 delete iMmcImagesPath; |
|
162 iMmcImagesPath = NULL; |
|
163 |
|
164 delete iPhoneVideosPath; |
|
165 iPhoneVideosPath = NULL; |
|
166 delete iMmcVideosPath; |
|
167 iMmcVideosPath = NULL; |
|
168 |
|
169 delete iPhoneSoundsPath; |
|
170 iPhoneSoundsPath = NULL; |
|
171 delete iMmcSoundsPath; |
|
172 iMmcSoundsPath = NULL; |
117 } |
173 } |
118 |
174 |
119 |
175 |
120 |
176 |
121 // --------------------------------------------------------------------------- |
177 // --------------------------------------------------------------------------- |
241 aEvent.iFileName.FindF(KCameraTemp) != KErrNotFound) ) |
298 aEvent.iFileName.FindF(KCameraTemp) != KErrNotFound) ) |
242 { |
299 { |
243 WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - ignored camera origin for %S", &status.iFileName ); |
300 WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - ignored camera origin for %S", &status.iFileName ); |
244 return; |
301 return; |
245 } |
302 } |
|
303 |
|
304 if( (origin == KOriginIgnoreAttribsChanged || |
|
305 origin == MdeConstants::Object::ECamera ) && |
|
306 aEvent.iFileEventType == EMdsFileAttribsChanged ) |
|
307 { |
|
308 WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - ignored attribs changed event for %S", &status.iFileName ); |
|
309 return; |
|
310 } |
246 } |
311 } |
247 |
312 |
248 // ignore created file event if extension is not supported by any harverter plugin |
313 // ignore created file event if extension is not supported by any harverter plugin |
249 if( EMdsFileCreated == status.iFileEventType && |
314 if( EMdsFileCreated == status.iFileEventType && |
250 status.iFileName.Length() > 0 ) |
315 status.iFileName.Length() > 0 ) |
279 RenameToMDEL( status.iFileName, status.iNewFileName, origin ); |
344 RenameToMDEL( status.iFileName, status.iNewFileName, origin ); |
280 } |
345 } |
281 break; |
346 break; |
282 |
347 |
283 case EMdsFileModified: |
348 case EMdsFileModified: |
|
349 case EMdsFileAttribsChanged: |
284 { |
350 { |
285 WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - EmdsFileModified: %S", &status.iFileName ); |
351 WRITELOG1( "CFileEventHandlerAO::HandleNotificationL - EmdsFileModified: %S", &status.iFileName ); |
286 ModifyL( status.iFileName, origin, fastHarvest ); |
352 ModifyL( status.iFileName, origin, fastHarvest ); |
287 } |
353 } |
288 break; |
354 break; |
439 { |
505 { |
440 const TItemId removedId = iMdeSession->Session()->RemoveObjectL( |
506 const TItemId removedId = iMdeSession->Session()->RemoveObjectL( |
441 newObject->Id() ); |
507 newObject->Id() ); |
442 if ( removedId != KNoId ) |
508 if ( removedId != KNoId ) |
443 { |
509 { |
|
510 SetTitleL( oldObject , aNewUrl ); |
444 oldObject->SetUriL( aNewUrl ); |
511 oldObject->SetUriL( aNewUrl ); |
445 TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl ); |
512 TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl ); |
446 oldObject->SetMediaId( mediaId ); |
513 oldObject->SetMediaId( mediaId ); |
447 } |
514 } |
448 } |
515 } |
452 CleanupStack::PopAndDestroy( newObject ); |
519 CleanupStack::PopAndDestroy( newObject ); |
453 } |
520 } |
454 |
521 |
455 if ( oldObject ) |
522 if ( oldObject ) |
456 { |
523 { |
|
524 CheckDefaultFolderL( oldObject ); |
457 SetModifiedTimeL( oldObject, aNewUrl ); |
525 SetModifiedTimeL( oldObject, aNewUrl ); |
458 TOrigin origin = OriginFromMdEObjectL( *oldObject ); |
526 TOrigin origin = OriginFromMdEObjectL( *oldObject ); |
459 if( origin == MdeConstants::Object::EOther) |
527 if( origin == MdeConstants::Object::EOther) |
460 { |
528 { |
461 OriginToMdEObjectL( *oldObject, aOrigin ); |
529 OriginToMdEObjectL( *oldObject, aOrigin ); |
629 if ( oldObject ) |
697 if ( oldObject ) |
630 { |
698 { |
631 CleanupStack::PushL( oldObject ); |
699 CleanupStack::PushL( oldObject ); |
632 SetTitleL( oldObject , aNewUrl ); |
700 SetTitleL( oldObject , aNewUrl ); |
633 oldObject->SetUriL( aNewUrl ); |
701 oldObject->SetUriL( aNewUrl ); |
|
702 CheckDefaultFolderL( oldObject ); |
634 TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl ); |
703 TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl ); |
635 oldObject->SetMediaId( mediaId ); |
704 oldObject->SetMediaId( mediaId ); |
|
705 SetModifiedTimeL( oldObject, aNewUrl ); |
636 TOrigin origin = OriginFromMdEObjectL( *oldObject ); |
706 TOrigin origin = OriginFromMdEObjectL( *oldObject ); |
637 if( origin == MdeConstants::Object::EOther) |
707 if( origin == MdeConstants::Object::EOther) |
638 { |
708 { |
639 OriginToMdEObjectL( *oldObject, aOrigin ); |
709 OriginToMdEObjectL( *oldObject, aOrigin ); |
640 } |
710 } |
651 if ( oldObject ) |
721 if ( oldObject ) |
652 { |
722 { |
653 CleanupStack::PushL( oldObject ); |
723 CleanupStack::PushL( oldObject ); |
654 SetTitleL( oldObject , aNewUrl ); |
724 SetTitleL( oldObject , aNewUrl ); |
655 oldObject->SetUriL( aNewUrl ); |
725 oldObject->SetUriL( aNewUrl ); |
|
726 CheckDefaultFolderL( oldObject ); |
656 TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl ); |
727 TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl ); |
657 oldObject->SetMediaId( mediaId ); |
728 oldObject->SetMediaId( mediaId ); |
658 SetModifiedTimeL( oldObject, aNewUrl ); |
729 SetModifiedTimeL( oldObject, aNewUrl ); |
659 TOrigin origin = OriginFromMdEObjectL( *oldObject ); |
730 TOrigin origin = OriginFromMdEObjectL( *oldObject ); |
660 if( origin == MdeConstants::Object::EOther) |
731 if( origin == MdeConstants::Object::EOther) |
971 { |
1042 { |
972 aOldObject->AddTimePropertyL( *iTimePropertyDef , time ); |
1043 aOldObject->AddTimePropertyL( *iTimePropertyDef , time ); |
973 } |
1044 } |
974 } |
1045 } |
975 |
1046 |
|
1047 //--------------------------------------------------------------------------- |
|
1048 // CFileEventHandlerAO::CheckDefaultFolderL() |
|
1049 // --------------------------------------------------------------------------- |
|
1050 // |
|
1051 void CFileEventHandlerAO::CheckDefaultFolderL( CMdEObject* aOldObject ) |
|
1052 { |
|
1053 if( !iDefaultFolderPropertyDef ) |
|
1054 { |
|
1055 iDefaultFolderPropertyDef = &aOldObject->Def().GetPropertyDefL( |
|
1056 MdeConstants::Object::KInDefaultFolder ); |
|
1057 } |
|
1058 |
|
1059 CMdEProperty* folderProp = NULL; |
|
1060 aOldObject->Property( *iDefaultFolderPropertyDef, folderProp ); |
|
1061 |
|
1062 TBool inDefaultFolder( EFalse ); |
|
1063 TPtrC objectDefName( aOldObject->Def().Name() ); |
|
1064 if( objectDefName == MdeConstants::Image::KImageObject ) |
|
1065 { |
|
1066 const TDesC& uri = aOldObject->Uri(); |
|
1067 if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound || |
|
1068 uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound || |
|
1069 uri.FindF( KDCIMFolder ) != KErrNotFound ) |
|
1070 { |
|
1071 inDefaultFolder = ETrue; |
|
1072 } |
|
1073 } |
|
1074 else if( objectDefName == MdeConstants::Video::KVideoObject ) |
|
1075 { |
|
1076 const TDesC& uri = aOldObject->Uri(); |
|
1077 if( uri.FindF( iMmcVideosPath->Des()) != KErrNotFound || |
|
1078 uri.FindF( iPhoneVideosPath->Des()) != KErrNotFound || |
|
1079 uri.FindF( KDCIMFolder ) != KErrNotFound ) |
|
1080 { |
|
1081 inDefaultFolder = ETrue; |
|
1082 } |
|
1083 } |
|
1084 else if( objectDefName == MdeConstants::Audio::KAudioObject ) |
|
1085 { |
|
1086 const TDesC& uri = aOldObject->Uri(); |
|
1087 if( uri.FindF( iMmcSoundsPath->Des()) != KErrNotFound || |
|
1088 uri.FindF( iPhoneSoundsPath->Des()) != KErrNotFound ) |
|
1089 { |
|
1090 inDefaultFolder = ETrue; |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 if( folderProp ) |
|
1095 { |
|
1096 folderProp->SetBoolValueL( inDefaultFolder ); |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 aOldObject->AddBoolPropertyL( *iDefaultFolderPropertyDef, inDefaultFolder ); |
|
1101 } |
|
1102 } |
|
1103 |