localconnectivityservice/dun/utils/inc/DunUpstream.h
changeset 28 85e0c0339cc3
child 33 883e91c086aa
equal deleted inserted replaced
25:48a2e0d8a4ce 28:85e0c0339cc3
       
     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_CDUNUPSTREAM_H
       
    20 #define C_CDUNUPSTREAM_H
       
    21 
       
    22 #include "DunTransUtils.h"
       
    23 #include "DunStream.h"
       
    24 #include "DunAtCmdHandler.h"
       
    25 #include "DunAtCmdEchoer.h"
       
    26 #include "DunDataPusher.h"
       
    27 
       
    28 class MDunCmdModeMonitor;
       
    29 
       
    30 /**
       
    31  *  Class used for storing data related to activity monitoring
       
    32  *
       
    33  *  @lib dunutils.lib
       
    34  *  @since S60 v3.2
       
    35  */
       
    36 NONSHARABLE_CLASS( TDunActivityData )
       
    37     {
       
    38 
       
    39 public:
       
    40 
       
    41     /**
       
    42      * Callback to call when notification via MDunActivityManager to be made
       
    43      * Not own.
       
    44      */
       
    45     MDunActivityManager* iActivityCallback;
       
    46 
       
    47     /**
       
    48      * Flag for data read activity's MDunActivityManager callback
       
    49      * This flag is needed to prevent multiple notifications of same activity
       
    50      */
       
    51     TBool iDataRead;
       
    52 
       
    53     /**
       
    54      * Used as a flag for the first notification of read activity
       
    55      * This flag is needed to keep MDunActivityManager notifications in sync
       
    56      * (inactivity notification done only if activity notification done first)
       
    57      */
       
    58     TBool iNotified;
       
    59 
       
    60     };
       
    61 
       
    62 /**
       
    63  *  Class used for storing data related to AT command parsing
       
    64  *
       
    65  *  @lib dunutils.lib
       
    66  *  @since S60 v3.2
       
    67  */
       
    68 NONSHARABLE_CLASS( TDunParseData )
       
    69     {
       
    70 
       
    71 public:
       
    72 
       
    73     /**
       
    74      * Flag for command mode notifier's MDunCmdModeMonitor callback
       
    75      * This flag is needed to mark command mode start/end for parse start/end
       
    76      */
       
    77     TBool iDataMode;
       
    78 
       
    79     /**
       
    80      * Flag to indicate whether AT parsing is needed or not
       
    81      */
       
    82     TBool iParseNeeded;
       
    83 
       
    84     /**
       
    85      * Flag to be set when AT command handling starts
       
    86      */
       
    87     TBool iHandling;
       
    88 
       
    89     /**
       
    90      * AT Command handler. Used if iAtParseNeeded is ETrue
       
    91      */
       
    92     CDunAtCmdHandler* iAtCmdHandler;
       
    93 
       
    94     };
       
    95 
       
    96 /**
       
    97  *  Accessor class for AT command handling related functionality
       
    98  *
       
    99  *  @lib dunutils.lib
       
   100  *  @since S60 v3.2
       
   101  */
       
   102 NONSHARABLE_CLASS( MDunAtCmdHandler )
       
   103     {
       
   104 
       
   105 public:
       
   106 
       
   107     /**
       
   108      * Starts URC message handling
       
   109      * This is an accessor for CDunDownstream's StartStream()
       
   110      *
       
   111      * @since S60 5.0
       
   112      * @return Symbian error code on error, KErrNone otherwise
       
   113      */
       
   114     virtual TInt StartUrc() = 0;
       
   115 
       
   116     /**
       
   117      * Stops AT command handling downstream related activity (also URC)
       
   118      * This is an accessor for CDunDownstream's Stop()
       
   119      *
       
   120      * @since S60 3.2
       
   121      * @return None
       
   122      */
       
   123     virtual TInt StopAtCmdHandling() = 0;
       
   124 
       
   125     };
       
   126 
       
   127 /**
       
   128  *  Class for data transmission of one "stream" from local media to network
       
   129  *
       
   130  *  @lib dunutils.lib
       
   131  *  @since S60 v3.2
       
   132  */
       
   133 NONSHARABLE_CLASS( CDunUpstream ) : public CDunStream,
       
   134                                     public MDunAtCmdHandler,
       
   135                                     public MDunCmdModeMonitor,
       
   136                                     public MDunAtCmdStatusReporter,
       
   137                                     public MDunAtCmdEchoer
       
   138     {
       
   139 
       
   140 public:
       
   141 
       
   142     /**
       
   143      * Two-phased constructor.
       
   144      * @param aUtility Pointer to common utility class
       
   145      * @return Instance of self
       
   146      */
       
   147 	static CDunUpstream* NewL( MDunTransporterUtilityAux* aUtility );
       
   148 
       
   149     /**
       
   150     * Destructor.
       
   151     */
       
   152     virtual ~CDunUpstream();
       
   153 
       
   154     /**
       
   155      * Resets data to initial values
       
   156      *
       
   157      * @since S60 3.2
       
   158      * @return None
       
   159      */
       
   160     void ResetData();
       
   161 
       
   162     /**
       
   163      * Sets activity callback for this stream
       
   164      *
       
   165      * @since S60 3.2
       
   166      * @param aActivityCallback Pointer to activity callback
       
   167      * @return KErrGeneral if callback null, KErrNone otherwise
       
   168      */
       
   169     TInt SetActivityCallback( MDunActivityManager* aActivityCallback );
       
   170 
       
   171     /**
       
   172      * Initializes this stream for AT command notifications
       
   173      *
       
   174      * @since S60 5.0
       
   175      * @param aStreamCallback Pointer to stream callback
       
   176      * @param aConnectionName Connection identifier name
       
   177      * @param aCallbackUp Upstream callback to call when command mode starts or
       
   178      *                    ends
       
   179      * @param aCallbackDown Downstream callback to call when command mode starts
       
   180      *                    or ends
       
   181      * @return Symbian error code on error, KErrNone otherwise
       
   182      */
       
   183     TInt InitializeForAtParsing( MDunStreamManipulator* aStreamCallback,
       
   184                                  const TDesC8* aConnectionName,
       
   185                                  MDunCmdModeMonitor* aCallbackUp,
       
   186                                  MDunCmdModeMonitor* aCallbackDown );
       
   187 
       
   188     /**
       
   189      * Starts upstream by issuing read request
       
   190      *
       
   191      * @since S60 3.2
       
   192      * @return Symbian error code on error, KErrNone otherwise
       
   193      */
       
   194     TInt StartStream();
       
   195 
       
   196     /**
       
   197      * Stops transfer for read & write endpoints
       
   198      *
       
   199      * @since S60 3.2
       
   200      * @return Symbian error code on error, KErrNone otherwise
       
   201      */
       
   202     TInt Stop();
       
   203 
       
   204     /**
       
   205      * Data transmission state (if read completed)
       
   206      *
       
   207      * @since S60 3.2
       
   208      * @return ETrue if data successfully read, EFalse otherwise
       
   209      */
       
   210     TBool DataReadStatus();
       
   211 
       
   212 private:
       
   213 
       
   214     CDunUpstream( MDunTransporterUtilityAux* aUtility );
       
   215 
       
   216     void ConstructL();
       
   217 
       
   218     /**
       
   219      * Initializes this class
       
   220      *
       
   221      * @since S60 3.2
       
   222      * @return None
       
   223      */
       
   224     void Initialize();
       
   225 
       
   226     /**
       
   227      * Issues transfer request for this stream
       
   228      *
       
   229      * @since S60 3.2
       
   230      * @return Symbian error code on error, KErrNone otherwise
       
   231      */
       
   232     TInt IssueRequest();
       
   233 
       
   234     /**
       
   235      * Processes data that was read
       
   236      *
       
   237      * @since S60 5.0
       
   238      * @return ETrue if request to be reissued, EFalse otherwise
       
   239      */
       
   240     TBool ProcessReadData();
       
   241 
       
   242     /**
       
   243      * Manages activity in a channel
       
   244      *
       
   245      * @since S60 3.2
       
   246      * @return Symbian error code on error, KErrNone otherwise
       
   247      */
       
   248     TInt ManageChannelActivity();
       
   249 
       
   250 // from base class CActive
       
   251 
       
   252     /**
       
   253      * From CActive.
       
   254      * Gets called when endpoint data read/write complete
       
   255      *
       
   256      * @since S60 3.2
       
   257      * @return None
       
   258      */
       
   259     void RunL();
       
   260 
       
   261     /**
       
   262      * From CActive.
       
   263      * Gets called on cancel
       
   264      *
       
   265      * @since S60 3.2
       
   266      * @return None
       
   267      */
       
   268     void DoCancel();
       
   269 
       
   270 // from base class MDunAtCmdStatusReporter
       
   271 
       
   272     /**
       
   273      * Notifies about AT command handling start
       
   274      *
       
   275      * @since S60 5.0
       
   276      * @return None
       
   277      */
       
   278     void NotifyAtCmdHandlingStart();
       
   279 
       
   280     /**
       
   281      * Notifies about AT command handling end
       
   282      *
       
   283      * @since S60 5.0
       
   284      * @param aEndIndex Index to the start of next command
       
   285      * @return None
       
   286      */
       
   287     void NotifyAtCmdHandlingEnd( TInt aStartIndex );
       
   288 
       
   289     /**
       
   290      * Notifies about editor mode reply
       
   291      *
       
   292      * @since TB9.2
       
   293      * @param aStart ETrue if start of editor mode, EFalse otherwise
       
   294      * @return Symbian error code on error, KErrNone otherwise
       
   295      */
       
   296     void NotifyEditorModeReply( TBool aStart );
       
   297 
       
   298 // from base class MDunAtCmdHandler
       
   299 
       
   300     /**
       
   301      * Starts URC message handling
       
   302      * This is an accessor for CDunDownstream's StartStream()
       
   303      *
       
   304      * @since S60 5.0
       
   305      * @return Symbian error code on error, KErrNone otherwise
       
   306      */
       
   307     TInt StartUrc();
       
   308 
       
   309     /**
       
   310      * Stops AT command handling downstream related activity (also URC)
       
   311      * This is an accessor for CDunDownstream's Stop()
       
   312      *
       
   313      * @since S60 3.2
       
   314      * @return Symbian error code on error, KErrNone otherwise
       
   315      */
       
   316     TInt StopAtCmdHandling();
       
   317 
       
   318 // from base class MDunCmdModeMonitor
       
   319 
       
   320     /**
       
   321      * Notifies about command mode start
       
   322      *
       
   323      * @since S60 5.0
       
   324      * @return None
       
   325      */
       
   326     void NotifyCommandModeStart();
       
   327 
       
   328     /**
       
   329      * Notifies about command mode end
       
   330      *
       
   331      * @since S60 5.0
       
   332      * @return None
       
   333      */
       
   334     void NotifyCommandModeEnd();
       
   335 
       
   336 // from base class MDunAtCmdEchoer
       
   337 
       
   338     /**
       
   339      * Notifies about completed echo in text mode
       
   340      *
       
   341      * @since TB9.2
       
   342      * @return None
       
   343      */
       
   344     void NotifyEchoComplete();
       
   345 
       
   346 private:  // data
       
   347 
       
   348     /**
       
   349      * Pointer to common utility class
       
   350      * Not own.
       
   351      */
       
   352     MDunTransporterUtilityAux* iUtility;
       
   353 
       
   354     /**
       
   355      * Data related to activity monitoring
       
   356      */
       
   357     TDunActivityData iActivityData;
       
   358 
       
   359     /**
       
   360      * Data related to AT command parsing
       
   361      */
       
   362     TDunParseData iParseData;
       
   363 
       
   364     };
       
   365 
       
   366 #endif  // C_CDUNUPSTREAM_H