|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __HLPSRCH_H__ |
|
17 #define __HLPSRCH_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <d32dbms.h> |
|
21 #include <s32file.h> |
|
22 #include "HLPDB.H" |
|
23 #include "HLPMODEL.H" |
|
24 |
|
25 class CHlpDatabase; |
|
26 class MHlpDbObserver; |
|
27 |
|
28 |
|
29 |
|
30 // |
|
31 // ----> MHlpPrivObserver |
|
32 // |
|
33 class MHlpPrivObserver |
|
34 { |
|
35 public: |
|
36 virtual void HandleSearchEventL(TInt aEvent)=0; |
|
37 }; |
|
38 |
|
39 |
|
40 |
|
41 // |
|
42 // ----> CHlpSQLBuffer |
|
43 // |
|
44 class CHlpSQLBuffer : public CBase |
|
45 { |
|
46 public: |
|
47 void ConstructL(TInt aBufferSize); |
|
48 CHlpSQLBuffer(); |
|
49 ~CHlpSQLBuffer(); |
|
50 void AppendL(const TDesC& aDes); |
|
51 void AppendL(TInt aNum); |
|
52 void AppendSQLL(const TDesC& aDes); |
|
53 const TDesC& SearchStatement() const; |
|
54 void Reset(); |
|
55 |
|
56 private: |
|
57 void AppendTextL(const TDesC& aDes); |
|
58 |
|
59 private: |
|
60 HBufC* iSQLStatement; |
|
61 }; |
|
62 |
|
63 |
|
64 // |
|
65 // ----> CHlpSQLEvaluator |
|
66 // |
|
67 class CHlpSQLEvaluator : public CActive |
|
68 { |
|
69 public: |
|
70 static CHlpSQLEvaluator* NewL(TInt aPriority); |
|
71 static CHlpSQLEvaluator* NewLC(TInt aPriority); |
|
72 ~CHlpSQLEvaluator(); |
|
73 |
|
74 void Initialize(RDbView& aView, MHlpPrivObserver& aObserver); |
|
75 |
|
76 protected: |
|
77 virtual void RunL(); |
|
78 virtual void DoCancel(); |
|
79 |
|
80 private: |
|
81 void Start(); |
|
82 CHlpSQLEvaluator(TInt aPriority); |
|
83 |
|
84 private: |
|
85 MHlpPrivObserver* iObserver; |
|
86 RDbView* iView; |
|
87 }; |
|
88 |
|
89 |
|
90 |
|
91 // |
|
92 // ----> CHlpSQLSearch |
|
93 // |
|
94 class CHlpSQLSearch : public CBase, public MHlpPrivObserver |
|
95 { |
|
96 public: |
|
97 static CHlpSQLSearch* NewL(MHlpDbObserver& aObserver); |
|
98 ~CHlpSQLSearch(); |
|
99 |
|
100 public: |
|
101 void SetDatabase(CHlpDatabase& aDatabase); |
|
102 void SearchL(TInt aType, const TDesC& aCriterion); |
|
103 void CancelEvaluator(); |
|
104 |
|
105 inline RDbView& View() const; |
|
106 |
|
107 private: |
|
108 void ContextSearchL(const TDesC& aCriterion); |
|
109 void IndexIdSearchL(const TDesC& aCriterion); |
|
110 void TopicIdSearchL(const TDesC& aCriterion); |
|
111 void TextSearchL(const TDesC& aCriterion, TBool aFullText=EFalse); |
|
112 |
|
113 private: |
|
114 void IndexListL(); |
|
115 void CategoryListL(); |
|
116 void TopicListForCategoryL(const TDesC& aCriterion); |
|
117 void TopicListForCategoryUIDL(const TDesC& aCriterion); |
|
118 void TopicIdSearchL(); |
|
119 void BuildViewL(); |
|
120 void Reset(); |
|
121 |
|
122 private: // observer stuff |
|
123 void HandleSearchEventL(TInt aEvent); |
|
124 inline void ReportEventToObserverL(TInt aEvent) { iObserver->HandleDbEventL(aEvent); } |
|
125 |
|
126 private: |
|
127 CHlpSQLSearch(MHlpDbObserver& aObserver); |
|
128 void ConstructL(); |
|
129 |
|
130 private: |
|
131 enum TFlags |
|
132 { |
|
133 EFlagsNull = 0x0000, |
|
134 EFlagsPerformSearch = 0x0001, |
|
135 EFlagsAsynchronousSearch = 0x0002, |
|
136 EFlagsHaveValidDatabase = 0x0004 |
|
137 }; |
|
138 |
|
139 private: |
|
140 TUint iFlags; |
|
141 CHlpSQLBuffer* iSQLStatement; |
|
142 CHlpSQLEvaluator* iSQLEvaluator; |
|
143 CHlpDatabase* iDatabase; |
|
144 RDbView* iView; |
|
145 MHlpDbObserver* iObserver; |
|
146 }; |
|
147 |
|
148 |
|
149 |
|
150 inline RDbView& CHlpSQLSearch::View() const |
|
151 { |
|
152 return *iView; |
|
153 } |
|
154 |
|
155 #endif |