uiutils/Findutil/src/FindUtil.cpp
changeset 0 2f259fa3e83a
child 3 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <FeatMgr.h>
       
    28 #include "findutil.h"
       
    29 #include "findutilbase.h"
       
    30 
       
    31 #ifdef __WINS__     
       
    32 #include <FeatMgr.h>    
       
    33 #endif
       
    34 
       
    35 typedef MFindUtil* (*TFindUtilFactoryFunctionL)();
       
    36 _LIT( KFindUtilImpl, "FindUtilImpl.dll" );
       
    37 #ifdef __WINS__
       
    38 _LIT( KFindUtilImplJapan, "FindUtilImplJapan.dll" );
       
    39 _LIT( KFindUtilImplChina, "FindUtilImplChina.dll" );
       
    40 _LIT( KFindUtilImplThai, "FindUtilImplThai.dll" );
       
    41 #endif // __WINS__
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CFindUtil::NewL()
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CFindUtil* CFindUtil::NewL()
       
    48     {
       
    49     TBool supported(ETrue);
       
    50 
       
    51     CFindUtil* self = NULL;
       
    52 
       
    53     if ( supported )
       
    54         {
       
    55         self = new( ELeave ) CFindUtil;
       
    56         CleanupStack::PushL( self );
       
    57         self->ConstructL();
       
    58         CleanupStack::Pop(self);
       
    59         }
       
    60         
       
    61     return self;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CFindUtil::~CFindUtil()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CFindUtil::~CFindUtil()
       
    69     {
       
    70     if ( iInterface )
       
    71         {
       
    72         static_cast<CFindUtilBase*>( iInterface )->Close();
       
    73         }
       
    74 
       
    75     iLib.Close();
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CFindUtil::CFindUtil()
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 CFindUtil::CFindUtil()
       
    83     {
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CFindUtil::ConstructL()
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CFindUtil::ConstructL()
       
    91     {
       
    92 #ifdef __WINS__     
       
    93     FeatureManager::InitializeLibL();
       
    94     if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
    95         {
       
    96         // load polymorphic implementation DLL
       
    97         User::LeaveIfError( iLib.Load( KFindUtilImplJapan ) );
       
    98         }
       
    99     else if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) )
       
   100         {
       
   101         // load polymorphic implementation DLL
       
   102         User::LeaveIfError( iLib.Load( KFindUtilImplChina ) );
       
   103         }
       
   104     else if ( FeatureManager::FeatureSupported( KFeatureIdThai ) )
       
   105         {
       
   106         // load polymorphic implementation DLL
       
   107         User::LeaveIfError( iLib.Load( KFindUtilImplThai ) );
       
   108         }
       
   109     else
       
   110         {
       
   111         // load polymorphic implementation DLL
       
   112         User::LeaveIfError( iLib.Load( KFindUtilImpl ) );
       
   113         }
       
   114     FeatureManager::UnInitializeLib();
       
   115 #else    
       
   116 
       
   117     // load polymorphic implementation DLL
       
   118     User::LeaveIfError( iLib.Load( KFindUtilImpl ) );
       
   119 
       
   120 #endif  // __WINS__
       
   121 
       
   122     // Check if object has already been allocated
       
   123     iInterface = static_cast<MFindUtil*>( Dll::Tls() );
       
   124     
       
   125     if ( !iInterface )
       
   126         {
       
   127         iInterface = ( *(TFindUtilFactoryFunctionL)iLib.Lookup( 1 ) )();
       
   128         Dll::SetTls( iInterface );
       
   129         }
       
   130 
       
   131     if ( iInterface )
       
   132         {
       
   133         // This never leaves
       
   134         static_cast<CFindUtilBase*>( iInterface )->OpenL();
       
   135         }
       
   136     }
       
   137 
       
   138 // End of File