Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/secureserverccountsession_8cpp_source.html
changeset 6 43e37759235e
equal deleted inserted replaced
5:f345bda72bc4 6:43e37759235e
       
     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
     2 <html xmlns="http://www.w3.org/1999/xhtml">
       
     3 <head>
       
     4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
       
     5 <title>TB9.2 Example Applications: examples/Base/IPC/secureserver/secureserverccountsession.cpp Source File</title>
       
     6 <link href="tabs.css" rel="stylesheet" type="text/css"/>
       
     7 <link href="doxygen.css" rel="stylesheet" type="text/css"/>
       
     8 </head>
       
     9 <body>
       
    10 <!-- Generated by Doxygen 1.6.2 -->
       
    11 <h1>examples/Base/IPC/secureserver/secureserverccountsession.cpp</h1><a href="secureserverccountsession_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
       
    12 <a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
       
    13 <a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
       
    14 <a name="l00004"></a>00004 <span class="comment">// under the terms of &quot;Eclipse Public License v1.0&quot;</span>
       
    15 <a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
       
    16 <a name="l00006"></a>00006 <span class="comment">// at the URL &quot;http://www.eclipse.org/legal/epl-v10.html&quot;.</span>
       
    17 <a name="l00007"></a>00007 <span class="comment">//</span>
       
    18 <a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
       
    19 <a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
       
    20 <a name="l00010"></a>00010 <span class="comment">//</span>
       
    21 <a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
       
    22 <a name="l00012"></a>00012 <span class="comment">//</span>
       
    23 <a name="l00013"></a>00013 <span class="comment">// Description:</span>
       
    24 <a name="l00014"></a>00014 <span class="comment">// Contains the implementation of functions described in the CSecureServerSession class.</span>
       
    25 <a name="l00015"></a>00015 <span class="comment">//</span>
       
    26 <a name="l00016"></a>00016 
       
    27 <a name="l00017"></a>00017 
       
    28 <a name="l00018"></a>00018 
       
    29 <a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="secureclientandserver_8h.html">secureclientandserver.h</a>&quot;</span>
       
    30 <a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="secureserver_8h.html">secureserver.h</a>&quot;</span>
       
    31 <a name="l00024"></a>00024 
       
    32 <a name="l00028"></a><a class="code" href="class_c_secure_server_session.html#ad02090d242cef53516c5680c97843b68">00028</a> <a class="code" href="class_c_secure_server_session.html#ad02090d242cef53516c5680c97843b68">CSecureServerSession::CSecureServerSession</a>()
       
    33 <a name="l00029"></a>00029         {
       
    34 <a name="l00030"></a>00030         }
       
    35 <a name="l00031"></a>00031 
       
    36 <a name="l00035"></a><a class="code" href="class_c_secure_server_session.html#ab9502afe61e2be236b5602af41ff234d">00035</a> <span class="keywordtype">void</span> <a class="code" href="class_c_secure_server_session.html#ab9502afe61e2be236b5602af41ff234d">CSecureServerSession::CreateL</a>()
       
    37 <a name="l00036"></a>00036         {
       
    38 <a name="l00037"></a>00037         iCountersObjectIndex = CObjectIx::NewL();
       
    39 <a name="l00038"></a>00038         iContainer=((<a class="code" href="class_c_secure_server.html">CSecureServer</a>*)Server())-&gt;NewContainerL();
       
    40 <a name="l00039"></a>00039         }
       
    41 <a name="l00040"></a>00040 
       
    42 <a name="l00045"></a><a class="code" href="class_c_secure_server_session.html#a5921d8c81a8a2e3c01f73a5ea23cc194">00045</a> <span class="keywordtype">void</span> <a class="code" href="class_c_secure_server_session.html#a5921d8c81a8a2e3c01f73a5ea23cc194">CSecureServerSession::CloseSession</a>()
       
    43 <a name="l00046"></a>00046         {
       
    44 <a name="l00047"></a>00047         <span class="keyword">delete</span> iCountersObjectIndex;
       
    45 <a name="l00048"></a>00048         iCountersObjectIndex = NULL;
       
    46 <a name="l00049"></a>00049         ((<a class="code" href="class_c_secure_server.html">CSecureServer</a>*)Server())-&gt;RemoveContainer(iContainer);
       
    47 <a name="l00050"></a>00050         iContainer = NULL;
       
    48 <a name="l00051"></a>00051         }
       
    49 <a name="l00052"></a>00052 
       
    50 <a name="l00059"></a><a class="code" href="class_c_secure_server_session.html#a478b6424b1ab3dde2b874847164650f0">00059</a> <a class="code" href="class_c_secure_server_sub_session.html">CSecureServerSubSession</a>* <a class="code" href="class_c_secure_server_session.html#a478b6424b1ab3dde2b874847164650f0">CSecureServerSession::CounterFromHandle</a>(<span class="keyword">const</span> RMessage2&amp; aMessage,TInt aHandle)
       
    51 <a name="l00060"></a>00060         {
       
    52 <a name="l00061"></a>00061         <a class="code" href="class_c_secure_server_sub_session.html">CSecureServerSubSession</a>* counter = (<a class="code" href="class_c_secure_server_sub_session.html">CSecureServerSubSession</a>*)iCountersObjectIndex-&gt;At(aHandle);
       
    53 <a name="l00062"></a>00062         <span class="keywordflow">if</span> (counter == NULL)
       
    54 <a name="l00063"></a>00063                 {
       
    55 <a name="l00064"></a>00064                 <a class="code" href="class_c_secure_server_session.html#a05f576bc35402465caafc65ad0593e8b">PanicClient</a>(aMessage, <a class="code" href="secureserver_8h.html#a091a5ad2956fb84c4470a59010a0d4efaeebad163989c978b8edd91b6893411c0">EBadSubsessionHandle</a>);
       
    56 <a name="l00065"></a>00065                 }
       
    57 <a name="l00066"></a>00066         <span class="keywordflow">return</span> counter;
       
    58 <a name="l00067"></a>00067         }
       
    59 <a name="l00068"></a>00068 
       
    60 <a name="l00077"></a><a class="code" href="class_c_secure_server_session.html#a1ef8c62f2085e8e860a9d4333a354a4c">00077</a> <span class="keywordtype">void</span> <a class="code" href="class_c_secure_server_session.html#a1ef8c62f2085e8e860a9d4333a354a4c">CSecureServerSession::ServiceL</a>(<span class="keyword">const</span> RMessage2&amp; aMessage)
       
    61 <a name="l00078"></a>00078         {
       
    62 <a name="l00079"></a>00079         <span class="comment">// Check if the message is intended to the parent session.</span>
       
    63 <a name="l00080"></a>00080         <span class="keywordflow">switch</span> (aMessage.Function())
       
    64 <a name="l00081"></a>00081                 {
       
    65 <a name="l00082"></a>00082         <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2aeeea637ffeed72685729b2eb5c0a1d06">ESecureServerCreateSubSession</a>:
       
    66 <a name="l00083"></a>00083                 <a class="code" href="class_c_secure_server_session.html#a7f1276a074d2f92b29b924903a02f6bf">NewCounterL</a>(aMessage);
       
    67 <a name="l00084"></a>00084                 aMessage.Complete(KErrNone);
       
    68 <a name="l00085"></a>00085                 <span class="keywordflow">return</span>;
       
    69 <a name="l00086"></a>00086         <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a8e272085a7b510b91c0e210e46eb687e">ESecureServerCloseSession</a>:
       
    70 <a name="l00087"></a>00087                 <a class="code" href="class_c_secure_server_session.html#a5921d8c81a8a2e3c01f73a5ea23cc194">CloseSession</a>();
       
    71 <a name="l00088"></a>00088                 aMessage.Complete(KErrNone);
       
    72 <a name="l00089"></a>00089                 <span class="keywordflow">return</span>;
       
    73 <a name="l00090"></a>00090         <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a7fc92e555feb4e8e8cacd2ea4508b4ed">ESecureServerResourceCount</a>:
       
    74 <a name="l00091"></a>00091                 <a class="code" href="class_c_secure_server_session.html#a4046b0fbcbf22d3aab8b2877cd554395">NumResourcesL</a>(aMessage);
       
    75 <a name="l00092"></a>00092                 aMessage.Complete(KErrNone);
       
    76 <a name="l00093"></a>00093                 <span class="keywordflow">return</span>;
       
    77 <a name="l00094"></a>00094                 }
       
    78 <a name="l00095"></a>00095         <span class="comment">// Check if the message is intended to a sub session.</span>
       
    79 <a name="l00096"></a>00096         <a class="code" href="class_c_secure_server_sub_session.html">CSecureServerSubSession</a>* counter=<a class="code" href="class_c_secure_server_session.html#a478b6424b1ab3dde2b874847164650f0">CounterFromHandle</a>(aMessage,aMessage.Int3());
       
    80 <a name="l00097"></a>00097         <span class="keywordflow">switch</span> (aMessage.Function())
       
    81 <a name="l00098"></a>00098                 {
       
    82 <a name="l00099"></a>00099                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a340b8bb36e8a83dedc23b33ad454cc41">ESecureServerInitSubSession</a>:
       
    83 <a name="l00100"></a>00100                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#a97ed872aae87b8cb76d6fa101a52303f">SetFromStringL</a>(aMessage);
       
    84 <a name="l00101"></a>00101                         aMessage.Complete(KErrNone);
       
    85 <a name="l00102"></a>00102                         <span class="keywordflow">return</span>;
       
    86 <a name="l00103"></a>00103                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a019d5723fe668d1d7092919022bb7cd8">ESecureServerCloseSubSession</a>:
       
    87 <a name="l00104"></a>00104                         <a class="code" href="class_c_secure_server_session.html#a879e7d197ab62104e2187e98ed2724b4">DeleteCounter</a>(aMessage.Int3());
       
    88 <a name="l00105"></a>00105                         aMessage.Complete(KErrNone);
       
    89 <a name="l00106"></a>00106                         <span class="keywordflow">return</span>;
       
    90 <a name="l00107"></a>00107                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a1b3935c0f5f79f45a27de1fa32654e17">ESecureServerIncrease</a>:
       
    91 <a name="l00108"></a>00108                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#a388299f02880acd81521b12ea68fb6ba">Increase</a>();
       
    92 <a name="l00109"></a>00109                         aMessage.Complete(KErrNone);
       
    93 <a name="l00110"></a>00110                         <span class="keywordflow">return</span>;
       
    94 <a name="l00111"></a>00111                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a9c27793f5b6b3beb6aad11d0bf953144">ESecureServerIncreaseBy</a>:
       
    95 <a name="l00112"></a>00112                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#a2de0131772c586accbd61fb2ed329647">IncreaseBy</a>(aMessage);
       
    96 <a name="l00113"></a>00113                         aMessage.Complete(KErrNone);
       
    97 <a name="l00114"></a>00114                         <span class="keywordflow">return</span>;
       
    98 <a name="l00115"></a>00115                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a42948fe36fdaab2a2d9a4328ea3eedec">ESecureServerDecrease</a>:
       
    99 <a name="l00116"></a>00116                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#ac9e4188e16b286e4ed6cbd1cce24a42e">Decrease</a>();
       
   100 <a name="l00117"></a>00117                         aMessage.Complete(KErrNone);
       
   101 <a name="l00118"></a>00118                         <span class="keywordflow">return</span>;
       
   102 <a name="l00119"></a>00119                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a0bcce01e7f822786412221374e7a8b76">ESecureServerDecreaseBy</a>:
       
   103 <a name="l00120"></a>00120                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#aaee3504a264b7c7136660201bf143a6d">DecreaseBy</a>(aMessage);
       
   104 <a name="l00121"></a>00121                         aMessage.Complete(KErrNone);
       
   105 <a name="l00122"></a>00122                         <span class="keywordflow">return</span>;
       
   106 <a name="l00123"></a>00123                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2aa9d1e980d9ed0a23782b98761d7e57d7">ESecureServerReset</a>:
       
   107 <a name="l00124"></a>00124                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#a5ffe759ade87ebaeea7e2399d65b07e5">Reset</a>();
       
   108 <a name="l00125"></a>00125                         aMessage.Complete(KErrNone);
       
   109 <a name="l00126"></a>00126                         <span class="keywordflow">return</span>;
       
   110 <a name="l00127"></a>00127                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2aac8031c2e6141daa00372a90dbea0686">ESecureServerValue</a>:
       
   111 <a name="l00128"></a>00128                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#a3edaea36ff8bb03d5814b4aa245b761a">CounterValueL</a>(aMessage);
       
   112 <a name="l00129"></a>00129                         aMessage.Complete(KErrNone);
       
   113 <a name="l00130"></a>00130                         <span class="keywordflow">return</span>;
       
   114 <a name="l00131"></a>00131                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2a1c7338d8bb93ce1b82088d1282516d3d">ESecureServerSaveCounter</a>:
       
   115 <a name="l00132"></a>00132                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#a5a58cd7db75221072f5ef4251fe75a82">SaveCounterValueL</a>();
       
   116 <a name="l00133"></a>00133                         aMessage.Complete(KErrNone);
       
   117 <a name="l00134"></a>00134                         <span class="keywordflow">return</span>;
       
   118 <a name="l00135"></a>00135                 <span class="keywordflow">case</span> <a class="code" href="secureclientandserver_8h.html#a19a3f57ac2d7b8518f6682573ac637c2af1d352024cd4a379c9dd9406152b9592">ESecureServerSetCounterFromFile</a>:
       
   119 <a name="l00136"></a>00136                         counter-&gt;<a class="code" href="class_c_secure_server_sub_session.html#a234065b99df276eca6097ab3d89cc81a">SetCounterValueFromFileL</a>();
       
   120 <a name="l00137"></a>00137                         aMessage.Complete(KErrNone);
       
   121 <a name="l00138"></a>00138                         <span class="keywordflow">return</span>;
       
   122 <a name="l00139"></a>00139                 <span class="keywordflow">default</span>:
       
   123 <a name="l00140"></a>00140                         <a class="code" href="class_c_secure_server_session.html#a05f576bc35402465caafc65ad0593e8b">PanicClient</a>(aMessage,<a class="code" href="secureserver_8h.html#a091a5ad2956fb84c4470a59010a0d4efaeef6b7f2a8413e6863e2136b93228c3a">EBadRequest</a>);
       
   124 <a name="l00141"></a>00141                         <span class="keywordflow">return</span>;
       
   125 <a name="l00142"></a>00142                 }
       
   126 <a name="l00143"></a>00143         }
       
   127 <a name="l00144"></a>00144 
       
   128 <a name="l00149"></a><a class="code" href="class_c_secure_server_session.html#a7f1276a074d2f92b29b924903a02f6bf">00149</a> <span class="keywordtype">void</span> <a class="code" href="class_c_secure_server_session.html#a7f1276a074d2f92b29b924903a02f6bf">CSecureServerSession::NewCounterL</a>(<span class="keyword">const</span> RMessage2&amp; aMessage)
       
   129 <a name="l00150"></a>00150         {
       
   130 <a name="l00151"></a>00151         <span class="comment">// Create a sub session object and add it to the container index.</span>
       
   131 <a name="l00152"></a>00152         <a class="code" href="class_c_secure_server_sub_session.html">CSecureServerSubSession</a>* counter = <span class="keyword">new</span> (ELeave) <a class="code" href="class_c_secure_server_sub_session.html">CSecureServerSubSession</a>(<span class="keyword">this</span>);
       
   132 <a name="l00153"></a>00153         iContainer-&gt;AddL(counter);
       
   133 <a name="l00154"></a>00154 
       
   134 <a name="l00155"></a>00155         TInt handle=iCountersObjectIndex-&gt;AddL(counter);
       
   135 <a name="l00156"></a>00156         TPckgBuf&lt;TInt&gt; handlePckg(handle);
       
   136 <a name="l00157"></a>00157         TRAPD(res,aMessage.WriteL(3,handlePckg));
       
   137 <a name="l00158"></a>00158         <span class="keywordflow">if</span> (res!=KErrNone)
       
   138 <a name="l00159"></a>00159                 {
       
   139 <a name="l00160"></a>00160                 iCountersObjectIndex-&gt;Remove(handle);
       
   140 <a name="l00161"></a>00161                 <a class="code" href="class_c_secure_server_session.html#a05f576bc35402465caafc65ad0593e8b">PanicClient</a>(aMessage,<a class="code" href="secureserver_8h.html#a091a5ad2956fb84c4470a59010a0d4efa59f7e1b1a0e300077050b023b97ebcfb">EDescriptorNonNumeric</a>);
       
   141 <a name="l00162"></a>00162                 <span class="keywordflow">return</span>;
       
   142 <a name="l00163"></a>00163                 }
       
   143 <a name="l00164"></a>00164         <span class="comment">// For every new sub session created, increase the resource count.</span>
       
   144 <a name="l00165"></a>00165         iResourceCount++;
       
   145 <a name="l00166"></a>00166         }
       
   146 <a name="l00167"></a>00167 
       
   147 <a name="l00172"></a><a class="code" href="class_c_secure_server_session.html#a879e7d197ab62104e2187e98ed2724b4">00172</a> <span class="keywordtype">void</span> <a class="code" href="class_c_secure_server_session.html#a879e7d197ab62104e2187e98ed2724b4">CSecureServerSession::DeleteCounter</a>(TInt aHandle)
       
   148 <a name="l00173"></a>00173         {
       
   149 <a name="l00174"></a>00174         iCountersObjectIndex-&gt;Remove(aHandle);
       
   150 <a name="l00175"></a>00175         <span class="comment">// For every new sub session deleted, decrease the resource count.</span>
       
   151 <a name="l00176"></a>00176         iResourceCount --;
       
   152 <a name="l00177"></a>00177         }
       
   153 <a name="l00178"></a>00178 
       
   154 <a name="l00183"></a><a class="code" href="class_c_secure_server_session.html#a0307c128da103c5fa6b9f5b382f90e3c">00183</a> TInt <a class="code" href="class_c_secure_server_session.html#a0307c128da103c5fa6b9f5b382f90e3c">CSecureServerSession::CountResources</a>()
       
   155 <a name="l00184"></a>00184         {
       
   156 <a name="l00185"></a>00185         <span class="keywordflow">return</span> iResourceCount;
       
   157 <a name="l00186"></a>00186         }
       
   158 <a name="l00187"></a>00187 
       
   159 <a name="l00192"></a><a class="code" href="class_c_secure_server_session.html#a4046b0fbcbf22d3aab8b2877cd554395">00192</a> <span class="keywordtype">void</span> <a class="code" href="class_c_secure_server_session.html#a4046b0fbcbf22d3aab8b2877cd554395">CSecureServerSession::NumResourcesL</a>(<span class="keyword">const</span> RMessage2&amp; aMessage)
       
   160 <a name="l00193"></a>00193         {
       
   161 <a name="l00194"></a>00194         TPckgBuf&lt;TInt&gt; resourcesPckg(iResourceCount);
       
   162 <a name="l00195"></a>00195         aMessage.WriteL(0,resourcesPckg);
       
   163 <a name="l00196"></a>00196         }
       
   164 <a name="l00197"></a>00197 
       
   165 <a name="l00203"></a><a class="code" href="class_c_secure_server_session.html#a05f576bc35402465caafc65ad0593e8b">00203</a> <span class="keywordtype">void</span> <a class="code" href="class_c_secure_server_session.html#a05f576bc35402465caafc65ad0593e8b">CSecureServerSession::PanicClient</a>(<span class="keyword">const</span> RMessage2&amp; aMessage,TInt aPanic)<span class="keyword"> const</span>
       
   166 <a name="l00204"></a>00204 <span class="keyword">        </span>{
       
   167 <a name="l00205"></a>00205         <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtServer,<span class="stringliteral">&quot;SecureServer&quot;</span>);
       
   168 <a name="l00206"></a>00206         aMessage.Panic(KTxtServer,aPanic);
       
   169 <a name="l00207"></a>00207         }
       
   170 </pre></div></div>
       
   171 <hr size="1"/><address style="text-align: right;"><small>Generated by&nbsp;
       
   172 <a href="http://www.doxygen.org/index.html">
       
   173 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address>
       
   174 </body>
       
   175 </html>