24
|
1 |
// Copyright (c) 1997-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 "smspdel.h"
|
|
17 |
#include "smspmain.h"
|
|
18 |
|
|
19 |
#include "smsuset.h"
|
|
20 |
|
|
21 |
#include <exterror.h>
|
|
22 |
#include "SmsuTimer.h"
|
|
23 |
#include "smspqueue.h"
|
|
24 |
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Creates new CSmsStoreRead instance
|
|
28 |
*
|
|
29 |
* @param aSmsComm reference to the MSmsComm class
|
|
30 |
* @param aSmsSettings reference to the TSmsSettings class
|
|
31 |
* @param aSmsMessaging reference to the RMobileSmsMessaging class
|
|
32 |
*/
|
|
33 |
CSmsPDUDelete* CSmsPDUDelete::NewL(const TSmsSettings& aSmsSettings,
|
|
34 |
RMobileSmsMessaging& aSmsMessaging
|
|
35 |
)
|
|
36 |
{
|
|
37 |
LOGSMSPROT1("CSmsPDUDelete::NewL()");
|
|
38 |
|
|
39 |
CSmsPDUDelete* smsPduDelete =
|
|
40 |
new(ELeave) CSmsPDUDelete(aSmsSettings,aSmsMessaging);
|
|
41 |
CleanupStack::PushL(smsPduDelete);
|
|
42 |
smsPduDelete->ConstructL();
|
|
43 |
CleanupStack::Pop();
|
|
44 |
return smsPduDelete;
|
|
45 |
} // CSmsPDUDelete::NewL
|
|
46 |
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Constructor
|
|
50 |
*
|
|
51 |
* @param aSmsComm reference to the MSmsComm class
|
|
52 |
* @param aSmsSettings reference to the TSmsSettings class
|
|
53 |
* @param aSmsMessaging reference to the RMobileSmsMessaging class
|
|
54 |
*/
|
|
55 |
CSmsPDUDelete::CSmsPDUDelete(const TSmsSettings& aSmsSettings,
|
|
56 |
RMobileSmsMessaging& aSmsMessaging)
|
|
57 |
: CSmsuActiveBase(KSmsSessionPriority),
|
|
58 |
iState(ESmsPDUDeleteIdle),
|
|
59 |
iSmsSettings(aSmsSettings),
|
|
60 |
iSmsMessaging(aSmsMessaging)
|
|
61 |
{
|
|
62 |
// NOP
|
|
63 |
} // CSmsPDUDelete::CSmsPDUDelete
|
|
64 |
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Creates instance to the class CSmsuTimeout
|
|
68 |
*/
|
|
69 |
void CSmsPDUDelete::ConstructL()
|
|
70 |
{
|
|
71 |
LOGSMSPROT1("CSmsPDUDelete::ConstructL()");
|
|
72 |
|
|
73 |
ConstructTimeoutL();
|
|
74 |
} // CSmsPDUDelete::ConstructL
|
|
75 |
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Starts CSmsPDUDelete active object
|
|
79 |
* Calls private methd OpenStore
|
|
80 |
*
|
|
81 |
* @param aStatus Reguest status
|
|
82 |
* @param aStoreIndex Index to the store to be read
|
|
83 |
*/
|
|
84 |
void CSmsPDUDelete::Start(CArrayFix<TGsmSmsSlotEntry>& aLocationArray, TRequestStatus& aStatus)
|
|
85 |
{
|
|
86 |
LOGSMSPROT1("CSmsPDUDelete::Start()");
|
|
87 |
|
|
88 |
__ASSERT_DEBUG(iState==ESmsPDUDeleteIdle,SmspPanic(KSmspPanicUnexpectedState));
|
|
89 |
|
|
90 |
Queue(aStatus);
|
|
91 |
|
|
92 |
iLocationArray=&aLocationArray;
|
|
93 |
iState=ESmsPDUDeleteOpeningStore;
|
|
94 |
OpenStore();
|
|
95 |
} // CSmsPDUDelete::Start
|
|
96 |
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Called by Active Scheduler
|
|
100 |
*
|
|
101 |
* Deletes slots giving in array. Opens new store if store change
|
|
102 |
*/
|
|
103 |
void CSmsPDUDelete::DoRunL()
|
|
104 |
{
|
|
105 |
LOGSMSPROT2("CSmsPDUDelete::RunL [iStatus=%d]", iStatus.Int());
|
|
106 |
|
|
107 |
switch (iState)
|
|
108 |
{
|
|
109 |
case ESmsPDUDeleteOpeningStore:
|
|
110 |
{
|
|
111 |
//
|
|
112 |
// If the store was opened, then delete the PDU...
|
|
113 |
//
|
|
114 |
if (iStatus.Int() == KErrNone)
|
|
115 |
{
|
|
116 |
DeletePDU();
|
|
117 |
}
|
|
118 |
}
|
|
119 |
break;
|
|
120 |
|
|
121 |
case ESmsPDUDeleteDeletingPDU:
|
|
122 |
{
|
|
123 |
//
|
|
124 |
// If deleting the PDU returned not found, then this is a valid
|
|
125 |
// result so assume KErrNone.
|
|
126 |
//
|
|
127 |
if (iStatus.Int() == KErrNotFound ||
|
|
128 |
iStatus.Int() == KErrGsmSMSInvalidMemoryIndex)
|
|
129 |
{
|
|
130 |
iStatus = KErrNone;
|
|
131 |
}
|
|
132 |
|
|
133 |
//
|
|
134 |
// If the delete was successful (or assumed to be) then remove
|
|
135 |
// it from the list. If the next one is the on a different store,
|
|
136 |
// then change stores, otherwise delete it.
|
|
137 |
//
|
|
138 |
if (iStatus.Int() == KErrNone)
|
|
139 |
{
|
|
140 |
iLocationArray->Delete(0);
|
|
141 |
|
|
142 |
if (iLocationArray->Count() > 0)
|
|
143 |
{
|
|
144 |
if (iLocationArray->At(0).iStore != iCurrentStore)
|
|
145 |
{
|
|
146 |
OpenStore();
|
|
147 |
}
|
|
148 |
else
|
|
149 |
{
|
|
150 |
DeletePDU();
|
|
151 |
}
|
|
152 |
}
|
|
153 |
}
|
|
154 |
}
|
|
155 |
break;
|
|
156 |
|
|
157 |
default:
|
|
158 |
{
|
|
159 |
SmspPanic(KSmspPanicUnexpectedState);
|
|
160 |
}
|
|
161 |
break;
|
|
162 |
}
|
|
163 |
|
|
164 |
//
|
|
165 |
// DoRunL() will now return to CSmsuActiveBase which if the object
|
|
166 |
// is not active, will call Complete().
|
|
167 |
//
|
|
168 |
} // CSmsPDUDelete::DoRunL
|
|
169 |
|
|
170 |
|
|
171 |
/**
|
|
172 |
* private method for opening the store where slot is saved
|
|
173 |
*/
|
|
174 |
void CSmsPDUDelete::OpenStore()
|
|
175 |
{
|
|
176 |
LOGSMSPROT1("CSmsPDUDelete::OpenStore()");
|
|
177 |
|
|
178 |
//
|
|
179 |
// Open the SMS Store for the first PDU...
|
|
180 |
//
|
|
181 |
if (iLocationArray->Count() > 0)
|
|
182 |
{
|
|
183 |
//
|
|
184 |
// Close it first, just in case it was left open...
|
|
185 |
//
|
|
186 |
iSmsStorage.Close();
|
|
187 |
|
|
188 |
//
|
|
189 |
// Now open the store...
|
|
190 |
//
|
|
191 |
TInt ret;
|
|
192 |
|
|
193 |
ret = iSmsStorage.Open(iSmsMessaging, iLocationArray->At(0).iStore);
|
|
194 |
if (ret == KErrNone)
|
|
195 |
{
|
|
196 |
iCurrentStore = iLocationArray->At(0).iStore;
|
|
197 |
}
|
|
198 |
|
|
199 |
//
|
|
200 |
// Complete this object to allow correct flow through DoRunL()
|
|
201 |
// and Complete() if needed.
|
|
202 |
//
|
|
203 |
iState = ESmsPDUDeleteOpeningStore;
|
|
204 |
|
|
205 |
CompleteMyself(ret);
|
|
206 |
}
|
|
207 |
} // CSmsPDUDelete::OpenStore
|
|
208 |
|
|
209 |
|
|
210 |
/**
|
|
211 |
* private method for deleting slot from the store
|
|
212 |
*/
|
|
213 |
void CSmsPDUDelete::DeletePDU()
|
|
214 |
{
|
|
215 |
LOGSMSPROT1("CSmsPDUDelete::DeletePDU()");
|
|
216 |
|
|
217 |
//
|
|
218 |
// Delete the first entry in the list...
|
|
219 |
//
|
|
220 |
if (iLocationArray->Count() > 0)
|
|
221 |
{
|
|
222 |
iSmsStorage.Delete(iStatus, iLocationArray->At(0).iIndex);
|
|
223 |
|
|
224 |
iState = ESmsPDUDeleteDeletingPDU;
|
|
225 |
|
|
226 |
TimedSetActive(iSmsSettings.Timeout());
|
|
227 |
}
|
|
228 |
} // CSmsPDUDelete::DeletePDU
|
|
229 |
|
|
230 |
|
|
231 |
/**
|
|
232 |
* Called by Active Scheduler
|
|
233 |
*/
|
|
234 |
void CSmsPDUDelete::DoCancel()
|
|
235 |
{
|
|
236 |
LOGSMSPROT1("CSmsPDUDelete::DoCancel()");
|
|
237 |
|
|
238 |
TimedSetActiveCancel();
|
|
239 |
|
|
240 |
switch (iState)
|
|
241 |
{
|
|
242 |
case ESmsPDUDeleteOpeningStore:
|
|
243 |
{
|
|
244 |
//
|
|
245 |
// Will never happen as CompleteMyself() was used...
|
|
246 |
//
|
|
247 |
}
|
|
248 |
break;
|
|
249 |
|
|
250 |
case ESmsPDUDeleteDeletingPDU:
|
|
251 |
{
|
|
252 |
iSmsStorage.CancelAsyncRequest(EMobilePhoneStoreDelete);
|
|
253 |
}
|
|
254 |
break;
|
|
255 |
|
|
256 |
default:
|
|
257 |
{
|
|
258 |
SmspPanic(KSmspPanicUnexpectedState);
|
|
259 |
}
|
|
260 |
}
|
|
261 |
|
|
262 |
//
|
|
263 |
// Handle completion of this Active Object. Note that the object
|
|
264 |
// may well still be active at this point...
|
|
265 |
//
|
|
266 |
if (TimedOut())
|
|
267 |
{
|
|
268 |
Complete(KErrTimedOut);
|
|
269 |
}
|
|
270 |
else
|
|
271 |
{
|
|
272 |
Complete(KErrCancel);
|
|
273 |
}
|
|
274 |
} // CSmsPDUDelete::DoCancel
|
|
275 |
|
|
276 |
|
|
277 |
/**
|
|
278 |
* Completes this object
|
|
279 |
*/
|
|
280 |
void CSmsPDUDelete::Complete(TInt aStatus)
|
|
281 |
{
|
|
282 |
LOGSMSPROT1("CSmsPDUDelete::Complete()");
|
|
283 |
|
|
284 |
//
|
|
285 |
// Only close the SMS Storage if the object is not active (and it may be
|
|
286 |
// if the operation was cancelled). Otherwise it will be closed on
|
|
287 |
// destruction.
|
|
288 |
//
|
|
289 |
if (!IsActive())
|
|
290 |
{
|
|
291 |
iSmsStorage.Close();
|
|
292 |
}
|
|
293 |
|
|
294 |
//
|
|
295 |
// Resets slot array...
|
|
296 |
//
|
|
297 |
iLocationArray->Reset();
|
|
298 |
|
|
299 |
//
|
|
300 |
// Call the base function to perform the actual complete...
|
|
301 |
//
|
|
302 |
CSmsuActiveBase::Complete(aStatus);
|
|
303 |
|
|
304 |
//
|
|
305 |
// This active object has completed...
|
|
306 |
//
|
|
307 |
iState = ESmsPDUDeleteIdle;
|
|
308 |
} // CSmsPDUDelete::Complete
|
|
309 |
|
|
310 |
|
|
311 |
/**
|
|
312 |
* Destructor
|
|
313 |
*/
|
|
314 |
CSmsPDUDelete::~CSmsPDUDelete()
|
|
315 |
{
|
|
316 |
Cancel();
|
|
317 |
iSmsStorage.Close();
|
|
318 |
} // CSmsPDUDelete::~CSmsPDUDelete
|
|
319 |
|