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