|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Data structures for generic access point information |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @publishedPartner |
|
21 @released |
|
22 */ |
|
23 |
|
24 |
|
25 |
|
26 #ifndef _ES_ACCESSPOINTSTATUS_H_ |
|
27 #define _ES_ACCESSPOINTSTATUS_H_ |
|
28 |
|
29 |
|
30 namespace ConnectionServ |
|
31 { |
|
32 |
|
33 // Type TAccessPointStatus (containing TAccessPointFlagValue instances) represents the status flags for an access point. |
|
34 // As well as the value of the flag True/False, |
|
35 // they include EUnknown, the case where the value isn't (yet) known / wasn't retrieved. |
|
36 |
|
37 struct TAccessPointStatusFilter; |
|
38 |
|
39 enum TAccessPointFlagValue |
|
40 { |
|
41 EAccessPointFlagUnknown = 0, |
|
42 EAccessPointFlagTrue = 1, |
|
43 EAccessPointFlagFalse = 2 |
|
44 }; |
|
45 |
|
46 struct TAccessPointStatus |
|
47 { |
|
48 union |
|
49 { |
|
50 struct |
|
51 { |
|
52 TUint iConfigured:2; |
|
53 TUint iRestricted:2; |
|
54 TUint iAvailable:2; |
|
55 TUint iStarted:2; |
|
56 TUint iActive:2; |
|
57 } iS; |
|
58 TInt64 iAsInt; |
|
59 } iU; |
|
60 |
|
61 TAccessPointStatus(TInt64 aI) |
|
62 { |
|
63 iU.iAsInt = aI; |
|
64 } |
|
65 |
|
66 TAccessPointStatus() |
|
67 { |
|
68 iU.iAsInt = TInt64(0); |
|
69 } |
|
70 |
|
71 TInt64 AsInt64() const { return iU.iAsInt; } |
|
72 |
|
73 void Configured(TAccessPointFlagValue aVal) {iU.iS.iConfigured = aVal;} |
|
74 TAccessPointFlagValue Configured() const {return static_cast<TAccessPointFlagValue>(iU.iS.iConfigured);} |
|
75 |
|
76 void Restricted(TAccessPointFlagValue aVal) {iU.iS.iRestricted = aVal;} |
|
77 TAccessPointFlagValue Restricted() const {return static_cast<TAccessPointFlagValue>(iU.iS.iRestricted);} |
|
78 |
|
79 void Available(TAccessPointFlagValue aVal) {iU.iS.iAvailable = aVal;} |
|
80 TAccessPointFlagValue Available() const {return static_cast<TAccessPointFlagValue>(iU.iS.iAvailable);} |
|
81 |
|
82 void Started(TAccessPointFlagValue aVal) {iU.iS.iStarted = aVal;} |
|
83 TAccessPointFlagValue Started() const {return static_cast<TAccessPointFlagValue>(iU.iS.iStarted);} |
|
84 |
|
85 void Active(TAccessPointFlagValue aVal) {iU.iS.iActive = aVal;} |
|
86 TAccessPointFlagValue Active() const {return static_cast<TAccessPointFlagValue>(iU.iS.iActive);} |
|
87 |
|
88 void UpdateWith(const TAccessPointStatus& aSrc) |
|
89 { |
|
90 // Fields: CRAS |
|
91 |
|
92 // Initial: CR?? |
|
93 // + |
|
94 // New: C?a? |
|
95 // = |
|
96 // Result CRa? |
|
97 |
|
98 // + |
|
99 // New: C?A? |
|
100 // = |
|
101 // Result: CRA? |
|
102 |
|
103 TAccessPointFlagValue value = static_cast<TAccessPointFlagValue>(iU.iS.iConfigured); |
|
104 TAccessPointStatus::PickUpIfSrcKnown( value, aSrc.Configured() ); |
|
105 iU.iS.iConfigured = value; |
|
106 |
|
107 value = static_cast<TAccessPointFlagValue>(iU.iS.iRestricted); |
|
108 TAccessPointStatus::PickUpIfSrcKnown( value, aSrc.Restricted() ); |
|
109 iU.iS.iRestricted = value; |
|
110 |
|
111 value = static_cast<TAccessPointFlagValue>(iU.iS.iAvailable); |
|
112 TAccessPointStatus::PickUpIfSrcKnown( value, aSrc.Available() ); |
|
113 iU.iS.iAvailable = value; |
|
114 |
|
115 value = static_cast<TAccessPointFlagValue>(iU.iS.iStarted); |
|
116 TAccessPointStatus::PickUpIfSrcKnown( value, aSrc.Started() ); |
|
117 iU.iS.iStarted = value; |
|
118 |
|
119 value = static_cast<TAccessPointFlagValue>(iU.iS.iActive); |
|
120 TAccessPointStatus::PickUpIfSrcKnown( value, aSrc.Active() ); |
|
121 iU.iS.iActive = value; |
|
122 } |
|
123 |
|
124 static void PickUpIfSrcKnown(TAccessPointFlagValue& aDest, const TAccessPointFlagValue aSrc ) |
|
125 { |
|
126 if(aSrc != EAccessPointFlagUnknown) |
|
127 { |
|
128 aDest = aSrc; |
|
129 } |
|
130 } |
|
131 |
|
132 inline void CopyFieldsRequiredByQueryFrom(const TAccessPointStatusFilter& aFilter,const TAccessPointStatus& aSource); |
|
133 |
|
134 static TText FlagValueAsChar(TAccessPointFlagValue aVal) |
|
135 { |
|
136 switch(aVal) |
|
137 { |
|
138 case EAccessPointFlagFalse: return 'N'; |
|
139 case EAccessPointFlagTrue: return 'Y'; |
|
140 } |
|
141 |
|
142 return '?'; |
|
143 } |
|
144 }; |
|
145 |
|
146 // Type TAccessPointStatusFilter (containing TAccessPointFlagFilterValue instances) represents a query against the above type. |
|
147 // As well as the value of the flag True/False, meaning "(find the value and) match true/false" |
|
148 // they include EAny, meaning "(retrieve the value and) match either value" |
|
149 // ... and .. EIgnore, meaning "don't retrieve the value" |
|
150 // This is of use for fields such as Availability which may be expensive to retrieve. |
|
151 |
|
152 enum TAccessPointFlagFilterValue |
|
153 { |
|
154 EAccessPointFlagIgnore = 0, // don't care.. signify we don't want to go and find it out if it requires any effort |
|
155 EAccessPointFlagMatchTrue = 1, |
|
156 EAccessPointFlagMatchFalse = 2, |
|
157 EAccessPointFlagMatchAny = 3, // find the value out |
|
158 }; |
|
159 |
|
160 struct TAccessPointStatusFilter |
|
161 { |
|
162 union |
|
163 { |
|
164 struct |
|
165 { |
|
166 TUint iConfigured:2; |
|
167 TUint iRestricted:2; |
|
168 TUint iAvailable:2; |
|
169 TUint iStarted:2; |
|
170 TUint iActive:2; |
|
171 } iS; |
|
172 TInt64 iAsInt; |
|
173 } iU; |
|
174 |
|
175 TAccessPointStatusFilter(TInt64 aI) |
|
176 { |
|
177 iU.iAsInt = aI; |
|
178 } |
|
179 |
|
180 TAccessPointStatusFilter() |
|
181 { |
|
182 iU.iAsInt = TInt64(0); |
|
183 } |
|
184 |
|
185 TInt64 AsInt64() const { return iU.iAsInt; } |
|
186 |
|
187 void Configured(TAccessPointFlagFilterValue aVal) {iU.iS.iConfigured = aVal;} |
|
188 TAccessPointFlagFilterValue Configured() const {return static_cast<TAccessPointFlagFilterValue>(iU.iS.iConfigured);} |
|
189 |
|
190 void Restricted(TAccessPointFlagFilterValue aVal) {iU.iS.iRestricted = aVal;} |
|
191 TAccessPointFlagFilterValue Restricted() const {return static_cast<TAccessPointFlagFilterValue>(iU.iS.iRestricted);} |
|
192 |
|
193 void Available(TAccessPointFlagFilterValue aVal) {iU.iS.iAvailable = aVal;} |
|
194 TAccessPointFlagFilterValue Available() const {return static_cast<TAccessPointFlagFilterValue>(iU.iS.iAvailable);} |
|
195 |
|
196 void Started(TAccessPointFlagFilterValue aVal) {iU.iS.iStarted = aVal;} |
|
197 TAccessPointFlagFilterValue Started() const {return static_cast<TAccessPointFlagFilterValue>(iU.iS.iStarted);} |
|
198 |
|
199 void Active(TAccessPointFlagFilterValue aVal) {iU.iS.iActive = aVal;} |
|
200 TAccessPointFlagFilterValue Active() const {return static_cast<TAccessPointFlagFilterValue>(iU.iS.iActive);} |
|
201 |
|
202 // helper function.. whether given flag value matches given filter |
|
203 static TBool Matches(TAccessPointFlagFilterValue aFilter,TAccessPointFlagValue aValue) |
|
204 { |
|
205 if(aFilter == EAccessPointFlagIgnore) |
|
206 { |
|
207 return ETrue; |
|
208 } |
|
209 |
|
210 switch(aValue) |
|
211 { |
|
212 case EAccessPointFlagFalse: |
|
213 if(aFilter != EAccessPointFlagMatchTrue) //i.e. is False/MatchAny |
|
214 { |
|
215 return ETrue; |
|
216 } |
|
217 break; |
|
218 |
|
219 case EAccessPointFlagTrue: |
|
220 if(aFilter != EAccessPointFlagMatchFalse) //i.e. is True/MatchAny |
|
221 { |
|
222 return ETrue; |
|
223 } |
|
224 break; |
|
225 |
|
226 case EAccessPointFlagUnknown: |
|
227 if(aFilter == EAccessPointFlagMatchAny) // only if we'll match any |
|
228 { |
|
229 return ETrue; |
|
230 } |
|
231 break; |
|
232 } |
|
233 |
|
234 return EFalse; |
|
235 } |
|
236 |
|
237 static TText FilterValueAsChar(TAccessPointFlagFilterValue aVal) |
|
238 { |
|
239 switch(aVal) |
|
240 { |
|
241 case EAccessPointFlagMatchFalse: return 'N'; |
|
242 case EAccessPointFlagMatchTrue: return 'Y'; |
|
243 case EAccessPointFlagMatchAny: return '?'; |
|
244 } |
|
245 return '-'; |
|
246 } |
|
247 |
|
248 }; |
|
249 |
|
250 |
|
251 |
|
252 inline void TAccessPointStatus::CopyFieldsRequiredByQueryFrom(const TAccessPointStatusFilter& aFilter,const TAccessPointStatus& aSource) |
|
253 { |
|
254 if(aFilter.Configured() != EAccessPointFlagIgnore) |
|
255 { |
|
256 Configured(aSource.Configured()); |
|
257 } |
|
258 |
|
259 if(aFilter.Restricted() != EAccessPointFlagIgnore) |
|
260 { |
|
261 Restricted(aSource.Restricted()); |
|
262 } |
|
263 |
|
264 if(aFilter.Available() != EAccessPointFlagIgnore) |
|
265 { |
|
266 Available(aSource.Available()); |
|
267 } |
|
268 |
|
269 if(aFilter.Started() != EAccessPointFlagIgnore) |
|
270 { |
|
271 Started(aSource.Started()); |
|
272 } |
|
273 |
|
274 if(aFilter.Active() != EAccessPointFlagIgnore) |
|
275 { |
|
276 Active(aSource.Active()); |
|
277 } |
|
278 } |
|
279 |
|
280 } |
|
281 #endif |
|
282 |