mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp
changeset 38 48c22c726cf9
parent 33 883e91c086aa
child 44 a5deb6b96675
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp	Tue Jul 06 15:13:34 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp	Wed Aug 18 10:38:51 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(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"));