messagingfw/msgsrvnstore/server/src/MSVIPC.CPP
branchRCL_3
changeset 18 b9e74fff3740
parent 0 8e480a14352b
equal deleted inserted replaced
16:b9bc42ac264b 18:b9e74fff3740
   152 #endif
   152 #endif
   153 	
   153 	
   154 	TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
   154 	TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
   155 	DoUnpackEntry(pS, aEntry);
   155 	DoUnpackEntry(pS, aEntry);
   156 	}
   156 	}
       
   157 
       
   158 TInt TMsvPackedEntry::PackEntryAndService(const TMsvEntry& aEntry, const TMsvId& aServiceId)
       
   159     {
       
   160     // find the start and end of the buffer
       
   161     const TUint8* pS = iBuffer->Ptr();
       
   162     const TUint8* pE = PtrAdd(pS, iBuffer->Des().MaxSize());
       
   163 
       
   164     TInt error = DoPackEntry(pS, pE, aEntry);
       
   165     if (error==KErrNone)
       
   166         {
       
   167         TInt sizeDes = Align4(sizeof(TMsvId));
       
   168         if ((pS + sizeDes)>pE)
       
   169             {
       
   170             return KErrOverflow;
       
   171             }            
       
   172         // copy the entry and descriptors into the memory area
       
   173         Mem::Copy((void*)pS, &aServiceId, sizeof(TMsvId));
       
   174         pS += sizeDes;
       
   175 
       
   176         // update the length of the buffer
       
   177         iBuffer->Des().SetLength(pS-iBuffer->Ptr());
       
   178         }
       
   179 
       
   180     return error;    
       
   181     }
       
   182 
       
   183 void TMsvPackedEntry::UnpackEntryAndService(TMsvEntry& aEntry, TMsvId& aServiceId)
       
   184     {
       
   185 #if defined(_DEBUG)
       
   186     // check that the buffer contain a valid package
       
   187     const TMsvEntry* dEntry = (TMsvEntry*) iBuffer->Ptr();
       
   188     const TUint8* dPos = PtrAdd(iBuffer->Ptr(), Align4(sizeof(TMsvEntry)) + Align4(dEntry->iDescription.Size()) + Align4(dEntry->iDetails.Size()) + Align4(sizeof(TMsvId)) );
       
   189     __ASSERT_DEBUG(dPos <= PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxLength()), PanicServer(EMsvEntryOverrunBuffer));
       
   190 #endif
       
   191     
       
   192     TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
       
   193     DoUnpackEntry(pS, aEntry);
       
   194 
       
   195     // get the service id from the current position in the buffer
       
   196     const TMsvId* pServiceId = (TMsvId*)pS;
       
   197     aServiceId = *pServiceId;
       
   198     pS = Align4(pS + sizeof(TMsvId));
       
   199     }
   157 
   200 
   158 //**********************************
   201 //**********************************
   159 // TMsvPackedEntryArray
   202 // TMsvPackedEntryArray
   160 //**********************************
   203 //**********************************
   161 
   204