1 /* |
|
2 * Copyright (c) 2006-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: Implementation of Internal address info structure. |
|
15 */ |
|
16 |
|
17 #include "internaladdressinfo.h" |
|
18 #include "locationmanagerdebug.h" |
|
19 |
|
20 |
|
21 |
|
22 // ---------------------------------------------------------------------------- |
|
23 // CInternalAddressInfo::CInternalAddressInfo() |
|
24 // Constructor |
|
25 // ---------------------------------------------------------------------------- |
|
26 CInternalAddressInfo::CInternalAddressInfo(): iCountryName( NULL ), |
|
27 iState( NULL ), |
|
28 iCity( NULL ), |
|
29 iDistrict( NULL ), |
|
30 iPin( NULL ), |
|
31 iTFName( NULL ), |
|
32 iTFNumber( NULL ) |
|
33 |
|
34 { |
|
35 |
|
36 |
|
37 } |
|
38 |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // CInternalAddressInfo::~CInternalAddressInfo() |
|
42 // Destructor |
|
43 // ---------------------------------------------------------------------------- |
|
44 CInternalAddressInfo::~CInternalAddressInfo() |
|
45 { |
|
46 LOG("CInternalAddressInfo::~CInternalAddressInfo ,begin"); |
|
47 if (iCountryName) |
|
48 { |
|
49 delete iCountryName; |
|
50 iCountryName = NULL ; |
|
51 } |
|
52 if (iState) |
|
53 { |
|
54 delete iState; |
|
55 iState= NULL ; |
|
56 } |
|
57 if (iCity) |
|
58 { |
|
59 delete iCity; |
|
60 iCity= NULL ; |
|
61 } |
|
62 if (iDistrict) |
|
63 { |
|
64 delete iDistrict; |
|
65 iDistrict = NULL ; |
|
66 } |
|
67 if (iPin) |
|
68 { |
|
69 delete iPin; |
|
70 iPin = NULL ; |
|
71 } |
|
72 if (iTFName) |
|
73 { |
|
74 delete iTFName; |
|
75 iTFName = NULL ; |
|
76 } |
|
77 if (iTFNumber) |
|
78 { |
|
79 delete iTFNumber; |
|
80 iTFNumber = NULL ; |
|
81 } |
|
82 |
|
83 LOG("CInternalAddressInfo::~CInternalAddressInfo ,end"); |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // CInternalAddressInfo::NewL() |
|
88 // Factory function to create the instance |
|
89 // ---------------------------------------------------------------------------- |
|
90 CInternalAddressInfo* CInternalAddressInfo::NewL() |
|
91 { |
|
92 LOG("CInternalAddressInfo::NewL ,begin"); |
|
93 CInternalAddressInfo *self = new (ELeave) CInternalAddressInfo(); |
|
94 CleanupStack::PushL(self); |
|
95 self->ConstructL(); |
|
96 |
|
97 CleanupStack::Pop( self ); |
|
98 return self; |
|
99 } |
|
100 |
|
101 |
|
102 // ---------------------------------------------------------------------------- |
|
103 // CInternalAddressInfo::ConstructL() |
|
104 // Second phase construction. |
|
105 // ---------------------------------------------------------------------------- |
|
106 void CInternalAddressInfo::ConstructL() |
|
107 { |
|
108 LOG("CInternalAddressInfo::ConstructL ,begin"); |
|
109 //Copy all with the empty strings; |
|
110 ResetAddressInfoL(); |
|
111 LOG("CInternalAddressInfo::ConstructL ,end"); |
|
112 } |
|
113 |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // CInternalAddressInfo::GetCountryName() |
|
117 // Gets Country name |
|
118 // ---------------------------------------------------------------------------- |
|
119 TDesC& CInternalAddressInfo::GetCountryName() |
|
120 { |
|
121 return *iCountryName; |
|
122 } |
|
123 |
|
124 |
|
125 // ---------------------------------------------------------------------------- |
|
126 // CInternalAddressInfo::GetState() |
|
127 // Gets State name |
|
128 // ---------------------------------------------------------------------------- |
|
129 TDesC& CInternalAddressInfo::GetState() |
|
130 { |
|
131 return *iState; |
|
132 } |
|
133 |
|
134 |
|
135 // ---------------------------------------------------------------------------- |
|
136 // CInternalAddressInfo::GetCity() |
|
137 // Gets City name. |
|
138 // ---------------------------------------------------------------------------- |
|
139 TDesC& CInternalAddressInfo::GetCity() |
|
140 { |
|
141 return *iCity; |
|
142 } |
|
143 |
|
144 |
|
145 // ---------------------------------------------------------------------------- |
|
146 // CInternalAddressInfo::GetDistrict() |
|
147 // Gets District name of the address. |
|
148 // ---------------------------------------------------------------------------- |
|
149 TDesC& CInternalAddressInfo::GetDistrict() |
|
150 { |
|
151 return *iDistrict; |
|
152 } |
|
153 |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CInternalAddressInfo::GetPincode() |
|
157 // Gets the postal code. |
|
158 // ---------------------------------------------------------------------------- |
|
159 TDesC& CInternalAddressInfo::GetPincode() |
|
160 { |
|
161 return *iPin; |
|
162 } |
|
163 |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CInternalAddressInfo::GetThoroughfareName() |
|
167 // Gets thoroughfare name |
|
168 // ---------------------------------------------------------------------------- |
|
169 TDesC& CInternalAddressInfo::GetThoroughfareName() |
|
170 { |
|
171 return *iTFName; |
|
172 } |
|
173 |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // CInternalAddressInfo::GetThoroughfareNumber() |
|
177 // Gets thoroughfare number |
|
178 // ---------------------------------------------------------------------------- |
|
179 TDesC& CInternalAddressInfo::GetThoroughfareNumber() |
|
180 { |
|
181 return *iTFNumber; |
|
182 } |
|
183 |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CInternalAddressInfo::SetCountryName() |
|
187 // Sets the country name information |
|
188 // ---------------------------------------------------------------------------- |
|
189 void CInternalAddressInfo::SetCountryName( const TDesC& aCountryName ) |
|
190 { |
|
191 if( iCountryName ) |
|
192 { |
|
193 delete iCountryName; |
|
194 } |
|
195 iCountryName = aCountryName.Alloc(); |
|
196 } |
|
197 |
|
198 |
|
199 // ---------------------------------------------------------------------------- |
|
200 // CInternalAddressInfo::SetState() |
|
201 // Sets the State name information |
|
202 // ---------------------------------------------------------------------------- |
|
203 void CInternalAddressInfo::SetState( const TDesC& aState ) |
|
204 { |
|
205 if( iState ) |
|
206 { |
|
207 delete iState; |
|
208 } |
|
209 iState = aState.Alloc(); |
|
210 } |
|
211 |
|
212 |
|
213 // ---------------------------------------------------------------------------- |
|
214 // CInternalAddressInfo::SetCity() |
|
215 // Sets the City name information |
|
216 // ---------------------------------------------------------------------------- |
|
217 void CInternalAddressInfo::SetCity( const TDesC& aCity ) |
|
218 { |
|
219 if( iCity ) |
|
220 { |
|
221 delete iCity; |
|
222 } |
|
223 iCity = aCity.Alloc(); |
|
224 } |
|
225 |
|
226 |
|
227 // ---------------------------------------------------------------------------- |
|
228 // CInternalAddressInfo::SetDistrict() |
|
229 // Sets the District name information |
|
230 // ---------------------------------------------------------------------------- |
|
231 void CInternalAddressInfo::SetDistrict( const TDesC& aDisrict ) |
|
232 { |
|
233 if( iDistrict ) |
|
234 { |
|
235 delete iDistrict; |
|
236 } |
|
237 iDistrict = aDisrict.Alloc(); |
|
238 } |
|
239 |
|
240 |
|
241 // ---------------------------------------------------------------------------- |
|
242 // CInternalAddressInfo::SetPincode() |
|
243 // Sets the Postal code information |
|
244 // ---------------------------------------------------------------------------- |
|
245 void CInternalAddressInfo::SetPincode( const TDesC& aPincode ) |
|
246 { |
|
247 if( iPin ) |
|
248 { |
|
249 delete iPin; |
|
250 } |
|
251 iPin = aPincode.Alloc(); |
|
252 } |
|
253 |
|
254 |
|
255 // ---------------------------------------------------------------------------- |
|
256 // CInternalAddressInfo::SetThoroughfareName() |
|
257 // Sets the thoroughfare name information |
|
258 // ---------------------------------------------------------------------------- |
|
259 void CInternalAddressInfo::SetThoroughfareName( const TDesC& aTFName ) |
|
260 { |
|
261 if( iTFName ) |
|
262 { |
|
263 delete iTFName; |
|
264 } |
|
265 iTFName = aTFName.Alloc(); |
|
266 } |
|
267 |
|
268 |
|
269 // ---------------------------------------------------------------------------- |
|
270 // CInternalAddressInfo::SetThoroughfareNumber() |
|
271 // Sets the thoroughfare number information |
|
272 // ---------------------------------------------------------------------------- |
|
273 void CInternalAddressInfo::SetThoroughfareNumber( const TDesC& aTFNumber ) |
|
274 { |
|
275 if( iTFNumber ) |
|
276 { |
|
277 delete iTFNumber; |
|
278 } |
|
279 iTFNumber = aTFNumber.Alloc(); |
|
280 } |
|
281 |
|
282 |
|
283 // ---------------------------------------------------------------------------- |
|
284 // CInternalAddressInfo::ResetAddressInfoL() |
|
285 // resets the address info |
|
286 // ---------------------------------------------------------------------------- |
|
287 void CInternalAddressInfo::ResetAddressInfoL() |
|
288 { |
|
289 // Allocate empty buffer to avoid crash on get method |
|
290 |
|
291 // Free memory |
|
292 if(iCountryName) |
|
293 { |
|
294 delete iCountryName; |
|
295 iCountryName = NULL; |
|
296 } |
|
297 if(iState) |
|
298 { |
|
299 delete iState; |
|
300 iState = NULL; |
|
301 } |
|
302 if(iCity) |
|
303 { |
|
304 delete iCity; |
|
305 iCity = NULL; |
|
306 } |
|
307 if(iDistrict) |
|
308 { |
|
309 delete iDistrict; |
|
310 iDistrict = NULL; |
|
311 } |
|
312 if(iPin) |
|
313 { |
|
314 delete iPin; |
|
315 iPin = NULL; |
|
316 } |
|
317 if(iTFName) |
|
318 { |
|
319 delete iTFName; |
|
320 iTFName = NULL; |
|
321 } |
|
322 if(iTFNumber) |
|
323 { |
|
324 delete iTFNumber; |
|
325 iTFNumber = NULL; |
|
326 } |
|
327 // Allocate empty strings, |
|
328 iCountryName = KNullDesC().AllocL(); |
|
329 iCity = KNullDesC().AllocL(); |
|
330 iState = KNullDesC().AllocL(); |
|
331 iDistrict = KNullDesC().AllocL(); |
|
332 iPin = KNullDesC().AllocL(); |
|
333 iTFName = KNullDesC().AllocL(); |
|
334 iTFNumber = KNullDesC().AllocL(); |
|
335 |
|
336 } |
|
337 |
|
338 |
|
339 //end of file |
|