idlefw/plugins/devicestatus/src/aimulticontentobserver.cpp
changeset 0 79c6a41cd166
child 3 ff572005ac23
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 interface multiplexer 
       
    15 *                implementation.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "aimulticontentobserver.h"
       
    21 #include "aicontentobserveroptimizer.h"
       
    22 
       
    23 CAiMultiContentObserver* CAiMultiContentObserver::NewL()
       
    24     {
       
    25     return new(ELeave) CAiMultiContentObserver;
       
    26     }
       
    27     
       
    28     
       
    29 CAiMultiContentObserver::~CAiMultiContentObserver()
       
    30     {
       
    31     iObserverOptimizers.ResetAndDestroy();
       
    32     }
       
    33     
       
    34     
       
    35 void CAiMultiContentObserver::AddObserverL(MAiContentObserver& aObserver)
       
    36     {
       
    37     TBool foundExisting = EFalse;
       
    38     
       
    39     for( TInt i = 0; i < iObserverOptimizers.Count(); ++i )
       
    40         {
       
    41         if ( &(iObserverOptimizers[i]->Observer()) == &aObserver )
       
    42             {
       
    43             foundExisting = ETrue;
       
    44             break;
       
    45             }
       
    46         }
       
    47     if( !foundExisting )
       
    48         {
       
    49         CAiContentObserverOptimizer *optimizer = 
       
    50             CAiContentObserverOptimizer::NewL( aObserver );
       
    51         iObserverOptimizers.AppendL( optimizer );       
       
    52         }
       
    53     }
       
    54 
       
    55 
       
    56 TInt CAiMultiContentObserver::StartTransaction( TInt aTxId )
       
    57     {
       
    58     TInt result = KErrNone;
       
    59     const TInt count = iObserverOptimizers.Count();
       
    60     for ( TInt i = 0; i < count; ++i )
       
    61         {
       
    62         const TInt r = iObserverOptimizers[i]->StartTransaction( aTxId );
       
    63    
       
    64         if ( r != KErrNone )
       
    65             {
       
    66             result = r;
       
    67             }
       
    68         }
       
    69     return result;
       
    70     }
       
    71     
       
    72 
       
    73 TInt CAiMultiContentObserver::Commit( TInt aTxId )
       
    74     {
       
    75     TInt result = KErrNone;
       
    76     const TInt count = iObserverOptimizers.Count();
       
    77     for ( TInt i = 0; i < count; ++i )
       
    78         {
       
    79         const TInt r = iObserverOptimizers[i]->Commit( aTxId );
       
    80       
       
    81         if ( r != KErrNone )
       
    82             {
       
    83             result = r;
       
    84             }
       
    85         }
       
    86     return result;
       
    87     }
       
    88     
       
    89 
       
    90 TInt CAiMultiContentObserver::CancelTransaction( TInt aTxId )
       
    91     {
       
    92     TInt result = KErrNone;
       
    93     const TInt count = iObserverOptimizers.Count();
       
    94     for ( TInt i = 0; i < count; ++i )
       
    95         {
       
    96         const TInt r = iObserverOptimizers[i]->CancelTransaction( aTxId );
       
    97         if ( r != KErrNone )
       
    98             {
       
    99             result = r;
       
   100             }
       
   101         }
       
   102     return result;
       
   103     }
       
   104     
       
   105     
       
   106 TBool CAiMultiContentObserver::CanPublish( MAiPropertyExtension& aPlugin,
       
   107                                            TInt aContent,
       
   108                                            TInt aIndex )
       
   109     {
       
   110     const TInt count = iObserverOptimizers.Count();
       
   111     for ( TInt i = 0; i < count; ++i )
       
   112         {
       
   113         if( iObserverOptimizers[i]->CanPublish( aPlugin, aContent, aIndex ) )
       
   114             {
       
   115             return ETrue;
       
   116             }
       
   117         }
       
   118     return EFalse;
       
   119     }
       
   120     
       
   121     
       
   122 TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin,
       
   123                                        TInt aContent,
       
   124                                        TInt aResource,
       
   125                                        TInt aIndex )
       
   126     {
       
   127     TInt result = KErrNone;
       
   128     const TInt count = iObserverOptimizers.Count();
       
   129     for ( TInt i = 0; i < count; ++i )
       
   130         {
       
   131         const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aResource, aIndex );
       
   132         if ( r != KErrNone )
       
   133             {
       
   134             result = r;
       
   135             }
       
   136         }
       
   137     return result;
       
   138     }
       
   139     
       
   140     
       
   141 TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin,
       
   142                                        TInt aContent,
       
   143                                        const TDesC16& aText,
       
   144                                        TInt aIndex )
       
   145     {
       
   146     TInt result = KErrNone;
       
   147     const TInt count = iObserverOptimizers.Count();
       
   148     for ( TInt i = 0; i < count; ++i )
       
   149         {
       
   150         const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aText, aIndex );
       
   151         if ( r != KErrNone )
       
   152             {
       
   153             result = r;
       
   154             }
       
   155         }
       
   156     return result;
       
   157     }
       
   158     
       
   159     
       
   160 TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin,
       
   161                                        TInt aContent,
       
   162                                        const TDesC8& aBuf,
       
   163                                        TInt aIndex )
       
   164     {
       
   165     TInt result = KErrNone;
       
   166     const TInt count = iObserverOptimizers.Count();
       
   167     for ( TInt i = 0; i < count; ++i )
       
   168         {
       
   169         const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aBuf, aIndex );
       
   170         if ( r != KErrNone )
       
   171             {
       
   172             result = r;
       
   173             }
       
   174         }
       
   175     return result;
       
   176     }
       
   177     
       
   178     
       
   179 TInt CAiMultiContentObserver::Publish( MAiPropertyExtension& aPlugin,
       
   180                                        TInt aContent,
       
   181                                        RFile& aFile,
       
   182                                        TInt aIndex )
       
   183     {
       
   184     TInt result = KErrNone;
       
   185     const TInt count = iObserverOptimizers.Count();
       
   186     for ( TInt i = 0; i < count; ++i )
       
   187         {
       
   188         const TInt r = iObserverOptimizers[i]->Publish( aPlugin, aContent, aFile, aIndex );
       
   189         if ( r != KErrNone )
       
   190             {
       
   191             result = r;
       
   192             }
       
   193         }
       
   194     return result;
       
   195     }
       
   196     
       
   197     
       
   198 TInt CAiMultiContentObserver::Clean( MAiPropertyExtension& aPlugin,
       
   199                                      TInt aContent,
       
   200                                      TInt aIndex )
       
   201     {
       
   202     TInt result = KErrNone;
       
   203     const TInt count = iObserverOptimizers.Count();
       
   204     for ( TInt i = 0; i < count; ++i )
       
   205         {
       
   206         const TInt r = iObserverOptimizers[i]->Clean( aPlugin, aContent, aIndex );
       
   207         if ( r != KErrNone )
       
   208             {
       
   209             result = r;
       
   210             }
       
   211         }
       
   212     return result;
       
   213     }
       
   214 
       
   215 
       
   216 TAny* CAiMultiContentObserver::Extension( TUid /*aUid*/ )
       
   217     {
       
   218     return NULL;
       
   219     }
       
   220 
       
   221 TBool CAiMultiContentObserver::RequiresSubscription( 
       
   222     const TAiPublisherInfo& /*aPublisherInfo*/ ) const
       
   223     {
       
   224     return ETrue;
       
   225     }
       
   226 
       
   227 CAiMultiContentObserver::CAiMultiContentObserver()
       
   228     {
       
   229     }
       
   230