engine/src/PodcastUtils.cpp
branchsymbian1
changeset 336 3d6c1417e8bd
parent 246 140a404c6b53
child 366 f015466e6642
child 390 d7abecc9d189
equal deleted inserted replaced
296:80f1da5ac28b 336:3d6c1417e8bd
    71 	DP("PodcastUtils::CleanHtmlL BEGIN");
    71 	DP("PodcastUtils::CleanHtmlL BEGIN");
    72 	if (str.Length() == 0)
    72 	if (str.Length() == 0)
    73 		{
    73 		{
    74 		return;
    74 		return;
    75 		}
    75 		}
    76 	
       
    77 	DP("    miscellaneous");
       
    78 // miscellaneous cleanup
    76 // miscellaneous cleanup
       
    77 	DP("    miscellaneous cleanup");
    79 	const TChar KLineBreak(CEditableText::ELineBreak); 
    78 	const TChar KLineBreak(CEditableText::ELineBreak); 
    80 	_LIT(KNewLine, "\n");
    79 	_LIT(KNewLine, "\n");
    81 	_LIT(KNewLineWindows, "\r\n");
    80 	_LIT(KNewLineWindows, "\r\n");
    82 	ReplaceString(str, KNewLine, KNullDesC);
    81 	ReplaceString(str, KNewLine, KNullDesC);
    83 	ReplaceString(str, KNewLineWindows, KNullDesC);
    82 	ReplaceString(str, KNewLineWindows, KNullDesC);
    84 
    83 
    85 	DP("    strip HTML");
       
    86 // strip out HTML tags
    84 // strip out HTML tags
    87 	
    85 	DP("    strip out HTML tags");
    88 	TInt startPos = str.Locate('<');
    86 	TInt startPos = str.Locate('<');
    89 	TInt endPos = str.Locate('>');
    87 	TInt endPos = str.Locate('>');
    90 	HBufC* tmpBuf = HBufC::NewLC(KMaxDescriptionLength);
    88 	HBufC* tmpBuf = HBufC::NewLC(KMaxDescriptionLength);
    91 	TPtr tmp(tmpBuf->Des());
    89 	TPtr tmp(tmpBuf->Des());
    92 	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos) {
    90 	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos) {
   114 		str.Copy(tmp);
   112 		str.Copy(tmp);
   115 		startPos = str.Locate('<');
   113 		startPos = str.Locate('<');
   116 		endPos = str.Locate('>');
   114 		endPos = str.Locate('>');
   117 	}
   115 	}
   118 		
   116 		
       
   117 // change HTML encoded chars to unicode
   119 	DP("    change HTML encoded chars to unicode");
   118 	DP("    change HTML encoded chars to unicode");
   120 // change HTML encoded chars to unicode
       
   121 	startPos = str.Locate('&');
   119 	startPos = str.Locate('&');
   122 	endPos = str.Locate(';');
   120 	endPos = str.Locate(';');
   123 	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos)
   121 	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos)
   124 		{
   122 		{
   125 		TPtrC ptr(str.Mid(startPos+1, endPos-startPos));
   123 		TPtrC ptr(str.Mid(startPos+1, endPos-startPos));
   205 			}
   203 			}
   206 		}
   204 		}
   207 		
   205 		
   208 	CleanupStack::PopAndDestroy(tmpBuf);
   206 	CleanupStack::PopAndDestroy(tmpBuf);
   209 	
   207 	
   210 	DP("    trim");
       
   211 	if(str.Length()>1)
   208 	if(str.Length()>1)
   212 		{
   209 		{
   213 		DP1("str.Length() ==%d", str.Length());
       
   214 		// chop away newlines at start
   210 		// chop away newlines at start
   215 		while (str.Length() && (str[0] == KLineBreak))  {
   211 		DP("    chop away newlines at start");
   216 			DP("mid");
   212 		while (str.Length() > 0 && (str[0] == KLineBreak))  {
   217 			str = str.Mid(1);
   213 			str = str.Mid(1);
   218 		}
   214 		}
   219 		
   215 		
   220 		// chop away newlines at end
   216 		// chop away newlines at end
   221 	
   217 		DP("    chop away newlines at end");
   222 		while (str.Length() && (str[str.Length()-1] == KLineBreak)) {
   218 		while (str.Length() > 0 && (str[str.Length()-1] == KLineBreak)) {
   223 			DP("left");
       
   224 			str = str.Left(str.Length()-1);
   219 			str = str.Left(str.Length()-1);
   225 		}
   220 		}
   226 
   221 
   227 		str.Trim();
   222 		str.Trim();
   228 		}
   223 		}