|
1 // Copyright (c) 2003-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 // User includes |
|
17 #include "CVIEWCONTACTEXTENSION.h" |
|
18 |
|
19 |
|
20 /** Allocates and constructs a CViewContactExtension object |
|
21 * @param aLength initial MaxLenght of a contact buffer.*/ |
|
22 CViewContactExtension* CViewContactExtension::NewL(TInt aLength) |
|
23 { |
|
24 CViewContactExtension* extension=new(ELeave)CViewContactExtension(); |
|
25 CleanupStack::PushL(extension); |
|
26 extension->ConstructL(aLength); |
|
27 CleanupStack::Pop(extension); |
|
28 return extension; |
|
29 } |
|
30 |
|
31 /** |
|
32 * Second phase constructor. |
|
33 * @param aLength initial MaxLenght of a contact buffer. |
|
34 */ |
|
35 void CViewContactExtension::ConstructL(TInt aLength) |
|
36 { |
|
37 if (aLength > 0) |
|
38 { |
|
39 iFieldTextBuf = HBufC::NewL(aLength); |
|
40 } |
|
41 } |
|
42 |
|
43 /** |
|
44 * Default constructor |
|
45 */ |
|
46 CViewContactExtension::CViewContactExtension() |
|
47 : iFieldTextBuf(NULL) |
|
48 { |
|
49 } |
|
50 |
|
51 /** |
|
52 * Destructor |
|
53 */ |
|
54 CViewContactExtension::~CViewContactExtension() |
|
55 { |
|
56 delete iFieldTextBuf; |
|
57 } |
|
58 |
|
59 /** |
|
60 * Append the specified field data to any existing field data |
|
61 * |
|
62 * @param aField Field data |
|
63 */ |
|
64 void CViewContactExtension::AppendToFieldTextL(const TDesC& aField) |
|
65 { |
|
66 const TInt fieldLength = aField.Length(); |
|
67 |
|
68 if (fieldLength > 0) |
|
69 { |
|
70 if (!iFieldTextBuf) |
|
71 { |
|
72 iFieldTextBuf = aField.AllocL(); |
|
73 } |
|
74 else |
|
75 { |
|
76 const TInt length = iFieldTextBuf->Length(); |
|
77 const TInt maxLength = iFieldTextBuf->Des().MaxLength(); |
|
78 |
|
79 if (length + fieldLength > maxLength) |
|
80 { |
|
81 iFieldTextBuf = iFieldTextBuf->ReAllocL(length + fieldLength); |
|
82 } |
|
83 iFieldTextBuf->Des().Append(aField); |
|
84 } |
|
85 } |
|
86 } |