windowing/windowserver/test/tauto/themeserverpropertydefine.cpp
author hgs
Tue, 20 Jul 2010 13:27:44 +0300
changeset 121 d72fc2aace31
permissions -rw-r--r--
201027_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
121
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     2
// All rights reserved.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     7
//
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     8
// Initial Contributors:
d72fc2aace31 201027_1
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    10
//
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    11
// Contributors:
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    12
//
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    13
// Description:
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    14
// This Process called with the argument KThemeServerPropertyDefineCmdDefine, defines
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    15
// the theme server RProperty catagory to be the same as the theme servers process ID. 
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    16
// Called with the argument KThemeServerPropertyDefineCmdDelete, it will delete the 
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    17
// theme server RProperty. This is because an RProperty can only be defined and deleted 
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    18
// from within a process with the same UID3 as the RProperty catogory you are trying to 
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    19
// define/delete.
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    20
//
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    21
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    22
/**
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    23
 @file
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    24
 @test
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    25
 @internalComponent - Internal Nokia test code
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    26
 */
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    27
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    28
#include <BACLINE.H> 
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    29
#include <e32base.h>
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    30
#include <e32property.h>
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    31
#include "..\..\nga\server\renderorientationtracker.h" //for KThemeOrientationCatagory and KThemeOrientationKey
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    32
#include "themeserverpropertydefine.h"
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    33
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    34
void DefineThemeServerPropertyL()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    35
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    36
    RProperty themeServerOrientationProperty;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    37
    const TSecurityPolicy KThemeOrientationReadSecurityPolicy(
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    38
            TSecurityPolicy::EAlwaysPass);
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    39
    const TSecurityPolicy KThemeOrientationWriteSecurityPolicy(
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    40
            TSecurityPolicy::EAlwaysPass);
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    41
    User::LeaveIfError(RProperty::Define(   KThemeOrientationCategory,
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    42
                                            KThemeOrientationKey, 
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    43
                                            RProperty::EInt,
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    44
                                            KThemeOrientationReadSecurityPolicy,
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    45
                                            KThemeOrientationWriteSecurityPolicy));
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    46
    themeServerOrientationProperty.Close();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    47
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    48
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    49
void DeleteThemeServerPropertyL()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    50
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    51
    TInt err = KErrNone;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    52
    RProperty themeServerOrientationProperty;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    53
    User::LeaveIfError(themeServerOrientationProperty.Delete(
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    54
            KThemeOrientationCategory, KThemeOrientationKey));
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    55
    themeServerOrientationProperty.Close();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    56
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    57
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    58
void MainL()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    59
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    60
    CCommandLineArguments* args = CCommandLineArguments::NewLC();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    61
    TPtrC argumentPrt(args->Arg(1));
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    62
    if (argumentPrt == KThemeServerPropertyDefineCmdDefine)
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    63
        {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    64
        DefineThemeServerPropertyL();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    65
        }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    66
    else if (argumentPrt == KThemeServerPropertyDefineCmdDelete)
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    67
        {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    68
        DeleteThemeServerPropertyL();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    69
        }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    70
    else
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    71
        {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    72
        User::Leave(KErrNotSupported);
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    73
        }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    74
    CleanupStack::PopAndDestroy(args);
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    75
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    76
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    77
GLDEF_C TInt E32Main()
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    78
    {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    79
    CTrapCleanup* cleanUpStack = CTrapCleanup::New();
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    80
    if (cleanUpStack == NULL)
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    81
        {
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    82
        return KErrNoMemory;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    83
        }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    84
    TRAPD(err, MainL());
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    85
    delete cleanUpStack;
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    86
    return (err);
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    87
    }
d72fc2aace31 201027_1
hgs
parents:
diff changeset
    88