os/persistentdata/featuremgmt/featuremgr/tools/featureinstaller/featureinstaller.cpp
Update contrib.
2 // Copyright (c) 2007-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".
9 // Initial Contributors:
10 // Nokia Corporation - initial contribution.
20 #include <featmgr/featurecontrol.h>
22 // LOCAL CONSTANTS AND MACROS
23 _LIT(KTxt,"featureinstaller: mainL failed");
26 // ============================= LOCAL FUNCTIONS ===============================
28 // -----------------------------------------------------------------------------
30 // -----------------------------------------------------------------------------
34 // Open Feature Control.
35 RFeatureControl featureControl;
36 User::LeaveIfError( featureControl.Open() );
38 // Example code adds a new persisted feature to the device.
39 // Comment or uncomment code when needed.
41 // Specify in your .pkg file:
42 // @"featureinstaller.sisx", (0x10283303)
45 // Replace UID 0x00000000 with real value
46 TUid featureUid( TUid::Uid( 0x00000000 ) );
48 // Set feature flags of the feature!
50 // Set all flags to zero.
51 // Comment when needed!
52 TBitFlags32 featureFlags( 0 );
54 // If set, feature is supported and available for use;
55 // if not, feature is not supported.
56 // Comment when needed!
57 featureFlags.Set( EFeatureSupported );
59 // If set, feature is upgradeable. The feature is known to the device
60 // but it must be upgraded to enable it. If a feature s blacklisted,
61 // its upgradeable flag is unset.
62 // Uncomment when needed!
63 // featureFlags.Set( EFeatureUpgradeable );
65 // If set, the feature is modifiable and may be enabled/disabled
66 // at run-time. The initial flag values for such a feature flag are
67 // defined in a ROM image obey file.
68 // Comment when needed!
69 featureFlags.Set( EFeatureModifiable );
71 // If set, the feature has been blacklisted, and may not be changed at
72 // run-time. This also prevents a feature from being upgraded.
73 // Uncomment when needed!
74 // featureFlags.Set( EFeatureBlackListed );
76 // If set, only clients with WriteDeviceData capability can modify it.
77 // This ensures only trusted software can set the feature Supported flag.
78 // Uncomment when needed!
79 // featureFlags.Set( EFeatureProtected );
81 // If set, this flag is saved to the system drive when modified
82 // preserving its value across reboots/power downs.
83 // Comment when needed!
84 featureFlags.Set( EFeaturePersisted );
86 // If set, this flag Supported state is unknown at build-time and is
87 // initialised at run-time by system software. The Feature Manager will
88 // ignore the Supported flag in the file. A run-time call to RFeatureControl
89 // will be needed to set the feature's supported flag. Look ups of
90 // uninitialised features result in a KErrNotReady error code
91 // Uncomment when needed!
92 // featureFlags.Set( EFeatureUninitialized );
94 // Feature data is 32-bit quantity for client read and write. Feature data is
95 // defined by owner of the feature and can contain for example flags,
96 // enumeratons and/or integers.
97 // Set feature data. Replace <featureData> with real value!
98 // Comment when needed!
99 TUint32 featureData( 0x00000000 );
101 // Comment when needed!
102 TFeatureEntry entry( featureUid, featureFlags, featureData );
104 TInt err( KErrNone );
106 // Inform feature manager that your executable is launched by the software installer (SWI)
107 // and it wishes to set, add, delete, enable or disable features in feature manager. This
108 // function must be called before any API calls by RFeatureControl that add, set, delete
109 // enable, or disable features so that changes in feature manager are cached to be rolled
110 // back if the installationhas user-aborted or failed. Otherwise, feature manipulations will
111 // be committed directly into feature manager and will not be possible to undo them in the
113 // A call to SWIStart must be accompanied by a call to SWIEnd after all API calls by
114 // RFeatureControl functions that manipulate features.
115 User::LeaveIfError(featureControl.SWIStart());
117 // Add a new feature to the device.
118 // Comment when needed!
119 err = featureControl.AddFeature( entry );
121 if ( err == KErrAlreadyExists ) // Existing feature cannot be added as a new feature.
123 // Enable an existing feature.
124 User::LeaveIfError( featureControl.EnableFeature( featureUid ) );
126 // OR enable an exsiting feature and set feature data.
127 // Uncomment when needed!
128 //User::LeaveIfError( featureControl.SetFeature( featureUid, ETrue, featureData ) );
131 // Inform feature manager that caching feature manipulations should stop and they should be
132 // committed to feature manager.
133 // A call to this API should follow the call to SWIStart before any RFeatureControl API calls
134 // that manipulate features to feature manager.
135 User::LeaveIfError(featureControl.SWIEnd());
137 featureControl.Close();
139 // ============================ MEMBER FUNCTIONS ===============================
141 TInt E32Main() // main function called by E32
144 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
145 TRAPD( error,mainL() ); // Run main method
146 __ASSERT_ALWAYS( !error,User::Panic(KTxt,error) );
147 delete cleanup; // destroy clean-up stack
149 return 0; // and return