void 
CConnectionSettings::SetPreferredIAPsL(const TDesC& aPreferredIAPs) 
{
   if(aPreferredIAPs.Length() > 0) {
      if(iPreferredIAPs) {
         iPreferredIAPs->Reset();
         delete iPreferredIAPs;
      }
      iPreferredIAPs = new (ELeave) CDesCArrayFlat(2);
      TLex lexer(aPreferredIAPs);
      while (!lexer.Eos()) {
         HBufC *tmp = lexer.NextToken().AllocLC();
         TChar ch = '_';
         TInt pos = tmp->Locate(ch);
         while (pos != KErrNotFound) {
            tmp->Des().Replace(pos, 1, _L(" "));
            pos = tmp->Locate(ch);
         }
         iPreferredIAPs->AppendL(*tmp);
         CleanupStack::PopAndDestroy(tmp);
      }
   }
}
Exemplo n.º 2
0
EXPORT_C HBufC* CUrl::EscapeEncodeL(const TDesC& aString, TInt aEscapeMode)
//
// Encodes any excluded characters in aString as escape triples - excluded characters set by aEscapeMode
	{
	// Need to create an HBufC with our excluded characters
	HBufC* excludedBuf = NULL;

	switch (aEscapeMode)
		{
	case EUrlGenericCompare:
		{
		// This is normal operation - escape all sets of data other than KReservedData
		excludedBuf = HBufC::NewLC(KUnwiseData().Length() + KDelimsData().Length());
		TPtr excluded = excludedBuf->Des();
		excluded.Append(KUnwiseData);
		excluded.Append(KDelimsData);
		} break;
	case EUrlScheme:
		{
		// Escaping data in scheme - reserved chars have no special meaning so escape as well.
		excludedBuf = HBufC::NewLC(KUnwiseData().Length() + KDelimsData().Length() + KReservedData().Length());
		TPtr excluded = excludedBuf->Des();
		excluded.Append(KUnwiseData);
		excluded.Append(KDelimsData);
		excluded.Append(KReservedData);
		} break;
	case EUrlPath:
		{
		// Escaping data in a local file path - same as EUrlScheme but don't escape '/' and ':'
		excludedBuf = HBufC::NewLC(KUnwiseData().Length() + KDelimsData().Length() + KReservedDataForPath().Length());
		TPtr excluded = excludedBuf->Des();
		excluded.Append(KUnwiseData);
		excluded.Append(KDelimsData);
		excluded.Append(KReservedDataForPath);
		} break;
	default:
		// Not supported return NULL
		return NULL;
		break;
		}

	//	Descriptor to hex digits
	const TDesC& HexDigit = KHexDigit;

	//	Allocate space to build escaped url - consider worse case, where all characters are excluded => length x 3
	HBufC* buf = HBufC::NewLC(aString.Length()*3);	//	CS
	TPtr escapedBuf = buf->Des();

	for (TInt i=0; i<aString.Length(); ++i)
		{
		//	Check if current character must be escaped, will leave if non 8-bit character
		TChar currentChar = aString[i];
		if (currentChar > 0xff)
			User::Leave(EWapErrCorruptUrl);
		//	Check if aChar is a member of DelimsData or UnwiseData or a control character
		if (excludedBuf->Locate(currentChar)!=KErrNotFound || (currentChar>=0x00 && currentChar<=0x1F) || currentChar==' ' || currentChar > 0x7E )
			{
			//	Escaped character will be 8-bit
			escapedBuf.Append('%');
			TInt msNibble = (currentChar & 0xf0) >> 4;	//	Get msNibble by masking against 11110000 and dividing by 16 (>>4)
			escapedBuf.Append(HexDigit[msNibble]);
			TInt lsNibble = (currentChar & 0x0f);	//	Get lsNibble by masking against 00001111
			escapedBuf.Append(HexDigit[lsNibble]);
			}
		else
			{