engine/src/PodcastUtils.cpp
author teknolog
Thu, 25 Feb 2010 21:08:38 +0000
changeset 15 93d9f66bf50b
parent 2 29cda98b007e
child 18 cda6e6257514
permissions -rw-r--r--
Cleaning description better for second line in search results
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
* All rights reserved.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
* This component and the accompanying materials are made available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
* under the terms of the License "Eclipse Public License v1.0"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
* which accompanies this distribution, and is available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
* Initial Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
* EmbedDev AB - initial contribution.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
* Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
* Description:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
#include <e32std.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include <e32base.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include <TXTETEXT.H> // for ELineBreak
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
#include "PodcastUtils.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include "debug.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include "FeedEngine.h" // for KMaxDescriptionLength
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
EXPORT_C void PodcastUtils::FixProtocolsL(TDes &aUrl)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
	HBufC* urlCopy = aUrl.AllocLC();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
	TPtr urlCopyPtr (urlCopy->Des());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
	urlCopyPtr.LowerCase();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
	// url is always present so access that								
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
	// Some pod links are written in format itpc://mylink.net/podcast.xml
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
	// Symbian HTTP stack does not like itpc:// 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
	// Try to use a HTTP instead.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
	TInt p = urlCopyPtr.Find(KItpcPrefix);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
	if (p >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
		aUrl.Delete(p, KItpcPrefix().Length());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
	// Some pod links are written in format pcast://mylink.net/podcast.xml
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
	// Symbian HTTP stack does not like itpc:// 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
	// Try to use a HTTP instead.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
	p = urlCopyPtr.Find(KPcastPrefix);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
	if (p >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
		aUrl.Delete(p, KPcastPrefix().Length());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
	// The URL must start with http://, otherwise the HTTP stack fails.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
	TInt pos = urlCopyPtr.Find(KURLPrefix);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	if (pos == KErrNotFound)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
		HBufC* newUrl = HBufC::NewL(aUrl.Length() + KURLPrefix().Length());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
		TPtr ptr = newUrl->Des();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
		ptr.Append(KURLPrefix());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
		ptr.Append(aUrl);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
		// replace the url buffer
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
		aUrl.Copy(*newUrl);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
		delete newUrl;					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
	CleanupStack::PopAndDestroy(urlCopy);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
EXPORT_C void PodcastUtils::CleanHtmlL(TDes &str)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
#ifdef UIQ
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
	_LIT(KLineBreak, "\r\n");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
#else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	const TChar KLineBreak(CEditableText::ELineBreak); 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
	_LIT(KNewLine, "\n");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	ReplaceString(str, KNewLine, KNullDesC);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
//	DP2("CleanHtml %d, %S", str.Length(), &str);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	TInt startPos = str.Locate('<');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	TInt endPos = str.Locate('>');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	//DP3("length: %d, startPos: %d, endPos: %d", str.Length(), startPos, endPos);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	HBufC* tmpBuf = HBufC::NewLC(KMaxDescriptionLength);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	TPtr tmp(tmpBuf->Des());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	while (startPos != KErrNotFound && endPos != KErrNotFound && endPos > startPos) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
		//DP1("Cleaning out %S", &str.Mid(startPos, endPos-startPos+1));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
		tmp.Copy(str.Left(startPos));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
		TPtrC ptr=str.Mid(startPos, endPos-startPos+1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
		_LIT(KHtmlBr, "<br>");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
		_LIT(KHtmlBr2, "<br />");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
		_LIT(KHtmlBr3, "<br/>");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
		_LIT(KHtmlP, "<p>");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
		if (ptr.CompareF(KHtmlBr)== 0 || ptr.CompareF(KHtmlBr2)== 0 || ptr.CompareF(KHtmlBr3)== 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
			tmp.Append(KLineBreak);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
		else if (ptr.CompareF(KHtmlP) == 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
			tmp.Append(KLineBreak);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
			tmp.Append(KLineBreak);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
		if (str.Length() > endPos+1) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
			tmp.Append(str.Mid(endPos+1));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
		str.Copy(tmp);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
		startPos = str.Locate('<');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
		endPos = str.Locate('>');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
	str.Trim();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
	_LIT(KAmp, "&amp;");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
	_LIT(KQuot, "&quot;");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
	_LIT(KNbsp, "&nbsp;");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
	_LIT(KCopy, "&copy;");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
	_LIT(KCopyReplacement, "(c)");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
	if(str.Locate('&') != KErrNotFound) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
		ReplaceString(str, KAmp, KNullDesC);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
		ReplaceString(str, KQuot, KNullDesC);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
		ReplaceString(str, KNbsp, KNullDesC);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
		ReplaceString(str, KCopy, KCopyReplacement);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
	ReplaceChar(str, '"', '\'');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
	CleanupStack::PopAndDestroy(tmpBuf);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
15
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   129
EXPORT_C void PodcastUtils::RemoveAllFormatting(TDes & aString)
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   130
	{
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   131
	// check for combination first so we prevent adding two spaces 
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   132
	ReplaceString(aString,_L("\r\n"), _L(" "));
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   133
	
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   134
	ReplaceString(aString,_L("\n"), _L(" "));
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   135
	ReplaceString(aString,_L("\r"), _L(" "));
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   136
	
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   137
	}
93d9f66bf50b Cleaning description better for second line in search results
teknolog
parents: 2
diff changeset
   138
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
EXPORT_C void PodcastUtils::ReplaceString(TDes & aString, const TDesC& aStringToReplace, const TDesC& aReplacement)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
	TInt pos=aString.Find(aStringToReplace);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
	TInt offset = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
	while (pos != KErrNotFound)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
		aString.Replace(offset+pos, aStringToReplace.Length(), aReplacement);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
		offset += pos + aStringToReplace.Length()+1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
		if (offset > aString.Length())
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
			return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
		pos=aString.Mid(offset).Find(aStringToReplace);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
EXPORT_C void PodcastUtils::ReplaceChar(TDes & aString, TUint aCharToReplace, TUint aReplacement)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
	TInt strLen=aString.Length();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
	for (TInt i=0; i < strLen; i++)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
		if (aString[i] == aCharToReplace)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
			aString[i] = aReplacement;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
EXPORT_C void PodcastUtils::EnsureProperPathName(TFileName &aPath)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
	// from the SDK: The following characters cannot occur in the path: < >: " / |*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
	ReplaceChar(aPath, '/', '_'); // better not to add \\ in case we have multiple /
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
	ReplaceChar(aPath, ':', '_');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
	ReplaceChar(aPath, '?', '_');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
	ReplaceChar(aPath, '|', '_');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
	ReplaceChar(aPath, '*', '_');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
	ReplaceChar(aPath, '<', '_');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
	ReplaceChar(aPath, '>', '_');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
	ReplaceChar(aPath, '"', '_');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
	//buf.Append(_L("\\"));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
EXPORT_C void PodcastUtils::FileNameFromUrl(const TDesC& aUrl, TFileName &aFileName)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
	TInt pos = aUrl.LocateReverse('/');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
	if (pos != KErrNotFound) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
		{	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
		TPtrC str = aUrl.Mid(pos+1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
		pos = str.Locate('?');
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
		if (pos != KErrNotFound) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
			aFileName.Copy(str.Left(pos));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
			} 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
		else 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
			aFileName.Copy(str);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
	DP2("FileNameFromUrl in: %S, out: %S", &aUrl, &aFileName);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
EXPORT_C void PodcastUtils::SQLEncode(TDes &aString)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
	ReplaceString(aString, _L("\""), _L("\"\""));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
	//ReplaceString(aString, _L("'"), _L("''"));	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
EXPORT_C void PodcastUtils::XMLEncode(TDes &aString)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
	ReplaceString(aString, _L("\""), _L("&quot;"));	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
	ReplaceString(aString, _L("<"), _L("&lt;"));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
	ReplaceString(aString, _L(">"), _L("&gt;"));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
	ReplaceString(aString, _L("&"), _L("&amp;"));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
	}