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