Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dummy__diskstatus__swppolicy_8cpp-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/AppFramework/ssmanager/policies/swp/dummy_diskstatus_swppolicy.cpp 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/AppFramework/ssmanager/policies/swp/dummy_diskstatus_swppolicy.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 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: A dummy disk status system wide property is provided to demonstrate</span>
       
    21 <a name="l00014"></a>00014 <span class="comment">// the System State Manager framework.</span>
       
    22 <a name="l00015"></a>00015 <span class="comment">//</span>
       
    23 <a name="l00016"></a>00016 
       
    24 <a name="l00036"></a>00036 <span class="preprocessor">#include &lt;ssm/ssmswppolicy.h&gt;</span>
       
    25 <a name="l00037"></a>00037 <span class="preprocessor">#include &lt;ssm/ssmcommandlist.h&gt;</span>
       
    26 <a name="l00038"></a>00038 <span class="preprocessor">#include &lt;ssm/ssmcommandlistresourcereader.h&gt;</span>
       
    27 <a name="l00039"></a>00039 <span class="preprocessor">#include "dummy_diskstatus_swppolicy.h"</span>
       
    28 <a name="l00040"></a>00040 <span class="preprocessor">#include "dummy_diskstatus_swppolicy.hrh"</span>
       
    29 <a name="l00041"></a>00041 
       
    30 <a name="l00045"></a>00045 _LIT(KCommandListPath, <span class="stringliteral">"z:\\private\\2000d75b\\ssmaeg\\swp_dummy_diskstatus\\"</span>);
       
    31 <a name="l00046"></a>00046 
       
    32 <a name="l00050"></a>00050 _LIT(KExamplePolicyPanic,<span class="stringliteral">"DummyDiskStatus"</span>);
       
    33 <a name="l00051"></a>00051 
       
    34 <a name="l00057"></a>00057 EXPORT_C MSsmSwpPolicy* CSsmDummyDiskStatusSwpPolicy::NewL()
       
    35 <a name="l00058"></a>00058         {
       
    36 <a name="l00059"></a>00059         CSsmDummyDiskStatusSwpPolicy* <span class="keyword">self</span> = <span class="keyword">new</span> (ELeave) CSsmDummyDiskStatusSwpPolicy;
       
    37 <a name="l00060"></a>00060         CleanupStack::PushL(<span class="keyword">self</span>);
       
    38 <a name="l00061"></a>00061         <span class="keyword">self</span>-&gt;ConstructL();
       
    39 <a name="l00062"></a>00062         CleanupStack::Pop(<span class="keyword">self</span>);
       
    40 <a name="l00063"></a>00063         <span class="keywordflow">return</span> <span class="keyword">self</span>;
       
    41 <a name="l00064"></a>00064         }
       
    42 <a name="l00065"></a>00065 
       
    43 <a name="l00069"></a>00069 CSsmDummyDiskStatusSwpPolicy::CSsmDummyDiskStatusSwpPolicy()
       
    44 <a name="l00070"></a>00070         {
       
    45 <a name="l00071"></a>00071         }
       
    46 <a name="l00072"></a>00072 
       
    47 <a name="l00076"></a>00076 CSsmDummyDiskStatusSwpPolicy::~CSsmDummyDiskStatusSwpPolicy()
       
    48 <a name="l00077"></a>00077         {
       
    49 <a name="l00078"></a>00078         iFs.Close();
       
    50 <a name="l00079"></a>00079         <span class="keyword">delete</span> iCommandListResourceReader;
       
    51 <a name="l00080"></a>00080         }
       
    52 <a name="l00081"></a>00081 
       
    53 <a name="l00085"></a>00085 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::ConstructL()
       
    54 <a name="l00086"></a>00086         {
       
    55 <a name="l00087"></a>00087         User::LeaveIfError(iFs.Connect());
       
    56 <a name="l00088"></a>00088         <span class="comment">// create resource reader</span>
       
    57 <a name="l00089"></a>00089         iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, KCommandListPath(), *<span class="keyword">this</span>);
       
    58 <a name="l00090"></a>00090         }
       
    59 <a name="l00091"></a>00091 
       
    60 <a name="l00095"></a>00095 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::Initialize(TRequestStatus&amp; aStatus)
       
    61 <a name="l00096"></a>00096         {
       
    62 <a name="l00097"></a>00097         __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
       
    63 <a name="l00098"></a>00098         <span class="comment">// initialise command list resource reader.</span>
       
    64 <a name="l00099"></a>00099         iCommandListResourceReader-&gt;Initialise(aStatus);
       
    65 <a name="l00100"></a>00100         }
       
    66 <a name="l00101"></a>00101 
       
    67 <a name="l00105"></a>00105 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::InitializeCancel()
       
    68 <a name="l00106"></a>00106         {
       
    69 <a name="l00107"></a>00107         __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
       
    70 <a name="l00108"></a>00108         iCommandListResourceReader-&gt;InitialiseCancel();
       
    71 <a name="l00109"></a>00109         }
       
    72 <a name="l00110"></a>00110 
       
    73 <a name="l00116"></a>00116 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::Release()
       
    74 <a name="l00117"></a>00117         {
       
    75 <a name="l00118"></a>00118         <span class="keyword">delete</span> <span class="keyword">this</span>;
       
    76 <a name="l00119"></a>00119         }
       
    77 <a name="l00120"></a>00120 
       
    78 <a name="l00129"></a>00129 MSsmSwpPolicy::TResponse CSsmDummyDiskStatusSwpPolicy::TransitionAllowed(<span class="keyword">const</span> TSsmSwp&amp; <span class="comment">/*aSwp*/</span>, <span class="keyword">const</span> RMessagePtr2&amp; <span class="comment">/*aMessage*/</span>)
       
    79 <a name="l00130"></a>00130         {
       
    80 <a name="l00131"></a>00131         TResponse response = EAllowed;
       
    81 <a name="l00132"></a>00132         <span class="keywordflow">return</span> response;
       
    82 <a name="l00133"></a>00133         }
       
    83 <a name="l00134"></a>00134 
       
    84 <a name="l00141"></a>00141 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::PrepareCommandList(<span class="keyword">const</span> TSsmSwp&amp; aSwp, TRequestStatus&amp; aStatus)
       
    85 <a name="l00142"></a>00142         {
       
    86 <a name="l00143"></a>00143         __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
       
    87 <a name="l00144"></a>00144         <span class="comment">// Build the command list for this value from a resource </span>
       
    88 <a name="l00145"></a>00145         iCommandListResourceReader-&gt;PrepareCommandList(aSwp.Value(), aSwp, aStatus);
       
    89 <a name="l00146"></a>00146         }
       
    90 <a name="l00147"></a>00147 
       
    91 <a name="l00152"></a>00152 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::PrepareCommandListCancel()
       
    92 <a name="l00153"></a>00153         {
       
    93 <a name="l00154"></a>00154         __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
       
    94 <a name="l00155"></a>00155         iCommandListResourceReader-&gt;PrepareCommandListCancel();
       
    95 <a name="l00156"></a>00156         }
       
    96 <a name="l00157"></a>00157 
       
    97 <a name="l00164"></a>00164 CSsmCommandList* CSsmDummyDiskStatusSwpPolicy::CommandList()
       
    98 <a name="l00165"></a>00165         {       
       
    99 <a name="l00166"></a>00166         __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
       
   100 <a name="l00167"></a>00167         <span class="keywordflow">return</span> iCommandListResourceReader-&gt;GetCommandList();
       
   101 <a name="l00168"></a>00168         }
       
   102 <a name="l00169"></a>00169 
       
   103 <a name="l00178"></a>00178 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::HandleCleReturnValue(<span class="keyword">const</span> TSsmSwp&amp; <span class="comment">/*aSwp*/</span>, TInt <span class="comment">/*aError*/</span>, TInt <span class="comment">/*aSeverity*/</span>, TRequestStatus&amp; aStatus)
       
   104 <a name="l00179"></a>00179         {
       
   105 <a name="l00180"></a>00180         <span class="comment">/*</span>
       
   106 <a name="l00181"></a>00181 <span class="comment">        This function is going to handle the return value. Even an reported error is treated as </span>
       
   107 <a name="l00182"></a>00182 <span class="comment">        a successful API request. The request always needs to be completed with KErrNone.</span>
       
   108 <a name="l00183"></a>00183 <span class="comment">        */</span>
       
   109 <a name="l00184"></a>00184         TRequestStatus* rs = &amp;aStatus;
       
   110 <a name="l00185"></a>00185         User::RequestComplete(rs, KErrNone);
       
   111 <a name="l00186"></a>00186         }
       
   112 <a name="l00187"></a>00187 
       
   113 <a name="l00192"></a>00192 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::HandleCleReturnValueCancel()
       
   114 <a name="l00193"></a>00193         {
       
   115 <a name="l00194"></a>00194         <span class="comment">// Nothing to do as HandleCleReturnValue always completes immediately</span>
       
   116 <a name="l00195"></a>00195         }
       
   117 <a name="l00196"></a>00196 
       
   118 <a name="l00207"></a>00207 TBool CSsmDummyDiskStatusSwpPolicy::ConditionalCommandAllowedL(CResourceFile&amp; <span class="comment">/*aResourceFile*/</span>, TInt <span class="comment">/*aResourceId*/</span>)
       
   119 <a name="l00208"></a>00208         {
       
   120 <a name="l00209"></a>00209         <span class="keywordflow">return</span> EFalse; <span class="comment">// command list does not contain commands that have conditions, so return EFalse</span>
       
   121 <a name="l00210"></a>00210         }
       
   122 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:32:54 2010 for TB10.1 Example Applications by&nbsp;
       
   123 <a href="http://www.doxygen.org/index.html">
       
   124 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
       
   125 </body>
       
   126 </html>