943 DoChangeRemoteEntryL(entry, operationId, aMessage); |
945 DoChangeRemoteEntryL(entry, operationId, aMessage); |
944 |
946 |
945 CleanupStack::PopAndDestroy(); // opData |
947 CleanupStack::PopAndDestroy(); // opData |
946 } |
948 } |
947 |
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 } |
|
1055 |
|
1056 |
948 void CMsvServerSession::DoChangeLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId) |
1057 void CMsvServerSession::DoChangeLocalEntryL(const TMsvEntry& aEntry, TMsvOp aOpId, const RMessage2 &aMessage, TSecureId aOwnerId) |
949 // |
1058 // |
950 // Create a local entry in the index |
1059 // Create a local entry in the index |
951 // |
1060 // |
952 { |
1061 { |
978 iOperations.AppendL(operation); // will not fail - see start of function |
1087 iOperations.AppendL(operation); // will not fail - see start of function |
979 CleanupStack::Pop(); // operation |
1088 CleanupStack::Pop(); // operation |
980 } |
1089 } |
981 |
1090 |
982 |
1091 |
983 void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry) |
1092 void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry, const TMsvId& aServiceId) |
984 // |
1093 // |
985 // |
1094 // |
986 // |
1095 { |
987 { |
1096 // package the entry and service id in same buffer |
988 // package the entry |
|
989 TMsvPackedEntry packedEntry(iBuffer); |
1097 TMsvPackedEntry packedEntry(iBuffer); |
990 TInt error = packedEntry.PackEntry(aEntry); |
1098 TInt error = packedEntry.PackEntryAndService(aEntry, aServiceId); |
991 while(error!=KErrNone) |
1099 while(error!=KErrNone) |
992 { |
1100 { |
993 // increase the size of the buffer and try again |
1101 // increase the size of the buffer and try again |
994 iBuffer->Des().SetLength(0); // to avoid copying contents |
1102 iBuffer->Des().SetLength(0); // to avoid copying contents |
995 iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength); |
1103 iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength); |
996 error = packedEntry.PackEntry(aEntry); |
1104 error = packedEntry.PackEntryAndService(aEntry, aServiceId); |
997 } |
1105 } |
998 WriteBufferL(aMessage, aParam); |
1106 // max destination length is passed from client |
|
1107 TInt maxDesLen = aMessage.Int2(); |
|
1108 if (maxDesLen < iBuffer->Des().Length()) |
|
1109 { |
|
1110 User::Leave(KErrOverflow); |
|
1111 } |
|
1112 |
|
1113 aMessage.WriteL(aParam, iBuffer->Des()); |
999 } |
1114 } |
1000 |
1115 |
1001 void CMsvServerSession::GetEntryL(const RMessage2 &aMessage) |
1116 void CMsvServerSession::GetEntryL(const RMessage2 &aMessage) |
1002 // |
1117 // |
1003 // Returns the index entry for the given id |
1118 // Returns the index entry for the given id |
1013 { |
1128 { |
1014 // Police request - client must be able to read the entry. |
1129 // Police request - client must be able to read the entry. |
1015 iMsvServer.PoliceReadEntryL(aMessage, ownerId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetEntryL")); |
1130 iMsvServer.PoliceReadEntryL(aMessage, ownerId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetEntryL")); |
1016 |
1131 |
1017 // get the owning service and write that back |
1132 // get the owning service and write that back |
1018 TPckgBuf<TMsvId> service; |
1133 TMsvId service; |
1019 if (id==KMsvRootIndexEntryId) |
1134 if (id == KMsvRootIndexEntryId) |
1020 service()=KMsvRootIndexEntryId; |
1135 service = KMsvRootIndexEntryId; |
1021 else |
1136 else |
1022 { |
1137 { |
1023 iMsvServer.IndexAdapter().OwningService(id, service()); // error ignore as the entry exists |
1138 iMsvServer.IndexAdapter().OwningService(id, service); // error ignore as the entry exists |
1024 } |
1139 } |
1025 |
|
1026 WriteL(aMessage, 2, service); |
|
1027 // write the entry back |
1140 // write the entry back |
1028 PackEntryAndWriteBufferL(aMessage, 1, *entryPtr); |
1141 PackEntryAndWriteBufferL(aMessage, 1, *entryPtr, service); |
1029 } |
1142 } |
|
1143 |
1030 aMessage.Complete(error); |
1144 aMessage.Complete(error); |
1031 } |
1145 } |
1032 |
1146 |
1033 void CMsvServerSession::OutstandingOperationsL(const RMessage2& aMessage) |
1147 void CMsvServerSession::OutstandingOperationsL(const RMessage2& aMessage) |
1034 { |
1148 { |