os/ossrv/genericservices/taskscheduler/Test/TSUtils/TPropertyDefine.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32base.h>
sl@0
    17
#include <e32property.h>
sl@0
    18
#include <numberconversion.h>
sl@0
    19
#include <swi/swispubsubdefs.h>
sl@0
    20
sl@0
    21
using namespace Swi;
sl@0
    22
sl@0
    23
_LIT(KSeparator, "|"); // Invalid filepath char used to separate filenames
sl@0
    24
sl@0
    25
	
sl@0
    26
//This function defines a P&S variable as requested by the parameters
sl@0
    27
static TInt CreateVariableL(TUid aCategory, TInt aKey, TInt aAttr)
sl@0
    28
	{
sl@0
    29
	TSecurityPolicy readPolicy = TSecurityPolicy::EAlwaysPass;
sl@0
    30
	TSecurityPolicy writePolicy = TSecurityPolicy::EAlwaysPass;
sl@0
    31
	
sl@0
    32
	TInt err = RProperty::Define(aCategory, aKey, aAttr, readPolicy, writePolicy);
sl@0
    33
	
sl@0
    34
	if(err != KErrAlreadyExists)
sl@0
    35
		{
sl@0
    36
		//This will leave for any value other than KErrNone
sl@0
    37
		User::LeaveIfError(err);	
sl@0
    38
		}
sl@0
    39
		
sl@0
    40
	//If the variable is already defined then return KErrNone as this is fine,
sl@0
    41
	return KErrNone;
sl@0
    42
	}
sl@0
    43
sl@0
    44
GLDEF_C TInt E32Main()
sl@0
    45
    {
sl@0
    46
    	
sl@0
    47
    CTrapCleanup* cleanup = CTrapCleanup::New(); 
sl@0
    48
	
sl@0
    49
	TDigitType digitType;
sl@0
    50
	TInt length;
sl@0
    51
	TBuf<32> args;
sl@0
    52
	User::CommandLine(args);
sl@0
    53
	TInt error;
sl@0
    54
	
sl@0
    55
	TInt pos = args.Find(KSeparator);
sl@0
    56
	
sl@0
    57
	if(pos > 0)
sl@0
    58
		{
sl@0
    59
		TInt32 category = NumberConversion::ConvertFirstNumber(args.Mid(0,pos), length, digitType);
sl@0
    60
		TUid categoryUid = TUid::Uid(category);
sl@0
    61
		TPtrC remainder = args.Mid(pos+1, args.Length()-(pos+1));
sl@0
    62
		pos = remainder.Find(KSeparator);
sl@0
    63
		TUint key = NumberConversion::ConvertFirstNumber(remainder.Mid(0,pos), length, digitType);
sl@0
    64
		TInt attr =	NumberConversion::ConvertFirstNumber(
sl@0
    65
			remainder.Mid(pos+1, remainder.Length()-(pos+1)), length, digitType
sl@0
    66
			);
sl@0
    67
		
sl@0
    68
		//create the appropriate variable
sl@0
    69
		error = CreateVariableL(categoryUid, key, attr);			
sl@0
    70
		}
sl@0
    71
		
sl@0
    72
	else error = pos;
sl@0
    73
sl@0
    74
	delete cleanup;
sl@0
    75
	return error;	
sl@0
    76
    	
sl@0
    77
	}