commonui/src/glxzoomstatepublisher.cpp
changeset 23 74c9f037fd5d
equal deleted inserted replaced
5:f7f0874bfe7d 23:74c9f037fd5d
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:   Utility class for publishing the zoom state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // Class header
       
    21 #include "glxzoomstatepublisher.h"
       
    22 
       
    23 // External includes
       
    24 #include <bldvariant.hrh> // for feature flag
       
    25 #include <cfclient.h>
       
    26 #include <cflistener.h>
       
    27 
       
    28 // Internal includes
       
    29 #include <glxlog.h>
       
    30 
       
    31 /**
       
    32  * @internal reviewed 5/02/2007 by Alex Birkett
       
    33  */
       
    34  
       
    35 // -----------------------------------------------------------------------------
       
    36 // NGlxZoomStatePublisher
       
    37 // -----------------------------------------------------------------------------
       
    38 namespace NGlxZoomStatePublisher
       
    39     {
       
    40 #ifdef GLX_PUBLISH_ZOOMING_STATE
       
    41     // local constants
       
    42     _LIT( KGlxContextSource, "Application" );
       
    43     _LIT( KGlxContextType, "Photos.Zoom" );
       
    44     _LIT_SECURITY_POLICY_PASS( KGlxContextSec );
       
    45 
       
    46     _LIT( KGlxContextValueEnabled, "Enabled" );
       
    47     _LIT( KGlxContextValueDisabled, "Disabled" );
       
    48 
       
    49     /**
       
    50      * Implementation of MCFListener, needed
       
    51      * since CCFClient takes a reference
       
    52      */
       
    53     class TemporaryListener : public MCFListener
       
    54         {
       
    55         private: // From MCFListener
       
    56             /// @ref MCFListener
       
    57             void ContextIndicationL(
       
    58                 const CCFContextIndication& /*aChangedContext*/ )
       
    59                 {
       
    60                 // nothing to do
       
    61                 }
       
    62             /// @ref MCFListener
       
    63             void ActionIndicationL(
       
    64                 const CCFActionIndication& /*aActionToExecute*/ )
       
    65                 {
       
    66                 // nothing to do
       
    67                 }
       
    68             /// @ref MCFListener
       
    69             void HandleContextFrameworkError(
       
    70                 TCFError /*aError*/,
       
    71                 const TDesC& /*aSource*/,
       
    72                 const TDesC& /*aType*/ )
       
    73                 {
       
    74                 // nothing to do
       
    75                 }
       
    76             /// @ref MCFListener
       
    77             TAny* Extension( const TUid& /*aExtensionUid*/ ) const
       
    78                 {
       
    79                 // nothing to do
       
    80                 return NULL;
       
    81                 }
       
    82         };
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // PublishStateL
       
    86 // -----------------------------------------------------------------------------
       
    87 EXPORT_C void PublishStateL( TBool aEnabled )
       
    88     {
       
    89     TRACER( "NGlxZoomStatePublisher::PublishStateL" );
       
    90     // publish zooming state if the feature is enabled
       
    91     TemporaryListener templistener;
       
    92     // create client and keep it on the cleanupstack
       
    93     CCFClient* client = CCFClient::NewLC( templistener );
       
    94     // define the context
       
    95     TInt err = client->DefineContext( 
       
    96         KGlxContextSource, KGlxContextType, KGlxContextSec );
       
    97     // if either success or context already there
       
    98     if( ( err == KErrNone )||
       
    99         ( err == KErrAlreadyExists ) )
       
   100         {
       
   101         // create context object and keep it on the cleanupstack
       
   102         CCFContextObject* context = CCFContextObject::NewLC();
       
   103         // set source and type
       
   104         context->SetSourceL( KGlxContextSource );
       
   105         context->SetTypeL( KGlxContextType );
       
   106         // default zoom state is disabled
       
   107         context->SetValueL( KGlxContextValueDisabled );
       
   108         if( aEnabled )
       
   109             {
       
   110             // enable zoom state
       
   111             context->SetValueL( KGlxContextValueEnabled );
       
   112             }
       
   113         // publish, cant really deal with the error so just ignore it
       
   114         (void)client->PublishContext( *context );
       
   115         CleanupStack::PopAndDestroy( context );
       
   116         }
       
   117     // release client
       
   118     CleanupStack::PopAndDestroy( client );
       
   119     } // PublishStateL
       
   120 #else
       
   121 // -----------------------------------------------------------------------------
       
   122 // PublishStateL
       
   123 // -----------------------------------------------------------------------------
       
   124 EXPORT_C void PublishStateL( TBool /*aEnabled*/ )
       
   125     {
       
   126     }
       
   127 #endif
       
   128     } // namespace
       
   129