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