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