localconnectivityservice/dun/utils/inc/DunDownstream.h
changeset 0 c3e98f10fcf4
child 15 c47ebe2ac36c
equal deleted inserted replaced
-1:000000000000 0:c3e98f10fcf4
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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 aPushedData 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 *aPushedData,
       
    82         MDunCompletionReporter* aCallback ) = 0;
       
    83 
       
    84     };
       
    85 
       
    86 /**
       
    87  *  Class for data transmission of one "stream" from network to local media
       
    88  *
       
    89  *  @lib dunutils.lib
       
    90  *  @since S60 v3.2
       
    91  */
       
    92 NONSHARABLE_CLASS( CDunDownstream ) : public CDunStream,
       
    93                                       public MDunStreamManipulator,
       
    94                                       public MDunCompletionReporter,
       
    95                                       public MDunCmdModeMonitor
       
    96     {
       
    97 
       
    98     friend class CDunDataPusher;
       
    99 
       
   100 public:
       
   101 
       
   102     /**
       
   103      * Two-phased constructor.
       
   104      * @param aUtility Pointer to common utility class
       
   105      * @return Instance of self
       
   106      */
       
   107 	static CDunDownstream* NewL( MDunTransporterUtilityAux* aUtility );
       
   108 
       
   109     /**
       
   110     * Destructor.
       
   111     */
       
   112     virtual ~CDunDownstream();
       
   113 
       
   114     /**
       
   115      * Resets data to initial values
       
   116      *
       
   117      * @since S60 3.2
       
   118      * @return None
       
   119      */
       
   120     void ResetData();
       
   121 
       
   122     /**
       
   123      * Starts downstream by issuing read request
       
   124      *
       
   125      * @since S60 3.2
       
   126      * @return Symbian error code on error, KErrNone otherwise
       
   127      */
       
   128     TInt StartStream();
       
   129 
       
   130     /**
       
   131      * Stops transfer for read or write endpoints
       
   132      *
       
   133      * @since S60 3.2
       
   134      * @param aStopMplex ETrue if multiplexer stop, EFalse otherwise
       
   135      * @return Symbian error code on error, KErrNone otherwise
       
   136      */
       
   137     TInt Stop( TBool aStopMplex=ETrue );
       
   138 
       
   139     /**
       
   140      * Initializes this stream for data pushing
       
   141      *
       
   142      * @since S60 3.2
       
   143      * @param aAtCmdHandler AT command handling related functionality
       
   144      * @return Symbian error code on error, KErrNone otherwise
       
   145      */
       
   146     TInt InitializeForDataPushing( MDunAtCmdHandler* aAtCmdHandler );
       
   147 
       
   148     /**
       
   149      * Adds data to event queue and starts sending if needed
       
   150      *
       
   151      * @since S60 5.0
       
   152      * @param aPushedData Data to push to the stream (not copied)
       
   153      * @param aCallback Callback to call when data is processed by the stream
       
   154      * @return Symbian error code on error, KErrNone otherwise
       
   155      */
       
   156     TInt AddToQueueAndSend( const TDesC8 *aPushedData,
       
   157                             MDunCompletionReporter* aCallback );
       
   158 
       
   159     /**
       
   160      * Gets the endpoint readiness handler
       
   161      *
       
   162      * @since S60 5.0
       
   163      * @return Endpoint readiness handler
       
   164      */
       
   165     MDunEndpointReady* EndpointReadyHandler();
       
   166 
       
   167 private:
       
   168 
       
   169     CDunDownstream( MDunTransporterUtilityAux* aUtility );
       
   170 
       
   171     void ConstructL();
       
   172 
       
   173     /**
       
   174      * Initializes this class
       
   175      *
       
   176      * @since S60 3.2
       
   177      * @return None
       
   178      */
       
   179     void Initialize();
       
   180 
       
   181     /**
       
   182      * Issues transfer request for this stream
       
   183      *
       
   184      * @since S60 3.2
       
   185      * @return Symbian error code on error, KErrNone otherwise
       
   186      */
       
   187     TInt IssueRequest();
       
   188 
       
   189 // from base class CActive
       
   190 
       
   191     /**
       
   192      * From CActive.
       
   193      * Gets called when endpoint data read complete
       
   194      *
       
   195      * @since S60 3.2
       
   196      * @return None
       
   197      */
       
   198     void RunL();
       
   199 
       
   200     /**
       
   201      * From CActive.
       
   202      * Gets called on cancel
       
   203      *
       
   204      * @since S60 3.2
       
   205      * @return None
       
   206      */
       
   207     void DoCancel();
       
   208 
       
   209 // from base class MDunStreamManipulator
       
   210 
       
   211     /**
       
   212      * Gets called when outside party wants to push data to the existing stream
       
   213      *
       
   214      * @since S60 3.2
       
   215      * @param aPushedData Data to push to the stream (not copied)
       
   216      * @param aCallback Callback to call when data is processed by the stream
       
   217      * @return Symbian error code on error, KErrNone otherwise
       
   218      */
       
   219     TInt NotifyDataPushRequest( const TDesC8 *aPushedData,
       
   220                                 MDunCompletionReporter* aCallback );
       
   221 
       
   222 // from base class MDunCompletionReporter
       
   223 
       
   224     /**
       
   225      * Gets called when data push is complete
       
   226      *
       
   227      * @since S60 5.0
       
   228      * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
       
   229      * @return None
       
   230      */
       
   231     void NotifyDataPushComplete( TBool aAllPushed );
       
   232 
       
   233 // from base class MDunCmdModeMonitor
       
   234 
       
   235     /**
       
   236      * Notifies about command mode start
       
   237      *
       
   238      * @since S60 5.0
       
   239      * @return None
       
   240      */
       
   241     void NotifyCommandModeStart();
       
   242 
       
   243     /**
       
   244      * Notifies about command mode end
       
   245      *
       
   246      * @since S60 5.0
       
   247      * @return None
       
   248      */
       
   249     void NotifyCommandModeEnd();
       
   250 
       
   251 private:  // data
       
   252 
       
   253     /**
       
   254      * Pointer to common utility class
       
   255      * Not own.
       
   256      */
       
   257     MDunTransporterUtilityAux* iUtility;
       
   258 
       
   259     /**
       
   260      * Data related to data pushing
       
   261      */
       
   262     TDunPushData iPushData;
       
   263 
       
   264     };
       
   265 
       
   266 #endif  // C_CDUNDOWNSTREAM_H