1 /* |
|
2 * Copyright (c) 2009-2010 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: Network registration status handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "nwregistrationstatushandler.h" |
|
20 #include "locationmanagerdebug.h" |
|
21 |
|
22 |
|
23 // ---------------------------------------------------------------------------- |
|
24 // CNwRegistrationStatusHandler::CNwRegistrationStatusHandler() |
|
25 // ---------------------------------------------------------------------------- |
|
26 CNwRegistrationStatusHandler::CNwRegistrationStatusHandler(RMobilePhone& aMobilePhone): |
|
27 CActive(EPriorityStandard ), |
|
28 iMobilePhone(aMobilePhone), |
|
29 iRegistrationStatus(RMobilePhone::ERegistrationUnknown), |
|
30 iState(ERegStatusOptStateNone) |
|
31 { |
|
32 } |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CNwRegistrationStatusHandler::~CNwRegistrationStatusHandler() |
|
36 // ---------------------------------------------------------------------------- |
|
37 CNwRegistrationStatusHandler::~CNwRegistrationStatusHandler() |
|
38 { |
|
39 LOG("CNwRegistrationStatusHandler::~CNwRegistrationStatusHandler"); |
|
40 Cancel(); |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CNwRegistrationStatusHandler::NewL() |
|
45 // ---------------------------------------------------------------------------- |
|
46 CNwRegistrationStatusHandler* CNwRegistrationStatusHandler::NewL(RMobilePhone& aMobilePhone) |
|
47 { |
|
48 LOG("CNwRegistrationStatusHandler::NewL ,begin"); |
|
49 CNwRegistrationStatusHandler* self = new( ELeave ) CNwRegistrationStatusHandler(aMobilePhone); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(); //self |
|
53 |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CNwRegistrationStatusHandler::ConstructL() |
|
59 // ---------------------------------------------------------------------------- |
|
60 void CNwRegistrationStatusHandler::ConstructL() |
|
61 { |
|
62 LOG("CNwRegistrationStatusHandler::ConstructL ,begin"); |
|
63 CActiveScheduler::Add(this); |
|
64 iMobilePhone.GetNetworkRegistrationStatus(iStatus, iRegistrationStatus); |
|
65 iState = ERegStatusOptStateGet; |
|
66 SetActive(); |
|
67 LOG("CNwRegistrationStatusHandler::ConstructL ,end"); |
|
68 } |
|
69 |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CNwRegistrationStatusHandler::GetNetworkRegistrationStatus() |
|
73 // ---------------------------------------------------------------------------- |
|
74 RMobilePhone::TMobilePhoneRegistrationStatus CNwRegistrationStatusHandler::GetNetworkRegistrationStatus() const |
|
75 { |
|
76 return iRegistrationStatus; |
|
77 } |
|
78 |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CNwRegistrationStatusHandler::StartNotifier() |
|
82 // ---------------------------------------------------------------------------- |
|
83 void CNwRegistrationStatusHandler::StartNotifier() |
|
84 { |
|
85 LOG("CNwRegistrationStatusHandler::StartNotifier ,begin"); |
|
86 if(!IsActive()) |
|
87 { |
|
88 iState = ERegStatusOptStateNotify; |
|
89 iMobilePhone.NotifyNetworkRegistrationStatusChange(iStatus, iRegistrationStatus); |
|
90 SetActive(); |
|
91 } |
|
92 else |
|
93 { |
|
94 // already active. |
|
95 LOG("N/W registration status handler already active"); |
|
96 } |
|
97 LOG("CNwRegistrationStatusHandler::StartNotifier ,end"); |
|
98 } |
|
99 |
|
100 // ---------------------------------------------------------------------------- |
|
101 // CNwRegistrationStatusHandler::RunL() |
|
102 // ---------------------------------------------------------------------------- |
|
103 void CNwRegistrationStatusHandler::RunL( ) |
|
104 { |
|
105 LOG("CNwRegistrationStatusHandler::RunL"); |
|
106 LOG1("Status - %d", iStatus.Int()); |
|
107 StartNotifier(); |
|
108 } |
|
109 |
|
110 // ---------------------------------------------------------------------------- |
|
111 // CNwRegistrationStatusHandler::DoCancel() |
|
112 // ---------------------------------------------------------------------------- |
|
113 void CNwRegistrationStatusHandler::DoCancel( ) |
|
114 { |
|
115 LOG("CNwRegistrationStatusHandler::DoCancel"); |
|
116 switch(iState) |
|
117 { |
|
118 case ERegStatusOptStateGet: |
|
119 { |
|
120 iMobilePhone.CancelAsyncRequest(EMobilePhoneGetNetworkRegistrationStatus); |
|
121 break; |
|
122 } |
|
123 case ERegStatusOptStateNotify: |
|
124 { |
|
125 iMobilePhone.CancelAsyncRequest(EMobilePhoneNotifyNetworkRegistrationStatusChange); |
|
126 break; |
|
127 } |
|
128 default: |
|
129 // execution shouldn't come over here |
|
130 LOG1("CNwRegistrationStatusHandler::DoCancel, in wrong state - %d", iState); |
|
131 break; |
|
132 } |
|
133 } |
|
134 |
|
135 |
|
136 // End of file |
|
137 |
|