mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp
branchRCL_3
changeset 40 453dfc402455
parent 32 f85613f12947
child 42 0aa8cc770c8a
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp	Thu Jul 15 19:35:12 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp	Thu Aug 19 10:44:03 2010 +0300
@@ -120,8 +120,10 @@
         }     
     
     //Define RProperty of new pictures for status data provider
+	RProcess process;
+	TUid tSid = process.SecureId();
     _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
-    TInt error = RProperty::Define(TUid::Uid(KMTPServerUID), KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
+    TInt error = RProperty::Define(tSid, KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
     if (error != KErrNone && error != KErrAlreadyExists)
         {
         __FLOG_1(_L8("CMTPImageDataProvider::ConstructL - RProperty define error:%d"), error);
@@ -165,6 +167,7 @@
     //Try to delete objects in array
     HandleDeleteObjectsArray();
     iDeleteObjectsArray.ResetAndDestroy();
+    iNewPicHandles.Reset();
     
     __FLOG(_L8("<< ~CMTPImageDataProvider"));
     __FLOG_CLOSE;
@@ -610,8 +613,7 @@
         /**
          * Get image object count from framework and calculate the new pictures
          */
-        TUint newPictures = QueryImageObjectCountL();
-        RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPictures);
+        TUint newPictures = QueryImageObjectCountL();        
         iNewPicNotifier->SetNewPictures(newPictures);
         __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - New Pics: %d"), newPictures);        
         iEnumerated = EFalse;
@@ -693,6 +695,8 @@
     CleanupClosePushL(context);
     CleanupClosePushL(handles);    
     
+    iNewPicHandles.Reset();
+    
     do
         {
         /*
@@ -712,6 +716,7 @@
         if (MTPImageDpUtilits::IsNewPicture(*objMetadata))
             {
             ++newPictures;
+            iNewPicHandles.Append(handles[i]);
             }
         }
     
@@ -765,6 +770,32 @@
     __FLOG(_L8("<< DecreaseNewPictures "));    
     }
 
+void CMTPImageDataProvider::ResetNewPictures()
+	{
+	__FLOG(_L8(">> ResetNewPictures "));
+
+	iNewPicNotifier->SetNewPictures(0);
+	
+	TInt count = iNewPicHandles.Count();
+	if (!count)
+		{
+		return;
+		}
+
+	CMTPObjectMetaData* objMetadata = CMTPObjectMetaData::NewLC();
+	
+	for (TInt i(0); i<count; ++i)
+	{
+		Framework().ObjectMgr().ObjectL(iNewPicHandles[i], *objMetadata);
+		MTPImageDpUtilits::UpdateObjectStatusToOldL(Framework(), *objMetadata);
+	}
+	
+	iNewPicHandles.Reset();
+	CleanupStack::PopAndDestroy(objMetadata);
+	
+	__FLOG(_L8("<< ResetNewPictures "));
+	}
+
 void CMTPImageDataProvider::HandleMdeSessionCompleteL(TInt aError)
     {
     __FLOG(_L8(">> HandleMdeSessionComplete"));