|
1 /* |
|
2 * Copyright (c) 2006 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: Contact identifier used with virtual phonebook |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "MPhCntContactManager.h" |
|
20 #include "cphcntvpbkcontactid.h" |
|
21 #include "MVPbkContactLink.h" |
|
22 |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Constructor |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CPhCntVPbkContactId::CPhCntVPbkContactId( |
|
31 MVPbkContactLink* aContactLink, |
|
32 MPhCntContactManager& aContactManager ) : |
|
33 iContactLink( aContactLink ), |
|
34 iContactManager( aContactManager ) |
|
35 { |
|
36 } |
|
37 |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // ConstructL |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 void CPhCntVPbkContactId::ConstructL( |
|
44 TContactItemId aContactItemId ) |
|
45 { |
|
46 iContactLink = |
|
47 iContactManager.ConvertContactIdToLinkL( aContactItemId ); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // ConstructL |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void CPhCntVPbkContactId::ConstructL( const TDesC8& aContactLink ) |
|
55 { |
|
56 iContactLink = |
|
57 iContactManager.ConvertDescriptorToLinkL( aContactLink ); |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Static constructor |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CPhCntVPbkContactId* CPhCntVPbkContactId::NewL( |
|
65 MVPbkContactLink* aContactLink, |
|
66 MPhCntContactManager& aContactManager ) |
|
67 { |
|
68 CPhCntVPbkContactId* self = |
|
69 CPhCntVPbkContactId::NewLC( aContactLink, aContactManager ); |
|
70 CleanupStack::Pop( self ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // Static constructor |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 CPhCntVPbkContactId* CPhCntVPbkContactId::NewLC( |
|
80 TContactItemId aContactId, |
|
81 MPhCntContactManager& aContactManager ) |
|
82 { |
|
83 CPhCntVPbkContactId* self = |
|
84 new( ELeave ) CPhCntVPbkContactId( |
|
85 NULL, aContactManager ); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL( aContactId ); |
|
88 return self; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Static constructor |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CPhCntVPbkContactId* CPhCntVPbkContactId::NewL( |
|
96 TContactItemId aContactId, |
|
97 MPhCntContactManager& aContactManager ) |
|
98 { |
|
99 CPhCntVPbkContactId* self = |
|
100 CPhCntVPbkContactId::NewLC( aContactId, aContactManager ); |
|
101 CleanupStack::Pop( self ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // Static constructor |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CPhCntVPbkContactId* CPhCntVPbkContactId::NewLC( |
|
111 MVPbkContactLink* aContactLink, |
|
112 MPhCntContactManager& aContactManager ) |
|
113 { |
|
114 CPhCntVPbkContactId* self = |
|
115 new( ELeave ) CPhCntVPbkContactId( |
|
116 aContactLink, |
|
117 aContactManager ); |
|
118 CleanupStack::PushL( self ); |
|
119 return self; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // Static constructor |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CPhCntVPbkContactId* CPhCntVPbkContactId::NewL( |
|
127 const TDesC8& aContactLink, |
|
128 MPhCntContactManager& aContactManager ) |
|
129 { |
|
130 CPhCntVPbkContactId* self = |
|
131 new( ELeave )CPhCntVPbkContactId( NULL, aContactManager ); |
|
132 CleanupStack::PushL( self ); |
|
133 self->ConstructL( aContactLink ); |
|
134 CleanupStack::Pop( self ); |
|
135 return self; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // Destructor |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 CPhCntVPbkContactId::~CPhCntVPbkContactId() |
|
143 { |
|
144 delete iContactLink; |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // Gives the contact link |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 const MVPbkContactLink& CPhCntVPbkContactId::ContactLink() const |
|
152 { |
|
153 return *iContactLink; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // From class CPhCntContactId |
|
158 // Clones this object. |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 CPhCntContactId* CPhCntVPbkContactId::CloneL() const |
|
162 { |
|
163 CPhCntContactId* clone = NULL; |
|
164 if( iContactLink ) |
|
165 { |
|
166 MVPbkContactLink* clonedLink = iContactLink->CloneLC(); |
|
167 clone = CPhCntVPbkContactId::NewL( clonedLink, iContactManager ); |
|
168 CleanupStack::Pop(); // clonedLink |
|
169 } |
|
170 return clone; |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // From class CPhCntContactId |
|
175 // Invalidates this contact id |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CPhCntVPbkContactId::Invalidate() |
|
179 { |
|
180 delete iContactLink; |
|
181 iContactLink = NULL; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // From class CPhCntContactId |
|
186 // Is valid |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 TBool CPhCntVPbkContactId::IsValid() const |
|
190 { |
|
191 TBool isValid = EFalse; |
|
192 if( iContactLink ) |
|
193 { |
|
194 isValid = ETrue; |
|
195 } |
|
196 return isValid; |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // From class CPhCntContactId |
|
201 // Contact id |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 TContactItemId CPhCntVPbkContactId::ContactId() const |
|
205 { |
|
206 TContactItemId contactId = KNullContactId; |
|
207 if( iContactLink ) |
|
208 { |
|
209 contactId = iContactManager.ConvertContactLinkToContactId( *iContactLink ); |
|
210 } |
|
211 return contactId; |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // From class CPhCntContactId |
|
216 // Packs contact link. |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 HBufC8* CPhCntVPbkContactId::PackLC() const |
|
220 { |
|
221 HBufC8* pack = NULL; |
|
222 if( iContactLink ) |
|
223 { |
|
224 pack = iContactLink->PackLC(); |
|
225 } |
|
226 return pack; |
|
227 } |