|
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/Base/FeatMngrExample/FeatureChecker/src/FeatureChecker.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/Base/FeatMngrExample/FeatureChecker/src/FeatureChecker.cpp</h1><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> |
|
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">//</span> |
|
22 <a name="l00015"></a>00015 |
|
23 <a name="l00016"></a>00016 <span class="preprocessor">#include "FeatureChecker.h"</span> |
|
24 <a name="l00017"></a>00017 <span class="preprocessor">#include <e32cons.h></span> |
|
25 <a name="l00018"></a>00018 |
|
26 <a name="l00019"></a><a class="code" href="class_c_feature_checker.html#e3e9b0382fab377cbb24147c943f831c">00019</a> <span class="keywordtype">void</span> <a class="code" href="class_c_feature_checker.html#e3e9b0382fab377cbb24147c943f831c">CFeatureChecker::ConstructL</a>() |
|
27 <a name="l00020"></a>00020 { |
|
28 <a name="l00021"></a>00021 iFeatNotifier = CFeatureNotifier::NewL(*<span class="keyword">this</span>); |
|
29 <a name="l00022"></a>00022 } |
|
30 <a name="l00023"></a>00023 |
|
31 <a name="l00024"></a><a class="code" href="class_c_feature_checker.html#0529f6ad0b87d00e4ba0110100fdc837">00024</a> <a class="code" href="class_c_feature_checker.html">CFeatureChecker</a>* <a class="code" href="class_c_feature_checker.html#0529f6ad0b87d00e4ba0110100fdc837">CFeatureChecker::NewL</a>() |
|
32 <a name="l00025"></a>00025 { |
|
33 <a name="l00026"></a>00026 <a class="code" href="class_c_feature_checker.html">CFeatureChecker</a>* <span class="keyword">self</span>=<span class="keyword">new</span>(ELeave)<a class="code" href="class_c_feature_checker.html">CFeatureChecker</a>(); |
|
34 <a name="l00027"></a>00027 CleanupStack::PushL(<span class="keyword">self</span>); |
|
35 <a name="l00028"></a>00028 <span class="keyword">self</span>->ConstructL(); |
|
36 <a name="l00029"></a>00029 CleanupStack::Pop(<span class="keyword">self</span>); |
|
37 <a name="l00030"></a>00030 <span class="keywordflow">return</span> <span class="keyword">self</span>; |
|
38 <a name="l00031"></a>00031 } |
|
39 <a name="l00032"></a>00032 |
|
40 <a name="l00036"></a><a class="code" href="class_c_feature_checker.html#2f290dbff4a1e23854b1acd0038836ed">00036</a> <a class="code" href="class_c_feature_checker.html#2f290dbff4a1e23854b1acd0038836ed">CFeatureChecker::~CFeatureChecker</a>() |
|
41 <a name="l00037"></a>00037 { |
|
42 <a name="l00038"></a>00038 <span class="keyword">delete</span> iFeatNotifier; |
|
43 <a name="l00039"></a>00039 } |
|
44 <a name="l00040"></a>00040 |
|
45 <a name="l00044"></a><a class="code" href="class_c_feature_checker.html#d81e893eb0476ad7aed4b31d77fb131f">00044</a> <span class="keywordtype">void</span> <a class="code" href="class_c_feature_checker.html#d81e893eb0476ad7aed4b31d77fb131f">CFeatureChecker::NotifyFeatureL</a>() |
|
46 <a name="l00045"></a>00045 { |
|
47 <a name="l00046"></a>00046 RFeatureUidArray featArray; |
|
48 <a name="l00047"></a>00047 CleanupClosePushL(featArray); |
|
49 <a name="l00048"></a>00048 TUid uidFeature; |
|
50 <a name="l00049"></a>00049 |
|
51 <a name="l00050"></a>00050 <span class="comment">//Number of feature UIDs which are subscribed to for notification.</span> |
|
52 <a name="l00051"></a>00051 <span class="keyword">const</span> TInt KNumFeaturesforNotification(10); |
|
53 <a name="l00052"></a>00052 |
|
54 <a name="l00053"></a>00053 <span class="comment">//Base feature UID for which notification requests are made. This is the same UID range which </span> |
|
55 <a name="l00054"></a>00054 <span class="comment">//the user can use when adding features to the FeatMngrExample process.</span> |
|
56 <a name="l00055"></a>00055 TUid KFeatureUidforNotification = {0x12000000}; |
|
57 <a name="l00056"></a>00056 |
|
58 <a name="l00057"></a>00057 <span class="comment">//Append the UIDs to featArray.</span> |
|
59 <a name="l00058"></a>00058 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> k=0; k<=KNumFeaturesforNotification; k++) |
|
60 <a name="l00059"></a>00059 { |
|
61 <a name="l00060"></a>00060 uidFeature.iUid = KFeatureUidforNotification.iUid + k; |
|
62 <a name="l00061"></a>00061 featArray.Append(uidFeature); |
|
63 <a name="l00062"></a>00062 } |
|
64 <a name="l00063"></a>00063 |
|
65 <a name="l00064"></a>00064 <span class="comment">//Request notification for user defined features.</span> |
|
66 <a name="l00065"></a>00065 User::LeaveIfError(iFeatNotifier->NotifyRequest(featArray)); |
|
67 <a name="l00066"></a>00066 CleanupStack::PopAndDestroy(&featArray); |
|
68 <a name="l00067"></a>00067 } |
|
69 <a name="l00068"></a>00068 |
|
70 <a name="l00072"></a><a class="code" href="class_c_feature_checker.html#e0338caa887d637c92972b5b91bfa76a">00072</a> <span class="keywordtype">void</span> <a class="code" href="class_c_feature_checker.html#e0338caa887d637c92972b5b91bfa76a">CFeatureChecker::HandleNotifyError</a>(TInt <span class="comment">/*err*/</span>) |
|
71 <a name="l00073"></a>00073 { |
|
72 <a name="l00074"></a>00074 } |
|
73 <a name="l00075"></a>00075 |
|
74 <a name="l00081"></a><a class="code" href="class_c_feature_checker.html#2d4636a82989321c291e135004d74247">00081</a> <span class="keywordtype">void</span> <a class="code" href="class_c_feature_checker.html#2d4636a82989321c291e135004d74247">CFeatureChecker::HandleNotifyChange</a>(TFeatureChangeType aType, TFeatureEntry <span class="comment">/*aFeature*/</span>) |
|
75 <a name="l00082"></a>00082 { |
|
76 <a name="l00083"></a>00083 <span class="keyword">const</span> TInt KFeatureChangeTypeMaxSize(45); |
|
77 <a name="l00084"></a>00084 TBuf<KFeatureChangeTypeMaxSize> changetype; |
|
78 <a name="l00085"></a>00085 <span class="keywordflow">switch</span>(aType) |
|
79 <a name="l00086"></a>00086 { |
|
80 <a name="l00087"></a>00087 <span class="keywordflow">case</span> EFeatureNoChange: |
|
81 <a name="l00088"></a>00088 _LIT(KNoChange, <span class="stringliteral">"Feature status not changed"</span>); |
|
82 <a name="l00089"></a>00089 changetype.Copy(KNoChange); |
|
83 <a name="l00090"></a>00090 <span class="keywordflow">break</span>; |
|
84 <a name="l00091"></a>00091 <span class="keywordflow">case</span> EFeatureStatusUpdated : |
|
85 <a name="l00092"></a>00092 _LIT(KStatusUpdated, <span class="stringliteral">"Feature status changed to enabled or disabled"</span>); |
|
86 <a name="l00093"></a>00093 changetype.Copy(KStatusUpdated); |
|
87 <a name="l00094"></a>00094 <span class="keywordflow">break</span>; |
|
88 <a name="l00095"></a>00095 <span class="keywordflow">case</span> EFeatureDataUpdated: |
|
89 <a name="l00096"></a>00096 _LIT(KDataUpdated, <span class="stringliteral">"Feature data changed"</span>); |
|
90 <a name="l00097"></a>00097 changetype.Copy(KDataUpdated); |
|
91 <a name="l00098"></a>00098 <span class="keywordflow">break</span>; |
|
92 <a name="l00099"></a>00099 <span class="keywordflow">case</span> EFeatureStatusDataUpdated: |
|
93 <a name="l00100"></a>00100 <span class="comment">//not used in the current version.</span> |
|
94 <a name="l00101"></a>00101 _LIT(KStatusDataUpdated, <span class="stringliteral">"Feature status and data changed"</span>); |
|
95 <a name="l00102"></a>00102 changetype.Copy(KStatusDataUpdated); |
|
96 <a name="l00103"></a>00103 <span class="keywordflow">break</span>; |
|
97 <a name="l00104"></a>00104 <span class="keywordflow">case</span> EFeatureRediscover: |
|
98 <a name="l00105"></a>00105 <span class="comment">//not used in the current version.</span> |
|
99 <a name="l00106"></a>00106 _LIT(KFeatureRediscover, <span class="stringliteral">"Complex change occurred, reload all features"</span>); |
|
100 <a name="l00107"></a>00107 changetype.Copy(KFeatureRediscover); |
|
101 <a name="l00108"></a>00108 <span class="keywordflow">break</span>; |
|
102 <a name="l00109"></a>00109 <span class="keywordflow">case</span> EFeatureFeatureCreated: |
|
103 <a name="l00110"></a>00110 _LIT(KFeatureCreated, <span class="stringliteral">"New feature has been added to the system"</span>); |
|
104 <a name="l00111"></a>00111 changetype.Copy(KFeatureCreated); |
|
105 <a name="l00112"></a>00112 <span class="keywordflow">break</span>; |
|
106 <a name="l00113"></a>00113 <span class="keywordflow">case</span> EFeatureFeatureDeleted: |
|
107 <a name="l00114"></a>00114 _LIT(KFeatureDeleted, <span class="stringliteral">"Feature has been deleted"</span>); |
|
108 <a name="l00115"></a>00115 changetype.Copy(KFeatureDeleted); |
|
109 <a name="l00116"></a>00116 <span class="keywordflow">break</span>; |
|
110 <a name="l00117"></a>00117 } |
|
111 <a name="l00118"></a>00118 <span class="comment">//Print the change type as an infoprint.</span> |
|
112 <a name="l00119"></a>00119 User::InfoPrint(changetype); |
|
113 <a name="l00120"></a>00120 } |
|
114 <a name="l00121"></a>00121 |
|
115 <a name="l00126"></a>00126 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="circularbuffer_8cpp.html#5fb473d4ee18739183215b04dcad6e12">MainL</a>() |
|
116 <a name="l00127"></a>00127 { |
|
117 <a name="l00128"></a>00128 CActiveScheduler* scheduler = <span class="keyword">new</span> (ELeave) CActiveScheduler(); |
|
118 <a name="l00129"></a>00129 CleanupStack::PushL(scheduler); |
|
119 <a name="l00130"></a>00130 CActiveScheduler::Install(scheduler); |
|
120 <a name="l00131"></a>00131 |
|
121 <a name="l00132"></a>00132 <a class="code" href="class_c_feature_checker.html">CFeatureChecker</a>* featChecker = <a class="code" href="class_c_feature_checker.html#0529f6ad0b87d00e4ba0110100fdc837">CFeatureChecker::NewL</a>(); |
|
122 <a name="l00133"></a>00133 CleanupStack::PushL(featChecker); |
|
123 <a name="l00134"></a>00134 <span class="comment">//Issue feature change notification request.</span> |
|
124 <a name="l00135"></a>00135 featChecker-><a class="code" href="class_c_feature_checker.html#d81e893eb0476ad7aed4b31d77fb131f">NotifyFeatureL</a>(); |
|
125 <a name="l00136"></a>00136 CActiveScheduler::Start(); |
|
126 <a name="l00137"></a>00137 |
|
127 <a name="l00138"></a>00138 CleanupStack::PopAndDestroy(featChecker); |
|
128 <a name="l00139"></a>00139 CleanupStack::PopAndDestroy(scheduler); |
|
129 <a name="l00140"></a>00140 } |
|
130 <a name="l00141"></a>00141 |
|
131 <a name="l00142"></a>00142 <span class="keyword">extern</span> TInt <a class="code" href="dbllist_8cpp.html#0f358e9c4355138f629b8c4f37310295">E32Main</a>() |
|
132 <a name="l00143"></a>00143 { |
|
133 <a name="l00144"></a>00144 <span class="comment">// Create cleanup stack</span> |
|
134 <a name="l00145"></a>00145 __UHEAP_MARK; |
|
135 <a name="l00146"></a>00146 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
136 <a name="l00147"></a>00147 <span class="keywordflow">if</span>(cleanup == NULL) |
|
137 <a name="l00148"></a>00148 { |
|
138 <a name="l00149"></a>00149 <span class="keywordflow">return</span> KErrNoMemory; |
|
139 <a name="l00150"></a>00150 } |
|
140 <a name="l00151"></a>00151 <span class="comment">// Run application code inside TRAP harness.</span> |
|
141 <a name="l00152"></a>00152 TRAPD(mainError, <a class="code" href="circularbuffer_8cpp.html#5fb473d4ee18739183215b04dcad6e12">MainL</a>()); |
|
142 <a name="l00153"></a>00153 <span class="keywordflow">if</span>(mainError != KErrNone) |
|
143 <a name="l00154"></a>00154 { |
|
144 <a name="l00155"></a>00155 _LIT(KUserPanic,<span class="stringliteral">"Failed to complete"</span>); |
|
145 <a name="l00156"></a>00156 User::Panic(KUserPanic, mainError); |
|
146 <a name="l00157"></a>00157 } |
|
147 <a name="l00158"></a>00158 <span class="keyword">delete</span> cleanup; |
|
148 <a name="l00159"></a>00159 __UHEAP_MARKEND; |
|
149 <a name="l00160"></a>00160 <span class="keywordflow">return</span> KErrNone; |
|
150 <a name="l00161"></a>00161 } |
|
151 </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 |
|
152 <a href="http://www.doxygen.org/index.html"> |
|
153 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> |
|
154 </body> |
|
155 </html> |