contextframework/cfwplugins/cenrepsourceplugin/src/cenrepsourceplugin.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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:  CCenRepSourcePlugIn class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32cmn.h>
       
    20 #include <cfcontextsourcesettingarray.h>
       
    21 
       
    22 #include "cenrepsourceplugin.h"
       
    23 #include "cenrephandler.h"
       
    24 #include "cenreptrace.h"
       
    25 
       
    26 // ======== LOCAL FUNCTIONS =========
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 CCenRepSourcePlugIn* CCenRepSourcePlugIn::NewL(
       
    31     TContextSourceInitParams* aParams )
       
    32     {
       
    33     FUNC_LOG;
       
    34 
       
    35     CCenRepSourcePlugIn* self = CCenRepSourcePlugIn::NewLC( aParams );
       
    36     CleanupStack::Pop( self );
       
    37     return self;
       
    38     }
       
    39 
       
    40 CCenRepSourcePlugIn* CCenRepSourcePlugIn::NewLC(
       
    41     TContextSourceInitParams* aParams )
       
    42     {
       
    43     FUNC_LOG;
       
    44 
       
    45     CCenRepSourcePlugIn* self =
       
    46         new( ELeave ) CCenRepSourcePlugIn( aParams );
       
    47     CleanupStack::PushL( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 CCenRepSourcePlugIn::~CCenRepSourcePlugIn()
       
    52     {
       
    53     FUNC_LOG;
       
    54 
       
    55     // Cleanup settings
       
    56     iCenRepHandlerArray.ResetAndDestroy();
       
    57     delete iSettings;
       
    58     }
       
    59 
       
    60 CCenRepSourcePlugIn::CCenRepSourcePlugIn(
       
    61     TContextSourceInitParams* aParams ) :
       
    62     CCFContextSourcePlugIn( aParams )
       
    63     {
       
    64     FUNC_LOG;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CCenRepSourcePlugIn::HandleSettingL
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void CCenRepSourcePlugIn::HandleSettingL(
       
    72     CCFContextSourceSettingArray* aSettingList )
       
    73     {
       
    74     FUNC_LOG;
       
    75 
       
    76     // Take ownership from settings
       
    77     iSettings = aSettingList;
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CCenRepSourcePlugIn::DefineContextsL
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 void CCenRepSourcePlugIn::DefineContextsL()
       
    85     {
       
    86     FUNC_LOG;
       
    87 
       
    88     // Definitions will be made during CCenRepAttributes object initialization
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // CCenRepSourcePlugIn::InitializeL
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CCenRepSourcePlugIn::InitializeL()
       
    96     {
       
    97     FUNC_LOG;
       
    98 
       
    99     if( iSettings )
       
   100         {
       
   101         TInt keyNumbers = iSettings->Count();
       
   102         iCenRepHandlerArray.ReserveL( keyNumbers );
       
   103         for ( TInt i=0; i<keyNumbers; i++ )
       
   104             {
       
   105             CCenRepHandler* localCenRepHandler = NULL;
       
   106 
       
   107             TRAPD( err,
       
   108                 localCenRepHandler = CCenRepHandler::NewL( iCF, *iSettings, i ) );
       
   109             if( err == KErrNone )
       
   110                 {
       
   111                 CleanupStack::PushL( localCenRepHandler );
       
   112                 iCenRepHandlerArray.AppendL( localCenRepHandler );
       
   113                 CleanupStack::Pop( localCenRepHandler );
       
   114                 }
       
   115             }
       
   116         }
       
   117     }