|
1 /* |
|
2 * Copyright (c) 2006-2009 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 "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: A class for getting network cell id. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <etel3rdparty.h> |
|
19 |
|
20 #include "cnetworkinfo.h" |
|
21 #include "locationmanagerdebug.h" |
|
22 |
|
23 // -------------------------------------------------------------------------- |
|
24 // CNetworkInfo::NewL |
|
25 // -------------------------------------------------------------------------- |
|
26 // |
|
27 EXPORT_C CNetworkInfo* CNetworkInfo::NewL( MNetworkInfoObserver* aTrail ) |
|
28 { |
|
29 LOG( "CNetworkInfo::NewL(), begin" ); |
|
30 CNetworkInfo* self = new (ELeave) CNetworkInfo( aTrail ); |
|
31 CleanupStack::PushL( self ); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop( self ); |
|
34 LOG( "CNetworkInfo::NewL(), end" ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // -------------------------------------------------------------------------- |
|
39 // CNetworkInfo::CNetworkInfo |
|
40 // -------------------------------------------------------------------------- |
|
41 // |
|
42 CNetworkInfo::CNetworkInfo( MNetworkInfoObserver* aTrail ) |
|
43 : CActive( CActive::EPriorityStandard ), |
|
44 iFirstTime( EFalse ), |
|
45 iTelephony( NULL ), |
|
46 iNetworkInfoV1Pckg( iNetworkInfoV1 ) |
|
47 { |
|
48 CActiveScheduler::Add( this ); |
|
49 iTrail = aTrail; |
|
50 } |
|
51 |
|
52 // -------------------------------------------------------------------------- |
|
53 // CNetworkInfo::ConstructL |
|
54 // -------------------------------------------------------------------------- |
|
55 // |
|
56 void CNetworkInfo::ConstructL() |
|
57 { |
|
58 LOG( "CNetworkInfo::ConstructL(), begin" ); |
|
59 iFirstTime = ETrue; |
|
60 iTelephony = CTelephony::NewL(); |
|
61 iTelephony->GetCurrentNetworkInfo(iStatus, iNetworkInfoV1Pckg); |
|
62 LOG( "CNetworkInfo::ConstructL(), iTelephony->GetCurrentNetworkInfo called" ); |
|
63 |
|
64 if ( IsActive() ) |
|
65 { |
|
66 Cancel(); |
|
67 } |
|
68 SetActive(); |
|
69 |
|
70 LOG( "CNetworkInfo::ConstructL(), end" ); |
|
71 } |
|
72 |
|
73 // -------------------------------------------------------------------------- |
|
74 // CNetworkInfo::~CNetworkInfo |
|
75 // -------------------------------------------------------------------------- |
|
76 // |
|
77 CNetworkInfo::~CNetworkInfo() |
|
78 { |
|
79 Cancel(); |
|
80 delete iTelephony; |
|
81 } |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // CNetworkInfo::RunError |
|
85 // -------------------------------------------------------------------------- |
|
86 // |
|
87 TInt CNetworkInfo::RunError( TInt /*aError*/ ) |
|
88 { |
|
89 return KErrNone; |
|
90 } |
|
91 |
|
92 // -------------------------------------------------------------------------- |
|
93 // CNetworkInfo::RunL |
|
94 // -------------------------------------------------------------------------- |
|
95 // |
|
96 void CNetworkInfo::RunL() |
|
97 { |
|
98 LOG( "CNetworkInfo::RunL(), begin" ); |
|
99 iFirstTime = EFalse; |
|
100 iTrail->NetworkInfo( iNetworkInfoV1, iStatus.Int() ); |
|
101 LOG( "CNetworkInfo::RunL(), iTrail->NetworkInfo called" ); |
|
102 |
|
103 iTelephony->NotifyChange(iStatus, CTelephony::ECurrentNetworkInfoChange, iNetworkInfoV1Pckg); |
|
104 LOG( "CNetworkInfo::RunL(), iTelephony->NotifyChange called" ); |
|
105 |
|
106 if ( IsActive() ) |
|
107 { |
|
108 Cancel(); |
|
109 } |
|
110 SetActive(); |
|
111 |
|
112 LOG( "CNetworkInfo::RunL(), end" ); |
|
113 } |
|
114 |
|
115 // -------------------------------------------------------------------------- |
|
116 // CNetworkInfo::DoCancel |
|
117 // -------------------------------------------------------------------------- |
|
118 // |
|
119 void CNetworkInfo::DoCancel() |
|
120 { |
|
121 LOG( "CNetworkInfo::DoCancel(), begin" ); |
|
122 if ( IsActive() ) |
|
123 { |
|
124 if ( iFirstTime ) |
|
125 { |
|
126 LOG( "CNetworkInfo::DoCancel(), cancelling CTelephony::EGetCurrentNetworkInfoCancel" ); |
|
127 iTelephony->CancelAsync( CTelephony::EGetCurrentNetworkInfoCancel ); |
|
128 } |
|
129 else |
|
130 { |
|
131 LOG( "CNetworkInfo::DoCancel(), cancelling CTelephony::ECurrentNetworkInfoChangeCancel" ); |
|
132 iTelephony->CancelAsync( CTelephony::ECurrentNetworkInfoChangeCancel ); |
|
133 } |
|
134 } |
|
135 LOG( "CNetworkInfo::DoCancel(), end" ); |
|
136 } |
|
137 |
|
138 // End of file |