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 "locationservice.h"
|
|
23 |
|
|
24 |
#define TRACE 0
|
|
25 |
#define GETLOCATION 1
|
|
26 |
|
|
27 |
|
|
28 |
_LIT(KRequestor,"testapp");
|
|
29 |
|
|
30 |
class ASyncCB : public MLocationCallBack
|
|
31 |
{
|
|
32 |
TInt iCmd ;
|
|
33 |
TInt iRetStatus ;
|
|
34 |
TInt iCount ;
|
|
35 |
|
|
36 |
CLocationService *iService ;
|
|
37 |
|
|
38 |
|
|
39 |
public :
|
|
40 |
|
|
41 |
|
|
42 |
TInt HandleNotifyL(HPositionGenericInfo* aPosInfo , TInt aError) ;
|
|
43 |
|
|
44 |
ASyncCB() :iCmd(0) , iRetStatus(KErrGeneral) , iCount(0) //Default constructor
|
|
45 |
{
|
|
46 |
;
|
|
47 |
}
|
|
48 |
ASyncCB(TInt aCmd , CLocationService *aService) ;
|
|
49 |
};
|
|
50 |
|
|
51 |
|
|
52 |
ASyncCB :: ASyncCB(TInt aCmd ,CLocationService *aService):iCount(0)
|
|
53 |
{
|
|
54 |
iCmd = aCmd ;
|
|
55 |
iService = aService ;
|
|
56 |
|
|
57 |
}
|
|
58 |
|
|
59 |
TInt ASyncCB :: HandleNotifyL (HPositionGenericInfo* aPosInfo , TInt Error )
|
|
60 |
{
|
|
61 |
if(iCmd == TRACE)
|
|
62 |
{
|
|
63 |
iService->CancelOnGoingService(ECancelTrace) ;
|
|
64 |
}
|
|
65 |
else if(iCmd == GETLOCATION)
|
|
66 |
{
|
|
67 |
iService->GetLocationL(this,EBasicInfo) ;
|
|
68 |
iCount++ ;
|
|
69 |
}
|
|
70 |
|
|
71 |
if(iCount > 3)
|
|
72 |
{
|
|
73 |
CActiveScheduler *current = CActiveScheduler :: Current() ;
|
|
74 |
current->Stop() ;
|
|
75 |
}
|
|
76 |
iRetStatus = KErrNone ;
|
|
77 |
return iRetStatus ;
|
|
78 |
}
|
|
79 |
|
|
80 |
|
|
81 |
TInt StrayTestL()
|
|
82 |
{
|
|
83 |
|
|
84 |
CActiveScheduler *Scheduler = new CActiveScheduler ;
|
|
85 |
|
|
86 |
CActiveScheduler :: Install(Scheduler) ;
|
|
87 |
CLocationService *CoreObj = CLocationService ::NewL() ;
|
|
88 |
ASyncCB Updates(TRACE , CoreObj) ;
|
|
89 |
ASyncCB GetLoc(GETLOCATION , CoreObj) ;
|
|
90 |
|
|
91 |
// GelocUpdateCallBack MyUpdates(&CmdId , (CLocationService *)NULL) ;
|
|
92 |
CoreObj->TraceL(&Updates,EBasicInfo) ;
|
|
93 |
CoreObj->GetLocationL(&GetLoc,EBasicInfo) ;
|
|
94 |
|
|
95 |
CActiveScheduler :: Start() ;
|
|
96 |
return 0 ; // Controll never reaches here
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
TInt StrayTest(TAny */*Arg*/)
|
|
101 |
{
|
|
102 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
103 |
//Install a new active scheduler to this thread
|
|
104 |
TRAPD(err , StrayTestL()) ;
|
|
105 |
delete cleanup ;
|
|
106 |
return 0 ;
|
|
107 |
}
|
|
108 |
|
|
109 |
|