phoneuis/dialer/src/cdialingextensionobserver.cpp
branchRCL_3
changeset 62 5266b1f337bd
child 81 c26cc2a7c548
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
       
     1 /*
       
     2 * Copyright (c) 2007 - 2010 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:  Observer for dialingextension plug-in.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <eikenv.h>
       
    20 #include <eikappui.h>
       
    21 #include <phoneappcommands.hrh>
       
    22 
       
    23 // USER INCLUDE FILES
       
    24 #include "cdialingextensionobserver.h"
       
    25 #include "cdialernumberentry.h"
       
    26 #include "cdialer.h"
       
    27 
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 //  CDialingExtensionObserver::CDialingExtensionObserver
       
    31 //  
       
    32 // 
       
    33 // ---------------------------------------------------------------------------
       
    34 //    
       
    35 CDialingExtensionObserver* CDialingExtensionObserver::NewL( 
       
    36         CDialingExtensionInterface* aDialingExtension, 
       
    37         CDialerNumberEntry* aNumberEntry,
       
    38         CDialer* aDialer )
       
    39     {
       
    40     CDialingExtensionObserver* self = new (ELeave) CDialingExtensionObserver( 
       
    41             aDialingExtension, aNumberEntry, aDialer );
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 //  CDialingExtensionObserver::~CDialingExtensionObserver
       
    47 //  
       
    48 // 
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CDialingExtensionObserver::~CDialingExtensionObserver()
       
    52     {
       
    53     // no owned data => no implementation needed
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 //  CDialingExtensionObserver::HandleDialingExtensionEvent
       
    58 //  
       
    59 // 
       
    60 // ---------------------------------------------------------------------------
       
    61 //    
       
    62 void CDialingExtensionObserver::HandleDialingExtensionEvent( MDialingExtensionObserver::TEvent aEvent )
       
    63     {
       
    64     switch ( aEvent )
       
    65         {
       
    66         case MDialingExtensionObserver::EFocusChanged:
       
    67             {
       
    68             // The basic idea of EFocusChanged event handling:
       
    69             // - If dialing extension gets in focus, focus is taken from number entry editor.
       
    70             // - If dialing extension gives up focus, focus is given to number entry editor.
       
    71             
       
    72             if ( iDialingExtension->IsFocused() && iNumberEntry->IsFocused() )
       
    73                 {
       
    74                 iNumberEntry->SetFocus(EFalse);
       
    75                 UpdateCba();
       
    76                 iDialer->UpdateToolbar();
       
    77                 }
       
    78             else if ( !iDialingExtension->IsFocused() && !iNumberEntry->IsFocused() && iDialer->IsFocused() )
       
    79                 {
       
    80                 // Number entry editor is set focused only if the parent control is in focus.
       
    81                 // If number entry editor was focused but parent was not, this may show as a
       
    82                 // a blinking cursor in an inappropriate place.
       
    83                 iNumberEntry->SetFocus(ETrue);
       
    84                 UpdateCba();
       
    85                 iDialer->UpdateToolbar();
       
    86                 }
       
    87             
       
    88             iNumberEntry->DrawDeferred();
       
    89             }
       
    90             break;
       
    91 
       
    92         case MDialingExtensionObserver::ECCALauncherExit:
       
    93         case MDialingExtensionObserver::ECommunicationCancelled:
       
    94         case MDialingExtensionObserver::ECommunicationStarted:
       
    95             {
       
    96             // No actions. We should stay in dialer, and not go to idle.
       
    97             }
       
    98             break;
       
    99         
       
   100         case MDialingExtensionObserver::EEasyDialingEnabled:
       
   101             {
       
   102             // order dialer to refresh its layout
       
   103             iDialer->UpdateNumberEntryConfiguration();
       
   104             iDialer->SetSize( iDialer->Size() );
       
   105             if (iDialingExtension && iNumberEntry)
       
   106                 {
       
   107                 // get matches for the current input
       
   108                 TRAP_IGNORE( SearchL() );
       
   109                 }
       
   110             iDialer->DrawDeferred();
       
   111             }
       
   112             break;
       
   113 
       
   114         case MDialingExtensionObserver::EEasyDialingDisabled:
       
   115             {
       
   116             // order parent to refresh its layout
       
   117             iDialer->UpdateNumberEntryConfiguration();
       
   118             iDialer->SetSize( iDialer->Size() );
       
   119             iDialer->DrawDeferred();
       
   120             }
       
   121             break;
       
   122             
       
   123         default:
       
   124             break;
       
   125         }    
       
   126     }
       
   127 
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 //  CDialingExtensionObserver::CDialingExtensionObserver
       
   131 //  
       
   132 // 
       
   133 // ---------------------------------------------------------------------------
       
   134 //    
       
   135 CDialingExtensionObserver::CDialingExtensionObserver( 
       
   136         CDialingExtensionInterface* aDialingExtension, 
       
   137         CDialerNumberEntry* aNumberEntry,
       
   138         CDialer* aDialer ) :
       
   139 iDialingExtension( aDialingExtension ), 
       
   140 iNumberEntry( aNumberEntry ), 
       
   141 iDialer( aDialer ),
       
   142 iEikonEnvironment( NULL )
       
   143     {
       
   144     }
       
   145         
       
   146         
       
   147 // ---------------------------------------------------------------------------
       
   148 //  CDialingExtensionObserver::CDialingExtensionObserver
       
   149 //  
       
   150 // 
       
   151 // ---------------------------------------------------------------------------
       
   152 //    
       
   153 void CDialingExtensionObserver::UpdateCba()
       
   154     {
       
   155     if ( !iEikonEnvironment )
       
   156         {
       
   157         iEikonEnvironment = CEikonEnv::Static(); // codescanner::performance::eikonenvstatic
       
   158         }
       
   159     
       
   160     if( iEikonEnvironment && iEikonEnvironment->EikAppUi() )
       
   161         {
       
   162         TRAP_IGNORE( iEikonEnvironment->EikAppUi()->HandleCommandL( EPhoneCmdUpdateCba ));
       
   163         }
       
   164     }
       
   165 
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 //  CDialingExtensionObserver::SearchL
       
   169 //  
       
   170 // 
       
   171 // ---------------------------------------------------------------------------
       
   172 //    
       
   173 void CDialingExtensionObserver::SearchL()
       
   174     {
       
   175     TPtrC searchString = iNumberEntry->Text();
       
   176     if ( searchString.Length() )
       
   177         {
       
   178         iDialingExtension->SetInputL( searchString );
       
   179         }
       
   180     }
       
   181 
       
   182 // end of file