|
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: Implementation of MDevicePresenceInfo object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "presenceinfofield.h" |
|
20 #include "devicepresenceinfoimp.h" |
|
21 #include "presenceinfofieldcollectionimp.h" |
|
22 #include "ximprbufhelpers.h" |
|
23 #include "presenceinfofilterimp.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS ============================= |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CDevicePresenceInfoImp::NewLC() |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 EXPORT_C CDevicePresenceInfoImp* CDevicePresenceInfoImp::NewLC() |
|
32 { |
|
33 CDevicePresenceInfoImp* self = new( ELeave ) CDevicePresenceInfoImp; |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CDevicePresenceInfoImp::NewFromStreamLC() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 XIMPIMP_IMPLEMENT_DATAOBJ_NEWFROMSTREAM( CDevicePresenceInfoImp ) |
|
44 |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Implement supported interface access. |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CDevicePresenceInfoImp, |
|
51 MDevicePresenceInfo ) |
|
52 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
53 |
|
54 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CDevicePresenceInfoImp, |
|
55 MDevicePresenceInfo ) |
|
56 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CDevicePresenceInfoImp::~CDevicePresenceInfoImp() |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CDevicePresenceInfoImp::~CDevicePresenceInfoImp() |
|
63 { |
|
64 delete iFields; |
|
65 iDeviceName.Close(); |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CDevicePresenceInfoImp::CDevicePresenceInfoImp() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CDevicePresenceInfoImp::CDevicePresenceInfoImp() |
|
74 { |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CDevicePresenceInfoImp::ConstructL() |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CDevicePresenceInfoImp::ConstructL() |
|
83 { |
|
84 iFields = CPresenceInfoFieldCollectionImp::NewLC(); |
|
85 CleanupStack::Pop( iFields ); |
|
86 |
|
87 iDeviceName.CreateL( 0 ); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CDevicePresenceInfoImp::ExternalizeL() |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CDevicePresenceInfoImp::ExternalizeL( RWriteStream& aStream ) const |
|
95 { |
|
96 XIMPRBuf8Helper::ExternalizeL( iDeviceName, aStream ); |
|
97 iFields->ExternalizeL( aStream ); |
|
98 } |
|
99 |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CDevicePresenceInfoImp::InternalizeL() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C void CDevicePresenceInfoImp::InternalizeL( RReadStream& aStream ) |
|
106 { |
|
107 XIMPRBuf8Helper::InternalizeL( iDeviceName, aStream ); |
|
108 |
|
109 // we only have a parameterless ConstructL which creates the fields structure... |
|
110 CXIMPApiDataObjBase* tmp = CPresenceInfoFieldCollectionImp::NewFromStreamLC( aStream ); |
|
111 CPresenceInfoFieldCollectionImp* fields = |
|
112 TXIMPGetImpClassOrPanic< CPresenceInfoFieldCollectionImp >::From( tmp->Base() ); |
|
113 delete iFields; |
|
114 iFields = fields; |
|
115 CleanupStack::Pop( tmp ); |
|
116 } |
|
117 |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CDevicePresenceInfoImp::EqualsContent() |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CDevicePresenceInfoImp::EqualsContent( |
|
124 const CXIMPApiDataObjBase& aOtherInstance ) const |
|
125 { |
|
126 const CDevicePresenceInfoImp* tmp = |
|
127 TXIMPGetImpClassOrPanic< const CDevicePresenceInfoImp >::From( |
|
128 aOtherInstance.Base() ); |
|
129 |
|
130 TBool same = ETrue; |
|
131 TBool x; |
|
132 x = iFields->EqualsContent( *( tmp->iFields ) ); |
|
133 same &= x; |
|
134 |
|
135 return same; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // From MDevicePresenceInfo class. |
|
140 // CDevicePresenceInfoImp::DeviceName() |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 const TPtrC8 CDevicePresenceInfoImp::DeviceName() const |
|
144 { |
|
145 return iDeviceName; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // From MDevicePresenceInfo class. |
|
150 // CDevicePresenceInfoImp::SetDeviceNameL() |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CDevicePresenceInfoImp::SetDeviceNameL( const TDesC8& aDeviceName ) |
|
154 { |
|
155 HBufC8* tmp = aDeviceName.AllocL(); |
|
156 iDeviceName.Close(); |
|
157 iDeviceName.Assign( tmp ); |
|
158 } |
|
159 |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // From MDevicePresenceInfo class. |
|
163 // CDevicePresenceInfoImp::Fields() |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 const MPresenceInfoFieldCollection& CDevicePresenceInfoImp::Fields() const |
|
167 { |
|
168 return *iFields; |
|
169 } |
|
170 |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // From MDevicePresenceInfo class. |
|
174 // CDevicePresenceInfoImp::Fields() |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 MPresenceInfoFieldCollection& CDevicePresenceInfoImp::Fields() |
|
178 { |
|
179 return *iFields; |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CDevicePresenceInfoImp::FilterWithL() |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CDevicePresenceInfoImp::FilterWithL( const CPresenceInfoFilterImp& aFilter ) |
|
187 { |
|
188 TInt count = iFields->FieldCount(); |
|
189 |
|
190 // must traverse backwards when removing |
|
191 for ( TInt i = count-1; i >= 0; i-- ) |
|
192 { |
|
193 if ( ! aFilter.MatchDeviceFilterL( |
|
194 iDeviceName, |
|
195 iFields->FieldAt( i ).FieldType() ) ) |
|
196 { |
|
197 // no match, so remove the field |
|
198 // the filter tells us which ones to ACCEPT |
|
199 iFields->RemoveField( i ); |
|
200 } |
|
201 } |
|
202 } |
|
203 |
|
204 // End of file |