|
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: Implementation of MSearch |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <ximpobjecthelpers.h> |
|
21 #include <ximpidentityimp.h> |
|
22 #include <ximpcontextinternal.h> |
|
23 |
|
24 #include "searchoperationdefs.h" |
|
25 #include "searchimp.h" |
|
26 #include "searchelementimp.h" |
|
27 |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS ============================= |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CSearchImp::NewL() |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 |
|
37 CSearchImp* CSearchImp::NewL( MXIMPContextInternal& aContext ) |
|
38 { |
|
39 XSearchLogger::Log(_L("CSearchImp::NewL Started")); |
|
40 CSearchImp* self = new( ELeave ) CSearchImp( aContext ); |
|
41 XSearchLogger::Log(_L("CSearchImp::NewL Completed")); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Implement supported interface access. |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CSearchImp, |
|
51 MSearch ) |
|
52 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
53 |
|
54 |
|
55 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CSearchImp, |
|
56 MSearch ) |
|
57 XIMPIMP_IF_BASE_GET_INTERFACE_END() |
|
58 |
|
59 |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CSearchImp::~CSearchImp() |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CSearchImp::~CSearchImp() |
|
66 { |
|
67 XSearchLogger::Log(_L("CSearchImp::~CSearchImp Started - Completed")); |
|
68 } |
|
69 // --------------------------------------------------------------------------- |
|
70 // CSearchImp::CSearchImp() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CSearchImp::CSearchImp(MXIMPContextInternal& aContext ) |
|
74 : iContext( aContext ) |
|
75 { |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CSearchImp::SearchL |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 TXIMPRequestId CSearchImp::SearchL( const MXIMPIdentity& aSearchId, |
|
84 const RPointerArray< MSearchElement >& aObjs, |
|
85 TInt aSearchLimit ) |
|
86 { |
|
87 |
|
88 CBufFlat* buffer = CBufFlat::NewL( 10 ); |
|
89 CleanupStack::PushL( buffer ); |
|
90 |
|
91 RBufWriteStream ws; |
|
92 CleanupClosePushL( ws ); |
|
93 ws.Open( *buffer ); // CSI: 65 # Does not return a value |
|
94 |
|
95 |
|
96 // identity |
|
97 const CXIMPIdentityImp* identityImp = |
|
98 TXIMPGetImpClassOrPanic< const CXIMPIdentityImp >::From( aSearchId ); |
|
99 identityImp->ExternalizeL( ws ); |
|
100 |
|
101 |
|
102 |
|
103 // Get count of objects |
|
104 TInt objCount( aObjs.Count() ); |
|
105 // write the count |
|
106 ws.WriteInt32L( objCount ); |
|
107 // objects |
|
108 for ( TInt count(0); count < objCount; count++ ) |
|
109 { |
|
110 const CSearchElementImp* eleImp = |
|
111 TXIMPGetImpClassOrPanic< const CSearchElementImp >::From( *aObjs[count] ); |
|
112 eleImp->ExternalizeL( ws ); |
|
113 } |
|
114 |
|
115 // write the Search Limit |
|
116 ws.WriteInt32L( aSearchLimit ); |
|
117 |
|
118 ws.CommitL(); |
|
119 CleanupStack::PopAndDestroy(); //ws |
|
120 |
|
121 HBufC8* packedBuf = buffer->Ptr( 0 ).AllocL(); |
|
122 CleanupStack::PopAndDestroy( buffer ); |
|
123 CleanupStack::PushL( packedBuf ); |
|
124 |
|
125 |
|
126 // Queue the operation |
|
127 TXIMPRequestId reqId = |
|
128 iContext.QueueOperationL( NSearchOps::ESearch, *packedBuf ); |
|
129 CleanupStack::PopAndDestroy( packedBuf ); |
|
130 |
|
131 |
|
132 return reqId ; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CSearchImp::GetSearchKeysL |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 TXIMPRequestId CSearchImp::GetSearchKeysL() |
|
140 { |
|
141 return iContext.QueueOperationL( NSearchOps::EGetSearchKeys , KNullDesC8); |
|
142 } |
|
143 |
|
144 // end of file |
|
145 |
|
146 |