data/publisherif/inc/transaction.h
changeset 0 b856a9924bbc
equal deleted inserted replaced
-1:000000000000 0:b856a9924bbc
       
     1 /*
       
     2 * Copyright (c) {Year(s)} {Copyright owner}.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * {Name} {Company} ? Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * {Name} {Company} ? {{Description of contribution}}
       
    14 *
       
    15 * Description:
       
    16 * {{Description of the file}}
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __TRANSACTION_H__
       
    22 #define __TRANSACTION_H__
       
    23 
       
    24 // System includes 
       
    25 #include <e32base.h>
       
    26 
       
    27 // User includes
       
    28 
       
    29 // Forward declarations
       
    30 
       
    31 // Constants
       
    32 
       
    33 // CTransactionItem Class declaration
       
    34 NONSHARABLE_CLASS( CTransactionItem ) : public CBase
       
    35     {
       
    36 public:
       
    37     // constrcutor and destructor
       
    38 
       
    39     /**
       
    40      * C++ constructor
       
    41      */
       
    42     CTransactionItem( const TDesC8& aElementId );        
       
    43     
       
    44     /**
       
    45      * Destructor
       
    46      */
       
    47     ~CTransactionItem();
       
    48 
       
    49 public:
       
    50     // new functions
       
    51     
       
    52     /**
       
    53      * Returns this transaction's element id.
       
    54      * 
       
    55      * @return Transaction element id.
       
    56      */
       
    57     const TDesC8& ElementId() const;
       
    58     
       
    59     /**
       
    60      * Returns this transaction's content type.
       
    61      * To be overriden by sub-classes.
       
    62      * 
       
    63      * @return Transaction element type. 
       
    64      */
       
    65     virtual const TDesC8& Type() const = 0;
       
    66     
       
    67 protected:
       
    68     // data
       
    69     
       
    70     /** Transaction's element id, owned */
       
    71     HBufC8* iElementId;
       
    72     };
       
    73 
       
    74 // CImageTransactionItem Class declaration
       
    75 NONSHARABLE_CLASS( CImageTransactionItem ) : public CTransactionItem
       
    76     {
       
    77 public:
       
    78     // constructors and destructor
       
    79 
       
    80     /**
       
    81      * C++ constructor
       
    82      */
       
    83     CImageTransactionItem( 
       
    84         const TDesC8& aElementId, 
       
    85         TInt aImageHandle, 
       
    86         TInt aMaskHandle );
       
    87     
       
    88     /**
       
    89      * C++ constructor
       
    90      */    
       
    91     CImageTransactionItem( 
       
    92         const TDesC8& aElementId, 
       
    93         const TDesC& aPath );
       
    94     
       
    95     /**
       
    96      * Destructor
       
    97      */    
       
    98     ~CImageTransactionItem();
       
    99     
       
   100 public:
       
   101     // from CTransactionItem
       
   102     
       
   103     /**
       
   104      * @see CTransactionItem
       
   105      */
       
   106     const TDesC8& Type() const;
       
   107     
       
   108 public:
       
   109     // new functions
       
   110     
       
   111     /** 
       
   112      * Gets transaction's image handle.
       
   113      * Notice that path and handles are mutually exclusice in one transaction.
       
   114      * 
       
   115      * @return Image handle
       
   116      */
       
   117     TInt ImageHandle() const;
       
   118 
       
   119     /** 
       
   120      * Gets transaction's mask handle.
       
   121      * Notice that path and handles are mutually exclusice in one transaction.
       
   122      * 
       
   123      * @return Mask handle
       
   124      */    
       
   125     TInt MaskHandle() const;
       
   126 
       
   127     /** 
       
   128      * Gets transaction's path. 
       
   129      * Notice that path and handles are mutually exclusice in one transaction.
       
   130      * 
       
   131      * @return Path
       
   132      */        
       
   133     const TDesC& Path() const;
       
   134     
       
   135 private:
       
   136     // data
       
   137             
       
   138     /** Transaction's data, caller must maintain the bitmap alive */
       
   139     TInt iImageHandle;
       
   140     /** Transaction's data, caller must maintain the bitmap alive */
       
   141     TInt iMaskHandle;
       
   142     /** Transaction's data, owned */
       
   143     HBufC* iPath;
       
   144     };
       
   145 
       
   146 // CTextTransactionItem Class declaration
       
   147 NONSHARABLE_CLASS( CTextTransactionItem ) : public CTransactionItem 
       
   148     {
       
   149 public:    
       
   150     // constructors and destructor
       
   151 
       
   152     /**
       
   153      * C++ constructor
       
   154      */
       
   155     CTextTransactionItem( 
       
   156         const TDesC8& aElementId, 
       
   157         const TDesC& aText );
       
   158     
       
   159     /**
       
   160      * Destructor
       
   161      */        
       
   162     ~CTextTransactionItem();
       
   163     
       
   164 public:
       
   165     // from CTransactionItem
       
   166 
       
   167     /**
       
   168      * @see CTransactionItem
       
   169      */
       
   170     const TDesC8& Type() const;
       
   171 
       
   172 public:
       
   173     // new functions
       
   174     
       
   175     /**
       
   176      * Gets transaction's text
       
   177      * 
       
   178      * @return Text
       
   179      */
       
   180     const TDesC& Text() const;
       
   181     
       
   182 private:
       
   183     // data
       
   184     
       
   185     /** Transaction's data, owned */
       
   186     HBufC* iText;
       
   187     };
       
   188 
       
   189 // CDataTransactionItem Class declaration
       
   190 NONSHARABLE_CLASS( CDataTransactionItem ) : public CTransactionItem 
       
   191     {
       
   192 public:    
       
   193     // constructors and destructor
       
   194 
       
   195     /**
       
   196      * C++ constructor
       
   197      */
       
   198     CDataTransactionItem( 
       
   199         const TDesC8& aElementId, 
       
   200         const TDesC8& aData );
       
   201     
       
   202     /**
       
   203      * Destructor
       
   204      */        
       
   205     ~CDataTransactionItem();
       
   206     
       
   207 public:
       
   208     // from CTransactionItem
       
   209 
       
   210     /**
       
   211      * @see CTransactionItem
       
   212      */
       
   213     const TDesC8& Type() const;
       
   214 
       
   215 public:
       
   216     // new functions
       
   217     
       
   218     /**
       
   219      * Gets transaction's data
       
   220      * 
       
   221      * @return Data
       
   222      */
       
   223     const TDesC8& Data() const;
       
   224     
       
   225 private:
       
   226     // data
       
   227     
       
   228     /** Transaction's data, owned */
       
   229     HBufC8* iData;
       
   230     };
       
   231 
       
   232 
       
   233 // CTransaction Class declaration
       
   234 NONSHARABLE_CLASS( CTransaction ) : public CBase
       
   235     {
       
   236 public:
       
   237     // constructors and destructor
       
   238 
       
   239     /**
       
   240      * C++ constructor
       
   241      */
       
   242     CTransaction( 
       
   243         const TDesC& aWidgetId ); 
       
   244     
       
   245     /**
       
   246      * Destructor
       
   247      */            
       
   248     ~CTransaction();
       
   249 
       
   250 public:
       
   251     // new functions
       
   252     
       
   253     /**
       
   254      * Equals operator
       
   255      * 
       
   256      * @param aWidgetId Widget id to use in comparision
       
   257      * @return ETrue if this transaction matches to aWidgetId, EFalse otherwise
       
   258      */
       
   259     TBool operator== ( const TDesC& aWidgetId ) const;
       
   260 
       
   261     /**
       
   262      * Appends transaction item to transaction items array.
       
   263      * 
       
   264      * @param aItem Transaction item. This transaction takes item's ownership.
       
   265      */
       
   266     void AppendL( CTransactionItem* aItem );
       
   267 
       
   268     /**
       
   269      * Gets transaction items from this transaction.
       
   270      * 
       
   271      * @return Transaction items. 
       
   272      */    
       
   273     const RPointerArray< CTransactionItem >& Items() const;
       
   274     
       
   275 private:    
       
   276     // data
       
   277     
       
   278     /** Transaction items, owned */
       
   279     mutable RPointerArray< CTransactionItem > iItems;
       
   280     /** Transaction's id, same as widget id */
       
   281     const TDesC& iWidgetId;    
       
   282     };
       
   283 
       
   284 #endif // __TRANSACTION_H__
       
   285 
       
   286 // End of file