1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/featuremgmt/featuremgr/test/helper/dummyswi/src/dummyswi.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,122 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +#include "dummyswi.h"
1.21 +#include <e32base.h>
1.22 +#include <eikenv.h>
1.23 +#include <e32property.h>
1.24 +#include <sacls.h>
1.25 +#include <bacline.h> //CCommandLineArguments
1.26 +
1.27 +// This exe is used to simulate the Software Installer behaviour of setting and resetting
1.28 +// the P&S KSAUidSoftwareInstallKeyValue property.
1.29 +
1.30 +LOCAL_C void DoStartL()
1.31 + {
1.32 + CCommandLineArguments* args = CCommandLineArguments::NewLC();
1.33 + TInt i = args->Count();
1.34 +
1.35 + if ( args->Count() == 2 )
1.36 + {
1.37 + TLex tlex(args->Arg(1));
1.38 + TInt argVal = 0;
1.39 + if ( tlex.Val(argVal) == KErrNone )
1.40 + {
1.41 + RProperty propertyHndl;
1.42 + User::LeaveIfError(propertyHndl.Attach(KUidSystemCategory, KSAUidSoftwareInstallKeyValue));
1.43 + TInt initialVal = 0;
1.44 +
1.45 + // Get initial value
1.46 + TInt err = propertyHndl.Get(initialVal);
1.47 +
1.48 + // 1 => Successful installation
1.49 + // 4 => Successful uninstallation
1.50 + if(argVal == 1 || argVal == 4 )
1.51 + {
1.52 + // Imitate the start of SWI
1.53 + TInt val = initialVal;
1.54 + if(argVal == 1)
1.55 + {
1.56 + val |= ESASwisInstall;
1.57 + }
1.58 + else
1.59 + {
1.60 + val |= ESASwisUninstall;
1.61 + }
1.62 + err = propertyHndl.Set(val);
1.63 +
1.64 + // Wait for the test case to finish and for the P&S value to be set
1.65 + User::After(1200000);
1.66 +
1.67 + // Imitate the successful completion of SWI
1.68 + val |= ESASwisStatusSuccess;
1.69 + err = propertyHndl.Set(val);
1.70 +
1.71 + // wait for RProperty::Set() to complete
1.72 + User::After(100000);
1.73 + }
1.74 + // 2 => Aborted installation
1.75 + // 3 => Hanging installation
1.76 + // 5 => Aborted uninstallation
1.77 + // 6 =? Hanging uninstallation
1.78 + else if(argVal == 2 || argVal == 3 || argVal == 5 || argVal == 6)
1.79 + {
1.80 + // Imitate the start of SWI
1.81 + TInt val = initialVal;
1.82 + if( argVal == 2 || argVal == 3)
1.83 + {
1.84 + val |= ESASwisInstall;
1.85 + }
1.86 + else
1.87 + {
1.88 + val |= ESASwisUninstall;
1.89 + }
1.90 + err = propertyHndl.Set(val);
1.91 +
1.92 + // Wait for the test case to finish
1.93 + if( argVal == 3 || argVal == 6 )
1.94 + {
1.95 + User::After(16500000);
1.96 + }
1.97 + else
1.98 + {
1.99 + User::After(1200000);
1.100 + }
1.101 +
1.102 + // Imitate the successful completion of SWI
1.103 + val |= ESASwisStatusAborted;
1.104 + err = propertyHndl.Set(val);
1.105 +
1.106 + // wait for RProperty::Set() to complete
1.107 + User::After(100000);
1.108 + }
1.109 + // Reset initial value for P&S install property
1.110 + err = propertyHndl.Set(initialVal);
1.111 + propertyHndl.Close();
1.112 + }
1.113 + }
1.114 + CleanupStack::PopAndDestroy(); //args
1.115 + }
1.116 +
1.117 +GLDEF_C TInt E32Main()
1.118 + {
1.119 + __UHEAP_MARK;
1.120 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.121 + TRAPD( err, DoStartL() );
1.122 + delete cleanup;
1.123 + __UHEAP_MARKEND;
1.124 + return err;
1.125 + }