|
1 /* |
|
2 * Copyright (c) 2009 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 #include <comms-infras/ss_log.h> |
|
18 #include <in_sock.h> |
|
19 #include <comms-infras/metadata.h> |
|
20 #include <comms-infras/coremcpractivities.h> |
|
21 #include <comms-infras/agentmcpractivities.h> |
|
22 #include <comms-infras/ss_tiermanagerutils.h> |
|
23 #include "mcpr.h" |
|
24 #include "provision.h" |
|
25 #include "agent_handler.h" |
|
26 #include <comms-infras/ss_msgintercept.h> |
|
27 |
|
28 using namespace Messages; |
|
29 using namespace MeshMachine; |
|
30 using namespace ESock; |
|
31 using namespace MCprActivities; |
|
32 using namespace LegacyLoopbackMCprStates; |
|
33 |
|
34 // No Bearer Activity |
|
35 namespace LegacyLoopbackMCPRNoBearerActivity |
|
36 { |
|
37 DECLARE_DEFINE_NODEACTIVITY(ECFActivityNoBearer, LegacyLoopbackMCPRNoBearer, TCFControlProvider::TNoBearer) |
|
38 NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendBearer, CoreNetStates::TAwaitingNoBearer, MeshMachine::TNoTag) |
|
39 NODEACTIVITY_END() |
|
40 } |
|
41 |
|
42 |
|
43 // Activity Map |
|
44 namespace LegacyLoopbackMCprStates |
|
45 { |
|
46 DECLARE_DEFINE_ACTIVITY_MAP(stateMap) |
|
47 ACTIVITY_MAP_ENTRY(LegacyLoopbackMCPRNoBearerActivity, LegacyLoopbackMCPRNoBearer) |
|
48 ACTIVITY_MAP_END_BASE(AgentMCprActivities, agentMCprActivities) |
|
49 } // namespace LegacyLoopbackMCprStates |
|
50 |
|
51 |
|
52 #if defined __CFLOG_ACTIVE || defined SYMBIAN_TRACE_ENABLE |
|
53 _LIT8(KLegacyLoopbackMCprSubTag, "legacy_loopback"); |
|
54 #endif |
|
55 |
|
56 //-========================================================= |
|
57 // |
|
58 // CLegacyLoopbackMetaConnectionProvider implementation |
|
59 // |
|
60 //-========================================================= |
|
61 |
|
62 CLegacyLoopbackMetaConnectionProvider* CLegacyLoopbackMetaConnectionProvider::NewL(ESock::CMetaConnectionProviderFactoryBase& aFactory, const ESock::TProviderInfo& aProviderInfo) |
|
63 { |
|
64 CLegacyLoopbackMetaConnectionProvider* self = new (ELeave) CLegacyLoopbackMetaConnectionProvider(aFactory, aProviderInfo); |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop(self); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 CLegacyLoopbackMetaConnectionProvider::CLegacyLoopbackMetaConnectionProvider(CMetaConnectionProviderFactoryBase& aFactory, const ESock::TProviderInfo& aProviderInfo) |
|
73 : CAgentMetaConnectionProvider(aFactory, aProviderInfo, LegacyLoopbackMCprStates::stateMap::Self()) |
|
74 { |
|
75 LOG_NODE_CREATE(KLegacyLoopbackMCprSubTag, CLegacyLoopbackMetaConnectionProvider); |
|
76 } |
|
77 |
|
78 CLegacyLoopbackMetaConnectionProvider::~CLegacyLoopbackMetaConnectionProvider() |
|
79 { |
|
80 // Assumption is that CLegacyLoopbackProvision will be cleaned up by ~CAccessPointConfig |
|
81 |
|
82 // Clean up Agent Notification Handler |
|
83 SetAgentNotificationHandlerL(NULL); |
|
84 delete iAgentHandler; |
|
85 |
|
86 LOG_NODE_DESTROY(KLegacyLoopbackMCprSubTag, CLegacyLoopbackMetaConnectionProvider); |
|
87 } |
|
88 |
|
89 |
|
90 void CLegacyLoopbackMetaConnectionProvider::ConstructL() |
|
91 { |
|
92 CAgentMetaConnectionProvider::ConstructL(); |
|
93 SetAccessPointConfigFromDbL(); |
|
94 } |
|
95 |
|
96 |
|
97 void CLegacyLoopbackMetaConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage) |
|
98 { |
|
99 __CFLOG_VAR((KDummyProtoMCprTag, KLegacyLoopbackMCprSubTag, _L8("CLegacyLoopbackMetaConnectionProvider [this=%08x]::ReceivedL() aMessage=%d"), |
|
100 this, aMessage.MessageId())); |
|
101 |
|
102 ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient); |
|
103 |
|
104 TNodeContext<CLegacyLoopbackMetaConnectionProvider> ctx(*this, aMessage, aSender, aRecipient); |
|
105 CCoreMetaConnectionProvider::Received(ctx); |
|
106 User::LeaveIfError(ctx.iReturn); |
|
107 } |
|
108 |
|
109 void CLegacyLoopbackMetaConnectionProvider::SetAccessPointConfigFromDbL() |
|
110 { |
|
111 RMetaExtensionContainer mec; |
|
112 mec.Open(AccessPointConfig()); |
|
113 CleanupClosePushL(mec); |
|
114 |
|
115 // Add provisioning information. |
|
116 CCommsDatIapView* iapView = OpenIapViewLC(); |
|
117 CLegacyLoopbackProvision* provision = new (ELeave) CLegacyLoopbackProvision(); |
|
118 CleanupStack::PushL(provision); |
|
119 provision->InitialiseConfigL(iapView); |
|
120 |
|
121 // Presumptions: |
|
122 // - none of the extensions can already exist in the AccessPointConfig array. AppendExtensionL() |
|
123 // is presumed to panic if adding the same extension a second time. |
|
124 // - if we have added several extensions to the AccessPointConfig array before getting a failure |
|
125 // and leaving, it is presumed that the MCPr will be destroyed and AccessPointConfig destructor |
|
126 // will clean up the extensions immediately afterwards. |
|
127 |
|
128 mec.AppendExtensionL(provision); |
|
129 CleanupStack::Pop(provision); // ownership (including cleanup) transferred to AccessPointConfig() |
|
130 CleanupStack::PopAndDestroy(); // CloseIapView() |
|
131 |
|
132 AccessPointConfig().Close(); |
|
133 AccessPointConfig().Open(mec); |
|
134 CleanupStack::PopAndDestroy(&mec); |
|
135 |
|
136 ASSERT(iAgentHandler == NULL); |
|
137 // Register the agent notification handler |
|
138 iAgentHandler = new (ELeave) CLegacyLoopbackProtoAgentHandler(); |
|
139 SetAgentNotificationHandlerL(iAgentHandler); // ownership NOT transferred |
|
140 } |