websrv_pub/hostlet_connection_api/tsrc/hostconnTester/inc/testconsumer.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef __TESTCONSUMER_H__
       
    24 #define __TESTCONSUMER_H__
       
    25 
       
    26 //  EXTERNAL INCLUDES
       
    27 #include <SenServiceConnection.h>
       
    28 
       
    29 //  INTERNAL INCLUDES
       
    30 
       
    31 //  FORWARD DECLARATIONS
       
    32 class ChostconnTester;
       
    33 
       
    34 class CTestConsumer : public CBase, public MSenServiceConsumer
       
    35     {
       
    36     public:
       
    37 
       
    38         /**
       
    39          * Two phase construction
       
    40          */
       
    41         static CTestConsumer* NewL(ChostconnTester* aTestSuite,
       
    42                                    void (*ap2HandleMessageL) (ChostconnTester*, const TDesC8&) = NULL,
       
    43                                    void (*ap2HandleErrorL) (ChostconnTester*, const TInt, const TDesC8&) = NULL,
       
    44                                    void (*ap2SetStatus) (ChostconnTester*, const TInt) = NULL);
       
    45         static CTestConsumer* NewLC(ChostconnTester* aTestSuite,
       
    46                                    void (*ap2HandleMessageL) (ChostconnTester*, const TDesC8&) = NULL,
       
    47                                    void (*ap2HandleErrorL) (ChostconnTester*, const TInt, const TDesC8&) = NULL,
       
    48                                    void (*ap2SetStatus) (ChostconnTester*, const TInt) = NULL);
       
    49         /**
       
    50          * Destructor
       
    51          */
       
    52         ~CTestConsumer();
       
    53 
       
    54         virtual void HandleMessageL(const TDesC8& aMessage);
       
    55 
       
    56         virtual void HandleErrorL(const TInt aErrorCode,
       
    57                                   const TDesC8& aMessage);
       
    58 
       
    59         virtual void SetStatus(const TInt aStatus);
       
    60 
       
    61     public: // Public data => OK in testers, no benefit gained from getters => in real apps, these should be private:
       
    62         
       
    63         RPointerArray<HBufC8>		iResponses; // ok/error => check iErrorCode to determine which
       
    64         RPointerArray<CSenTransportProperties> iResponseProperties;
       
    65         RArray<TInt> 				iResponseCodes;// either error code (if handle error) OR KErrNone (if handle message) 
       
    66         TInt 						iConnectionStatus;
       
    67         TInt 						iTxnId;
       
    68         TInt                        iErrorCode;
       
    69 
       
    70 
       
    71     private:    // Constructor
       
    72         CTestConsumer(ChostconnTester* aTestSuite,
       
    73                       void (*ap2HandleMessageL) (ChostconnTester*, const TDesC8&) = NULL,
       
    74                       void (*ap2HandleErrorL) (ChostconnTester*, const TInt, const TDesC8&) = NULL,
       
    75                       void (*ap2SetStatus) (ChostconnTester*, const TInt) = NULL);
       
    76 
       
    77     private:    // Data
       
    78         ChostconnTester*       ipTestSuite;
       
    79         
       
    80     private:    // Function pointers
       
    81         void (*ip2HandleMessageL) (ChostconnTester*, const TDesC8&);
       
    82         void (*ip2HandleErrorL) (ChostconnTester*, const TInt, const TDesC8&);
       
    83         void (*ip2SetStatus) (ChostconnTester*, const TInt);
       
    84     };
       
    85 
       
    86 #endif      //  __TESTCONSUMER_H__
       
    87 
       
    88 // End of file