|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include <e32base.h> |
|
21 #ifdef SYMBIAN_FEATURE_MANAGER |
|
22 #include <featdiscovery.h> |
|
23 #include <featureuids.h> |
|
24 #endif |
|
25 // LBS-specific |
|
26 #include <lbs.h> |
|
27 #include <lbs/lbsprivacycontroller.h> |
|
28 #include <lbs/lbsx3p.h> |
|
29 |
|
30 |
|
31 #include "lbsdevloggermacros.h" |
|
32 #include "lbsrootapi.h" |
|
33 #include "privacyandlocationrequesthandler.h" |
|
34 #include "x3phandler.h" |
|
35 #include "ngmessageswitch.h" |
|
36 #include "lbsnetworkrequesthandler.h" |
|
37 #include "lbsnrhserver.h" |
|
38 #include "agpsinterfacehandler.h" |
|
39 |
|
40 CLbsNetworkRequestHandler::CLbsNetworkRequestHandler(CNrhServer* aNrhServer) |
|
41 : iNrhServer(aNrhServer) |
|
42 { |
|
43 } |
|
44 CLbsNetworkRequestHandler::~CLbsNetworkRequestHandler() |
|
45 { |
|
46 #if defined(_DEBUG) |
|
47 if(iOomListener) |
|
48 { |
|
49 iOomListener->Cancel(); |
|
50 delete iOomListener; |
|
51 } |
|
52 #endif |
|
53 |
|
54 iNrhServer->SetPrivacyServerObserver(NULL); |
|
55 |
|
56 delete iX3pHandler; |
|
57 delete iPrivLocHandler; |
|
58 delete iNgMessageSwitch; |
|
59 iNetRegStatus.Close(); |
|
60 delete iAdmin; |
|
61 } |
|
62 |
|
63 CLbsNetworkRequestHandler* CLbsNetworkRequestHandler::NewL(CNrhServer* aNrhServer) |
|
64 { |
|
65 CLbsNetworkRequestHandler* self = new(ELeave) CLbsNetworkRequestHandler(aNrhServer); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop(); |
|
69 return(self); |
|
70 } |
|
71 |
|
72 void CLbsNetworkRequestHandler::ConstructL() |
|
73 { |
|
74 LBSLOG_BEGIN(); |
|
75 // Create the LbsAdmin. |
|
76 // It would be possible to do this every time a value |
|
77 // is needed, but that would give the potential for OOM |
|
78 // conditions, so do it once and pass the pointer to the |
|
79 // sub-components that need it. |
|
80 |
|
81 iAdmin = CLbsAdmin::NewL(); |
|
82 |
|
83 // Connect to the internal network registration (roaming) status interface |
|
84 iNetRegStatus.OpenL(); |
|
85 |
|
86 // Create the Network Gateway Message Switch |
|
87 iNgMessageSwitch = CNGMessageSwitch::NewL(*iAdmin); |
|
88 |
|
89 //Create the Privacy and Location Handler |
|
90 iPrivLocHandler = CPrivacyAndLocationHandler::NewL(*iNgMessageSwitch, |
|
91 *iAdmin, |
|
92 iNetRegStatus); |
|
93 |
|
94 iNrhServer->SetPrivacyServerObserver(iPrivLocHandler->PrivacyHandler()); |
|
95 |
|
96 #ifdef SYMBIAN_FEATURE_MANAGER |
|
97 TBool locationManagementSupported = CFeatureDiscovery::IsFeatureSupportedL(NFeature::KLocationManagement); |
|
98 #else |
|
99 TBool locationManagementSupported(ETrue); |
|
100 #endif |
|
101 if(locationManagementSupported) |
|
102 { |
|
103 iX3pHandler = CX3pHandler::NewL(*iNgMessageSwitch, iPrivLocHandler->X3pStatusHandler(), *iAdmin); |
|
104 } |
|
105 |
|
106 // Let the server know about the X3P Handler |
|
107 iNrhServer->SetX3pServerObserver(iX3pHandler); |
|
108 |
|
109 #if defined(_DEBUG) |
|
110 // For OOM testing. The listener will force an error on the next heap |
|
111 // allocation when it is kicked by test code. |
|
112 iOomListener = CLbsOomListener::NewL(); |
|
113 iOomListener->StartGettingRequests(); |
|
114 #endif |
|
115 } |
|
116 |
|
117 CLbsAdmin* CLbsNetworkRequestHandler::Admin() const |
|
118 { |
|
119 return iAdmin; |
|
120 } |
|
121 |
|
122 RLbsNetworkRegistrationStatus& CLbsNetworkRequestHandler::NetworkRegistrationStatus() |
|
123 { |
|
124 return iNetRegStatus; |
|
125 } |