localconnectivityservice/dun/utils/inc/DunStream.h
author hgs
Thu, 04 Nov 2010 15:31:42 +0800
changeset 60 841f70763fbe
parent 29 3ae5cb0b4c02
permissions -rw-r--r--
201044_04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     1
/*
60
841f70763fbe 201044_04
hgs
parents: 29
diff changeset
     2
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
29
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:  Definitions needed for common stream functionality
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
#ifndef C_CDUNSTREAM_H
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    20
#define C_CDUNSTREAM_H
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    21
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    22
#include "DunTransporter.h"
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    23
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    24
/**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    25
 *  Class for common stream functionality
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    26
 *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    27
 *  @lib dunutils.lib
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    28
 *  @since S60 v3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    29
 */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    30
NONSHARABLE_CLASS( CDunStream ) : public CActive
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    31
    {
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    32
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    33
public:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    34
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    35
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    36
     * Resets data to initial values
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    37
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    38
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    39
     * @return None
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    40
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    41
    void ResetData();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    42
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    43
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    44
     * Adds error code to consider as "no error" to either endpoint
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    45
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    46
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    47
     * @param aError Error code to add
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    48
     * @param aOperationType Type of operation for which to add error
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    49
     *                       (read or write)
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    50
     * @return Symbian error code on error, KErrNone otherwise
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    51
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    52
    TInt AddSkippedError( TInt aError, TDunOperationType aOperationType );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    53
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    54
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    55
     * Adds callback for line status change controlling
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    56
     * The callback will be called when serious read error is detected
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    57
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    58
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    59
     * @param aCallback Callback to call when read error occurs
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    60
     * @param aOperationType Type of operation for which to add error
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    61
     *                       (read or write)
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    62
     * @return Symbian error code on error, KErrNone otherwise
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    63
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    64
    TInt AddConnMonCallback( MDunConnMon* aCallback,
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    65
                             TDunOperationType aOperationType );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    66
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    67
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    68
     * Sets buffering for this stream
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    69
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    70
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    71
     * @param aBufferPtr Pointer to the buffer
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    72
     * @return KErrGeneral if buffer pointer null, KErrNone otherwise
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    73
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    74
    TInt SetBuffering( TPtr8* aBufferPtr );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    75
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    76
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    77
     * Sets media to be used for this endpoint
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    78
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    79
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    80
     * @param aComm RComm pointer to use as the endpoint
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    81
     * @param aMediaContext Media context to use for this endpoint, either
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    82
     *                      local or network
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    83
     * @return Symbian error code on error, KErrNone otherwise
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    84
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    85
    TInt SetMedia( RComm* aComm, TDunMediaContext aMediaContext );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    86
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    87
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    88
     * Sets media to be used for this endpoint
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    89
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    90
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    91
     * @param aSocket RSocket pointer to use as the endpoint
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    92
     * @param aMediaContext Media context to use for this endpoint, either
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    93
     *                      local or network
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    94
     * @return Symbian error code on error, KErrNone otherwise
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    95
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    96
    TInt SetMedia( RSocket* aSocket, TDunMediaContext aMediaContext );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    97
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    98
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    99
     * Gets media context
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   100
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   101
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   102
     * @param aStreamType Stream type
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   103
     * @return Media context in use
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   104
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   105
    TDunMediaContext GetMediaContext( TDunStreamType aStreamType );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   106
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   107
protected:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   108
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   109
    CDunStream();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   110
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   111
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   112
    * Destructor.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   113
    */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   114
    virtual ~CDunStream();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   115
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   116
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   117
     * Check whether an error code is severe error or not
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   118
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   119
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   120
     * @param aError Error code to check for severity
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   121
     * @param aIsError ETrue if error code is error, EFalse if not error
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   122
     * @return ETrue if severe error detected, EFalse if not severe error
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   123
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   124
    TBool ProcessErrorCondition( TInt aError, TBool& aIsError );
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   125
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   126
// from base class CActive
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   127
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   128
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   129
     * From CActive.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   130
     * Gets called when endpoint data read/write complete
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   131
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   132
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   133
     * @return None
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   134
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   135
    virtual void RunL() {};
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   136
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   137
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   138
     * From CActive.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   139
     * Gets called on cancel
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   140
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   141
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   142
     * @return None
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   143
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   144
    virtual void DoCancel() {};
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   145
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   146
private:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   147
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   148
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   149
     * Initializes this class
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   150
     *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   151
     * @since S60 3.2
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   152
     * @return None
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   153
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   154
    void Initialize();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   155
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   156
protected:  // data
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   157
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   158
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   159
     * Pointer to stream's data buffer: upstream or downstream
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   160
     * Not own.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   161
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   162
    TPtr8* iBufferPtr;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   163
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   164
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   165
     * Callback(s) to call when notification(s) via MDunConnMon to be made
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   166
     * These callbacks are called on read failures
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   167
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   168
    RPointerArray<MDunConnMon> iCallbacksR;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   169
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   170
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   171
     * Callback(s) to call when notification(s) via MDunConnMon to be made
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   172
     * These callbacks are called on write failures
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   173
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   174
    RPointerArray<MDunConnMon> iCallbacksW;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   175
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   176
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   177
     * Read length set when RSocket::RecvOneOrMore() request completes
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   178
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   179
    TSockXfrLength iReadLengthSocket;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   180
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   181
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   182
     * Type of current operation: read or write
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   183
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   184
    TDunOperationType iOperationType;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   185
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   186
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   187
     * Direction of data transfer
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   188
     * This is set after iStreamType and iOperationType are known
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   189
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   190
    TDunDirection iDirection;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   191
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   192
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   193
     * Array of error codes that will be skipped for read operations
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   194
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   195
    RArray<TInt> iOkErrorsR;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   196
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   197
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   198
     * Array of error codes that will be skipped for write operations
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   199
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   200
    RArray<TInt> iOkErrorsW;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   201
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   202
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   203
     * RComm object of network side
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   204
     * Not own.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   205
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   206
    RComm* iNetwork;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   207
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   208
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   209
     * RSocket object of local media side
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   210
     * If this is set then iComm is not used
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   211
     * Not own.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   212
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   213
    RSocket* iSocket;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   214
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   215
    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   216
     * RComm object of local media side
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   217
     * If this is set then iSocket is not used
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   218
     * Not own.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   219
     */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   220
    RComm* iComm;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   221
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   222
    };
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   223
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   224
#endif  // C_CDUNSTREAM_H