|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CSysInfoService class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AccessoryConnection.h> |
|
20 #include <AccessoryServer.h> |
|
21 #include <PtiEngine.h> |
|
22 #include <centralrepository.h> |
|
23 #include <SysUtilDomainCRKeys.h> |
|
24 |
|
25 #include "sysinfo.h" |
|
26 #include "SysInfoUtils.h" |
|
27 |
|
28 // -------------------------------------------------------------------- |
|
29 // CSysData::CSysData() |
|
30 // Constructor |
|
31 // -------------------------------------------------------------------- |
|
32 // |
|
33 CSysData::CSysData(TDataType aType):iDataType(aType) |
|
34 { |
|
35 } |
|
36 |
|
37 // -------------------------------------------------------------------- |
|
38 // CSysData::~CSysData() |
|
39 // Destructor |
|
40 // -------------------------------------------------------------------- |
|
41 // |
|
42 CSysData::~CSysData() |
|
43 { |
|
44 } |
|
45 |
|
46 // -------------------------------------------------------------------- |
|
47 // CSysData::DataType() |
|
48 // returns type of data this instance holds. @TDataType |
|
49 // -------------------------------------------------------------------- |
|
50 // |
|
51 EXPORT_C CSysData::TDataType CSysData::DataType() const |
|
52 { |
|
53 return iDataType; |
|
54 } |
|
55 |
|
56 // -------------------------------------------------------------------- |
|
57 // CStatus::CStatus() |
|
58 // Constructor |
|
59 // -------------------------------------------------------------------- |
|
60 // |
|
61 CStatus::CStatus(TInt aStatus):CSysData(EStatus),iStatus(aStatus) |
|
62 { |
|
63 } |
|
64 |
|
65 // -------------------------------------------------------------------- |
|
66 // CStatus::~CStatus() |
|
67 // Destructor |
|
68 // -------------------------------------------------------------------- |
|
69 // |
|
70 CStatus::~CStatus() |
|
71 { |
|
72 } |
|
73 |
|
74 // -------------------------------------------------------------------- |
|
75 // CStatus::CStatus() |
|
76 // Two-phased constructor |
|
77 // -------------------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C CStatus* CStatus::NewL(TInt aStatus) |
|
80 { |
|
81 CStatus* self = new (ELeave) CStatus(aStatus); |
|
82 return self; |
|
83 } |
|
84 |
|
85 // -------------------------------------------------------------------- |
|
86 // CStatus::CStatus() |
|
87 // returns interger value stored which is used to represent status of |
|
88 // many SA's. |
|
89 // -------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C TInt CStatus::Status() const |
|
92 { |
|
93 return iStatus; |
|
94 } |
|
95 |
|
96 // -------------------------------------------------------------------- |
|
97 // CStringData::CStringData() |
|
98 // Constructor. |
|
99 // -------------------------------------------------------------------- |
|
100 // |
|
101 CStringData::CStringData():CSysData(EStringData) |
|
102 { |
|
103 } |
|
104 |
|
105 // -------------------------------------------------------------------- |
|
106 // CStringData::~CStringData() |
|
107 // Destructor |
|
108 // -------------------------------------------------------------------- |
|
109 // |
|
110 CStringData::~CStringData() |
|
111 { |
|
112 delete iStringData; |
|
113 } |
|
114 |
|
115 // -------------------------------------------------------------------- |
|
116 // CStringData::NewL() |
|
117 // Two-phased constructor. returns new instance of this class. |
|
118 // -------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C CStringData* CStringData::NewL(const TDesC& aString) |
|
121 { |
|
122 CStringData* self = new (ELeave) CStringData(); |
|
123 CleanupStack::PushL(self); |
|
124 self->iStringData = aString.AllocL(); |
|
125 CleanupStack::Pop(self); |
|
126 return self; |
|
127 } |
|
128 |
|
129 // -------------------------------------------------------------------- |
|
130 // CStringData::StringData() |
|
131 // On return aString contains string data. |
|
132 // -------------------------------------------------------------------- |
|
133 // |
|
134 EXPORT_C void CStringData::StringData(TPtrC& aString) const |
|
135 { |
|
136 aString.Set(*iStringData); |
|
137 } |
|
138 |
|
139 // -------------------------------------------------------------------- |
|
140 // CVersion::CVersion() |
|
141 // Constructor. |
|
142 // -------------------------------------------------------------------- |
|
143 // |
|
144 CVersion::CVersion(TInt aMajor,TInt aMinor):CSysData(EVersion), |
|
145 iMajorVersion(aMajor), |
|
146 iMinorVersion(aMinor) |
|
147 { |
|
148 } |
|
149 |
|
150 // -------------------------------------------------------------------- |
|
151 // CVersion::~CVersion() |
|
152 // Destructor |
|
153 // -------------------------------------------------------------------- |
|
154 // |
|
155 CVersion::~CVersion() |
|
156 { |
|
157 } |
|
158 |
|
159 // -------------------------------------------------------------------- |
|
160 // CVersion::NewL() |
|
161 // Two-phased constructor. returns new instance of this class. |
|
162 // -------------------------------------------------------------------- |
|
163 // |
|
164 CVersion* CVersion::NewL(TInt aMajor,TInt aMinor) |
|
165 { |
|
166 CVersion* self = new (ELeave) CVersion(aMajor,aMinor); |
|
167 return self; |
|
168 } |
|
169 |
|
170 // -------------------------------------------------------------------- |
|
171 // CVersion::MajorVersion() |
|
172 // returns major version number. |
|
173 // -------------------------------------------------------------------- |
|
174 // |
|
175 EXPORT_C TInt CVersion::MajorVersion() const |
|
176 { |
|
177 return iMajorVersion; |
|
178 } |
|
179 |
|
180 // -------------------------------------------------------------------- |
|
181 // CVersion::MinorVersion() |
|
182 // returns minor version number. |
|
183 // -------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C TInt CVersion::MinorVersion() const |
|
186 { |
|
187 return iMinorVersion; |
|
188 } |
|
189 |
|
190 // -------------------------------------------------------------------- |
|
191 // CNetworkInfo::CNetworkInfo() |
|
192 // Constructor. |
|
193 // -------------------------------------------------------------------- |
|
194 // |
|
195 CNetworkInfo::CNetworkInfo(RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo, |
|
196 RMobilePhone::TMobilePhoneLocationAreaV1& aArea) |
|
197 :CSysData(ENetworkInfo),iNetworkInfo(aNetworkInfo), |
|
198 iLAC(aArea) |
|
199 { |
|
200 } |
|
201 |
|
202 // -------------------------------------------------------------------- |
|
203 // CNetworkInfo::~CNetworkInfo() |
|
204 // Destructor |
|
205 // -------------------------------------------------------------------- |
|
206 // |
|
207 CNetworkInfo::~CNetworkInfo() |
|
208 { |
|
209 } |
|
210 |
|
211 // -------------------------------------------------------------------- |
|
212 // CNetworkInfo::NewL() |
|
213 // Two-phased constructor. returns new instance of this class. |
|
214 // -------------------------------------------------------------------- |
|
215 // |
|
216 CNetworkInfo* CNetworkInfo::NewL( |
|
217 RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo, |
|
218 RMobilePhone::TMobilePhoneLocationAreaV1& aArea ) |
|
219 { |
|
220 CNetworkInfo* self = new (ELeave) CNetworkInfo(aNetworkInfo,aArea); |
|
221 return self; |
|
222 } |
|
223 |
|
224 // -------------------------------------------------------------------- |
|
225 // CNetworkInfo::NetworkName() |
|
226 // returns network name. |
|
227 // -------------------------------------------------------------------- |
|
228 // |
|
229 EXPORT_C TPtrC CNetworkInfo::NetworkName() const |
|
230 { |
|
231 return TPtrC(iNetworkInfo.iLongName); |
|
232 } |
|
233 |
|
234 // -------------------------------------------------------------------- |
|
235 // CNetworkInfo::NetworkMode() |
|
236 // returns network mode. |
|
237 // -------------------------------------------------------------------- |
|
238 // |
|
239 EXPORT_C TInt CNetworkInfo::NetworkMode() const |
|
240 { |
|
241 return (iNetworkInfo.iMode - 1); |
|
242 } |
|
243 |
|
244 // -------------------------------------------------------------------- |
|
245 // CNetworkInfo::NetworkStatus() |
|
246 // returns network status. |
|
247 // -------------------------------------------------------------------- |
|
248 // |
|
249 EXPORT_C TInt CNetworkInfo::NetworkStatus() const |
|
250 { |
|
251 return (iNetworkInfo.iStatus -1); |
|
252 } |
|
253 |
|
254 // -------------------------------------------------------------------- |
|
255 // CNetworkInfo::CountryCode() |
|
256 // returns MCC Mobile Country Code. |
|
257 // -------------------------------------------------------------------- |
|
258 // |
|
259 EXPORT_C TPtrC CNetworkInfo::CountryCode() const |
|
260 { |
|
261 return TPtrC(iNetworkInfo.iCountryCode); |
|
262 } |
|
263 |
|
264 // -------------------------------------------------------------------- |
|
265 // CNetworkInfo::NetworkCode() |
|
266 // returns MNC Mobile Network Code. |
|
267 // -------------------------------------------------------------------- |
|
268 // |
|
269 EXPORT_C TPtrC CNetworkInfo::NetworkCode() const |
|
270 { |
|
271 return TPtrC(iNetworkInfo.iNetworkId); |
|
272 } |
|
273 |
|
274 // -------------------------------------------------------------------- |
|
275 // CNetworkInfo::LocationAreaCode() |
|
276 // returns LAC Location Area Code. |
|
277 // -------------------------------------------------------------------- |
|
278 // |
|
279 EXPORT_C TUint CNetworkInfo::LocationAreaCode() const |
|
280 { |
|
281 return iLAC.iLocationAreaCode; |
|
282 } |
|
283 |
|
284 // -------------------------------------------------------------------- |
|
285 // CNetworkInfo::CellId() |
|
286 // returns Cell ID of a region. |
|
287 // -------------------------------------------------------------------- |
|
288 // |
|
289 EXPORT_C TUint CNetworkInfo::CellId() const |
|
290 { |
|
291 return iLAC.iCellId; |
|
292 } |
|
293 |
|
294 // -------------------------------------------------------------------- |
|
295 // CNetworkInfo::ValidLocationAreaCode() |
|
296 // returns bool validates LAC and CellID data values. |
|
297 // -------------------------------------------------------------------- |
|
298 // |
|
299 EXPORT_C TBool CNetworkInfo::ValidLocationAreaCode() const |
|
300 { |
|
301 return iLAC.iAreaKnown; |
|
302 } |
|
303 |
|
304 |
|
305 // -------------------------------------------------------------------- |
|
306 // CAccessoryInfo::CAccessoryInfo() |
|
307 // Constructor. |
|
308 // -------------------------------------------------------------------- |
|
309 // |
|
310 CAccessoryInfo::CAccessoryInfo(TAccessoryState aAccState) |
|
311 :CSysData(EAccessoryInfo), |
|
312 iConnectionState(aAccState) |
|
313 { |
|
314 } |
|
315 |
|
316 // -------------------------------------------------------------------- |
|
317 // CAccessoryInfo::~CAccessoryInfo() |
|
318 // Destructor |
|
319 // -------------------------------------------------------------------- |
|
320 // |
|
321 CAccessoryInfo::~CAccessoryInfo() |
|
322 { |
|
323 } |
|
324 |
|
325 // -------------------------------------------------------------------- |
|
326 // CAccessoryInfo::NewL() |
|
327 // Two-phased constructor. returns new instance of this class. |
|
328 // -------------------------------------------------------------------- |
|
329 // |
|
330 CAccessoryInfo* CAccessoryInfo::NewL(const TAccPolGenericID& aGenericID, |
|
331 TAccessoryState aAccState) |
|
332 { |
|
333 CAccessoryInfo* self = new (ELeave) CAccessoryInfo(aAccState); |
|
334 self->GetAccessoryProperty(aGenericID); |
|
335 return self; |
|
336 } |
|
337 |
|
338 // -------------------------------------------------------------------- |
|
339 // CAccessoryInfo::AccessoryType() |
|
340 // returns type of accessory. |
|
341 // -------------------------------------------------------------------- |
|
342 // |
|
343 EXPORT_C TInt CAccessoryInfo::AccessoryType() const |
|
344 { |
|
345 return iAccessoryType; |
|
346 } |
|
347 |
|
348 // -------------------------------------------------------------------- |
|
349 // CAccessoryInfo::GetAccessoryProperty() |
|
350 // retrives accessory type information from aGenericID. |
|
351 // -------------------------------------------------------------------- |
|
352 // |
|
353 void CAccessoryInfo::GetAccessoryProperty(const TAccPolGenericID& aGenericID) |
|
354 { |
|
355 TUint32 deviceType = aGenericID.DeviceTypeCaps(); |
|
356 TUint32 connectionType = aGenericID.PhysicalConnectionCaps(); |
|
357 |
|
358 if(deviceType == KDTHeadset && (connectionType & KPCWired)) |
|
359 { |
|
360 iAccessoryType = CAccessoryInfo::EHeadSet; |
|
361 } |
|
362 else if(deviceType == KDTHeadset && (connectionType & KPCBluetooth) ) |
|
363 { |
|
364 iAccessoryType = EBTHeadSet; |
|
365 } |
|
366 else if(deviceType == KDTCarKit && (connectionType & KPCWired) ) |
|
367 { |
|
368 iAccessoryType = ECarKit; |
|
369 } |
|
370 else if(deviceType == KDTCarKit && (connectionType == KPCBluetooth) ) |
|
371 { |
|
372 iAccessoryType = EBTCarKit; |
|
373 } |
|
374 else |
|
375 { |
|
376 iAccessoryType = EUnknown; |
|
377 } |
|
378 } |
|
379 |
|
380 // -------------------------------------------------------------------- |
|
381 // CAccessoryInfo::ConnectionState() |
|
382 // returns accessory state (Connected,Disconnected). |
|
383 // -------------------------------------------------------------------- |
|
384 // |
|
385 EXPORT_C TInt CAccessoryInfo::ConnectionState() const |
|
386 { |
|
387 return iConnectionState; |
|
388 } |
|
389 |
|
390 // -------------------------------------------------------------------- |
|
391 // CAccList::CAccList() |
|
392 // Constructor. |
|
393 // -------------------------------------------------------------------- |
|
394 // |
|
395 CAccList::CAccList():CSysData(EAccessoryList) |
|
396 { |
|
397 } |
|
398 |
|
399 // -------------------------------------------------------------------- |
|
400 // CAccList::~CAccList() |
|
401 // Destructor |
|
402 // -------------------------------------------------------------------- |
|
403 // |
|
404 CAccList::~CAccList() |
|
405 { |
|
406 } |
|
407 |
|
408 // -------------------------------------------------------------------- |
|
409 // CAccList::NewL() |
|
410 // Two-phased constructor. returns new instance of this class. |
|
411 // -------------------------------------------------------------------- |
|
412 // |
|
413 CAccList* CAccList::NewL() |
|
414 { |
|
415 CAccList* self = new (ELeave) CAccList(); |
|
416 CleanupStack::PushL(self); |
|
417 self->ConstructL(); |
|
418 CleanupStack::Pop(self); |
|
419 return self; |
|
420 } |
|
421 |
|
422 // -------------------------------------------------------------------- |
|
423 // CAccList::ConstructL() |
|
424 // 2nd phase construtor |
|
425 // -------------------------------------------------------------------- |
|
426 // |
|
427 void CAccList::ConstructL() |
|
428 { |
|
429 RAccessoryServer AccSrv; |
|
430 RAccessoryConnection AccConnection; |
|
431 |
|
432 //Connect to accessory server. |
|
433 User::LeaveIfError(AccSrv.Connect()); |
|
434 //Create a session to it. |
|
435 User::LeaveIfError(AccConnection.CreateSubSession(AccSrv)); |
|
436 //read list of connected accssories at this moment. |
|
437 AccConnection.GetAccessoryConnectionStatus(iAccessories); |
|
438 iCount = iAccessories.Count(); |
|
439 //Close subsession. |
|
440 AccConnection.CloseSubSession(); |
|
441 //Disconnect accessory server. |
|
442 AccSrv.Disconnect(); |
|
443 } |
|
444 |
|
445 // -------------------------------------------------------------------- |
|
446 // CAccList::AtL() |
|
447 // Reads AccessoryInfo at an index. On return aAccessoryInfo consists |
|
448 // of accessory information. |
|
449 // -------------------------------------------------------------------- |
|
450 // |
|
451 EXPORT_C TBool CAccList::AtL(TInt aIndex,const CAccessoryInfo*& |
|
452 aAccessoryInfo) const |
|
453 { |
|
454 TAccPolGenericID accessoryid; |
|
455 if(0 <= aIndex && aIndex < Count()) |
|
456 { |
|
457 accessoryid = iAccessories.GetGenericIDL(aIndex); |
|
458 } |
|
459 else |
|
460 { |
|
461 aAccessoryInfo = NULL; |
|
462 return EFalse; |
|
463 } |
|
464 |
|
465 //Create CAccessoryInfo. client has the ownership. |
|
466 aAccessoryInfo = CAccessoryInfo::NewL(accessoryid, |
|
467 CAccessoryInfo::EConnected); |
|
468 return ETrue; |
|
469 } |
|
470 |
|
471 // -------------------------------------------------------------------- |
|
472 // CAccList::[] |
|
473 // Reads AccessoryInfo at an index. returns CAccessoryInfo |
|
474 // -------------------------------------------------------------------- |
|
475 // |
|
476 EXPORT_C const CAccessoryInfo* CAccList::operator[](TInt aIndex) const |
|
477 { |
|
478 CAccessoryInfo* accessoryinfo = NULL; |
|
479 if(0 <= aIndex && aIndex < iCount) |
|
480 { |
|
481 TAccPolGenericID accessoryid; |
|
482 accessoryid = iAccessories.GetGenericIDL(aIndex); |
|
483 //Create CAccessoryInfo. client has the ownership. |
|
484 accessoryinfo = CAccessoryInfo::NewL(accessoryid, |
|
485 CAccessoryInfo::EConnected); |
|
486 } |
|
487 return accessoryinfo; |
|
488 } |
|
489 |
|
490 // -------------------------------------------------------------------- |
|
491 // CAccList::Count() |
|
492 // returns number of accessories. |
|
493 // -------------------------------------------------------------------- |
|
494 // |
|
495 EXPORT_C TInt CAccList::Count() const |
|
496 { |
|
497 return iCount; |
|
498 } |
|
499 |
|
500 // -------------------------------------------------------------------- |
|
501 // CLanguageList::CLanguageList() |
|
502 // Constructor. |
|
503 // -------------------------------------------------------------------- |
|
504 // |
|
505 CLanguageList::CLanguageList():CSysData(ELanguageList) |
|
506 { |
|
507 } |
|
508 |
|
509 // -------------------------------------------------------------------- |
|
510 // CLanguageList::~CLanguageList() |
|
511 // Destructor |
|
512 // -------------------------------------------------------------------- |
|
513 // |
|
514 CLanguageList::~CLanguageList() |
|
515 { |
|
516 iLanguages.Close(); |
|
517 } |
|
518 |
|
519 // -------------------------------------------------------------------- |
|
520 // CLanguageList::NewL() |
|
521 // Two-phased constructor. returns new instance of this class. |
|
522 // -------------------------------------------------------------------- |
|
523 // |
|
524 CLanguageList* CLanguageList::NewL() |
|
525 { |
|
526 CLanguageList* self; |
|
527 self = new (ELeave) CLanguageList(); |
|
528 CleanupStack::PushL(self); |
|
529 self->ConstructL(); |
|
530 CleanupStack::Pop(self); |
|
531 return self; |
|
532 } |
|
533 |
|
534 // -------------------------------------------------------------------- |
|
535 // CLanguageList::ConstructL() |
|
536 // 2nd phase construtor |
|
537 // -------------------------------------------------------------------- |
|
538 // |
|
539 void CLanguageList::ConstructL() |
|
540 { |
|
541 CPtiEngine* PtiEngine; |
|
542 PtiEngine = CPtiEngine::NewL(); |
|
543 CleanupStack::PushL(PtiEngine); |
|
544 PtiEngine->GetAvailableLanguagesL(iLanguages); |
|
545 CleanupStack::PopAndDestroy(PtiEngine); |
|
546 } |
|
547 |
|
548 // -------------------------------------------------------------------- |
|
549 // CLanguageList::[] |
|
550 // returns language code at the index. |
|
551 // -------------------------------------------------------------------- |
|
552 // |
|
553 EXPORT_C TInt CLanguageList::operator[](TInt aIndex) const |
|
554 { |
|
555 if(0 <= aIndex && aIndex < Count()) |
|
556 return iLanguages[aIndex]; |
|
557 else |
|
558 return -1; |
|
559 } |
|
560 |
|
561 // -------------------------------------------------------------------- |
|
562 // CLanguageList::At |
|
563 // On return aEntry consists of language code at the index. |
|
564 // -------------------------------------------------------------------- |
|
565 // |
|
566 EXPORT_C TBool CLanguageList::At(TInt aIndex, TInt& aEntry) const |
|
567 { |
|
568 if(0 <= aIndex && aIndex < Count()) |
|
569 { |
|
570 aEntry = iLanguages[aIndex]; |
|
571 return ETrue; |
|
572 } |
|
573 return EFalse; |
|
574 } |
|
575 |
|
576 // -------------------------------------------------------------------- |
|
577 // CLanguageList::Count |
|
578 // returns number of languages. |
|
579 // -------------------------------------------------------------------- |
|
580 // |
|
581 EXPORT_C TInt CLanguageList::Count() const |
|
582 { |
|
583 return iLanguages.Count(); |
|
584 } |
|
585 |
|
586 // -------------------------------------------------------------------- |
|
587 // CStringList::CStringList() |
|
588 // Constructor. |
|
589 // -------------------------------------------------------------------- |
|
590 // |
|
591 CStringList::CStringList(CDesCArray*& aDesArray):CSysData(EStringList), |
|
592 iDesArray(aDesArray) |
|
593 { |
|
594 } |
|
595 |
|
596 // -------------------------------------------------------------------- |
|
597 // CStringList::~CStringList() |
|
598 // Destructor |
|
599 // -------------------------------------------------------------------- |
|
600 // |
|
601 CStringList::~CStringList() |
|
602 { |
|
603 delete iDesArray; |
|
604 } |
|
605 |
|
606 // -------------------------------------------------------------------- |
|
607 // CStringList::NewL() |
|
608 // Two-phased constructor. returns new instance of this class. |
|
609 // -------------------------------------------------------------------- |
|
610 // |
|
611 CStringList* CStringList::NewL(CDesCArray*& aDesArray) |
|
612 { |
|
613 CStringList* self = new (ELeave) CStringList(aDesArray); |
|
614 return self; |
|
615 } |
|
616 |
|
617 // -------------------------------------------------------------------- |
|
618 // CStringList::[] |
|
619 // returns string data at specified index. |
|
620 // -------------------------------------------------------------------- |
|
621 // |
|
622 EXPORT_C TPtrC CStringList::operator[](TInt aIndex) const |
|
623 { |
|
624 if( 0 <= aIndex && aIndex < iCount ) |
|
625 return (*iDesArray)[aIndex]; |
|
626 |
|
627 return NULL; |
|
628 } |
|
629 |
|
630 // -------------------------------------------------------------------- |
|
631 // CStringList::At |
|
632 // On return aEntry consists of string data at specified index. |
|
633 // -------------------------------------------------------------------- |
|
634 // |
|
635 EXPORT_C TBool CStringList::At(TInt aIndex, TPtrC& aEntry) const |
|
636 { |
|
637 if( 0 <= aIndex && aIndex < Count() ) |
|
638 { |
|
639 aEntry.Set((*iDesArray)[aIndex]); |
|
640 return ETrue; |
|
641 } |
|
642 return EFalse; |
|
643 } |
|
644 |
|
645 // -------------------------------------------------------------------- |
|
646 // CStringList::Count |
|
647 // returns number of strings. |
|
648 // -------------------------------------------------------------------- |
|
649 // |
|
650 EXPORT_C TInt CStringList::Count() const |
|
651 { |
|
652 return iDesArray->Count(); |
|
653 } |
|
654 |
|
655 // -------------------------------------------------------------------- |
|
656 // CResolution::CResolution() |
|
657 // Constructor. |
|
658 // -------------------------------------------------------------------- |
|
659 // |
|
660 CResolution::CResolution(TInt aXPixels, TInt aYPixels):CSysData(EResolution), |
|
661 iXPixels(aXPixels),iYPixels(aYPixels) |
|
662 { |
|
663 } |
|
664 |
|
665 // -------------------------------------------------------------------- |
|
666 // CResolution::~CResolution() |
|
667 // Destructor |
|
668 // -------------------------------------------------------------------- |
|
669 // |
|
670 CResolution::~CResolution() |
|
671 { |
|
672 } |
|
673 |
|
674 // -------------------------------------------------------------------- |
|
675 // CResolution::NewL() |
|
676 // Two-phased constructor. returns new instance of this class. |
|
677 // -------------------------------------------------------------------- |
|
678 // |
|
679 CResolution* CResolution::NewL(TInt aXPixels, TInt aYPixels) |
|
680 { |
|
681 CResolution* self = new (ELeave) CResolution(aXPixels,aYPixels); |
|
682 return self; |
|
683 } |
|
684 |
|
685 // -------------------------------------------------------------------- |
|
686 // CResolution::XPixels() |
|
687 // returns x-pixels. |
|
688 // -------------------------------------------------------------------- |
|
689 // |
|
690 EXPORT_C TInt CResolution::XPixels() const |
|
691 { |
|
692 return iXPixels; |
|
693 } |
|
694 |
|
695 // -------------------------------------------------------------------- |
|
696 // CResolution::YPixels() |
|
697 // returns y-pixels. |
|
698 // -------------------------------------------------------------------- |
|
699 // |
|
700 EXPORT_C TInt CResolution::YPixels() const |
|
701 { |
|
702 return iYPixels; |
|
703 } |
|
704 |
|
705 // -------------------------------------------------------------------- |
|
706 // CDriveList::CDriveList() |
|
707 // Constructor. |
|
708 // -------------------------------------------------------------------- |
|
709 // |
|
710 CDriveList::CDriveList():CSysData(EDriveList) |
|
711 { |
|
712 } |
|
713 |
|
714 // -------------------------------------------------------------------- |
|
715 // CDriveList::~CDriveList() |
|
716 // Destructor |
|
717 // -------------------------------------------------------------------- |
|
718 // |
|
719 CDriveList::~CDriveList() |
|
720 { |
|
721 iDrives.Close(); |
|
722 } |
|
723 |
|
724 // -------------------------------------------------------------------- |
|
725 // CDriveList::NewL() |
|
726 // Two-phased constructor. returns new instance of this class. |
|
727 // -------------------------------------------------------------------- |
|
728 // |
|
729 CDriveList* CDriveList::NewL(TDriveList& aDrives) |
|
730 { |
|
731 CDriveList* self; |
|
732 self = new (ELeave) CDriveList(); |
|
733 CleanupStack::PushL(self); |
|
734 self->ConstructL(aDrives); |
|
735 CleanupStack::Pop(self); |
|
736 return self; |
|
737 } |
|
738 |
|
739 // -------------------------------------------------------------------- |
|
740 // CDriveList::ConstructL() |
|
741 // 2nd phase construtor |
|
742 // -------------------------------------------------------------------- |
|
743 // |
|
744 void CDriveList::ConstructL(TDriveList& aDrives) |
|
745 { |
|
746 for (TInt i=0; KMaxDrives > i; i++) |
|
747 //check drive is valid. |
|
748 if( aDrives[i] ) |
|
749 //add the drive to list. |
|
750 iDrives.AppendL(i); |
|
751 |
|
752 iCount = iDrives.Count(); |
|
753 } |
|
754 |
|
755 // -------------------------------------------------------------------- |
|
756 // CDriveList::[] |
|
757 // gets drive number at specified index. |
|
758 // -------------------------------------------------------------------- |
|
759 // |
|
760 EXPORT_C TInt CDriveList::operator[](TInt aIndex) const |
|
761 { |
|
762 if(0 <= aIndex && aIndex<iCount) |
|
763 return iDrives[aIndex]; |
|
764 else |
|
765 return -1; |
|
766 } |
|
767 |
|
768 // -------------------------------------------------------------------- |
|
769 // CDriveList::AtL |
|
770 // gets drive number at specified index. aEntry consists of drive number. |
|
771 // -------------------------------------------------------------------- |
|
772 // |
|
773 EXPORT_C TBool CDriveList::At(TInt aIndex, TInt& aEntry) const |
|
774 { |
|
775 if( 0 <= aIndex && aIndex<iCount ) |
|
776 { |
|
777 aEntry = iDrives[aIndex]; |
|
778 return ETrue; |
|
779 } |
|
780 return EFalse; |
|
781 } |
|
782 |
|
783 // -------------------------------------------------------------------- |
|
784 // CDriveList::Count |
|
785 // returns number of drives. |
|
786 // -------------------------------------------------------------------- |
|
787 // |
|
788 EXPORT_C TInt CDriveList::Count() const |
|
789 { |
|
790 return iCount; |
|
791 } |
|
792 |
|
793 // -------------------------------------------------------------------- |
|
794 // CDriveInfo::CDriveInfo() |
|
795 // Constructor. |
|
796 // -------------------------------------------------------------------- |
|
797 // |
|
798 CDriveInfo::CDriveInfo(TInt aDrvNumber,TVolumeInfo& aVolumeInfo) |
|
799 :CSysData(EDriveInfo),iDrvNumber(aDrvNumber), |
|
800 iVolumeInfo(aVolumeInfo),iVolumeInfoValid(ETrue), |
|
801 iCriticalSpace(-1) |
|
802 { |
|
803 } |
|
804 |
|
805 // -------------------------------------------------------------------- |
|
806 // CDriveInfo::CDriveInfo() |
|
807 // Constructor. |
|
808 // -------------------------------------------------------------------- |
|
809 // |
|
810 CDriveInfo::CDriveInfo(TInt aDrvNumber,TInt aCriticalSpace) |
|
811 :CSysData(EDriveInfo),iDrvNumber(aDrvNumber), |
|
812 iVolumeInfoValid(EFalse), |
|
813 iCriticalSpace(aCriticalSpace) |
|
814 { |
|
815 } |
|
816 |
|
817 // -------------------------------------------------------------------- |
|
818 // CDriveInfo::~CDriveInfo() |
|
819 // Destructor |
|
820 // -------------------------------------------------------------------- |
|
821 // |
|
822 CDriveInfo::~CDriveInfo() |
|
823 { |
|
824 } |
|
825 |
|
826 // -------------------------------------------------------------------- |
|
827 // CDriveInfo::NewL() |
|
828 // Two-phased constructor. returns new instance of this class. |
|
829 // -------------------------------------------------------------------- |
|
830 // |
|
831 EXPORT_C CDriveInfo* CDriveInfo::NewL(TInt aDriveNumber, TInt aCriticalSpace) |
|
832 { |
|
833 CDriveInfo* self; |
|
834 self = new (ELeave) CDriveInfo(aDriveNumber,aCriticalSpace); |
|
835 return self; |
|
836 } |
|
837 |
|
838 // -------------------------------------------------------------------- |
|
839 // CDriveInfo::NewL() |
|
840 // Two-phased constructor. returns new instance of this class. |
|
841 // -------------------------------------------------------------------- |
|
842 // |
|
843 CDriveInfo* CDriveInfo::NewL(TInt aDriveNumber, TVolumeInfo& aVolumeInfo) |
|
844 { |
|
845 CDriveInfo* self; |
|
846 self = new (ELeave) CDriveInfo(aDriveNumber,aVolumeInfo); |
|
847 return self; |
|
848 } |
|
849 |
|
850 // -------------------------------------------------------------------- |
|
851 // CDriveInfo::DriveNumber |
|
852 // returns drive number. |
|
853 // -------------------------------------------------------------------- |
|
854 // |
|
855 EXPORT_C TInt CDriveInfo::DriveNumber() const |
|
856 { |
|
857 return iDrvNumber; |
|
858 } |
|
859 |
|
860 // -------------------------------------------------------------------- |
|
861 // CDriveInfo::CriticalSpace |
|
862 // returns critical space of the drive. |
|
863 // -------------------------------------------------------------------- |
|
864 // |
|
865 EXPORT_C TInt CDriveInfo::CriticalSpace() const |
|
866 { |
|
867 TInt err(KErrNone); |
|
868 TInt criticalspace(0); |
|
869 if( -1 == iCriticalSpace ) |
|
870 { |
|
871 if( EMediaRam == MediaType() ) |
|
872 { |
|
873 TRAP(err,RepositoryUtil::GetRepositoryKeyL(KCRUidDiskLevel, |
|
874 KRamDiskCriticalLevel,criticalspace)); |
|
875 } |
|
876 else |
|
877 { |
|
878 TRAP(err,RepositoryUtil::GetRepositoryKeyL(KCRUidDiskLevel, |
|
879 KDiskCriticalThreshold,criticalspace)); |
|
880 } |
|
881 } |
|
882 else |
|
883 { |
|
884 criticalspace = iCriticalSpace; |
|
885 } |
|
886 |
|
887 return ( (KErrNone == err) ? criticalspace : err); |
|
888 } |
|
889 |
|
890 // -------------------------------------------------------------------- |
|
891 // CDriveInfo::MediaType |
|
892 // returns drive media type. |
|
893 // -------------------------------------------------------------------- |
|
894 // |
|
895 EXPORT_C TInt CDriveInfo::MediaType() const |
|
896 { |
|
897 return iVolumeInfo.iDrive.iType; |
|
898 } |
|
899 |
|
900 // -------------------------------------------------------------------- |
|
901 // CDriveInfo::TotalSpace |
|
902 // returns total space on this drive. |
|
903 // -------------------------------------------------------------------- |
|
904 // |
|
905 EXPORT_C TInt64 CDriveInfo::TotalSpace() const |
|
906 { |
|
907 return iVolumeInfo.iSize; |
|
908 } |
|
909 |
|
910 // -------------------------------------------------------------------- |
|
911 // CDriveInfo::FreeSpace |
|
912 // returns free space on this drive. |
|
913 // -------------------------------------------------------------------- |
|
914 // |
|
915 EXPORT_C TInt64 CDriveInfo::FreeSpace() const |
|
916 { |
|
917 return iVolumeInfo.iFree; |
|
918 } |
|
919 |
|
920 // -------------------------------------------------------------------- |
|
921 // CDriveInfo::DriveName |
|
922 // On return aDriveName consists name of the drive. |
|
923 // -------------------------------------------------------------------- |
|
924 // |
|
925 EXPORT_C void CDriveInfo::DriveName(TPtrC& aDriveName) const |
|
926 { |
|
927 aDriveName.Set(iVolumeInfo.iName); |
|
928 } |
|
929 |
|
930 // -------------------------------------------------------------------- |
|
931 // CDriveInfo::DriveName |
|
932 // returns battery state of this drive. |
|
933 // -------------------------------------------------------------------- |
|
934 // |
|
935 EXPORT_C TInt CDriveInfo::BatteryState() const |
|
936 { |
|
937 return iVolumeInfo.iDrive.iBattery; |
|
938 } |
|
939 |
|
940 // -------------------------------------------------------------------- |
|
941 // CConnectionList::CConnectionList() |
|
942 // Constructor. |
|
943 // -------------------------------------------------------------------- |
|
944 // |
|
945 CConnectionList::CConnectionList():CSysData(EConnectionList) |
|
946 { |
|
947 } |
|
948 |
|
949 // -------------------------------------------------------------------- |
|
950 // CConnectionList::~CConnectionList() |
|
951 // Destructor |
|
952 // -------------------------------------------------------------------- |
|
953 // |
|
954 CConnectionList::~CConnectionList() |
|
955 { |
|
956 iConnectionInfoArray.ResetAndDestroy(); |
|
957 iConnectionInfoArray.Close(); |
|
958 } |
|
959 |
|
960 // -------------------------------------------------------------------- |
|
961 // CConnectionList::NewL() |
|
962 // Two-phased constructor. returns new instance of this class. |
|
963 // -------------------------------------------------------------------- |
|
964 // |
|
965 CConnectionList* CConnectionList::NewL( |
|
966 RPointerArray<CConnectionInfo>& aConnectionInfoArr) |
|
967 { |
|
968 CConnectionList* self = CConnectionList::NewLC(aConnectionInfoArr); |
|
969 CleanupStack::Pop(self); |
|
970 return self; |
|
971 } |
|
972 |
|
973 // -------------------------------------------------------------------- |
|
974 // CConnectionList::NewLC() |
|
975 // Two-phased constructor. returns new instance of this class. |
|
976 // -------------------------------------------------------------------- |
|
977 // |
|
978 CConnectionList* CConnectionList::NewLC( |
|
979 RPointerArray<CConnectionInfo>& aConnectionInfoArr) |
|
980 { |
|
981 CConnectionList* self = new (ELeave) CConnectionList(); |
|
982 CleanupStack::PushL(self); |
|
983 self->ConstructL(aConnectionInfoArr); |
|
984 return self; |
|
985 } |
|
986 |
|
987 // -------------------------------------------------------------------- |
|
988 // CConnectionList::ConstructL() |
|
989 // 2nd phase construtor |
|
990 // -------------------------------------------------------------------- |
|
991 // |
|
992 void CConnectionList::ConstructL( |
|
993 RPointerArray<CConnectionInfo>& aConnectionInfoArr) |
|
994 { |
|
995 iCount = aConnectionInfoArr.Count(); |
|
996 //Make a copy of available ConnectionInfo pointers. |
|
997 if(iCount > 0) |
|
998 { |
|
999 for(TInt index = 0 ; index < iCount; index++) |
|
1000 { |
|
1001 iConnectionInfoArray.AppendL(aConnectionInfoArr[index]); |
|
1002 } |
|
1003 } |
|
1004 } |
|
1005 |
|
1006 // -------------------------------------------------------------------- |
|
1007 // CConnectionList::At() |
|
1008 // On return aConnectionInfo contains connection information. |
|
1009 // -------------------------------------------------------------------- |
|
1010 // |
|
1011 EXPORT_C TBool CConnectionList::At(TInt aIndex, |
|
1012 const CConnectionInfo*& aConnectionInfo) const |
|
1013 { |
|
1014 if( 0 <= aIndex && aIndex<iCount ) |
|
1015 { |
|
1016 aConnectionInfo = iConnectionInfoArray[aIndex]; |
|
1017 return ETrue; |
|
1018 } |
|
1019 return EFalse; |
|
1020 } |
|
1021 |
|
1022 // -------------------------------------------------------------------- |
|
1023 // CConnectionList::[] |
|
1024 // gets CConnectionInfo at specified index. |
|
1025 // -------------------------------------------------------------------- |
|
1026 // |
|
1027 EXPORT_C const CConnectionInfo* CConnectionList::operator[](TInt aIndex) const |
|
1028 { |
|
1029 return iConnectionInfoArray[aIndex]; |
|
1030 } |
|
1031 |
|
1032 // -------------------------------------------------------------------- |
|
1033 // CConnectionList::Count() |
|
1034 // returns number of connections. |
|
1035 // -------------------------------------------------------------------- |
|
1036 // |
|
1037 EXPORT_C TInt CConnectionList::Count() const |
|
1038 { |
|
1039 return iCount; |
|
1040 } |
|
1041 |
|
1042 // -------------------------------------------------------------------- |
|
1043 // CConnectionInfo::CConnectionInfo() |
|
1044 // Constructor. |
|
1045 // -------------------------------------------------------------------- |
|
1046 // |
|
1047 CConnectionInfo::CConnectionInfo():CSysData(EConnectionInfo) |
|
1048 { |
|
1049 } |
|
1050 |
|
1051 // -------------------------------------------------------------------- |
|
1052 // CConnectionInfo::~CConnectionInfo() |
|
1053 // Destructor |
|
1054 // -------------------------------------------------------------------- |
|
1055 // |
|
1056 CConnectionInfo::~CConnectionInfo() |
|
1057 { |
|
1058 delete iIAPName; |
|
1059 delete iNetworkName; |
|
1060 delete iConnectionName; |
|
1061 } |
|
1062 |
|
1063 // -------------------------------------------------------------------- |
|
1064 // CConnectionInfo::CopyL() |
|
1065 // Creates new copy of the connectionInfo |
|
1066 // -------------------------------------------------------------------- |
|
1067 // |
|
1068 CConnectionInfo* CConnectionInfo::CopyL() |
|
1069 { |
|
1070 CConnectionInfo* self = new (ELeave) CConnectionInfo(); |
|
1071 CleanupStack::PushL(self); |
|
1072 |
|
1073 self->ConstructL(iConnectionId, iIAPId, iBearerType, iConnectStatus, |
|
1074 *iIAPName, *iNetworkName, *iConnectionName); |
|
1075 |
|
1076 CleanupStack::Pop(self); |
|
1077 return self; |
|
1078 } |
|
1079 |
|
1080 // -------------------------------------------------------------------- |
|
1081 // CConnectionInfo::NewL() |
|
1082 // Two-phased constructor. returns new instance of this class. |
|
1083 // -------------------------------------------------------------------- |
|
1084 // |
|
1085 CConnectionInfo* CConnectionInfo::NewL(TUint aConnId, TUint aIAPId, |
|
1086 TInt aBearerType, |
|
1087 TConnectionState aConnectState, |
|
1088 const TDesC& aIAPName, |
|
1089 const TDesC& aNetworkName, |
|
1090 const TDesC& aConnectionName) |
|
1091 { |
|
1092 CConnectionInfo* self = new (ELeave) CConnectionInfo(); |
|
1093 CleanupStack::PushL(self); |
|
1094 self->ConstructL(aConnId, aIAPId, aBearerType, aConnectState, aIAPName, |
|
1095 aNetworkName, aConnectionName); |
|
1096 CleanupStack::Pop(self); |
|
1097 return self; |
|
1098 } |
|
1099 |
|
1100 // -------------------------------------------------------------------- |
|
1101 // CConnectionInfo::ConstructL() |
|
1102 // 2nd phase construtor |
|
1103 // -------------------------------------------------------------------- |
|
1104 // |
|
1105 void CConnectionInfo::ConstructL(TUint aConnId,TUint aIAPId, |
|
1106 TInt aBearerType, |
|
1107 TConnectionState aConnectState, |
|
1108 const TDesC& aIAPName, |
|
1109 const TDesC& aNetworkName, |
|
1110 const TDesC& aConnectionName) |
|
1111 { |
|
1112 iConnectionId = aConnId; |
|
1113 iIAPId = aIAPId; |
|
1114 iBearerType = aBearerType; |
|
1115 iConnectStatus = aConnectState; |
|
1116 iIAPName = aIAPName.AllocL(); |
|
1117 iNetworkName = aNetworkName.AllocL(); |
|
1118 iConnectionName = aConnectionName.AllocL(); |
|
1119 } |
|
1120 |
|
1121 // -------------------------------------------------------------------- |
|
1122 // CConnectionInfo::IAPId() |
|
1123 // returns IAP ID. |
|
1124 // -------------------------------------------------------------------- |
|
1125 // |
|
1126 EXPORT_C TUint CConnectionInfo::IAPId() const |
|
1127 { |
|
1128 return iIAPId; |
|
1129 } |
|
1130 |
|
1131 // -------------------------------------------------------------------- |
|
1132 // CConnectionInfo::ConnectionState() |
|
1133 // returns Connection State. |
|
1134 // -------------------------------------------------------------------- |
|
1135 // |
|
1136 EXPORT_C CConnectionInfo::TConnectionState CConnectionInfo::ConnectionState() |
|
1137 const |
|
1138 { |
|
1139 return iConnectStatus; |
|
1140 } |
|
1141 |
|
1142 // -------------------------------------------------------------------- |
|
1143 // CConnectionInfo::SetConnectionState() |
|
1144 // changes connection state. |
|
1145 // -------------------------------------------------------------------- |
|
1146 // |
|
1147 void CConnectionInfo::SetConnectionState( |
|
1148 CConnectionInfo::TConnectionState aState) |
|
1149 { |
|
1150 iConnectStatus = aState; |
|
1151 } |
|
1152 |
|
1153 // -------------------------------------------------------------------- |
|
1154 // CConnectionInfo::ConnectionId() |
|
1155 // returns iConnection ID. |
|
1156 // -------------------------------------------------------------------- |
|
1157 // |
|
1158 TUint CConnectionInfo::ConnectionId() const |
|
1159 { |
|
1160 return iConnectionId; |
|
1161 } |
|
1162 |
|
1163 // -------------------------------------------------------------------- |
|
1164 // CConnectionInfo::BearerType() |
|
1165 // returns BearerType. |
|
1166 // -------------------------------------------------------------------- |
|
1167 // |
|
1168 EXPORT_C TInt CConnectionInfo::BearerType() const |
|
1169 { |
|
1170 return iBearerType-1; |
|
1171 } |
|
1172 |
|
1173 // -------------------------------------------------------------------- |
|
1174 // CConnectionInfo::IAPName() |
|
1175 // returns IAP Name. |
|
1176 // -------------------------------------------------------------------- |
|
1177 // |
|
1178 EXPORT_C TPtrC CConnectionInfo::IAPName() const |
|
1179 { |
|
1180 return TPtrC(*iIAPName); |
|
1181 } |
|
1182 |
|
1183 // -------------------------------------------------------------------- |
|
1184 // CConnectionInfo::NetworkName() |
|
1185 // returns Network Name. |
|
1186 // -------------------------------------------------------------------- |
|
1187 // |
|
1188 EXPORT_C TPtrC CConnectionInfo::NetworkName() const |
|
1189 { |
|
1190 return TPtrC(*iNetworkName); |
|
1191 } |
|
1192 |
|
1193 // -------------------------------------------------------------------- |
|
1194 // CConnectionInfo::ConnectionName() |
|
1195 // returns Connection Name. |
|
1196 // -------------------------------------------------------------------- |
|
1197 // |
|
1198 EXPORT_C TPtrC CConnectionInfo::ConnectionName() const |
|
1199 { |
|
1200 return TPtrC(*iConnectionName); |
|
1201 } |
|
1202 |
|
1203 // End of file. |