|
1 /* |
|
2 * Copyright (c) 2009 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * Stray signal test function |
|
20 */ |
|
21 |
|
22 #include <e32svr.h> |
|
23 #include <StifParser.h> |
|
24 #include <Stiftestinterface.h> |
|
25 #include <LbsRequestor.h> |
|
26 #include <LiwServiceHandler.h> |
|
27 #include <LiwCommon.h> |
|
28 |
|
29 #include "tcomplugin.h" |
|
30 |
|
31 #define TRACE 0 |
|
32 #define GETLOCATION 1 |
|
33 |
|
34 class TraceCB : public MLiwNotifyCallback |
|
35 { |
|
36 TInt iCount ; |
|
37 TInt iCmd ; |
|
38 MLiwInterface *iLocationInterface ; |
|
39 CLiwGenericParamList *iInputList ; |
|
40 |
|
41 public : |
|
42 TInt iRetStatus ; |
|
43 |
|
44 TInt HandleNotifyL( |
|
45 TInt aCmdId, |
|
46 TInt aEventId, |
|
47 CLiwGenericParamList& aEventParamList, |
|
48 const CLiwGenericParamList& aInParamList) ; |
|
49 |
|
50 TraceCB() : iRetStatus(KErrGeneral) , iCount(0) ,iCmd(0)//Default constructor |
|
51 { |
|
52 ; |
|
53 } |
|
54 TraceCB(TInt aCmd , MLiwInterface *aInterface , CLiwGenericParamList *aInputList) ; |
|
55 }; |
|
56 |
|
57 |
|
58 TraceCB :: TraceCB(TInt aCmd ,MLiwInterface *aInterface , CLiwGenericParamList *aInputList):iCount(0) |
|
59 { |
|
60 iCmd = aCmd ; |
|
61 iLocationInterface = aInterface ; |
|
62 iInputList = aInputList ; |
|
63 |
|
64 } |
|
65 |
|
66 TInt TraceCB :: HandleNotifyL( |
|
67 TInt aCmdId, |
|
68 TInt aEventId, |
|
69 CLiwGenericParamList& aEventParamList, |
|
70 const CLiwGenericParamList& aInParamList) |
|
71 { |
|
72 |
|
73 //DeRefrence Allocated Map first |
|
74 TInt index = 0 ; |
|
75 |
|
76 |
|
77 const TLiwGenericParam *Notifyparm = aEventParamList.FindFirst(index ,KLocationMap) ; |
|
78 |
|
79 if(Notifyparm) |
|
80 { |
|
81 TLiwVariant mapVar = Notifyparm->Value() ; |
|
82 const CLiwMap *map = mapVar.AsMap() ; |
|
83 // map->DecRef() ; |
|
84 } |
|
85 iCount++ ; |
|
86 if(iCount > 3) |
|
87 { |
|
88 CActiveScheduler *current = CActiveScheduler :: Current() ; |
|
89 current->Stop() ; |
|
90 } |
|
91 if(iCmd == GETLOCATION) |
|
92 { |
|
93 TBuf8<20>CmdBuf(KCmdCancelRequest) ; |
|
94 TLiwVariant CancelType(KCmdGetLocation) ; |
|
95 |
|
96 TLiwGenericParam CancelParm(KCancelType , TLiwVariant (KRequestGetLoc)) ; |
|
97 iInputList->AppendL(CancelParm) ; |
|
98 CLiwGenericParamList *outlist1 = CLiwGenericParamList :: NewL() ; |
|
99 iLocationInterface->ExecuteCmdL(CmdBuf , *iInputList , *outlist1 ) ; |
|
100 iInputList->Reset() ; |
|
101 |
|
102 delete outlist1 ; |
|
103 return 0; |
|
104 } |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 iRetStatus = KErrNone ; |
|
111 return iRetStatus ; |
|
112 } |
|
113 |
|
114 |
|
115 TInt StrayTestGetLocL() |
|
116 { |
|
117 |
|
118 CActiveScheduler *Scheduler = new CActiveScheduler ; |
|
119 |
|
120 CActiveScheduler :: Install(Scheduler) ; |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
126 |
|
127 // Input and output parameter list |
|
128 CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
129 CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KContents, KService); |
|
135 |
|
136 |
|
137 crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
138 |
|
139 RCriteriaArray a; |
|
140 a.AppendL(crit); |
|
141 |
|
142 ServiceHandler->AttachL(a) ; |
|
143 ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 TInt pos = 0; |
|
149 |
|
150 const TLiwGenericParam *errorprm = outputlist->FindFirst(pos , KErrorCode) ; |
|
151 |
|
152 if(!errorprm) |
|
153 { |
|
154 return KErrGeneral ; |
|
155 } |
|
156 |
|
157 pos = 0 ; |
|
158 const TLiwGenericParam *genericparm = outputlist->FindFirst(pos,KDataSource ); |
|
159 |
|
160 if(!genericparm) |
|
161 { |
|
162 |
|
163 return KErrGeneral ; |
|
164 } |
|
165 |
|
166 MLiwInterface* locinterface = (genericparm->Value()).AsInterface(); |
|
167 |
|
168 |
|
169 TBuf8<20>CmdBuf(KCmdTraceLocation) ; |
|
170 |
|
171 CLiwGenericParamList *InputList = CLiwGenericParamList :: NewL() ; |
|
172 CLiwGenericParamList *OutParmList = CLiwGenericParamList :: NewL() ; |
|
173 |
|
174 |
|
175 TraceCB Updates(TRACE , locinterface , InputList) ; |
|
176 TraceCB GetLoc(GETLOCATION , locinterface , InputList) ; |
|
177 |
|
178 locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous , &Updates); |
|
179 |
|
180 CmdBuf = KCmdGetLocation ; |
|
181 locinterface->ExecuteCmdL(CmdBuf , *InputList , *OutParmList ,KLiwOptASyncronous , &GetLoc); |
|
182 |
|
183 CActiveScheduler :: Start() ; |
|
184 |
|
185 |
|
186 locinterface->Close() ; |
|
187 delete ServiceHandler ; |
|
188 delete InputList ; |
|
189 delete OutParmList ; |
|
190 delete Scheduler ; |
|
191 return 0 ; // Controll never reaches here |
|
192 } |
|
193 |
|
194 |
|
195 TInt StrayTestGetLoc(TAny */*Arg*/) |
|
196 { |
|
197 |
|
198 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
199 //Install a new active scheduler to this thread |
|
200 TRAPD(err , StrayTestGetLocL()) ; |
|
201 delete cleanup ; |
|
202 |
|
203 return err ; |
|
204 } |
|
205 |
|
206 |