5
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 - 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 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: tsysinfosigstrengthasyn
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "tsysinfonetworktests.h"
|
|
21 |
#include "sysinfoservice.h"
|
|
22 |
#include "entitykeys.h"
|
|
23 |
#include "tsysinfosigstrengthnotify.h"
|
|
24 |
|
|
25 |
using namespace SysInfo;
|
|
26 |
|
|
27 |
CSignalStrNotify* CSignalStrNotify::NewL(CStifLogger* aLog,TInt aStrength)
|
|
28 |
{
|
|
29 |
CSignalStrNotify* self = new(ELeave) CSignalStrNotify(aLog,aStrength);
|
|
30 |
self->ConstructL();
|
|
31 |
return self;
|
|
32 |
}
|
|
33 |
|
|
34 |
CSignalStrNotify::~CSignalStrNotify()
|
|
35 |
{
|
|
36 |
Cancel();
|
|
37 |
|
|
38 |
if(iWaitSchedular->IsStarted())
|
|
39 |
iWaitSchedular->AsyncStop();
|
|
40 |
|
|
41 |
delete iSysInfoService;
|
|
42 |
delete iWaitSchedular;
|
|
43 |
delete iTimer;
|
|
44 |
}
|
|
45 |
|
|
46 |
void CSignalStrNotify::ConstructL()
|
|
47 |
{
|
|
48 |
iSysInfoService = CSysInfoService::NewL();
|
|
49 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait();
|
|
50 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this);
|
|
51 |
CActiveScheduler::Add(this);
|
|
52 |
}
|
|
53 |
|
|
54 |
CSignalStrNotify::CSignalStrNotify(CStifLogger* aLog,TInt aStrength)
|
|
55 |
:CActive(EPriorityStandard),
|
|
56 |
iLog(aLog),iSignalStrength(aStrength)
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
void CSignalStrNotify::DoCancel()
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
void CSignalStrNotify::RunL()
|
|
65 |
{
|
|
66 |
TestFuncL();
|
|
67 |
}
|
|
68 |
|
|
69 |
void CSignalStrNotify::Start()
|
|
70 |
{
|
|
71 |
SetActive();
|
|
72 |
TRequestStatus* temp = &iStatus;
|
|
73 |
User::RequestComplete(temp, KErrNone);
|
|
74 |
iWaitSchedular->Start();
|
|
75 |
}
|
|
76 |
|
|
77 |
TInt CSignalStrNotify::Result()
|
|
78 |
{
|
|
79 |
return iResult;
|
|
80 |
}
|
|
81 |
|
|
82 |
void CSignalStrNotify::TestFuncL()
|
|
83 |
{
|
45
|
84 |
TInt64 x = 6000000000;
|
|
85 |
const TTimeIntervalMicroSeconds32 OneMinute = TTimeIntervalMicroSeconds32(x);
|
5
|
86 |
TRAPD(err,iSysInfoService->GetNotificationL(KNetwork,KSignalStrength,2222,this));
|
|
87 |
iResult = err;
|
|
88 |
|
|
89 |
iTimer->After(OneMinute);
|
|
90 |
}
|
|
91 |
|
|
92 |
void CSignalStrNotify::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/,
|
|
93 |
CSysData* aOutput, TInt32 aTransID, TSysRequest::TRequestType /*aType*/,TInt aError)
|
|
94 |
{
|
|
95 |
|
|
96 |
iLog->Log(_L("Signal Strength read.."));
|
|
97 |
|
|
98 |
if(!aError)
|
|
99 |
{
|
|
100 |
TInt32 tid = aTransID;
|
|
101 |
TInt SignalStrength = ((CStatus*)aOutput)->Status();
|
|
102 |
|
|
103 |
{
|
|
104 |
iResult = PASS;
|
|
105 |
iLog->Log(_L("Signal strength is with in specified range"));
|
|
106 |
|
|
107 |
TInt32 tid = aTransID;
|
|
108 |
TInt cellId = ((CStatus*)aOutput)->Status();
|
|
109 |
|
|
110 |
TBuf<50> buf;
|
|
111 |
buf.AppendNum(cellId);
|
|
112 |
iLog->Log(buf);
|
|
113 |
|
|
114 |
}
|
|
115 |
|
|
116 |
}
|
|
117 |
else
|
|
118 |
{
|
|
119 |
iLog->Log(_L("ERROR SET"));
|
|
120 |
iResult = FAIL;
|
|
121 |
}
|
|
122 |
delete aOutput;
|
|
123 |
iWaitSchedular->AsyncStop();
|
|
124 |
}
|
|
125 |
|
|
126 |
void CSignalStrNotify::HandleTimeOut()
|
|
127 |
{
|
|
128 |
iLog->Log(_L("TimeOut reached..."));
|
|
129 |
iSysInfoService->Cancel(1);
|
|
130 |
iResult = FAIL;
|
|
131 |
iWaitSchedular->AsyncStop();
|
|
132 |
} |