20
|
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: Class for handling popup query.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32std.h>
|
|
20 |
#include <s32mem.h>
|
|
21 |
#include <aknappui.h>
|
|
22 |
#include <coemain.h>
|
|
23 |
|
|
24 |
#include "ccacontactorserviceheaders.h"
|
|
25 |
|
|
26 |
// ================= MEMBER FUNCTIONS =======================
|
|
27 |
//
|
|
28 |
|
|
29 |
// --------------------------------------------------------------------------
|
|
30 |
// CCCAContactorPopupHandler::NewL
|
|
31 |
// --------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
CCCAContactorPopupHandler* CCCAContactorPopupHandler::NewL()
|
|
34 |
{
|
|
35 |
CCCAContactorPopupHandler* self = new (ELeave) CCCAContactorPopupHandler();
|
|
36 |
CleanupStack::PushL(self);
|
|
37 |
self->ConstructL();
|
|
38 |
CleanupStack::Pop(self);
|
|
39 |
return self;
|
|
40 |
}
|
|
41 |
|
|
42 |
// --------------------------------------------------------------------------
|
|
43 |
// CCCAContactorPopupHandler::~CCCAContactorPopupHandler
|
|
44 |
// --------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
CCCAContactorPopupHandler::~CCCAContactorPopupHandler()
|
|
47 |
{
|
|
48 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::~CCCAContactorPopupHandler"));
|
|
49 |
delete iServiceHandler;
|
|
50 |
delete iSchedulerWait;
|
|
51 |
iCoeEnv.DeleteResourceFile (iResourceOffset);
|
|
52 |
delete iQueryResults;
|
|
53 |
}
|
|
54 |
|
|
55 |
// --------------------------------------------------------------------------
|
|
56 |
// CCCAContactorPopupHandler::LaunchPopupL
|
|
57 |
// --------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
TDesC& CCCAContactorPopupHandler::LaunchPopupL(
|
|
60 |
const TDesC8& aContactLinkArray,
|
|
61 |
TAiwCommAddressSelectType aCommAddressSelectType,
|
|
62 |
TBool aUseDefaults )
|
|
63 |
{
|
|
64 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::LaunchPopupL"));
|
|
65 |
|
|
66 |
__ASSERT_ALWAYS (NULL != &aContactLinkArray, User::Leave (KErrArgument));
|
|
67 |
__ASSERT_ALWAYS (0 < aContactLinkArray.Size(), User::Leave (KErrArgument));
|
|
68 |
|
|
69 |
TUint fetchFlags = 0;
|
|
70 |
|
|
71 |
// Stop scheduler just in case this is called while operation is still ongoing.
|
|
72 |
AsyncStop();
|
|
73 |
|
|
74 |
// Set service data
|
|
75 |
TAiwSingleItemSelectionDataV3 data;
|
|
76 |
|
|
77 |
if (!aUseDefaults)
|
|
78 |
{
|
|
79 |
fetchFlags |= ::EDoNotUseDefaultField;
|
|
80 |
}
|
|
81 |
|
|
82 |
data.SetFlags(fetchFlags);
|
|
83 |
data.SetCommAddressSelectType(aCommAddressSelectType);
|
|
84 |
CAiwGenericParamList& inParamList = iServiceHandler->InParamListL();
|
|
85 |
inParamList.AppendL(TAiwGenericParam(EGenericParamContactSelectionData,
|
|
86 |
TAiwVariant(TAiwSingleItemSelectionDataV3Pckg(data))));
|
|
87 |
|
|
88 |
// Set contactlink
|
|
89 |
inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray,
|
|
90 |
TAiwVariant(aContactLinkArray)));
|
|
91 |
|
|
92 |
//Append the current status pane id
|
|
93 |
//this will also be used by Pbk2ServerApplication
|
|
94 |
//This is kind of a new implementation which will pave way
|
|
95 |
//for the applications to use the required statuspane that they
|
|
96 |
//prefer.
|
|
97 |
//since its not feasible to add any new AIW functionality
|
|
98 |
//we will follow this approach.
|
|
99 |
CEikStatusPane* statusPane =
|
|
100 |
CEikonEnv::Static()->AppUiFactory()->StatusPane();
|
|
101 |
|
|
102 |
if ( statusPane )
|
|
103 |
{
|
|
104 |
TInt currentstatuspane = statusPane->CurrentLayoutResId();
|
|
105 |
TBuf<KCCAMAXBUFFSIZE> numBuf;
|
|
106 |
numBuf.AppendNum( currentstatuspane );
|
|
107 |
|
|
108 |
inParamList.AppendL(TAiwGenericParam(EGenericParamUnspecified,
|
|
109 |
TAiwVariant( numBuf )));
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
iServiceHandler->ExecuteServiceCmdL(KAiwCmdSelect, inParamList,
|
|
114 |
iServiceHandler->OutParamListL(), 0, this);
|
|
115 |
|
|
116 |
CAknInputBlock* inputBlock = CAknInputBlock::NewCancelHandlerLC( this );
|
|
117 |
iCloseApp = EFalse;
|
|
118 |
|
|
119 |
// Waiting for popup selection.
|
|
120 |
// Make this whole operation look synchronous
|
|
121 |
iSchedulerWait->Start();
|
|
122 |
|
|
123 |
CleanupStack::PopAndDestroy( inputBlock );
|
|
124 |
|
|
125 |
// If error case occurred, leave
|
|
126 |
if (KErrNone != iError)
|
|
127 |
{
|
|
128 |
if (iCloseApp)
|
|
129 |
{
|
|
130 |
// Send an exit command in order to close CCA and Phonebook2
|
|
131 |
// once the end(red) key is pressed or Exit command
|
|
132 |
CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv.AppUi() );
|
|
133 |
|
|
134 |
if ( appUi )
|
|
135 |
{
|
|
136 |
appUi->ProcessCommandL( EAknCmdExit );
|
|
137 |
}
|
|
138 |
}
|
|
139 |
User::Leave(iError);
|
|
140 |
}
|
|
141 |
|
|
142 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::LaunchPopupL: Done."));
|
|
143 |
|
|
144 |
return *iQueryResults;
|
|
145 |
}
|
|
146 |
|
|
147 |
// --------------------------------------------------------------------------
|
|
148 |
// CCCAContactorPopupHandler::HandleNotifyL
|
|
149 |
// --------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
TInt CCCAContactorPopupHandler::HandleNotifyL(TInt aCmdId, TInt aEventId,
|
|
152 |
CAiwGenericParamList& aEventParamList,
|
|
153 |
const CAiwGenericParamList& /*aInParamList*/)
|
|
154 |
{
|
|
155 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::HandleNotifyL"));
|
|
156 |
TInt returnValue = KErrNone;
|
|
157 |
|
|
158 |
if (aCmdId == KAiwCmdSelect)
|
|
159 |
{
|
|
160 |
switch(aEventId)
|
|
161 |
{
|
|
162 |
case KAiwEventCompleted:
|
|
163 |
{
|
|
164 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::HandleNotifyL: KAiwEventCompleted"));
|
|
165 |
// Selection done.
|
|
166 |
// Read and store results
|
|
167 |
TRAP(iError, ReadFieldDataL(aEventParamList));
|
|
168 |
}
|
|
169 |
break;
|
|
170 |
|
|
171 |
case KAiwEventCanceled:
|
|
172 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::HandleNotifyL: KAiwEventCanceled"));
|
|
173 |
// Selection canceled.
|
|
174 |
iError = KErrCancel;
|
|
175 |
break;
|
|
176 |
|
|
177 |
case KAiwEventError:
|
|
178 |
case KAiwEventStopped:
|
|
179 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::HandleNotifyL: KAiwEventError or KAiwEventStopped"));
|
|
180 |
// Error occurred.
|
|
181 |
iError = KErrGeneral;
|
|
182 |
break;
|
|
183 |
|
|
184 |
case KAiwEventQueryExit:
|
|
185 |
// TODO: how should this work?
|
|
186 |
iError = KErrAbort;
|
|
187 |
iCloseApp = ETrue;
|
|
188 |
returnValue = ETrue;
|
|
189 |
break;
|
|
190 |
|
|
191 |
default:
|
|
192 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::HandleNotifyL: Unknown"));
|
|
193 |
iError = KErrGeneral;
|
|
194 |
break;
|
|
195 |
}
|
|
196 |
// if notify received, stop scheduler
|
|
197 |
AsyncStop();
|
|
198 |
}
|
|
199 |
|
|
200 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::HandleNotifyL: Done."));
|
|
201 |
return returnValue;
|
|
202 |
}
|
|
203 |
|
|
204 |
// --------------------------------------------------------------------------
|
|
205 |
// CCCAContactorPopupHandler::CCCAContactorPopupHandler
|
|
206 |
// --------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
CCCAContactorPopupHandler::CCCAContactorPopupHandler() :
|
|
209 |
iCoeEnv(*CCoeEnv::Static()),
|
|
210 |
iError(KErrNone)
|
|
211 |
{
|
|
212 |
}
|
|
213 |
|
|
214 |
// --------------------------------------------------------------------------
|
|
215 |
// CCCAContactorPopupHandler::ConstructL
|
|
216 |
// --------------------------------------------------------------------------
|
|
217 |
//
|
|
218 |
void CCCAContactorPopupHandler::ConstructL()
|
|
219 |
{
|
|
220 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::ConstructL"));
|
|
221 |
|
|
222 |
PrepareResourcesL();
|
|
223 |
|
|
224 |
iServiceHandler = CAiwServiceHandler::NewL();
|
|
225 |
iServiceHandler->AttachL(R_CCACONTACTORSERVICE_CONTACT_SELECTION_INTEREST);
|
|
226 |
|
|
227 |
iSchedulerWait = new (ELeave) CActiveSchedulerWait();
|
|
228 |
|
|
229 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::ConstructL: Done."));
|
|
230 |
}
|
|
231 |
|
|
232 |
// --------------------------------------------------------------------------
|
|
233 |
// CCCAContactorPopupHandler::PrepareResourcesL
|
|
234 |
// --------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
void CCCAContactorPopupHandler::PrepareResourcesL()
|
|
237 |
{
|
|
238 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::PrepareResourcesL"));
|
|
239 |
|
|
240 |
// preparing resources for use
|
|
241 |
TFileName fileName;
|
|
242 |
fileName.Append (KCCAContactorServiceResourceFileName);
|
|
243 |
|
|
244 |
BaflUtils::NearestLanguageFile (iCoeEnv.FsSession (), fileName);
|
|
245 |
if (ConeUtils::FileExists (fileName))
|
|
246 |
{
|
|
247 |
iResourceOffset = iCoeEnv.AddResourceFileL (fileName);
|
|
248 |
}
|
|
249 |
else // not found from user drive, leave badly.
|
|
250 |
{
|
|
251 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::PrepareResourcesL: Resource file not exists."));
|
|
252 |
User::Leave (KErrGeneral);
|
|
253 |
}
|
|
254 |
|
|
255 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::PrepareResourcesL: Done."));
|
|
256 |
}
|
|
257 |
|
|
258 |
// --------------------------------------------------------------------------
|
|
259 |
// CCCAContactorPopupHandler::ReadFieldDataL
|
|
260 |
// --------------------------------------------------------------------------
|
|
261 |
//
|
|
262 |
void CCCAContactorPopupHandler::ReadFieldDataL(
|
|
263 |
CAiwGenericParamList& aEventParamList)
|
|
264 |
{
|
|
265 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::ReadFieldDataL"));
|
|
266 |
|
|
267 |
if (iQueryResults)
|
|
268 |
{
|
|
269 |
delete iQueryResults;
|
|
270 |
iQueryResults = NULL;
|
|
271 |
}
|
|
272 |
|
|
273 |
TInt index = 1; // Get field data from index 1
|
|
274 |
const TAiwGenericParam* param =
|
|
275 |
aEventParamList.FindFirst(index, EGenericParamContactFieldData);
|
|
276 |
if (KErrNotFound != index)
|
|
277 |
{
|
|
278 |
TInt length = param->Value().AsDes().Length();
|
|
279 |
iQueryResults = HBufC::NewL(length);
|
|
280 |
iQueryResults->Des().Append(param->Value().AsDes());
|
|
281 |
|
|
282 |
// Data must be found!
|
|
283 |
if (0 >= iQueryResults->Length())
|
|
284 |
{
|
|
285 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::ReadFieldDataL: Failed to get field data!"));
|
|
286 |
User::Leave(KErrGeneral);
|
|
287 |
}
|
|
288 |
}
|
|
289 |
else
|
|
290 |
{
|
|
291 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::ReadFieldDataL: Not found!"));
|
|
292 |
User::Leave(KErrNotFound);
|
|
293 |
}
|
|
294 |
|
|
295 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::ReadFieldDataL: Done."));
|
|
296 |
}
|
|
297 |
|
|
298 |
// --------------------------------------------------------------------------
|
|
299 |
// CCCAContactorPopupHandler::AsyncStop
|
|
300 |
// --------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
void CCCAContactorPopupHandler::AsyncStop()
|
|
303 |
{
|
|
304 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::AsyncStop"));
|
|
305 |
|
|
306 |
if(iSchedulerWait->IsStarted())
|
|
307 |
{
|
|
308 |
iSchedulerWait->AsyncStop();
|
|
309 |
}
|
|
310 |
|
|
311 |
CCA_DP(KCCAContactorServiceLoggerFile, CCA_L("CCCAContactorPopupHandler::AsyncStop: Done."));
|
|
312 |
}
|
|
313 |
|
|
314 |
// --------------------------------------------------------------------------
|
|
315 |
// CCCAContactorPopupHandler::AknInputBlockCancel
|
|
316 |
// --------------------------------------------------------------------------
|
|
317 |
//
|
|
318 |
void CCCAContactorPopupHandler::AknInputBlockCancel()
|
|
319 |
{
|
|
320 |
if ( iSchedulerWait->IsStarted() )
|
|
321 |
{
|
|
322 |
TRAPD( error, iServiceHandler->ExecuteServiceCmdL( KAiwCmdSelect,
|
|
323 |
iServiceHandler->InParamListL(),
|
|
324 |
iServiceHandler->OutParamListL(),
|
|
325 |
KAiwOptCancel,
|
|
326 |
this ) );
|
|
327 |
if ( error == KErrNone )
|
|
328 |
{
|
|
329 |
iCloseApp = ETrue;
|
|
330 |
}
|
|
331 |
}
|
|
332 |
}
|
|
333 |
|
|
334 |
// End of file
|