idlefw/plugins/devicestatus/inc/aicontentobserveroptimizer.h
changeset 0 79c6a41cd166
child 8 d0529222e3f0
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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:  Active Idle Content Observer optimizer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_AIMULTICONTENTOBSERVEROPTIMIZER_H
       
    20 #define C_AIMULTICONTENTOBSERVEROPTIMIZER_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include "aicontentobserver.h"
       
    25 
       
    26 /**
       
    27  *  @ingroup group_devicestatusplugin
       
    28  *
       
    29  * Active Idle Content Observer optimizer. 
       
    30  * 
       
    31  * Optimizes the Commit calls to different UI controllers. In 
       
    32  * case nothing is published nothing is committed.
       
    33  *
       
    34  * @see MAiContentObserver
       
    35  * @since S60 3.2
       
    36  */
       
    37 class CAiContentObserverOptimizer : public CBase      
       
    38     {
       
    39 
       
    40 private:
       
    41     struct TAiPublishBlackList
       
    42         {
       
    43         TInt iContentId;
       
    44         
       
    45         TInt iIndex;              
       
    46         };
       
    47 
       
    48 public:
       
    49     static CAiContentObserverOptimizer* NewL(MAiContentObserver& aObserver);
       
    50     ~CAiContentObserverOptimizer();
       
    51     
       
    52     /**
       
    53      * Starts a transaction
       
    54      * 
       
    55      * @return KErrAlreadyExists in case transaction already ongoing. 
       
    56      *         KErrNotSupported in case transaction not supported
       
    57      *         KErrNone in case transaction succesfuly started
       
    58      */
       
    59     TInt StartTransaction( TInt aTxId );
       
    60     
       
    61     /**
       
    62      * Commits a started transaction. In case no committing is needed
       
    63      * (no publish calls has been made) the transaction is cancelled.
       
    64      * 
       
    65      * @return KErrNotReady in case no transaction is ongoing.
       
    66      *         KErrNotSupported in case transaction not supported
       
    67      *         KErrNone in case succesfully committed.
       
    68      */         
       
    69     TInt Commit( TInt aTxId );
       
    70     
       
    71     /**
       
    72      * Cancels a transactions in case a transaction was started.
       
    73      * 
       
    74      * @return KErrNotReady in case no transaction is ongoing.
       
    75      *         KErrNotSupported in case transactions are not supported
       
    76      *         KErrNone in case transaction succesfully cancelled     
       
    77      */
       
    78     TInt CancelTransaction( TInt aTxId );
       
    79     
       
    80     /*
       
    81      * @see MAiContentObserver
       
    82      */
       
    83     TBool CanPublish( MAiPropertyExtension& aPlugin, TInt aContent, TInt aIndex );
       
    84     
       
    85     /**
       
    86      * @see MAiContentObserver
       
    87      */
       
    88     TInt Publish( MAiPropertyExtension& aPlugin, TInt aContent,
       
    89                   TInt aResource, TInt aIndex );
       
    90 
       
    91     /**
       
    92      * @see MAiContentObserver
       
    93      */
       
    94     TInt Publish( MAiPropertyExtension& aPlugin, TInt aContent,
       
    95                   const TDesC16& aText, TInt aIndex );
       
    96     /**
       
    97      * @see MAiContentObserver
       
    98      */
       
    99     TInt Publish( MAiPropertyExtension& aPlugin, TInt aContent,
       
   100                   const TDesC8& aBuf, TInt aIndex );
       
   101 
       
   102     /**
       
   103      * @see MAiContentObserver
       
   104      */
       
   105     TInt Publish( MAiPropertyExtension& aPlugin, TInt aContent,
       
   106                   RFile& aFile, TInt aIndex );
       
   107     /**
       
   108      * @see MAiContentObserver
       
   109      */
       
   110     TInt Clean( MAiPropertyExtension& aPlugin, TInt aContent, TInt aIndex );
       
   111 
       
   112     /**
       
   113      * Returns the actual content observer.
       
   114      */
       
   115     MAiContentObserver& Observer() const;
       
   116     
       
   117 private:
       
   118     CAiContentObserverOptimizer(MAiContentObserver& aObserver);
       
   119 
       
   120     TInt AddToBlackList( TInt aContentId, TInt aIndex );
       
   121 
       
   122     TBool IsInBlackList( TInt aContentId, TInt aIndex ) const;
       
   123 
       
   124 private: // data
       
   125 
       
   126     /**
       
   127      * Handle to the observer that receives
       
   128      * the publish calls.
       
   129      */
       
   130     MAiContentObserver &iObserver;
       
   131     
       
   132     TBool iCommitNeeded;
       
   133 
       
   134     TBool iTransactionStarted;
       
   135     
       
   136     RArray<TAiPublishBlackList> iBlackList;
       
   137     };
       
   138 
       
   139 
       
   140 #endif // C_AIMULTICONTENTOBSERVEROPTIMIZER_H