|
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: Msearchelement implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpobjecthelpers.h> |
|
20 #include "searchelementimp.h" |
|
21 #include "ximpidentityimp.h" |
|
22 #include "ximprbufhelpers.h" |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS ============================= |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CSearchElementImp::NewLC() |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 EXPORT_C CSearchElementImp* CSearchElementImp::NewLC() |
|
32 { |
|
33 CSearchElementImp* self = new( ELeave ) CSearchElementImp; |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CSearchElementImp::NewL() |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CSearchElementImp* CSearchElementImp::NewL() |
|
45 { |
|
46 CSearchElementImp* self = NewLC(); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CSearchElementImp::NewFromStreamLC() |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 XIMPIMP_IMPLEMENT_DATAOBJ_NEWFROMSTREAM( CSearchElementImp ) |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Implement supported interface access. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CSearchElementImp, MSearchElement ) |
|
62 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
63 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CSearchElementImp, MSearchElement ) |
|
64 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CSearchElementImp::~CSearchElementImp() |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CSearchElementImp::~CSearchElementImp() |
|
71 { |
|
72 delete iIdentity; |
|
73 iIdentity=NULL; |
|
74 delete iLabelIdentity; |
|
75 iLabelIdentity=NULL; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CSearchElementImp::CSearchElementImp() |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CSearchElementImp::CSearchElementImp() |
|
83 { |
|
84 } |
|
85 |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CSearchElementImp::ConstructL() |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CSearchElementImp::ConstructL() |
|
92 { |
|
93 iIdentity = CXIMPIdentityImp::NewLC(); |
|
94 CleanupStack::Pop( iIdentity ); |
|
95 iLabelIdentity = CXIMPIdentityImp::NewLC(); |
|
96 CleanupStack::Pop( iLabelIdentity ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CSearchElementImp::ExternalizeL() |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CSearchElementImp::ExternalizeL( RWriteStream& aStream ) const |
|
104 { |
|
105 iIdentity->ExternalizeL(aStream); |
|
106 iLabelIdentity->ExternalizeL(aStream); |
|
107 aStream.WriteInt32L(iSearchKey); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CSearchElementImp::InternalizeL() |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 EXPORT_C void CSearchElementImp::InternalizeL( RReadStream& aStream ) |
|
115 { |
|
116 iIdentity->InternalizeL(aStream); |
|
117 iLabelIdentity->InternalizeL(aStream); |
|
118 iSearchKey=aStream.ReadInt32L(); |
|
119 } |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CSearchElementImp::EqualsContent() |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 TBool CSearchElementImp::EqualsContent( |
|
129 const CXIMPApiDataObjBase& /*aOtherInstance*/ ) const |
|
130 { |
|
131 return ETrue; |
|
132 } |
|
133 // --------------------------------------------------------------------------- |
|
134 // CSearchElementImp::SetRequestL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CSearchElementImp::SetRequestL( MXIMPIdentity& aSearchStringId, |
|
138 TSearchKey aKey ) |
|
139 |
|
140 { |
|
141 if ( EReadLabel == aKey ) // if client trys to set EReadLabel then leave |
|
142 { |
|
143 User::Leave( KErrArgument ); |
|
144 } |
|
145 const CXIMPIdentityImp* identityImp = |
|
146 TXIMPGetImpClassOrPanic< CXIMPIdentityImp>::From( aSearchStringId ); |
|
147 |
|
148 delete iIdentity; |
|
149 iIdentity=NULL; |
|
150 iIdentity =TXIMPObjectCloner< CXIMPIdentityImp>::CloneL(*identityImp ); |
|
151 |
|
152 iSearchKey=aKey; |
|
153 |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CSearchElementImp::SetRequestL |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CSearchElementImp::SetRequestL( MXIMPIdentity& aSearchStringId, |
|
161 MXIMPIdentity& aLabelId ) |
|
162 |
|
163 { |
|
164 const CXIMPIdentityImp* identityImp = |
|
165 TXIMPGetImpClassOrPanic< CXIMPIdentityImp>::From( aSearchStringId ); |
|
166 |
|
167 delete iIdentity; |
|
168 iIdentity=NULL; |
|
169 iIdentity =TXIMPObjectCloner< CXIMPIdentityImp>::CloneL(*identityImp ); |
|
170 |
|
171 const CXIMPIdentityImp* labelIdentity = TXIMPGetImpClassOrPanic< CXIMPIdentityImp>::From( aLabelId ); |
|
172 delete iLabelIdentity; |
|
173 iLabelIdentity=NULL; |
|
174 iLabelIdentity =TXIMPObjectCloner< CXIMPIdentityImp>::CloneL(*labelIdentity ); |
|
175 iSearchKey = EReadLabel ; // make sure that if label is there then key is EReadLabel |
|
176 |
|
177 } |
|
178 // --------------------------------------------------------------------------- |
|
179 // CSearchElementImp::GetSearchId |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 MXIMPIdentity& CSearchElementImp::GetSearchId() const |
|
183 { |
|
184 return *iIdentity; |
|
185 } |
|
186 // --------------------------------------------------------------------------- |
|
187 // CSearchElementImp::GetSearchLabel |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 MXIMPIdentity& CSearchElementImp::GetSearchLabel() const |
|
191 { |
|
192 return *iLabelIdentity; |
|
193 } |
|
194 // --------------------------------------------------------------------------- |
|
195 // CSearchElementImp ::GetSearchKey |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 TSearchKey CSearchElementImp::GetSearchKey() const |
|
199 { |
|
200 return (TSearchKey)iSearchKey; |
|
201 } |
|
202 |
|
203 // End of file |