|
1 /* |
|
2 * Copyright (c) 2007 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: MSearchEvent API object implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "searchkeyseventimp.h" |
|
19 #include "ximpapiobjbase.h" |
|
20 #include "ximpapieventbase.h" |
|
21 |
|
22 #include <ximpbase.h> |
|
23 #include "ximpobjecthelpers.h" |
|
24 #include "searchkeyinfoimp.h" |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CSearchKeysEventImp::NewLC() |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C CSearchKeysEventImp* CSearchKeysEventImp::NewLC( RSearchKeyInfoImpArray* aKeyInfoArray ) |
|
31 { |
|
32 CSearchKeysEventImp* self = new( ELeave ) CSearchKeysEventImp(); |
|
33 CleanupStack::PushL( self ); |
|
34 self->ConstructL( aKeyInfoArray ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CSearchKeysEventImp::NewFromStreamLC() |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CXIMPApiEventBase* CSearchKeysEventImp::NewFromStreamLC( RReadStream& aStream ) |
|
43 { |
|
44 CSearchKeysEventImp* self = new( ELeave ) CSearchKeysEventImp; |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL( aStream ); |
|
47 return self; |
|
48 } |
|
49 // --------------------------------------------------------------------------- |
|
50 // CSearchKeysEventImp::EqualsContent |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 TBool CSearchKeysEventImp::EqualsContent( |
|
54 const CXIMPApiEventBase& /*aOtherInstance*/ ) const |
|
55 { |
|
56 return ETrue; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // From class CXIMPApiEventBase |
|
61 // CSearchKeysEventImp::ExternalizeL |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CSearchKeysEventImp::ExternalizeL( RWriteStream& aStream ) const |
|
65 { |
|
66 WriteArrayToStreamL( *iInfoArray, aStream ); |
|
67 } |
|
68 |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CSearchKeysEventImp::~CSearchKeysEventImp() |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CSearchKeysEventImp::~CSearchKeysEventImp() |
|
75 { |
|
76 delete iInfoArray; |
|
77 iInfoArray = NULL; |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CSearchKeysEventImp::CSearchKeysEventImp() |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CSearchKeysEventImp::CSearchKeysEventImp() |
|
86 { |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CSearchKeysEventImp::ConstructL() |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CSearchKeysEventImp::ConstructL( RSearchKeyInfoImpArray* aKeyInfoArray ) |
|
95 { |
|
96 iInfoArray = aKeyInfoArray ; // ownership is transfered here, need to delete |
|
97 } |
|
98 |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CSearchKeysEventImp::ConstructL() |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void CSearchKeysEventImp::ConstructL( RReadStream& aStream ) |
|
105 { |
|
106 iInfoArray = new ( ELeave) RSearchKeyInfoImpArray; |
|
107 InternalizeL( aStream ); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Implement supported interface access. |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CSearchKeysEventImp, |
|
115 MSearchKeysEvent ) |
|
116 |
|
117 XIMPIMP_IF_BASE_GET_CLASS( CXIMPApiEventBase, this ) |
|
118 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
119 |
|
120 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CSearchKeysEventImp, |
|
121 MSearchKeysEvent ) |
|
122 XIMPIMP_IF_BASE_GET_CONST_CLASS( CXIMPApiEventBase, this ) |
|
123 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
124 |
|
125 |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // Implement methods from base event interface and base event class |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 XIMPIMP_IMPLEMENT_EVENT_BASE_METHODS( CSearchKeysEventImp, |
|
132 MSearchKeysEvent ) |
|
133 |
|
134 |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // CSearchKeysEventImp::SupportedKeysCount() |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 TInt CSearchKeysEventImp::InfoCount() const |
|
141 { |
|
142 return iInfoArray->Count(); |
|
143 } |
|
144 // --------------------------------------------------------------------------- |
|
145 // CSearchKeysEventImp::SupportedKey() |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 const MSearchKeyInfo& CSearchKeysEventImp::SearchKeyInfo( TInt aIndex ) const |
|
149 { |
|
150 return *(*iInfoArray)[ aIndex ]; |
|
151 |
|
152 } |
|
153 |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // CSearchEventImp::FillArrayFromStreamL |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CSearchKeysEventImp::FillArrayFromStreamL( RSearchKeyInfoImpArray& aKeyInfoArray, |
|
160 RReadStream& aStream ) |
|
161 { |
|
162 TInt count = aStream.ReadInt32L(); |
|
163 for( TInt a = 0; a < count; ++a ) |
|
164 { |
|
165 // the stream MUST be in order (since it was externalized by this class) |
|
166 CSearchKeyInfoImp* newInfo = CSearchKeyInfoImp::NewLC(); |
|
167 newInfo->InternalizeL( aStream ); |
|
168 aKeyInfoArray.AppendL( newInfo ); // trap here if there is any error in the append |
|
169 CleanupStack::Pop(); // newInfo |
|
170 } |
|
171 } |
|
172 // --------------------------------------------------------------------------- |
|
173 // CSearchEventImp::WriteArrayToStreamL() |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CSearchKeysEventImp::WriteArrayToStreamL( RSearchKeyInfoImpArray& aKeyInfoArray, |
|
177 RWriteStream& aStream ) const |
|
178 { |
|
179 TInt count = aKeyInfoArray.Count(); |
|
180 aStream.WriteInt32L( count ); |
|
181 |
|
182 for( TInt a = 0; a < count; ++a ) |
|
183 { |
|
184 aKeyInfoArray[ a ]->ExternalizeL( aStream ); |
|
185 } |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CSearchKeysEventImp::InternalizeL( ) |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 |
|
194 void CSearchKeysEventImp::InternalizeL( RReadStream& aStream ) |
|
195 { |
|
196 FillArrayFromStreamL( *iInfoArray, aStream ); |
|
197 } |