201029_01
authorhgs
Wed, 21 Jul 2010 02:03:54 +0530
changeset 34 b66b8f3a7fd8
parent 30 3a6baaa22be8
child 36 e7635922c074
201029_01
messagingfw/msgsrvnstore/server/bwins/v2_MSGSU.DEF
messagingfw/msgsrvnstore/server/eabi/v2_msgsU.def
messagingfw/msgsrvnstore/server/inc/MCLIENT.H
messagingfw/msgsrvnstore/server/inc/MSERVER.H
messagingfw/msgsrvnstore/server/inc/MSVAPI.H
messagingfw/msgsrvnstore/server/inc/MSVIPC.H
messagingfw/msgsrvnstore/server/inc/MSVLOPS.H
messagingfw/msgsrvnstore/server/inc/MSVROPS.H
messagingfw/msgsrvnstore/server/inc/MSVROPS.INL
messagingfw/msgsrvnstore/server/inc/MSVSERV.H
messagingfw/msgsrvnstore/server/inc/MTSR.H
messagingfw/msgsrvnstore/server/src/CMsvCachedStore.cpp
messagingfw/msgsrvnstore/server/src/MCLENTRY.CPP
messagingfw/msgsrvnstore/server/src/MCLIENT.CPP
messagingfw/msgsrvnstore/server/src/MSVIPC.CPP
messagingfw/msgsrvnstore/server/src/MSVLOCAL.CPP
messagingfw/msgsrvnstore/server/src/MSVOPERT.CPP
messagingfw/msgsrvnstore/server/src/MSVSESS.CPP
messagingfw/msgsrvnstore/server/src/MTCLBASE.CPP
messagingfw/msgsrvnstore/server/src/MTSR.CPP
messagingfw/msgsrvnstore/server/src/TMsvServerStoreManager.cpp
--- a/messagingfw/msgsrvnstore/server/bwins/v2_MSGSU.DEF	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/bwins/v2_MSGSU.DEF	Wed Jul 21 02:03:54 2010 +0530
@@ -719,4 +719,6 @@
 	?UnpackL@TMsvPackedDriveIdOperation@@QAEXAAV?$RArray@W4TDriveNumber@@@@@Z @ 718 NONAME ABSENT ; void TMsvPackedDriveIdOperation::UnpackL(class RArray<enum TDriveNumber> &)
 	?UpdateDrivePriorityL@CMsvSession@@QAEXW4TDriveNumber@@AAI@Z @ 719 NONAME ABSENT ; void CMsvSession::UpdateDrivePriorityL(enum TDriveNumber, unsigned int &)
 	?UpdateDrivePriorityL@RMsvServerSession@@QAEXW4TDriveNumber@@AAI@Z @ 720 NONAME ABSENT ; void RMsvServerSession::UpdateDrivePriorityL(enum TDriveNumber, unsigned int &)
+	?ChangeEntriesL@CBaseServerMtm@@UAEHABVCMsvEntrySelection@@HAAVTRequestStatus@@@Z @ 721 NONAME ; int CBaseServerMtm::ChangeEntriesL(class CMsvEntrySelection const &, int, class TRequestStatus &)
+	?ChangeL@CMsvEntry@@QAEPAVCMsvOperation@@ABVCMsvEntrySelection@@HAAVTRequestStatus@@@Z @ 722 NONAME ; class CMsvOperation * CMsvEntry::ChangeL(class CMsvEntrySelection const &, int, class TRequestStatus &)
 
--- a/messagingfw/msgsrvnstore/server/eabi/v2_msgsU.def	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/eabi/v2_msgsU.def	Wed Jul 21 02:03:54 2010 +0530
@@ -1022,4 +1022,8 @@
 	_ZN26TMsvPackedDriveIdOperationC2ERP6HBufC8 @ 1021 NONAME ABSENT
 	_ZNK9CMsvEntry26ChildrenOfAvailableDrivesLEv @ 1022 NONAME ABSENT
 	_ZN28CMsvSearchsortOpOnHeaderBody4NewLER11CMsvSessioni @ 1023 NONAME
+	_ZN14CBaseServerMtm14ChangeEntriesLERK18CMsvEntrySelectioniR14TRequestStatus @ 1024 NONAME
+	_ZN9CMsvEntry7ChangeLERK18CMsvEntrySelectioniR14TRequestStatus @ 1025 NONAME
+	_ZTI31CMsvLocalChangeEntriesOperation @ 1026 NONAME
+	_ZTV31CMsvLocalChangeEntriesOperation @ 1027 NONAME
 
--- a/messagingfw/msgsrvnstore/server/inc/MCLIENT.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MCLIENT.H	Wed Jul 21 02:03:54 2010 +0530
@@ -99,6 +99,8 @@
 	// Asynchronous messages
 	IMPORT_C void CreateEntryL(const TMsvEntry& aEntry, TMsvOp aOperationId, TSecureId aOwnerId, TRequestStatus& aRequestStatus);
 	IMPORT_C void ChangeEntryL(const TMsvEntry& aEntry, TMsvOp aOperationId, TSecureId aOwnerId, TRequestStatus& aRequestStatus);
+	void ChangeEntriesL(const CMsvEntrySelection& aSelection,TBool aMark, TMsvOp aOperationId, TSecureId aOwnerId, TRequestStatus& aRequestStatus);
+	
 	IMPORT_C void DeleteEntriesL(const CMsvEntrySelection& aSelection, TMsvOp aOperationId, TRequestStatus& aRequestStatus);
 	IMPORT_C void MoveEntriesL(const CMsvEntrySelection& aSelection, TMsvId aTarget, TMsvOp aOperationId, TRequestStatus& aRequestStatus);
 	IMPORT_C void CopyEntriesL(const CMsvEntrySelection& aSelection, TMsvId aTarget, TMsvOp aOperationId, TRequestStatus& aRequestStatus);
@@ -217,7 +219,6 @@
 	void SendCommandDataL(TMsvOp aOperationId, const CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter);
 	void TestSlotAvailableL();
 	void PackOperationDataL(const CMsvEntrySelection& aSelection, TInt aParameter1, TInt aParameter2);
-	void DoGetEntryL(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry);
 
 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
 	void DoGetChildrenAllL(TMsvId aId, CArrayPtrFlat<CMsvClientEntry>& aEntries, const TMsvSelectionOrdering& aOrdering);
--- a/messagingfw/msgsrvnstore/server/inc/MSERVER.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MSERVER.H	Wed Jul 21 02:03:54 2010 +0530
@@ -148,7 +148,7 @@
 	EMsvIdWithSortFiled=89,
 	EMsvGetSearchSortProgress=90,
 	EMsvCancelSearchSortOp=91,
-	EMsvUpdateAndSort=92
+	EMsvUpdateAndSort=92,
 	// Code added for PREQ 557.
 	// Macros for preferred drive list APIs.
 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
@@ -162,7 +162,7 @@
     EMsvGetChildIdsALL=101
 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
 	,EMsvResetRepository=102,
-	EMsvPrintCache=103
+	EMsvPrintCache=103,
 #endif
 #endif		// #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
 
@@ -180,8 +180,9 @@
 	EMsvConvertMessageStore=113,
 	EMsvCancelConversionRequest=114,
 	EMsvGetConvertibleDriveList=115,
-	EMsvGetConversionStatus=116
+	EMsvGetConversionStatus=116,
 #endif
+	EMsvChangeEntries = 117
 	};
 
 
--- a/messagingfw/msgsrvnstore/server/inc/MSVAPI.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MSVAPI.H	Wed Jul 21 02:03:54 2010 +0530
@@ -928,6 +928,7 @@
 	// --- Asynchronous Current Entry functions ---
 	IMPORT_C CMsvOperation* ChangeL(const TMsvEntry& aEntry, TRequestStatus& aStatus);
 	IMPORT_C CMsvOperation* ChangeL(const TMsvEntry& aEntry, TSecureId aOwnerId, TRequestStatus& aStatus);
+	IMPORT_C CMsvOperation* ChangeL(const CMsvEntrySelection& aSelection, TBool aMark,TRequestStatus& aStatus);
 	//
 	// --- Asynchronous Child Entry functions ---
 	IMPORT_C CMsvOperation* CreateL(const TMsvEntry& aEntry, TRequestStatus& aStatus);
--- a/messagingfw/msgsrvnstore/server/inc/MSVIPC.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MSVIPC.H	Wed Jul 21 02:03:54 2010 +0530
@@ -93,6 +93,8 @@
 	IMPORT_C TMsvPackedEntry(HBufC8*& aBuffer);
 	IMPORT_C TInt PackEntry(const TMsvEntry& aEntry);
 	IMPORT_C void UnpackEntry(TMsvEntry& aEntry);
+    TInt PackEntryAndService(const TMsvEntry& aEntry, const TMsvId& aServiceId);
+    void UnpackEntryAndService(TMsvEntry& aEntry, TMsvId& aServiceId);
 private:
 	HBufC8*& iBuffer;
 	};
--- a/messagingfw/msgsrvnstore/server/inc/MSVLOPS.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MSVLOPS.H	Wed Jul 21 02:03:54 2010 +0530
@@ -197,7 +197,43 @@
 	TMsvId iId;
 	TMsvId iParent;
 	};
+///
+//**********************************
+// CMsvLocalChangeOperation
+//**********************************
+//
+// Operation used to control server side local change od selection of ids.
+//
 
+class CMsvLocalChangeEntriesOperation : public CMsvLocalOperation
+/**
+@internalComponent
+@released
+*/
+    {
+public:
+    CMsvLocalChangeEntriesOperation(const RMessage2& aMessage, TMsvOp aId, CMsvEntrySelection* aSelection, CMsvServer& aMsvServer, TInt aMark);
+    ~CMsvLocalChangeEntriesOperation();
+    //
+    void StartL(TSecureId aOwnerId, TBool aForcedUpdate);
+    //
+private:
+    void DoCancel();
+    void RunL();
+    void Completed();
+    //
+private:
+    CMsvEntrySelection* iSelection;
+    CMsvEntrySelection* iWorkSelection1;
+    CMsvEntrySelection* iWorkSelection2;
+    CMsvDelete* iDelete;
+    TMsvId iId;
+    TMsvId iParent;
+    TInt iMark;
+    };
+
+
+///
 //**********************************
 // CMsvLocalCreateOperation
 //**********************************
--- a/messagingfw/msgsrvnstore/server/inc/MSVROPS.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MSVROPS.H	Wed Jul 21 02:03:54 2010 +0530
@@ -49,7 +49,8 @@
 						EMtmOpDeleteAll,
 						EMtmOpCreate,
 						EMtmOpChange,
-						EMtmOpCommand};
+						EMtmOpCommand,
+						EMtmOpChangeEntries};
 public:
 	static CMsvMtmOperation* NewL(const RMessage2& aMessage, TMsvOp aId, TUid aMtmUid, TMsvId aServiceId, TInt aSessionId, MMsvOperationObserver& aOpObserver);
 	~CMsvMtmOperation();
@@ -70,6 +71,7 @@
 	inline void DeleteAll(CMsvEntrySelection* aSelection);
 	inline void CreateL(const TMsvEntry& aNewEntry);
 	inline void ChangeL(const TMsvEntry& aNewEntry);
+	inline void ChangeEntriesL(CMsvEntrySelection* aSelection, TInt aMark);
 	inline void StartCommand(CMsvEntrySelection* aSelection, TInt aCommand, HBufC8* aParameter);
 #if (defined SYMBIAN_USER_PROMPT_SERVICE)	
  	inline void SetThreadId(TThreadId aThreadId);
--- a/messagingfw/msgsrvnstore/server/inc/MSVROPS.INL	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MSVROPS.INL	Wed Jul 21 02:03:54 2010 +0530
@@ -60,6 +60,11 @@
 	StoreParametersL(EMtmOpChange, aNewEntry);
 	}
 
+inline void CMsvMtmOperation::ChangeEntriesL(CMsvEntrySelection* aSelection, TInt aMark)
+    {
+    StoreParameters(EMtmOpChangeEntries, aSelection ,aMark, NULL);
+    }
+
 inline void CMsvMtmOperation::StartCommand(CMsvEntrySelection* aSelection, TInt aCommand, HBufC8* aParameter)
 	{
 	StoreParameters(EMtmOpCommand ,aSelection ,aCommand, aParameter);
--- a/messagingfw/msgsrvnstore/server/inc/MSVSERV.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MSVSERV.H	Wed Jul 21 02:03:54 2010 +0530
@@ -108,7 +108,8 @@
 	EMsvProgressBufferExceeds256=12,
 	EMsvNoEntriesInMoveSelection=13,
 	EMsvNoEntriesInCopySelection=14,
-	EMsvNoEntriesInChangeAttributesSelection=15
+	EMsvNoEntriesInChangeAttributesSelection=15,
+	EMsvNoEntriesInChangeSelection=16
 	};
 
 const TInt KMsvMessageDriveStreamVersionNumber = 3;
@@ -558,8 +559,11 @@
 	void OperationMtmL(const RMessage2 &aMessage);
 	//
 	void ChangeEntryL(const RMessage2 &aMessage);
+	void ChangeEntriesL(const RMessage2 &aMessage);
 	void DoChangeLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId);
 	void DoChangeRemoteEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage);
+	void DoChangeLocalEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId, TInt aMark);
+	void DoChangeRemoteEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage,TInt aMark);
 	//
 	void CreateEntryL(const RMessage2 &aMessage);
 	void DoCreateLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId);
@@ -585,7 +589,7 @@
 	void CopyCommandDataL(const RMessage2 &aMessage);
 	HBufC8* RecoverOperationData(TMsvOp aOpId);
 	//
-	void PackEntryAndWriteBufferL(const RMessage2 &aMessage, TInt aParam, const TMsvEntry& aEntry);
+	void PackEntryAndWriteBufferL(const RMessage2 &aMessage, TInt aParam, const TMsvEntry& aEntry, const TMsvId& aServiceId);
 	//
 	void WriteBufferL(const RMessage2 &aMessage, TInt aParam);
 	void WriteL(const RMessage2 &aMessage, TInt aParam, const TDesC8& aDes);
--- a/messagingfw/msgsrvnstore/server/inc/MTSR.H	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/inc/MTSR.H	Wed Jul 21 02:03:54 2010 +0530
@@ -383,7 +383,8 @@
 #endif
 
 	TInt GetNonOperationMtmData(TNonOperationMtmDataType& aMtmDataType, TPtrC8& aResultBuffer);
-
+	
+	IMPORT_C virtual TInt ChangeEntriesL( const CMsvEntrySelection& aSelection,TInt aMark, TRequestStatus& aStatus );
 protected:
 	IMPORT_C CBaseServerMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aServerEntry);
 	/** Handles the completion of any asynchronous requests that it makes. It is called 
--- a/messagingfw/msgsrvnstore/server/src/CMsvCachedStore.cpp	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/CMsvCachedStore.cpp	Wed Jul 21 02:03:54 2010 +0530
@@ -620,16 +620,13 @@
 	RFileWriteStream out(tempStoreFile);
 	out.PushL();
 	WriteToFileStreamL(out);
-	CleanupStack::PopAndDestroy(&out); // close RFileWriteStream out
-	iStoreManager.ReplaceFileStoreL(iEntryId);
 
-	// Need the size
-	RFile storeFile;
-	User::LeaveIfError(iStoreManager.OpenFileStoreForRead(iEntryId, storeFile));
-	CleanupClosePushL(storeFile);
-	User::LeaveIfError(storeFile.Size(iSize));
-	CleanupStack::PopAndDestroy(&storeFile);
+	//get the size of the stream, in previous call the Stream is already commited to the file, the next step simply replace the file with this temp new file so size should be the same
+	//the SizeL in this case will not involve any file i/o calls.
+	iSize=out.Sink()->SizeL();
 	
+    CleanupStack::PopAndDestroy(&out); // close RFileWriteStream out
+    iStoreManager.ReplaceFileStoreL(iEntryId);
 
 	}
 
--- a/messagingfw/msgsrvnstore/server/src/MCLENTRY.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MCLENTRY.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -920,6 +920,68 @@
 	iEntryPtr = &iEntries->At(0)->Entry();
 	}
 
+/** 
+Update a selection of children to read or Unread asynchronously of the context. 
+The returned CMsvOperation object .
+
+@param	aSelection 
+The selectio of entry values for the context
+
+@param	aMark 
+True : Update selection to UnRead .
+False: Update selection to Read . 
+
+@param aStatus The request status to be completed when the operation has finished .
+
+@leave KErrAccessDenied The entry is locked by another client 
+
+@return
+An operation object controlling the change command
+*/
+EXPORT_C CMsvOperation* CMsvEntry::ChangeL(const CMsvEntrySelection& aSelection,TBool aMark, TRequestStatus& aStatus)
+     {
+#ifndef _NO_SESSION_LOGGING_
+    Log(_L("Asynchronous ChangeL with selection of %d entries"), aSelection.Count()); 
+#endif
+
+    __ASSERT_DEBUG(aSelection.Count(), PanicServer(EMsvEmptySelection));
+
+#if defined(_DEBUG)    
+     
+      TInt aCount = aSelection.Count();
+      while (aCount--)
+          {
+          TMsvEntry aEntry;
+          TMsvId aService;
+          if (iMsvSession.Session().GetEntry(aSelection.At(aCount), aService, aEntry)==KErrNone)
+              {
+              __ASSERT_DEBUG(iState==EValid || iState==EInvalidDeletedContext, PanicServer(EMsvEntryAlreadyChangingContext));
+              __ASSERT_DEBUG(MsvUtils::ValidEntry(aEntry), PanicServer(EMsvChangingToInvalidEntry));
+             
+              // can only change the current context
+              if (!MsvUtils::ValidEntry(aEntry))
+                  User::Leave(KErrArgument);
+              }
+           }
+#endif
+      // cannot change standard folders
+      if (iEntryPtr->StandardFolder())
+          User::Leave(KErrAccessDenied);
+  
+      //// create the operation
+      CMsvEntryOperation* operation = CMsvEntryOperation::NewL(iMsvSession, aStatus);
+      CleanupStack::PushL(operation);
+      User::LeaveIfError(iMsvSession.Session().OperationMtmL(aSelection.At(0), operation->iMtm, operation->iService)); 
+   
+      // start the change operation
+	  iMsvSession.Session().ChangeEntriesL(aSelection, aMark, operation->Id(), RProcess().SecureId(), operation->iStatus);
+     
+      operation->Start();
+      iState = EInvalidChangingContext;
+      CleanupStack::Pop(1); // operation 
+      return operation; 
+      }
+
 
 EXPORT_C CMsvOperation* CMsvEntry::DeleteL(TMsvId aId, TRequestStatus& aStatus)
 //
--- a/messagingfw/msgsrvnstore/server/src/MCLIENT.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MCLIENT.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -457,6 +457,25 @@
 	User::LeaveIfError(SendReceive(EMsvChangeEntry, TIpcArgs(aOperationId, aOwnerId)));
 	}
 
+/**
+Update the specified Changes to selection of TMsvId (asynchronously).
+
+@param aSelection The IDs of the entry to Change. 
+@param aMark The read/Unread value.  
+@param aOperationId Operation identifier
+@param aOwnerId The ID of the owning process
+@param aRequestStatus Asynchronous request status
+
+*/
+
+void RMsvServerSession::ChangeEntriesL(const CMsvEntrySelection& aSelection, TBool aMark ,TMsvOp aOperationId, TSecureId aOwnerId, TRequestStatus& aRequestStatus)
+    {
+     TestSlotAvailableL();
+     TInt markvalue = (TInt)aMark;
+     SendOperationDataL(aOperationId, aSelection, markvalue);
+     aRequestStatus=KRequestPending;
+     SendReceive(EMsvChangeEntries, TIpcArgs(aOperationId, aOwnerId), aRequestStatus);
+    }
 
 /**
 Gets the index entry with the specified unique id.
@@ -472,30 +491,36 @@
 */
 EXPORT_C TInt RMsvServerSession::GetEntry(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry)
 	{
-	TRAPD(error, DoGetEntryL(aId, aService, aEntry));
-	return error;
-	}
-
-void RMsvServerSession::DoGetEntryL(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry)
-	{
-	// pass the buffer to receive the data through
-	TPtr8 ptr=iBuffer->Des();
-	// get the service the entry i sunder
-	TPckg<TMsvId> service(aService);
+    // pass the buffer and its max length to receive the data through
+    TPtr8 ptr=iBuffer->Des();
+    TInt maxLength = iBuffer->Des().MaxLength();
+    
 	// signal the server
-	TInt error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,&service));
-	while(error == KErrOverflow)
-		{
-		// increase the size of the buffer and try again
-		iBuffer->Des().SetLength(0);
-		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
-		// pass the buffer to receive the data through
-		TPtr8 ptr=iBuffer->Des();
-		error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,&service));
-		}
-	User::LeaveIfError(error);
-	TMsvPackedEntry packedEntry(iBuffer);
-	packedEntry.UnpackEntry(aEntry);
+    TInt error = SendReceive(EMsvGetEntry,TIpcArgs(aId, &ptr, maxLength));
+    while(error == KErrOverflow)
+        {
+        // increase the size of the buffer and try again
+        iBuffer->Des().SetLength(0);
+        // TRAP here and return if leaving with error
+        TRAP(error, iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength));
+        if( error != KErrNone)
+			{
+            break;
+			}
+        // pass the buffer to receive the data through
+        TPtr8 ptr=iBuffer->Des();
+        maxLength = iBuffer->Des().MaxLength();
+        error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,maxLength));
+        }
+
+    if( error == KErrNone)
+        {
+        TMsvPackedEntry packedEntry(iBuffer);
+        // Unpack the entry and servie id from same buffer
+        packedEntry.UnpackEntryAndService(aEntry, aService);
+        }
+
+    return error;
 	}
 
 /**
--- a/messagingfw/msgsrvnstore/server/src/MSVIPC.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MSVIPC.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -155,6 +155,49 @@
 	DoUnpackEntry(pS, aEntry);
 	}
 
+TInt TMsvPackedEntry::PackEntryAndService(const TMsvEntry& aEntry, const TMsvId& aServiceId)
+    {
+    // find the start and end of the buffer
+    const TUint8* pS = iBuffer->Ptr();
+    const TUint8* pE = PtrAdd(pS, iBuffer->Des().MaxSize());
+
+    TInt error = DoPackEntry(pS, pE, aEntry);
+    if (error==KErrNone)
+        {
+        TInt sizeDes = Align4(sizeof(TMsvId));
+        if ((pS + sizeDes)>pE)
+            {
+            return KErrOverflow;
+            }            
+        // copy the entry and descriptors into the memory area
+        Mem::Copy((void*)pS, &aServiceId, sizeof(TMsvId));
+        pS += sizeDes;
+
+        // update the length of the buffer
+        iBuffer->Des().SetLength(pS-iBuffer->Ptr());
+        }
+
+    return error;    
+    }
+
+void TMsvPackedEntry::UnpackEntryAndService(TMsvEntry& aEntry, TMsvId& aServiceId)
+    {
+#if defined(_DEBUG)
+    // check that the buffer contain a valid package
+    const TMsvEntry* dEntry = (TMsvEntry*) iBuffer->Ptr();
+    const TUint8* dPos = PtrAdd(iBuffer->Ptr(), Align4(sizeof(TMsvEntry)) + Align4(dEntry->iDescription.Size()) + Align4(dEntry->iDetails.Size()) + Align4(sizeof(TMsvId)) );
+    __ASSERT_DEBUG(dPos <= PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxLength()), PanicServer(EMsvEntryOverrunBuffer));
+#endif
+    
+    TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
+    DoUnpackEntry(pS, aEntry);
+
+    // get the service id from the current position in the buffer
+    const TMsvId* pServiceId = (TMsvId*)pS;
+    aServiceId = *pServiceId;
+    pS = Align4(pS + sizeof(TMsvId));
+    }
+
 //**********************************
 // TMsvPackedEntryArray
 //**********************************
--- a/messagingfw/msgsrvnstore/server/src/MSVLOCAL.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MSVLOCAL.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -686,6 +686,125 @@
 	SetState(EMsvOperationCompleted);
 	iMessage.Complete(KErrNone);
 	}
+//**********************************
+// CMsvLocalChangeEntriesOperation
+//**********************************
+
+
+CMsvLocalChangeEntriesOperation::CMsvLocalChangeEntriesOperation(const RMessage2& aMessage, TMsvOp aId, CMsvEntrySelection* aSelection, CMsvServer& aMsvServer, TInt aMark)
+: CMsvLocalOperation(aMessage, aId, aMsvServer), iSelection(aSelection), iMark(aMark)
+    {
+    __DECLARE_NAME(_S("CMsvLocalChangeEntriesOperation"));
+    // set up the progress
+    iProgress().iType = TMsvLocalOperationProgress::ELocalChanged;
+    iProgress().iTotalNumberOfEntries = iSelection->Count();;
+    iProgress().iNumberRemaining = iProgress().iTotalNumberOfEntries;
+    CActiveScheduler::Add(this);
+    }
+
+CMsvLocalChangeEntriesOperation::~CMsvLocalChangeEntriesOperation()
+//
+//
+//
+    {
+    Cancel();
+    delete iSelection;
+    delete iDelete;
+    delete iWorkSelection1;
+    delete iWorkSelection2;
+    }
+
+void CMsvLocalChangeEntriesOperation::DoCancel()
+//
+//
+//
+    {
+    __ASSERT_DEBUG(iDelete!=NULL, PanicServer(EMsvChangeEntryBadState));
+    iDelete->Cancel(); 
+    iProgress().iError = KErrCancel;
+    Completed();
+    }
+
+void CMsvLocalChangeEntriesOperation::RunL()
+//
+//
+//
+    {
+    if (iStatus.Int()==KErrNone)
+        {
+        iProgress().iNumberCompleted++;
+        }
+    else
+        {
+        iProgress().iNumberFailed++;
+        iProgress().iError = iStatus.Int();
+        }
+    
+    Completed();
+    }
+
+
+void CMsvLocalChangeEntriesOperation::StartL(TSecureId aOwnerId, TBool aForcedUpdate)
+//
+//
+//
+    {
+    TMsvEntry* entry1;
+ 
+    TInt count = iSelection->Count();
+    while (count--)
+        {
+        iMsvServer.IndexAdapter().GetEntry(iSelection->At(count),entry1);
+        iId = entry1->Id();
+        iParent = entry1->Parent();
+        // check if this is actually a deletion
+        if (entry1->Deleted() && entry1->PcSyncCount()==0)
+            {
+             iDelete = CMsvDelete::NewL(iMsvServer);
+             iWorkSelection1 = new(ELeave)CMsvEntrySelection;
+             iWorkSelection2 = new(ELeave)CMsvEntrySelection;
+
+            iDelete->StartL(entry1->Id(), *iWorkSelection1, *iWorkSelection2, iStatus, ETrue);
+            SetActive();
+            return;
+            }
+        }
+  
+    TInt error  = KErrNone;
+    TMsvEntry* entry;
+    count = iSelection->Count();
+    while (count--)
+        {
+        error = iMsvServer.IndexAdapter().GetEntry(iSelection->At(count),entry);
+        if (error==KErrNone)
+            {
+            error = iMsvServer.IndexAdapter().LockEntry(iSelection->At(count));
+            error = iMsvServer.ChangeEntry(*entry, aOwnerId, aForcedUpdate);
+            error = iMsvServer.IndexAdapter().ReleaseEntry(iSelection->At(count)); // error ignored
+            }
+         }
+
+    if (error==KErrNone)
+        iProgress().iNumberCompleted++;
+    else
+        {
+        iProgress().iNumberFailed++;
+        iProgress().iError = error;
+        }
+    Completed();
+    }
+
+void CMsvLocalChangeEntriesOperation::Completed()
+//
+//
+//
+    {
+    
+    if (iProgress().iError==KErrNone)
+        iMsvServer.NotifyChanged(iDelete==NULL ? EMsvEntriesChanged : EMsvEntriesDeleted, iId, iParent);
+    SetState(EMsvOperationCompleted);
+    iMessage.Complete(KErrNone);
+     }
 
 
 //**********************************
--- a/messagingfw/msgsrvnstore/server/src/MSVOPERT.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MSVOPERT.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -164,6 +164,9 @@
 		case EMtmOpCommand:
 			iServerMtm->StartCommandL(*iSelection, iIntParam, *iDesParam, iStatus);
 			break;
+        case EMtmOpChangeEntries:
+            iServerMtm->ChangeEntriesL(*iSelection,iIntParam,iStatus);
+            break;
 		default:
 			PanicServer(EMsvUnknownMtmOpType);
 			break;
--- a/messagingfw/msgsrvnstore/server/src/MSVSESS.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MSVSESS.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -578,6 +578,9 @@
 			CancelConversionRequestL(aMessage);
 			break;
 #endif	  // #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
+		case EMsvChangeEntries:
+		     ChangeEntriesL(aMessage);
+		     break;
 		default:
 			PanicClient(aMessage, EMsvBadRequest);
 			break;
@@ -696,7 +699,6 @@
 		}
 	}
 
-
 void CMsvServerSession::WriteBufferL(const RMessage2& aMessage, TInt aParam)
 //
 // Copies the packed entry buffer from the client
@@ -945,6 +947,113 @@
 	CleanupStack::PopAndDestroy(); // opData
 	}
 
+//
+// Changes the selection of id.
+//
+
+void CMsvServerSession::ChangeEntriesL(const RMessage2 &aMessage)
+    {
+     // Recover the operation data
+     TMsvOp operationId = aMessage.Int0();
+     HBufC8* opData = RecoverOperationData(operationId);
+     // Check for NULL data entry to be changed, must have been given incorrect id for argument.
+     if(opData == NULL)
+         {
+         aMessage.Complete(KErrArgument);
+         return;
+         }
+     CleanupStack::PushL(opData);
+
+     // unpack the data
+     TMsvPackedOperation packedOperation(opData);
+     
+     CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+     CleanupStack::PushL(selection);
+     TInt target,temp;
+     packedOperation.UnpackL(*selection, target, temp);
+
+     if (selection->Count() == 0)
+         {
+         PanicClient(aMessage, EMsvNoEntriesInChangeSelection);
+         aMessage.Complete(KErrNotFound);
+         return;
+         }
+     // Find the first entry in the selection which exists
+     TInt count=selection->Count();
+     while (count--)
+         {
+         TBool entryExsists = EFalse;
+         entryExsists = iMsvServer.IndexAdapter().EntryExists(selection->At(count));
+         if (entryExsists)
+             break;
+         }
+ 
+       // Check if the entry is local or the entry is a service
+      TBool local=ETrue;
+      TMsvEntry* entry=NULL;
+      User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(selection->At(0), entry));
+     
+      // Police request - client must be able to modify the entry.
+      iMsvServer.PoliceModifyEntryL(aMessage, *entry, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ChangeEntryL"));
+             
+      // For purpose of changing a service entry, it is considered local as an MTM
+      // is not required to do the work.
+      if( entry->iType == KUidMsvServiceEntry )
+          local = ETrue;
+
+      // start the change for local or remote entries
+      if (local)
+          {
+          // Extract the owner ID from the message.
+          TSecureId ownerId = aMessage.Int1();
+
+          DoChangeLocalEntriesL(selection, operationId, aMessage, ownerId, target);
+          }
+      else
+          DoChangeRemoteEntriesL(selection, operationId, aMessage,target);
+
+      CleanupStack::PopAndDestroy(); // opData
+   }
+
+void CMsvServerSession::DoChangeLocalEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId, TInt mark)
+    {
+    CMsvLocalChangeEntriesOperation* operation = new(ELeave) CMsvLocalChangeEntriesOperation(aMessage, aOpId, aSelection, iMsvServer,mark);
+    CleanupStack::Pop(); // selection
+    CleanupStack::PushL(operation);
+   
+    TBool forcedUpdate = (aOwnerId != aMessage.SecureId());
+    operation->StartL(aOwnerId, forcedUpdate);
+
+    iOperations.AppendL(operation);
+    CleanupStack::Pop(); // operation
+
+    
+    }
+
+void CMsvServerSession::DoChangeRemoteEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage,TInt mark)
+//
+// Change a selection of entry under a remote service
+//
+    {
+    // make sure that the operation can be added to the list
+     iOperations.SetReserveL(iOperations.Count()+1);
+
+     TMsvEntry* entry=NULL;
+     User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aSelection->At(0), entry));
+ 
+     // create the operation
+     CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, entry->iMtm, entry->iServiceId, iSessionId, iMsvServer);
+     CleanupStack::Pop(); // aSelection
+     CleanupStack::PushL(operation);
+     operation->ChangeEntriesL(aSelection,mark);
+     
+     iMsvServer.StartOperationL(*operation, iSessionId, aMessage, ETrue);
+     iOperations.AppendL(operation); // will not fail - see start of function
+     CleanupStack::Pop(); // operation
+   
+    }
+
+
 void CMsvServerSession::DoChangeLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId)
 //
 // Create a local entry in the index
@@ -980,22 +1089,28 @@
 	}
 
 
-void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry)
-//
+void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry, const TMsvId& aServiceId)
 //
 //
 	{
-	// package the entry
+	// package the entry and service id in same buffer
 	TMsvPackedEntry packedEntry(iBuffer);
-	TInt error = packedEntry.PackEntry(aEntry);
+	TInt error = packedEntry.PackEntryAndService(aEntry, aServiceId);
 	while(error!=KErrNone)
 		{
 		// increase the size of the buffer and try again
 		iBuffer->Des().SetLength(0); // to avoid copying contents
 		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
-		error = packedEntry.PackEntry(aEntry);
+		error = packedEntry.PackEntryAndService(aEntry, aServiceId);
 		}
-	WriteBufferL(aMessage, aParam);
+	// max destination length is passed from client
+	TInt maxDesLen = aMessage.Int2();
+    if (maxDesLen < iBuffer->Des().Length())
+		{
+        User::Leave(KErrOverflow);
+		}
+
+    aMessage.WriteL(aParam, iBuffer->Des());
 	}
 
 void CMsvServerSession::GetEntryL(const RMessage2 &aMessage)
@@ -1015,18 +1130,17 @@
 		iMsvServer.PoliceReadEntryL(aMessage, ownerId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetEntryL"));
 
 		// get the owning service and write that back
-		TPckgBuf<TMsvId> service;
-		if (id==KMsvRootIndexEntryId)
-			service()=KMsvRootIndexEntryId;
+		TMsvId service;
+		if (id == KMsvRootIndexEntryId)
+			service = KMsvRootIndexEntryId;
 		else
 			{
-			iMsvServer.IndexAdapter().OwningService(id, service()); // error ignore as the entry exists
+			iMsvServer.IndexAdapter().OwningService(id, service); // error ignore as the entry exists
 			}
-
-		WriteL(aMessage, 2, service);
 		// write the entry back
-		PackEntryAndWriteBufferL(aMessage, 1, *entryPtr);
+		PackEntryAndWriteBufferL(aMessage, 1, *entryPtr, service);
 		}
+
 	aMessage.Complete(error);
 	}
 
--- a/messagingfw/msgsrvnstore/server/src/MTCLBASE.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MTCLBASE.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -687,10 +687,12 @@
 */	
 EXPORT_C void CBaseMtm::CancelAttachmentOperation()
 	{
-	__ASSERT_ALWAYS(iAttachmentWaiter != NULL, PanicServer(EMsvOperationNotFound));
-	iAttachmentWaiter->Cancel();
-	delete iAttachmentWaiter;
-	iAttachmentWaiter = NULL;
+	if(iAttachmentWaiter)
+		{
+		iAttachmentWaiter->Cancel();
+		delete iAttachmentWaiter;
+		iAttachmentWaiter = NULL;
+		}
 	}
 
 
--- a/messagingfw/msgsrvnstore/server/src/MTSR.CPP	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/MTSR.CPP	Wed Jul 21 02:03:54 2010 +0530
@@ -175,6 +175,15 @@
 		}
 	return ret;
 	}
+// Empty declaration
+EXPORT_C TInt CBaseServerMtm::ChangeEntriesL( const CMsvEntrySelection& /*aSelection*/,TInt /*aMark*/, TRequestStatus& aStatus )
+    {
+    //Empty declaration. Respective MTM implementation should be call .
+    TRequestStatus aEmptyStatus;
+    aEmptyStatus = aStatus ;
+    
+    return KErrNotSupported; // Specific to MTM. Base return Not supported.  
+    }
 
 EXPORT_C CServerMtmDllRegistry* CServerMtmDllRegistry::NewL(RFs& aFs,TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32)
 	{
--- a/messagingfw/msgsrvnstore/server/src/TMsvServerStoreManager.cpp	Tue Jul 06 22:57:17 2010 +0530
+++ b/messagingfw/msgsrvnstore/server/src/TMsvServerStoreManager.cpp	Wed Jul 21 02:03:54 2010 +0530
@@ -381,11 +381,17 @@
 	GetStoreFileName(aEntryId,tempFilePathAndName);
 
 	tempFilePathAndName.Append(KMsvUtilsNewExtension);
-	TInt error = iFs->MkDirAll(tempFilePathAndName);
-	if(error == KErrNone || error == KErrAlreadyExists)
-		error = aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
-
+	
+	TInt error= aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
+	if (error==KErrPathNotFound)
+		{
+        //only create directory if not found
+        error=iFs->MkDirAll(tempFilePathAndName);
+        if (error==KErrNone)
+            error=aFile.Replace(*iFs,tempFilePathAndName,EFileShareExclusive|EFileWrite);
+		}
 	User::LeaveIfError(error);
+	
 	}
 
 void TMsvServerStoreManager::ReplaceFileStoreL(TMsvId aEntryId)