|
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 // Implements Sms Storage Extensions |
|
15 // |
|
16 // |
|
17 |
|
18 #include <et_phone.h> |
|
19 #include "mSMSREAD.H" |
|
20 #include "mSMSWRIT.H" |
|
21 #include "mSMSDEL.H" |
|
22 #include "mSMSSTOR.H" |
|
23 #include "ATINIT.H" |
|
24 #include "mSLOGGER.H" |
|
25 #include "smsutil.h" |
|
26 |
|
27 // This class implements functionality to get info, entries and all stored entries from the SMS stores in the phone. |
|
28 CMobileSmsStore* CMobileSmsStore::NewL(CATIO* aATIO, CATInit* aInit, CPhoneGlobals* aPhoneGlobals, TStorageType aStoreType) |
|
29 { |
|
30 CMobileSmsStore* subsession=new(ELeave) CMobileSmsStore(aATIO, aInit, aPhoneGlobals, aStoreType); |
|
31 CleanupStack::PushL(subsession); |
|
32 subsession->ConstructL(); |
|
33 CleanupStack::Pop(); |
|
34 return subsession; |
|
35 } |
|
36 |
|
37 TInt CMobileSmsStore::CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle) |
|
38 { |
|
39 __ASSERT_ALWAYS((aIpc==EMobilePhoneStoreDelete) || (aIpc==EMobilePhoneStoreRead) || (aIpc==EMobilePhoneStoreWrite) || |
|
40 (aIpc==EMobilePhoneStoreGetInfo), PanicClient(KErrUnknown)); |
|
41 switch(aIpc) |
|
42 { |
|
43 case EMobilePhoneStoreWrite: |
|
44 return WriteCancel(aTsyReqHandle); |
|
45 case EMobilePhoneStoreRead: |
|
46 return ReadCancel(aTsyReqHandle); |
|
47 case EMobilePhoneStoreDelete: |
|
48 return DeleteCancel(aTsyReqHandle); |
|
49 case EMobilePhoneStoreGetInfo: |
|
50 return GetInfoCancel(aTsyReqHandle); |
|
51 default: |
|
52 return KErrNotSupported; |
|
53 }//switch |
|
54 } |
|
55 |
|
56 void CMobileSmsStore::Init() |
|
57 { |
|
58 } |
|
59 |
|
60 CMobileSmsStore::CMobileSmsStore(CATIO* aIo, CATInit* aInit, CPhoneGlobals* aPhoneGlobals, TStorageType aStoreType) |
|
61 :iIo(aIo) |
|
62 ,iInit(aInit) |
|
63 ,iPhoneGlobals(aPhoneGlobals) |
|
64 { |
|
65 iStoreName=aStoreType; // provides name for this object, ie: SM, ME, MT |
|
66 } |
|
67 |
|
68 void CMobileSmsStore::ConstructL() |
|
69 { |
|
70 iATSmsStorageRead = CATSmsMessagingRead::NewL(iIo, this, iInit, iPhoneGlobals); |
|
71 iATSmsStorageWrite = CATSmsMessagingWrite::NewL(iIo, this, iInit, iPhoneGlobals); |
|
72 iATSmsStorageDelete = CATSmsStorageDelete::NewL(iIo, this, iInit, iPhoneGlobals); |
|
73 iATSmsStorageGetInfo = CATSmsMemoryStorage::NewL(iIo, this, iInit, iPhoneGlobals); |
|
74 } |
|
75 |
|
76 CMobileSmsStore::~CMobileSmsStore() |
|
77 { |
|
78 delete iATSmsStorageRead; |
|
79 delete iATSmsStorageWrite; |
|
80 delete iATSmsStorageDelete; |
|
81 delete iATSmsStorageGetInfo; |
|
82 } |
|
83 |
|
84 CTelObject* CMobileSmsStore::OpenNewObjectByNameL(const TDesC& /*aName*/) |
|
85 { |
|
86 User::Leave(KErrNotSupported); |
|
87 return NULL; |
|
88 } |
|
89 |
|
90 CTelObject* CMobileSmsStore::OpenNewObjectL(TDes& /*aNewName*/) |
|
91 { |
|
92 User::Leave(KErrNotSupported); |
|
93 return NULL; |
|
94 } |
|
95 |
|
96 CTelObject::TReqMode CMobileSmsStore::ReqModeL(const TInt aIpc) |
|
97 { |
|
98 CTelObject::TReqMode ret=0; |
|
99 switch (aIpc) |
|
100 { |
|
101 // |
|
102 // Sms Storage |
|
103 // |
|
104 case EMobilePhoneStoreGetInfo: |
|
105 ret = KReqModeMultipleCompletionEnabled|KReqModeFlowControlObeyed; |
|
106 break; |
|
107 |
|
108 case EMobilePhoneStoreRead: |
|
109 case EMobilePhoneStoreWrite: |
|
110 case EMobilePhoneStoreDelete: |
|
111 ret=KReqModeFlowControlObeyed; |
|
112 break; |
|
113 |
|
114 default: |
|
115 User::Leave(KErrNotSupported); |
|
116 break; |
|
117 } |
|
118 |
|
119 // Check if the data port is currently loaned. If it is and the requested IPC |
|
120 // is flow controlled then block Etel calling the IPC by leaving with KErrInUse |
|
121 if((ret&KReqModeFlowControlObeyed) && iPhoneGlobals->iPhoneStatus.iDataPortLoaned) |
|
122 { |
|
123 LOGTEXT2(_L8("ReqModeL Leaving with KErrInUse as data port is loaned (aIpc=%d)"),aIpc); |
|
124 User::Leave(KErrInUse); |
|
125 } |
|
126 |
|
127 return ret; |
|
128 } |
|
129 |
|
130 TInt CMobileSmsStore::NumberOfSlotsL(const TInt /*aIpc*/) |
|
131 { |
|
132 // Return the number of slots (buffered in server) |
|
133 // for any KReqRepostImmediately ipc calls in the above ReqModeL function |
|
134 User::Leave(KErrNotSupported); |
|
135 return 0; //just to make compiler happy |
|
136 } |
|
137 |
|
138 TInt CMobileSmsStore::RegisterNotification(const TInt /*aIpc*/) |
|
139 { |
|
140 return KErrNone; |
|
141 } |
|
142 |
|
143 TInt CMobileSmsStore::DeregisterNotification(const TInt /*aIpc*/) |
|
144 { |
|
145 return KErrNone; |
|
146 } |
|
147 |
|
148 TInt CMobileSmsStore::ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc, const TDataPackage& aPackage) |
|
149 { |
|
150 // Prior to dispatch check that we're not setting up or in the middle of a data or fax call |
|
151 if((iPhoneGlobals->iPhoneStatus.iPortAccess==EPortAccessDenied) || (iPhoneGlobals->iPhoneStatus.iMode == RPhone::EModeOnlineData)) |
|
152 { |
|
153 LOGTEXT2(_L8("CMobileSmsStore::ExtFunc (aIpc=%d)"),aIpc); |
|
154 LOGTEXT(_L8("CMobileSmsStore::ExtFunc\tPort Access Denied/Mode Online flag detected")); |
|
155 switch(aIpc) |
|
156 { |
|
157 // These may interfere with the Fax, so error the request now... |
|
158 case EMobilePhoneStoreGetInfo: |
|
159 case EMobilePhoneStoreRead: |
|
160 case EMobilePhoneStoreWrite: |
|
161 case EMobilePhoneStoreDelete: |
|
162 LOGTEXT(_L8("CMobileSmsStore::ExtFunc\tReturning KErrAccessDenied error")); |
|
163 return KErrAccessDenied; |
|
164 |
|
165 default: |
|
166 break; |
|
167 } |
|
168 } |
|
169 |
|
170 TAny* dataPtr=aPackage.Ptr1(); |
|
171 |
|
172 switch (aIpc) |
|
173 { |
|
174 case EMobilePhoneStoreGetInfo: |
|
175 return GetInfo(aTsyReqHandle, aPackage.Des1n()); |
|
176 case EMobilePhoneStoreRead: |
|
177 return Read(aTsyReqHandle, aPackage.Des1n()); |
|
178 case EMobilePhoneStoreWrite: |
|
179 return Write(aTsyReqHandle,aPackage.Des1n()); |
|
180 case EMobilePhoneStoreDelete: |
|
181 return Delete(aTsyReqHandle, reinterpret_cast<TInt*>(dataPtr)); |
|
182 default: |
|
183 return KErrNotSupported; |
|
184 } |
|
185 } |
|
186 |
|
187 TInt CMobileSmsStore::GetInfo(const TTsyReqHandle aTsyReqHandle, TDes8* aInfoPckg) |
|
188 /** Get SMS store Inforamtion |
|
189 * |
|
190 * This method starts retrieval of information about the current SMS store. |
|
191 * When the request is completed information about total number of slots, number |
|
192 * of used slots, type of store and store capabilities is returned to the client. |
|
193 * @param aTsyReqHandle Handle to the request ID. |
|
194 * @param aInfoPckg A packet of type TMobilePhoneStoreInfoV1Pckg |
|
195 * @return TInt error code |
|
196 */ |
|
197 {// special case, can't just call ExecuteCommand, because this'll call the WRONG Start() function, therefore only call it for re-start init etc. |
|
198 LOGTEXT(_L8("CMobileSmsStore\tSMS Store Get Info called.")); |
|
199 |
|
200 if (iPhoneGlobals->iPhoneStatus.iInitStatus != EPhoneInitialised) |
|
201 ReqCompleted(aTsyReqHandle,KErrNotReady); |
|
202 |
|
203 iATSmsStorageGetInfo->CopyDataFromCATInit(iInit); |
|
204 iATSmsStorageGetInfo->StartGetInfo(aTsyReqHandle,aInfoPckg); |
|
205 |
|
206 return KErrNone; |
|
207 } |
|
208 |
|
209 TInt CMobileSmsStore::Read(const TTsyReqHandle aTsyReqHandle, TDes8* aEntryPckg) |
|
210 /** Read a Fixed Size SMS entry |
|
211 * |
|
212 * This method starts the retrieval of a fixed size SMS entry. The entry to read |
|
213 * is specified by the index(entry.iIndex) in TMobileSmsEntryV1. During the |
|
214 * retrieval of the specified entry the iFormat and iFlags fields are set as well. |
|
215 * @param aTsyReqHandle Handle to the request ID. |
|
216 * @param aEntryPckg A packet of type TMobilePhoneStoreInfoV1Pckg |
|
217 * @return TInt error code |
|
218 */ |
|
219 { |
|
220 LOGTEXT(_L8("CMobileSmsStore\tSMS Store Read called.")); |
|
221 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg* smsEntryPckg = static_cast<RMobileSmsStore::TMobileGsmSmsEntryV1Pckg*>(aEntryPckg); |
|
222 RMobileSmsStore::TMobileGsmSmsEntryV1& entry = (*smsEntryPckg)(); |
|
223 |
|
224 if (entry.ExtensionId()!=RMobileSmsStore::KETelMobileGsmSmsEntryV1) |
|
225 ReqCompleted(aTsyReqHandle, KErrNotSupported); |
|
226 else |
|
227 iATSmsStorageRead->ExecuteCommand(aTsyReqHandle, &entry); |
|
228 |
|
229 return KErrNone; |
|
230 } |
|
231 |
|
232 |
|
233 TInt CMobileSmsStore::Write(const TTsyReqHandle aTsyReqHandle, TDes8* aEntryPckg) |
|
234 /** Write a SMS Entry to the store |
|
235 * |
|
236 * This method starts the writing of a SMS entry to the mobilephone. The entry written |
|
237 * to the phone allways has a prepended SCA header({0x01,0x80}), regardless of what the |
|
238 * client puts in the packet which is unpacket here. This is due to a lack of erorror |
|
239 * responses from some phones (Ericsson T28 and R320). |
|
240 * @param aTsyReqHandle Handle to the request ID. |
|
241 * @param aEntryPckg A packet of type TMobilePhoneStoreInfoV1Pckg |
|
242 * @return TInt error code |
|
243 */ |
|
244 { |
|
245 LOGTEXT(_L8("CMobileSmsStore\tSMS Store Write called.")); |
|
246 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg* smsEntryPckg = static_cast<RMobileSmsStore::TMobileGsmSmsEntryV1Pckg*>(aEntryPckg); |
|
247 RMobileSmsStore::TMobileGsmSmsEntryV1& entry = (*smsEntryPckg)(); |
|
248 |
|
249 if (entry.ExtensionId()!=RMobileSmsStore::KETelMobileGsmSmsEntryV1) |
|
250 ReqCompleted(aTsyReqHandle, KErrNotSupported); |
|
251 else |
|
252 iATSmsStorageWrite->ExecuteCommand(aTsyReqHandle, &entry); |
|
253 |
|
254 return KErrNone; |
|
255 } |
|
256 |
|
257 TInt CMobileSmsStore::Delete(const TTsyReqHandle aTsyReqHandle, TInt* aIndex) |
|
258 /** Delete a SMS Message |
|
259 * |
|
260 * This methos deletes the SMS entry defined by aIndex. |
|
261 * @param aTsyReqHandle Handle to the request ID. |
|
262 * @param aIndex The index of the SMS entry to delete. |
|
263 * @return TInt error code. |
|
264 */ |
|
265 |
|
266 { |
|
267 LOGTEXT(_L8("CMobileSmsStore\tSMS Store Delete called.")); |
|
268 iATSmsStorageDelete->ExecuteCommand(aTsyReqHandle, aIndex); |
|
269 |
|
270 return KErrNone; |
|
271 } |
|
272 |
|
273 TInt CMobileSmsStore::WriteCancel(const TTsyReqHandle aTsyReqHandle) |
|
274 /** Write Cancel |
|
275 * |
|
276 * This method cancels an outstanding request to write a SMS message to |
|
277 * the current memory(ME or SM). |
|
278 * @param aTsyReqHandle Handle to the request ID. |
|
279 * @return TInt error code. |
|
280 */ |
|
281 { |
|
282 iATSmsStorageWrite->CancelCommand(aTsyReqHandle); |
|
283 return KErrNone; |
|
284 } |
|
285 |
|
286 |
|
287 TInt CMobileSmsStore::ReadCancel(const TTsyReqHandle aTsyReqHandle) |
|
288 /** Read Cancel |
|
289 * |
|
290 * This method cancels a outstanding request to read a SMS message |
|
291 * from the current memory(ME or SM). |
|
292 * @param aTsyReqHandle Handle to the request ID. |
|
293 * @return TInt error code. |
|
294 */ |
|
295 { |
|
296 LOGTEXT(_L8("CMobileSmsStore\tSMS Store Read Cancel called.")); |
|
297 iATSmsStorageRead->CancelCommand(aTsyReqHandle); |
|
298 return KErrNone; |
|
299 } |
|
300 |
|
301 |
|
302 TInt CMobileSmsStore::DeleteCancel(const TTsyReqHandle aTsyReqHandle) |
|
303 /** Delete Cancel |
|
304 * |
|
305 * This method cancels a outstanding request to write a SMS message |
|
306 * to the current memory(ME or SM). |
|
307 * @param aTsyReqHandle Handle to the request ID. |
|
308 * @return TInt error code. |
|
309 */ |
|
310 { |
|
311 LOGTEXT(_L8("CMobileSmsStore\tSMS Store Delete Cancel called.")); |
|
312 iATSmsStorageDelete->CancelCommand(aTsyReqHandle); |
|
313 return KErrNone; |
|
314 } |
|
315 |
|
316 |
|
317 TInt CMobileSmsStore::GetInfoCancel(const TTsyReqHandle aTsyReqHandle) |
|
318 /** Delete Cancel |
|
319 * |
|
320 * This method cancels a outstanding request to get information about the |
|
321 * current memory(ME or SM). |
|
322 * to the current memory. |
|
323 * @param aTsyReqHandle Handle to the request ID. |
|
324 * @return TInt error code. |
|
325 */ |
|
326 { |
|
327 LOGTEXT(_L8("CMobileSmsStore\tSMS Store Get Info Cancel called.")); |
|
328 iATSmsStorageGetInfo->CancelCommand(aTsyReqHandle); |
|
329 return KErrNone; |
|
330 } |