messagingfw/msgsrvnstore/server/src/MSVSESS.CPP
branchRCL_3
changeset 21 e5b3a2155e1a
parent 18 b9e74fff3740
child 22 d2c4c66342f3
equal deleted inserted replaced
20:e4175d61d967 21:e5b3a2155e1a
   576 			break;
   576 			break;
   577 		case EMsvCancelConversionRequest:
   577 		case EMsvCancelConversionRequest:
   578 			CancelConversionRequestL(aMessage);
   578 			CancelConversionRequestL(aMessage);
   579 			break;
   579 			break;
   580 #endif	  // #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
   580 #endif	  // #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   581 		case EMsvChangeEntries:
       
   582 		     ChangeEntriesL(aMessage);
       
   583 		     break;
   581 		default:
   584 		default:
   582 			PanicClient(aMessage, EMsvBadRequest);
   585 			PanicClient(aMessage, EMsvBadRequest);
   583 			break;
   586 			break;
   584 		}
   587 		}
   585 	}
   588 	}
   941 	else
   944 	else
   942 		DoChangeRemoteEntryL(entry, operationId, aMessage);
   945 		DoChangeRemoteEntryL(entry, operationId, aMessage);
   943 
   946 
   944 	CleanupStack::PopAndDestroy(); // opData
   947 	CleanupStack::PopAndDestroy(); // opData
   945 	}
   948 	}
       
   949 
       
   950 //
       
   951 // Changes the selection of id.
       
   952 //
       
   953 
       
   954 void CMsvServerSession::ChangeEntriesL(const RMessage2 &aMessage)
       
   955     {
       
   956      // Recover the operation data
       
   957      TMsvOp operationId = aMessage.Int0();
       
   958      HBufC8* opData = RecoverOperationData(operationId);
       
   959      // Check for NULL data entry to be changed, must have been given incorrect id for argument.
       
   960      if(opData == NULL)
       
   961          {
       
   962          aMessage.Complete(KErrArgument);
       
   963          return;
       
   964          }
       
   965      CleanupStack::PushL(opData);
       
   966 
       
   967      // unpack the data
       
   968      TMsvPackedOperation packedOperation(opData);
       
   969      
       
   970      CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
       
   971      CleanupStack::PushL(selection);
       
   972      TInt target,temp;
       
   973      packedOperation.UnpackL(*selection, target, temp);
       
   974 
       
   975      if (selection->Count() == 0)
       
   976          {
       
   977          PanicClient(aMessage, EMsvNoEntriesInChangeSelection);
       
   978          aMessage.Complete(KErrNotFound);
       
   979          return;
       
   980          }
       
   981      // Find the first entry in the selection which exists
       
   982      TInt count=selection->Count();
       
   983      while (count--)
       
   984          {
       
   985          TBool entryExsists = EFalse;
       
   986          entryExsists = iMsvServer.IndexAdapter().EntryExists(selection->At(count));
       
   987          if (entryExsists)
       
   988              break;
       
   989          }
       
   990  
       
   991        // Check if the entry is local or the entry is a service
       
   992       TBool local=ETrue;
       
   993       TMsvEntry* entry=NULL;
       
   994       User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(selection->At(0), entry));
       
   995      
       
   996       // Police request - client must be able to modify the entry.
       
   997       iMsvServer.PoliceModifyEntryL(aMessage, *entry, local, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::ChangeEntryL"));
       
   998              
       
   999       // For purpose of changing a service entry, it is considered local as an MTM
       
  1000       // is not required to do the work.
       
  1001       if( entry->iType == KUidMsvServiceEntry )
       
  1002           local = ETrue;
       
  1003 
       
  1004       // start the change for local or remote entries
       
  1005       if (local)
       
  1006           {
       
  1007           // Extract the owner ID from the message.
       
  1008           TSecureId ownerId = aMessage.Int1();
       
  1009 
       
  1010           DoChangeLocalEntriesL(selection, operationId, aMessage, ownerId, target);
       
  1011           }
       
  1012       else
       
  1013           DoChangeRemoteEntriesL(selection, operationId, aMessage,target);
       
  1014 
       
  1015       CleanupStack::PopAndDestroy(); // opData
       
  1016     }
       
  1017 
       
  1018 void CMsvServerSession::DoChangeLocalEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId, TInt mark)
       
  1019     {
       
  1020     CMsvLocalChangeEntriesOperation* operation = new(ELeave) CMsvLocalChangeEntriesOperation(aMessage, aOpId, aSelection, iMsvServer,mark);
       
  1021     CleanupStack::Pop(); // selection
       
  1022     CleanupStack::PushL(operation);
       
  1023    
       
  1024     TBool forcedUpdate = (aOwnerId != aMessage.SecureId());
       
  1025     operation->StartL(aOwnerId, forcedUpdate);
       
  1026 
       
  1027     iOperations.AppendL(operation);
       
  1028     CleanupStack::Pop(); // operation
       
  1029 
       
  1030     
       
  1031     }
       
  1032 
       
  1033 void CMsvServerSession::DoChangeRemoteEntriesL(CMsvEntrySelection*& aSelection, TMsvOp aOpId, const RMessage2 &aMessage,TInt mark)
       
  1034 //
       
  1035 // Change a selection of entry under a remote service
       
  1036 //
       
  1037     {
       
  1038      // make sure that the operation can be added to the list
       
  1039      iOperations.SetReserveL(iOperations.Count()+1);
       
  1040 
       
  1041      TMsvEntry* entry=NULL;
       
  1042      User::LeaveIfError(iMsvServer.IndexAdapter().GetEntry(aSelection->At(0), entry));
       
  1043  
       
  1044      // create the operation
       
  1045      CMsvMtmOperation* operation = CMsvMtmOperation::NewL(aMessage, aOpId, entry->iMtm, entry->iServiceId, iSessionId, iMsvServer);
       
  1046      CleanupStack::Pop(); // aSelection
       
  1047      CleanupStack::PushL(operation);
       
  1048      operation->ChangeEntriesL(aSelection,mark);
       
  1049      
       
  1050      iMsvServer.StartOperationL(*operation, iSessionId, aMessage, ETrue);
       
  1051      iOperations.AppendL(operation); // will not fail - see start of function
       
  1052      CleanupStack::Pop(); // operation
       
  1053 	}
       
  1054 
   946 
  1055 
   947 void CMsvServerSession::DoChangeLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId)
  1056 void CMsvServerSession::DoChangeLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId)
   948 //
  1057 //
   949 // Create a local entry in the index
  1058 // Create a local entry in the index
   950 //
  1059 //