|
1 // Copyright (c) 1999-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 |
|
17 #include <etelmm.h> |
|
18 #include "SMCMMAIN.H" |
|
19 #include "SMUTSET.H" |
|
20 |
|
21 #include <commsdattypesv1_1.h> |
|
22 #include <commsdat.h> |
|
23 #include <txtetext.h> |
|
24 #include <csmsemailfields.h> |
|
25 #include <logwraplimits.h> |
|
26 using namespace CommsDat; |
|
27 |
|
28 |
|
29 |
|
30 // Compile time check to see if the enums RMobileSmsMessaging::TMobileSmsBearer and CSmsSettings::TMobileSmsBearer |
|
31 // are equivalent. |
|
32 |
|
33 #undef C_ASSERT |
|
34 #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] |
|
35 |
|
36 C_ASSERT(RMobileSmsMessaging::ESmsBearerPacketOnly==CSmsSettings::ESmsBearerPacketOnly); |
|
37 C_ASSERT(RMobileSmsMessaging::ESmsBearerCircuitOnly==CSmsSettings::ESmsBearerCircuitOnly); |
|
38 C_ASSERT(RMobileSmsMessaging::ESmsBearerPacketPreferred==CSmsSettings::ESmsBearerPacketPreferred); |
|
39 C_ASSERT(RMobileSmsMessaging::ESmsBearerCircuitPreferred==CSmsSettings::ESmsBearerCircuitPreferred); |
|
40 |
|
41 const TInt16 KMsgFileSmsMessageSettingsVersion = 1; |
|
42 const TInt16 KMsgFileSmsNumberVersion = 2; |
|
43 const TInt KSmcmSCAddressGranularity = 8; |
|
44 |
|
45 |
|
46 /** |
|
47 Constructor. |
|
48 */ |
|
49 CSmsMessageSettings::CSmsMessageSettings() |
|
50 : CBase(), |
|
51 iValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet) |
|
52 { |
|
53 } |
|
54 |
|
55 /** |
|
56 Internalises the settings from a read stream. |
|
57 |
|
58 @param aReadStream |
|
59 The stream from which the settings should be internalised. |
|
60 */ |
|
61 EXPORT_C void CSmsMessageSettings::InternalizeL(RReadStream& aReadStream) |
|
62 { |
|
63 aReadStream.ReadInt16L(); // version - not used yet |
|
64 |
|
65 iValidityPeriod = aReadStream.ReadInt32L(); |
|
66 iValidityPeriodFormat = (TSmsFirstOctet::TSmsValidityPeriodFormat) aReadStream.ReadInt8L(); |
|
67 iAlphabet = (TSmsDataCodingScheme::TSmsAlphabet) aReadStream.ReadInt16L(); |
|
68 iMsgFlags = aReadStream.ReadUint32L(); |
|
69 iMessageConversion = (TSmsPIDConversion) aReadStream.ReadInt16L(); |
|
70 } |
|
71 |
|
72 /** |
|
73 Externalises the settings to a write stream. |
|
74 |
|
75 @param aWriteStream |
|
76 The stream to which the settings should be externalised. |
|
77 */ |
|
78 EXPORT_C void CSmsMessageSettings::ExternalizeL(RWriteStream& aWriteStream) const |
|
79 { |
|
80 aWriteStream.WriteInt16L(KMsgFileSmsMessageSettingsVersion); |
|
81 aWriteStream.WriteInt32L(iValidityPeriod.Int()); |
|
82 aWriteStream.WriteInt8L(iValidityPeriodFormat); |
|
83 aWriteStream.WriteInt16L(iAlphabet); |
|
84 aWriteStream.WriteUint32L(iMsgFlags); |
|
85 aWriteStream.WriteInt16L(iMessageConversion); |
|
86 } |
|
87 |
|
88 /** |
|
89 Copies the settings stored in the specified object into this object. |
|
90 |
|
91 @param aSettings |
|
92 The settings to be copied. |
|
93 */ |
|
94 EXPORT_C void CSmsMessageSettings::CopyL(const CSmsMessageSettings& aSettings) |
|
95 { |
|
96 iMsgFlags = aSettings.iMsgFlags; |
|
97 iMessageConversion = aSettings.iMessageConversion; |
|
98 iAlphabet = aSettings.iAlphabet; |
|
99 SetValidityPeriod(aSettings.ValidityPeriod()); |
|
100 SetValidityPeriodFormat(aSettings.ValidityPeriodFormat()); |
|
101 } |
|
102 |
|
103 /** |
|
104 Returns SMS message settings flag |
|
105 |
|
106 @return |
|
107 SMS message settings flag |
|
108 */ |
|
109 TUint32 CSmsMessageSettings::MessageFlags() const |
|
110 { |
|
111 return iMsgFlags; |
|
112 } |
|
113 |
|
114 /** |
|
115 Sets SMS message settings flag |
|
116 |
|
117 @param aMsgFlags |
|
118 SMS message settings flag |
|
119 */ |
|
120 void CSmsMessageSettings::SetMessageFlags(TUint32 aMsgFlags) |
|
121 { |
|
122 iMsgFlags = aMsgFlags; |
|
123 } |
|
124 |
|
125 /* |
|
126 * CSmsSettings |
|
127 */ |
|
128 |
|
129 /** |
|
130 Allocates and constructs an SMS settings object. |
|
131 |
|
132 Initialises all member data to their default values. |
|
133 |
|
134 @return |
|
135 The newly constructed SMS settings object. |
|
136 */ |
|
137 EXPORT_C CSmsSettings* CSmsSettings::NewL() |
|
138 { |
|
139 CSmsSettings* self = CSmsSettings::NewLC(); |
|
140 CleanupStack::Pop(self); |
|
141 return self; |
|
142 } |
|
143 |
|
144 /** |
|
145 Allocates and constructs an SMS settings object. |
|
146 |
|
147 Initialises all member data to their default values. |
|
148 |
|
149 @return |
|
150 The newly constructed SMS settings object. |
|
151 */ |
|
152 EXPORT_C CSmsSettings* CSmsSettings::NewLC() |
|
153 { |
|
154 CSmsSettings* self = new (ELeave) CSmsSettings(); |
|
155 CleanupStack::PushL(self); |
|
156 self->ConstructL(); |
|
157 return self; |
|
158 } |
|
159 |
|
160 /** |
|
161 Constructor. |
|
162 */ |
|
163 CSmsSettings::CSmsSettings() |
|
164 : CSmsMessageSettings(), |
|
165 iDefaultSC(-1), |
|
166 iStatusReportHandling(EDoNotWatchForReport), |
|
167 iSpecialMessageHandling(EDoNotWatchForReport), |
|
168 iCommDbAction(ENone), |
|
169 iSmsBearerAction(ENone), |
|
170 iSmsBearer(ESmsBearerCircuitPreferred), |
|
171 iClass2Folder(KMsvGlobalInBoxIndexEntryId), |
|
172 iDescriptionLength(KSmsDescriptionLength) |
|
173 { |
|
174 } |
|
175 |
|
176 /** |
|
177 Destructor. |
|
178 */ |
|
179 EXPORT_C CSmsSettings::~CSmsSettings() |
|
180 { |
|
181 if (iServiceCenters) |
|
182 { |
|
183 iServiceCenters->ResetAndDestroy(); |
|
184 delete iServiceCenters; |
|
185 } |
|
186 } |
|
187 |
|
188 /** |
|
189 Second phase construction. |
|
190 */ |
|
191 void CSmsSettings::ConstructL() |
|
192 { |
|
193 iServiceCenters = new (ELeave) CArrayPtrFlat<CSmsServiceCenter>(KSmcmSCAddressGranularity); |
|
194 } |
|
195 |
|
196 |
|
197 void CSmsSettings::StoreToCommDbL() const |
|
198 { |
|
199 if (iCommDbAction != EStoreToCommDb && iSmsBearerAction != EStoreToCommDb) |
|
200 return; // nothing to store to the Comm DB |
|
201 |
|
202 CMDBSession *dbSession = CMDBSession::NewL(KCDVersion1_2); |
|
203 CleanupStack::PushL(dbSession); |
|
204 |
|
205 //Create a CCDModemBearerRecord link field container to read the |
|
206 //RecordID in the CCDGlobalSettingsRecord.iModemForPhoneServicesAndSMS |
|
207 CMDBRecordLink<CCDModemBearerRecord> *modemBearerRecordSet = new(ELeave) CMDBRecordLink<CCDModemBearerRecord>(KCDTIdGlobalSettingsRecord | KCDTIdModemPhoneServicesSMS); |
|
208 CleanupStack::PushL(modemBearerRecordSet); |
|
209 |
|
210 //RecordID needs to be set to 1, as there is always just one GlobalSettings record |
|
211 modemBearerRecordSet->SetRecordId(1); |
|
212 |
|
213 //Load field container with data from database |
|
214 TRAPD(err, modemBearerRecordSet->LoadL(*dbSession)); |
|
215 if(err != KErrNone) |
|
216 { |
|
217 User::Leave(KErrNotFound); |
|
218 } |
|
219 |
|
220 if (iCommDbAction == EStoreToCommDb) |
|
221 { |
|
222 //Create a container for a ModemBearerRecord and read its contents |
|
223 CCDModemBearerRecord *modemRecord = static_cast<CCDModemBearerRecord*> (CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord)); |
|
224 CleanupStack::PushL(modemRecord); |
|
225 |
|
226 //Set the record ID to that previously read from CCDGlobalSettingsRecord.iModemForPhoneServicesAndSMS |
|
227 modemRecord->SetRecordId(*modemBearerRecordSet); |
|
228 |
|
229 //Load record container with data from database |
|
230 modemRecord->LoadL(*dbSession); |
|
231 |
|
232 if (iDefaultSC > -1 && iServiceCenters->Count()) |
|
233 { |
|
234 const TPtrC address = GetServiceCenter(iDefaultSC).Address(); |
|
235 modemRecord->iMessageCentreNumber.SetMaxLengthL(address.Length()); |
|
236 modemRecord->iMessageCentreNumber = address; |
|
237 } |
|
238 else |
|
239 { |
|
240 modemRecord->iMessageCentreNumber = KNullDesC; |
|
241 } |
|
242 |
|
243 const TUint32 valPeriod = (TUint32) ValidityPeriod().Int(); |
|
244 modemRecord->iMessageValidityPeriod = valPeriod; |
|
245 |
|
246 const TBool delReport = DeliveryReport() ? ETrue : EFalse; |
|
247 modemRecord->iMessageDeliveryReport = delReport; |
|
248 |
|
249 modemRecord->ModifyL(*dbSession); |
|
250 |
|
251 CleanupStack::PopAndDestroy(modemRecord); |
|
252 } |
|
253 |
|
254 if (iSmsBearerAction == EStoreToCommDb) |
|
255 { |
|
256 CCDGlobalSettingsRecord* globalSettingsRecord = static_cast<CCDGlobalSettingsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdGlobalSettingsRecord)); |
|
257 CleanupStack::PushL(globalSettingsRecord); |
|
258 |
|
259 //RecordID needs to be set to 1, as there is always just one GlobalSettings record |
|
260 globalSettingsRecord->SetRecordId(1); |
|
261 |
|
262 TRAPD(err, globalSettingsRecord->LoadL(*dbSession)); |
|
263 if(err != KErrNone) |
|
264 { |
|
265 User::Leave(KErrNotFound); |
|
266 } |
|
267 |
|
268 globalSettingsRecord->iSMSBearer = SmsBearer(); |
|
269 globalSettingsRecord->iSMSBearer.ModifyL(*dbSession); |
|
270 CleanupStack::PopAndDestroy(globalSettingsRecord); |
|
271 } |
|
272 |
|
273 CleanupStack::PopAndDestroy(modemBearerRecordSet); |
|
274 CleanupStack::PopAndDestroy(dbSession); |
|
275 } |
|
276 |
|
277 |
|
278 /** |
|
279 Gets the number of Service Centre addresses stored in this object. |
|
280 |
|
281 @return |
|
282 The number of addresses. |
|
283 */ |
|
284 EXPORT_C TInt CSmsSettings::ServiceCenterCount() const |
|
285 { |
|
286 return iServiceCenters->Count(); |
|
287 } |
|
288 |
|
289 /** |
|
290 Gets the Service Centre address at the specified index in the list. |
|
291 |
|
292 @param aIndex |
|
293 The index of the specified address. |
|
294 |
|
295 @return |
|
296 The indexed address. |
|
297 */ |
|
298 EXPORT_C CSmsServiceCenter& CSmsSettings::GetServiceCenter(TInt aIndex) const |
|
299 { |
|
300 return *iServiceCenters->At(aIndex); |
|
301 } |
|
302 |
|
303 /** |
|
304 Appends a service centre address (name and number) to the list. |
|
305 |
|
306 @param aName |
|
307 The Service Centre name |
|
308 |
|
309 @param aNumber |
|
310 The Service Centre number. |
|
311 */ |
|
312 EXPORT_C void CSmsSettings::AddServiceCenterL(const TDesC& aName,const TDesC& aNumber) |
|
313 { |
|
314 |
|
315 CSmsServiceCenter* recipient=CSmsServiceCenter::NewL(); |
|
316 CleanupStack::PushL(recipient); |
|
317 recipient->SetNameL(aName); |
|
318 recipient->SetAddressL(aNumber); |
|
319 |
|
320 iServiceCenters->AppendL(recipient); |
|
321 CleanupStack::Pop(recipient); |
|
322 |
|
323 if (iServiceCenters->Count() == 1 || iDefaultSC < 0) |
|
324 iDefaultSC = 0; |
|
325 } |
|
326 |
|
327 /** |
|
328 Removes the service centre address with index aIndex from the array of service |
|
329 centre addresses that are stored in the object. |
|
330 |
|
331 @param aIndex |
|
332 The index of the Service Centre address to remove. |
|
333 */ |
|
334 EXPORT_C void CSmsSettings::RemoveServiceCenter(TInt aIndex) |
|
335 { |
|
336 delete iServiceCenters->At(aIndex); |
|
337 iServiceCenters->Delete(aIndex); |
|
338 |
|
339 if (iDefaultSC == aIndex) |
|
340 { |
|
341 iDefaultSC = iServiceCenters->Count() ? 0 : -1; |
|
342 } |
|
343 else if (iDefaultSC > aIndex) |
|
344 { |
|
345 iDefaultSC--; |
|
346 } |
|
347 } |
|
348 |
|
349 /** |
|
350 Gets the index of the default service centre address for this service. |
|
351 |
|
352 @return |
|
353 The index of the default service centre address. |
|
354 */ |
|
355 EXPORT_C TInt CSmsSettings::DefaultServiceCenter() const |
|
356 { |
|
357 return iDefaultSC; |
|
358 } |
|
359 |
|
360 /** |
|
361 Sets the index of the default service centre address for this service. |
|
362 |
|
363 @param aDefaultSC |
|
364 An index into the list of the default service centre address. |
|
365 |
|
366 @panic SMCM 7 |
|
367 The specified index is negative or beyond the maximum index (debug only). |
|
368 */ |
|
369 EXPORT_C void CSmsSettings::SetDefaultServiceCenter(TInt aDefaultSC) |
|
370 { |
|
371 __ASSERT_DEBUG(aDefaultSC>=0, Panic(ESmscDefaultSCOutOfRange)); |
|
372 __ASSERT_DEBUG(aDefaultSC<iServiceCenters->Count(), Panic(ESmscDefaultSCOutOfRange)); |
|
373 |
|
374 iDefaultSC=aDefaultSC; |
|
375 } |
|
376 |
|
377 void CSmsSettings::RemoveSCAddresses() |
|
378 { |
|
379 iServiceCenters->ResetAndDestroy(); |
|
380 } |
|
381 |
|
382 /** |
|
383 Copies the SMS settings stored in the specified object into this object. |
|
384 |
|
385 @param aSmsSettings |
|
386 The SMS Settings to be copied. |
|
387 */ |
|
388 EXPORT_C void CSmsSettings::CopyL(const CSmsSettings& aSmsSettings) |
|
389 { |
|
390 CSmsMessageSettings::CopyL(aSmsSettings); |
|
391 |
|
392 iServiceCenters->ResetAndDestroy(); |
|
393 const TInt count = aSmsSettings.ServiceCenterCount(); |
|
394 for (TInt i=0; i < count; i++) |
|
395 { |
|
396 CSmsServiceCenter* scNumber = CSmsServiceCenter::NewL(aSmsSettings.GetServiceCenter(i)); |
|
397 CleanupStack::PushL(scNumber); |
|
398 iServiceCenters->AppendL(scNumber); |
|
399 CleanupStack::Pop(scNumber); |
|
400 } |
|
401 |
|
402 iDelivery = aSmsSettings.iDelivery; |
|
403 iDefaultSC = aSmsSettings.iDefaultSC; |
|
404 iSpecialMessageHandling = aSmsSettings.iSpecialMessageHandling; |
|
405 iStatusReportHandling = aSmsSettings.iStatusReportHandling; |
|
406 iSetFlags = aSmsSettings.iSetFlags; |
|
407 iCommDbAction = aSmsSettings.iCommDbAction; |
|
408 iSmsBearerAction = aSmsSettings.iSmsBearerAction; |
|
409 iSmsBearer = aSmsSettings.iSmsBearer; |
|
410 iClass2Folder = aSmsSettings.iClass2Folder; |
|
411 iDescriptionLength = aSmsSettings.iDescriptionLength; |
|
412 } |
|
413 |
|
414 /** |
|
415 Returns SMS settings flag |
|
416 |
|
417 @return |
|
418 SMS settings flag |
|
419 */ |
|
420 TUint32 CSmsSettings::SettingsFlags() const |
|
421 { |
|
422 return iSetFlags; |
|
423 } |
|
424 |
|
425 /** |
|
426 Sets SMS settings flag |
|
427 |
|
428 @param aSetFlags |
|
429 SMS settings flag |
|
430 */ |
|
431 void CSmsSettings::SetSettingsFlags(TUint32 aSetFlags) |
|
432 { |
|
433 iSetFlags = aSetFlags; |
|
434 } |
|
435 |
|
436 /* |
|
437 * CSmsNumber |
|
438 */ |
|
439 |
|
440 /** |
|
441 Creates and allocates a new CSmsNumber object. |
|
442 |
|
443 @return |
|
444 The new object. |
|
445 */ |
|
446 EXPORT_C CSmsNumber* CSmsNumber::NewL() |
|
447 { |
|
448 return new(ELeave) CSmsNumber(); |
|
449 } |
|
450 |
|
451 /** |
|
452 Creates and allocates a new CSmsNumber object, copying an existing object. |
|
453 |
|
454 @param aSmsNumber |
|
455 The object to be copied. |
|
456 |
|
457 @return |
|
458 The new object. |
|
459 */ |
|
460 EXPORT_C CSmsNumber* CSmsNumber::NewL(const CSmsNumber& aSmsNumber) |
|
461 { |
|
462 CSmsNumber* number=new(ELeave) CSmsNumber(); |
|
463 CleanupStack::PushL(number); |
|
464 number->CopyL(aSmsNumber); |
|
465 CleanupStack::Pop(number); |
|
466 return number; |
|
467 } |
|
468 |
|
469 /** |
|
470 Destructor. |
|
471 */ |
|
472 EXPORT_C CSmsNumber::~CSmsNumber() |
|
473 { |
|
474 delete iNumber; |
|
475 delete iName; |
|
476 } |
|
477 |
|
478 /** |
|
479 Internalises the object from a read stream. |
|
480 |
|
481 @param aStream |
|
482 The stream from which the object should be internalised. |
|
483 */ |
|
484 EXPORT_C void CSmsNumber::InternalizeL( RReadStream& aStream) |
|
485 { |
|
486 TInt16 version = aStream.ReadInt16L(); |
|
487 |
|
488 CMsvRecipient::InternalizeL(aStream); |
|
489 |
|
490 HBufC* number = HBufC::NewL(aStream, KSmcmSmsNumberMaxNumberLength); |
|
491 delete iNumber; |
|
492 iNumber = number; |
|
493 |
|
494 HBufC* name = HBufC::NewL(aStream, KSmcmSmsNumberMaxNameLength); |
|
495 delete iName; |
|
496 iName = name; |
|
497 |
|
498 iLogId = aStream.ReadInt32L(); |
|
499 |
|
500 if( version >= 2 ) |
|
501 { |
|
502 iDeliveryStatus = (TSmsAckStatus) aStream.ReadInt8L(); |
|
503 } |
|
504 else |
|
505 { |
|
506 iDeliveryStatus = ENoAckRequested; |
|
507 } |
|
508 } |
|
509 |
|
510 /** |
|
511 Externalises the object to a write stream. |
|
512 |
|
513 @param aStream |
|
514 The stream to which the object should be externalised. |
|
515 */ |
|
516 EXPORT_C void CSmsNumber::ExternalizeL( RWriteStream& aStream) const |
|
517 { |
|
518 aStream.WriteInt16L(KMsgFileSmsNumberVersion); |
|
519 |
|
520 CMsvRecipient::ExternalizeL(aStream); |
|
521 |
|
522 aStream << Address(); |
|
523 aStream << Name(); |
|
524 |
|
525 aStream.WriteInt32L(iLogId); |
|
526 aStream.WriteInt8L(iDeliveryStatus); |
|
527 } |
|
528 |
|
529 /** |
|
530 Constructor. |
|
531 */ |
|
532 CSmsNumber::CSmsNumber() |
|
533 : iLogId(KLogNullId) |
|
534 { |
|
535 } |
|
536 |
|
537 /** |
|
538 Copies settings from another CSmsNumber object. |
|
539 |
|
540 @param aSmsNumber |
|
541 The object to be copied. |
|
542 |
|
543 @return |
|
544 This object with the updated settings. |
|
545 */ |
|
546 EXPORT_C CSmsNumber& CSmsNumber::CopyL(const CSmsNumber& aSmsNumber) |
|
547 { |
|
548 SetNameL(aSmsNumber.Name()); |
|
549 SetAddressL(aSmsNumber.Address()); |
|
550 SetLogId(aSmsNumber.LogId()); |
|
551 SetAckStatus(ESmsAckTypeDelivery, aSmsNumber.AckStatus(ESmsAckTypeDelivery)); |
|
552 return *this; |
|
553 } |
|
554 |
|
555 /** |
|
556 Gets the recipient address. |
|
557 |
|
558 The address is a telephone number. It is limited to a maximum length specified |
|
559 by KSmcmSmsNumberMaxNumberLength. |
|
560 |
|
561 @see KSmcmSmsNumberMaxNumberLength |
|
562 |
|
563 @return |
|
564 A descriptor with the recipient address. |
|
565 */ |
|
566 EXPORT_C TPtrC CSmsNumber::Address() const |
|
567 { |
|
568 TPtrC number = iNumber ? iNumber->Des() : TPtrC(); |
|
569 return number; |
|
570 } |
|
571 |
|
572 /** |
|
573 Gets the recipient name. |
|
574 |
|
575 @return |
|
576 A descriptor with the recipient name. |
|
577 */ |
|
578 EXPORT_C TPtrC CSmsNumber::Name() const |
|
579 { |
|
580 TPtrC name = iName ? iName->Des() : TPtrC(); |
|
581 return name; |
|
582 } |
|
583 |
|
584 /** |
|
585 Sets the recipient address. |
|
586 |
|
587 The address is a telephone number. It is limited to a maximum length specified |
|
588 by KSmcmSmsNumberMaxNumberLength. |
|
589 |
|
590 @see KSmcmSmsNumberMaxNumberLength |
|
591 |
|
592 @param aAddress |
|
593 The recipient address. |
|
594 */ |
|
595 EXPORT_C void CSmsNumber::SetAddressL(const TDesC& aAddress) |
|
596 { |
|
597 TPtrC clippedNumber = LimitStringSize(aAddress, KSmcmSmsNumberMaxNumberLength); |
|
598 HBufC* number = clippedNumber.AllocL(); |
|
599 delete iNumber; |
|
600 iNumber = number; |
|
601 } |
|
602 |
|
603 /** |
|
604 Sets the recipient email address, The address here is a email address. |
|
605 |
|
606 @param aAddress |
|
607 The recipient address. |
|
608 @param aEmailFields |
|
609 Encapsulates the address fields for Email sent over SMS. |
|
610 @param aAlias |
|
611 */ |
|
612 |
|
613 // For address information separation (start) |
|
614 const TUint KMsgSmsAddressStartChar ('<'); |
|
615 // For address information separation (end) |
|
616 const TUint KMsgSmsAddressEndChar ('>'); |
|
617 |
|
618 void CSmsNumber::SetEmailAddressL(const TDesC& aAddress, CSmsEmailFields* aEmailFields, const TDesC& aAlias) |
|
619 { |
|
620 if ( aAlias.Length() > 0 ) |
|
621 { |
|
622 HBufC* aliasBuf = HBufC::NewLC( aAddress.Length() + aAlias.Length() + 3 ); |
|
623 TPtr aliasTPtr = aliasBuf->Des(); |
|
624 aliasTPtr.Append( aAlias ); |
|
625 aliasTPtr.Append( CEditableText::ESpace ); |
|
626 aliasTPtr.Append( KMsgSmsAddressStartChar ); |
|
627 aliasTPtr.Append( aAddress ); |
|
628 aliasTPtr.Append( KMsgSmsAddressEndChar ); |
|
629 aEmailFields->AddAddressL( aliasTPtr ); |
|
630 |
|
631 CleanupStack::PopAndDestroy( aliasBuf ); |
|
632 } |
|
633 else |
|
634 { |
|
635 aEmailFields->AddAddressL( aAddress ); |
|
636 } |
|
637 } |
|
638 |
|
639 /** |
|
640 Sets the recipient name. |
|
641 |
|
642 The name is limited to a maximum length specified by KSmcmSmsNumberMaxNameLength. |
|
643 |
|
644 @see KSmcmSmsNumberMaxNameLength |
|
645 |
|
646 @param aName |
|
647 The recipient name. |
|
648 */ |
|
649 EXPORT_C void CSmsNumber::SetNameL(const TDesC& aName) |
|
650 { |
|
651 TPtrC clippedName = LimitStringSize(aName, KSmcmSmsNumberMaxNameLength); |
|
652 HBufC* name = clippedName.AllocL(); |
|
653 delete iName; |
|
654 iName = name; |
|
655 } |
|
656 |
|
657 /** |
|
658 Gets the delivery status for this recipient. |
|
659 |
|
660 @return |
|
661 The current delivery status for this recipient. |
|
662 |
|
663 @see CSmsNumber::TSmsDeliveryStatus |
|
664 */ |
|
665 EXPORT_C CSmsNumber::TSmsAckStatus CSmsNumber::AckStatus(TSmsAckType aAckType) const |
|
666 { |
|
667 TSmsAckStatus status = ENoAckRequested; |
|
668 switch( aAckType ) |
|
669 { |
|
670 case ESmsAckTypeDelivery: |
|
671 status = iDeliveryStatus; |
|
672 break; |
|
673 default: |
|
674 // Use the default... |
|
675 break; |
|
676 } |
|
677 return status; |
|
678 } |
|
679 |
|
680 /** |
|
681 Sets the delivery status for this recipient. |
|
682 |
|
683 @param |
|
684 aDeliveryStatus The new delivery status for this recipient. |
|
685 |
|
686 @see CSmsNumber::TSmsDeliveryStatus |
|
687 */ |
|
688 EXPORT_C void CSmsNumber::SetAckStatus(TSmsAckType aAckType, TSmsAckStatus aAckStatus) |
|
689 { |
|
690 switch( aAckType ) |
|
691 { |
|
692 case ESmsAckTypeDelivery: |
|
693 iDeliveryStatus = aAckStatus; |
|
694 break; |
|
695 default: |
|
696 // Do nothing - fail gracefully |
|
697 break; |
|
698 } |
|
699 } |
|
700 |
|
701 /** |
|
702 Returns a limited version of the input string. |
|
703 |
|
704 The output string is limited by the maximum length specified or the actual# |
|
705 length of the input string, withever is the shortest. |
|
706 |
|
707 @param aString |
|
708 The input string to be limited. |
|
709 |
|
710 @param aMaxLength |
|
711 The maximum length |
|
712 |
|
713 @return |
|
714 The input string limited by the shortest value between its original length or |
|
715 the maximum length specified. |
|
716 */ |
|
717 TPtrC CSmsNumber::LimitStringSize(const TPtrC& aString, TInt aMaxLength) const |
|
718 { |
|
719 if (aString.Length() <= aMaxLength) |
|
720 return aString; |
|
721 else |
|
722 return aString.Left(aMaxLength); |
|
723 } |
|
724 |
|
725 /** |
|
726 Creates and allocates a new CSmsServiceCenter object. |
|
727 |
|
728 @return |
|
729 The new object. |
|
730 */ |
|
731 EXPORT_C CSmsServiceCenter* CSmsServiceCenter::NewL() |
|
732 { |
|
733 return new(ELeave) CSmsServiceCenter(); |
|
734 } |
|
735 |
|
736 /** |
|
737 Creates and allocates a new CSmsServiceCenter object, copying an existing object. |
|
738 |
|
739 @param CSmsServiceCenter |
|
740 The object to be copied. |
|
741 |
|
742 @return |
|
743 The new object. |
|
744 */ |
|
745 EXPORT_C CSmsServiceCenter* CSmsServiceCenter::NewL(const CSmsServiceCenter& aSmsSc) |
|
746 { |
|
747 CSmsServiceCenter* sc = new(ELeave) CSmsServiceCenter(); |
|
748 CleanupStack::PushL(sc); |
|
749 sc->CopyL(aSmsSc); |
|
750 CleanupStack::Pop(sc); |
|
751 return sc; |
|
752 } |
|
753 |
|
754 /** |
|
755 Destructor. |
|
756 */ |
|
757 EXPORT_C CSmsServiceCenter::~CSmsServiceCenter() |
|
758 { |
|
759 delete iNumber; |
|
760 delete iName; |
|
761 } |
|
762 |
|
763 /** |
|
764 Constructor. |
|
765 */ |
|
766 CSmsServiceCenter::CSmsServiceCenter() |
|
767 { |
|
768 } |
|
769 |
|
770 /** |
|
771 Copies settings from another CSmsServiceCenter object. |
|
772 |
|
773 @param aSmsSc |
|
774 The object to be copied. |
|
775 |
|
776 @return |
|
777 This object with the updated settings. |
|
778 */ |
|
779 EXPORT_C CSmsServiceCenter& CSmsServiceCenter::CopyL(const CSmsServiceCenter& aSmsSc) |
|
780 { |
|
781 SetNameL(aSmsSc.Name()); |
|
782 SetAddressL(aSmsSc.Address()); |
|
783 return *this; |
|
784 } |
|
785 |
|
786 /** |
|
787 Gets the recipient address. |
|
788 |
|
789 The address is a telephone number. It is limited to a maximum length specified |
|
790 by KSmcmSmsNumberMaxNumberLength. |
|
791 |
|
792 @see KSmcmSmsNumberMaxNumberLength |
|
793 |
|
794 @return |
|
795 A descriptor with the recipient address. |
|
796 */ |
|
797 EXPORT_C TPtrC CSmsServiceCenter::Address() const |
|
798 { |
|
799 TPtrC number = iNumber ? iNumber->Des() : TPtrC(); |
|
800 return number; |
|
801 } |
|
802 |
|
803 /** |
|
804 Gets the recipient name. |
|
805 |
|
806 @return |
|
807 A descriptor with the recipient name. |
|
808 */ |
|
809 EXPORT_C TPtrC CSmsServiceCenter::Name() const |
|
810 { |
|
811 TPtrC name = iName ? iName->Des() : TPtrC(); |
|
812 return name; |
|
813 } |
|
814 |
|
815 /** |
|
816 Sets the recipient address. |
|
817 |
|
818 The address is a telephone number. It is limited to a maximum length specified |
|
819 by KSmcmSmsNumberMaxNumberLength. |
|
820 |
|
821 @see KSmcmSmsNumberMaxNumberLength |
|
822 |
|
823 @param aAddress |
|
824 The recipient address. |
|
825 */ |
|
826 EXPORT_C void CSmsServiceCenter::SetAddressL(const TDesC& aAddress) |
|
827 { |
|
828 TPtrC clippedNumber = LimitStringSize(aAddress, KSmcmSmsNumberMaxNumberLength); |
|
829 HBufC* number = clippedNumber.AllocL(); |
|
830 delete iNumber; |
|
831 iNumber = number; |
|
832 } |
|
833 |
|
834 /** |
|
835 Sets the recipient name. |
|
836 |
|
837 The name is limited to a maximum length specified by KSmcmSmsNumberMaxNameLength. |
|
838 |
|
839 @see KSmcmSmsNumberMaxNameLength |
|
840 |
|
841 @param aName |
|
842 The recipient name. |
|
843 */ |
|
844 EXPORT_C void CSmsServiceCenter::SetNameL(const TDesC& aName) |
|
845 { |
|
846 TPtrC clippedName = LimitStringSize(aName, KSmcmSmsNumberMaxNameLength); |
|
847 HBufC* name = clippedName.AllocL(); |
|
848 delete iName; |
|
849 iName = name; |
|
850 } |
|
851 |
|
852 /** |
|
853 Returns a limited version of the input string. |
|
854 |
|
855 The output string is limited by the maximum length specified or the actual# |
|
856 length of the input string, withever is the shortest. |
|
857 |
|
858 @param aString |
|
859 The input string to be limited. |
|
860 |
|
861 @param aMaxLength |
|
862 The maximum length |
|
863 |
|
864 @return |
|
865 The input string limited by the shortest value between its original length or |
|
866 the maximum length specified. |
|
867 */ |
|
868 TPtrC CSmsServiceCenter::LimitStringSize(const TPtrC& aString, TInt aMaxLength) const |
|
869 { |
|
870 if (aString.Length() <= aMaxLength) |
|
871 { |
|
872 return aString; |
|
873 } |
|
874 else |
|
875 { |
|
876 return aString.Left(aMaxLength); |
|
877 } |
|
878 } |
|
879 |