29
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-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: Utility class for other CDunTransporter classes
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <e32property.h>
|
|
21 |
#include "dundomainpskeys.h"
|
|
22 |
#include "DunTransUtils.h"
|
|
23 |
#include "DunDataWaiter.h"
|
|
24 |
#include "DunUpstream.h"
|
|
25 |
#include "DunDownstream.h"
|
|
26 |
#include "DunSignalCopy.h"
|
|
27 |
#include "DunSignalNotify.h"
|
|
28 |
#include "DunNoteHandler.h"
|
|
29 |
#include "DunUtils.h"
|
|
30 |
#include "DunDebug.h"
|
|
31 |
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
// Two-phased constructor.
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CDunTransUtils* CDunTransUtils::NewL( CDunTransporter& aParent,
|
|
37 |
MDunPluginManager* aPluginManager )
|
|
38 |
{
|
|
39 |
CDunTransUtils* self = new (ELeave) CDunTransUtils( aParent,
|
|
40 |
aPluginManager );
|
|
41 |
CleanupStack::PushL( self );
|
|
42 |
self->ConstructL();
|
|
43 |
CleanupStack::Pop( self );
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// Destructor.
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CDunTransUtils::~CDunTransUtils()
|
|
52 |
{
|
|
53 |
FTRACE(FPrint( _L("CDunTransUtils::~CDunTransUtils()" )));
|
|
54 |
FTRACE(FPrint( _L("CDunTransUtils::~CDunTransUtils() complete" )));
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// CDunTransUtils::CDunTransUtils
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CDunTransUtils::CDunTransUtils( CDunTransporter& aParent,
|
|
62 |
MDunPluginManager* aPluginManager ) :
|
|
63 |
iParent( aParent ),
|
|
64 |
iChannelData( aParent.iChannelData ),
|
|
65 |
iServAdvData( aParent.iServAdvData ),
|
|
66 |
iPluginManager( aPluginManager )
|
|
67 |
{
|
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
// CDunTransUtils::ConstructL
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
void CDunTransUtils::ConstructL()
|
|
75 |
{
|
|
76 |
FTRACE(FPrint( _L("CDunTransUtils::ConstructL()" )));
|
|
77 |
if ( !iPluginManager )
|
|
78 |
{
|
|
79 |
User::Leave( KErrGeneral );
|
|
80 |
}
|
|
81 |
FTRACE(FPrint( _L("CDunTransUtils::ConstructL() complete" )));
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
// Manages service advertisement status changes
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CDunTransUtils::ManageAdvertisementStatusChange( TBool aAdvertise,
|
|
89 |
TBool aCreation )
|
|
90 |
{
|
|
91 |
FTRACE(FPrint( _L("CDunTransUtils::ManageAdvertisementStatusChange()" )));
|
|
92 |
TInt i;
|
|
93 |
TInt count;
|
|
94 |
iParent.iAdvertise = aAdvertise;
|
|
95 |
count = iServAdvData.Count();
|
|
96 |
for ( i=0; i<count; i++ )
|
|
97 |
{
|
|
98 |
TDunServAdvData& servAdvData = iServAdvData[i];
|
|
99 |
if ( servAdvData.iServAdvMon )
|
|
100 |
{
|
|
101 |
if ( aAdvertise )
|
|
102 |
{
|
|
103 |
servAdvData.iServAdvMon->NotifyAdvertisementStart( aCreation );
|
|
104 |
}
|
|
105 |
else
|
|
106 |
{
|
|
107 |
servAdvData.iServAdvMon->NotifyAdvertisementEnd();
|
|
108 |
}
|
|
109 |
}
|
|
110 |
}
|
|
111 |
FTRACE(FPrint( _L("CDunTransUtils::ManageAdvertisementStatusChange() complete" )));
|
|
112 |
}
|
|
113 |
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
// Creates empty channel data
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
void CDunTransUtils::CreateEmptyChannelData( TDunChannelData& aChannel )
|
|
119 |
{
|
|
120 |
FTRACE(FPrint( _L("CDunTransUtils::CreateEmptyChannelData()" )));
|
|
121 |
aChannel.iNetwork = NULL;
|
|
122 |
aChannel.iComm = NULL;
|
|
123 |
aChannel.iSocket = NULL;
|
|
124 |
aChannel.iChannelName = NULL;
|
|
125 |
aChannel.iUpstreamRW = NULL;
|
|
126 |
aChannel.iDownstreamRW = NULL;
|
|
127 |
aChannel.iBufferUpstream = NULL;
|
|
128 |
aChannel.iBufferDownstream = NULL;
|
|
129 |
aChannel.iBufferUpPtr = NULL;
|
|
130 |
aChannel.iBufferDownPtr = NULL;
|
|
131 |
aChannel.iUpstreamSignalCopy = NULL;
|
|
132 |
aChannel.iDownstreamSignalCopy = NULL;
|
|
133 |
aChannel.iSignalNotify = NULL;
|
|
134 |
aChannel.iOwnerUid = TUid::Null();
|
|
135 |
aChannel.iChannelInUse = EFalse;
|
|
136 |
FTRACE(FPrint( _L("CDunTransUtils::CreateEmptyChannelData() complete" )));
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// Creates new buffer if source buffer defined, otherwise already existing
|
|
141 |
// buffer will be used
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CDunTransUtils::DoCreateBufferLC( TUint8* aSrcBuffer,
|
|
145 |
TPtr8* aSrcPtr,
|
|
146 |
TUint8*& aDstBuffer,
|
|
147 |
TPtr8*& aDstPtr,
|
|
148 |
TInt aBufferLength,
|
|
149 |
TInt& aItemsInCs )
|
|
150 |
{
|
|
151 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC()" )));
|
|
152 |
TUint8* buffer;
|
|
153 |
if ( !aSrcBuffer )
|
|
154 |
{
|
|
155 |
buffer = new (ELeave) TUint8[aBufferLength];
|
|
156 |
CleanupStack::PushL( buffer );
|
|
157 |
aItemsInCs++;
|
|
158 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() new created" )));
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
buffer = aSrcBuffer;
|
|
163 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() existing set" )));
|
|
164 |
}
|
|
165 |
TPtr8* bufferPtr;
|
|
166 |
if ( !aSrcPtr )
|
|
167 |
{
|
|
168 |
bufferPtr = new (ELeave) TPtr8( buffer, aBufferLength, aBufferLength );
|
|
169 |
CleanupStack::PushL( bufferPtr );
|
|
170 |
aItemsInCs++;
|
|
171 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() new created" )));
|
|
172 |
}
|
|
173 |
else
|
|
174 |
{
|
|
175 |
bufferPtr = aSrcPtr;
|
|
176 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() existing set" )));
|
|
177 |
}
|
|
178 |
aDstBuffer = buffer;
|
|
179 |
aDstPtr = bufferPtr;
|
|
180 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateBufferLC() complete" )));
|
|
181 |
}
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// Creates new signal copy object if source defined, otherwise already
|
|
185 |
// existing will be used
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void CDunTransUtils::DoCreateSignalCopyLC( CDunSignalCopy* aSrcSignalCopy,
|
|
189 |
CDunSignalCopy*& aDstSignalCopy,
|
|
190 |
TInt& aItemsInCs )
|
|
191 |
{
|
|
192 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC()" )));
|
|
193 |
CDunSignalCopy* signalCopy;
|
|
194 |
if ( !aSrcSignalCopy )
|
|
195 |
{
|
|
196 |
signalCopy = CDunSignalCopy::NewL();
|
|
197 |
CleanupStack::PushL( signalCopy );
|
|
198 |
aItemsInCs++;
|
|
199 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC() new created" )));
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
signalCopy = aSrcSignalCopy;
|
|
204 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC() existing set" )));
|
|
205 |
}
|
|
206 |
aDstSignalCopy = signalCopy;
|
|
207 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalCopyLC() complete" )));
|
|
208 |
}
|
|
209 |
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
// Creates new signal notify object if source defined, otherwise already
|
|
212 |
// existing will be used
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
void CDunTransUtils::DoCreateSignalNotifyLC(
|
|
216 |
CDunSignalNotify* aSrcSignalNotify,
|
|
217 |
CDunSignalNotify*& aDstSignalNotify,
|
|
218 |
TInt& aItemsInCs )
|
|
219 |
{
|
|
220 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC()" )));
|
|
221 |
CDunSignalNotify* signalNotify;
|
|
222 |
if ( !aSrcSignalNotify )
|
|
223 |
{
|
|
224 |
signalNotify = CDunSignalNotify::NewL( this );
|
|
225 |
CleanupStack::PushL( signalNotify );
|
|
226 |
aItemsInCs++;
|
|
227 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC() new created" )));
|
|
228 |
}
|
|
229 |
else
|
|
230 |
{
|
|
231 |
signalNotify = aSrcSignalNotify;
|
|
232 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC() existing set" )));
|
|
233 |
}
|
|
234 |
aDstSignalNotify = signalNotify;
|
|
235 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateSignalNotifyLC() complete" )));
|
|
236 |
}
|
|
237 |
|
|
238 |
// ---------------------------------------------------------------------------
|
|
239 |
// Creates transfer objects for reader and writer if sources defined,
|
|
240 |
// otherwise already existing ones will be used
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
void CDunTransUtils::DoCreateUpTransferObjectL( CDunUpstream* aSrcReader,
|
|
244 |
CDunUpstream*& aDstReader,
|
|
245 |
TInt& aItemsInCs )
|
|
246 |
{
|
|
247 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL()" )));
|
|
248 |
CDunUpstream* dunReader;
|
|
249 |
if ( !aSrcReader )
|
|
250 |
{
|
|
251 |
dunReader = CDunUpstream::NewL( this );
|
|
252 |
CleanupStack::PushL( dunReader );
|
|
253 |
aItemsInCs++;
|
|
254 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL() new created" )));
|
|
255 |
}
|
|
256 |
else
|
|
257 |
{
|
|
258 |
dunReader = aSrcReader;
|
|
259 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL() existing set" )));
|
|
260 |
}
|
|
261 |
aDstReader = dunReader;
|
|
262 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateUpTransferObjectL() complete" )));
|
|
263 |
}
|
|
264 |
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
// Creates transfer objects for reader and writer if sources defined,
|
|
267 |
// otherwise already existing ones will be used
|
|
268 |
// ---------------------------------------------------------------------------
|
|
269 |
//
|
|
270 |
void CDunTransUtils::DoCreateDownTransferObjectL( CDunDownstream* aSrcReader,
|
|
271 |
CDunDownstream*& aDstReader,
|
|
272 |
TInt& aItemsInCs )
|
|
273 |
{
|
|
274 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL()" )));
|
|
275 |
CDunDownstream* dunReader;
|
|
276 |
if ( !aSrcReader )
|
|
277 |
{
|
|
278 |
dunReader = CDunDownstream::NewL( this );
|
|
279 |
CleanupStack::PushL( dunReader );
|
|
280 |
aItemsInCs++;
|
|
281 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL() new created" )));
|
|
282 |
}
|
|
283 |
else
|
|
284 |
{
|
|
285 |
dunReader = aSrcReader;
|
|
286 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL() existing set" )));
|
|
287 |
}
|
|
288 |
aDstReader = dunReader;
|
|
289 |
FTRACE(FPrint( _L("CDunTransUtils::DoCreateDownTransferObjectL() complete" )));
|
|
290 |
}
|
|
291 |
|
|
292 |
// ---------------------------------------------------------------------------
|
|
293 |
// Resets/frees network data of aIndex:th channel
|
|
294 |
// ---------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
TInt CDunTransUtils::DeleteOneNetworkData( TInt aIndex )
|
|
297 |
{
|
|
298 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData()" )));
|
|
299 |
|
|
300 |
if ( aIndex < 0 ||
|
|
301 |
aIndex >= iChannelData.Count() )
|
|
302 |
{
|
|
303 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData (not found) complete" )));
|
|
304 |
return KErrNotFound;
|
|
305 |
}
|
|
306 |
|
|
307 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
308 |
if ( !channelData.iChannelInUse )
|
|
309 |
{
|
|
310 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData() (channel not found) complete" ), aIndex));
|
|
311 |
return KErrGeneral;
|
|
312 |
}
|
|
313 |
|
|
314 |
// channelData.iDownstreamSignalCopy may or may not exist (optional)
|
|
315 |
// channelData.iSignalNotify may or may not exist (optional)
|
|
316 |
delete channelData.iDownstreamSignalCopy;
|
|
317 |
channelData.iDownstreamSignalCopy = NULL;
|
|
318 |
delete channelData.iSignalNotify;
|
|
319 |
channelData.iSignalNotify = NULL;
|
|
320 |
delete channelData.iDownstreamRW;
|
|
321 |
channelData.iDownstreamRW = NULL;
|
|
322 |
|
|
323 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneNetworkData complete()" )));
|
|
324 |
return KErrNone;
|
|
325 |
}
|
|
326 |
|
|
327 |
// ---------------------------------------------------------------------------
|
|
328 |
// Resets/frees network data of aIndex:th channel
|
|
329 |
// ---------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
TInt CDunTransUtils::DeleteOneLocalData( TInt aIndex )
|
|
332 |
{
|
|
333 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData()" )));
|
|
334 |
|
|
335 |
if ( aIndex < 0 ||
|
|
336 |
aIndex >= iChannelData.Count() )
|
|
337 |
{
|
|
338 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData() (not found) complete" )));
|
|
339 |
return KErrNotFound;
|
|
340 |
}
|
|
341 |
|
|
342 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
343 |
if ( !channelData.iChannelInUse )
|
|
344 |
{
|
|
345 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData() (channel not found) complete" ), aIndex));
|
|
346 |
return KErrGeneral;
|
|
347 |
}
|
|
348 |
|
|
349 |
// channelData.iUpstreamSignalCopy may or may not exist (optional)
|
|
350 |
delete channelData.iUpstreamSignalCopy;
|
|
351 |
channelData.iUpstreamSignalCopy = NULL;
|
|
352 |
delete channelData.iUpstreamRW;
|
|
353 |
channelData.iUpstreamRW = NULL;
|
|
354 |
|
|
355 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteOneLocalData() complete" )));
|
|
356 |
return KErrNone;
|
|
357 |
}
|
|
358 |
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
// Deletes buffering objects of aIndex:th channel
|
|
361 |
// ---------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
TInt CDunTransUtils::DeleteBuffering( TInt aIndex )
|
|
364 |
{
|
|
365 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering()" )));
|
|
366 |
|
|
367 |
if ( aIndex < 0 ||
|
|
368 |
aIndex >= iChannelData.Count() )
|
|
369 |
{
|
|
370 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering() (not found) complete" )));
|
|
371 |
return KErrNotFound;
|
|
372 |
}
|
|
373 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
374 |
if ( !channelData.iChannelInUse )
|
|
375 |
{
|
|
376 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering() (channel not found) complete" ), aIndex));
|
|
377 |
return KErrGeneral;
|
|
378 |
}
|
|
379 |
|
|
380 |
delete channelData.iChannelName;
|
|
381 |
channelData.iChannelName = NULL;
|
|
382 |
delete channelData.iBufferUpstream;
|
|
383 |
channelData.iBufferUpstream = NULL;
|
|
384 |
delete channelData.iBufferDownstream;
|
|
385 |
channelData.iBufferDownstream = NULL;
|
|
386 |
delete channelData.iBufferUpPtr;
|
|
387 |
channelData.iBufferUpPtr = NULL;
|
|
388 |
delete channelData.iBufferDownPtr;
|
|
389 |
channelData.iBufferDownPtr = NULL;
|
|
390 |
|
|
391 |
FTRACE(FPrint( _L("CDunTransUtils::DeleteBuffering() complete" )));
|
|
392 |
return KErrNone;
|
|
393 |
}
|
|
394 |
|
|
395 |
// ---------------------------------------------------------------------------
|
|
396 |
// Initializes first free channel
|
|
397 |
// ---------------------------------------------------------------------------
|
|
398 |
//
|
|
399 |
TInt CDunTransUtils::InitializeFirstFreeChannel( TConnId aLocalIdNew )
|
|
400 |
{
|
|
401 |
FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel()" )));
|
|
402 |
TInt i;
|
|
403 |
TInt count;
|
|
404 |
TInt retTemp;
|
|
405 |
TInt firstFree = KErrNotFound;
|
|
406 |
count = iChannelData.Count();
|
|
407 |
for ( i=0; i<count; i++ )
|
|
408 |
{
|
|
409 |
TDunChannelData& channelData = iChannelData[i];
|
|
410 |
if ( channelData.iComm==aLocalIdNew ||
|
|
411 |
channelData.iSocket==aLocalIdNew )
|
|
412 |
{
|
|
413 |
FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() (already exists) complete" )));
|
|
414 |
return KErrAlreadyExists;
|
|
415 |
}
|
|
416 |
if ( !channelData.iChannelInUse && firstFree==KErrNotFound )
|
|
417 |
{
|
|
418 |
firstFree = i;
|
|
419 |
// no "break" here since KErrAlreadyExists needs to be checked
|
|
420 |
}
|
|
421 |
}
|
|
422 |
if ( firstFree >= 0 )
|
|
423 |
{
|
|
424 |
FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() complete" )));
|
|
425 |
return i;
|
|
426 |
}
|
|
427 |
// Free channel not found, now create new if possible
|
|
428 |
TDunChannelData emptyChannel;
|
|
429 |
CreateEmptyChannelData( emptyChannel );
|
|
430 |
retTemp = iChannelData.Append( emptyChannel );
|
|
431 |
if ( retTemp != KErrNone )
|
|
432 |
{
|
|
433 |
FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() (append failed!) complete" )));
|
|
434 |
return retTemp;
|
|
435 |
}
|
|
436 |
FTRACE(FPrint( _L("CDunTransUtils::InitializeFirstFreeChannel() complete" )));
|
|
437 |
return i;
|
|
438 |
}
|
|
439 |
|
|
440 |
// ---------------------------------------------------------------------------
|
|
441 |
// From class MDunTransporterUtility.
|
|
442 |
// Allocates a channel by creating and setting local media independent
|
|
443 |
// objects
|
|
444 |
// This is a common method used by exported local media dependent methods
|
|
445 |
// ---------------------------------------------------------------------------
|
|
446 |
//
|
|
447 |
void CDunTransUtils::DoAllocateChannelL( RComm* aComm,
|
|
448 |
TInt& aBufferLength,
|
|
449 |
TInt aFirstFree,
|
|
450 |
MDunBufferCorrection* aCorrection )
|
|
451 |
{
|
|
452 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL()" )));
|
|
453 |
TInt retTemp;
|
|
454 |
TInt itemsInCs = 0;
|
|
455 |
|
|
456 |
if ( !iParent.iNetwork )
|
|
457 |
{
|
|
458 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() (iNetwork) not initialized!" )));
|
|
459 |
User::Leave( KErrGeneral );
|
|
460 |
}
|
|
461 |
|
|
462 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() aFirstFree = %d" ), aFirstFree));
|
|
463 |
|
|
464 |
// Allocate network channel
|
|
465 |
RComm* networkEntity;
|
|
466 |
retTemp = iParent.iNetwork->AllocateChannel( networkEntity );
|
|
467 |
if ( retTemp != KErrNone )
|
|
468 |
{
|
|
469 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() network allocation failed" )));
|
|
470 |
if ( retTemp == KErrTooBig )
|
|
471 |
{
|
|
472 |
// Start to show note
|
|
473 |
if ( iParent.iNoteHandler )
|
|
474 |
{
|
|
475 |
iParent.iNoteHandler->IssueRequest();
|
|
476 |
}
|
|
477 |
// Set flag to indicate that advertisement is not possible anymore
|
|
478 |
ManageAdvertisementStatusChange( EFalse );
|
|
479 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() (too big) complete" )));
|
|
480 |
User::Leave( KErrTooBig );
|
|
481 |
}
|
|
482 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() (ERROR) complete" )));
|
|
483 |
User::Leave( KErrGeneral );
|
|
484 |
}
|
|
485 |
|
|
486 |
TInt currentLength = networkEntity->ReceiveBufferLength();
|
|
487 |
TInt newLength = currentLength;
|
|
488 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() buffer length before = %d" ), currentLength));
|
|
489 |
if ( aCorrection )
|
|
490 |
{
|
|
491 |
// Get network side buffer length and request change if required.
|
|
492 |
// Check "newlength>currentLength" here as it is not possible to
|
|
493 |
// increase Dataport's buffer length
|
|
494 |
newLength = aCorrection->NotifyBufferCorrection( currentLength );
|
|
495 |
if ( newLength<=0 || newLength>currentLength )
|
|
496 |
{
|
|
497 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() unknown buffer length" )));
|
|
498 |
User::Leave( KErrGeneral );
|
|
499 |
}
|
|
500 |
// It is not possible to set Dataport side receive buffer length to any
|
|
501 |
// arbitrary value (currently only 8kB..20kB are supported but that
|
|
502 |
// can't be queried via an API). So here only default buffer size will
|
|
503 |
// be used from Dataport while this component's local buffering uses
|
|
504 |
// Dataport's default buffer size if not adjusted via plugin side.
|
|
505 |
// NOTE: If Dataport side starts to support arbitrary receive buffer
|
|
506 |
// size, it should be changed here if newLength != currentLength.
|
|
507 |
}
|
|
508 |
aBufferLength = newLength;
|
|
509 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() buffer length after = %d" ), newLength));
|
|
510 |
|
|
511 |
// Get channel data
|
|
512 |
|
|
513 |
TDunChannelData& channelData = iChannelData[aFirstFree];
|
|
514 |
|
|
515 |
// Create buffers and set length
|
|
516 |
|
|
517 |
TUint8* bufferUpstream;
|
|
518 |
TPtr8* bufferUpPtr;
|
|
519 |
DoCreateBufferLC( channelData.iBufferUpstream,
|
|
520 |
channelData.iBufferUpPtr,
|
|
521 |
bufferUpstream,
|
|
522 |
bufferUpPtr,
|
|
523 |
newLength,
|
|
524 |
itemsInCs );
|
|
525 |
|
|
526 |
TUint8* bufferDownstream;
|
|
527 |
TPtr8* bufferDownPtr;
|
|
528 |
DoCreateBufferLC( channelData.iBufferDownstream,
|
|
529 |
channelData.iBufferDownPtr,
|
|
530 |
bufferDownstream,
|
|
531 |
bufferDownPtr,
|
|
532 |
newLength,
|
|
533 |
itemsInCs );
|
|
534 |
|
|
535 |
// Create signal copy objects
|
|
536 |
|
|
537 |
CDunSignalCopy* upstreamCopy = channelData.iUpstreamSignalCopy;
|
|
538 |
CDunSignalCopy* downstreamCopy = channelData.iDownstreamSignalCopy;
|
|
539 |
if ( aComm )
|
|
540 |
{
|
|
541 |
DoCreateSignalCopyLC( channelData.iUpstreamSignalCopy,
|
|
542 |
upstreamCopy,
|
|
543 |
itemsInCs );
|
|
544 |
DoCreateSignalCopyLC( channelData.iDownstreamSignalCopy,
|
|
545 |
downstreamCopy,
|
|
546 |
itemsInCs );
|
|
547 |
retTemp = upstreamCopy->SetMedia( aComm,
|
|
548 |
networkEntity,
|
|
549 |
EDunStreamTypeUpstream );
|
|
550 |
if ( retTemp != KErrNone )
|
|
551 |
{
|
|
552 |
delete upstreamCopy;
|
|
553 |
upstreamCopy = NULL;
|
|
554 |
}
|
|
555 |
retTemp = downstreamCopy->SetMedia( aComm,
|
|
556 |
networkEntity,
|
|
557 |
EDunStreamTypeDownstream );
|
|
558 |
if ( retTemp != KErrNone )
|
|
559 |
{
|
|
560 |
delete downstreamCopy;
|
|
561 |
downstreamCopy = NULL;
|
|
562 |
}
|
|
563 |
}
|
|
564 |
|
|
565 |
// Create signal notify objects
|
|
566 |
|
|
567 |
CDunSignalNotify* signalNotify = channelData.iSignalNotify;
|
|
568 |
if ( !aComm ) // RSocket
|
|
569 |
{
|
|
570 |
DoCreateSignalNotifyLC( channelData.iSignalNotify,
|
|
571 |
signalNotify,
|
|
572 |
itemsInCs );
|
|
573 |
retTemp = signalNotify->SetMedia( networkEntity );
|
|
574 |
if ( retTemp != KErrNone )
|
|
575 |
{
|
|
576 |
delete signalNotify;
|
|
577 |
signalNotify = NULL;
|
|
578 |
}
|
|
579 |
}
|
|
580 |
|
|
581 |
// Create upstream objects
|
|
582 |
|
|
583 |
CDunUpstream* upstreamRW;
|
|
584 |
DoCreateUpTransferObjectL( channelData.iUpstreamRW,
|
|
585 |
upstreamRW,
|
|
586 |
itemsInCs );
|
|
587 |
upstreamRW->SetBuffering( bufferUpPtr );
|
|
588 |
upstreamRW->SetMedia( networkEntity, EDunMediaContextNetwork );
|
|
589 |
upstreamRW->SetActivityCallback( this );
|
|
590 |
|
|
591 |
// Create downstream objects
|
|
592 |
|
|
593 |
CDunDownstream* downstreamRW;
|
|
594 |
DoCreateDownTransferObjectL( channelData.iDownstreamRW,
|
|
595 |
downstreamRW,
|
|
596 |
itemsInCs );
|
|
597 |
downstreamRW->SetBuffering( bufferDownPtr );
|
|
598 |
downstreamRW->SetMedia( networkEntity, EDunMediaContextNetwork );
|
|
599 |
|
|
600 |
// Save values
|
|
601 |
|
|
602 |
channelData.iNetwork = networkEntity;
|
|
603 |
channelData.iUpstreamRW = upstreamRW;
|
|
604 |
channelData.iDownstreamRW = downstreamRW;
|
|
605 |
channelData.iBufferUpstream = bufferUpstream;
|
|
606 |
channelData.iBufferDownstream = bufferDownstream;
|
|
607 |
channelData.iBufferUpPtr = bufferUpPtr;
|
|
608 |
channelData.iBufferDownPtr = bufferDownPtr;
|
|
609 |
channelData.iUpstreamSignalCopy = upstreamCopy;
|
|
610 |
channelData.iDownstreamSignalCopy = downstreamCopy;
|
|
611 |
channelData.iSignalNotify = signalNotify;
|
|
612 |
|
|
613 |
CleanupStack::Pop( itemsInCs );
|
|
614 |
|
|
615 |
// Set flag to indicate that advertisement is now possible
|
|
616 |
ManageAdvertisementStatusChange( ETrue, ETrue );
|
|
617 |
|
|
618 |
FTRACE(FPrint( _L("CDunTransUtils::DoAllocateChannelL() complete" )));
|
|
619 |
}
|
|
620 |
|
|
621 |
// ---------------------------------------------------------------------------
|
|
622 |
// From class MDunTransporterUtility.
|
|
623 |
// Adds connection monitor callback for either local media or network side
|
|
624 |
// by connection ID
|
|
625 |
// Connection monitor will be added to aIndex:th endpoint
|
|
626 |
// ---------------------------------------------------------------------------
|
|
627 |
//
|
|
628 |
TInt CDunTransUtils::DoAddConnMonCallback( TInt aIndex,
|
|
629 |
MDunConnMon* aCallback,
|
|
630 |
TDunDirection aDirection,
|
|
631 |
TBool aSignal )
|
|
632 |
{
|
|
633 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback()" )));
|
|
634 |
|
|
635 |
if ( !iParent.iNetwork )
|
|
636 |
{
|
|
637 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (iNetwork) not initialized!" )));
|
|
638 |
return KErrGeneral;
|
|
639 |
}
|
|
640 |
|
|
641 |
if ( aIndex < 0 ||
|
|
642 |
aIndex >= iChannelData.Count() )
|
|
643 |
{
|
|
644 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (not found) complete" )));
|
|
645 |
return KErrNotFound;
|
|
646 |
}
|
|
647 |
|
|
648 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
649 |
|
|
650 |
// Get upstream and downstream
|
|
651 |
CDunUpstream* upstream = channelData.iUpstreamRW;
|
|
652 |
CDunDownstream* downstream = channelData.iDownstreamRW;
|
|
653 |
|
|
654 |
if ( aDirection == EDunReaderUpstream )
|
|
655 |
{
|
|
656 |
// Initialize stream for AT parsing (ignore errors)
|
|
657 |
upstream->InitializeForAtParsing( downstream,
|
|
658 |
channelData.iChannelName,
|
|
659 |
upstream,
|
|
660 |
downstream );
|
|
661 |
downstream->InitializeForDataPushing( upstream );
|
|
662 |
}
|
|
663 |
|
|
664 |
// Get stream type and operation type
|
|
665 |
|
|
666 |
TDunStreamType streamType =
|
|
667 |
static_cast<TDunStreamType>( aDirection & KDunStreamTypeMask );
|
|
668 |
TDunOperationType operationType =
|
|
669 |
static_cast<TDunOperationType>( aDirection & KDunOperationTypeMask );
|
|
670 |
|
|
671 |
if ( streamType == EDunStreamTypeUpstream )
|
|
672 |
{
|
|
673 |
// If signal copy object(s) exist then add RunL error monitoring for them
|
|
674 |
if ( channelData.iUpstreamSignalCopy ) // optional
|
|
675 |
{
|
|
676 |
// Add callback (ignore errors)
|
|
677 |
channelData.iUpstreamSignalCopy->AddCallback( aCallback );
|
|
678 |
}
|
|
679 |
}
|
|
680 |
else if ( streamType == EDunStreamTypeDownstream )
|
|
681 |
{
|
|
682 |
// If signal copy object(s) exist then add RunL error monitoring for them
|
|
683 |
if ( channelData.iDownstreamSignalCopy ) // optional
|
|
684 |
{
|
|
685 |
// Add callback (ignore errors)
|
|
686 |
channelData.iDownstreamSignalCopy->AddCallback( aCallback );
|
|
687 |
}
|
|
688 |
}
|
|
689 |
else
|
|
690 |
{
|
|
691 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (stream) not initialized!" ) ));
|
|
692 |
return KErrGeneral;
|
|
693 |
}
|
|
694 |
|
|
695 |
// Set signal notify callback
|
|
696 |
|
|
697 |
if ( aSignal && aDirection==EDunReaderDownstream )
|
|
698 |
{
|
|
699 |
if ( !channelData.iSignalNotify )
|
|
700 |
{
|
|
701 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() (iSignalNotify) not initialized" )));
|
|
702 |
return KErrGeneral;
|
|
703 |
}
|
|
704 |
// Add callback (ignore errors)
|
|
705 |
channelData.iSignalNotify->AddCallback( aCallback );
|
|
706 |
}
|
|
707 |
|
|
708 |
// Add callback (ignore errors)
|
|
709 |
if ( streamType == EDunStreamTypeUpstream )
|
|
710 |
{
|
|
711 |
upstream->AddConnMonCallback( aCallback, operationType );
|
|
712 |
}
|
|
713 |
else // streamType == EDunStreamTypeDownstream
|
|
714 |
{
|
|
715 |
downstream->AddConnMonCallback( aCallback, operationType );
|
|
716 |
}
|
|
717 |
|
|
718 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddConnMonCallback() complete" )));
|
|
719 |
return KErrNone;
|
|
720 |
}
|
|
721 |
|
|
722 |
// ---------------------------------------------------------------------------
|
|
723 |
// From class MDunTransporterUtility.
|
|
724 |
// Adds error to consider as no error condition when doing any of the four
|
|
725 |
// endpoint's read/writer operation
|
|
726 |
// Error will be added to aIndex:th endpoint
|
|
727 |
// ---------------------------------------------------------------------------
|
|
728 |
//
|
|
729 |
TInt CDunTransUtils::DoAddSkippedError( TInt aIndex,
|
|
730 |
TInt aError,
|
|
731 |
TDunDirection aDirection )
|
|
732 |
{
|
|
733 |
FTRACE(FPrint( _L("CDunTransUtils::AddOneSkippedError" ) ));
|
|
734 |
if ( aIndex < 0 ||
|
|
735 |
aIndex >= iChannelData.Count() )
|
|
736 |
{
|
|
737 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (not found) complete" )));
|
|
738 |
return KErrNotFound;
|
|
739 |
}
|
|
740 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
741 |
if ( !channelData.iChannelInUse )
|
|
742 |
{
|
|
743 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (channel not found) complete" ), aIndex));
|
|
744 |
return KErrGeneral;
|
|
745 |
}
|
|
746 |
|
|
747 |
if ( aDirection != EDunReaderUpstream &&
|
|
748 |
aDirection != EDunWriterUpstream &&
|
|
749 |
aDirection != EDunReaderDownstream &&
|
|
750 |
aDirection != EDunWriterDownstream )
|
|
751 |
{
|
|
752 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (ERROR) added" ) ));
|
|
753 |
return KErrNotSupported;
|
|
754 |
}
|
|
755 |
|
|
756 |
TDunStreamType streamType =
|
|
757 |
static_cast<TDunStreamType>( aDirection & KDunStreamTypeMask );
|
|
758 |
TDunOperationType operationType =
|
|
759 |
static_cast<TDunOperationType>( aDirection & KDunOperationTypeMask );
|
|
760 |
|
|
761 |
if ( streamType != EDunStreamTypeUpstream &&
|
|
762 |
streamType != EDunStreamTypeDownstream )
|
|
763 |
{
|
|
764 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (stream) not initialized!" ) ));
|
|
765 |
return KErrGeneral;
|
|
766 |
}
|
|
767 |
|
|
768 |
// Add skipped error (ignore errors)
|
|
769 |
|
|
770 |
if ( streamType == EDunStreamTypeUpstream )
|
|
771 |
{
|
|
772 |
channelData.iUpstreamRW->AddSkippedError( aError, operationType );
|
|
773 |
}
|
|
774 |
else if ( streamType == EDunStreamTypeDownstream )
|
|
775 |
{
|
|
776 |
channelData.iDownstreamRW->AddSkippedError( aError, operationType );
|
|
777 |
}
|
|
778 |
else
|
|
779 |
{
|
|
780 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() (stream) not initialized!" ) ));
|
|
781 |
return KErrGeneral;
|
|
782 |
}
|
|
783 |
|
|
784 |
FTRACE(FPrint( _L("CDunTransUtils::DoAddSkippedError() complete" ) ));
|
|
785 |
return KErrNone;
|
|
786 |
}
|
|
787 |
|
|
788 |
// ---------------------------------------------------------------------------
|
|
789 |
// From class MDunTransporterUtility.
|
|
790 |
// Issues transfers requests for aIndex:th transfer objects
|
|
791 |
// ---------------------------------------------------------------------------
|
|
792 |
//
|
|
793 |
TInt CDunTransUtils::DoIssueTransferRequests( TInt aIndex )
|
|
794 |
{
|
|
795 |
FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests()" )));
|
|
796 |
if ( aIndex < 0 ||
|
|
797 |
aIndex >= iChannelData.Count() )
|
|
798 |
{
|
|
799 |
FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (not found) complete" )));
|
|
800 |
return KErrNotFound;
|
|
801 |
}
|
|
802 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
803 |
if ( !channelData.iChannelInUse )
|
|
804 |
{
|
|
805 |
FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (channel not found) complete" ), aIndex));
|
|
806 |
return KErrGeneral;
|
|
807 |
}
|
|
808 |
|
|
809 |
if ( !channelData.iUpstreamRW )
|
|
810 |
{
|
|
811 |
FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (iUpstreamRW) not initialized!" )));
|
|
812 |
return KErrGeneral;
|
|
813 |
}
|
|
814 |
if ( !channelData.iDownstreamRW )
|
|
815 |
{
|
|
816 |
FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() (iDownstreamRW) not initialized!" )));
|
|
817 |
return KErrGeneral;
|
|
818 |
}
|
|
819 |
|
|
820 |
// Below issuing requests on signal objects (CDunSignalCopy,
|
|
821 |
// CDunSignalNotify) before issuing request on read/write objects
|
|
822 |
// (CDunUpstream/CDunDownstream). This is to guarantee that if signals are
|
|
823 |
// already set in local media side then they will be copied to network side
|
|
824 |
// before data.
|
|
825 |
|
|
826 |
if ( channelData.iUpstreamSignalCopy ) // optional (RComm)
|
|
827 |
{
|
|
828 |
channelData.iUpstreamSignalCopy->IssueRequest();
|
|
829 |
}
|
|
830 |
if ( channelData.iDownstreamSignalCopy ) // optional (RComm)
|
|
831 |
{
|
|
832 |
channelData.iDownstreamSignalCopy->IssueRequest();
|
|
833 |
}
|
|
834 |
if ( channelData.iSignalNotify ) // optional (RSocket)
|
|
835 |
{
|
|
836 |
channelData.iSignalNotify->IssueRequest();
|
|
837 |
}
|
|
838 |
channelData.iUpstreamRW->StartStream();
|
|
839 |
channelData.iDownstreamRW->StartStream();
|
|
840 |
|
|
841 |
FTRACE(FPrint( _L("CDunTransUtils::DoIssueTransferRequests() complete" )));
|
|
842 |
return KErrNone;
|
|
843 |
}
|
|
844 |
|
|
845 |
// ---------------------------------------------------------------------------
|
|
846 |
// From class MDunTransporterUtility.
|
|
847 |
// Stops transfers for aIndex:th transfer objects
|
|
848 |
// ---------------------------------------------------------------------------
|
|
849 |
//
|
|
850 |
TInt CDunTransUtils::DoStopTransfers( TInt aIndex )
|
|
851 |
{
|
|
852 |
FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers()" )));
|
|
853 |
if ( aIndex < 0 ||
|
|
854 |
aIndex >= iChannelData.Count() )
|
|
855 |
{
|
|
856 |
FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (not found) complete" )));
|
|
857 |
return KErrNotFound;
|
|
858 |
}
|
|
859 |
|
|
860 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
861 |
if ( !channelData.iChannelInUse )
|
|
862 |
{
|
|
863 |
FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (channel not found) complete" ), aIndex));
|
|
864 |
return KErrGeneral;
|
|
865 |
}
|
|
866 |
|
|
867 |
if ( !channelData.iUpstreamRW )
|
|
868 |
{
|
|
869 |
FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (iUpstreamRW) not initialized!" )));
|
|
870 |
return KErrGeneral;
|
|
871 |
}
|
|
872 |
if ( !channelData.iDownstreamRW )
|
|
873 |
{
|
|
874 |
FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() (iDownstreamRW) not initialized!" )));
|
|
875 |
return KErrGeneral;
|
|
876 |
}
|
|
877 |
|
|
878 |
// Now stop operation of signal objects (CDunSignalCopy, CDunSignalNotify)
|
|
879 |
// before stopping operation on read/write objects (CDunUpstream/
|
|
880 |
// CDunDownstream). This is to ensure that signals don't change after
|
|
881 |
// stopping read/write which in turn could cause problems.
|
|
882 |
|
|
883 |
if ( channelData.iUpstreamSignalCopy ) // optional (RComm)
|
|
884 |
{
|
|
885 |
channelData.iUpstreamSignalCopy->Stop();
|
|
886 |
}
|
|
887 |
if ( channelData.iDownstreamSignalCopy ) // optional (RComm)
|
|
888 |
{
|
|
889 |
channelData.iDownstreamSignalCopy->Stop();
|
|
890 |
}
|
|
891 |
if ( channelData.iSignalNotify ) // optional (RSocket)
|
|
892 |
{
|
|
893 |
channelData.iSignalNotify->Stop();
|
|
894 |
}
|
|
895 |
channelData.iUpstreamRW->Stop();
|
|
896 |
channelData.iDownstreamRW->Stop();
|
|
897 |
|
|
898 |
FTRACE(FPrint( _L("CDunTransUtils::DoStopTransfers() complete" )));
|
|
899 |
return KErrNone;
|
|
900 |
}
|
|
901 |
|
|
902 |
// ---------------------------------------------------------------------------
|
|
903 |
// From class MDunTransporterUtility.
|
|
904 |
// Free aIndex:th channel's objects
|
|
905 |
// ---------------------------------------------------------------------------
|
|
906 |
//
|
|
907 |
TInt CDunTransUtils::DoFreeChannel( TInt aIndex )
|
|
908 |
{
|
|
909 |
FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel()" )));
|
|
910 |
|
|
911 |
TDunChannelData& channelData = iChannelData[aIndex];
|
|
912 |
if ( aIndex < 0 ||
|
|
913 |
aIndex >= iChannelData.Count() )
|
|
914 |
{
|
|
915 |
FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel (not found) complete" )));
|
|
916 |
return KErrNotFound;
|
|
917 |
}
|
|
918 |
if ( !channelData.iChannelInUse )
|
|
919 |
{
|
|
920 |
FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel (already free) complete" )));
|
|
921 |
return KErrNone;
|
|
922 |
}
|
|
923 |
if ( !iParent.iNetwork )
|
|
924 |
{
|
|
925 |
FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel (iNetwork) not initialized!" )));
|
|
926 |
return KErrGeneral;
|
|
927 |
}
|
|
928 |
|
|
929 |
DoStopTransfers( aIndex );
|
|
930 |
DeleteOneNetworkData( aIndex );
|
|
931 |
DeleteOneLocalData( aIndex );
|
|
932 |
DeleteBuffering( aIndex );
|
|
933 |
|
|
934 |
iParent.iNetwork->FreeChannel( channelData.iNetwork );
|
|
935 |
|
|
936 |
channelData.iNetwork = NULL;
|
|
937 |
channelData.iComm = NULL;
|
|
938 |
channelData.iSocket = NULL;
|
|
939 |
channelData.iChannelInUse = EFalse;
|
|
940 |
|
|
941 |
// If note exist then stop it now as no reason to show it anymore
|
|
942 |
if ( iParent.iNoteHandler )
|
|
943 |
{
|
|
944 |
iParent.iNoteHandler->Stop();
|
|
945 |
}
|
|
946 |
// Set flag to indicate that advertisement is now possible
|
|
947 |
ManageAdvertisementStatusChange( ETrue, EFalse );
|
|
948 |
|
|
949 |
FTRACE(FPrint( _L("CDunTransUtils::DoFreeChannel() complete" )));
|
|
950 |
return KErrNone;
|
|
951 |
}
|
|
952 |
|
|
953 |
// ---------------------------------------------------------------------------
|
|
954 |
// From class MDunTransporterUtilityAux.
|
|
955 |
// Gets local ID counterpart of a network ID
|
|
956 |
// ---------------------------------------------------------------------------
|
|
957 |
//
|
|
958 |
TConnId CDunTransUtils::GetLocalId( RComm* aComm )
|
|
959 |
{
|
|
960 |
FTRACE(FPrint( _L("CDunTransUtils::GetLocalId()" )));
|
|
961 |
TInt mediaIndex = iParent.GetMediaIndex( aComm, EDunMediaContextNetwork );
|
|
962 |
if ( mediaIndex < 0 )
|
|
963 |
{
|
|
964 |
FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (ERROR) complete (%d)" ), mediaIndex));
|
|
965 |
return NULL;
|
|
966 |
}
|
|
967 |
if ( mediaIndex >= iChannelData.Count() )
|
|
968 |
{
|
|
969 |
FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (not found) complete" ) ));
|
|
970 |
return NULL;
|
|
971 |
}
|
|
972 |
TDunChannelData& channelData = iChannelData[mediaIndex];
|
|
973 |
if ( channelData.iComm )
|
|
974 |
{
|
|
975 |
FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (iComm) complete" )));
|
|
976 |
return channelData.iComm;
|
|
977 |
}
|
|
978 |
if ( channelData.iSocket )
|
|
979 |
{
|
|
980 |
FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (iSocket) complete" )));
|
|
981 |
return channelData.iSocket;
|
|
982 |
}
|
|
983 |
FTRACE(FPrint( _L("CDunTransUtils::GetLocalId() (ERROR) complete" )));
|
|
984 |
return NULL;
|
|
985 |
}
|
|
986 |
|
|
987 |
// ---------------------------------------------------------------------------
|
|
988 |
// From MDunTransporterUtilityAux.
|
|
989 |
// Notifies when serious read/write error is detected on a connection
|
|
990 |
// ---------------------------------------------------------------------------
|
|
991 |
//
|
|
992 |
TInt CDunTransUtils::DoNotifyConnectionNotOk(
|
|
993 |
RComm* aComm,
|
|
994 |
RSocket* aSocket,
|
|
995 |
TDunConnectionReason& aConnReason,
|
|
996 |
RPointerArray<MDunConnMon>& aCallbacks )
|
|
997 |
{
|
|
998 |
FTRACE(FPrint( _L("CDunTransUtils::DoNotifyConnectionNotOk()" )));
|
|
999 |
TConnId localId = NULL;
|
|
1000 |
if ( aComm )
|
|
1001 |
{
|
|
1002 |
localId = aComm;
|
|
1003 |
}
|
|
1004 |
else if ( aSocket )
|
|
1005 |
{
|
|
1006 |
localId = aSocket;
|
|
1007 |
}
|
|
1008 |
TInt i;
|
|
1009 |
TInt count = aCallbacks.Count();
|
|
1010 |
for ( i=0; i<count; i++ )
|
|
1011 |
{
|
|
1012 |
if ( !aCallbacks[i] )
|
|
1013 |
{
|
|
1014 |
FTRACE(FPrint( _L("CDunTransUtils::DoNotifyConnectionNotOk() (iCallbacks[%d]) not initialized!" ), i));
|
|
1015 |
return KErrGeneral;
|
|
1016 |
}
|
|
1017 |
TRAP_IGNORE(
|
|
1018 |
aCallbacks[i]->NotifyProgressChangeL( localId, aConnReason ) );
|
|
1019 |
}
|
|
1020 |
FTRACE(FPrint( _L("CDunTransUtils::DoNotifyConnectionNotOk() complete" )));
|
|
1021 |
return KErrNone;
|
|
1022 |
}
|
|
1023 |
|
|
1024 |
// ---------------------------------------------------------------------------
|
|
1025 |
// From class MDunActivityManager.
|
|
1026 |
// Notifies about activity on a channel
|
|
1027 |
// ---------------------------------------------------------------------------
|
|
1028 |
//
|
|
1029 |
TInt CDunTransUtils::NotifyChannelActivity()
|
|
1030 |
{
|
|
1031 |
FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelActivity()" )));
|
|
1032 |
iParent.iActiveChannels++;
|
|
1033 |
if ( iParent.iActiveChannels == 1 )
|
|
1034 |
{
|
|
1035 |
// Now set key and notify (only once) that DUN is active
|
|
1036 |
TInt retTemp = RProperty::Set( KPSUidDialupConnStatus,
|
|
1037 |
KDialupConnStatus,
|
|
1038 |
EDialupActive );
|
|
1039 |
if ( retTemp != KErrNone )
|
|
1040 |
{
|
|
1041 |
FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelActivity() (ERROR) complete" )));
|
|
1042 |
return retTemp;
|
|
1043 |
}
|
|
1044 |
}
|
|
1045 |
FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelActivity() complete" )));
|
|
1046 |
return KErrNone;
|
|
1047 |
}
|
|
1048 |
|
|
1049 |
// ---------------------------------------------------------------------------
|
|
1050 |
// From class MDunActivityManager.
|
|
1051 |
// Notifies about inactivity on a channel
|
|
1052 |
// ---------------------------------------------------------------------------
|
|
1053 |
//
|
|
1054 |
TInt CDunTransUtils::NotifyChannelInactivity()
|
|
1055 |
{
|
|
1056 |
FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity()" )));
|
|
1057 |
if ( iParent.iActiveChannels <= 0 )
|
|
1058 |
{
|
|
1059 |
FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity() (wrong iActiveChannels!) complete" )));
|
|
1060 |
return KErrGeneral;
|
|
1061 |
}
|
|
1062 |
iParent.iActiveChannels--;
|
|
1063 |
if ( iParent.iActiveChannels == 0 )
|
|
1064 |
{
|
|
1065 |
// Now set key and notify (only once) that DUN is inactive
|
|
1066 |
TInt retTemp = RProperty::Set( KPSUidDialupConnStatus,
|
|
1067 |
KDialupConnStatus,
|
|
1068 |
EDialupInactive );
|
|
1069 |
if ( retTemp != KErrNone )
|
|
1070 |
{
|
|
1071 |
FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity() (ERROR) complete" )));
|
|
1072 |
return retTemp;
|
|
1073 |
}
|
|
1074 |
}
|
|
1075 |
FTRACE(FPrint( _L("CDunTransUtils::NotifyChannelInactivity() complete" )));
|
|
1076 |
return KErrNone;
|
|
1077 |
}
|