presadap12/Parser2/Inc/CPEngTransactionStatus.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Transaction status implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGTRANSACTIONSTATUS_H__
       
    19 #define __CPENGTRANSACTIONSTATUS_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <E32Base.h>
       
    23 #include "MPEngAdvTransactionStatus2.h"
       
    24 
       
    25 
       
    26 //FORWARD DECLARATION
       
    27 class CPEngDetailedResultEntry;
       
    28 class CPEngDataResultEntry;
       
    29 class RReadStream;
       
    30 class RWriteStream;
       
    31 
       
    32 
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37  * Transaction status implementation.
       
    38  *
       
    39  * @lib
       
    40  * @since 3.0
       
    41  */
       
    42 class CPEngTransactionStatus : public CBase, public MPEngAdvTransactionStatus2
       
    43     {
       
    44     public:  // Constructors and destructor
       
    45 
       
    46         /**
       
    47          * Two-phased constructor.
       
    48          */
       
    49         IMPORT_C static CPEngTransactionStatus* NewL();
       
    50 
       
    51 
       
    52 
       
    53         /**
       
    54          * Destructor.
       
    55          */
       
    56         virtual ~CPEngTransactionStatus();
       
    57 
       
    58 
       
    59 
       
    60     private: // Constructors.
       
    61 
       
    62         /**
       
    63          * C++ default constructor.
       
    64          */
       
    65         CPEngTransactionStatus();
       
    66 
       
    67 
       
    68 
       
    69 
       
    70 
       
    71     public: // Functions from MPEngTransactionStatus
       
    72 
       
    73         /**
       
    74          * From MPEngTransactionStatus
       
    75          */
       
    76         TInt Status() const;
       
    77 
       
    78         TInt DetailedResultCount() const;
       
    79         const MPEngDetailedResultEntry2& DetailedResult( TInt aIndex ) const;
       
    80 
       
    81         TInt GetFirstDetailedResultByOperation( TInt aOperationID,
       
    82                                                 const MPEngDetailedResultEntry2*& aDetailedResult );
       
    83         TInt GetNextDetailedResultByOperation( const MPEngDetailedResultEntry2*& aDetailedResult );
       
    84 
       
    85 
       
    86         TInt GetDesc( TPtrC& aDescriptionText,
       
    87                       TPEngTransStatusDescriptionText2 aDescriptionID ) const;
       
    88 
       
    89 
       
    90         TInt GetInt( TUint32& aDescriptionInt,
       
    91                      TPEngTransStatusDescriptionInteger2 aDescriptionID ) const;
       
    92 
       
    93 
       
    94         MPEngTransactionStatusCopy2* CloneLC() const;
       
    95 
       
    96 
       
    97         MPEngTransactionStatusExtension2* StatusExtension();
       
    98 
       
    99 
       
   100 
       
   101     public: // Functions from MPEngTransactionStatusCopy
       
   102 
       
   103         /**
       
   104          * From MPEngTransactionStatusCopy
       
   105          */
       
   106         void Close();
       
   107 
       
   108 
       
   109     public: // Functions from MPEngAdvTransactionStatus
       
   110 
       
   111         /**
       
   112          * From MPEngAdvTransactionStatus
       
   113          */
       
   114         void SetStatus( TInt aStatus );
       
   115         void AddDetailedResultL( TInt aOperationID,
       
   116                                  TInt aErrorCode,
       
   117                                  const TUint32* aAttributeTypeID,
       
   118                                  const TDesC* aPresenceID,
       
   119                                  const TDesC* aContactListID,
       
   120                                  const TDesC* aDescription );
       
   121 
       
   122         void AddDataResultL( TInt aOperationID,
       
   123                              HBufC16* aDataResult );
       
   124 
       
   125         TInt GetFirstDataResultByOperation( TInt aOperationID,
       
   126                                             TPtrC16& aDataResult );
       
   127         TInt GetNextDataResultByOperation( TPtrC16& aDataResult );
       
   128 
       
   129 
       
   130 
       
   131     public: // New functions
       
   132 
       
   133 
       
   134         /**
       
   135          * Resets transaction status object contents.
       
   136          *
       
   137          * Status will be set to KErrNone and
       
   138          * all contained detailed entries are cleared.
       
   139          *
       
   140          * @since 3.0
       
   141          */
       
   142         IMPORT_C void Reset();
       
   143 
       
   144 
       
   145 
       
   146         /**
       
   147          * Imports transaction status data from given object.
       
   148          *
       
   149          * Merges transaction status from given source container
       
   150          * to called object. In merging following rules are used:
       
   151          *
       
   152          * 1. All detailed results from the source container
       
   153          *    are moved as such to the end of existing ones.
       
   154          *
       
   155          * 2. Transaction status code is handled following way:
       
   156          *
       
   157          * Status code in           Status code                 Destination container
       
   158          * destination container    in source container   ===>  end state
       
   159          * KErrNone                 KErrNone                    KErrNone
       
   160          * KErrNone                 KErrCode1                   KErrCode1
       
   161          * KErrCode1                KErrNone                    KErrCode1
       
   162          * KErrCode1                KErrCode1                   KErrCode1
       
   163          * KErrCode1                KErrCode2                   KErrCode1
       
   164          *
       
   165          * ===> First found error is kept in importing container.
       
   166          *
       
   167          * NOTE: Import succeeds always. Takes the ownership of
       
   168          * parameter container.
       
   169          *
       
   170          * @since 3.0
       
   171          * @param aContainerToImport The container to merge.
       
   172          * Takes the ownership.
       
   173          */
       
   174         IMPORT_C void ImportStatusFrom( CPEngTransactionStatus& aSource );
       
   175 
       
   176 
       
   177 
       
   178         /**
       
   179          * Creates a new deep copy from transaction status object.
       
   180          *
       
   181          * Creates a deep copy from transaction status object and
       
   182          * returns it ownership to client. Created object is placed
       
   183          * on the CleanupStack.
       
   184          *
       
   185          * This copy holds also internal data results.
       
   186          * CloneLC() for external clients doesn't copy data results.
       
   187          *
       
   188          * Only data is copied. Cached settings like criterias
       
   189          *
       
   190          * @since 3.0
       
   191          * @return New copy from CPEngTransactionStatus.
       
   192          * Ownership of created object is returned to calling client.
       
   193          */
       
   194         IMPORT_C CPEngTransactionStatus* FullCloneLC() const;
       
   195 
       
   196 
       
   197         /**
       
   198          * Packs the transaction status and possible data results
       
   199          * as one HBufC8.
       
   200          *
       
   201          * @since 3.0
       
   202          * @return Transaction result package.
       
   203          *         Buffer ownership is returned to caller.
       
   204          */
       
   205         IMPORT_C HBufC8* PackResultsL() const;
       
   206 
       
   207 
       
   208         /**
       
   209          * Extracts transaction results from package.
       
   210          *
       
   211          * Extracts the transaction status and possible data results
       
   212          * from package.
       
   213          *
       
   214          * @since 3.0
       
   215          * @param aResultPkg Transaction result package.
       
   216          */
       
   217         IMPORT_C void UnpackResultsL( const TDesC8& aResultPkg );
       
   218 
       
   219 
       
   220 
       
   221 
       
   222 
       
   223     private: // Helper functions.
       
   224 
       
   225 
       
   226         /**
       
   227          * Gets next by required operation type.
       
   228          */
       
   229         TInt LocateNextDetailByOperation( const MPEngDetailedResultEntry2*& aDetailedResult );
       
   230         TInt LocateNextDataByOperation( TPtrC16& aDataResult );
       
   231 
       
   232         /**
       
   233          * Merges imported containers status code to local one.
       
   234          * See MPEngTransactionStatus for merging rules.
       
   235          */
       
   236         void MergeStatusCodes( const CPEngTransactionStatus& aSource );
       
   237 
       
   238 
       
   239         /**
       
   240          * Approximates the needed stream length needed to
       
   241          * externalize the object data.
       
   242          *
       
   243          * @since 3.0
       
   244          * @return Approximation of needed space in bytes.
       
   245          */
       
   246         TInt ExternalizeSize() const;
       
   247 
       
   248 
       
   249         /**
       
   250          * Externalizes objects state to given write stream.
       
   251          *
       
   252          * @since 3.0
       
   253          */
       
   254         void ExternalizeL( RWriteStream& aStream ) const;
       
   255 
       
   256 
       
   257         /**
       
   258          * Internalizes this objects state from given
       
   259          * read stream. Before reading, previous
       
   260          * contents are reseted.
       
   261          *
       
   262          * @since 3.0
       
   263          */
       
   264         void InternalizeL( RReadStream& aStream );
       
   265 
       
   266 
       
   267         /**
       
   268          * Clones transaction container base data.
       
   269          * e.g. status code and detailed results
       
   270          * visible to external clients.
       
   271          *
       
   272          * @since 3.0
       
   273          * @return New cloned CPEngTransactionStatus instance.
       
   274          */
       
   275         CPEngTransactionStatus* BaseCloneLC() const;
       
   276 
       
   277 
       
   278         /**
       
   279          * Panics with given reason.
       
   280          */
       
   281         static void Panic( TInt aReason );
       
   282 
       
   283 
       
   284 
       
   285     private:    // Data
       
   286 
       
   287 
       
   288         //OWN: Detailed results
       
   289         TSglQue<CPEngDetailedResultEntry>  iDetailedResultsQ;
       
   290 
       
   291         //OWN: Detailed results iterator
       
   292         TSglQueIter<CPEngDetailedResultEntry> iDetailedResultsQIter;
       
   293 
       
   294         //OWN: Count of detailed results
       
   295         TInt    iDetailedResultsCount;
       
   296 
       
   297         //OWN: Operation ID for detailed results filtered access
       
   298         TInt    iDetResCurrentOperationId;
       
   299 
       
   300         //OWN: Current index for  detailed results filtered access
       
   301         TInt    iDetResCurrentIndex;
       
   302 
       
   303 
       
   304 
       
   305 
       
   306         //OWN: Data results
       
   307         TSglQue<CPEngDataResultEntry>  iDataResultsQ;
       
   308 
       
   309         //OWN: Data results iterator
       
   310         TSglQueIter<CPEngDataResultEntry> iDataResultsQIter;
       
   311 
       
   312         //OWN: Count of data results
       
   313         TInt    iDataResultsCount;
       
   314 
       
   315         //OWN: Operation ID for for data results filtered access
       
   316         TInt    iDataResCurrentOperationId;
       
   317 
       
   318         //OWN: Current index for data results filtered access
       
   319         TInt    iDataResCurrentIndex;
       
   320 
       
   321 
       
   322 
       
   323 
       
   324         //OWN: Transaction result code, owned
       
   325         TInt    iStatusCode;
       
   326 
       
   327 
       
   328     };
       
   329 
       
   330 
       
   331 #endif      //  __CPENGTRANSACTIONSTATUS_H__
       
   332 
       
   333 // End of File
       
   334 
       
   335