1 // Copyright (c) 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 // CATGetModemStatus |
|
15 // Description: |
|
16 // CATNetworkRegistration |
|
17 |
|
18 #include <et_phone.h> |
|
19 |
|
20 #include "atgetnetworkregistrationstatus.h" |
|
21 #include "mslogger.h" |
|
22 #include "atnetworkregstatuschange.h" |
|
23 |
|
24 |
|
25 _LIT8(KATGetNetworkRegCommand, "AT+CREG?\r"); |
|
26 _LIT8(KATGetNetworkRegResponse,"+CREG:"); |
|
27 // Class CATNetworkRegistration |
|
28 // --------------------------------------------------------------------------- |
|
29 // CATNetworkRegistration::NewL |
|
30 // other items were commented in a header |
|
31 // --------------------------------------------------------------------------- |
|
32 CATNetworkRegistration* CATNetworkRegistration::NewL(CGlobalPhonemanager& aGloblePhone, |
|
33 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
34 { |
|
35 CATNetworkRegistration* self = new(ELeave) CATNetworkRegistration(aGloblePhone, |
|
36 aCtsyDispatcherCallback); |
|
37 CleanupStack::PushL(self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self ); |
|
40 return self ; |
|
41 } |
|
42 // --------------------------------------------------------------------------- |
|
43 // CATNetworkRegistration::NewL |
|
44 // other items were commented in a header |
|
45 // --------------------------------------------------------------------------- |
|
46 CATNetworkRegistration::CATNetworkRegistration(CGlobalPhonemanager& aGloblePhone, |
|
47 CCtsyDispatcherCallback& aCtsyDispatcherCallback) |
|
48 :CAtCommandBase(aGloblePhone,aCtsyDispatcherCallback) |
|
49 { |
|
50 } |
|
51 // --------------------------------------------------------------------------- |
|
52 // CATNetworkRegistration::ConstructL |
|
53 // other items were commented in a header |
|
54 // --------------------------------------------------------------------------- |
|
55 void CATNetworkRegistration::ConstructL() |
|
56 { |
|
57 CAtCommandBase::ConstructL(); |
|
58 iAtType = ELtsyAT_Phone_NwkRegStatus; |
|
59 } |
|
60 // --------------------------------------------------------------------------- |
|
61 // CATNetworkRegistration::~CATNetworkRegistration |
|
62 // other items were commented in a header |
|
63 // --------------------------------------------------------------------------- |
|
64 CATNetworkRegistration::~CATNetworkRegistration() |
|
65 { |
|
66 } |
|
67 // --------------------------------------------------------------------------- |
|
68 // CATNetworkRegistration::StartRequestL |
|
69 // other items were commented in a header |
|
70 // --------------------------------------------------------------------------- |
|
71 void CATNetworkRegistration::StartRequest() |
|
72 { |
|
73 ExecuteCommand(); |
|
74 } |
|
75 // --------------------------------------------------------------------------- |
|
76 // CATNetworkRegistration::ExecuteCommand |
|
77 // other items were commented in a header |
|
78 // --------------------------------------------------------------------------- |
|
79 void CATNetworkRegistration::ExecuteCommand() |
|
80 { |
|
81 iTxBuffer.Copy(KATGetNetworkRegCommand); |
|
82 Write(); |
|
83 } |
|
84 // --------------------------------------------------------------------------- |
|
85 // CATNetworkRegistration::GetErrorValue |
|
86 // other items were commented in a header |
|
87 // --------------------------------------------------------------------------- |
|
88 TInt CATNetworkRegistration::GetErrorValue() |
|
89 { |
|
90 return iError; |
|
91 } |
|
92 /** |
|
93 * This method parses the modems response to the 'AT+CGREG?' command. |
|
94 * An example response is '+CGREG: 0,1' where second value denotes the |
|
95 * current registration status. |
|
96 */ |
|
97 // --------------------------------------------------------------------------- |
|
98 // CATNetworkRegistration::ParseResponseL |
|
99 // other items were commented in a header |
|
100 // --------------------------------------------------------------------------- |
|
101 void CATNetworkRegistration::ParseResponseL(const TDesC8& /*aResponseBuf*/) |
|
102 { |
|
103 if (CurrentLine().Match(KLtsyOkString) != 0) |
|
104 { |
|
105 iError = KErrGeneral; |
|
106 return ; |
|
107 } |
|
108 RArray<TPtrC8> array; |
|
109 CleanupClosePushL(array); |
|
110 iParser->ParseRespondedBuffer(array,PrecedingLine()); |
|
111 TInt Count = array.Count(); |
|
112 if (Count < 1) |
|
113 { |
|
114 CleanupStack::PopAndDestroy(); |
|
115 iError = KErrNotFound; |
|
116 return ; |
|
117 } |
|
118 if( array[0].MatchF(KATGetNetworkRegResponse)==KErrNotFound) |
|
119 { |
|
120 CleanupStack::PopAndDestroy(); |
|
121 iError = KErrNotFound; |
|
122 return ; |
|
123 } |
|
124 // Skip over one parameter |
|
125 |
|
126 TInt val = 0; |
|
127 TLex8 lex(array[2]); |
|
128 lex.Val(val); |
|
129 // Convert scond value to equivalent EtelMM enum |
|
130 switch(val) |
|
131 { |
|
132 case 0: |
|
133 iRegistrationStatus = RMobilePhone::ENotRegisteredNoService; |
|
134 break; |
|
135 case 1: |
|
136 iRegistrationStatus = RMobilePhone::ERegisteredOnHomeNetwork; |
|
137 break; |
|
138 case 2: |
|
139 iRegistrationStatus = RMobilePhone::ENotRegisteredSearching; |
|
140 break; |
|
141 case 3: |
|
142 iRegistrationStatus = RMobilePhone::ERegistrationDenied; |
|
143 break; |
|
144 case 4: |
|
145 iRegistrationStatus = RMobilePhone::ERegistrationUnknown; |
|
146 break; |
|
147 case 5: |
|
148 iRegistrationStatus = RMobilePhone::ERegisteredRoaming; |
|
149 break; |
|
150 default: |
|
151 iRegistrationStatus = RMobilePhone::ERegistrationUnknown; |
|
152 break; |
|
153 } |
|
154 iPhoneGlobals.iPhoneStatus.iRegistrationStatus = iRegistrationStatus; |
|
155 CleanupStack::PopAndDestroy(&array); |
|
156 iError = KErrNone; |
|
157 } //ParseResponseL |
|
158 // --------------------------------------------------------------------------- |
|
159 // CATNetworkRegistration::EventSignal |
|
160 // other items were commented in a header |
|
161 // --------------------------------------------------------------------------- |
|
162 void CATNetworkRegistration::EventSignal(TAtEventSource aEventSource, TInt aStatus) |
|
163 { |
|
164 if(KErrNone ==aStatus) |
|
165 { |
|
166 if(aEventSource == EReadCompletion) |
|
167 { |
|
168 aStatus = iError; |
|
169 } |
|
170 else |
|
171 return; |
|
172 } |
|
173 CAtCommandBase::Complete(); |
|
174 iPhoneGlobals.iEventSignalActive = EFalse; |
|
175 iCtsyDispatcherCallback.CallbackPhoneGetNetworkRegistrationStatusComp(aStatus,iRegistrationStatus); |
|
176 if(iIpcCompleteObserver) |
|
177 { |
|
178 iIpcCompleteObserver->NotifyIpcRequestComplete(iIpcId); |
|
179 } |
|
180 } |
|
181 // |
|
182 // End of file |
|