/**
 Retrieve the EIR data for the next Data Type 
 @param aOffset Offset to current data type (0 to start traversing)
 @param aDes Pointer descriptor that will point to the EIR data for the Data Type requested if successful 
 (please note this does not contain the Data Type byte) 
 @return TExtendedInquiryResponseDataType (TExtendedInquiryResponseDataType::EEirInvalid means there is no more eir data to get)
 @internalTechnology
 */
EXPORT_C TExtendedInquiryResponseDataType TExtendedInquiryResponseDataCodec::GetNextData(TPtrC8& aDes)
	{
	LOG_FUNC
	TExtendedInquiryResponseDataType dataType;
	iOffset = NextDataType(iOffset);

	if(iOffset >= KErrNone && iEir.Length() >= (iOffset +iEir[iOffset - KEIRLengthToTagOffset]))
		{
		aDes.Set(iEir.Mid(iOffset + KEIRTagToDataOffset, iEir[iOffset-KEIRLengthToTagOffset] - KEIRLengthToTagOffset));
		dataType = static_cast<TExtendedInquiryResponseDataType>(iEir[iOffset]);
		}
	else
		{
		// Data must be malformed or corrupted
		dataType = EEirInvalid;
		}

	return dataType;
	}
CTzDbZone* CTzDbLinksTable::FindZoneL(const TDesC8& aLinkName)
	{
	const TInt KLinkCount = iPersistedEntity.iNumberOfLinks;
	TPtrC8 name;
	TTzLink* link(NULL);
	TInt linkAddress = reinterpret_cast<TInt>(&iPersistedEntity) + sizeof(iPersistedEntity.iNumberOfLinks);
	for (TInt i = 0; i < KLinkCount; i++, linkAddress += sizeof(TTzLink))
		{
		link = reinterpret_cast<TTzLink*>(linkAddress);
		name.Set(iReadOnlyTzDb.GetStringL(link->iOffsetToLinkName));
		if (!name.CompareC(aLinkName))
			{ // we found our link
			return iReadOnlyTzDb.GetZoneL(link->iOffsetToZone);
			}
		}

	// if it gets here, it means that the zone has not been found
	return NULL;
	}
Example #3
0
void CDebugRouterClient::RunL()
	{
	TUint chunkSize = iSharedChunk.Size();
	const TUint KDataStartOffset = sizeof(SDebugChunkHeader);
	SDebugChunkHeader* chunkHeader = (SDebugChunkHeader*)iSharedChunk.Base();
	TUint start = chunkHeader->iStartOffset;
	TUint end = chunkHeader->iEndOffset;
	TUint overflows = chunkHeader->iOverflows;

	TBool wrap = (start > end);
	TUint endLen = wrap ? chunkSize - start : end - start;
	TUint startLen = wrap ? end - KDataStartOffset : 0;

	TPtrC8 endData(iSharedChunk.Base() + start, endLen);
	TPtrC8 startData;
	if (wrap) startData.Set(iSharedChunk.Base() + KDataStartOffset, startLen);
	TPtrC8 data(endData);

	while (data.Length())
		{
		TPtrC8 header = Read(iTempBuf, data, sizeof(SCloggerTraceInfo), startData);
		if (header.Length() < (TInt)sizeof(SCloggerTraceInfo))
			{
			ASSERT(EFalse); // for udeb
			break; // Something's broken
			}
		SCloggerTraceInfo info;
		Mem::Copy(&info, header.Ptr(), sizeof(SCloggerTraceInfo));
		ASSERT(info.iTraceType == 'K' || info.iTraceType == 'U' || info.iTraceType == 'P');
		TPtrC8 msg = Read(iTempBuf, data, info.iLength, startData);
		iServer.LogKernMessage(info.iTraceType, info.iTickCount, info.iThreadId, msg);
		}
	if (overflows)
		{
		_LIT8(KErr, "RDebug::Print buffer overflowed, %u calls not logged");
		iServer.LogError(KErr, overflows);
		}
	// Zero the memory so it's easier to read in the crashlog
	memclr(iSharedChunk.Base() + start, endLen);
	if (startLen) memclr(iSharedChunk.Base() + KDataStartOffset, startLen);
	
	StartRouting(-1); // Magic number to indicate no need to call EnableDebugRouting again
	}
TInt CExampleCookieManager::CountSeparators(const TDesC8& aDes)
	{
	const TChar pathSeparator('/');
	TInt numSeps = 0;

	// Get all the descriptor to start with
	TPtrC8 desPtr = aDes.Mid(0);
	TInt sepPos = desPtr.Locate(pathSeparator);
	while(sepPos != KErrNotFound)
		{
		++numSeps;

		// Get the rest of the descriptor without the separator that we have found
		desPtr.Set(desPtr.Mid(sepPos + 1));
		sepPos = desPtr.Locate(pathSeparator);
		}

	return numSeps;
	}
// -----------------------------------------------------------------------------
// CUpnpDeviceLibraryElement::AddInfoFromNotificationTypeHeaderL
//
// Supported NT (Notification Type) messages:
// "uuid:"                         (length: 5 )
// "upnp:rootdevice"               (length: 15)
// "urn:schemas-upnp-org:device:"  (length: 28)
// "urn:schemas-upnp-org:service:" (length: 29)
// -----------------------------------------------------------------------------
//
TBool CUpnpDeviceLibraryElement::AddInfoFromNotificationTypeHeaderL(
    CUpnpSsdpMessage* aMessage )
    {
    TPtrC8 nt = aMessage->St( );

    if ( nt.Length( ) == 0 )
        {
        nt.Set( aMessage->Nt( ) );
        }

    if ( HasPrefix( nt, KUPnPUuid ) )
        {
        // an uuid advertisement
        return ETrue;
        }

    if ( iDeviceType->Length( ) == 0 )
        {
        if ( nt == KUPnPRootDevice )
            {
            // a root device advertisement
            SetDeviceTypeL( nt );
            return ETrue;
            }

        if ( HasPrefix( nt, KUPnPDeviceSchema ) )
            {
            // a device advertisement
            SetDeviceTypeL( nt );
            return ETrue;
            }
        }

    if ( HasPrefix( nt, KUPnPServiceSchema ) )
        {
        // a service advertisement
        AddServiceTypeL( nt );
        return ETrue;
        }

    return EFalse;
    }
Example #6
0
TInt TMetaVarLenBase::CheckBuf( TPtrC8& aBuffer )
	{
	// Check if the descriptor is long enough
	if (aBuffer.Length() < (TInt)sizeof(TUint32))
		{
		return KErrArgument;
		}
	
	// Check if the descriptor is long enough
    TBuf8<sizeof(TUint32)> lenSubBuf;
    lenSubBuf.Copy(aBuffer.Ptr(), sizeof(TUint32));
    TUint length = *((TUint32*)lenSubBuf.Ptr());	
	if (aBuffer.Length() < (TInt)length)
		{
		return KErrArgument;
		}

	aBuffer.Set(aBuffer.Ptr() + sizeof(TUint32), aBuffer.Length() - sizeof(TUint32)); //update pointer
	return length;
	}
Example #7
0
/**
   @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery7L
  
   @SYMPREQ 538
  
   @SYMTestCaseDesc Given the size of data that is returned from the server is greater than the default 
   1024 bytes of the buffer, test if a larger buffer is assigned in such cases
   
   @SYMTestPriority 
  
   @SYMTestStatus Implemented
   
   @SYMTestActions Call GetAppServicesLC with the app uid as parameter. The size of the resource data in 
   the registration file should be greater than the default size.
   on z: drive.\n
   API Calls:\n	
   RApaLsSession::GetAppServicesLC(TUid aAppUid) const
   
   @SYMTestExpectedResults A larger buffer is allocated. The size of the buffer can be tested by checking 
   the size of the returned data.
    
 */
void CT_ServicesTestStep::TestServiceDiscovery7L()
	{
	INFO_PRINTF1(_L("TestServiceDiscovery7 about to start..."));
	const TUid KUidServerApp = {0x10004c57};
	// get all services for a particular app
	CApaAppServiceInfoArray* array = iApaLsSession.GetAppServicesLC(KUidServerApp);
	TArray<TApaAppServiceInfo> serviceArray(array->Array());
	TInt count = serviceArray.Count();
	TEST(count == 16);
	TPtrC8 opaqueData;
	TInt size(0);
	for(TInt i=0;i<count;i++)
		{
			opaqueData.Set(serviceArray[i].OpaqueData());
			size +=opaqueData.Length(); 
		}
	TEST(size>=1024);
	CleanupStack::PopAndDestroy(array); // the servicearray	
	array = NULL;
	}
/**
 Retrieve the EIR data for a particular Data Type 
 @param aDataType Data Type to look for
 @param aDes Pointer descriptor that will point to the EIR data for the Data Type requested if successful 
 (please note this does not contain the Data Type byte) 
 @return an error code
 @internalTechnology
 */
EXPORT_C TInt TExtendedInquiryResponseDataCodec::GetData(TExtendedInquiryResponseDataType aDataType, TPtrC8& aDes) const
	{
	LOG_FUNC
	TInt offset = NextDataType(0);

	while(offset >= KErrNone)
		{
		if(iEir[offset] == aDataType)
			{
			aDes.Set(iEir.Mid(offset + KEIRTagToDataOffset, iEir[offset - KEIRLengthToTagOffset] - KEIRLengthToTagOffset));
			return KErrNone;
			}
		else
			{
			offset = NextDataType(offset);
			}
		}

	return offset;
	}
Example #9
0
HBufC8* CmsUtils::CreateSignatureL(const TDesC8& aDataToBeSigned, TBool aIsHash, TAlgorithmId aAlgorithm, const CDSAPrivateKey& aKey)
	{
	HBufC8* signature(NULL);
	
	if (!aIsHash)
		{
		TPtrC8 hashValue;
		// Create hash first
		CMessageDigest* hash=CreateHashLC(aAlgorithm);
		hashValue.Set(hash->Hash(aDataToBeSigned));
		signature=CreateSignatureL(hashValue, aKey);
		CleanupStack::PopAndDestroy(); // hash
		}
	else
		{
		signature=CreateSignatureL(aDataToBeSigned, aKey);
		}
		
	return signature;
	}
Example #10
0
//
// Looks for a region given its name.
// Returns the region wrapped in a CTzDbRegion object.
// Returns NULL if region is not found
//
CTzDbRegion* CTzDbRegionsTable::FindRegionL(const TDesC8& aRegionName)
	{
	const TInt KRegionCount = iPersistedEntity.iNumberOfRegions;
	TTzRegion* region(NULL);
	TPtrC8 name;
	TInt regionAddress = reinterpret_cast<TInt>(&iPersistedEntity) + sizeof(iPersistedEntity.iNumberOfRegions);
	for (TInt i = 0; i < KRegionCount; i++, regionAddress += sizeof(TTzRegion))
		{
		region = reinterpret_cast<TTzRegion*>(regionAddress);
		name.Set(iReadOnlyTzDb.GetStringL(region->iOffsetToRegionName));

		// compare both strings
		if (aRegionName.Compare(name) == 0) // found our region
			{
			return CTzDbRegion::NewL(iReadOnlyTzDb,*region);
			}
		}

	// if it gets here, it means that the region has not been found
	return NULL;
	}
Example #11
0
/**
   @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery17L
  
   @SYMPREQ 538
  
   @SYMTestCaseDesc Test the functionality of GetAppServicesLC on a app that has a localised 
   resource defined in the registration file
  
   @SYMTestStatus Implemented

   @SYMTestPriority  High
   
   @SYMTestActions  Call GetAppServicesLC with the app uid as parameter
   on z: drive.\n
   API Calls:\n	
   RApaLsSession::GetAppServicesLC(TUid aAppUid) const
   
   @SYMTestExpectedResults Returns an array of TApaAppServiceInfo objects. 
   Each TApaAppServiceInfo contains details about a service uid and corresponding opaque data. 
   The returned data should be the same as that defined in the registration files.
    
 */
void CT_ServicesTestStep::TestServiceDiscovery17L() 
	{
	INFO_PRINTF1(_L("TestServiceDiscovery17 about to start..."));
	const TUid KUidService1235 = {0x01020305};
	const TUid KUidServerApp = {0x10004c55};
	CApaAppServiceInfoArray* array = iApaLsSession.GetAppServicesLC(KUidServerApp);
	TArray<TApaAppServiceInfo> serviceArray(array->Array());
	TInt count = serviceArray.Count();
	TEST(count == 1);
	TPtrC8 opaqueData;
	TResourceReader reader;
	TPtrC16 theText;
	TInt val(0);
	_LIT(KSecondService,"Localised text for service UID 0x01020305");
	TEST(serviceArray[0].Uid()==KUidService1235);
	opaqueData.Set(serviceArray[0].OpaqueData());
	reader.SetBuffer(&opaqueData);
	theText.Set(reader.ReadTPtrC16());
	User::LeaveIfError(val=theText.Compare(KSecondService));
	TEST(val==KErrNone);
	CleanupStack::PopAndDestroy(array); // the servicearray
	}
TInt CKeytoolFileView::ReadLine(const TDesC8& aBuffer, TInt& aPos, TPtrC8& aLine)
	{
	TBool endOfBuffer = EFalse;
	const TChar KCarriageReturn = '\r';
	const TChar KLineReturn = '\n';

	TInt bufferLength = aBuffer.Length();
	if ( aPos > bufferLength || aPos < 0 )
		{	
		return ETrue; // End of buffer
		}
		
	// find the position of the next delimter		
	TInt endPos = aPos;	
	while (endPos < bufferLength)
		{
		TChar c = aBuffer[endPos];

		if (c == KCarriageReturn || c == KLineReturn) 
			{
			break;
			}	
		endPos++;
		}

	if (endPos != aPos)	
		{
		TInt tokenLen = endPos - aPos;
		aLine.Set(&aBuffer[aPos], tokenLen);
		endPos += 2;
		}
	else
		{
		return ETrue; // End of buffer
		}

	aPos = endPos;
	return endOfBuffer;
	}
// -----------------------------------------------------------------------------
// CSTSAccessControl::FindAuthTypeL
// Saves found authType to member variable, which will be returned
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CSTSAccessControl::FindAuthTypeL(TInt aPinID)
{

    CSTSAuthType* authType = NULL;
    TPtrC8 authIdPtr;

    //go through all authTypes in loop and find correct authId
    TInt authTypesCount = iAuthTypes->Count();
    TBool authTypeNotFound = ETrue;
    for (TInt x = 0; x < authTypesCount && authTypeNotFound; x++)
    {

        //points to array's object
        authType = iAuthTypes->At(x);

        //get CommonAuthenticationObjectAttributes.authID
        authIdPtr.Set(authType->AuthID());
        if (authIdPtr.Length() != 0)
        {

            if (authIdPtr[0] == aPinID) //first value can be compared to PinID
            {
                authTypeNotFound = EFalse;

                CSTSAuthType* tmp = CSTSAuthType::NewLC();
                tmp->CopyL(*authType);

                CleanupStack::Pop(tmp);
                delete iAuthType;
                iAuthType = tmp;
            }
        }
    }
    if (authTypeNotFound)
    {
        User::Leave(KSTSErrSecurity);
    }
}
/**
 *	Set SL entry fields prior to storing message.
 *	@param aSlPushMsgEntry
 *		entry represents message format to use when storing it
 */
void CSLContentHandler::SetSlPushMsgEntryFieldsL(CSLPushMsgEntry& aSlPushMsgEntry)
	{
	
	//set URL and Action fields
	aSlPushMsgEntry.SetUrlL(*iHrefBuf);
	aSlPushMsgEntry.SetAction(iPushMsgAction);
	
	// Set all the relevant header fields
	TPtrC8 msgHeaderPtr;
	iMessage->GetHeader(msgHeaderPtr);
	aSlPushMsgEntry.SetHeaderL(msgHeaderPtr); 

	TPtrC8 from;
	if (!iMessage->GetBinaryHeaderField(EHttpFrom,from) &&
		!iMessage->GetBinaryHeaderField(EHttpXWapInitiatorURI,from) &&
		!iMessage->GetBinaryHeaderField(EHttpContentLocation,from) )
		{
		from.Set(KNullDesC8);
		}
		aSlPushMsgEntry.SetFromL(from);
		
	if(iMessage->MessageAllowed())
		{
		aSlPushMsgEntry.SetTrusted(ETrue);
		}
	else
		{
		aSlPushMsgEntry.SetTrusted(EFalse);	
		}
		
	TPtrC8 serverAddress8;
	iMessage->GetServerAddress(serverAddress8);
	aSlPushMsgEntry.SetMsgOriginUriL(serverAddress8);
		
	TTime puchMsgDate;
	if(iMessage->GetHeaderField(EHttpDate, puchMsgDate))
		aSlPushMsgEntry.SetTimeSent(puchMsgDate );
	}
// --------------------------------------------------------------------------------------
// Verifies if container's parent node has xmlmime:contentType 
// attribute information item. If found, the function returns ETrue 
// and xmlmime:contentType attribute value. Otherwise, function
// returns EFalse and aContentType is undefined.
// --------------------------------------------------------------------------------------
//
TBool CXmlEngSerializerXOP::GetContentTypeValue(TXmlEngDataContainer aContainer, TPtrC8& aContentType)
	{
	_LIT8(KMimeNsUri, "http://www.w3.org/2004/11/xmlmime");
	_LIT8(KContentTypeName, "contentType");
	
	TXmlEngElement parent = aContainer.ParentNode().AsElement();
	if(parent.HasAttributes())
		{
		RXmlEngNodeList<TXmlEngAttr> attrList;
		parent.GetAttributes(attrList);
		for(TInt i = 0; i < attrList.Count(); i++)
			{
			TXmlEngAttr attr = attrList.Next();
			if(attr.Name().Compare(KContentTypeName) == 0 
				&& attr.NamespaceUri().Compare(KMimeNsUri) == 0)
				{
				aContentType.Set(attr.Value());
				return ETrue;
				}
			}
		}
	return EFalse;
	}
void CAknKeyLockControl::CallNumberL( TDesC& aNumber )
    {
    CAiwServiceHandler* serviceHandler;
    serviceHandler = CAiwServiceHandler::NewL();
    serviceHandler->AttachL(R_AKNNOTIFYPLUGIN_INTEREST);

    TAiwDialDataV1 dialData = TAiwDialDataV1();
    dialData.SetTelephoneNumber(aNumber);
    dialData.SetCallType(EAiwVoice);
    TAiwDialDataV1Pckg dialDataPckg = TAiwDialDataV1Pckg(dialData);
    CAiwGenericParamList& paramList = serviceHandler->InParamListL();
    TPtrC8 ptr;
    ptr.Set(dialDataPckg);
    TAiwVariant variant(ptr);
    TAiwGenericParam param(EGenericParamCallDialDataV1, variant);
    paramList.AppendL(param);

    serviceHandler->ExecuteServiceCmdL(KAiwCmdCall,
                                        paramList,
                                        serviceHandler->OutParamListL(),
                                        0,
                                        NULL);
    }
void CSenXmlReader::OnEndElementL(const RTagInfo& aElement, TInt /* aErrorCode */)
    {
    if(!iContentHandler)
        {
        SENDEBUG_L("OnEndElementL: KErrSenXmlContentHandlerNotSet");
        User::Leave(KErrSenXmlContentHandlerNotSet);
        }


    const TPtrC8 localName = aElement.LocalName().DesC();
    const TPtrC8 nsUri = aElement.Uri().DesC();
    const TPtrC8 prefix = aElement.Prefix().DesC();

    TPtrC8 qualifiedName = localName;

    if (prefix != KNullDesC8)
        {
        HBufC8* pQName = HBufC8::NewLC(prefix.Length()+localName.Length()+
                                        KSenColon().Length());
        TPtr8 qName = pQName->Des();
        qName.Append(prefix);
        qName.Append(KSenColon);
        qName.Append(localName);
        qualifiedName.Set(qName);
        }


    iContentHandler->EndElement(nsUri,
                                localName,
                                qualifiedName);

    if (prefix != KNullDesC8)
        {
        CleanupStack::PopAndDestroy(); // pQName
        }

    }
Example #18
0
TInt CFloggerTest028_Sync_ConMultiple2::executeStepL()
	{
	TInt ret;
	
	// clear the old log messages
	ret = flogger.Connect();
	
	if ( ret == KErrNone )
		{
		flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
		flogger.ClearLog();
		
		for (TInt loop = 1; loop <= KMultipleWriteStressTimes; loop++)
			{
			flogger.Write(KTestMessage);
			flogger.WriteFormat(KTestMessageOneParam16,KTestMessageOneParamValue);
			flogger.Write(KTestTooLongMessage16);
			flogger.WriteFormat(KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue);
			DoTestWriteFormat(KTestTooLongMessageOneParam8,KTestTooLongMessageOneParamValue);
			
			TPtrC8 dataSeg;
			dataSeg.Set(K1KilobyteOfData,K1KilobyteOfDataSize);
			flogger.WriteBinary(dataSeg);
			}
		flogger.Write(KTestEndMessage8);
		
		flogger.Close();
		
		TRAPD(r, ret = DoTestCheckWriteL());
		if (r != KErrNone)
			ret = r;
		}
		
	
	return ret;		

	}
void CImMobilityLogger::LogData(TInt /*aFilePos*/, const TDesC8& /*aText*/, const TDesC8& /*aFmt*/)
#endif //__IM_MOBILITY_LOGGING
	{
#ifdef __IM_MOBILITY_LOGGING

	TPtrC8 text(aText);
	TPtrC8 line;
	TInt crlfPos(0);

	for(;;)
		{
		crlfPos = text.Find(KTxtCRLF);

		if (crlfPos == KErrNotFound)
			{
			if (text.Length() > 0)
				{
				LogFormat(aFilePos, aFmt, text.Length(), &text);
				}

			break;
			}

		line.Set(text.Left(crlfPos));
		LogFormat(aFilePos, aFmt, crlfPos + 2, &line);

		if (text.Length() > crlfPos + 2)
			{
			text.Set(text.Mid(crlfPos + 2));
			}
		else
			{
			break;
			}
		}
#endif //__IM_MOBILITY_LOGGING
	}
EXPORT_C TBool CHTTPResponse::FindRealm(TPtrC8& aRealm) const
    {
	__LOG_ENTER(_L("CHTTPResponse::FindRealm"));
	// Search for the WWWAuthenticate field
	TPtrC8 realmPtr(aRealm);
    TBool retVal = FindField(EHttpWWWAuthenticate, realmPtr, 0);
    if (retVal)
        {
		// realmPtr now points to the WWWAuthentication field value. This contains the Authentication scheme, realm
		// value and optional parameters. Check authentication is Basic (encoded as 0x80). This is stored in the
		// second byte of the header value (i.e. index [1]).
		if (realmPtr[1] == 0x80)
			{
			// Set the realm descriptor passed in
            aRealm.Set(realmPtr.Mid(2));
#ifdef _DEBUG
			// In debug builds, convert the 8-bit realm to 16-bit UNICODE in order to log it.
			HBufC16* aRealm16 = HBufC16::New(aRealm.Length());
			if(aRealm16!=NULL)
				{
				TPtr16 aRealm16_Ptr = aRealm16->Des();
				aRealm16_Ptr.Copy(aRealm);
				__LOG1(_L("CHTTPResponse::FindRealm : found realm string: %S"), &aRealm16_Ptr);
				delete aRealm16;
				}
#endif
			}
		else
			{
			__LOG(_L("CHTTPResponse::FindRealm : nothing found"));
			retVal = EFalse;
			}
		}
	__LOG_RETURN;
    return retVal;
    }
THttpDataParser::TParseResult THttpDataParser::GetData(TPtrC8& aData, TInt aMaxSize)
/**
	Attempts to supply the data requested. The argument aMaxSize specifies the 
	amount of data required. If the amount is available the data returns a value
	of EGotData, otherwise EPartialData is returned.
	@param		aData		The output argument that is set to the buffer with 
							the requested data.
	@param		aMaxSize	The amount of data required.
	@return		A value of EGotData if all the requested data was supplied or 
				EPartialData if was not.
	@panic		EHttpMessagePanicBadDataParserState The parser was not in the 
													Idle state.
*/
	{
	__ASSERT_DEBUG( iState == EIdle, THttpMessagePanic::Panic(THttpMessagePanic::EHttpMessagePanicBadDataParserState) );

	// Set the length of the data to copy - intially set to available amount
	TInt copyLength = iData.Length();
	TParseResult result = EPartialData;

	// Make sure that not too much data is given...
	if( copyLength >= aMaxSize )
		{
		// The available data is same or more than the requested amount - adjust
		// the copy size to copy just the requested amount.
		copyLength = aMaxSize;
		result = EGotData;
		}
	// Copy over the data specified.
	aData.Set(iData.Left(copyLength));

	// Update the data buffer...
	iData.Set(iData.Mid(copyLength));

	return result;
	}
Example #22
0
// --------------------------------------------------------------------------
// CImageCapture::GetNextFileNameLC
// Get the file name
// --------------------------------------------------------------------------
HBufC* CImageCapture::GetNextFileNameLC(const TDesC& aName) const
{
    const TInt KNumberLength = 4; // this is to indicate the file numbering,
                                  // e.g. 0001, 0002, etc.
    const TInt KMaxIndex = 10000;
    const TInt KTimeRecordSize = 512;
    
    TPtrC filePathPtr;
    _LIT(KExtensionpng, ".png");
    _LIT(KSlash,"\\");
    
    // Gets the file extension.
    TPtrC fileExtension;
    fileExtension.Set(KExtensionpng);
   
    filePathPtr.Set(iSettings.iLogPath);
    TInt result = filePathPtr.LocateReverse('\\');
    TPtrC string;
    if(result!=KErrNotFound)
    	string.Set(filePathPtr.Left(result+1));
    
    TBuf8<KTimeRecordSize> fileName;
    fileName.Copy(string);
    
    if(iXmlFileName.Length()>0)
    {
    	TInt pos=iXmlFileName.LocateReverse('.');
    	TPtrC8 ptr;
    	if(pos!=KErrNotFound)
    	{
    		ptr.Set(iXmlFileName.Left(pos));
    		fileName.Append(ptr);
    	}
    	
		fileName.Append(KSlash);
    }
    
    fileName.Append(aName);
    HBufC* newFileName = HBufC::NewLC(fileName.Length()+ KNumberLength + fileExtension.Length() + 1);
    TPtr newFileNamePtr(newFileName->Des());
    newFileNamePtr.Copy(fileName);

    
    // Checks whether aNamexxxx.png already exists on the phone or not.
    // This is to prevent over-riding of any existing images with the same name
    TBool IsFileExist = ETrue;
    TInt index = 1;
    HBufC* buffer = HBufC::NewL(newFileNamePtr.MaxLength());
    TPtr bufferPtr(buffer->Des());
    while ((index < KMaxIndex) && (IsFileExist))
    {
        bufferPtr.Copy(newFileNamePtr);
        bufferPtr.AppendNumFixedWidth(index, EDecimal, KNumberLength);
        bufferPtr.Append(fileExtension);
        if (BaflUtils::FileExists(CCoeEnv::Static()->FsSession(), *buffer))
        {
        	index++;
        }
        else
        {
        	IsFileExist = EFalse;
        }
    }
    delete buffer;

    // If the index exceeds KMaxIndex, then we don't need to format the file name.
    if (index >= KMaxIndex)
    {
    	newFileNamePtr.AppendNum(index);
    }
    else
    {
    	newFileNamePtr.AppendNumFixedWidth(index, EDecimal, KNumberLength);
    }
    newFileNamePtr.Append(fileExtension);

    // If the index greated then KMaxIndex, then rollback to 1
    
    if (index >= KMaxIndex)
    {
    	index = 1;
    }
    
    return newFileName;
}
// Please see  » Symbian OS v9.1 » Symbian OS guide » Using HTTP Client »
// Handling request body data for explanation on this part
TBool CSymbianTransportAgent::GetNextDataPart(TPtrC8& aDataChunk)
{
    aDataChunk.Set(iPostBody->Des());
    return ETrue;
}
// ---------------------------------------------------------------------------
// CUpnpHttpFileTransferWriter::StartL
// Sends the HTTP headers of the content
// ---------------------------------------------------------------------------
//
void CUpnpHttpFileTransferWriter::SendHeadersL()
    {
    if(iState == EHeaders)
    	if( iSession.FileAccess() )
    		if(!IsActive())
    			{ 
    			//in case session not connected,waiting...
    			if(!iSession.IsConnected())
					{
					iWaiting = ETrue;
					return;
					}   			
				iSendBuffer.Zero();
				
				if ( ( iSession.FileAccess()->GetHeaders().Length() -
				       iSession.FileAccess()->TransferredBytes()) <= 
		               iSendBuffer.MaxLength() )
					{
					TPtrC8 headerPointer;
					headerPointer.Set(iSession.FileAccess()->GetHeaders());
					headerPointer.Set( headerPointer.Right( 
		            iSession.FileAccess()->GetHeaders().Length()-
		                iSession.FileAccess()->TransferredBytes()) );
				
					iSendBuffer.Append( headerPointer );			
					iSession.FileAccess()->SetHeadersSent();

                    // Adding file content to the header
                    TInt length = iSendBuffer.MaxLength()-iSendBuffer.Length();
                    						
                    HBufC8* tmpBuffer = HBufC8::NewLC(length);
					
                    iSendPointer.Set(tmpBuffer->Des());
                    if( iSession.FileAccess()->GetL(iSendPointer,length) )
                        {
                        iState = EFinished;
                        }
                    iSendBuffer.Append(iSendPointer);
                    CleanupStack::PopAndDestroy( tmpBuffer );
					}
				else
					{
					TPtrC8 headerPointer;
					headerPointer.Set( iSession.FileAccess()->GetHeaders() );
					headerPointer.Set( headerPointer.Right( 
		            iSession.FileAccess()->GetHeaders().Length() -
		                iSession.FileAccess()->TransferredBytes() ) );
					headerPointer.Set( headerPointer.Left( 
		                iSendBuffer.Length() ) );
					
					iSendBuffer.Append( headerPointer );				
					iSession.FileAccess()->SetPosOfHeader( 
					    iSession.FileAccess()->TransferredBytes() + headerPointer.Length() );							
					}
		    	
		    	iSendPointer.Set((TUint8*)iSendBuffer.Ptr(),iSendBuffer.Length(),iSendBuffer.MaxLength());
    	   		
    	   		iSession.TimerCancel();        
	        	WriteToSocket();
	        	iSession.StartTimeoutTimer(ETrue);
	        	
	        	if(!iHttpPostStarted)
	        		{
	        		iSession.NotifyUpperLayersOnPostL();
	        		iHttpPostStarted = ETrue;
	        		}
	        		
    			}
    }          
Example #25
0
SYSCALL(MAHandle, maConnect(const char* url)) {
	TPtrC8 urlP(CBP url, SYSCALL_THIS->ValidatedStrLen(url));
	LOGST("Connect %i %s", gConnNextHandle, url);
	if(gConnections.size() >= CONN_MAX)
		return CONNERR_MAX;

	_LIT8(KLocalhost, "localhost");
	CConnection* conn = NULL;
	TPtrC8 match;
	SocketType socketType = TCP;	// initialized to placate stupid compiler
	ConnectionType type;

	// determine type of connection
	if(SSTREQ(urlP, KSocket)) {
		match.Set(KSocket);
		type = eSocket;
		socketType = TCP;
	} else if(SSTREQ(urlP, KDatagram)) {
		match.Set(KDatagram);
		type = eSocket;
		socketType = UDP;
	} else if(SSTREQ(urlP, KSsl)) {
		match.Set(KSsl);
		type = eSocket;
		socketType = SSL;
	} else if(SSTREQ(urlP, KHttp)) {
		match.Set(KHttp);
		type = eHttp;
		socketType = TCP;
	} else if(SSTREQ(urlP, KHttps)) {
		match.Set(KHttps);
		type = eHttp;
		socketType = SSL;
	} else if(SSTREQ(urlP, KBtspp)) {
		match.Set(KBtspp);
		type = eBtspp;
	} else {	//error
		return CONNERR_URL;
	}
	TPtrC8 parturl = urlP.Mid(match.Length());

	if(type == eSocket) {
		TPtrC8 hostnamePtrC8;
		int port;
		if(!splitPurl(parturl, hostnamePtrC8, port, (1<<16))) {
			return CONNERR_URL;
		}
		Smartie<CSocket> sockp(createSocket(socketType));

		_LIT8(K127, "127.");
		TInetAddr addr;
		bool localhost = false;
		if(hostnamePtrC8 == KLocalhost) {
			localhost = true;
			addr.SetAddress(INET_ADDR(127,0,0,1));
		} else if(hostnamePtrC8.Length() > K127().Length()) {
			if(hostnamePtrC8.Left(K127().Length()) == K127) {
				localhost = true;
				Smartie<HBufC16> hostname(CreateHBufC16FromDesC8LC(hostnamePtrC8));
				addr.Input(*hostname());
			}
		}
		sockp->state |= CONNOP_CONNECT;
		if(localhost) {
			StartConnOpL(CO_AddrConnect::NewL(false, *this, gConnNextHandle, *sockp(),
				addr, port, *sockp()));
		} else {
			Smartie<HBufC16> hostname(CreateHBufC16FromDesC8LC(hostnamePtrC8));
			CleanupStack::Pop(hostname());
			StartConnOpL(CO_NameConnect::NewL(gNetworkingState != EStarted,
				*this, gConnNextHandle, *sockp(), hostname, port, *sockp()));
		}
		conn = sockp.extract();
	} else if(type == eHttp) {
		CHttpConnection* http;
		TLTZ_PASS(httpCreateConnectionLC(parturl, http, HTTP_GET, socketType));
		http->state |= CONNOP_CONNECT;
		StartConnOpL(CO_HttpFinish::NewL(gNetworkingState != EStarted,
			*this, gConnNextHandle, *http, *http, true));
		http->mState = CHttpConnection::WRITING;
		conn = http;
		CleanupStack::Pop(conn);
	} else if(type == eBtspp) {
		if(gBtState != eAvailable) {
			return CONNERR_UNAVAILABLE;
		}
		TPtrC8 hostnamePtrC8;
		int port_m1_index = parturl.Locate(':');
		if(port_m1_index == KErrNotFound) {
			return false;
		}
		hostnamePtrC8.Set(parturl.Left(port_m1_index));
		if(hostnamePtrC8 == KLocalhost) {	// server
			// extract and parse uuid
			static const int KUuidLength = 32;
			int uuidStartIndex = port_m1_index + 1;
			int paramStartIndex = uuidStartIndex + KUuidLength;
			if(parturl.Length() < paramStartIndex) {
				return CONNERR_URL;
			}
			TPtrC8 uuidPtrC8(parturl.Mid(uuidStartIndex, KUuidLength));
			TUint32 us[4];
			for(int i=0; i<4; i++) {
				TPtrC8 p(uuidPtrC8.Mid(i*8, 8));
				for(int j=0; j<8; j++) {
					if(!TChar(p[j]).IsHexDigit())
						return CONNERR_URL;
				}
				LHEL(TLex8(p).Val(us[i], EHex));
			}
			TUUID uuid(us[0], us[1], us[2], us[3]);
			//TUUID uuid(KSerialPortUUID);	//temp hack

			// create listener socket
			Smartie<CBtServerSocket> sockp(new (ELeave) CBtServerSocket(gBtSdpDB));

			// extract name, if it's there. initialize the socket.
			TPtrC8 paramPtrC8(parturl.Mid(paramStartIndex));
			_LIT8(KNameParam, ";name=");
			if(SSTREQ(paramPtrC8, KNameParam)) {
				TPtrC8 namePtrC8(paramPtrC8.Mid(KNameParam().Length()));
				sockp->init(gSocketServ, uuid, true, namePtrC8);
			} else if(paramPtrC8.Length() == 0) {
				sockp->init(gSocketServ, uuid, false);
			} else {
				return CONNERR_URL;
			}
			//skip the async/connect step
			gConnections.insert(gConnNextHandle, sockp.extract());
			return gConnNextHandle++;
		} else {	// client
			// extract port number
			int port;
			if(!splitPurl(parturl, hostnamePtrC8, port, 31)) {
				return CONNERR_URL;
			}
			TRfcommSockAddr rfcsa;

			// parse address
			TBTDevAddr btaddr;
			for(int i=0; i<BTADDR_LEN; i++) {
				TLex8 btaLex(parturl.Mid(i*2, 2));
				int result = btaLex.Val(btaddr[i], EHex);
				if(result != KErrNone)
					return CONNERR_URL;
			}
			rfcsa.SetBTAddr(btaddr);

			// create socket
			Smartie<CSocket> sockp(new (ELeave) CSocket(gSocketServ, CSocket::ERfcomm));
			sockp->state |= CONNOP_CONNECT;
			StartConnOpL(CO_AddrConnect::NewL(false, *this, gConnNextHandle, *sockp(),
				rfcsa, port, *sockp()));
			conn = sockp.extract();
		}
	}
	CleanupStack::PushL(conn);
	gConnections.insert(gConnNextHandle, conn);
	CleanupStack::Pop(conn);
	return gConnNextHandle++;
}
void CDomainNameCodec::EncodeL(TDomainNameArray& aNames, RBuf8& aBuf8)
	{
	TUint requiredLength = 0;
	TUint8 nameIdx = 0;
	
	for (nameIdx=0;nameIdx<aNames.Count();nameIdx++)
		{
		// The total length required for the labels that comprise an
		// individual domain name needs to take into the length octet
		// for the initial label and the null-termination character.
		// Hence the '+ 2' below.
		requiredLength += (aNames[nameIdx].Length() + 2);		
		
		// A further length check is performed on each domain name to
		// ensure it does not exceed the maximum length permitted according
		// to RFC 1035.
		if(aNames[nameIdx].Length() > KMaxDomainNameLength)
			{
			User::Leave(KErrArgument);
			}
		}		
	
	aBuf8.Zero();
	aBuf8.ReAllocL(requiredLength);
	
	TLex8 domainName;
	TPtrC8 currentLabel;
	
	for (nameIdx=0;nameIdx<aNames.Count();nameIdx++)
		{
		domainName.Assign(aNames[nameIdx]);		
		domainName.Mark();
		
		while (!domainName.Eos())
			{
			TChar ch;
			do
				{
				ch = domainName.Get();
				}
			while ( ch != TChar('.') && !domainName.Eos() );
			
			// if not the end of the string, unget the previous char to skip the trailing
			//  dot in our marked token
			//
			if( !domainName.Eos() )
				{
				domainName.UnGet();
				}
			
			currentLabel.Set(domainName.MarkedToken());
			
			// move past the dot again, or do nothing in particular at EOS
			//
			domainName.Get();
			
			User::LeaveIfError(currentLabel.Length() > KMaxDnsLabelLength ? 
				KErrArgument : KErrNone);
			
			aBuf8.Append(TChar(currentLabel.Length()));
			aBuf8.Append(currentLabel);
			
			domainName.Mark();
			}
		
		aBuf8.Append(TChar(0));
		}
	}
// ----------------------------------------------------------
// CSimplePresenceList::DoConstructL
// ----------------------------------------------------------
//    
void CSimplePresenceList::DoConstructL( 
    RPointerArray<CBodyPart>& aParts, const TDesC8& aStart )
    {
    
    _LIT8( KMyContentType, "Content-Type: multipart/related;");  
    _LIT8( KMyBoundary, "boundary="); 
    
    const TInt myBoundaryLen = 9;   // boundary=  9 characters         
       
    // Handle body parts one by one
    TInt size = aParts.Count();
    TInt i;
    CBodyPart* cp = NULL;
    TPtrC8 boundary;
    TPtrC8 start;
    
    // remove "..." quoted marks when needed
    TPtrC8 pStartUnquoted( KNullDesC8 );
    if ( aStart.Locate( '"') == 0 )
        {
        pStartUnquoted.Set( aStart.Mid( 1, aStart.Length() - 2 ));
        }
    else
        {
        pStartUnquoted.Set( aStart );        
        } 

    // remove <...> marks when needed
    if ( pStartUnquoted.Locate( '<') == 0 )
        {
        pStartUnquoted.Set( pStartUnquoted.Mid( 1, pStartUnquoted.Length() - 2 ));
        } 
    
    TPtrC8 p8;
    p8.Set( KSimpleDocumentType );
    TInt mySize = p8.Length();
    p8.Set( KSimpleMultipartType );
    TInt mySize2 = p8.Length();    
          
#ifdef _DEBUG                
    TPtrC p16b; // notice: for debug
    TPtrC8 p8b;
#endif 

// Make this handle direct content too in the RLMI list, i.e. 
// content-type: multipart/related; type="application/pidf+xml"; boundary=...;
    for (i = 0; i < size; i++)
        {
        cp = aParts[i];
        // inline const TDesC8& Headers() { return iHeaders; }
        TPtrC8 allHeaders = cp->Headers();
        HBufC8* headersBuff = allHeaders.AllocL();
        CleanupStack::PushL( headersBuff );
               
#ifdef _DEBUG        
        p16b.Set( cp->Url() ); // debug only
        p8b.Set( cp->ContentType() ); // debug only
        p8b.Set( cp->ContentID() ); // debug only
#endif                         
        if ( !pStartUnquoted.Compare( cp->ContentID()) &&
             !cp->ContentType().Left(sizeof(KSimpleListType)).CompareF( KSimpleListType ))
            {
            // Meta data is the root         
            iMeta = CSimpleMeta::NewL( cp->Body() );                               
            }
        else if ( !cp->ContentType().CompareF( KSimpleDocumentType ))
            {
            // Ordinary presence element                    
            CSimpleDocument* cd = CSimpleDocument::NewL( cp->Body() );             
            CleanupStack::PushL( cd );           
            User::LeaveIfError( iDocuments.Append( cd ) );
            CleanupStack::Pop( cd );
            }             
        else if ( (!cp->ContentType().Left(mySize2).CompareF( KSimpleMultipartType ))) 
            {
            // multipart for user's direct content data
            // get boundary from headers
            TPtrC8 pStart(KNullDesC8);
            TPtrC8 pBoundary(KNullDesC8);          
            
            TPtrC8 pHeaders = headersBuff->Des();
            TPtrC8 pContentType;
            TInt pos1 = pHeaders.Find( KMyContentType );
            if ( pos1 >= 0 )
                {
                TPtrC8 h2 = pHeaders.Mid( pos1 );
                TInt pos2 = h2.Locate( '\r');
                if ( pos2 < 0 )
                    {
                    pContentType.Set( h2 );
                    }
                else
                    {
                    pContentType.Set( h2.Left( h2.Length() - pos2 ));                    
                    }    
                                                                
                // search boundary 
                TInt posx = pContentType.Find( KMyBoundary );
                if ( posx >= 0 )
                    {                    
                    TPtrC8 h5 = pContentType.Mid( posx );
                    TInt pos5 = h5.Locate( ';');
                    if ( pos5 < 0 )
                        {
                        // There are no more parameters
                        pBoundary.Set( h5.Mid( myBoundaryLen )); 
                        }
                    else
                        {
                        // There are more in the line, has to cut off                        
                        pBoundary.Set( h5.Mid( myBoundaryLen, pos5 - myBoundaryLen ));                        
                        }    
                    }                 
                }
            
            // "..." characters are removed later from boundary in NewInMultiPartL(
            CSimpleDocument* cd = CSimpleDocument::NewInMultiPartL( cp->Body(), pBoundary, pStart );
            CleanupStack::PushL( cd );           
            User::LeaveIfError( iDocuments.Append( cd ) );
            CleanupStack::Pop( cd );            
                        
            }        
        /* notice: later nested multiparts if type = rlmi   */
        else
            {
            // This is something that should not be in the document.
            // Ignore it.
            } 
        CleanupStack::PopAndDestroy( headersBuff );                             
        }    
    }
// ---------------------------------------------------------
// CDpMif::HandlePepCtrlReq
// Handles PepCtrlReq messages
// ---------------------------------------------------------
//
void CDpMif::HandlePepCtrlReq(
    TIsiReceiveC& aIsiMessage )
    {
    OstTrace0( TRACE_NORMAL, CDPMIF_HANDLEPEPCTRLREQ, "CDpMif::HandlePepCtrlReq" );
    LOGM(" CDpMif::HandlePepCtrlReq");

    // Transaction id
    TUint8 transactionId( aIsiMessage.Get8bit(
        ISI_HEADER_OFFSET_TRANSID ) );

    // Pipe Handle
    if ( PN_PIPE_INVALID_HANDLE == iPifDcs.PipeHandle() )
        {
        TUint8 pipeHandle( aIsiMessage.Get8bit(
            ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PIPEHANDLE) );
        iPifDcs.SetPipeHandle( pipeHandle );
        }

    // PEP Type
    TUint8 pepType( aIsiMessage.Get8bit(
        ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PEPTYPE ) );
    // PEP Control ID
    TUint8 ctrlId( aIsiMessage.Get8bit(
        ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PEPCTRLID ) );
    // PEP Control Data
    TPtrC8 ctrlData;
    // Check if there is data (there is no data for all control id's)
    if ( ( ISI_HEADER_SIZE + SIZE_PNS_PEP_CTRL_REQ ) <=
         aIsiMessage.GetBuffer().Length() )
        {
        // Control Data length is 1 byte
        TInt ctrlDataLen( 1 );
        ctrlData.Set( aIsiMessage.GetData(
            ISI_HEADER_SIZE + PNS_PEP_CTRL_REQ_OFFSET_PEPCTRLDATA,
            ctrlDataLen ) );
        }
    // Get sender device
    TUint8 senderDevice( aIsiMessage.Get8bit(
        ISI_HEADER_OFFSET_SENDERDEVICE ) );
    // Get sender object
    TUint8 senderObject( aIsiMessage.Get8bit(
        ISI_HEADER_OFFSET_SENDEROBJECT ) );
#ifdef PIPECAMP_DATAPORT_PNS_PEP_STATUS_IND_PHONET_ADDRESS_FROM_PNS_PEP_CTRL_REQ
    iPifDcs.SetPipeControllerDeviceIdentifier( senderDevice );
    iPifDcs.SetPipeControllerObjectIdentifier( senderObject );
#endif
    // E32 return value
    TInt return_E32( KErrNone );
    // PN_PIPE return value
    TInt ret( KErrNone );

    switch ( pepType )
        {
        case PN_PEP_TYPE_COMM:
        case PN_PEP_TYPE_BT_ACC:
            {
            // comm_pep handles ctrl_req
            // Something can go wrong in here. Leaving is not the best case in here.
            // We can send an response message with error value to NOS side and
            // hope for the best.
            return_E32 = iCommPep.HandlePepCtrlReq( ctrlId, ctrlData );
            break;
            }

        default: // Not supported pepType
            {
            LOG1("  ERROR - Unsupported pep type: %d", pepType );
            OstTraceExt1( TRACE_NORMAL, DUP1_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Unsupported pep type: %hhu", pepType );

            return_E32 = KErrArgument;
            break;
            }
        }

    // do mapping from E32 error codes => PN_PIPE error codes
    switch ( return_E32 )
        {
        case KErrNone:
            {
            ret = PN_PIPE_NO_ERROR;
            break;
            }
        case KErrNotSupported:
            {
            // this error code should NOT be used according to specification
            LOG("  ERROR - Unsupported config (KErrNotSupported)");
            OstTrace0( TRACE_NORMAL, DUP2_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Unsupported config (KErrNotSupported)" );

            ret = PN_PIPE_ERR_NOT_SUPPORTED;
            break;
            }
        case KErrArgument:
            {
            // this error code should NOT be used according to specification
            LOG("  ERROR - Invalid argument (KErrArgument)");
            OstTrace0( TRACE_NORMAL, DUP3_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Invalid argument (KErrArgument)" );

            ret = PN_PIPE_ERR_INVALID_PARAM;
            break;
            }
        case KErrGeneral:
            {
            LOG("  ERROR - Invalid parameter (KErrGeneral)");
            OstTrace0( TRACE_NORMAL, DUP4_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Invalid parameter (KErrGeneral)" );

            ret = PN_PIPE_ERR_INVALID_CTRL_ID;
            break;
            }
        default:
            {
            // this error code should NOT be used according to specification
            LOG1("  ERROR - Other error: %d", return_E32 );
            OstTrace1( TRACE_NORMAL, DUP5_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: ERROR - Other error: %d", return_E32 );

            ret = PN_PIPE_ERR_GENERAL;
            break;
            }
        }

    // Create PNS_PEP_CTRL_RESP response
    TBuf8<SIZE_PNS_PEP_CTRL_RESP> messageData;
    // Pipe Handle
    messageData.Append( iPifDcs.PipeHandle() );
    // PEP Control ID
    messageData.Append( ctrlId );
    // PEP Type
    messageData.Append( pepType );
    // Error Code
    messageData.Append( static_cast<TUint8>( ret  ) );
    // Filler bytes
    messageData.Append( KDpPadding );
    messageData.Append( KDpPadding );

    // Send message, respond to sender
    return_E32 = SendMessage(
        senderDevice,
        senderObject,
        PN_PIPE,
        transactionId,
        PNS_PEP_CTRL_RESP,
        messageData );

    LOG1("  <== PNS_PEP_CTRL_RESP resp sent, error code = %d", ret );
    OstTrace1( TRACE_NORMAL, DUP6_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: <== PNS_PEP_CTRL_RESP resp sent, error code = %d", ret );

#if defined(_DEBUG)
    if (KErrNone != return_E32 )
        {
        LOG1("  Error isc api send %d", return_E32 );
        OstTrace1( TRACE_NORMAL, DUP7_CDPMIF_HANDLEPEPCTRLREQ, "CDpMif:: Error isc api send %d", return_E32 );
        }
    //no else
#endif

    }
/** Retreives the payload from this frame.

@pre The integrity of the frame must have been verified (@see 
	 BrowsingFrame::VerifyFrameL) as the length is not checked
	 before retrieving the payload.
@param aFrame The frame to retrieve the payload for.
@param aPayload On return the payload of aFrame
*/
void AvrcpBrowsing::BrowsingFrame::Payload(const TDesC8& aFrame, TPtrC8& aPayload)
	{
	aPayload.Set(aFrame.Mid(AvrcpBrowsing::KHeaderLength, AvrcpBrowsing::BrowsingFrame::ParamLength(aFrame)));
	}
// ---------------------------------------------------------
// CDpMif::HandlePepStatusInd
// Handles PepStatusInd messages
// ---------------------------------------------------------
//
TInt CDpMif::HandlePepStatusInd(
    TIsiReceiveC& aIsiMessage )
    {
    OstTrace0( TRACE_NORMAL, CDPMIF_HANDLEPEPSTATUSIND, "CDpMif::HandlePepStatusInd" );
    LOGM(" CDpMif::HandlePepStatusInd");

    // PEP Type
    TUint8 pepType( aIsiMessage.Get8bit(
        ISI_HEADER_SIZE + PNS_PEP_STATUS_IND_OFFSET_PEPTYPE ) );
    // Indication ID
    TUint8 indId( aIsiMessage.Get8bit(
        ISI_HEADER_SIZE + PNS_PEP_STATUS_IND_OFFSET_INDICATIONID ) );

    // Indication Data
    TPtrC8 indData;
    TInt ret( KErrNone );

    if ( 15 < aIsiMessage.GetBuffer().Length() )
        {
        // Indication data length is 1 byte
        indData.Set( aIsiMessage.GetData(
            ISI_HEADER_SIZE + PNS_PEP_STATUS_IND_OFFSET_INDICATIONDATA, 1 ) );
        }
    else
        {
        ret = KErrGeneral;
        }

    if ( KErrNone == ret )
        {
        TInt result( KErrNone );
        switch ( pepType )
            {
            case PN_PEP_TYPE_COMM:
            case PN_PEP_TYPE_BT_ACC:
                {
                // comm_pep handles status_ind.
                // If dataport doesn't understand the status msg
                // it can't do nothing about it.
                result = iCommPep.HandlePepStatusInd( indId, indData );
                break;
                }
            case PN_PEP_TYPE_COMMON:
                {
                // DO NOTHING
                // This is handled in ISC
                break;
                }
            default:
                {
                // Dataport doesn't support the PNS_PEP_STATUS pep type
                // Life's hard, can't do nothing. Don't need to leave
                // in release code.
                LOG1(" ERROR - Unsupported pep type: %d", result );
                OstTrace1( TRACE_NORMAL, DUP1_CDPMIF_HANDLEPEPSTATUSIND, "CDpMif:: ERROR - Unsupported pep type: %d", result );

                ret = KErrGeneral;
                }
            }

        if ( KErrNone == result )
            {
            LOG1(" CDpMif::HandlePepStatusInd: %d", result );
            OstTrace1( TRACE_NORMAL, DUP2_CDPMIF_HANDLEPEPSTATUSIND, "CDpMif:: HandlePepStatusInd: %d", result );
            }
        //no else
        }
    //no else

    return ret;
    }