|
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: MPresenceInfoFieldValueText API object implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "presenceinfofieldvaluetextimp.h" |
|
20 #include "presenceinfofieldvaluetext.h" |
|
21 #include "ximprbufhelpers.h" |
|
22 #include "ximpobjecthelpers.h" |
|
23 #include "presenceinfo.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS ============================= |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CPresenceInfoFieldValueTextImp::NewLC() |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 EXPORT_C CPresenceInfoFieldValueTextImp* CPresenceInfoFieldValueTextImp::NewLC( |
|
32 TInt aMaxLength /* = NPresenceInfo::KValueLengthUnlimited */ |
|
33 ) |
|
34 { |
|
35 CPresenceInfoFieldValueTextImp* self = new ( ELeave ) CPresenceInfoFieldValueTextImp( aMaxLength ); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CPresenceInfoFieldValueTextImp::NewFromStreamLC() |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 XIMPIMP_IMPLEMENT_DATAOBJ_NEWFROMSTREAM( CPresenceInfoFieldValueTextImp ) |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // Implement supported interface access. |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CPresenceInfoFieldValueTextImp, MPresenceInfoFieldValueText ) |
|
52 XIMPIMP_IF_BASE_GET_CLASS( CXIMPApiDataObjBase, this ) |
|
53 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
54 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CPresenceInfoFieldValueTextImp, MPresenceInfoFieldValueText ) |
|
55 XIMPIMP_IF_BASE_GET_CONST_CLASS( CXIMPApiDataObjBase, this ) |
|
56 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CPresenceInfoFieldValueTextImp::~CPresenceInfoFieldValueTextImp() |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CPresenceInfoFieldValueTextImp::~CPresenceInfoFieldValueTextImp() |
|
63 { |
|
64 iFieldValue.Close(); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CPresenceInfoFieldValueTextImp::CPresenceInfoFieldValueTextImp() |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CPresenceInfoFieldValueTextImp::CPresenceInfoFieldValueTextImp( |
|
72 TInt aMaxLength ) |
|
73 { |
|
74 iMaxLength = aMaxLength; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CPresenceInfoFieldValueTextImp::CPresenceInfoFieldValueTextImp() |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CPresenceInfoFieldValueTextImp::CPresenceInfoFieldValueTextImp() |
|
82 { |
|
83 // nothing |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CPresenceInfoFieldValueTextImp::ConstructL() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CPresenceInfoFieldValueTextImp::ConstructL() |
|
91 { |
|
92 // always allocate a 0-length here, then in the setter enforce |
|
93 // the maximal length |
|
94 iFieldValue.CreateL( 0 ); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CPresenceInfoFieldValueTextImp::ExternalizeL() |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void CPresenceInfoFieldValueTextImp::ExternalizeL( RWriteStream& aStream ) const |
|
102 { |
|
103 XIMPRBuf16Helper::ExternalizeL( iFieldValue, aStream ); |
|
104 aStream.WriteInt32L( iMaxLength ); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CPresenceInfoFieldValueTextImp::InternalizeL() |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C void CPresenceInfoFieldValueTextImp::InternalizeL( RReadStream& aStream ) |
|
112 { |
|
113 XIMPRBuf16Helper::InternalizeL( iFieldValue, aStream ); |
|
114 iMaxLength = aStream.ReadInt32L(); |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CPresenceInfoFieldValueTextImp::EqualsContent() |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 TBool CPresenceInfoFieldValueTextImp::EqualsContent( |
|
122 const CXIMPApiDataObjBase& aOtherInstance ) const |
|
123 { |
|
124 const CPresenceInfoFieldValueTextImp* tmp = |
|
125 TXIMPGetImpClassOrPanic< const CPresenceInfoFieldValueTextImp >::From( |
|
126 aOtherInstance.Base() ); |
|
127 |
|
128 TBool same = ETrue; |
|
129 TBool x; |
|
130 x = 0 == iFieldValue.Compare( tmp->iFieldValue ); |
|
131 same &= x; |
|
132 |
|
133 x = iMaxLength == tmp->iMaxLength; |
|
134 same &= x; |
|
135 |
|
136 return same; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CPresenceInfoFieldValueTextImp::MaxLength() |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 TInt CPresenceInfoFieldValueTextImp::MaxLength() const |
|
144 { |
|
145 return iMaxLength; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CPresenceInfoFieldValueTextImp::TextValue() |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 TPtrC CPresenceInfoFieldValueTextImp::TextValue() const |
|
153 { |
|
154 return iFieldValue; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CPresenceInfoFieldValueTextImp::SetTextValueL() |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CPresenceInfoFieldValueTextImp::SetTextValueL( const TDesC& aValue ) |
|
162 { |
|
163 // maximal length might be enforced |
|
164 User::LeaveIfError( ( iMaxLength != NPresenceInfo::KValueLengthUnlimited ) |
|
165 && ( iMaxLength < aValue.Length() ) ? KErrOverflow : KErrNone ); |
|
166 |
|
167 HBufC16* tmp = aValue.AllocL(); |
|
168 iFieldValue.Close(); |
|
169 iFieldValue.Assign( tmp ); |
|
170 } |
|
171 |
|
172 // End of file |