messagingappbase/msgeditor/appuisrc/MsgEditorSettingCacheUpdatePlugin.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  MsgEditorSettingCacheUpdatePlugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ========== INCLUDE FILES ================================
       
    21 
       
    22 
       
    23 
       
    24 #include "MsgEditorSettingCacheUpdatePlugin.h"
       
    25 
       
    26 #include <e32std.h>                 // for GLDEF_C
       
    27 #include <centralrepository.h>
       
    28 #include <MessagingSDKCRKeys.h>
       
    29 
       
    30 // ========== EXTERNAL DATA STRUCTURES =====================
       
    31 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    32 // ========== CONSTANTS ====================================
       
    33 // ========== MACROS =======================================
       
    34 // ========== LOCAL CONSTANTS AND MACROS ===================
       
    35 // ========== MODULE DATA STRUCTURES =======================
       
    36 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
    37 // ========== LOCAL FUNCTIONS ==============================
       
    38 // ========== MEMBER FUNCTIONS =============================
       
    39 
       
    40 // ---------------------------------------------------------
       
    41 // TMsgEditorSettingCacheUpdatePlugin::TMsgEditorSettingCacheUpdatePlugin
       
    42 //
       
    43 // Constructor.
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 EXPORT_C TMsgEditorSettingCacheUpdatePlugin::TMsgEditorSettingCacheUpdatePlugin(CAknAppUi* aAppUi)    
       
    47     :
       
    48     iLocalZoomCache(EAknUiZoomAutomatic),
       
    49     iAppUi(aAppUi)
       
    50     {
       
    51     CRepository* repository = NULL;
       
    52     TRAPD( ret, repository = CRepository::NewL(KCRUidMessagingUiSettings) );
       
    53     if (ret == KErrNone)
       
    54         {
       
    55         TInt cenRepZoomValue = 0;
       
    56         ret = repository->Get(KMessagingEditorLocalUiZoom, cenRepZoomValue);
       
    57         if( ret == KErrNone )
       
    58             {
       
    59             iLocalZoomCache = static_cast<TAknUiZoom>(cenRepZoomValue);
       
    60             }
       
    61         }
       
    62     delete repository;          
       
    63     }
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // TMsgEditorSettingCacheUpdatePlugin::~TMsgEditorSettingCacheUpdatePlugin
       
    68 //
       
    69 // Destructor.
       
    70 // ---------------------------------------------------------
       
    71 //
       
    72 EXPORT_C TMsgEditorSettingCacheUpdatePlugin::~TMsgEditorSettingCacheUpdatePlugin()
       
    73     {
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // TMsgEditorSettingCacheUpdatePlugin::HandlesEvent
       
    78 //
       
    79 // check for the KAknLocalZoomLayoutSwitch event
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 TBool TMsgEditorSettingCacheUpdatePlugin::HandlesEvent(TInt aEventId) const
       
    83     {
       
    84     return (aEventId == KAknLocalZoomLayoutSwitch);
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // TMsgEditorSettingCacheUpdatePlugin::Update
       
    89 //
       
    90 // Update the cached value of the local messaging Ui Local Zoom value.
       
    91 // Recognises layout switch events and checks for changes
       
    92 // ---------------------------------------------------------
       
    93 //
       
    94 TBool TMsgEditorSettingCacheUpdatePlugin::Update(TInt aEventId)
       
    95     {
       
    96     bool changed = EFalse;
       
    97     if (aEventId == KAknLocalZoomLayoutSwitch)
       
    98         {
       
    99         if(iAppUi)
       
   100             {
       
   101             TInt oldLocalZoom = iLocalZoomCache;
       
   102             CRepository* repository = NULL;
       
   103             TRAPD( ret, repository = CRepository::NewL(KCRUidMessagingUiSettings) );
       
   104             if (ret == KErrNone)
       
   105                 {
       
   106                 TInt cenRepZoomValue = 0;
       
   107                 ret = repository->Get(KMessagingEditorLocalUiZoom, cenRepZoomValue);
       
   108                  if( ret == KErrNone )
       
   109                     {
       
   110                     iLocalZoomCache = static_cast<TAknUiZoom>(cenRepZoomValue);
       
   111                     changed = (iLocalZoomCache != oldLocalZoom);
       
   112                     }
       
   113                 }
       
   114             delete repository;
       
   115             }
       
   116         }
       
   117     return changed;
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------
       
   121 // TMsgEditorSettingCacheUpdatePlugin::GetValue
       
   122 // ---------------------------------------------------------
       
   123 EXPORT_C TInt TMsgEditorSettingCacheUpdatePlugin::GetValue(TInt aEventId, TInt& aValue) const
       
   124     {
       
   125     if(aEventId == KAknLocalZoomLayoutSwitch)
       
   126         {
       
   127         aValue = iLocalZoomCache;
       
   128         return KErrNone;
       
   129         }
       
   130     return KErrNotSupported;
       
   131     }
       
   132  
       
   133 
       
   134 
       
   135 //  End of File