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