localconnectivityservice/dun/utils/inc/DunDownstream.h
changeset 29 3ae5cb0b4c02
equal deleted inserted replaced
20:6e82ae192c3a 29:3ae5cb0b4c02
       
     1 /*
       
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Definitions needed for one "stream" of CDunTransporter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CDUNDOWNSTREAM_H
       
    20 #define C_CDUNDOWNSTREAM_H
       
    21 
       
    22 #include "DunTransUtils.h"
       
    23 #include "DunStream.h"
       
    24 #include "DunAtCmdHandler.h"
       
    25 #include "DunDataPusher.h"
       
    26 
       
    27 class MDunCompletionReporter;
       
    28 class MDunAtCmdHandler;
       
    29 
       
    30 /**
       
    31  *  Class used for storing data related to data pushing
       
    32  *
       
    33  *  @lib dunutils.lib
       
    34  *  @since S60 v3.2
       
    35  */
       
    36 NONSHARABLE_CLASS( TDunPushData )
       
    37     {
       
    38 
       
    39 public:
       
    40 
       
    41     /**
       
    42      * Flag for command mode notifier's MDunCmdModeMonitor callback
       
    43      * This flag is needed to mark command mode start/end
       
    44      */
       
    45     TBool iDataMode;
       
    46 
       
    47     /**
       
    48      * Data pusher for stream manipulation
       
    49      */
       
    50     CDunDataPusher* iDataPusher;
       
    51 
       
    52     /**
       
    53      * AT command handling related functionality for CDunDownstream
       
    54      * Not own.
       
    55      */
       
    56     MDunAtCmdHandler* iAtCmdHandler;
       
    57 
       
    58     };
       
    59 
       
    60 /**
       
    61  *  Class for manipulating existing stream's contents from outside
       
    62  *  (outside of class CDunDownstream)
       
    63  *
       
    64  *  @lib dunutils.lib
       
    65  *  @since S60 v3.2
       
    66  */
       
    67 NONSHARABLE_CLASS( MDunStreamManipulator )
       
    68     {
       
    69 
       
    70 public:
       
    71 
       
    72     /**
       
    73      * Gets called when outside party wants to push data to the existing stream
       
    74      *
       
    75      * @since S60 5.0
       
    76      * @param aDataToPush Data to push to the stream (not copied)
       
    77      * @param aCallback Callback to call when data is processed by the stream
       
    78      * @return Symbian error code on error, KErrNone otherwise
       
    79      */
       
    80     virtual TInt NotifyDataPushRequest(
       
    81         const TDesC8* aDataToPush,
       
    82         MDunCompletionReporter* aCallback ) = 0;
       
    83 
       
    84     /**
       
    85      * Checks if data is in queue
       
    86      *
       
    87      * @since TB9.2
       
    88      * @param aDataToPush Data to check
       
    89      * @return ETrue if data is in queue, EFalse otherwise
       
    90      */
       
    91     virtual TBool IsDataInQueue( const TDesC8 *aDataToPush ) = 0;
       
    92 
       
    93     };
       
    94 
       
    95 /**
       
    96  *  Class for data transmission of one "stream" from network to local media
       
    97  *
       
    98  *  @lib dunutils.lib
       
    99  *  @since S60 v3.2
       
   100  */
       
   101 NONSHARABLE_CLASS( CDunDownstream ) : public CDunStream,
       
   102                                       public MDunStreamManipulator,
       
   103                                       public MDunCompletionReporter,
       
   104                                       public MDunCmdModeMonitor
       
   105     {
       
   106 
       
   107     friend class CDunDataPusher;
       
   108 
       
   109 public:
       
   110 
       
   111     /**
       
   112      * Two-phased constructor.
       
   113      * @param aUtility Pointer to common utility class
       
   114      * @return Instance of self
       
   115      */
       
   116 	static CDunDownstream* NewL( MDunTransporterUtilityAux* aUtility );
       
   117 
       
   118     /**
       
   119     * Destructor.
       
   120     */
       
   121     virtual ~CDunDownstream();
       
   122 
       
   123     /**
       
   124      * Resets data to initial values
       
   125      *
       
   126      * @since S60 3.2
       
   127      * @return None
       
   128      */
       
   129     void ResetData();
       
   130 
       
   131     /**
       
   132      * Starts downstream by issuing read request
       
   133      *
       
   134      * @since S60 3.2
       
   135      * @return Symbian error code on error, KErrNone otherwise
       
   136      */
       
   137     TInt StartStream();
       
   138 
       
   139     /**
       
   140      * Stops transfer for read or write endpoints
       
   141      *
       
   142      * @since S60 3.2
       
   143      * @param aStopMplex ETrue if multiplexer stop, EFalse otherwise
       
   144      * @return Symbian error code on error, KErrNone otherwise
       
   145      */
       
   146     TInt Stop( TBool aStopMplex=ETrue );
       
   147 
       
   148     /**
       
   149      * Initializes this stream for data pushing
       
   150      *
       
   151      * @since S60 3.2
       
   152      * @param aAtCmdHandler AT command handling related functionality
       
   153      * @return Symbian error code on error, KErrNone otherwise
       
   154      */
       
   155     TInt InitializeForDataPushing( MDunAtCmdHandler* aAtCmdHandler );
       
   156 
       
   157     /**
       
   158      * Checks if data is in queue
       
   159      *
       
   160      * @since TB9.2
       
   161      * @param aDataToPush Data to check
       
   162      * @return ETrue if data is in queue, EFalse otherwise
       
   163      */
       
   164     TBool IsDataInQueue( const TDesC8* aDataToPush );
       
   165 
       
   166     /**
       
   167      * Adds data to event queue and starts sending if needed
       
   168      *
       
   169      * @since S60 5.0
       
   170      * @param aDataToPush Data to push to the stream (not copied)
       
   171      * @param aCallback Callback to call when data is processed by the stream
       
   172      * @return Symbian error code on error, KErrNone otherwise
       
   173      */
       
   174     TInt AddToQueueAndSend( const TDesC8* aDataToPush,
       
   175                             MDunCompletionReporter* aCallback );
       
   176 
       
   177 private:
       
   178 
       
   179     CDunDownstream( MDunTransporterUtilityAux* aUtility );
       
   180 
       
   181     void ConstructL();
       
   182 
       
   183     /**
       
   184      * Initializes this class
       
   185      *
       
   186      * @since S60 3.2
       
   187      * @return None
       
   188      */
       
   189     void Initialize();
       
   190 
       
   191     /**
       
   192      * Issues transfer request for this stream
       
   193      *
       
   194      * @since S60 3.2
       
   195      * @return Symbian error code on error, KErrNone otherwise
       
   196      */
       
   197     TInt IssueRequest();
       
   198 
       
   199 // from base class CActive
       
   200 
       
   201     /**
       
   202      * From CActive.
       
   203      * Gets called when endpoint data read complete
       
   204      *
       
   205      * @since S60 3.2
       
   206      * @return None
       
   207      */
       
   208     void RunL();
       
   209 
       
   210     /**
       
   211      * From CActive.
       
   212      * Gets called on cancel
       
   213      *
       
   214      * @since S60 3.2
       
   215      * @return None
       
   216      */
       
   217     void DoCancel();
       
   218 
       
   219 // from base class MDunStreamManipulator
       
   220 
       
   221     /**
       
   222      * Gets called when outside party wants to push data to the existing stream
       
   223      *
       
   224      * @since S60 3.2
       
   225      * @param aDataToPush Data to push to the stream (not copied)
       
   226      * @param aCallback Callback to call when data is processed by the stream
       
   227      * @return Symbian error code on error, KErrNone otherwise
       
   228      */
       
   229     TInt NotifyDataPushRequest( const TDesC8* aDataToPush,
       
   230                                 MDunCompletionReporter* aCallback );
       
   231 
       
   232 // from base class MDunCompletionReporter
       
   233 
       
   234     /**
       
   235      * Gets called when data push is complete
       
   236      *
       
   237      * @since S60 5.0
       
   238      * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
       
   239      * @return None
       
   240      */
       
   241     void NotifyDataPushComplete( TBool aAllPushed );
       
   242 
       
   243 // from base class MDunCmdModeMonitor
       
   244 
       
   245     /**
       
   246      * Notifies about command mode start
       
   247      *
       
   248      * @since S60 5.0
       
   249      * @return None
       
   250      */
       
   251     void NotifyCommandModeStart();
       
   252 
       
   253     /**
       
   254      * Notifies about command mode end
       
   255      *
       
   256      * @since S60 5.0
       
   257      * @return None
       
   258      */
       
   259     void NotifyCommandModeEnd();
       
   260 
       
   261 private:  // data
       
   262 
       
   263     /**
       
   264      * Pointer to common utility class
       
   265      * Not own.
       
   266      */
       
   267     MDunTransporterUtilityAux* iUtility;
       
   268 
       
   269     /**
       
   270      * Data related to data pushing
       
   271      */
       
   272     TDunPushData iPushData;
       
   273 
       
   274     };
       
   275 
       
   276 #endif  // C_CDUNDOWNSTREAM_H