author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 22 | fc9cf246af83 |
permissions | -rw-r--r-- |
19 | 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> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
24 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
25 |
#include <lbsrequestor.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
26 |
#include <liwservicehandler.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
27 |
#include <liwcommon.h> |
19 | 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 |
{ |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
117 |
__UHEAP_MARK ; |
19 | 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 |
||
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
185 |
a.ResetAndDestroy() ; |
19 | 186 |
locinterface->Close() ; |
187 |
delete ServiceHandler ; |
|
188 |
delete InputList ; |
|
189 |
delete OutParmList ; |
|
190 |
delete Scheduler ; |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
191 |
__UHEAP_MARKEND ; |
19 | 192 |
return 0 ; // Controll never reaches here |
193 |
} |
|
194 |
||
195 |
||
196 |
TInt StrayTestGetLoc(TAny */*Arg*/) |
|
197 |
{ |
|
198 |
||
199 |
CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
200 |
//Install a new active scheduler to this thread |
|
201 |
TRAPD(err , StrayTestGetLocL()) ; |
|
202 |
delete cleanup ; |
|
203 |
||
204 |
return err ; |
|
205 |
} |
|
206 |
||
207 |