|
1 // Copyright (c) 2001-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 // |
|
15 |
|
16 #include <et_phone.h> // for CTelObject class |
|
17 #include "Gprscontext.h" // for CGprsContext |
|
18 #include "atgprscontextdelete.h" // header file for this source file |
|
19 #include "mSLOGGER.H" // for LOGTEXT macros |
|
20 #include "ATIO.H" // for CATIO |
|
21 #include "Matstd.h" // for AT command strings, and other stuff |
|
22 #include "NOTIFY.H" // for CNotifications |
|
23 |
|
24 const TUint KWriteTimeout=10000; // Is in milli seconds |
|
25 const TInt KReadTimeout=10; // Is in seconds |
|
26 |
|
27 // |
|
28 // Macro for logging text to the log file using the local class name and a simpler |
|
29 // call style. |
|
30 #ifdef __LOGDEB__ |
|
31 _LIT8(KLogEntry,"CATGprsContextDelete::%S\t%S"); |
|
32 #define LOCAL_LOGTEXT(function,text) {_LIT8(F,function);_LIT8(T,text);LOGTEXT3(KLogEntry,&F,&T);} |
|
33 #else |
|
34 #define LOCAL_LOGTEXT(function,text) |
|
35 #endif |
|
36 |
|
37 |
|
38 /** |
|
39 * @file |
|
40 * AT state machine which will send AT+CGDCONT=x to delete a context from the phone. |
|
41 */ |
|
42 |
|
43 CATGprsContextDelete* CATGprsContextDelete::NewL(CATIO* aIo, CTelObject* aTelObject, CATInit* aInit, CPhoneGlobals* aPhoneGlobals ) |
|
44 /** |
|
45 * Factory function. |
|
46 */ |
|
47 { |
|
48 CATGprsContextDelete* p =new(ELeave) CATGprsContextDelete(aIo, aTelObject, aInit, aPhoneGlobals); |
|
49 CleanupStack::PushL(p); |
|
50 p->ConstructL(); // We call this to allow our base class to construct |
|
51 CleanupStack::Pop(); |
|
52 return p; |
|
53 } |
|
54 |
|
55 |
|
56 CATGprsContextDelete::CATGprsContextDelete(CATIO* aIo, CTelObject* aTelObject, CATInit* aInit, CPhoneGlobals* aPhoneGlobals) |
|
57 : CATCommands(aIo, aTelObject, aInit, aPhoneGlobals) |
|
58 /** |
|
59 * C++ constructor. |
|
60 */ |
|
61 { |
|
62 } |
|
63 |
|
64 CATGprsContextDelete::~CATGprsContextDelete() |
|
65 /** |
|
66 * C++ Destructor. |
|
67 */ |
|
68 { |
|
69 iIo->RemoveExpectStrings(this); |
|
70 } |
|
71 |
|
72 void CATGprsContextDelete::Stop(TTsyReqHandle /*aTsyReqHandle*/) |
|
73 /** |
|
74 * This function called by CATCommands to cancel an AT command state machine. |
|
75 * This AT command state machine can not be cancelled. |
|
76 */ |
|
77 { |
|
78 LOCAL_LOGTEXT("Stop","Enter function"); |
|
79 LOCAL_LOGTEXT("Stop","This functionality is not supported"); |
|
80 } |
|
81 |
|
82 |
|
83 void CATGprsContextDelete::Start(TTsyReqHandle aTsyReqHandle, TAny* aDummy) |
|
84 /** |
|
85 * Starting of the state machine. |
|
86 * |
|
87 * This will be called by CATCommands::ExecuteCommand to start the sending |
|
88 * of the AT commands. |
|
89 */ |
|
90 { |
|
91 LOCAL_LOGTEXT("Start","Enter function"); |
|
92 const TInt index=*(static_cast<TInt*>(aDummy)); |
|
93 LOGTEXT2(_L8("index=%d"),index); |
|
94 |
|
95 iReqHandle=aTsyReqHandle; |
|
96 |
|
97 // |
|
98 // Send the AT+CGDCONT=x command to the phone |
|
99 iTxBuffer.Format(KDeleteContextCommand,index); |
|
100 iIo->Write(this,iTxBuffer); |
|
101 iIo->SetTimeOut(this,KWriteTimeout); |
|
102 iState=EWaitForWrite; |
|
103 } |
|
104 |
|
105 |
|
106 void CATGprsContextDelete::EventSignal(TEventSource aSource) |
|
107 /** |
|
108 * Main part of the state machine |
|
109 */ |
|
110 { |
|
111 LOCAL_LOGTEXT("EventSignal","Enter function"); |
|
112 |
|
113 if (aSource==ETimeOutCompletion) |
|
114 { |
|
115 LOCAL_LOGTEXT("EventSignal","Timeout error"); |
|
116 Complete(KErrTimedOut,aSource); |
|
117 return; |
|
118 } |
|
119 |
|
120 switch(iState) |
|
121 { |
|
122 case EWaitForWrite: |
|
123 __ASSERT_DEBUG(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected)); |
|
124 iIo->WriteAndTimerCancel(this); |
|
125 StandardWriteCompletionHandler(aSource,KReadTimeout); |
|
126 iState=EWaitForRead; |
|
127 break; |
|
128 |
|
129 case EWaitForRead: |
|
130 __ASSERT_DEBUG(aSource==EReadCompletion,Panic(EATCommand_IllegalCompletionWaitExpected)); |
|
131 iIo->WriteAndTimerCancel(this); |
|
132 // There is no need to validate the response from the modem |
|
133 // as we are going to ignore it anyway. |
|
134 Complete(KErrNone,aSource); |
|
135 break; |
|
136 |
|
137 case EIdle: |
|
138 break; |
|
139 } |
|
140 } |
|
141 |
|
142 |
|
143 void CATGprsContextDelete::CompleteWithIOError(TEventSource aSource,TInt aStatus) |
|
144 /** |
|
145 * This Function completes the command from the client with an error. |
|
146 */ |
|
147 { |
|
148 Complete(aStatus,aSource); |
|
149 } |
|
150 |
|
151 |
|
152 void CATGprsContextDelete::Complete(TInt aError,TEventSource aSource) |
|
153 { |
|
154 LOCAL_LOGTEXT("Complete","Enter function"); |
|
155 |
|
156 if(aError==KErrNone) |
|
157 { |
|
158 // |
|
159 // Mark the context as deleted in the TSY |
|
160 CGprsContext* contextPtr=static_cast<CGprsContext*>(iTelObject); |
|
161 RPacketService::TContextInfo contextInfo; |
|
162 contextPtr->ContextInfo(&contextInfo); |
|
163 contextInfo.iStatus = RPacketContext::EStatusDeleted; |
|
164 contextPtr->SetContextInfo(&contextInfo); |
|
165 |
|
166 // |
|
167 // Update the notifications |
|
168 iPhoneGlobals->iNotificationStore->CheckNotification(iTelObject, EPacketContextStatusChanged); |
|
169 } |
|
170 |
|
171 // |
|
172 // Cleanup the CATIO stuff |
|
173 RemoveStdExpectStrings(); // We have to call this to ensure iOKExpectString & iErrorExpectString are NULLed |
|
174 iIo->WriteAndTimerCancel(this); |
|
175 iIo->RemoveExpectStrings(this); |
|
176 |
|
177 // |
|
178 // Allow base class chance to start of AT commands and complete our client request |
|
179 CATCommands::Complete(aError,aSource); |
|
180 iTelObject->ReqCompleted(iReqHandle, aError); |
|
181 |
|
182 iState = EIdle; |
|
183 } |
|
184 |
|
185 |
|
186 |
|
187 |