|
1 /* |
|
2 * Copyright (c) 2006-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: Responsible for handling the overall application data, if any. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // System Includes |
|
24 #include <AiwGenericParam.h> |
|
25 #include <s32mem.h> |
|
26 |
|
27 // User Includes |
|
28 #include "srchuiappappui.h" |
|
29 #include "srchuiappdocument.h" |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // Ecom interface static factory method implementation. |
|
33 // Other Items are mentioned in the Header |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 CSrchUiAppDocument* CSrchUiAppDocument::NewL(CEikApplication& aApp) |
|
37 { |
|
38 CSrchUiAppDocument* self = NewLC(aApp); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // Ecom interface static factory method implementation. |
|
45 // Other Items are mentioned in the Header |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 CSrchUiAppDocument* CSrchUiAppDocument::NewLC(CEikApplication& aApp) |
|
49 { |
|
50 CSrchUiAppDocument* self = new (ELeave) CSrchUiAppDocument(aApp); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // Destructor |
|
58 // Other Items are mentioned in the Header |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 CSrchUiAppDocument::~CSrchUiAppDocument() |
|
62 { |
|
63 // no implementation required |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------------------------- |
|
67 // Other Items are mentioned in the Header |
|
68 // ---------------------------------------------------------------------------- |
|
69 // |
|
70 CEikAppUi* CSrchUiAppDocument::CreateAppUiL() |
|
71 { |
|
72 // Create the application user interface, and return a pointer to it, |
|
73 // the framework takes ownership of this object CEikAppUi |
|
74 iAppUi = new (ELeave) CSrchUiAppAppUi; |
|
75 return static_cast<CEikAppUi *>(iAppUi); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Extract the AIW parameters |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CSrchUiAppDocument::ExternalizeParametersL() |
|
83 { |
|
84 |
|
85 |
|
86 TPtrC keyword; //keyword |
|
87 TPtrC name; //calling application's name |
|
88 RDesWriteStream wrStrm; |
|
89 HBufC8* paramsPtr = HBufC8::NewL( 1024 ); //to be changed to KMaxCmdLineLength |
|
90 TPtr8 ptr = paramsPtr->Des(); |
|
91 const CAiwGenericParamList* params = GetInputParameters(); |
|
92 if (params) |
|
93 { |
|
94 TInt index = 0; |
|
95 |
|
96 |
|
97 TRAP_IGNORE(wrStrm.Open( ptr )); |
|
98 const TAiwGenericParam* param; |
|
99 |
|
100 // Get host application UID |
|
101 param = params->FindFirst(index, EGenericParamApplication, EVariantTypeTUid); |
|
102 |
|
103 if (index >= 0 && param) |
|
104 { |
|
105 TUid uid = KNullUid; |
|
106 param->Value().Get(uid); |
|
107 wrStrm.WriteInt32L( uid.iUid ); |
|
108 } |
|
109 |
|
110 // Get the keyword, if available |
|
111 index = 0; |
|
112 param = params->FindFirst(index, EGenericParamKeywords, |
|
113 EVariantTypeDesC); |
|
114 |
|
115 if (param) |
|
116 { |
|
117 keyword.Set(param->Value().AsDes()); |
|
118 TInt32 sizeOfStr = keyword.Length(); |
|
119 wrStrm.WriteInt32L( sizeOfStr ); |
|
120 wrStrm << keyword; |
|
121 } |
|
122 |
|
123 // Get the calling application's name, if available |
|
124 index = 0; |
|
125 param = params->FindFirst(index, EGenericParamCallAppLocName, |
|
126 EVariantTypeDesC); |
|
127 |
|
128 if (param) |
|
129 { |
|
130 name.Set(param->Value().AsDes()); |
|
131 TInt32 sizeOfStr = name.Length(); |
|
132 wrStrm.WriteInt32L( sizeOfStr ); |
|
133 wrStrm << name; |
|
134 } |
|
135 |
|
136 //In-Device-Search starting parameter |
|
137 index = 0; |
|
138 param = params->FindFirst(index, |
|
139 EGenericParamStartOption, EVariantTypeTInt32); |
|
140 if (param) |
|
141 { |
|
142 TInt32 value = 0; |
|
143 param->Value().Get(value); |
|
144 wrStrm.WriteInt32L( value ); |
|
145 } |
|
146 |
|
147 // Target content of search |
|
148 TInt count = 0; |
|
149 index = 0; |
|
150 do |
|
151 { |
|
152 param = params->FindFirst(index, EGenericParamSearchContent, EVariantTypeTUid); |
|
153 if (index >= 0 && param) |
|
154 { |
|
155 count++; |
|
156 index++; |
|
157 } |
|
158 }while(param); |
|
159 |
|
160 wrStrm.WriteInt32L( count ); |
|
161 |
|
162 index = 0; |
|
163 for(TInt i =0; i < count; i++) |
|
164 { |
|
165 param = params->FindFirst(index, EGenericParamSearchContent, EVariantTypeTUid); |
|
166 if (index >= 0 && param) |
|
167 { |
|
168 index++; |
|
169 TUid uid = KNullUid; |
|
170 param->Value().Get(uid); |
|
171 wrStrm.WriteInt32L( uid.iUid ); |
|
172 } |
|
173 } |
|
174 wrStrm.CommitL(); |
|
175 } |
|
176 iAppUi->CreateGenSrchUiL(ptr); |
|
177 } |
|
178 |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // Other Items are mentioned in the Header |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 void CSrchUiAppDocument::ConstructL() |
|
185 { |
|
186 // no implementation required |
|
187 } |
|
188 |
|
189 // ---------------------------------------------------------------------------- |
|
190 // Constructor |
|
191 // ---------------------------------------------------------------------------- |
|
192 // |
|
193 CSrchUiAppDocument::CSrchUiAppDocument(CEikApplication& aApp) : CAiwGenericParamConsumer(aApp) |
|
194 { |
|
195 // no implementation required |
|
196 } |
|
197 |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // Open file |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 CFileStore* CSrchUiAppDocument::OpenFileL(TBool aDoOpen, |
|
204 const TDesC& aFilename, |
|
205 RFs& aFs) |
|
206 { |
|
207 if(aDoOpen) |
|
208 ExternalizeParametersL(); |
|
209 return CAknDocument::OpenFileL(aDoOpen, aFilename, aFs); |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // Open File |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void CSrchUiAppDocument::OpenFileL(CFileStore*& aFileStore, RFile& aFile) |
|
218 { |
|
219 ExternalizeParametersL(); |
|
220 return CAknDocument::OpenFileL(aFileStore, aFile); |
|
221 } |
|
222 |
|
223 |
|
224 |
|
225 //end of file |
|
226 |