Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/httpexampleclient_8h-source.html
changeset 1 25a17d01db0c
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
       
     2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
       
     3 <title>TB10.1 Example Applications: examples/AppProts/exampleclient/httpexampleclient.h Source File</title>
       
     4 <link href="doxygen.css" rel="stylesheet" type="text/css">
       
     5 <link href="tabs.css" rel="stylesheet" type="text/css">
       
     6 </head><body>
       
     7 <!-- Generated by Doxygen 1.5.3 -->
       
     8 <h1>examples/AppProts/exampleclient/httpexampleclient.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
       
     9 <a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
       
    10 <a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
       
    11 <a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
       
    12 <a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
       
    13 <a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
       
    14 <a name="l00007"></a>00007 <span class="comment">//</span>
       
    15 <a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
       
    16 <a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
       
    17 <a name="l00010"></a>00010 <span class="comment">//</span>
       
    18 <a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
       
    19 <a name="l00012"></a>00012 <span class="comment">//</span>
       
    20 <a name="l00013"></a>00013 <span class="comment">// Description:</span>
       
    21 <a name="l00014"></a>00014 <span class="comment">// HTTPEXAMPLECLIENT is a simple text based http client. </span>
       
    22 <a name="l00015"></a>00015 <span class="comment">// It is intended as an example and introduction to the HTTP Client API's available in </span>
       
    23 <a name="l00016"></a>00016 <span class="comment">// The Symbian Platform Release 6.2</span>
       
    24 <a name="l00017"></a>00017 <span class="comment">// Users should have a brief understanding of HTTP and the different types of requests and responses you can get</span>
       
    25 <a name="l00018"></a>00018 <span class="comment">// from servers. They should also be familiar with setting up a communications database (cdbv2.dat) with suitable settings</span>
       
    26 <a name="l00019"></a>00019 <span class="comment">// for modems/NTRas and ISP's.</span>
       
    27 <a name="l00020"></a>00020 <span class="comment">//</span>
       
    28 <a name="l00021"></a>00021 
       
    29 <a name="l00022"></a>00022 
       
    30 <a name="l00023"></a>00023 
       
    31 <a name="l00024"></a>00024 <span class="preprocessor">#include &lt;e32test.h&gt;</span>
       
    32 <a name="l00025"></a>00025 <span class="preprocessor">#include &lt;f32file.h&gt;</span>
       
    33 <a name="l00026"></a>00026 <span class="preprocessor">#include &lt;http/mhttpauthenticationcallback.h&gt;</span>
       
    34 <a name="l00027"></a>00027 
       
    35 <a name="l00028"></a>00028 <span class="comment">// Maximum size of buffer to hold content-type data</span>
       
    36 <a name="l00029"></a>00029 <span class="comment">//</span>
       
    37 <a name="l00030"></a>00030 <span class="keyword">const</span> TInt KMaxContentTypeSize = 64;
       
    38 <a name="l00031"></a>00031 
       
    39 <a name="l00032"></a>00032 
       
    40 <a name="l00033"></a>00033 <span class="comment">//</span>
       
    41 <a name="l00034"></a>00034 <span class="comment">// Definition of CHttpClient</span>
       
    42 <a name="l00035"></a>00035 <span class="comment">//</span>
       
    43 <a name="l00036"></a>00036 <span class="keyword">class </span><a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>;
       
    44 <a name="l00037"></a>00037 <span class="keyword">class </span><a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>;
       
    45 <a name="l00038"></a>00038 
       
    46 <a name="l00039"></a>00039 
       
    47 <a name="l00048"></a><a class="code" href="class_c_http_client.html">00048</a> <span class="keyword">class </span><a class="code" href="class_c_http_client.html">CHttpClient</a> : <span class="keyword">public</span> CBase, <span class="keyword">public</span> MHTTPDataSupplier, 
       
    48 <a name="l00049"></a>00049                                         <span class="keyword">public</span> MHTTPAuthenticationCallback
       
    49 <a name="l00050"></a>00050         {
       
    50 <a name="l00051"></a>00051 <span class="keyword">public</span>:
       
    51 <a name="l00052"></a>00052         <span class="keyword">virtual</span> <a class="code" href="class_c_http_client.html#33c02fb95218215e3289f560713597ce">~CHttpClient</a>();
       
    52 <a name="l00053"></a>00053         <span class="keyword">static</span> <a class="code" href="class_c_http_client.html">CHttpClient</a>* <a class="code" href="class_c_http_client.html#c629afd9dba45056a81a58be2a94a5c5">NewLC</a>();
       
    53 <a name="l00054"></a>00054         <span class="keyword">static</span> <a class="code" href="class_c_http_client.html">CHttpClient</a>* <a class="code" href="class_c_http_client.html#f62107c868da9904c92ffe6b726dc222">NewL</a>();
       
    54 <a name="l00055"></a>00055         <span class="keywordtype">void</span> <a class="code" href="class_c_http_client.html#0f39c19552deec488b5fa98fa9f9d929">StartClientL</a>();
       
    55 <a name="l00056"></a>00056 <span class="comment">// methods inherited from MHTTPDataSupplier</span>
       
    56 <a name="l00057"></a>00057         <span class="keyword">virtual</span> TBool <a class="code" href="class_c_http_client.html#a296adbd23a0df0c7aacdee6d44b25f0">GetNextDataPart</a>(TPtrC8&amp; aDataPart);
       
    57 <a name="l00058"></a>00058         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_http_client.html#c9ebeda59a1c72795f56b84c18da6ae4">ReleaseData</a>();
       
    58 <a name="l00059"></a>00059         <span class="keyword">virtual</span> TInt <a class="code" href="class_c_http_client.html#21f73ccc81e3025a99fc56b3d5cb3d1d">OverallDataSize</a>();
       
    59 <a name="l00060"></a>00060         <span class="keyword">virtual</span> TInt <a class="code" href="class_c_http_client.html#58dcb78f4fd957522ee44b42b721b021">Reset</a>();
       
    60 <a name="l00061"></a>00061 
       
    61 <a name="l00062"></a>00062 <span class="comment">// methods inherited from MHTTPAuthenticationCallback</span>
       
    62 <a name="l00063"></a>00063         <span class="keyword">virtual</span> TBool <a class="code" href="class_c_http_client.html#e154d7b4e42475225582afc5bde9c53a">GetCredentialsL</a>(<span class="keyword">const</span> TUriC8&amp; aURI, RString aRealm, 
       
    63 <a name="l00064"></a>00064                                                                  RStringF aAuthenticationType,
       
    64 <a name="l00065"></a>00065                                                                  RString&amp; aUsername, 
       
    65 <a name="l00066"></a>00066                                                                  RString&amp; aPassword);
       
    66 <a name="l00067"></a>00067 
       
    67 <a name="l00068"></a>00068 <span class="keyword">protected</span>:
       
    68 <a name="l00069"></a>00069         <a class="code" href="class_c_http_client.html#845a9f4ee99a401b8e5f719af489e970">CHttpClient</a>();
       
    69 <a name="l00070"></a>00070         <span class="keywordtype">void</span> <a class="code" href="class_c_http_client.html#38d577b3c8c8a3cd740e1b9be9224b91">ConstructL</a>();
       
    70 <a name="l00071"></a>00071 <span class="keyword">private</span>:
       
    71 <a name="l00072"></a>00072 
       
    72 <a name="l00073"></a>00073         <span class="keyword">enum</span> TMenuItems
       
    73 <a name="l00074"></a>00074                 {
       
    74 <a name="l00075"></a>00075                 EGet,
       
    75 <a name="l00076"></a>00076                 EPost,
       
    76 <a name="l00077"></a>00077                 EHead,
       
    77 <a name="l00078"></a>00078                 ETrace,
       
    78 <a name="l00079"></a>00079                 EToggleVerbosity,
       
    79 <a name="l00080"></a>00080                 EQuit
       
    80 <a name="l00081"></a>00081                 };
       
    81 <a name="l00082"></a>00082 
       
    82 <a name="l00083"></a>00083         <span class="keywordtype">void</span> ResetTimeElapsed();
       
    83 <a name="l00084"></a>00084         <span class="keywordtype">void</span> DisplayTimeElapsed();
       
    84 <a name="l00085"></a>00085         <span class="comment">//</span>
       
    85 <a name="l00086"></a>00086         <span class="keywordtype">void</span> InvokeHttpMethodL(<span class="keyword">const</span> TDesC8&amp; aUri, RStringF aMethod);
       
    86 <a name="l00087"></a>00087         <span class="keywordtype">void</span> SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, <span class="keyword">const</span> TDesC8&amp; aHdrValue);
       
    87 <a name="l00088"></a>00088         <span class="keywordtype">void</span> GetRequestBodyL(RStringF&amp; aMethod);
       
    88 <a name="l00089"></a>00089         <span class="keywordtype">void</span> GetPostBodyManuallyL();
       
    89 <a name="l00090"></a>00090 
       
    90 <a name="l00091"></a>00091 <span class="keyword">private</span>:
       
    91 <a name="l00092"></a>00092         TTime iLastTimeStamp;
       
    92 <a name="l00093"></a>00093         TInt iDataChunkCount;
       
    93 <a name="l00094"></a>00094         RHTTPSession iSess;
       
    94 <a name="l00095"></a>00095         RHTTPTransaction iTrans;
       
    95 <a name="l00096"></a>00096         TBool iHasARequestBody;
       
    96 <a name="l00097"></a>00097         RFs iFileServ;
       
    97 <a name="l00098"></a>00098         RFile iReqBodyFile;
       
    98 <a name="l00099"></a>00099         TFileName iReqBodyFileName;
       
    99 <a name="l00100"></a>00100         TParse iParsedFileName;
       
   100 <a name="l00101"></a>00101         TBuf&lt;KMaxContentTypeSize&gt; iReqBodyContentType;
       
   101 <a name="l00102"></a>00102         <a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>* iTransObs;
       
   102 <a name="l00103"></a>00103         HBufC8* iReqBodySubmitBuffer;
       
   103 <a name="l00104"></a>00104         TPtr8 iReqBodySubmitBufferPtr;
       
   104 <a name="l00105"></a>00105         CHTTPFormEncoder* iFormEncoder;         <span class="comment">// used for manual post submissions</span>
       
   105 <a name="l00106"></a>00106         TBool iManualPost;
       
   106 <a name="l00107"></a>00107         <a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>* iUtils;
       
   107 <a name="l00108"></a>00108         };
       
   108 <a name="l00109"></a>00109 
       
   109 <a name="l00110"></a>00110 
       
   110 <a name="l00111"></a>00111 
       
   111 <a name="l00114"></a><a class="code" href="class_c_http_event_handler.html">00114</a> <span class="keyword">class </span><a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a> : <span class="keyword">public</span> CBase, <span class="keyword">public</span> MHTTPTransactionCallback
       
   112 <a name="l00115"></a>00115         {
       
   113 <a name="l00116"></a>00116 <span class="keyword">public</span>:
       
   114 <a name="l00117"></a>00117         <span class="keyword">virtual</span> <a class="code" href="class_c_http_event_handler.html#f0c5dbd7a9db37f99a303ccd70d07f2b">~CHttpEventHandler</a>();
       
   115 <a name="l00118"></a>00118         <span class="keyword">static</span> <a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>* <a class="code" href="class_c_http_event_handler.html#4e22bb739a6ee13185d22dda382c2fb1">NewLC</a>(<a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>&amp; aUtils);
       
   116 <a name="l00119"></a>00119         <span class="keyword">static</span> <a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>* <a class="code" href="class_c_http_event_handler.html#9f822eb7d70103589216653878a6a3fc">NewL</a>(<a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>&amp; aUtils);
       
   117 <a name="l00120"></a>00120         <span class="keywordtype">void</span> <a class="code" href="class_c_http_event_handler.html#976804deb934b33ed62a3f2245ce5019">SetVerbose</a>(TBool aVerbose);
       
   118 <a name="l00121"></a>00121         TBool <a class="code" href="class_c_http_event_handler.html#508fdfdc104001adf4a57a6105d81b27">Verbose</a>() <span class="keyword">const</span>;
       
   119 <a name="l00122"></a>00122         <span class="comment">//</span>
       
   120 <a name="l00123"></a>00123         <span class="comment">// methods from MHTTPTransactionCallback</span>
       
   121 <a name="l00124"></a>00124         <span class="comment">//</span>
       
   122 <a name="l00125"></a>00125         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_http_event_handler.html#4834f458326a10126d8b0b149394e35e">MHFRunL</a>(RHTTPTransaction aTransaction, <span class="keyword">const</span> THTTPEvent&amp; aEvent);
       
   123 <a name="l00126"></a>00126         <span class="keyword">virtual</span> TInt <a class="code" href="class_c_http_event_handler.html#5ea099b761ad15cf308ddc939afea3d4">MHFRunError</a>(TInt aError, RHTTPTransaction aTransaction, <span class="keyword">const</span> THTTPEvent&amp; aEvent);
       
   124 <a name="l00127"></a>00127 
       
   125 <a name="l00128"></a>00128 <span class="keyword">protected</span>:
       
   126 <a name="l00129"></a>00129         <a class="code" href="class_c_http_event_handler.html#321925f9d78dcecfa990fe56e9aaf7f9">CHttpEventHandler</a>(<a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>&amp; aUtils);
       
   127 <a name="l00130"></a>00130         <span class="keywordtype">void</span> <a class="code" href="class_c_http_event_handler.html#9bab82a1ec81a955cee1387efd8bde1e">ConstructL</a>();
       
   128 <a name="l00131"></a>00131 <span class="keyword">private</span>:
       
   129 <a name="l00132"></a>00132         <span class="keywordtype">void</span> DumpRespHeadersL(RHTTPTransaction&amp; aTrans);
       
   130 <a name="l00133"></a>00133         <span class="keywordtype">void</span> DumpRespBody(RHTTPTransaction&amp; aTrans);
       
   131 <a name="l00134"></a>00134         <span class="keywordtype">void</span> DumpIt(<span class="keyword">const</span> TDesC8&amp; aData);
       
   132 <a name="l00135"></a>00135         TBool iVerbose;
       
   133 <a name="l00136"></a>00136         TBool iSavingResponseBody;
       
   134 <a name="l00137"></a>00137         RFs iFileServ;
       
   135 <a name="l00138"></a>00138         RFile iRespBodyFile;
       
   136 <a name="l00139"></a>00139         TFileName iRespBodyFileName;
       
   137 <a name="l00140"></a>00140         TParse iParsedFileName;
       
   138 <a name="l00141"></a>00141         MHTTPDataSupplier* iRespBody;
       
   139 <a name="l00142"></a>00142         <a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>&amp; iUtils; <span class="comment">// not owned</span>
       
   140 <a name="l00143"></a>00143         };
       
   141 <a name="l00144"></a>00144 
       
   142 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:32:55 2010 for TB10.1 Example Applications by&nbsp;
       
   143 <a href="http://www.doxygen.org/index.html">
       
   144 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
       
   145 </body>
       
   146 </html>