phoneapp/phoneuiview/src/cphonecontactcontroller.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Contact Controller
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "cphonecontactcontroller.h"
       
    22 #include    <cphonecntsaveaddtoname.h>
       
    23 #include    <cphcntsingleitemfetch.h>
       
    24 #include    <cphonecntfactory.h>
       
    25 #include    <eikenv.h>
       
    26 #include    <aknappui.h>
       
    27 #include	<cphcntrfshandler.h>
       
    28 #include    "phonelogger.h"
       
    29 
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // Library containing contact matcher.
       
    34 _LIT( KPhoneCntFinderLibrary, "phonecntfinder.dll" );
       
    35 
       
    36 // Ordinal position of function to create instance of CPhoneCntFactory.
       
    37 const TInt KPhoneCntFinderOrdinal = 1;
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =======================
       
    40 
       
    41 CPhoneContactController* CPhoneContactController::NewL()
       
    42     {
       
    43     CPhoneContactController* self = 
       
    44         new ( ELeave ) CPhoneContactController();
       
    45 
       
    46     return self;
       
    47     }
       
    48         
       
    49 CPhoneContactController::~CPhoneContactController()
       
    50     {
       
    51     delete iFactory;
       
    52     iLibrary.Close();
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CPhoneContactController::ContinueConstructL
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 TInt CPhoneContactController::ContinueConstructL( TInt aSteps )
       
    60     {
       
    61     __PHONELOG( EBasic, EPhoneUIView,
       
    62                 "CPhoneViewController::ContinueConstructL()" );
       
    63     if ( aSteps == KConstructAll )
       
    64         {
       
    65         aSteps = ConstructionSteps();
       
    66         }
       
    67 
       
    68     // Perform as many steps as required..
       
    69     for ( ; aSteps > 0; aSteps-- )
       
    70         {
       
    71         DoStepL();
       
    72 
       
    73         // If we do not need any steps, stop.
       
    74         if ( !ConstructionSteps() )
       
    75             {
       
    76             break;
       
    77             }
       
    78         }
       
    79 
       
    80     return ConstructionSteps();
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CPhoneContactController::ConstructionSteps
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 TInt CPhoneContactController::ConstructionSteps() const
       
    88     {
       
    89     return TInt( EStepDone - iCurrentStep );
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // CPhoneContactController::CreateSingleItemFetchL
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 CPhCntSingleItemFetch* CPhoneContactController::CreateSingleItemFetchL()
       
    97     {
       
    98     ConstructCreateFactoryL();
       
    99 
       
   100     return iFactory->CreateSingleItemFetchL();
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CPhoneContactController::CreateSaveAddToNameL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 CPhoneCntSaveAddToName* CPhoneContactController::CreateSaveAddToNameL()
       
   108     {
       
   109     ConstructCreateFactoryL();
       
   110 
       
   111     return iFactory->CreateSaveAddToNameL();
       
   112     }
       
   113 
       
   114 
       
   115 CPhoneContactController::CPhoneContactController()
       
   116     {
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CPhoneContactController::DoStepL
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 void CPhoneContactController::DoStepL()
       
   124     {
       
   125     // If all steps have been completed, then there is 
       
   126     // nothing to do.
       
   127     if ( iCurrentStep == EStepDone )
       
   128         {
       
   129         return;
       
   130         }
       
   131 
       
   132     // Perform one step; if it doesn't leave, then we have done it.
       
   133     switch ( iCurrentStep )
       
   134         {
       
   135         case EStepLoadLibrary:
       
   136             ConstructLoadLibraryL();
       
   137             break;
       
   138 
       
   139         case EStepCreateFactory:
       
   140             ConstructCreateFactoryL();
       
   141             break;
       
   142 
       
   143         case EStepDone:
       
   144         default:
       
   145             return;
       
   146         }
       
   147 
       
   148     // Next step
       
   149     iCurrentStep = NextStep( iCurrentStep );
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CPhoneContactController::NextStep
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 CPhoneContactController::TStep 
       
   157     CPhoneContactController::NextStep( TStep aStep )
       
   158     {
       
   159     TStep result = EStepDone;
       
   160 
       
   161     switch ( aStep )
       
   162         {
       
   163         case EStepLoadLibrary:
       
   164             result = EStepCreateFactory;
       
   165             break;
       
   166 
       
   167         case EStepCreateFactory:
       
   168             result = EStepDone;
       
   169             break;
       
   170 
       
   171         case EStepDone:
       
   172             result = EStepDone;
       
   173             break;
       
   174 
       
   175         default:
       
   176             break;
       
   177         }
       
   178 
       
   179     return result;
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CPhoneContactController::ConstructLoadLibraryL
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 void CPhoneContactController::ConstructLoadLibraryL()
       
   187     {
       
   188     if ( !iLibrary.Handle() )
       
   189         {
       
   190         User::LeaveIfError( iLibrary.Load( KPhoneCntFinderLibrary ) );
       
   191         }
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CPhoneContactController::ConstructCreateFactoryL
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 void CPhoneContactController::ConstructCreateFactoryL()
       
   199     {
       
   200     __PHONELOG( EBasic, EPhoneUIView,
       
   201                     "CPhoneContactController::ConstructCreateFactoryL()" );
       
   202     if ( !iFactory )
       
   203         {
       
   204         ConstructLoadLibraryL();
       
   205 
       
   206         TInt res = iLibrary.Lookup( KPhoneCntFinderOrdinal )();
       
   207         iFactory = (CPhCntFactory*)res;
       
   208         }
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CPhoneContactController::CreatePhoneBookServiceL
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CPhoneContactController::CreatePhoneBookServiceL()
       
   216     {
       
   217     __PHONELOG( EBasic, EPhoneUIView,
       
   218                     "CPhoneContactController::CreatePhoneBookServiceL()" );
       
   219     if ( iFactory )
       
   220         {
       
   221         iFactory->CreatePhonebookServicesL();
       
   222         }
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CPhoneContactController::CreateRfsHandlerL
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 CPhCntRfsHandler* CPhoneContactController::CreateRfsHandlerL()
       
   230     {
       
   231     ConstructCreateFactoryL();
       
   232 
       
   233     return iFactory->CreateRfsHandlerL();
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CPhoneContactController::CreateSpeedDialMonitorL
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 CPhCntSpeedDialMonitor* CPhoneContactController::CreateSpeedDialMonitorL()
       
   241     {
       
   242     ConstructCreateFactoryL();
       
   243 
       
   244     return iFactory->CreateSpeedDialMonitorL();
       
   245     }    
       
   246 //  End of File