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