dosservices/commondsy/inc/CDSYMessageBufferItem.h
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 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:  Declaration of CCDSYMessageBufferItem class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CDSYMESSAGEBUFFERITEM_H
       
    20 #define CDSYMESSAGEBUFFERITEM_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 
       
    26 
       
    27 // CONSTANTS
       
    28 // MACROS
       
    29 // DATA TYPES
       
    30 // FUNCTION PROTOTYPES
       
    31 // FORWARD DECLARATIONS
       
    32 class CCDSYController;
       
    33 class TCDSYMessage;
       
    34 class CCDSYDOSServerRequestManager;
       
    35 
       
    36 
       
    37 
       
    38 /**
       
    39 *  CCDSYMessageBufferItem
       
    40 *  This class implements the CCDSYMessageBufferItem, which keeps the DSY message in buffer and waits for the response.
       
    41 */
       
    42 NONSHARABLE_CLASS( CCDSYMessageBufferItem ): public CBase
       
    43     {
       
    44     public:
       
    45         /**
       
    46         * Destructor.
       
    47         */
       
    48         ~CCDSYMessageBufferItem();
       
    49 
       
    50         /**
       
    51         * Creates a new instance of CCDSYMessageBufferItem.
       
    52         * @param CCDSYController& aCDSYController                           Reference to CCDSYController.
       
    53         * @param CCDSYDOSServerRequestManager& aCDSYDOSServerRequestManager Reference to CCDSYDOSServerRequestManager.
       
    54         * @param TCDSYMessage& aCDSYMessage                                 Reference to the message to be sent.
       
    55         * @return static CCDSYMessageBufferItem*                            Pointer to instance of CCDSYMessageBufferItem.
       
    56         */
       
    57         static CCDSYMessageBufferItem* NewL( CCDSYController& aCDSYController, CCDSYDOSServerRequestManager& aCDSYDOSServerRequestManager, TCDSYMessage& aCDSYMessage );
       
    58 
       
    59         /**
       
    60         * Creates a new instance of CCDSYMessageBufferItem.
       
    61         * @param CCDSYController& aCDSYController                           Reference to CCDSYController.
       
    62         * @param CCDSYDOSServerRequestManager& aCDSYDOSServerRequestManager Reference to CCDSYDOSServerRequestManager.
       
    63         * @param TCDSYMessage& aCDSYMessage                                 Reference to the message to be sent.
       
    64         * @param RMessagePtr2 aMessage                                      Client/server message.
       
    65         * @return static CCDSYMessageBufferItem*                            Pointer to instance of CCDSYMessageBufferItem.
       
    66         */
       
    67         static CCDSYMessageBufferItem* NewL( CCDSYController& aCDSYController, CCDSYDOSServerRequestManager& aCDSYDOSServerRequestManager, TCDSYMessage& aCDSYMessage, RMessagePtr2 aMessage );
       
    68         
       
    69         /**
       
    70         * Sends the message to the controller and waits for the response.
       
    71         * @return void
       
    72         */
       
    73         void SendMessageL();
       
    74 
       
    75         /**
       
    76         * Processes the response to the message sent.
       
    77         * @param const TCDSYMessage& aCDSYMessage   Reference to CCDSYMessage to be sent.
       
    78         * @return void 
       
    79         */
       
    80         void ProcessResponseL( const TCDSYMessage& aCDSYMessage );
       
    81 
       
    82         /**
       
    83         * Cancels the Async command.
       
    84         * @param TInt aReason   Cancel reason.
       
    85         * @return void 
       
    86         */
       
    87         void CancelAsyncCommand( TInt aReason ) const;
       
    88 
       
    89         /**
       
    90         * Returns the messages transaction ID.
       
    91         * @return TUint32       Transaction ID.
       
    92         */
       
    93         inline TUint32 TransactionID() const
       
    94             {
       
    95             return iTransactionID;
       
    96             }
       
    97 
       
    98         /**
       
    99         * Returns if the message is Async.
       
   100         * @return TBool         Async flag.
       
   101         */
       
   102         inline TBool IsAsyncMessage()
       
   103             {
       
   104             return !iClientServerMessage.IsNull();
       
   105             }
       
   106 
       
   107     private:
       
   108         /**
       
   109         * Constructor.
       
   110         * @param CCDSYController& aCDSYController                           Reference to CCDSYController.
       
   111         * @param CCDSYDOSServerRequestManager& aCDSYDOSServerRequestManager Reference to CCDSYDOSServerRequestManager.
       
   112         * @param TCDSYMessage& aCDSYMessage                                 Reference to the message to be sent.
       
   113         */
       
   114         CCDSYMessageBufferItem( CCDSYController& aCDSYController, CCDSYDOSServerRequestManager& aCDSYDOSServerRequestManager, TCDSYMessage& aCDSYMessage );
       
   115 
       
   116         /**
       
   117         * 2nd phase constructor.
       
   118         * @return void 
       
   119         */
       
   120         void ConstructL();
       
   121 
       
   122         /**
       
   123         * Starts waiting for the resopnse to the message.
       
   124         * @return void 
       
   125         */
       
   126         void BeginActiveWait();
       
   127 
       
   128         /**
       
   129         * Ends the waiting for the response to the message.
       
   130         * @return void 
       
   131         */
       
   132         void EndActiveWait();
       
   133 
       
   134         /**
       
   135         * Timer callback function.
       
   136         * @param TAny* aPtr     Pointer to data.
       
   137         * @return static TInt   Error code.
       
   138         */
       
   139         static TInt NotifyTimerCallback( TAny* aPtr );
       
   140 
       
   141         /**
       
   142         * Timer callback function.
       
   143         * @return void 
       
   144         */
       
   145         void DoNotifyTimerCallbackL();
       
   146 
       
   147     private:
       
   148         CCDSYController& iCDSYController;                           // Reference to CCDSYController
       
   149         CCDSYDOSServerRequestManager& iCDSYDOSServerRequestManager; // Request manager
       
   150         TCDSYMessage* iCDSYMessage;                                 // Message in buffer
       
   151         HBufC8* iMessageData;                                       // Messages data
       
   152         TBool iMessageOwned;                                        // The owned flag tells the destructor that the message needs to be deleted
       
   153         TBool iActiveWait;                                          // Wait boolean flag
       
   154         CActiveSchedulerWait iWait;                                 // Wait object
       
   155         CPeriodic* iTimer;                                          // Expiration timer
       
   156         TUint32 iTransactionID;                                     // Messages transaction ID
       
   157         RMessagePtr2 iClientServerMessage;                          // Async message
       
   158     };
       
   159 
       
   160 
       
   161 
       
   162 #endif //#ifndef CDSYMESSAGEBUFFERITEM_H
       
   163 
       
   164 
       
   165 
       
   166 //  End of File