atext/plugins/limitedpdpplugin/inc/limitedpdpplugin.h
branchRCL_3
changeset 22 786b94c6f0a4
equal deleted inserted replaced
21:14e240312f6f 22:786b94c6f0a4
       
     1 /*
       
     2  * Copyright (c) 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:  Main handler for incoming requests
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef C_LIMITEDPDPPLUGIN_H
       
    19 #define C_LIMITEDPDPPLUGIN_H
       
    20 
       
    21 #include <atextpluginbase.h>
       
    22 #include <e32base.h>
       
    23 #include <e32property.h>
       
    24 
       
    25 /**
       
    26  *  Class for selecting handlers for different AT commands
       
    27  *
       
    28  *  @since TB9.2
       
    29  */
       
    30 NONSHARABLE_CLASS( CLimitedPdpPlugin ) : public CATExtPluginBase
       
    31     {
       
    32 
       
    33 public:
       
    34 
       
    35     /**
       
    36      * Two-phased constructor.
       
    37      * @return Instance of self
       
    38      */
       
    39     static CLimitedPdpPlugin* NewL();
       
    40 
       
    41     /**
       
    42      * Destructor.
       
    43      */
       
    44     virtual ~CLimitedPdpPlugin();
       
    45 
       
    46 private:
       
    47 
       
    48     CLimitedPdpPlugin();
       
    49 
       
    50     void ConstructL();
       
    51 
       
    52     /**
       
    53      * Reports connection identifier name to the extension plugin.
       
    54      *
       
    55      * @since TB9.2
       
    56      * @param aName Connection identifier name
       
    57      * @return None
       
    58      */
       
    59     void ReportConnectionName( const TDesC8& aName );
       
    60 
       
    61     /**
       
    62      * Reports the support status of an AT command. This is synchronous API.
       
    63      *
       
    64      * @since TB9.2
       
    65      * @param aCmd The AT command. Its format may vary depending on the
       
    66      *             specification. 
       
    67      *             a character carriage return (<cr>) in the end.
       
    68      * @return ETrue if the command is supported; EFalse otherwise.
       
    69      */
       
    70     TBool IsCommandSupported( const TDesC8& aCmd );
       
    71 
       
    72     /**
       
    73      * Handles an AT command. Cancelling of the pending request is done by
       
    74      * HandleCommandCancel(). The implementation in the extension plugin
       
    75      * should be asynchronous. However, in this case, WE MUST IMPLEMENT THE 
       
    76      * PLUGIN synchronously and BLOCK ATEXT THREAD WHILE EXISTING CONNECTIONS
       
    77      * ARE BEING CLOSED. This is due to the fact that this plugin is an 
       
    78      * observer and the modem AT command handler is issued immediately after
       
    79      * this command returns. This has a couple of drawbacks:
       
    80      * 1. ATEXT thread is blocked, which is against the requirements
       
    81      * 2. Cancelling of this operation is not supported.
       
    82      * 
       
    83      * The extension plugin which accepts this command is responsible to
       
    84      * supply result codes and response and to format result codes properly.
       
    85      *
       
    86      * After an extension plugin has handled or decided to reject given AT
       
    87      * command, it must inform ATEXT by HandleCommandCompleted() with proper
       
    88      * error code.
       
    89      *
       
    90      * @since TB9.2
       
    91      * @param aCmd The AT command to be handled. 
       
    92      * @param aReply When passed in, contains the built in answer filled by
       
    93      *               ATEXT if it is not empty; when command handling
       
    94      *               completes successfully, contains the result codes and 
       
    95      *               responses to this command 
       
    96      * @param aReplyNeeded Reply needed if ETrue, no reply otherwise. 
       
    97      * @return None
       
    98      */
       
    99     void
       
   100             HandleCommand( const TDesC8& aCmd,
       
   101                            RBuf8& aReply,
       
   102                            TBool aReplyNeeded );
       
   103 
       
   104     /**
       
   105      * Cancels a pending HandleCommand request.
       
   106      *
       
   107      * @since TB9.2
       
   108      * @return None
       
   109      */
       
   110     void HandleCommandCancel();
       
   111 
       
   112     /**
       
   113      * Next reply part's length.
       
   114      * The value must be equal or less than KDefaultCmdBufLength.
       
   115      * When the reply from this method is zero, ATEXT stops calling
       
   116      * GetNextPartOfReply().
       
   117      *
       
   118      * @since TB9.2
       
   119      * @return Next reply part's length if zero or positive
       
   120      */
       
   121     TInt NextReplyPartLength();
       
   122 
       
   123     /**
       
   124      * Gets the next part of reply initially set by HandleCommandComplete().
       
   125      * Length of aNextReply must be equal or less than KDefaultCmdBufLength.
       
   126      *
       
   127      * @since TB9.2
       
   128      * @param aNextReply Next reply
       
   129      * @return Symbian error code on error, KErrNone otherwise
       
   130      */
       
   131     TInt GetNextPartOfReply( RBuf8& aNextReply );
       
   132 
       
   133     /**
       
   134      * Receives unsolicited results. Cancelling of pending request is done
       
   135      * by ReceiveUnsolicitedResultCancel(). The implementation in extension
       
   136      * plugin should be asynchronous.
       
   137      *
       
   138      * @since TB9.2
       
   139      * @return None
       
   140      */
       
   141     void ReceiveUnsolicitedResult();
       
   142 
       
   143     /**
       
   144      * Cancels a pending ReceiveUnsolicitedResult request.
       
   145      *
       
   146      * @since TB9.2
       
   147      * @return None
       
   148      */
       
   149     void ReceiveUnsolicitedResultCancel();
       
   150 
       
   151     /**
       
   152      * Reports NVRAM status change to the plugins.
       
   153      *
       
   154      * @since TB9.2
       
   155      * @param aNvram New NVRAM status. Each call of this function is a result
       
   156      *               of DUN extracting the form notified by
       
   157      *               CATExtCommonBase::SendNvramStatusChange(). Each of the
       
   158      *               settings from SendNvramStatusChange() is separated to
       
   159      *               one call of ReportNvramStatusChange().
       
   160      * @return None
       
   161      */
       
   162     void ReportNvramStatusChange( const TDesC8& aNvram );
       
   163 
       
   164     /**
       
   165      * Reports about external handle command error condition.
       
   166      * This is for cases when for example DUN decided the reply contained an
       
   167      * error condition but plugin is still handling the command internally.
       
   168      * This solution keeps the pointer to the last AT command handling plugin
       
   169      * inside ATEXT and calls this function there to report the error.
       
   170      * It is to be noted that HandleCommandCancel() is not sufficient to stop
       
   171      * the processing as the command handling has already finished.
       
   172      *
       
   173      * @since TB9.2
       
   174      * @return None
       
   175      */
       
   176     void ReportExternalHandleCommandError();
       
   177 
       
   178     /**
       
   179      * Checks whether this feature is on or off. Reads the value from CenRep
       
   180      * and stores it to the internal variable.
       
   181      *
       
   182      * @since TB9.2
       
   183      * @return ETrue if enabled, EFalse otherwise
       
   184      */
       
   185     TBool CheckFeatureEnablement();
       
   186 
       
   187     /**
       
   188      * Closes existing connections by setting PS key to ConnMon
       
   189      *
       
   190      * @since TB9.2
       
   191      * @return KErrNone if successful, otherwise Symbian error code
       
   192      */
       
   193     TInt CloseExistingConnections();
       
   194 
       
   195     /**
       
   196      * Blocks thread until ConnMon indicates that existing packet data
       
   197      * connections are closed. Operation is guarded by a timeout.
       
   198      *
       
   199      * @since TB9.2
       
   200      * @return KErrNone if successful, otherwise Symbian error code
       
   201      */
       
   202     TInt BlockThreadUntilConnectionsClosed();
       
   203 
       
   204 private:
       
   205     // data
       
   206 
       
   207     /**
       
   208      * Property handle used for communication with Connection monitor
       
   209      */
       
   210     RProperty iProperty;
       
   211 
       
   212     /**
       
   213      * Timer handle used for timeouting the ongoinging operation. Used for
       
   214      * cancelling the closing of existing PDP contexts in case the operation
       
   215      * takes too long.
       
   216      */
       
   217     RTimer iCancelTimer;
       
   218 
       
   219     /**
       
   220      * Value indicating whether this feature is enabled
       
   221      */
       
   222     TBool iFeatureSupported;
       
   223 
       
   224     };
       
   225 
       
   226 #endif  // C_LIMITEDPDPPLUGIN_H