Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dummy__diskstatus__swppolicy_8cpp-source.html
week 10 bug fix submission: Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>TB10.1 Example Applications: examples/AppFramework/ssmanager/policies/swp/dummy_diskstatus_swppolicy.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<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>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
<a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
<a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
<a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
<a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// Description: A dummy disk status system wide property is provided to demonstrate</span>
<a name="l00014"></a>00014 <span class="comment">// the System State Manager framework.</span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016
<a name="l00036"></a>00036 <span class="preprocessor">#include <ssm/ssmswppolicy.h></span>
<a name="l00037"></a>00037 <span class="preprocessor">#include <ssm/ssmcommandlist.h></span>
<a name="l00038"></a>00038 <span class="preprocessor">#include <ssm/ssmcommandlistresourcereader.h></span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "dummy_diskstatus_swppolicy.h"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "dummy_diskstatus_swppolicy.hrh"</span>
<a name="l00041"></a>00041
<a name="l00045"></a>00045 _LIT(KCommandListPath, <span class="stringliteral">"z:\\private\\2000d75b\\ssmaeg\\swp_dummy_diskstatus\\"</span>);
<a name="l00046"></a>00046
<a name="l00050"></a>00050 _LIT(KExamplePolicyPanic,<span class="stringliteral">"DummyDiskStatus"</span>);
<a name="l00051"></a>00051
<a name="l00057"></a>00057 EXPORT_C MSsmSwpPolicy* CSsmDummyDiskStatusSwpPolicy::NewL()
<a name="l00058"></a>00058 {
<a name="l00059"></a>00059 CSsmDummyDiskStatusSwpPolicy* <span class="keyword">self</span> = <span class="keyword">new</span> (ELeave) CSsmDummyDiskStatusSwpPolicy;
<a name="l00060"></a>00060 CleanupStack::PushL(<span class="keyword">self</span>);
<a name="l00061"></a>00061 <span class="keyword">self</span>->ConstructL();
<a name="l00062"></a>00062 CleanupStack::Pop(<span class="keyword">self</span>);
<a name="l00063"></a>00063 <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065
<a name="l00069"></a>00069 CSsmDummyDiskStatusSwpPolicy::CSsmDummyDiskStatusSwpPolicy()
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072
<a name="l00076"></a>00076 CSsmDummyDiskStatusSwpPolicy::~CSsmDummyDiskStatusSwpPolicy()
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078 iFs.Close();
<a name="l00079"></a>00079 <span class="keyword">delete</span> iCommandListResourceReader;
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081
<a name="l00085"></a>00085 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::ConstructL()
<a name="l00086"></a>00086 {
<a name="l00087"></a>00087 User::LeaveIfError(iFs.Connect());
<a name="l00088"></a>00088 <span class="comment">// create resource reader</span>
<a name="l00089"></a>00089 iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, KCommandListPath(), *<span class="keyword">this</span>);
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091
<a name="l00095"></a>00095 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::Initialize(TRequestStatus& aStatus)
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
<a name="l00098"></a>00098 <span class="comment">// initialise command list resource reader.</span>
<a name="l00099"></a>00099 iCommandListResourceReader->Initialise(aStatus);
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101
<a name="l00105"></a>00105 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::InitializeCancel()
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
<a name="l00108"></a>00108 iCommandListResourceReader->InitialiseCancel();
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110
<a name="l00116"></a>00116 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::Release()
<a name="l00117"></a>00117 {
<a name="l00118"></a>00118 <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120
<a name="l00129"></a>00129 MSsmSwpPolicy::TResponse CSsmDummyDiskStatusSwpPolicy::TransitionAllowed(<span class="keyword">const</span> TSsmSwp& <span class="comment">/*aSwp*/</span>, <span class="keyword">const</span> RMessagePtr2& <span class="comment">/*aMessage*/</span>)
<a name="l00130"></a>00130 {
<a name="l00131"></a>00131 TResponse response = EAllowed;
<a name="l00132"></a>00132 <span class="keywordflow">return</span> response;
<a name="l00133"></a>00133 }
<a name="l00134"></a>00134
<a name="l00141"></a>00141 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::PrepareCommandList(<span class="keyword">const</span> TSsmSwp& aSwp, TRequestStatus& aStatus)
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
<a name="l00144"></a>00144 <span class="comment">// Build the command list for this value from a resource </span>
<a name="l00145"></a>00145 iCommandListResourceReader->PrepareCommandList(aSwp.Value(), aSwp, aStatus);
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147
<a name="l00152"></a>00152 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::PrepareCommandListCancel()
<a name="l00153"></a>00153 {
<a name="l00154"></a>00154 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
<a name="l00155"></a>00155 iCommandListResourceReader->PrepareCommandListCancel();
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157
<a name="l00164"></a>00164 CSsmCommandList* CSsmDummyDiskStatusSwpPolicy::CommandList()
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
<a name="l00167"></a>00167 <span class="keywordflow">return</span> iCommandListResourceReader->GetCommandList();
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169
<a name="l00178"></a>00178 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::HandleCleReturnValue(<span class="keyword">const</span> TSsmSwp& <span class="comment">/*aSwp*/</span>, TInt <span class="comment">/*aError*/</span>, TInt <span class="comment">/*aSeverity*/</span>, TRequestStatus& aStatus)
<a name="l00179"></a>00179 {
<a name="l00180"></a>00180 <span class="comment">/*</span>
<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>
<a name="l00182"></a>00182 <span class="comment"> a successful API request. The request always needs to be completed with KErrNone.</span>
<a name="l00183"></a>00183 <span class="comment"> */</span>
<a name="l00184"></a>00184 TRequestStatus* rs = &aStatus;
<a name="l00185"></a>00185 User::RequestComplete(rs, KErrNone);
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187
<a name="l00192"></a>00192 <span class="keywordtype">void</span> CSsmDummyDiskStatusSwpPolicy::HandleCleReturnValueCancel()
<a name="l00193"></a>00193 {
<a name="l00194"></a>00194 <span class="comment">// Nothing to do as HandleCleReturnValue always completes immediately</span>
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196
<a name="l00207"></a>00207 TBool CSsmDummyDiskStatusSwpPolicy::ConditionalCommandAllowedL(CResourceFile& <span class="comment">/*aResourceFile*/</span>, TInt <span class="comment">/*aResourceId*/</span>)
<a name="l00208"></a>00208 {
<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>
<a name="l00210"></a>00210 }
</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
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>