32
|
1 |
/*
|
|
2 |
* Copyright (c) 2004 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "vMessageHandler.h"
|
|
21 |
#include "obexutilsdebug.h"
|
|
22 |
#include "etelmm.h"
|
|
23 |
#include <BTSapDomainPSKeys.h>
|
|
24 |
#include <app/smut.h> // KUidMsgTypeSMS
|
|
25 |
#ifdef NO101APPDEPFIXES_NEW
|
|
26 |
#include <app/smuthdr.h>
|
|
27 |
#endif //NO101APPDEPFIXES_NEW
|
|
28 |
|
|
29 |
#include <gsmupdu.h>
|
|
30 |
#include <txtrich.h>
|
|
31 |
#include <msvuids.h>
|
|
32 |
|
|
33 |
#include <app/csmsaccount.h>
|
|
34 |
|
|
35 |
#ifdef NO101APPDEPFIXES_NEW
|
|
36 |
// SMUT Unbranch
|
|
37 |
#include <app/csmsgetdetdescinterface.h>
|
|
38 |
#endif //NO101APPDEPFIXES_NEW
|
|
39 |
|
42
|
40 |
// todo @ QT migration: take official definition from Messaging at app layer (btmsgtypeuid.h)
|
|
41 |
const TUid KUidMsgTypeBt = {0x10009ED5};
|
|
42 |
|
32
|
43 |
// ================= MEMBER FUNCTIONS =======================
|
|
44 |
TBool CSapVMessageParser::HandleMessageL(CObexBufObject* aReceivedObject, const TUid aMtmID,
|
|
45 |
RFile& aFile, CMsvSession* aMsvSession, TTime aTime)
|
|
46 |
{
|
|
47 |
FLOG( _L( " CSapVMessageParser: HandleMessageL\t" ) );
|
|
48 |
|
|
49 |
CSapVMessageParser* parser = CSapVMessageParser::NewLC();
|
|
50 |
TBool isVmsg=parser->ParseMessageL(aReceivedObject, aMtmID, aFile, aTime);
|
|
51 |
if(isVmsg)
|
|
52 |
{
|
|
53 |
parser->SaveSapMessageL(aMsvSession);
|
|
54 |
}
|
|
55 |
CleanupStack::PopAndDestroy(parser);
|
|
56 |
|
|
57 |
FLOG( _L( " CSapVMessageParser: HandleMessageL: Done\t" ) );
|
|
58 |
|
|
59 |
return isVmsg;
|
|
60 |
}
|
|
61 |
|
|
62 |
CSapVMessageParser* CSapVMessageParser::NewLC()
|
|
63 |
{
|
|
64 |
CSapVMessageParser* self = new (ELeave) CSapVMessageParser();
|
|
65 |
CleanupStack::PushL(self);
|
|
66 |
self->ConstructL();
|
|
67 |
return self;
|
|
68 |
}
|
|
69 |
|
|
70 |
void CSapVMessageParser::ConstructL()
|
|
71 |
{
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------
|
|
75 |
// Constructor
|
|
76 |
// ---------------------------------------------------------
|
|
77 |
//
|
|
78 |
CSapVMessageParser::CSapVMessageParser()
|
|
79 |
{
|
|
80 |
}
|
|
81 |
|
|
82 |
// ---------------------------------------------------------
|
|
83 |
// ParseMessageL
|
|
84 |
// Recognises and parses SAP VMessage.
|
|
85 |
// ---------------------------------------------------------
|
|
86 |
//
|
|
87 |
TBool CSapVMessageParser::ParseMessageL(CObexBufObject* aReceivedObject, const TUid aMtmID,
|
|
88 |
RFile& aFile, TTime aTime)
|
|
89 |
{
|
|
90 |
FLOG( _L( " CSapVMessageParser: ParseMessageL\t" ) );
|
|
91 |
|
|
92 |
static const TInt KExpandSize = 16;
|
|
93 |
|
|
94 |
iType=ESapVMessageUnknown;
|
|
95 |
|
|
96 |
if( aMtmID != KUidMsgTypeBt ||
|
|
97 |
!CheckMime(aReceivedObject->Type()) ||
|
|
98 |
!CheckName(aReceivedObject->Name()) ||
|
|
99 |
!IsSapConnectionActive())
|
|
100 |
{
|
|
101 |
FLOG( _L( " CSapVMessageParser: ParseMessageL: Unknown\t" ) );
|
|
102 |
return EFalse;
|
|
103 |
}
|
|
104 |
|
|
105 |
CBufFlat* buffer = CBufFlat::NewL( KExpandSize );
|
|
106 |
CleanupStack::PushL(buffer); // 1st push
|
|
107 |
|
|
108 |
TInt fileLength;
|
|
109 |
User::LeaveIfError( aFile.Size( fileLength ) );
|
|
110 |
|
|
111 |
// Read the file into buffer
|
|
112 |
buffer->ResizeL( fileLength );
|
|
113 |
TPtr8 temp = buffer->Ptr(0);
|
|
114 |
TInt pos = 0;
|
|
115 |
aFile.Seek(ESeekStart, pos);
|
|
116 |
User::LeaveIfError( aFile.Read( temp ) );
|
|
117 |
|
|
118 |
pos=0;
|
|
119 |
aFile.Seek(ESeekStart, pos); // rewind file
|
|
120 |
|
|
121 |
SimpleParseL(temp);
|
|
122 |
|
|
123 |
CleanupStack::PopAndDestroy(buffer); // -1 pop
|
|
124 |
|
|
125 |
iTimeReceived=aTime;
|
|
126 |
if(aReceivedObject->Time()==TTime(0))
|
|
127 |
{
|
|
128 |
iTimeOriginal = aTime;
|
|
129 |
}
|
|
130 |
else
|
|
131 |
{
|
|
132 |
iTimeOriginal = aReceivedObject->Time();
|
|
133 |
}
|
|
134 |
|
|
135 |
return (iType!=ESapVMessageUnknown);
|
|
136 |
}
|
|
137 |
|
|
138 |
// ---------------------------------------------------------
|
|
139 |
// IsSapConnectionActive
|
|
140 |
// Recognises active SAP connection.
|
|
141 |
// ---------------------------------------------------------
|
|
142 |
//
|
|
143 |
TBool CSapVMessageParser::IsSapConnectionActive()
|
|
144 |
{
|
|
145 |
FLOG( _L( " CSapVMessageParser: IsSapConnectionActive\t" ) );
|
|
146 |
|
|
147 |
TInt state=EBTSapNotConnected;
|
|
148 |
RProperty::Get(KPSUidBluetoothSapConnectionState, KBTSapConnectionState, state);
|
|
149 |
return state==EBTSapConnected;
|
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
// ---------------------------------------------------------
|
|
154 |
// CheckMime
|
|
155 |
// Check MIME type of vMessage.
|
|
156 |
// ---------------------------------------------------------
|
|
157 |
//
|
|
158 |
TBool CSapVMessageParser::CheckMime(const TDesC8& aType)
|
|
159 |
{
|
|
160 |
FLOG( _L( " CSapVMessageParser: CheckMime\t" ) );
|
|
161 |
|
|
162 |
_LIT8(KMimeVmsg,"text/x-vmsg\x00");
|
|
163 |
|
|
164 |
return (aType.Compare(KMimeVmsg)==0);
|
|
165 |
}
|
|
166 |
|
|
167 |
|
|
168 |
// ---------------------------------------------------------
|
|
169 |
// CheckName
|
|
170 |
// Check object name of SAP vMessage.
|
|
171 |
// ---------------------------------------------------------
|
|
172 |
//
|
|
173 |
TBool CSapVMessageParser::CheckName(const TDesC& aName)
|
|
174 |
{
|
|
175 |
FLOG( _L( " CSapVMessageParser: CheckName\t" ) );
|
|
176 |
|
|
177 |
_LIT(KNameVmsg, "sap_sms.vmg");
|
|
178 |
|
|
179 |
return (aName.Compare(KNameVmsg)==0);
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------
|
|
183 |
// Address
|
|
184 |
// Returns address field of parsed message.
|
|
185 |
// ---------------------------------------------------------
|
|
186 |
//
|
|
187 |
const TDesC& CSapVMessageParser::Address() const
|
|
188 |
{
|
|
189 |
if(iType==ESapVMessageTextSMS && iAddress)
|
|
190 |
{
|
|
191 |
return *iAddress;
|
|
192 |
}
|
|
193 |
else
|
|
194 |
{
|
|
195 |
return KNullDesC;
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
// ---------------------------------------------------------
|
|
200 |
// Message
|
|
201 |
// Returns body text of parsed message.
|
|
202 |
// ---------------------------------------------------------
|
|
203 |
//
|
|
204 |
const TDesC& CSapVMessageParser::Message() const
|
|
205 |
{
|
|
206 |
if(iType==ESapVMessageTextSMS && iMessage)
|
|
207 |
{
|
|
208 |
return *iMessage;
|
|
209 |
}
|
|
210 |
else
|
|
211 |
{
|
|
212 |
return KNullDesC;
|
|
213 |
}
|
|
214 |
}
|
|
215 |
|
|
216 |
// ---------------------------------------------------------
|
|
217 |
// ~CSapVMessageParser
|
|
218 |
// Destructor.
|
|
219 |
// ---------------------------------------------------------
|
|
220 |
//
|
|
221 |
CSapVMessageParser::~CSapVMessageParser()
|
|
222 |
{
|
|
223 |
FLOG( _L( " CSapVMessageParser: ~CSapVMessageParser\t" ) );
|
|
224 |
|
|
225 |
delete iAddress;
|
|
226 |
delete iMessage;
|
|
227 |
}
|
|
228 |
|
|
229 |
static TBool Compare(const TDesC8& aData, TInt& aReadBytes, const TDesC8& aToken)
|
|
230 |
{
|
|
231 |
if( (aData.Length() >= aReadBytes + aToken.Length()) &&
|
|
232 |
(aData.Mid(aReadBytes, aToken.Length()).Compare(aToken)==0) )
|
|
233 |
{
|
|
234 |
aReadBytes+=aToken.Length();
|
|
235 |
return ETrue;
|
|
236 |
}
|
|
237 |
else
|
|
238 |
{
|
|
239 |
return EFalse;
|
|
240 |
}
|
|
241 |
}
|
|
242 |
|
|
243 |
// ---------------------------------------------------------
|
|
244 |
// SimpleParseL
|
|
245 |
// Parses SAP VMessage.
|
|
246 |
// ---------------------------------------------------------
|
|
247 |
//
|
|
248 |
void CSapVMessageParser::SimpleParseL(const TDesC8& aData)
|
|
249 |
{
|
|
250 |
FLOG( _L( " CSapVMessageParser: SimpleParseL\t" ) );
|
|
251 |
|
|
252 |
// SAP VMessage format definitions
|
|
253 |
_LIT8(KVmsgStatus, "BEGIN:VMSG\x0d\x0a"
|
|
254 |
"VERSION:1.1\x0d\x0a"
|
|
255 |
"X-IRMC-STATUS:");
|
|
256 |
_LIT8(KVmsgBox, "\x0d\x0a"
|
|
257 |
"X-IRMC-TYPE:SMS\x0d\x0a"
|
|
258 |
"X-IRMC-BOX:");
|
|
259 |
_LIT8(KVmsgVCard, "BEGIN:VCARD\x0d\x0a"
|
|
260 |
"VERSION:2.1\x0d\x0a");
|
|
261 |
_LIT8(KVmsgName1, "N:");
|
|
262 |
_LIT8(KVmsgName2, "N;ENCODING=8BIT;CHARSET=UTF-8:");
|
|
263 |
_LIT8(KVmsgTel, "\x0d\x0a"
|
|
264 |
"TEL:");
|
|
265 |
_LIT8(KVmsgVCardEnd,"\x0d\x0a"
|
|
266 |
"END:VCARD\x0d\x0a");
|
|
267 |
_LIT8(KVmsgVEnv, "BEGIN:VENV\x0d\x0a");
|
|
268 |
_LIT8(KVmsgVBody, "BEGIN:VBODY\x0d\x0a"
|
|
269 |
"X-SMS;TYPE=TEXT;ENCODING=8BIT;CHARSET=UTF-8:");
|
|
270 |
_LIT8(KVmsgEnd, "\x0d\x0a"
|
|
271 |
"END:VBODY\x0d\x0a"
|
|
272 |
"END:VENV\x0d\x0a"
|
|
273 |
"END:VMSG\x0d\x0a");
|
|
274 |
_LIT8(KVmsgUnread, "UNREAD");
|
|
275 |
_LIT8(KVmsgRead, "READ");
|
|
276 |
_LIT8(KVmsgInbox, "INBOX\x0d\x0a");
|
|
277 |
_LIT8(KVmsgSentbox, "SENTBOX\x0d\x0a");
|
|
278 |
_LIT8(KCrLf, "\x0d\x0a");
|
|
279 |
|
|
280 |
// Simple SAP VMessage parsing
|
|
281 |
TInt readBytes=0;
|
|
282 |
if( Compare(aData, readBytes, KVmsgStatus) &&
|
|
283 |
aData.Right(KVmsgEnd().Length()).Compare(KVmsgEnd)==0 )
|
|
284 |
{ // The begin and end of the message are correct
|
|
285 |
if(Compare(aData, readBytes, KVmsgUnread))
|
|
286 |
{ // Status: Unread
|
|
287 |
iStatus=ESapVMessageStatusUnread;
|
|
288 |
}
|
|
289 |
else if(Compare(aData, readBytes, KVmsgRead))
|
|
290 |
{ // Status: Read or Sent
|
|
291 |
iStatus=ESapVMessageStatusRead;
|
|
292 |
}
|
|
293 |
else
|
|
294 |
{ // Unknown status
|
|
295 |
return;
|
|
296 |
}
|
|
297 |
if( Compare(aData, readBytes, KVmsgBox) )
|
|
298 |
{
|
|
299 |
if(iStatus==ESapVMessageStatusRead && Compare(aData, readBytes, KVmsgSentbox))
|
|
300 |
{ // Status: Sent
|
|
301 |
iStatus=ESapVMessageStatusSent;
|
|
302 |
if(!Compare(aData, readBytes, KVmsgVEnv))
|
|
303 |
{
|
|
304 |
return;
|
|
305 |
}
|
|
306 |
}
|
|
307 |
else if(! Compare(aData, readBytes, KVmsgInbox) )
|
|
308 |
{
|
|
309 |
return;
|
|
310 |
}
|
|
311 |
if( Compare(aData, readBytes, KVmsgVCard) &&
|
|
312 |
( Compare(aData, readBytes, KVmsgName1) ||
|
|
313 |
Compare(aData, readBytes, KVmsgName2) ) )
|
|
314 |
{ // The begin of the message is correct
|
|
315 |
TInt beginOfName=readBytes;
|
|
316 |
TInt endOfName=aData.Find(KVmsgTel);
|
|
317 |
TInt endOfFrom=aData.Find(KVmsgVCardEnd);
|
|
318 |
readBytes=endOfFrom+KVmsgVCardEnd().Length();
|
|
319 |
if(iStatus!=ESapVMessageStatusSent)
|
|
320 |
{
|
|
321 |
if(!Compare(aData, readBytes, KVmsgVEnv))
|
|
322 |
{
|
|
323 |
return;
|
|
324 |
}
|
|
325 |
}
|
|
326 |
if(endOfFrom!=KErrNotFound && endOfName!=KErrNotFound &&
|
|
327 |
endOfName<endOfFrom && Compare(aData, readBytes, KVmsgVBody))
|
|
328 |
{ // The middle part of the message is correct
|
|
329 |
TInt beginOfFrom=endOfName+KVmsgTel().Length();
|
|
330 |
TInt fromLength=endOfFrom-beginOfFrom;
|
|
331 |
if(fromLength <= RMobilePhone::KMaxMobileTelNumberSize)
|
|
332 |
{ // The sender field of the message is not too long
|
|
333 |
TInt beginOfBody=readBytes;
|
|
334 |
TInt bodyLength=(aData.Length()-KVmsgEnd().Length())-beginOfBody;
|
|
335 |
|
|
336 |
TPtrC8 name = aData.Mid(beginOfName, endOfName-beginOfName);
|
|
337 |
TPtrC8 from = aData.Mid(beginOfFrom, fromLength);
|
|
338 |
if((name.Find(KCrLf)==KErrNotFound) && (from.Find(KCrLf)==KErrNotFound))
|
|
339 |
{ // Message is correct
|
|
340 |
if(from.Length()==0 && name.Length()>0 &&
|
|
341 |
name.Length() <= RMobilePhone::KMaxMobileTelNumberSize)
|
|
342 |
{
|
|
343 |
iAddress = CnvUtfConverter::ConvertToUnicodeFromUtf8L(name);
|
|
344 |
}
|
|
345 |
else
|
|
346 |
{
|
|
347 |
iAddress = HBufC::NewL(from.Length());
|
|
348 |
iAddress->Des().Copy(from);
|
|
349 |
}
|
|
350 |
|
|
351 |
TPtrC8 body = aData.Mid(beginOfBody, bodyLength);
|
|
352 |
iMessage = CnvUtfConverter::ConvertToUnicodeFromUtf8L(body);
|
|
353 |
|
|
354 |
FLOG( _L( " CSapVMessageParser: SimpleParseL: SMS\t" ) );
|
|
355 |
iType=ESapVMessageTextSMS;
|
|
356 |
}
|
|
357 |
}
|
|
358 |
}
|
|
359 |
}
|
|
360 |
}
|
|
361 |
}
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------
|
|
365 |
// SaveSapMessageL
|
|
366 |
// Saves parsed VMessage.
|
|
367 |
// ---------------------------------------------------------
|
|
368 |
//
|
|
369 |
void CSapVMessageParser::SaveSapMessageL(CMsvSession* aMsvSession)
|
|
370 |
{
|
|
371 |
FLOG( _L( " CSapVMessageParser: SaveSapMessageL\t" ) );
|
|
372 |
|
|
373 |
switch(iType)
|
|
374 |
{
|
|
375 |
case ESapVMessageTextSMS:
|
|
376 |
SaveSapSmsL(aMsvSession);
|
|
377 |
break;
|
|
378 |
|
|
379 |
case ESapVMessageMMSNotificationInd:
|
|
380 |
SaveSapMmsL(aMsvSession);
|
|
381 |
break;
|
|
382 |
|
|
383 |
default: // Discard message
|
|
384 |
break;
|
|
385 |
}
|
|
386 |
}
|
|
387 |
|
|
388 |
// ---------------------------------------------------------
|
|
389 |
// SaveSapSmsL
|
|
390 |
// Saves parsed VMessage as SMS.
|
|
391 |
// ---------------------------------------------------------
|
|
392 |
//
|
|
393 |
void CSapVMessageParser::SaveSapSmsL(CMsvSession* aMsvSession)
|
|
394 |
{
|
|
395 |
FLOG( _L( " CSapVMessageParser: SaveSapSmsL\t" ) );
|
|
396 |
|
|
397 |
CParaFormatLayer* richParaFormatLayer = CParaFormatLayer::NewL();
|
|
398 |
CleanupStack::PushL(richParaFormatLayer); // 1st push
|
|
399 |
CCharFormatLayer* richCharFormatLayer = CCharFormatLayer::NewL();
|
|
400 |
CleanupStack::PushL(richCharFormatLayer); // 2nd push
|
|
401 |
CRichText*
|
|
402 |
richText = CRichText::NewL(richParaFormatLayer,richCharFormatLayer);
|
|
403 |
CleanupStack::PushL(richText); // 3rd push
|
|
404 |
|
|
405 |
richText->InsertL(0, Message());
|
|
406 |
|
|
407 |
if(iStatus==ESapVMessageStatusSent)
|
|
408 |
{
|
|
409 |
SaveSmsToSentL(aMsvSession, richText);
|
|
410 |
}
|
|
411 |
else
|
|
412 |
{
|
|
413 |
SaveSmsToInboxL(aMsvSession, richText);
|
|
414 |
}
|
|
415 |
|
|
416 |
CleanupStack::PopAndDestroy(3, richParaFormatLayer);
|
|
417 |
|
|
418 |
FLOG( _L( " CSapVMessageParser: SaveSapSmsL: Done\t" ) );
|
|
419 |
}
|
|
420 |
|
|
421 |
// ---------------------------------------------------------
|
|
422 |
// SaveSapMmsL
|
|
423 |
// Saves parsed VMessage as MMS notification.
|
|
424 |
// ---------------------------------------------------------
|
|
425 |
//
|
|
426 |
void CSapVMessageParser::SaveSapMmsL(CMsvSession* /*aMsvSession*/) const
|
|
427 |
{
|
|
428 |
// This is not supported
|
|
429 |
}
|
|
430 |
|
|
431 |
// ---------------------------------------------------------
|
|
432 |
// SaveSmsToInboxL
|
|
433 |
// Saves parsed VMessage to Inbox as SMS.
|
|
434 |
// ---------------------------------------------------------
|
|
435 |
//
|
|
436 |
void CSapVMessageParser::SaveSmsToInboxL(CMsvSession* aMsvSession, CRichText* aMessage)
|
|
437 |
{
|
|
438 |
#ifndef NO101APPDEPFIXES_NEW
|
|
439 |
(void) aMsvSession;
|
|
440 |
(void) aMessage;
|
|
441 |
#endif //NO101APPDEPFIXES_NEW
|
|
442 |
#ifdef NO101APPDEPFIXES_NEW
|
|
443 |
FLOG( _L( " CSapVMessageParser: SaveSmsToInboxL\t" ) );
|
|
444 |
CSmsHeader* header=CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *aMessage );
|
|
445 |
CleanupStack::PushL(header); // 1st push
|
|
446 |
header->SetFromAddressL(Address());
|
|
447 |
header->SetReplyPathProvided(EFalse);
|
|
448 |
|
|
449 |
TMsvEntry newTEntry;
|
|
450 |
|
|
451 |
newTEntry.iType = KUidMsvMessageEntry;
|
|
452 |
newTEntry.iMtm = KUidMsgTypeSMS;
|
|
453 |
newTEntry.SetComplete(EFalse);
|
|
454 |
newTEntry.SetFailed(EFalse);
|
|
455 |
newTEntry.SetOperation(EFalse);
|
|
456 |
newTEntry.SetMultipleRecipients(EFalse);
|
|
457 |
newTEntry.SetVisible(EFalse); // Make invisible
|
|
458 |
// and in preparation to make sure gets cleaned up on errors.
|
|
459 |
newTEntry.SetInPreparation(ETrue);
|
|
460 |
newTEntry.SetSendingState(KMsvSendStateNotApplicable);
|
|
461 |
newTEntry.iServiceId = KMsvLocalServiceIndexEntryId;
|
|
462 |
newTEntry.iSize = 0;
|
|
463 |
newTEntry.iDate = iTimeReceived;
|
|
464 |
header->Message().SetTime(iTimeOriginal);
|
|
465 |
((CSmsDeliver*)&header->Message().SmsPDU())->SetServiceCenterTimeStamp(iTimeOriginal);
|
|
466 |
|
|
467 |
// SMUT Unbranch
|
|
468 |
CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL();
|
|
469 |
CleanupStack::PushL( smsPlugin );
|
|
470 |
|
|
471 |
TBuf<KSmsDescriptionLength> description;
|
|
472 |
smsPlugin->GetDescription( header->Message(), description );
|
|
473 |
newTEntry.iDescription.Set(description);
|
|
474 |
TBuf<KSmsDetailsLength> details;
|
|
475 |
smsPlugin->GetDetails( aMsvSession->FileSession(), header->Message(), details );
|
|
476 |
newTEntry.iDetails.Set(details);
|
|
477 |
|
|
478 |
CleanupStack::PopAndDestroy( smsPlugin );
|
|
479 |
|
|
480 |
// Create new entry to inbox
|
|
481 |
CMsvEntry* inbox = aMsvSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
|
|
482 |
CleanupStack::PushL( inbox );
|
|
483 |
inbox->CreateL(newTEntry);
|
|
484 |
CleanupStack::PopAndDestroy(inbox);
|
|
485 |
|
|
486 |
TMsvId newEntryId=newTEntry.Id();
|
|
487 |
aMsvSession->CleanupEntryPushL(newEntryId); //2nd push
|
|
488 |
|
|
489 |
// Get the created entry
|
|
490 |
CMsvEntry* newEntry = aMsvSession->GetEntryL(newEntryId);
|
|
491 |
CleanupStack::PushL(newEntry); // 3rd push
|
|
492 |
|
|
493 |
// Store SMS message to the entry
|
|
494 |
CMsvStore* newMessageStore = newEntry->EditStoreL();
|
|
495 |
CleanupStack::PushL(newMessageStore); // 4th push
|
|
496 |
header->StoreL(*newMessageStore);
|
|
497 |
newMessageStore->StoreBodyTextL(*aMessage);
|
|
498 |
newMessageStore->CommitL();
|
|
499 |
|
|
500 |
// Save the size & make visible
|
|
501 |
newTEntry = newEntry->Entry();
|
|
502 |
newTEntry.iSize = newMessageStore->SizeL();
|
|
503 |
|
|
504 |
// Saved OK. Make the entry visible and flag it as complete.
|
|
505 |
newTEntry.SetVisible(ETrue);
|
|
506 |
newTEntry.SetInPreparation(EFalse);
|
|
507 |
newTEntry.SetUnread(iStatus==ESapVMessageStatusUnread);
|
|
508 |
newTEntry.SetNew(iStatus==ESapVMessageStatusRead);
|
|
509 |
newTEntry.SetComplete(ETrue);
|
|
510 |
newTEntry.SetReadOnly(ETrue);
|
|
511 |
newEntry->ChangeL(newTEntry);
|
|
512 |
|
|
513 |
CleanupStack::PopAndDestroy(2, newEntry);
|
|
514 |
aMsvSession->CleanupEntryPop();
|
|
515 |
CleanupStack::PopAndDestroy(header);
|
|
516 |
|
|
517 |
FLOG( _L( " CSapVMessageParser: SaveSmsToInboxL: Done\t" ) );
|
|
518 |
#endif //NO101APPDEPFIXES_NEW
|
|
519 |
}
|
|
520 |
|
|
521 |
// ---------------------------------------------------------
|
|
522 |
// SaveSmsToSentL
|
|
523 |
// Saves parsed VMessage to Sent folder as SMS.
|
|
524 |
// ---------------------------------------------------------
|
|
525 |
//
|
|
526 |
void CSapVMessageParser::SaveSmsToSentL(CMsvSession* aMsvSession, CRichText* aMessage)
|
|
527 |
{
|
|
528 |
#ifndef NO101APPDEPFIXES_NEW
|
|
529 |
(void) aMsvSession;
|
|
530 |
(void) aMessage;
|
|
531 |
#endif //NO101APPDEPFIXES_NEW
|
|
532 |
|
|
533 |
#ifdef NO101APPDEPFIXES_NEW
|
|
534 |
FLOG( _L( " CSapVMessageParser: SaveSmsToSentL\t" ) );
|
|
535 |
|
|
536 |
CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsSubmit, *aMessage );
|
|
537 |
CleanupStack::PushL( header );
|
|
538 |
header->SetFromAddressL(Address());
|
|
539 |
|
|
540 |
TMsvEntry newTEntry;
|
|
541 |
newTEntry.iType = KUidMsvMessageEntry;
|
|
542 |
newTEntry.iMtm = KUidMsgTypeSMS;
|
|
543 |
newTEntry.SetComplete(EFalse);
|
|
544 |
newTEntry.SetFailed(EFalse);
|
|
545 |
newTEntry.SetOperation(EFalse);
|
|
546 |
newTEntry.SetMultipleRecipients(EFalse);
|
|
547 |
newTEntry.SetVisible(EFalse); // Make invisible
|
|
548 |
// and in preparation to make sure gets cleaned up on errors.
|
|
549 |
newTEntry.SetInPreparation(ETrue);
|
|
550 |
newTEntry.SetSendingState(KMsvSendStateSent);
|
|
551 |
newTEntry.iServiceId = KMsvUnknownServiceIndexEntryId;
|
|
552 |
newTEntry.iSize = 0;
|
|
553 |
newTEntry.iDate=iTimeReceived;
|
|
554 |
header->Message().SetTime(iTimeOriginal);
|
|
555 |
|
|
556 |
// SMUT Unbranch
|
|
557 |
CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL();
|
|
558 |
CleanupStack::PushL( smsPlugin );
|
|
559 |
|
|
560 |
TBuf<KSmsDescriptionLength> description;
|
|
561 |
smsPlugin->GetDescription( header->Message(), description );
|
|
562 |
newTEntry.iDescription.Set(description);
|
|
563 |
TBuf<KSmsDetailsLength> details;
|
|
564 |
smsPlugin->GetDetails( aMsvSession->FileSession(), header->Message(), details );
|
|
565 |
newTEntry.iDetails.Set(details);
|
|
566 |
|
|
567 |
CleanupStack::PopAndDestroy( smsPlugin );
|
|
568 |
|
|
569 |
CSmsSettings* settings = CSmsSettings::NewLC();
|
|
570 |
CSmsAccount* account = CSmsAccount::NewLC();
|
|
571 |
account->LoadSettingsL(*settings);
|
|
572 |
CleanupStack::PopAndDestroy(account);
|
|
573 |
header->SetSmsSettingsL( *settings );
|
|
574 |
TInt scindex = settings->DefaultServiceCenter();
|
|
575 |
if ( scindex != KErrNotFound )
|
|
576 |
{
|
|
577 |
header->SetServiceCenterAddressL( ( settings->GetServiceCenter( scindex ) ).Address() );
|
|
578 |
}
|
|
579 |
CleanupStack::PopAndDestroy(settings);
|
|
580 |
|
|
581 |
CSmsNumber* rcpt = CSmsNumber::NewL();
|
|
582 |
CleanupStack::PushL( rcpt );
|
|
583 |
rcpt->SetAddressL(Address());
|
|
584 |
if(Address()!=details)
|
|
585 |
{
|
|
586 |
rcpt->SetNameL(details);
|
|
587 |
}
|
|
588 |
header->Recipients().ResetAndDestroy();
|
|
589 |
header->Recipients().AppendL( rcpt );
|
|
590 |
CleanupStack::Pop( rcpt );
|
|
591 |
|
|
592 |
// Create new entry to Sent folder
|
|
593 |
CMsvEntry* sentFldr = aMsvSession->GetEntryL( KMsvSentEntryId );
|
|
594 |
CleanupStack::PushL( sentFldr );
|
|
595 |
sentFldr->CreateL(newTEntry);
|
|
596 |
CleanupStack::PopAndDestroy(sentFldr);
|
|
597 |
|
|
598 |
TMsvId newEntryId=newTEntry.Id();
|
|
599 |
aMsvSession->CleanupEntryPushL(newEntryId); //2nd push
|
|
600 |
|
|
601 |
// Get the created entry
|
|
602 |
CMsvEntry* newEntry = aMsvSession->GetEntryL(newEntryId);
|
|
603 |
CleanupStack::PushL(newEntry); // 3rd push
|
|
604 |
|
|
605 |
// Store SMS message to the entry
|
|
606 |
CMsvStore* newMessageStore = newEntry->EditStoreL();
|
|
607 |
CleanupStack::PushL(newMessageStore); // 4th push
|
|
608 |
header->StoreL(*newMessageStore);
|
|
609 |
newMessageStore->StoreBodyTextL(*aMessage);
|
|
610 |
newMessageStore->CommitL();
|
|
611 |
|
|
612 |
// Save the size & make visible
|
|
613 |
newTEntry = newEntry->Entry();
|
|
614 |
newTEntry.iSize = newMessageStore->SizeL();
|
|
615 |
|
|
616 |
// Saved OK. Make the entry visible and flag it as complete.
|
|
617 |
newTEntry.SetVisible(ETrue);
|
|
618 |
newTEntry.SetInPreparation(EFalse);
|
|
619 |
newTEntry.SetComplete(ETrue);
|
|
620 |
newEntry->ChangeL(newTEntry);
|
|
621 |
|
|
622 |
CleanupStack::PopAndDestroy(2, newEntry);
|
|
623 |
aMsvSession->CleanupEntryPop();
|
|
624 |
CleanupStack::PopAndDestroy(header);
|
|
625 |
|
|
626 |
FLOG( _L( " CSapVMessageParser: SaveSmsToSentL: Done\t" ) );
|
|
627 |
#endif //NO101APPDEPFIXES_NEW
|
|
628 |
}
|
|
629 |
|
|
630 |
// End of File
|