|
1 /* |
|
2 * Copyright (c) 2002 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: Presence-list handling interface for clients |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "TCAWrappers.h" |
|
23 #include "e32base.h" |
|
24 #include "MPEngContactList2.h" |
|
25 #include "MPEngContactItem.h" |
|
26 #include "CPEngContactListStore2.h" |
|
27 #include "CPEngTrackedPresenceIDs2.h" |
|
28 #include "CPEngTrackedPresenceID2.h" |
|
29 |
|
30 EXPORT_C TMultiPecListWrapper::TMultiPecListWrapper() |
|
31 : iCount( KErrNotFound ) |
|
32 { |
|
33 } |
|
34 |
|
35 EXPORT_C void TMultiPecListWrapper::InitializeLC( MDesCArray& aLists, |
|
36 CPEngContactListStore2& aListStore ) |
|
37 { |
|
38 // build the pointer array |
|
39 CleanupClosePushL( *this ); |
|
40 TInt count( aLists.MdcaCount() ); |
|
41 iCount = 0; |
|
42 TInt listCount( 0 ); |
|
43 for ( TInt x( 0 ) ; x < count ; ++x ) |
|
44 { |
|
45 MPEngContactList2& list = aListStore.ContactListL( aLists.MdcaPoint( x ) ); |
|
46 listCount = list.Count(); |
|
47 iLists.AppendL( &list ); |
|
48 iListCounts.AppendL( listCount ); |
|
49 iCount += listCount; |
|
50 } |
|
51 } |
|
52 |
|
53 EXPORT_C void TMultiPecListWrapper::Close() |
|
54 { |
|
55 iLists.Reset(); |
|
56 iListCounts.Reset(); |
|
57 } |
|
58 |
|
59 EXPORT_C TInt TMultiPecListWrapper::MdcaCount() const |
|
60 { |
|
61 return iCount; |
|
62 } |
|
63 |
|
64 EXPORT_C TPtrC16 TMultiPecListWrapper::MdcaPoint( TInt aIndex ) const |
|
65 { |
|
66 // ASSERT for count can be added here |
|
67 TInt loop( 0 ); |
|
68 while ( aIndex >= iListCounts[ loop ] ) |
|
69 { |
|
70 aIndex -= iListCounts[ loop ]; |
|
71 loop++; |
|
72 } |
|
73 return iLists[ loop ]->ContactItem( aIndex ).Id(); |
|
74 } |
|
75 |
|
76 // ============ One Contact List wrapper =========================================== |
|
77 |
|
78 EXPORT_C TOneContactListWrapper::TOneContactListWrapper( |
|
79 const MPEngContactList2& aCntList ) |
|
80 : iList( aCntList ) |
|
81 { |
|
82 } |
|
83 |
|
84 EXPORT_C TInt TOneContactListWrapper::MdcaCount() const |
|
85 { |
|
86 return iList.Count(); |
|
87 } |
|
88 |
|
89 EXPORT_C TPtrC16 TOneContactListWrapper::MdcaPoint( |
|
90 TInt aIndex ) const |
|
91 { |
|
92 return iList.ContactItem( aIndex ).Id(); |
|
93 } |
|
94 |
|
95 |
|
96 // ======================= Contact Lists names Wrapper ============================== |
|
97 |
|
98 EXPORT_C TContactListsWrapper::TContactListsWrapper() |
|
99 : iWatcherIndex( KErrNotFound ) |
|
100 { |
|
101 } |
|
102 |
|
103 EXPORT_C TContactListsWrapper::TContactListsWrapper( |
|
104 const MDesCArray& aCntLists ) |
|
105 : iCntLists( &aCntLists ), |
|
106 iWatcherIndex( KErrNotFound ) |
|
107 { |
|
108 TInt index( 0 ); |
|
109 TInt count( aCntLists.MdcaCount() ); |
|
110 while ( |
|
111 ( index < count ) |
|
112 && |
|
113 ( KErrNone != aCntLists.MdcaPoint( index ).CompareF( KPEngWatcherList ) ) |
|
114 ) |
|
115 { |
|
116 index++; |
|
117 } |
|
118 |
|
119 if ( index < count ) |
|
120 { |
|
121 iWatcherIndex = index; |
|
122 } |
|
123 } |
|
124 |
|
125 EXPORT_C TInt TContactListsWrapper::MdcaCount() const |
|
126 { |
|
127 // there is always watcher list |
|
128 return ( iWatcherIndex != KErrNotFound ) ? iCntLists->MdcaCount() - 1 : iCntLists->MdcaCount() ; |
|
129 } |
|
130 |
|
131 EXPORT_C TPtrC16 TContactListsWrapper::MdcaPoint( |
|
132 TInt aIndex ) const |
|
133 { |
|
134 return ( ( aIndex < iWatcherIndex ) ? |
|
135 iCntLists->MdcaPoint( aIndex ) |
|
136 : iCntLists->MdcaPoint( aIndex + 1 ) ); |
|
137 } |
|
138 |
|
139 EXPORT_C TOneDesWrapper::TOneDesWrapper( const TDesC& aDes ) |
|
140 : iDes( aDes ) |
|
141 { |
|
142 } |
|
143 |
|
144 EXPORT_C TInt TOneDesWrapper::MdcaCount() const |
|
145 { |
|
146 return 1; |
|
147 } |
|
148 |
|
149 EXPORT_C TPtrC16 TOneDesWrapper::MdcaPoint( |
|
150 TInt /*aIndex*/ ) const |
|
151 { |
|
152 // panic if going out of zero index |
|
153 return iDes; |
|
154 } |
|
155 |
|
156 |
|
157 EXPORT_C TTrackedPresenceIds::TTrackedPresenceIds() |
|
158 { |
|
159 } |
|
160 |
|
161 EXPORT_C void TTrackedPresenceIds::InitializeLC( |
|
162 CPEngTrackedPresenceIDs2& aTrackedIds ) |
|
163 { |
|
164 CleanupClosePushL( *this ); |
|
165 |
|
166 TInt count( aTrackedIds.TrackedPresenceIDsCount() ); |
|
167 aTrackedIds.ResetTrackedIterator(); |
|
168 for ( TInt x ( 0 ) ; x < count ; ++x ) |
|
169 { |
|
170 iTrackedIds.AppendL( aTrackedIds.NextTrackedPresenceID() ); |
|
171 } |
|
172 } |
|
173 |
|
174 EXPORT_C void TTrackedPresenceIds::Close() |
|
175 { |
|
176 iTrackedIds.Reset(); |
|
177 } |
|
178 |
|
179 EXPORT_C TInt TTrackedPresenceIds::MdcaCount() const |
|
180 { |
|
181 return iTrackedIds.Count(); |
|
182 } |
|
183 |
|
184 EXPORT_C TPtrC16 TTrackedPresenceIds::MdcaPoint( |
|
185 TInt aIndex ) const |
|
186 { |
|
187 return iTrackedIds[ aIndex ]->PresenceID(); |
|
188 } |
|
189 |
|
190 // End of File |
|
191 |