|
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 * mcpr binding from agent mcpr for tunneldriver. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 /** |
|
21 @file tundrivermcpr.cpp |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #include <comms-infras/ss_log.h> |
|
26 #include <in_sock.h> |
|
27 #include <comms-infras/metadata.h> |
|
28 #include <comms-infras/coremcpractivities.h> |
|
29 #include <comms-infras/agentmcpractivities.h> |
|
30 #include <comms-infras/ss_tiermanagerutils.h> |
|
31 #include "tundrivermcpr.h" |
|
32 #include "tundriverprovision.h" |
|
33 #include <comms-infras/ss_msgintercept.h> |
|
34 |
|
35 using namespace Messages; |
|
36 using namespace MeshMachine; |
|
37 using namespace ESock; |
|
38 using namespace MCprActivities; |
|
39 using namespace TunDriverMCprStates; |
|
40 |
|
41 // No Bearer Activity |
|
42 namespace TunDriverMCPRNoBearerActivity |
|
43 { |
|
44 DECLARE_DEFINE_NODEACTIVITY(ECFActivityNoBearer, TunDriverMCPRNoBearer, TCFControlProvider::TNoBearer) |
|
45 NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendBearer, CoreNetStates::TAwaitingNoBearer, MeshMachine::TNoTag) |
|
46 NODEACTIVITY_END() |
|
47 } |
|
48 |
|
49 |
|
50 // Activity Map |
|
51 namespace TunDriverMCprStates |
|
52 { |
|
53 DECLARE_DEFINE_ACTIVITY_MAP(stateMap) |
|
54 ACTIVITY_MAP_ENTRY(TunDriverMCPRNoBearerActivity, TunDriverMCPRNoBearer) |
|
55 ACTIVITY_MAP_END_BASE(AgentMCprActivities, agentMCprActivities) |
|
56 } // namespace TunDriverMCprStates |
|
57 |
|
58 |
|
59 #if defined __CFLOG_ACTIVE || defined SYMBIAN_TRACE_ENABLE |
|
60 _LIT8(KTunDriverMCprSubTag, "tunmcpr"); |
|
61 #endif |
|
62 |
|
63 CTunDriverMetaConnectionProvider* CTunDriverMetaConnectionProvider::NewL(ESock::CMetaConnectionProviderFactoryBase& aFactory, const ESock::TProviderInfo& aProviderInfo) |
|
64 /** |
|
65 * CTunDriverMetaConnectionProvider::NewL constructs a Default TunDriver MCPR |
|
66 * @param aFactory |
|
67 * @param aProviderInfo |
|
68 * @returns pointer to a constructed mcpr object. |
|
69 */ |
|
70 { |
|
71 CTunDriverMetaConnectionProvider* self = new (ELeave) CTunDriverMetaConnectionProvider(aFactory, aProviderInfo); |
|
72 CleanupStack::PushL(self); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop(self); |
|
75 return self; |
|
76 } |
|
77 |
|
78 |
|
79 CTunDriverMetaConnectionProvider::CTunDriverMetaConnectionProvider(CMetaConnectionProviderFactoryBase& aFactory, const ESock::TProviderInfo& aProviderInfo) |
|
80 : CAgentMetaConnectionProvider(aFactory, aProviderInfo, TunDriverMCprStates::stateMap::Self()) |
|
81 /** |
|
82 * CTunDriverMetaConnectionProvider::CTunDriverMetaConnectionProvider is a default constructor |
|
83 * @param aFactory |
|
84 * @param aProviderInfo |
|
85 * @returns pointer to a constructed mcpr object. |
|
86 */ |
|
87 { |
|
88 LOG_NODE_CREATE(KTunDriverMCprSubTag, CTunDriverMetaConnectionProvider); |
|
89 } |
|
90 |
|
91 CTunDriverMetaConnectionProvider::~CTunDriverMetaConnectionProvider() |
|
92 /** |
|
93 * CTunDriverMetaConnectionProvider::CTunDriverMetaConnectionProvider is a default destructor |
|
94 */ |
|
95 { |
|
96 SetAgentNotificationHandlerL(NULL); |
|
97 LOG_NODE_DESTROY(KTunDriverMCprSubTag, CTunDriverMetaConnectionProvider); |
|
98 } |
|
99 |
|
100 |
|
101 void CTunDriverMetaConnectionProvider::ConstructL() |
|
102 /** |
|
103 * CTunDriverMetaConnectionProvider::ConstructL is a second-phase constructor |
|
104 * Will set the accesspoint from Comms database. |
|
105 * @param |
|
106 * @returns |
|
107 */ |
|
108 { |
|
109 CAgentMetaConnectionProvider::ConstructL(); |
|
110 SetAccessPointConfigFromDbL(); |
|
111 } |
|
112 |
|
113 |
|
114 void CTunDriverMetaConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage) |
|
115 /** |
|
116 * CTunDriverMetaConnectionProvider::ReceivedL called on incoming MCPR Messages. |
|
117 * @param |
|
118 * @returns |
|
119 */ |
|
120 { |
|
121 __CFLOG_VAR((KTunDriverMCprTag, KTunDriverMCprSubTag, _L8("CTunDriverMetaConnectionProvider [this=%08x]::ReceivedL() aMessage=%d"), |
|
122 this, aMessage.MessageId())); |
|
123 |
|
124 ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient); |
|
125 |
|
126 TNodeContext<CTunDriverMetaConnectionProvider> ctx(*this, aMessage, aSender, aRecipient); |
|
127 CCoreMetaConnectionProvider::Received(ctx); |
|
128 User::LeaveIfError(ctx.iReturn); |
|
129 } |
|
130 |
|
131 void CTunDriverMetaConnectionProvider::SetAccessPointConfigFromDbL() |
|
132 /** |
|
133 * CTunDriverMetaConnectionProvider::SetAccessPointConfigFromDbL will initialize the tundriver with |
|
134 * the configuration set in comms database. |
|
135 * @param |
|
136 * @returns |
|
137 */ |
|
138 { |
|
139 RMetaExtensionContainer mec; |
|
140 mec.Open(AccessPointConfig()); |
|
141 CleanupClosePushL(mec); |
|
142 |
|
143 // Add provisioning information. |
|
144 CCommsDatIapView* iapView = OpenIapViewLC(); |
|
145 CTunDriverProtoProvision* provision = new (ELeave) CTunDriverProtoProvision(); |
|
146 CleanupStack::PushL(provision); |
|
147 provision->InitialiseConfigL(iapView); |
|
148 |
|
149 // Presumptions: |
|
150 // - none of the extensions can already exist in the AccessPointConfig array. AppendExtensionL() |
|
151 // is presumed to panic if adding the same extension a second time. |
|
152 // - if we have added several extensions to the AccessPointConfig array before getting a failure |
|
153 // and leaving, it is presumed that the MCPr will be destroyed and AccessPointConfig destructor |
|
154 // will clean up the extensions immediately afterwards. |
|
155 |
|
156 mec.AppendExtensionL(provision); |
|
157 CleanupStack::Pop(provision); // ownership (including cleanup) transferred to AccessPointConfig() |
|
158 CleanupStack::PopAndDestroy(); // CloseIapView() |
|
159 |
|
160 AccessPointConfig().Close(); |
|
161 AccessPointConfig().Open(mec); |
|
162 CleanupStack::PopAndDestroy(&mec); |
|
163 } |