presadap12/impsplugin/inc/cimpspluginsenddataoperation.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2006 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: This is a class handling sending data
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CIMPSPLUGINSENDDATAOPERATION_H__
       
    19 #define __CIMPSPLUGINSENDDATAOPERATION_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include    <E32Std.h>
       
    23 
       
    24 #include 	"impsdebugprint.h"
       
    25 
       
    26 // WV Engine walk around
       
    27 #include    <impspurecli.h>
       
    28 
       
    29 // FORWARD DECLARATION
       
    30 class RImpsEng;
       
    31 
       
    32 // CONSTANTS
       
    33 /**
       
    34  * Send operation repeat time
       
    35  */
       
    36 const TInt KSendOperationRepeatTime = 100000;
       
    37 
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42  * Send data operation holder
       
    43  *
       
    44  * @since 3.0
       
    45  */
       
    46 NONSHARABLE_CLASS( CImpsPluginSendDataOperation ) :
       
    47         public CBase
       
    48     {
       
    49 public:
       
    50     /**
       
    51      *  Default constructor
       
    52      */
       
    53     static inline CImpsPluginSendDataOperation* NewLC();
       
    54 
       
    55     inline CImpsPluginSendDataOperation()
       
    56             : iOpId( KErrNone ),
       
    57             iData( NULL )
       
    58         {
       
    59         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::CImpsPluginSendDataOperation Start End" ) );
       
    60         }
       
    61 
       
    62     /**
       
    63      *  Destructor
       
    64      */
       
    65     inline ~CImpsPluginSendDataOperation()
       
    66         {
       
    67         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::~CImpsPluginSendDataOperation Start" ) );
       
    68         delete iData;
       
    69         if ( iStatus )
       
    70             {
       
    71             User::RequestComplete( iStatus, KErrCancel );
       
    72             }
       
    73         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::~CImpsPluginSendDataOperation End" ) );
       
    74         }
       
    75 
       
    76 public: // new function of the class
       
    77 
       
    78 
       
    79     /**
       
    80      * Set ids, operation and log id
       
    81      * @since 3.0
       
    82      */
       
    83     inline void SetIds( TInt aOperationId, TInt aLogId )
       
    84         {
       
    85         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::SetIds Start" ) );
       
    86         iOpId = aOperationId;
       
    87         iLogId = aLogId;
       
    88         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::SetIds End" ) );
       
    89         };
       
    90 
       
    91     inline void SetRequestStatus( TRequestStatus& aStatus )
       
    92         {
       
    93         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::SetRequestStatus Start" ) );
       
    94         iStatus = &aStatus;
       
    95         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::SetRequestStatus End" ) );
       
    96         };
       
    97 
       
    98     /**
       
    99      * Trequest status of this operation
       
   100      *
       
   101      * @since 3.0
       
   102      */
       
   103     inline TRequestStatus* Status()
       
   104         {
       
   105         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::Status Start-End" ) );
       
   106         return iStatus;
       
   107         }
       
   108 
       
   109     /**
       
   110      * Get Ids
       
   111      *
       
   112      * @since 3.0
       
   113      * @return operation Id
       
   114      */
       
   115     inline TInt OperationId() const
       
   116         {
       
   117         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::OperationId Start-End" ) );
       
   118         return iOpId;
       
   119         }
       
   120 
       
   121     inline TInt LogId() const
       
   122         {
       
   123         IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::LogId Start-End" ) );
       
   124         return iLogId;
       
   125         }
       
   126 
       
   127     /**
       
   128      * Complete operation
       
   129      *
       
   130      * @since 3.0
       
   131      * @param aCode complete code
       
   132      */
       
   133     inline void CompletedOperation( TInt aCode );
       
   134 
       
   135     /**
       
   136      * Set response buffer
       
   137      * Owner ship is transfered
       
   138      *
       
   139      * @since 3.0
       
   140      * @param aBuff response buffer
       
   141      */
       
   142     inline void SetResponse( HBufC8* aBuff );
       
   143 
       
   144     /**
       
   145      * Response buffer,
       
   146      * owner ship is transfered
       
   147      *
       
   148      * @since 3.0
       
   149      * @return transfer buffer
       
   150      */
       
   151     inline HBufC8* Response();
       
   152 
       
   153 private: // Public data
       
   154 
       
   155     /// Status of the operation
       
   156     TRequestStatus*     iStatus;
       
   157 
       
   158     /// OWN: Operation Id
       
   159     TInt                iOpId;
       
   160 
       
   161     /// OWN: Response buffer
       
   162     HBufC8*             iData;
       
   163 
       
   164     /// OWN: Id used for logs writting
       
   165     TInt                iLogId;
       
   166     };
       
   167 
       
   168 /**
       
   169  * NewLC
       
   170  */
       
   171 inline CImpsPluginSendDataOperation* CImpsPluginSendDataOperation::NewLC()
       
   172     {
       
   173     IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::NewLC Start-End" ) );
       
   174     CImpsPluginSendDataOperation* self = new( ELeave )
       
   175     CImpsPluginSendDataOperation();
       
   176 
       
   177     CleanupStack::PushL( self );
       
   178     IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::NewLC End" ) );
       
   179     return self;
       
   180     }
       
   181 
       
   182 /**
       
   183  * Complete operation
       
   184  */
       
   185 inline void CImpsPluginSendDataOperation::CompletedOperation( TInt aCode )
       
   186     {
       
   187     IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::CompletedOperation Start :id:%d,code:%d" ),
       
   188              iOpId,
       
   189              aCode );
       
   190     if ( !iStatus )
       
   191         {
       
   192         IMPS_DP(
       
   193             D_IMPS_LIT( "CImpsPluginSendDataOperation::CompletedOperation:!!Double Completion!!!" ) );
       
   194         return;
       
   195         }
       
   196     User::RequestComplete( iStatus, aCode );
       
   197     iStatus = NULL;
       
   198     }
       
   199 
       
   200 /**
       
   201  * Set response
       
   202  */
       
   203 inline void CImpsPluginSendDataOperation::SetResponse( HBufC8* aBuff )
       
   204     {
       
   205     IMPS_DP( D_IMPS_LIT( "CPEngPureDataHandler::SetResponse - id:  %d" ), iOpId );
       
   206     delete iData;
       
   207     iData = aBuff;
       
   208     IMPS_DP( D_IMPS_LIT( "CImpsPluginSendDataOperation::SetResponse End" ) );
       
   209     }
       
   210 
       
   211 /**
       
   212  * Get response
       
   213  */
       
   214 inline HBufC8* CImpsPluginSendDataOperation::Response()
       
   215     {
       
   216     IMPS_DP( D_IMPS_LIT( "CPEngPureDataHandler::Response Start" ) );
       
   217     HBufC8* b = iData;
       
   218     iData = NULL;
       
   219     IMPS_DP( D_IMPS_LIT( "CPEngPureDataHandler::Response End" ) );
       
   220     return b;
       
   221     }
       
   222 
       
   223 #endif      // __CIMPSPLUGINSENDDATAOPERATION_H__
       
   224 
       
   225 // End of File