featuremgmt/featuremgr/tools/datfilehelpers/ModifyFeatContent.pl
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 #!perl -w
       
     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".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 # This simple script shows how to modify the content of a feature manager
       
    16 # data file.
       
    17 # 
       
    18 #
       
    19 
       
    20 use strict;
       
    21 use FMCreate;
       
    22 
       
    23 #
       
    24 # Hardwire the datafile - this is only an example.
       
    25 # 
       
    26 my $datfile = "features.dat";
       
    27 my $datfile2 = "features2.dat";
       
    28 my $datfile3 = "features3.dat";
       
    29 
       
    30 #
       
    31 # Create an object that represents a feature data file.
       
    32 #
       
    33 my $fmc = FMCreate->new();
       
    34 
       
    35 #
       
    36 # Load the content of the data file into our FMCreate object.
       
    37 # Note that this will die if the content does not seem to be a feature set
       
    38 # file. This can happen if the first four bytes aren't 'feat' or if reading
       
    39 # the file fails at any point. This will also happen if the file is the wrong
       
    40 # size.
       
    41 #
       
    42 $fmc->LoadUp($datfile) or die "Failed to load up data from '$datfile'\n";
       
    43 
       
    44 #
       
    45 # Get feature flag '0x10000009'
       
    46 #
       
    47 my $ffuid = 0x10000009;
       
    48 my $ff = $fmc->GetFeatureFlagByUID($ffuid);
       
    49 if(ref($ff) ne "FeatureFlag")
       
    50 {
       
    51 	printf "Couldn't get feature flag uid 0x%0x from file $datfile\n";
       
    52 	die "no feature flag";
       
    53 }
       
    54 
       
    55 #
       
    56 # Change the feature flag.. Note that the feature flag object '$ff' is a
       
    57 # reference to the feature flag in '$fmc' - it's still in there, so when
       
    58 # we modify it here it will affect what '$fmc' will write.
       
    59 #
       
    60 $ff->BlackListed(1);
       
    61 $fmc->WriteToFile($datfile2) or die "Couldn't write feature data file '$datfile2'\n";
       
    62 
       
    63 #
       
    64 # Now add a new feature. The three arguments are UID, status flags (not defined
       
    65 # here) and user data word.
       
    66 #
       
    67 my $newfeat = FeatureFlag->new(0x12345678, undef, 0xabcd);
       
    68 die "Couldn't create new feature flag object.\n" unless(ref($newfeat));
       
    69 
       
    70 #
       
    71 # Add it to our existing feature data.
       
    72 #
       
    73 $fmc->AddFeatureFlag($newfeat) or die "Couldn't add new feature flag..\n";
       
    74 
       
    75 #
       
    76 # Remove the original feature flag.
       
    77 #
       
    78 $fmc->RemoveFeatureFlagByUID($ffuid) or die "Couldn't remove feature flag\n";
       
    79 
       
    80 $fmc->WriteToFile($datfile3);