00001 /* 00002 Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 00003 Redistribution and use in source and binary forms, with or without 00004 modification, are permitted provided that the following conditions are met: 00005 00006 * Redistributions of source code must retain the above copyright notice, this 00007 � list of conditions and the following disclaimer. 00008 * Redistributions in binary form must reproduce the above copyright notice, 00009 � this list of conditions and the following disclaimer in the documentation 00010 � and/or other materials provided with the distribution. 00011 * Neither the name of Nokia Corporation nor the names of its contributors 00012 � may be used to endorse or promote products derived from this software 00013 � without specific prior written permission. 00014 00015 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00016 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00017 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00018 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00019 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00020 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00021 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00022 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00023 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00024 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 Description: 00027 ExampleInetProtUtil is a sample code for understanding the applicability of InetProtUtil. 00028 It is intended as an example and introduction to the INETPROTUTIL API's. 00029 Users should have a brief understanding of URIs and the different concepts 00030 associated with it, like, URLs and URI components.� 00031 */ 00032 00033 00034 // System includes 00035 // 00036 #include <uri8.h> 00037 #include <delimitedparser8.h> 00038 #include <inetprottextutils.h> 00039 #include <escapeutils.h> 00040 #include <e32cons.h> 00041 00042 00044 // CExampleInetProtUtil // 00046 00047 class CExampleInetProtUtil : public CBase 00048 { 00049 public : 00050 00051 CExampleInetProtUtil(); 00052 00053 virtual ~CExampleInetProtUtil(); 00054 00055 void ConstructL(); 00056 00057 static void NewL(); 00058 00059 //Create an URI 00060 void CreateUriL(); 00061 00062 //Modify URI components 00063 void ModifyUriComponentsL(); 00064 00065 //Resolve 00066 void ResolveUriL(); 00067 00068 //Parse the URI 00069 void ParseUriL(); 00070 00071 //Validate URI components 00072 void ValidateUriComponentsL(); 00073 00074 //Extract URI components 00075 void ExtractUriComponentsL(); 00076 00077 //Retrieve Filename from a given Uri 00078 void RetrieveFileNameL(); 00079 00080 //Add and Trim delimiters 00081 void ModifyDelimiterL(); 00082 00083 //Text Utilities 00084 void WhiteSpaceRemover(); 00085 00086 //Escape encode and decode 00087 void EscapeEncodeDecodeL(); 00088 00089 private: 00090 CConsoleBase* iConsole; 00091 00092 }; 00093 00094 00095 00097 // CExampleDelimiterModifier // 00099 00100 00101 class CExampleDelimiterModifier : public TDelimitedParserBase8 //, public CDelimitedDataBase8 00102 { 00103 public: // Methods 00104 00105 inline TBool CheckFrontDelimiter() const; 00106 00107 inline TBool CheckBackDelimiter() const; 00108 00109 CExampleDelimiterModifier(); 00110 00111 inline void Parse(const TDesC8& aData); 00112 00113 inline void SetDelimiter(TChar ); 00114 00115 }; 00116 00117 void CExampleDelimiterModifier::SetDelimiter(TChar aChar) 00118 { 00119 TDelimitedParserBase8::SetDelimiter(aChar); 00120 } 00121 00122 void CExampleDelimiterModifier::Parse(const TDesC8& aData) 00123 { 00124 TDelimitedParserBase8::Parse(aData); 00125 } 00126 00127 CExampleDelimiterModifier::CExampleDelimiterModifier() 00128 { 00129 00130 } 00131 00132 TBool CExampleDelimiterModifier::CheckFrontDelimiter() const 00133 { 00134 TBool frontDelimiter = FrontDelimiter(); 00135 return frontDelimiter; 00136 } 00137 00138 TBool CExampleDelimiterModifier::CheckBackDelimiter() const 00139 { 00140 TBool backDelimiter = BackDelimiter(); 00141 return backDelimiter; 00142 }