localconnectivityservice/dun/atext/inc/DunAtCmdPusher.h
changeset 0 c3e98f10fcf4
child 13 2702348f1fe7
equal deleted inserted replaced
-1:000000000000 0:c3e98f10fcf4
       
     1 /*
       
     2 * Copyright (c) 2008 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:  AT command pusher for downstream
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_CDUNATCMDPUSHER_H
       
    19 #define C_CDUNATCMDPUSHER_H
       
    20 
       
    21 #include <atext.h>
       
    22 #include <e32base.h>
       
    23 #include "DunDataPusher.h"
       
    24 
       
    25 class MDunStreamManipulator;
       
    26 
       
    27 /**
       
    28  *  Notification interface class for data pushing status changes
       
    29  *
       
    30  *  @lib dunatext.lib
       
    31  *  @since S60 v5.0
       
    32  */
       
    33 NONSHARABLE_CLASS( MDunAtCmdPusher )
       
    34     {
       
    35 
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Notifies about end of AT command processing.
       
    40      * This is after all reply data for an AT command is multiplexed to the
       
    41      * downstream.
       
    42      *
       
    43      * @since S60 5.0
       
    44      * @param aError Error code of command processing completion
       
    45      * @return Symbian error code on error, KErrNone otherwise
       
    46      */
       
    47     virtual TInt NotifyEndOfProcessing( TInt aError ) = 0;
       
    48 
       
    49     /**
       
    50      * Notifies about request to stop AT command handling for the rest of the
       
    51      * command line data
       
    52      *
       
    53      * @since S60 5.0
       
    54      * @return Symbian error code on error, KErrNone otherwise
       
    55      */
       
    56     virtual TInt NotifyEndOfCmdLineProcessing() = 0;
       
    57 
       
    58     /**
       
    59      * Notifies about request to peek for the next command
       
    60      *
       
    61      * @since S60 5.0
       
    62      * @return ETrue if next command exists, EFalse otherwise
       
    63      */
       
    64     virtual TBool NotifyNextCommandPeekRequest() = 0;
       
    65 
       
    66     };
       
    67 
       
    68 /**
       
    69  *  Class for AT command URC handler
       
    70  *
       
    71  *  @lib dunatext.lib
       
    72  *  @since S60 v5.0
       
    73  */
       
    74 NONSHARABLE_CLASS( CDunAtCmdPusher ) : public CActive,
       
    75                                        public MDunCompletionReporter
       
    76     {
       
    77 
       
    78 public:
       
    79 
       
    80     /**
       
    81      * Two-phased constructor.
       
    82      * @param aAtCmdExt Pointer to AT command extension
       
    83      * @param aCallback Callback to AT command handler
       
    84      * @param aDownstream Callback to downstream,
       
    85      * @param aOkBuffer Buffer for ok reply
       
    86      * @return Instance of self
       
    87      */
       
    88 	static CDunAtCmdPusher* NewL( RATExt* aAtCmdExt,
       
    89 	                              MDunAtCmdPusher* aCallback,
       
    90 	                              MDunStreamManipulator* aDownstream,
       
    91 	                              TDesC8* aOkBuffer );
       
    92 
       
    93     /**
       
    94      * Two-phased constructor.
       
    95      * @param aAtCmdExt Pointer to AT command extension
       
    96      * @param aCallback Callback to AT command handler
       
    97      * @param aDownstream Callback to downstream
       
    98      * @param aOkBuffer Buffer for ok reply
       
    99      * @return Instance of self
       
   100      */
       
   101     static CDunAtCmdPusher* NewLC( RATExt* aAtCmdExt,
       
   102                                    MDunAtCmdPusher* aCallback,
       
   103                                    MDunStreamManipulator* aDownstream,
       
   104                                    TDesC8* aOkBuffer );
       
   105 
       
   106     /**
       
   107     * Destructor.
       
   108     */
       
   109     virtual ~CDunAtCmdPusher();
       
   110 
       
   111     /**
       
   112      * Resets data to initial values
       
   113      *
       
   114      * @since S60 5.0
       
   115      * @return None
       
   116      */
       
   117     void ResetData();
       
   118 
       
   119     /**
       
   120      * Starts AT command handling
       
   121      *
       
   122      * @since S60 5.0
       
   123      * @param aCommand AT command to handle
       
   124      * @return Symbian error code on error, KErrNone otherwise
       
   125      */
       
   126     TInt IssueRequest( TDesC8& aCommand );
       
   127 
       
   128     /**
       
   129      * Stops AT command handling
       
   130      *
       
   131      * @since S60 5.0
       
   132      * @return Symbian error code on error, KErrNone otherwise
       
   133      */
       
   134     TInt Stop();
       
   135 
       
   136     /**
       
   137      * Manages request to abort command handling
       
   138      *
       
   139      * @since S60 5.0
       
   140      * @return Symbian error code on error, KErrNone otherwise
       
   141      */
       
   142     TInt ManageAbortRequest();
       
   143 
       
   144     /**
       
   145      * Sets end of command line marker on for the possible series of AT
       
   146      * commands.
       
   147      *
       
   148      * @since S60 5.0
       
   149      * @param aPushLast ETrue to push last reply, EFalse otherwise
       
   150      * @return None
       
   151      */
       
   152     void SetEndOfCmdLine();
       
   153 
       
   154 private:
       
   155 
       
   156     CDunAtCmdPusher( RATExt* aAtCmdExt,
       
   157                      MDunAtCmdPusher* aCallback,
       
   158                      MDunStreamManipulator* aDownstream,
       
   159                      TDesC8* aOkBuffer );
       
   160 
       
   161     void ConstructL();
       
   162 
       
   163     /**
       
   164      * Initializes this class
       
   165      *
       
   166      * @since S60 5.0
       
   167      * @return None
       
   168      */
       
   169     void Initialize();
       
   170 
       
   171     /**
       
   172      * Sets state to idle and notifies about subcommand handling completion
       
   173      *
       
   174      * @since S60 5.0
       
   175      * @param aError Error code for completion
       
   176      * @return None
       
   177      */
       
   178     void SetToIdleAndNotifyEnd( TInt aError );
       
   179 
       
   180     /**
       
   181      * Checks if "OK" (verbose) or "0" (numeric) string or exists at the end of
       
   182      * buffer and removes it
       
   183      *
       
   184      * @since S60 5.0
       
   185      * @return Symbian error code on error, KErrNone otherwise
       
   186      */
       
   187     TInt CheckAndRemoveOkString();
       
   188 
       
   189     /**
       
   190      * Sends reply data to downstream
       
   191      *
       
   192      * @since S60 5.0
       
   193      * @param aRecvBuffer ETrue if using receive buffer
       
   194      *                    EFalse if using "OK" buffer
       
   195      * @return None
       
   196      */
       
   197     void SendReplyData( TBool aRecvBuffer=ETrue );
       
   198 
       
   199     /**
       
   200      * Manages change in reply type
       
   201      *
       
   202      * @since S60 5.0
       
   203      * @return None
       
   204      */
       
   205     void ManageReplyTypeChange();
       
   206 
       
   207 // from base class CActive
       
   208 
       
   209     /**
       
   210      * From CActive.
       
   211      * Gets called when AT command handled
       
   212      *
       
   213      * @since S60 5.0
       
   214      * @return None
       
   215      */
       
   216     void RunL();
       
   217 
       
   218     /**
       
   219      * From CActive.
       
   220      * Gets called on cancel
       
   221      *
       
   222      * @since S60 5.0
       
   223      * @return None
       
   224      */
       
   225     void DoCancel();
       
   226 
       
   227 // from base class MDunCompletionReporter
       
   228 
       
   229     /**
       
   230      * From MDunCompletionReporter.
       
   231      * Gets called when data push is complete
       
   232      *
       
   233      * @since S60 5.0
       
   234      * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise
       
   235      * @return None
       
   236      */
       
   237     void NotifyDataPushComplete( TBool aAllPushed );
       
   238 
       
   239 private:  // data
       
   240 
       
   241     /**
       
   242      * AT command extension
       
   243      * Not own.
       
   244      */
       
   245     RATExt* iAtCmdExt;
       
   246 
       
   247     /**
       
   248      * Notification interface class for data pushing status changes
       
   249      * Not own.
       
   250      */
       
   251     MDunAtCmdPusher* iCallback;
       
   252 
       
   253     /**
       
   254      * Callback to call when data to push
       
   255      * Not own.
       
   256      */
       
   257     MDunStreamManipulator* iDownstream;
       
   258 
       
   259     /**
       
   260      * Buffer for ok reply
       
   261      * Not own.
       
   262      */
       
   263     TDesC8* iOkBuffer;
       
   264 
       
   265     /**
       
   266      * Current state of AT command handling: active or inactive
       
   267      */
       
   268     TDunState iAtPushState;
       
   269 
       
   270     /**
       
   271      * Buffer for receiving
       
   272      */
       
   273     TBuf8<KDefaultCmdBufLength> iRecvBuffer;
       
   274 
       
   275     /**
       
   276      * Indicates how many bytes of reply left
       
   277      */
       
   278     TInt iReplyBytesLeft;
       
   279 
       
   280     /**
       
   281      * Package for reply bytes left
       
   282      */
       
   283     TPckg<TInt> iReplyLeftPckg;
       
   284 
       
   285     /**
       
   286      * Reply type for the handled AT command
       
   287      */
       
   288     TATExtensionReplyType iReplyType;
       
   289 
       
   290     /**
       
   291      * Package for reply type for the handled AT command
       
   292      */
       
   293     TPckg<TATExtensionReplyType> iReplyTypePckg;
       
   294 
       
   295     /**
       
   296      * Flag indicating if other than "ERROR" reply already received in the
       
   297      * command line
       
   298      */
       
   299     TBool iNoErrorReceived;
       
   300 
       
   301     /**
       
   302      * Flag indicating if the last "OK" reply push is started
       
   303      */
       
   304     TBool iLastOkPush;
       
   305 
       
   306     /**
       
   307      * Flag indicating if abort already tried for one command
       
   308      */
       
   309     TBool iCmdAbort;
       
   310 
       
   311     /**
       
   312      * Flag indicating if stop needed after the next reply
       
   313      */
       
   314     TBool iStop;
       
   315 
       
   316     };
       
   317 
       
   318 #endif  // C_CDUNATCMDPUSHER_H