phonebookui/Phonebook2/xSPExtensionManager/src/CxSPScanner.cpp
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     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: 
       
    15 *       Scanner that finds extensions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CxSPScanner.h"
       
    22 #include <ecom/ecom.h>
       
    23 #include "CxSPLoader.h"
       
    24 #include "ExtensionManagerUID.H"
       
    25 
       
    26 
       
    27 // Unnamed namespace for local definitions
       
    28 namespace {
       
    29 
       
    30 _LIT8(KPbkxSPExtension, KPBKXSPDEFAULTDATASTRING);
       
    31 
       
    32 void CleanupResetAndDestroy(TAny* aObj)
       
    33     {
       
    34     if (aObj)
       
    35         {
       
    36         static_cast<RImplInfoPtrArray*>(aObj)->ResetAndDestroy();
       
    37         }
       
    38     }
       
    39 } // namespace
       
    40 
       
    41 // ==================== MEMBER FUNCTIONS ====================
       
    42 CxSPScanner::CxSPScanner(CxSPArray& aExtensions) :
       
    43     iExtensions(aExtensions)
       
    44     {
       
    45 	}
       
    46 
       
    47 CxSPScanner::~CxSPScanner()
       
    48     {
       
    49     }
       
    50 
       
    51 
       
    52 CxSPScanner* CxSPScanner::NewL(CxSPArray& aExtensions)
       
    53     {
       
    54     CxSPScanner* self =
       
    55         new (ELeave) CxSPScanner(aExtensions);
       
    56     return self;
       
    57     }
       
    58 
       
    59 void CxSPScanner::ScanL()
       
    60     {
       
    61     RImplInfoPtrArray implementations;
       
    62     TEComResolverParams resolverParams;
       
    63 
       
    64     resolverParams.SetWildcardMatch(ETrue);
       
    65     resolverParams.SetDataType(KPbkxSPExtension);
       
    66 
       
    67     REComSession::ListImplementationsL
       
    68         (TUid::Uid(KPBKXSPINTERFACEDEFINITIONUID),
       
    69          resolverParams,
       
    70          implementations);
       
    71 
       
    72     CleanupStack::PushL(TCleanupItem(CleanupResetAndDestroy,
       
    73                                      &implementations));
       
    74 
       
    75     const TInt count = implementations.Count();
       
    76     iExtensions.SetReserveL(iExtensions.Count() + count);
       
    77     for (TInt i = count-1; i >= 0; --i)
       
    78         {
       
    79         CImplementationInformation* implInfo = implementations[i];
       
    80         CleanupStack::PushL(implInfo);
       
    81         implementations.Remove(i);
       
    82 
       
    83         CxSPLoader* extension = NULL;
       
    84         TRAPD(err,
       
    85               extension = CxSPLoader::NewL(implInfo->ImplementationUid()));
       
    86         if (err == KErrNone)
       
    87             {
       
    88             CleanupStack::PushL(extension);
       
    89             iExtensions.AppendL(extension);
       
    90             CleanupStack::Pop(extension);
       
    91             }
       
    92 
       
    93         CleanupStack::PopAndDestroy(implInfo);
       
    94         }
       
    95     CleanupStack::PopAndDestroy(); // implementations     
       
    96     }
       
    97     
       
    98 // End of File