28
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 "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 |
*@file
|
|
20 |
*@internalComponent
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include "ncmdhcpnotifwatcher.h"
|
|
24 |
#include "ncmconnectionmanager.h"
|
|
25 |
#include "ncmdhcpnotifobserver.h"
|
|
26 |
|
|
27 |
#ifdef OVERDUMMY_NCMCC
|
|
28 |
#include <usb/testncmcc/dummy_ncminternalsrv.h>
|
|
29 |
#else
|
|
30 |
#include "ncminternalsrv.h"
|
|
31 |
|
|
32 |
#endif // OVERDUMMY_NCMCC
|
|
33 |
|
|
34 |
// For OST trace
|
|
35 |
#include "OstTraceDefinitions.h"
|
|
36 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
37 |
#include "ncmdhcpnotifwatcherTraces.h"
|
|
38 |
#endif
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Constructor.
|
|
42 |
* @param aObserver The AO which handle the DHCP provisioning request from NCM internal server
|
|
43 |
* @param aNcmInteralSvr The reference of the NCM internal server client API handle
|
|
44 |
*/
|
|
45 |
CNcmDhcpNotifWatcher::CNcmDhcpNotifWatcher(MNcmDhcpNotificationObserver& aObserver,
|
|
46 |
RNcmInternalSrv& aNcmInteralSvr)
|
|
47 |
: CActive(CActive::EPriorityStandard),
|
|
48 |
iObserver(aObserver),
|
|
49 |
iNcmInteralSvr(aNcmInteralSvr)
|
|
50 |
{
|
|
51 |
OstTraceFunctionEntryExt( CNCMDHCPNOTIFWATCHER_CNCMDHCPNOTIFWATCHER_ENTRY, this );
|
|
52 |
|
|
53 |
CActiveScheduler::Add(this);
|
|
54 |
OstTraceFunctionExit1( CNCMDHCPNOTIFWATCHER_CNCMDHCPNOTIFWATCHER_EXIT, this );
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Destructor.
|
|
60 |
*/
|
|
61 |
CNcmDhcpNotifWatcher::~CNcmDhcpNotifWatcher()
|
|
62 |
{
|
|
63 |
OstTraceFunctionEntry0( CNCMDHCPNOTIFWATCHER_CNCMDHCPNOTIFWATCHER_ENTRY_DESTROY );
|
|
64 |
Cancel();
|
|
65 |
OstTraceFunctionExit0( CNCMDHCPNOTIFWATCHER_CNCMDHCPNOTIFWATCHER_EXIT_DESTROY );
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Start observing the connection stage changes.
|
|
70 |
*/
|
|
71 |
void CNcmDhcpNotifWatcher::StartL()
|
|
72 |
{
|
|
73 |
OstTraceFunctionEntry0( CNCMDHCPNOTIFWATCHER_START_ENTRY );
|
|
74 |
|
|
75 |
if(!IsActive())
|
|
76 |
{
|
|
77 |
iNcmInteralSvr.DhcpProvisionNotify(iStatus);
|
|
78 |
SetActive();
|
|
79 |
}
|
|
80 |
else
|
|
81 |
{
|
|
82 |
// Report this to NCM connection manager
|
|
83 |
OstTrace0( TRACE_FATAL, CNCMDHCPNOTIFWATCHER_STARTL, "DHCP notifier already actived!" );
|
|
84 |
User::Leave(KErrInUse);
|
|
85 |
}
|
|
86 |
|
|
87 |
OstTraceFunctionExit0( CNCMDHCPNOTIFWATCHER_START_EXIT );
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Implements cancellation of an outstanding request. Cancels the connection progress notification request.
|
|
92 |
*/
|
|
93 |
void CNcmDhcpNotifWatcher::DoCancel()
|
|
94 |
{
|
|
95 |
OstTraceFunctionEntry0( CNCMDHCPNOTIFWATCHER_DOCANCEL_ENTRY );
|
|
96 |
|
|
97 |
iNcmInteralSvr.DhcpProvisionNotifyCancel();
|
|
98 |
OstTraceFunctionExit0( CNCMDHCPNOTIFWATCHER_DOCANCEL_EXIT );
|
|
99 |
}
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Called when got DHCP provisioning request from NCM internal server.
|
|
103 |
*/
|
|
104 |
void CNcmDhcpNotifWatcher::RunL()
|
|
105 |
{
|
|
106 |
OstTraceFunctionEntry0( CNCMDHCPNOTIFWATCHER_RUNL_ENTRY );
|
|
107 |
|
|
108 |
TInt completionCode = iStatus.Int();
|
|
109 |
if (KErrCancel != completionCode)
|
|
110 |
{
|
|
111 |
// Doing DHCP
|
|
112 |
iObserver.MdnoHandleDhcpNotification(iStatus.Int());
|
|
113 |
|
|
114 |
if (KErrNone == completionCode)
|
|
115 |
{
|
|
116 |
// Restart the watcher
|
|
117 |
StartL();
|
|
118 |
}
|
|
119 |
}
|
|
120 |
OstTraceFunctionExit0( CNCMDHCPNOTIFWATCHER_RUNL_EXIT );
|
|
121 |
}
|
|
122 |
|