1 // Copyright (c) 2005-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 // SHIMSCPR.CPP |
|
15 // This is part of an ECOM plug-in |
|
16 // |
|
17 // |
|
18 |
|
19 #include <ss_std.h> |
|
20 #include <comms-infras/ss_log.h> |
|
21 #include "shimnifmansconn.h" |
|
22 |
|
23 START_ATTRIBUTE_TABLE(TShimConnectionInfo, KShimCommsUid, Meta::KNetMetaTypeAny) |
|
24 END_ATTRIBUTE_TABLE() |
|
25 |
|
26 TInt CNifManSubConnectionShim::AsyncDestructorCb(TAny* aInstance) |
|
27 { |
|
28 CNifManSubConnectionShim* nifManSubConnection= reinterpret_cast<CNifManSubConnectionShim*>(aInstance); |
|
29 delete nifManSubConnection; |
|
30 return KErrNone; |
|
31 } |
|
32 |
|
33 /** |
|
34 Create a new CNifManSubConnectionShim to act as a mux/demux for subconnections |
|
35 */ |
|
36 CNifManSubConnectionShim::CNifManSubConnectionShim (CConnectionProviderShim& aProviderShim) |
|
37 :iSubConnectionsUniqueId(0), iConnectionProvider(&aProviderShim), |
|
38 iAsyncDestructor(CActive::EPriorityStandard + 1) |
|
39 { |
|
40 __CFLOG_VAR((KShimScprTag, KShimScprSubTag, _L8("CNifManSubConnectionShim [this=%08x]:\tCNifManSubConnectionShim() [MConnectionDataClient=%08x]"), |
|
41 this, (MConnectionDataClient*)this)); |
|
42 iAsyncDestructor.Set(TCallBack(AsyncDestructorCb, this)); |
|
43 } |
|
44 |
|
45 /** |
|
46 D'tor |
|
47 */ |
|
48 CNifManSubConnectionShim::~CNifManSubConnectionShim() |
|
49 { |
|
50 __CFLOG_VAR((KShimScprTag, KShimScprSubTag, _L8("CNifManSubConnectionShim::~CNifManSubConnectionShim() %08x"), this)); |
|
51 iShimClients.ResetAndDestroy(); |
|
52 delete iConnDataTransferShim; |
|
53 } |
|
54 |
|
55 |
|
56 void CNifManSubConnectionShim::DeleteAsync() |
|
57 { |
|
58 if ( !iAsyncDestructor.IsActive() ) |
|
59 { |
|
60 iAsyncDestructor.CallBack(); |
|
61 } |
|
62 } |
|
63 |
|
64 TInt CNifManSubConnectionShim::FindClient(const CConnection& aConnection) |
|
65 { |
|
66 TInt max = iShimClients.Count(); |
|
67 for (TInt i = max - 1 ; i >= 0 ; i--) |
|
68 { |
|
69 CSubConnectionLinkShimClient* client = iShimClients[i]; |
|
70 if ( client->Match(aConnection) ) |
|
71 { |
|
72 return i; |
|
73 } |
|
74 } |
|
75 return KErrNotFound; |
|
76 } |
|
77 |
|
78 void CNifManSubConnectionShim::ConnectionJoiningL(const CConnection& aConnection) |
|
79 {//create a new CSubConnectionLinkShimClient for the joining conection |
|
80 TInt i = FindClient(aConnection); |
|
81 if ( i == KErrNotFound ) |
|
82 { |
|
83 CSubConnectionLinkShimClient* client = new (ELeave)CSubConnectionLinkShimClient(aConnection,*this); |
|
84 CleanupStack::PushL(client); |
|
85 //create data transfer object if not created yet |
|
86 CreateDataTransferL(); |
|
87 iConnDataTransferShim->RegisterClientL(*client); |
|
88 TInt ret = iShimClients.Append(client); |
|
89 if (ret != KErrNone) |
|
90 { |
|
91 iConnDataTransferShim->DeRegisterClient(*client); |
|
92 User::Leave(ret); |
|
93 } |
|
94 CleanupStack::Pop(client); |
|
95 } |
|
96 } |
|
97 |
|
98 void CNifManSubConnectionShim::ConnectionLeaving(const CConnection& aConnection) |
|
99 {//destroy a CSubConnectionLinkShimClient belonging to leaving conection |
|
100 TInt i = FindClient(aConnection); |
|
101 if ( i >= 0 ) |
|
102 { |
|
103 CSubConnectionLinkShimClient* client = iShimClients[i]; |
|
104 iShimClients.Remove(i); |
|
105 delete client; |
|
106 } |
|
107 } |
|
108 |
|
109 void CNifManSubConnectionShim::ConnectionGoingDown(CConnectionProviderBase& /*aConnProvider*/) |
|
110 { |
|
111 __CFLOG_VAR((KShimScprTag, KShimScprSubTag, _L8("CNifManSubConnectionShim %08x:\tConnectionGoingDown() Id %d"), |
|
112 this, iSubConnectionsUniqueId)); |
|
113 |
|
114 // The ConnectionProvider has told us its going down so we delete ourselves, clearing |
|
115 // the pointer to it so our d'tor doesn't make any calls on it. |
|
116 iConnectionProvider = NULL; |
|
117 delete this; |
|
118 } |
|
119 |
|
120 void CNifManSubConnectionShim::ConnectionError(TInt /*aStage*/, TInt /*aError*/) |
|
121 { |
|
122 } |
|
123 |
|
124 void CNifManSubConnectionShim::Notify(TNotify /*aNotifyType*/, CConnectionProviderBase* /*aConnProvider*/, TInt /*aError*/, const CConNotificationEvent* /*aConNotificationEvent*/) |
|
125 { |
|
126 } |
|
127 |
|
128 void CNifManSubConnectionShim::AttachToNext(CSubConnectionProviderBase* /*aSubConnProvider*/) |
|
129 { |
|
130 } |
|
131 |
|
132 TInt CNifManSubConnectionShim::ProgressNotification(TInt aStage, TInt aError, const TDesC8& aInfo) |
|
133 /** |
|
134 Upcall from connection provider via CInterface with notification of new progress stage reached |
|
135 |
|
136 @param aStage The progress stage that the subconnection has reached |
|
137 @param aError Any errors that were encountered at this stage |
|
138 @param aInfo No idea what this is, it's inserted by CInterface and is currently null |
|
139 @return KErrNone, or one of the system-wide error codes |
|
140 */ |
|
141 { |
|
142 __CFLOG_VAR((KShimScprTag, KShimScprSubTag, _L8("CNifManSubConnectionShim %08x:\tProgressNotification(%d, %d) SubConnId: %d"), |
|
143 this, aStage, aError, iSubConnectionsUniqueId)); |
|
144 |
|
145 TInt max = iShimClients.Count(); |
|
146 for (TInt i = max - 1 ; i >= 0 ; i--) |
|
147 { |
|
148 iShimClients[i]->ProgressNotification(aStage, aError, aInfo); |
|
149 } |
|
150 |
|
151 return KErrNone; |
|
152 } |
|
153 |
|
154 |
|
155 TInt CNifManSubConnectionShim::NotifyDataTransferred(TUint aUplinkVolume, TUint aDownlinkVolume) |
|
156 { |
|
157 return iConnDataTransferShim ? iConnDataTransferShim->NotifyDataTransferred(aUplinkVolume, aDownlinkVolume) : KErrNone; |
|
158 |
|
159 } |
|
160 |
|
161 TInt CNifManSubConnectionShim::NotifyDataSent(TUint aUplinkVolume, TUint /*aCurrentGranularity*/) |
|
162 { |
|
163 return iConnDataTransferShim ? iConnDataTransferShim->NotifyDataSent(aUplinkVolume) : KErrNone; |
|
164 |
|
165 } |
|
166 |
|
167 TInt CNifManSubConnectionShim::NotifyDataReceived(TUint aDownlinkVolume, TUint /*aCurrentGranularity*/) |
|
168 { |
|
169 return iConnDataTransferShim ? iConnDataTransferShim->NotifyDataReceived(aDownlinkVolume) : KErrNone; |
|
170 |
|
171 } |
|
172 |
|
173 TSubConnectionUniqueId CNifManSubConnectionShim::Id() |
|
174 /** |
|
175 Access this subconnections unique id for search purposes |
|
176 */ |
|
177 { |
|
178 return iSubConnectionsUniqueId; |
|
179 } |
|
180 |
|
181 void CNifManSubConnectionShim::SetSubConnectionUniqueId( TSubConnectionUniqueId aSubConnectionUniqueId ) |
|
182 { |
|
183 iSubConnectionsUniqueId = aSubConnectionUniqueId; |
|
184 } |
|
185 |
|
186 //void CNifManSubConnectionShim::DataClientJoiningL(MSubConnectionDataClient& aDataClient) |
|
187 // { |
|
188 // aDataClient.JoinComplete(*this); |
|
189 // } |
|
190 |
|
191 //void CNifManSubConnectionShim::DataClientLeaving(MSubConnectionDataClient& aDataClient) |
|
192 // { |
|
193 // aDataClient.LeaveComplete(*this); |
|
194 // } |
|
195 |
|
196 //void CNifManSubConnectionShim::DoSourceAddressUpdate(MSubConnectionDataClient& /*aDataClient*/, const TSockAddr& /*aSource*/) |
|
197 // {//do nothing |
|
198 // } |
|
199 |
|
200 //void CNifManSubConnectionShim::DoDestinationAddressUpdate(MSubConnectionDataClient& /*aDataClient*/, const TSockAddr& /*aDestination*/) |
|
201 // {//do nothing |
|
202 // } |
|
203 |
|
204 //void CNifManSubConnectionShim::DoDataClientRouted(MSubConnectionDataClient& /*aDataClient*/, const TSockAddr& /*aSource*/, const TSockAddr& /*aDestination*/, const TDesC8& /*aConnectionInfo*/) |
|
205 // {//do nothing |
|
206 // } |
|
207 |
|
208 //void CNifManSubConnectionShim::DoParametersAboutToBeSetL(CSubConParameterBundle& /*aParameterBundle*/) |
|
209 // {//do nothing |
|
210 // } |
|
211 |
|
212 //TInt CNifManSubConnectionShim::DoControl(TUint /*aOptionLevel*/, TUint /*aOptionName*/, TDes8& /*aOption*/) |
|
213 // {//do nothing |
|
214 // return KErrNotSupported; |
|
215 // } |
|
216 |
|
217 //void CNifManSubConnectionShim::DoStartL() |
|
218 // { |
|
219 // User::Leave(KErrNotSupported); |
|
220 // } |
|
221 |
|
222 //void CNifManSubConnectionShim::DoStop() |
|
223 // { |
|
224 // } |
|
225 |
|
226 //CSubConnectionProviderBase* CNifManSubConnectionShim::DoNextLayer() |
|
227 // { |
|
228 // return NULL; |
|
229 // } |
|
230 |
|
231 CConnDataTransfer& CNifManSubConnectionShim::CreateDataTransferL() |
|
232 { |
|
233 if (!iConnDataTransferShim) |
|
234 { |
|
235 iConnDataTransferShim = new (ELeave)CConnDataTransferShim(*this); |
|
236 } |
|
237 return *iConnDataTransferShim; |
|
238 } |
|
239 |
|
240 //MConnectionDataClient* CNifManSubConnectionShim::DoSelfConnectionDataClient() |
|
241 // { |
|
242 // return this; |
|
243 // } |
|
244 |
|