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