|
1 /* |
|
2 * Copyright (c) 2002-2004 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 CMessageAddress interface. |
|
15 * Encapsulates message real address and alias. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "MessageAddressImpl.h" |
|
24 #include <msvstore.h> |
|
25 #include <sendui.h> |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CMessageDataImpl::CMessageAddressImpl |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CMessageAddressImpl::CMessageAddressImpl() |
|
37 { |
|
38 } |
|
39 |
|
40 // Destructor |
|
41 CMessageAddressImpl::~CMessageAddressImpl() |
|
42 { |
|
43 delete iRealAddress; |
|
44 delete iAlias; |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMessageAddressImpl::SetAddressL |
|
50 // Sets real address. |
|
51 // (other items were commented in a header). |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CMessageAddressImpl::SetAddressL( const TDesC& aAddress ) |
|
55 { |
|
56 delete iRealAddress; |
|
57 iRealAddress = NULL; |
|
58 iRealAddress = aAddress.AllocL(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CMessageAddressImpl::SetAliasL |
|
63 // Sets alias for real address. |
|
64 // (other items were commented in a header). |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CMessageAddressImpl::SetAliasL( const TDesC& aAlias ) |
|
68 { |
|
69 delete iAlias; |
|
70 iAlias = NULL; |
|
71 iAlias = aAlias.AllocL(); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CMessageAddressImpl::ExternalizeL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CMessageAddressImpl::ExternalizeL( RWriteStream& aStream ) const |
|
79 { |
|
80 TInt length(0); |
|
81 |
|
82 if (iAlias) |
|
83 { |
|
84 length = iAlias->Length(); |
|
85 } |
|
86 |
|
87 aStream.WriteUint32L( length ); |
|
88 |
|
89 if ( length ) |
|
90 { |
|
91 aStream << iAlias->Des(); |
|
92 } |
|
93 |
|
94 if (iRealAddress) |
|
95 { |
|
96 length = iRealAddress->Length(); |
|
97 } |
|
98 else |
|
99 { |
|
100 length = 0; |
|
101 } |
|
102 |
|
103 aStream.WriteUint32L( length ); |
|
104 |
|
105 if ( length ) |
|
106 { |
|
107 aStream << iRealAddress->Des(); |
|
108 } |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CMessageAddressImpl::InternalizeL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CMessageAddressImpl::InternalizeL( RReadStream& aStream ) |
|
116 { |
|
117 if ( aStream.ReadUint32L( ) ) |
|
118 { |
|
119 iAlias = NULL; |
|
120 iAlias = HBufC::NewL(aStream, KMaxLength); |
|
121 } |
|
122 |
|
123 if ( aStream.ReadUint32L( ) ) |
|
124 { |
|
125 iRealAddress = NULL; |
|
126 iRealAddress = HBufC::NewL( aStream, KMaxLength ); |
|
127 } |
|
128 } |
|
129 |
|
130 // End of File |