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(CMDBSession::LatestVersion()); |
|
203 CleanupStack::PushL(dbSession); |
|
204 CMDBRecordSet<CCDGlobalSettingsRecord> globalSettingsRecord(KCDTIdGlobalSettingsRecord); |
|
205 TRAPD(err, globalSettingsRecord.LoadL(*dbSession)); |
|
206 if(err != KErrNone) |
|
207 { |
|
208 User::Leave(KErrNotFound); |
|
209 } |
|
210 |
|
211 if (iCommDbAction == EStoreToCommDb) |
|
212 { |
|
213 CCDModemBearerRecord *modemRecord = (CCDModemBearerRecord*)(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord)); |
|
214 CleanupStack::PushL(modemRecord); |
|
215 modemRecord->SetRecordId(((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iModemForPhoneServicesAndSMS); |
|
216 modemRecord->LoadL(*dbSession); |
|
217 |
|
218 if (iDefaultSC > -1 && iServiceCenters->Count()) |
|
219 { |
|
220 const TPtrC address = GetServiceCenter(iDefaultSC).Address(); |
|
221 modemRecord->iMessageCentreNumber.SetMaxLengthL(address.Length()); |
|
222 modemRecord->iMessageCentreNumber = address; |
|
223 } |
|
224 else |
|
225 { |
|
226 modemRecord->iMessageCentreNumber = KNullDesC; |
|
227 } |
|
228 |
|
229 const TUint32 valPeriod = (TUint32) ValidityPeriod().Int(); |
|
230 modemRecord->iMessageValidityPeriod = valPeriod; |
|
231 |
|
232 const TBool delReport = DeliveryReport() ? ETrue : EFalse; |
|
233 modemRecord->iMessageDeliveryReport = delReport; |
|
234 modemRecord->ModifyL(*dbSession); |
|
235 CleanupStack::PopAndDestroy(modemRecord); |
|
236 } |
|
237 |
|
238 if (iSmsBearerAction == EStoreToCommDb) |
|
239 { |
|
240 ((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iSMSBearer = iSmsBearer; |
|
241 ((CCDGlobalSettingsRecord*)globalSettingsRecord.iRecords[0])->iSMSBearer.ModifyL(*dbSession); |
|
242 } |
|
243 |
|
244 CleanupStack::PopAndDestroy(dbSession); |
|
245 } |
|
246 |
|
247 |
|
248 /** |
|
249 Gets the number of Service Centre addresses stored in this object. |
|
250 |
|
251 @return |
|
252 The number of addresses. |
|
253 */ |
|
254 EXPORT_C TInt CSmsSettings::ServiceCenterCount() const |
|
255 { |
|
256 return iServiceCenters->Count(); |
|
257 } |
|
258 |
|
259 /** |
|
260 Gets the Service Centre address at the specified index in the list. |
|
261 |
|
262 @param aIndex |
|
263 The index of the specified address. |
|
264 |
|
265 @return |
|
266 The indexed address. |
|
267 */ |
|
268 EXPORT_C CSmsServiceCenter& CSmsSettings::GetServiceCenter(TInt aIndex) const |
|
269 { |
|
270 return *iServiceCenters->At(aIndex); |
|
271 } |
|
272 |
|
273 /** |
|
274 Appends a service centre address (name and number) to the list. |
|
275 |
|
276 @param aName |
|
277 The Service Centre name |
|
278 |
|
279 @param aNumber |
|
280 The Service Centre number. |
|
281 */ |
|
282 EXPORT_C void CSmsSettings::AddServiceCenterL(const TDesC& aName,const TDesC& aNumber) |
|
283 { |
|
284 |
|
285 CSmsServiceCenter* recipient=CSmsServiceCenter::NewL(); |
|
286 CleanupStack::PushL(recipient); |
|
287 recipient->SetNameL(aName); |
|
288 recipient->SetAddressL(aNumber); |
|
289 |
|
290 iServiceCenters->AppendL(recipient); |
|
291 CleanupStack::Pop(recipient); |
|
292 |
|
293 if (iServiceCenters->Count() == 1 || iDefaultSC < 0) |
|
294 iDefaultSC = 0; |
|
295 } |
|
296 |
|
297 /** |
|
298 Removes the service centre address with index aIndex from the array of service |
|
299 centre addresses that are stored in the object. |
|
300 |
|
301 @param aIndex |
|
302 The index of the Service Centre address to remove. |
|
303 */ |
|
304 EXPORT_C void CSmsSettings::RemoveServiceCenter(TInt aIndex) |
|
305 { |
|
306 delete iServiceCenters->At(aIndex); |
|
307 iServiceCenters->Delete(aIndex); |
|
308 |
|
309 if (iDefaultSC == aIndex) |
|
310 { |
|
311 iDefaultSC = iServiceCenters->Count() ? 0 : -1; |
|
312 } |
|
313 else if (iDefaultSC > aIndex) |
|
314 { |
|
315 iDefaultSC--; |
|
316 } |
|
317 } |
|
318 |
|
319 /** |
|
320 Gets the index of the default service centre address for this service. |
|
321 |
|
322 @return |
|
323 The index of the default service centre address. |
|
324 */ |
|
325 EXPORT_C TInt CSmsSettings::DefaultServiceCenter() const |
|
326 { |
|
327 return iDefaultSC; |
|
328 } |
|
329 |
|
330 /** |
|
331 Sets the index of the default service centre address for this service. |
|
332 |
|
333 @param aDefaultSC |
|
334 An index into the list of the default service centre address. |
|
335 |
|
336 @panic SMCM 7 |
|
337 The specified index is negative or beyond the maximum index (debug only). |
|
338 */ |
|
339 EXPORT_C void CSmsSettings::SetDefaultServiceCenter(TInt aDefaultSC) |
|
340 { |
|
341 __ASSERT_DEBUG(aDefaultSC>=0, Panic(ESmscDefaultSCOutOfRange)); |
|
342 __ASSERT_DEBUG(aDefaultSC<iServiceCenters->Count(), Panic(ESmscDefaultSCOutOfRange)); |
|
343 |
|
344 iDefaultSC=aDefaultSC; |
|
345 } |
|
346 |
|
347 void CSmsSettings::RemoveSCAddresses() |
|
348 { |
|
349 iServiceCenters->ResetAndDestroy(); |
|
350 } |
|
351 |
|
352 /** |
|
353 Copies the SMS settings stored in the specified object into this object. |
|
354 |
|
355 @param aSmsSettings |
|
356 The SMS Settings to be copied. |
|
357 */ |
|
358 EXPORT_C void CSmsSettings::CopyL(const CSmsSettings& aSmsSettings) |
|
359 { |
|
360 CSmsMessageSettings::CopyL(aSmsSettings); |
|
361 |
|
362 iServiceCenters->ResetAndDestroy(); |
|
363 const TInt count = aSmsSettings.ServiceCenterCount(); |
|
364 for (TInt i=0; i < count; i++) |
|
365 { |
|
366 CSmsServiceCenter* scNumber = CSmsServiceCenter::NewL(aSmsSettings.GetServiceCenter(i)); |
|
367 CleanupStack::PushL(scNumber); |
|
368 iServiceCenters->AppendL(scNumber); |
|
369 CleanupStack::Pop(scNumber); |
|
370 } |
|
371 |
|
372 iDelivery = aSmsSettings.iDelivery; |
|
373 iDefaultSC = aSmsSettings.iDefaultSC; |
|
374 iSpecialMessageHandling = aSmsSettings.iSpecialMessageHandling; |
|
375 iStatusReportHandling = aSmsSettings.iStatusReportHandling; |
|
376 iSetFlags = aSmsSettings.iSetFlags; |
|
377 iCommDbAction = aSmsSettings.iCommDbAction; |
|
378 iSmsBearerAction = aSmsSettings.iSmsBearerAction; |
|
379 iSmsBearer = aSmsSettings.iSmsBearer; |
|
380 iClass2Folder = aSmsSettings.iClass2Folder; |
|
381 iDescriptionLength = aSmsSettings.iDescriptionLength; |
|
382 } |
|
383 |
|
384 /** |
|
385 Returns SMS settings flag |
|
386 |
|
387 @return |
|
388 SMS settings flag |
|
389 */ |
|
390 TUint32 CSmsSettings::SettingsFlags() const |
|
391 { |
|
392 return iSetFlags; |
|
393 } |
|
394 |
|
395 /** |
|
396 Sets SMS settings flag |
|
397 |
|
398 @param aSetFlags |
|
399 SMS settings flag |
|
400 */ |
|
401 void CSmsSettings::SetSettingsFlags(TUint32 aSetFlags) |
|
402 { |
|
403 iSetFlags = aSetFlags; |
|
404 } |
|
405 |
|
406 /* |
|
407 * CSmsNumber |
|
408 */ |
|
409 |
|
410 /** |
|
411 Creates and allocates a new CSmsNumber object. |
|
412 |
|
413 @return |
|
414 The new object. |
|
415 */ |
|
416 EXPORT_C CSmsNumber* CSmsNumber::NewL() |
|
417 { |
|
418 return new(ELeave) CSmsNumber(); |
|
419 } |
|
420 |
|
421 /** |
|
422 Creates and allocates a new CSmsNumber object, copying an existing object. |
|
423 |
|
424 @param aSmsNumber |
|
425 The object to be copied. |
|
426 |
|
427 @return |
|
428 The new object. |
|
429 */ |
|
430 EXPORT_C CSmsNumber* CSmsNumber::NewL(const CSmsNumber& aSmsNumber) |
|
431 { |
|
432 CSmsNumber* number=new(ELeave) CSmsNumber(); |
|
433 CleanupStack::PushL(number); |
|
434 number->CopyL(aSmsNumber); |
|
435 CleanupStack::Pop(number); |
|
436 return number; |
|
437 } |
|
438 |
|
439 /** |
|
440 Destructor. |
|
441 */ |
|
442 EXPORT_C CSmsNumber::~CSmsNumber() |
|
443 { |
|
444 delete iNumber; |
|
445 delete iName; |
|
446 } |
|
447 |
|
448 /** |
|
449 Internalises the object from a read stream. |
|
450 |
|
451 @param aStream |
|
452 The stream from which the object should be internalised. |
|
453 */ |
|
454 EXPORT_C void CSmsNumber::InternalizeL( RReadStream& aStream) |
|
455 { |
|
456 TInt16 version = aStream.ReadInt16L(); |
|
457 |
|
458 CMsvRecipient::InternalizeL(aStream); |
|
459 |
|
460 HBufC* number = HBufC::NewL(aStream, KSmcmSmsNumberMaxNumberLength); |
|
461 delete iNumber; |
|
462 iNumber = number; |
|
463 |
|
464 HBufC* name = HBufC::NewL(aStream, KSmcmSmsNumberMaxNameLength); |
|
465 delete iName; |
|
466 iName = name; |
|
467 |
|
468 iLogId = aStream.ReadInt32L(); |
|
469 |
|
470 if( version >= 2 ) |
|
471 { |
|
472 iDeliveryStatus = (TSmsAckStatus) aStream.ReadInt8L(); |
|
473 } |
|
474 else |
|
475 { |
|
476 iDeliveryStatus = ENoAckRequested; |
|
477 } |
|
478 } |
|
479 |
|
480 /** |
|
481 Externalises the object to a write stream. |
|
482 |
|
483 @param aStream |
|
484 The stream to which the object should be externalised. |
|
485 */ |
|
486 EXPORT_C void CSmsNumber::ExternalizeL( RWriteStream& aStream) const |
|
487 { |
|
488 aStream.WriteInt16L(KMsgFileSmsNumberVersion); |
|
489 |
|
490 CMsvRecipient::ExternalizeL(aStream); |
|
491 |
|
492 aStream << Address(); |
|
493 aStream << Name(); |
|
494 |
|
495 aStream.WriteInt32L(iLogId); |
|
496 aStream.WriteInt8L(iDeliveryStatus); |
|
497 } |
|
498 |
|
499 /** |
|
500 Constructor. |
|
501 */ |
|
502 CSmsNumber::CSmsNumber() |
|
503 : iLogId(KLogNullId) |
|
504 { |
|
505 } |
|
506 |
|
507 /** |
|
508 Copies settings from another CSmsNumber object. |
|
509 |
|
510 @param aSmsNumber |
|
511 The object to be copied. |
|
512 |
|
513 @return |
|
514 This object with the updated settings. |
|
515 */ |
|
516 EXPORT_C CSmsNumber& CSmsNumber::CopyL(const CSmsNumber& aSmsNumber) |
|
517 { |
|
518 SetNameL(aSmsNumber.Name()); |
|
519 SetAddressL(aSmsNumber.Address()); |
|
520 SetLogId(aSmsNumber.LogId()); |
|
521 SetAckStatus(ESmsAckTypeDelivery, aSmsNumber.AckStatus(ESmsAckTypeDelivery)); |
|
522 return *this; |
|
523 } |
|
524 |
|
525 /** |
|
526 Gets the recipient address. |
|
527 |
|
528 The address is a telephone number. It is limited to a maximum length specified |
|
529 by KSmcmSmsNumberMaxNumberLength. |
|
530 |
|
531 @see KSmcmSmsNumberMaxNumberLength |
|
532 |
|
533 @return |
|
534 A descriptor with the recipient address. |
|
535 */ |
|
536 EXPORT_C TPtrC CSmsNumber::Address() const |
|
537 { |
|
538 TPtrC number = iNumber ? iNumber->Des() : TPtrC(); |
|
539 return number; |
|
540 } |
|
541 |
|
542 /** |
|
543 Gets the recipient name. |
|
544 |
|
545 @return |
|
546 A descriptor with the recipient name. |
|
547 */ |
|
548 EXPORT_C TPtrC CSmsNumber::Name() const |
|
549 { |
|
550 TPtrC name = iName ? iName->Des() : TPtrC(); |
|
551 return name; |
|
552 } |
|
553 |
|
554 /** |
|
555 Sets the recipient address. |
|
556 |
|
557 The address is a telephone number. It is limited to a maximum length specified |
|
558 by KSmcmSmsNumberMaxNumberLength. |
|
559 |
|
560 @see KSmcmSmsNumberMaxNumberLength |
|
561 |
|
562 @param aAddress |
|
563 The recipient address. |
|
564 */ |
|
565 EXPORT_C void CSmsNumber::SetAddressL(const TDesC& aAddress) |
|
566 { |
|
567 TPtrC clippedNumber = LimitStringSize(aAddress, KSmcmSmsNumberMaxNumberLength); |
|
568 HBufC* number = clippedNumber.AllocL(); |
|
569 delete iNumber; |
|
570 iNumber = number; |
|
571 } |
|
572 |
|
573 /** |
|
574 Sets the recipient email address, The address here is a email address. |
|
575 |
|
576 @param aAddress |
|
577 The recipient address. |
|
578 @param aEmailFields |
|
579 Encapsulates the address fields for Email sent over SMS. |
|
580 @param aAlias |
|
581 */ |
|
582 |
|
583 // For address information separation (start) |
|
584 const TUint KMsgSmsAddressStartChar ('<'); |
|
585 // For address information separation (end) |
|
586 const TUint KMsgSmsAddressEndChar ('>'); |
|
587 |
|
588 void CSmsNumber::SetEmailAddressL(const TDesC& aAddress, CSmsEmailFields* aEmailFields, const TDesC& aAlias) |
|
589 { |
|
590 if ( aAlias.Length() > 0 ) |
|
591 { |
|
592 HBufC* aliasBuf = HBufC::NewLC( aAddress.Length() + aAlias.Length() + 3 ); |
|
593 TPtr aliasTPtr = aliasBuf->Des(); |
|
594 aliasTPtr.Append( aAlias ); |
|
595 aliasTPtr.Append( CEditableText::ESpace ); |
|
596 aliasTPtr.Append( KMsgSmsAddressStartChar ); |
|
597 aliasTPtr.Append( aAddress ); |
|
598 aliasTPtr.Append( KMsgSmsAddressEndChar ); |
|
599 aEmailFields->AddAddressL( aliasTPtr ); |
|
600 |
|
601 CleanupStack::PopAndDestroy( aliasBuf ); |
|
602 } |
|
603 else |
|
604 { |
|
605 aEmailFields->AddAddressL( aAddress ); |
|
606 } |
|
607 } |
|
608 |
|
609 /** |
|
610 Sets the recipient name. |
|
611 |
|
612 The name is limited to a maximum length specified by KSmcmSmsNumberMaxNameLength. |
|
613 |
|
614 @see KSmcmSmsNumberMaxNameLength |
|
615 |
|
616 @param aName |
|
617 The recipient name. |
|
618 */ |
|
619 EXPORT_C void CSmsNumber::SetNameL(const TDesC& aName) |
|
620 { |
|
621 TPtrC clippedName = LimitStringSize(aName, KSmcmSmsNumberMaxNameLength); |
|
622 HBufC* name = clippedName.AllocL(); |
|
623 delete iName; |
|
624 iName = name; |
|
625 } |
|
626 |
|
627 /** |
|
628 Gets the delivery status for this recipient. |
|
629 |
|
630 @return |
|
631 The current delivery status for this recipient. |
|
632 |
|
633 @see CSmsNumber::TSmsDeliveryStatus |
|
634 */ |
|
635 EXPORT_C CSmsNumber::TSmsAckStatus CSmsNumber::AckStatus(TSmsAckType aAckType) const |
|
636 { |
|
637 TSmsAckStatus status = ENoAckRequested; |
|
638 switch( aAckType ) |
|
639 { |
|
640 case ESmsAckTypeDelivery: |
|
641 status = iDeliveryStatus; |
|
642 break; |
|
643 default: |
|
644 // Use the default... |
|
645 break; |
|
646 } |
|
647 return status; |
|
648 } |
|
649 |
|
650 /** |
|
651 Sets the delivery status for this recipient. |
|
652 |
|
653 @param |
|
654 aDeliveryStatus The new delivery status for this recipient. |
|
655 |
|
656 @see CSmsNumber::TSmsDeliveryStatus |
|
657 */ |
|
658 EXPORT_C void CSmsNumber::SetAckStatus(TSmsAckType aAckType, TSmsAckStatus aAckStatus) |
|
659 { |
|
660 switch( aAckType ) |
|
661 { |
|
662 case ESmsAckTypeDelivery: |
|
663 iDeliveryStatus = aAckStatus; |
|
664 break; |
|
665 default: |
|
666 // Do nothing - fail gracefully |
|
667 break; |
|
668 } |
|
669 } |
|
670 |
|
671 /** |
|
672 Returns a limited version of the input string. |
|
673 |
|
674 The output string is limited by the maximum length specified or the actual# |
|
675 length of the input string, withever is the shortest. |
|
676 |
|
677 @param aString |
|
678 The input string to be limited. |
|
679 |
|
680 @param aMaxLength |
|
681 The maximum length |
|
682 |
|
683 @return |
|
684 The input string limited by the shortest value between its original length or |
|
685 the maximum length specified. |
|
686 */ |
|
687 TPtrC CSmsNumber::LimitStringSize(const TPtrC& aString, TInt aMaxLength) const |
|
688 { |
|
689 if (aString.Length() <= aMaxLength) |
|
690 return aString; |
|
691 else |
|
692 return aString.Left(aMaxLength); |
|
693 } |
|
694 |
|
695 /** |
|
696 Creates and allocates a new CSmsServiceCenter object. |
|
697 |
|
698 @return |
|
699 The new object. |
|
700 */ |
|
701 EXPORT_C CSmsServiceCenter* CSmsServiceCenter::NewL() |
|
702 { |
|
703 return new(ELeave) CSmsServiceCenter(); |
|
704 } |
|
705 |
|
706 /** |
|
707 Creates and allocates a new CSmsServiceCenter object, copying an existing object. |
|
708 |
|
709 @param CSmsServiceCenter |
|
710 The object to be copied. |
|
711 |
|
712 @return |
|
713 The new object. |
|
714 */ |
|
715 EXPORT_C CSmsServiceCenter* CSmsServiceCenter::NewL(const CSmsServiceCenter& aSmsSc) |
|
716 { |
|
717 CSmsServiceCenter* sc = new(ELeave) CSmsServiceCenter(); |
|
718 CleanupStack::PushL(sc); |
|
719 sc->CopyL(aSmsSc); |
|
720 CleanupStack::Pop(sc); |
|
721 return sc; |
|
722 } |
|
723 |
|
724 /** |
|
725 Destructor. |
|
726 */ |
|
727 EXPORT_C CSmsServiceCenter::~CSmsServiceCenter() |
|
728 { |
|
729 delete iNumber; |
|
730 delete iName; |
|
731 } |
|
732 |
|
733 /** |
|
734 Constructor. |
|
735 */ |
|
736 CSmsServiceCenter::CSmsServiceCenter() |
|
737 { |
|
738 } |
|
739 |
|
740 /** |
|
741 Copies settings from another CSmsServiceCenter object. |
|
742 |
|
743 @param aSmsSc |
|
744 The object to be copied. |
|
745 |
|
746 @return |
|
747 This object with the updated settings. |
|
748 */ |
|
749 EXPORT_C CSmsServiceCenter& CSmsServiceCenter::CopyL(const CSmsServiceCenter& aSmsSc) |
|
750 { |
|
751 SetNameL(aSmsSc.Name()); |
|
752 SetAddressL(aSmsSc.Address()); |
|
753 return *this; |
|
754 } |
|
755 |
|
756 /** |
|
757 Gets the recipient address. |
|
758 |
|
759 The address is a telephone number. It is limited to a maximum length specified |
|
760 by KSmcmSmsNumberMaxNumberLength. |
|
761 |
|
762 @see KSmcmSmsNumberMaxNumberLength |
|
763 |
|
764 @return |
|
765 A descriptor with the recipient address. |
|
766 */ |
|
767 EXPORT_C TPtrC CSmsServiceCenter::Address() const |
|
768 { |
|
769 TPtrC number = iNumber ? iNumber->Des() : TPtrC(); |
|
770 return number; |
|
771 } |
|
772 |
|
773 /** |
|
774 Gets the recipient name. |
|
775 |
|
776 @return |
|
777 A descriptor with the recipient name. |
|
778 */ |
|
779 EXPORT_C TPtrC CSmsServiceCenter::Name() const |
|
780 { |
|
781 TPtrC name = iName ? iName->Des() : TPtrC(); |
|
782 return name; |
|
783 } |
|
784 |
|
785 /** |
|
786 Sets the recipient address. |
|
787 |
|
788 The address is a telephone number. It is limited to a maximum length specified |
|
789 by KSmcmSmsNumberMaxNumberLength. |
|
790 |
|
791 @see KSmcmSmsNumberMaxNumberLength |
|
792 |
|
793 @param aAddress |
|
794 The recipient address. |
|
795 */ |
|
796 EXPORT_C void CSmsServiceCenter::SetAddressL(const TDesC& aAddress) |
|
797 { |
|
798 TPtrC clippedNumber = LimitStringSize(aAddress, KSmcmSmsNumberMaxNumberLength); |
|
799 HBufC* number = clippedNumber.AllocL(); |
|
800 delete iNumber; |
|
801 iNumber = number; |
|
802 } |
|
803 |
|
804 /** |
|
805 Sets the recipient name. |
|
806 |
|
807 The name is limited to a maximum length specified by KSmcmSmsNumberMaxNameLength. |
|
808 |
|
809 @see KSmcmSmsNumberMaxNameLength |
|
810 |
|
811 @param aName |
|
812 The recipient name. |
|
813 */ |
|
814 EXPORT_C void CSmsServiceCenter::SetNameL(const TDesC& aName) |
|
815 { |
|
816 TPtrC clippedName = LimitStringSize(aName, KSmcmSmsNumberMaxNameLength); |
|
817 HBufC* name = clippedName.AllocL(); |
|
818 delete iName; |
|
819 iName = name; |
|
820 } |
|
821 |
|
822 /** |
|
823 Returns a limited version of the input string. |
|
824 |
|
825 The output string is limited by the maximum length specified or the actual# |
|
826 length of the input string, withever is the shortest. |
|
827 |
|
828 @param aString |
|
829 The input string to be limited. |
|
830 |
|
831 @param aMaxLength |
|
832 The maximum length |
|
833 |
|
834 @return |
|
835 The input string limited by the shortest value between its original length or |
|
836 the maximum length specified. |
|
837 */ |
|
838 TPtrC CSmsServiceCenter::LimitStringSize(const TPtrC& aString, TInt aMaxLength) const |
|
839 { |
|
840 if (aString.Length() <= aMaxLength) |
|
841 { |
|
842 return aString; |
|
843 } |
|
844 else |
|
845 { |
|
846 return aString.Left(aMaxLength); |
|
847 } |
|
848 } |
|
849 |
|