serviceapifw_plat/rtsecuritymanager_utility_api/inc/rtsecmgrscript.h
changeset 57 61b27eec6533
parent 45 7aa6007702af
equal deleted inserted replaced
45:7aa6007702af 57:61b27eec6533
     1 /*
       
     2 * Copyright (c) 2007-2008 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 the License "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:       Models script data structure
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef _CSCRIPT_H_
       
    24 #define _CSCRIPT_H_
       
    25 
       
    26 #include <rtsecmgrcommondef.h>
       
    27 #include <rtsecmgrutility.h>
       
    28 
       
    29 /**
       
    30  * Type holding data to be used while prompting. 
       
    31  * 
       
    32  * The default or custom (runtime over-ridden) prompt handler requires the permission
       
    33  * type to prompt and the user-selection to be returned to security 
       
    34  * manager for access permission check
       
    35  * 
       
    36  * @lib rtsecmgrclient.lib
       
    37  */
       
    38 NONSHARABLE_CLASS(CScript) : public CBase
       
    39 	{
       
    40 public:
       
    41 	
       
    42 	/**
       
    43 	 * Two-phased constructor
       
    44 	 * 
       
    45 	 * Constructs a CScript instance 
       
    46 	 * 
       
    47 	 * @param aPolicyID TPolicyID policy identifier of the script
       
    48 	 * @param aScriptID TExecutableID script identifier
       
    49 	 * 
       
    50 	 * @return pointer to an instance of CScript
       
    51 	 */
       
    52 	IMPORT_C static CScript* NewL(TPolicyID aPolicyID,TExecutableID aScriptID);
       
    53 
       
    54 	/**
       
    55 	 * Two-phased constructor
       
    56 	 * 
       
    57 	 * Constructs a CScript instance and leaves the created instance
       
    58 	 * on cleanupstack 
       
    59 	 * 
       
    60 	 * @param aPolicyID TPolicyID policy identifier of the script
       
    61 	 * @param aScriptID TExecutableID script identifier
       
    62 	 * 
       
    63 	 * @return pointer to an instance of CScript
       
    64 	 */
       
    65 	IMPORT_C static CScript* NewLC(TPolicyID aPolicyID,TExecutableID aScriptID);
       
    66 
       
    67 	/*
       
    68 	 * Destructor
       
    69 	 */
       
    70 	IMPORT_C ~CScript();
       
    71 	
       
    72 	/*
       
    73 	 * overloaded assignment operator
       
    74 	 * 
       
    75 	 * @param aRhs CScript source script object specified on the right
       
    76 	 * hand side of the assignment operator
       
    77 	 * 
       
    78 	 * @return CScript returns the reference of this script object
       
    79 	 */
       
    80 	IMPORT_C const CScript& operator=(const CScript& aRhs);
       
    81 
       
    82 	/*
       
    83 	 * Gets the policy identifier of the script
       
    84 	 * 
       
    85 	 * @return TPolicyID policy identifier of the script
       
    86 	 */
       
    87 	IMPORT_C TPolicyID PolicyID() const;
       
    88 	
       
    89 	/*
       
    90 	 * Gets the script identifier
       
    91 	 * 
       
    92 	 * @return TExecutableID identifier of the script
       
    93 	 */
       
    94 	IMPORT_C TExecutableID ScriptID() const;
       
    95 	
       
    96 	/*
       
    97 	 * Gets the permissionset of the script. The permissionset
       
    98 	 * contains the list of user-grantable permissions and the list
       
    99 	 * of unconditional permissions
       
   100 	 * 
       
   101 	 * @return CPermissionSet permissionset of the script
       
   102 	 */
       
   103 	IMPORT_C const CPermissionSet& PermissionSet() const;
       
   104 
       
   105 	/*
       
   106 	 * Gets the permissionset of the script. The permissionset
       
   107 	 * contains the list of user-grantable permissions and the list
       
   108 	 * of unconditional permissions. This overloaded version returns
       
   109 	 * a modifiable reference to permissionset object.
       
   110 	 * 
       
   111 	 * @return CPermissionSet modifiable reference to permissionset of the script
       
   112 	 */
       
   113 	IMPORT_C CPermissionSet& PermissionSet();
       
   114 	
       
   115 	/*
       
   116 	 * Gets the permanently granted permissions
       
   117 	 * 
       
   118 	 * @return TPermGrant permanently granted permission
       
   119 	 * 
       
   120 	 */
       
   121 	IMPORT_C TPermGrant PermGranted() const;
       
   122 	
       
   123 	/*
       
   124 	 * Gets the permanently denied permissions
       
   125 	 * 
       
   126 	 * @return TPermGrant permanently denied permission
       
   127 	 * 
       
   128 	 */
       
   129 	IMPORT_C TPermGrant PermDenied() const;
       
   130 
       
   131 	/*
       
   132      * Gets the permanently granted providers
       
   133      * 
       
   134      * @param aAllowedProviders RProviderArray IN/OUT param which will co
       
   135      * 
       
   136      */
       
   137     IMPORT_C void PermGranted(RProviderArray& aAllowedProviders) ;
       
   138     
       
   139     /*
       
   140      * Gets the permanently denied permissions
       
   141      * 
       
   142      * @return TPermGrant permanently denied permission
       
   143      * 
       
   144      */
       
   145     IMPORT_C void PermDenied(RProviderArray& aDeniedProviders) ;
       
   146     
       
   147 	/*
       
   148 	 * Sets the permissionset of the script
       
   149 	 * 
       
   150 	 * @param aPermissionSet CPermissionSet source permissionset to be set
       
   151 	 */
       
   152 	IMPORT_C void SetPermissionSet(const CPermissionSet& aPermissionSet);
       
   153 
       
   154 	/**
       
   155 	 * Externalizes script data to stream
       
   156 	 * 
       
   157 	 * @param aOutStream RWriteStream output stream
       
   158 	 */
       
   159 	IMPORT_C void ExternalizeL(RWriteStream& aSink) const;
       
   160 	
       
   161 	/**
       
   162 	 * Internalizes script data from stream
       
   163 	 * 
       
   164 	 * @param aInStream RReadStream input source stream
       
   165 	 */
       
   166 	IMPORT_C void InternalizeL(RReadStream& aSource);
       
   167 
       
   168 	/*
       
   169 	 * Sets permanently granted permission
       
   170 	 * 
       
   171 	 * @param aPermGrant TPermGrant permanently granted permission to be set
       
   172 	 * 
       
   173 	 */
       
   174 	IMPORT_C void SetPermGranted(TPermGrant aPermGrant);
       
   175 	
       
   176 	/*
       
   177 	 * Sets permanently denied permission
       
   178 	 * 
       
   179 	 * @param aPermDenied TPermGrant permanently denied permission to be set
       
   180 	 * 
       
   181 	 */
       
   182 	IMPORT_C void SetPermDenied(TPermGrant aPermDenied);
       
   183 	
       
   184 	/*
       
   185      * Sets permanently granted permission
       
   186      * 
       
   187      * @param aPermGrant TPermGrant permanently granted permission to be set
       
   188      * 
       
   189      */
       
   190     IMPORT_C void SetPermGranted(RProviderArray aPermGrantProviders);
       
   191     
       
   192     /*
       
   193      * Sets permanently denied permission
       
   194      * 
       
   195      * @param aPermDenied TPermGrant permanently denied permission to be set
       
   196      * 
       
   197      */
       
   198     IMPORT_C void SetPermDenied(RProviderArray aPermDeniedProviders);
       
   199     
       
   200 	/*
       
   201 	 * Sets hash value of the script
       
   202 	 * 
       
   203 	 * @param aHashMark TDesC hash value of the script
       
   204 	 * 
       
   205 	 */
       
   206 	inline void SetHashMarkL(const TDesC& aHashMark);
       
   207 	
       
   208 	/*
       
   209 	 * Compares the HashValue of the script with the one passed as argument.
       
   210 	 * 
       
   211 	 * @return TBool hash values match or not.
       
   212 	 * 
       
   213 	 */
       
   214 	inline TBool HashMatch(const TDesC& aHashValue = KNullDesC) const;
       
   215 
       
   216 	/*
       
   217 	 * returns hash value of the script
       
   218 	 * 
       
   219 	 * @return TDesC hash value of the script
       
   220 	 * 
       
   221 	 */
       
   222 	inline TDesC Hash();
       
   223 	
       
   224 private:
       
   225 	/*
       
   226 	 * default private constructor
       
   227 	 * 
       
   228 	 */
       
   229 	inline CScript():iPermGrant(KDefaultNullBit),iPermDenied(KDefaultNullBit)
       
   230 		{}
       
   231 
       
   232 	/*
       
   233 	 * overloaded constructor
       
   234 	 * 
       
   235 	 * @param aPolicyID TPolicyID policy identifier of the script
       
   236 	 * @param aScriptID TExecutableID script identifier
       
   237 	 * 
       
   238 	 */
       
   239 	inline CScript(TPolicyID aPolicyID,TExecutableID aScriptID):iPolicyID(aPolicyID),iPermGrant(KDefaultNullBit),iPermDenied(KDefaultNullBit),iScriptID(aScriptID)
       
   240 		{}
       
   241 
       
   242 	/*
       
   243 	 * copy constructor
       
   244 	 * 
       
   245 	 * @param aRhs source script object
       
   246 	 */
       
   247 	CScript(const CScript& aRhs);
       
   248 
       
   249 	/*
       
   250 	 * Two-phased constructor
       
   251 	 * 
       
   252 	 */
       
   253 	void ConstructL();
       
   254  
       
   255 
       
   256 private:
       
   257 	//permission set 
       
   258 	CPermissionSet* iPermissionSet;
       
   259 	
       
   260 	//script identifier
       
   261 	TExecutableID iScriptID;
       
   262 	
       
   263 	//policy identifier of the script
       
   264 	TPolicyID iPolicyID;
       
   265 	
       
   266 	//permanently granted permission	
       
   267 	TPermGrant iPermGrant;
       
   268 	
       
   269 	//permanently denied permission
       
   270 	TPermGrant iPermDenied; //separate bit-patterns for permanently allowed & denied
       
   271 	
       
   272 	//permanently allowed providers
       
   273 	RProviderArray iAllowedProviders;
       
   274 	
       
   275 	//permanently denied providers
       
   276 	RProviderArray iDeniedProviders;
       
   277 	
       
   278 	//hash value of the script
       
   279 	HBufC* iHashMark;	
       
   280 	
       
   281 	// Reserved for future additions
       
   282 	TAny* iReserved;
       
   283 	};
       
   284 
       
   285 /*
       
   286  * Sets hash value of the script
       
   287  * 
       
   288  * @param aHashMark TDesC hash value of the script
       
   289  * 
       
   290  */
       
   291 inline void CScript::SetHashMarkL(const TDesC& aHashMark)
       
   292 	{
       
   293 	if ( iHashMark)
       
   294 		{
       
   295 		delete iHashMark;
       
   296 		}
       
   297 	iHashMark = aHashMark.AllocLC ();
       
   298 	CleanupStack::Pop ();
       
   299 	}
       
   300 
       
   301 /*
       
   302  * 
       
   303  * 
       
   304  * @return TBool Etrue
       
   305  * 
       
   306  */
       
   307 inline TBool CScript::HashMatch(const TDesC& aHashValue) const
       
   308 	{
       
   309 	TBool matches(EFalse);
       
   310 	if(iHashMark)
       
   311 		{
       
   312 		if(0==aHashValue.CompareF(*iHashMark))	
       
   313 			{
       
   314 			return !matches;
       
   315 			}
       
   316 		}
       
   317 	return matches;
       
   318 	}
       
   319 
       
   320 /*
       
   321  *
       
   322  * @return TDesC hash value of the script.
       
   323  *
       
   324  */
       
   325 
       
   326 inline TDesC CScript::Hash()
       
   327 	{
       
   328 	if(iHashMark)
       
   329 		return *iHashMark;
       
   330 	else
       
   331 		return KNullDesC;
       
   332 	}
       
   333 
       
   334 #endif //_CSCRIPT_H_
       
   335 
       
   336 // End of file