serviceapifw_plat/rtsecuritymanager_utility_api/inc/rtsecmgrscript.h
changeset 0 99ef825efeca
child 18 a7062f7f0b79
equal deleted inserted replaced
-1:000000000000 0:99ef825efeca
       
     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 	 * Sets the permissionset of the script
       
   133 	 * 
       
   134 	 * @param aPermissionSet CPermissionSet source permissionset to be set
       
   135 	 */
       
   136 	IMPORT_C void SetPermissionSet(const CPermissionSet& aPermissionSet);
       
   137 
       
   138 	/**
       
   139 	 * Externalizes script data to stream
       
   140 	 * 
       
   141 	 * @param aOutStream RWriteStream output stream
       
   142 	 */
       
   143 	IMPORT_C void ExternalizeL(RWriteStream& aSink) const;
       
   144 	
       
   145 	/**
       
   146 	 * Internalizes script data from stream
       
   147 	 * 
       
   148 	 * @param aInStream RReadStream input source stream
       
   149 	 */
       
   150 	IMPORT_C void InternalizeL(RReadStream& aSource);
       
   151 
       
   152 	/*
       
   153 	 * Sets permanently granted permission
       
   154 	 * 
       
   155 	 * @param aPermGrant TPermGrant permanently granted permission to be set
       
   156 	 * 
       
   157 	 */
       
   158 	IMPORT_C void SetPermGranted(TPermGrant aPermGrant);
       
   159 	
       
   160 	/*
       
   161 	 * Sets permanently denied permission
       
   162 	 * 
       
   163 	 * @param aPermDenied TPermGrant permanently denied permission to be set
       
   164 	 * 
       
   165 	 */
       
   166 	IMPORT_C void SetPermDenied(TPermGrant aPermDenied);
       
   167 	
       
   168 	/*
       
   169 	 * Sets hash value of the script
       
   170 	 * 
       
   171 	 * @param aHashMark TDesC hash value of the script
       
   172 	 * 
       
   173 	 */
       
   174 	inline void SetHashMarkL(const TDesC& aHashMark);
       
   175 	
       
   176 	/*
       
   177 	 * Compares the HashValue of the script with the one passed as argument.
       
   178 	 * 
       
   179 	 * @return TBool hash values match or not.
       
   180 	 * 
       
   181 	 */
       
   182 	inline TBool HashMatch(const TDesC& aHashValue = KNullDesC) const;
       
   183 
       
   184 	/*
       
   185 	 * returns hash value of the script
       
   186 	 * 
       
   187 	 * @return TDesC hash value of the script
       
   188 	 * 
       
   189 	 */
       
   190 	inline TDesC Hash();
       
   191 	
       
   192 private:
       
   193 	/*
       
   194 	 * default private constructor
       
   195 	 * 
       
   196 	 */
       
   197 	inline CScript():iPermGrant(KDefaultNullBit),iPermDenied(KDefaultNullBit)
       
   198 		{}
       
   199 
       
   200 	/*
       
   201 	 * overloaded constructor
       
   202 	 * 
       
   203 	 * @param aPolicyID TPolicyID policy identifier of the script
       
   204 	 * @param aScriptID TExecutableID script identifier
       
   205 	 * 
       
   206 	 */
       
   207 	inline CScript(TPolicyID aPolicyID,TExecutableID aScriptID):iPolicyID(aPolicyID),iPermGrant(KDefaultNullBit),iPermDenied(KDefaultNullBit),iScriptID(aScriptID)
       
   208 		{}
       
   209 
       
   210 	/*
       
   211 	 * copy constructor
       
   212 	 * 
       
   213 	 * @param aRhs source script object
       
   214 	 */
       
   215 	CScript(const CScript& aRhs);
       
   216 
       
   217 	/*
       
   218 	 * Two-phased constructor
       
   219 	 * 
       
   220 	 */
       
   221 	void ConstructL();
       
   222  
       
   223 
       
   224 private:
       
   225 	//permission set 
       
   226 	CPermissionSet* iPermissionSet;
       
   227 	
       
   228 	//script identifier
       
   229 	TExecutableID iScriptID;
       
   230 	
       
   231 	//policy identifier of the script
       
   232 	TPolicyID iPolicyID;
       
   233 	
       
   234 	//permanently granted permission	
       
   235 	TPermGrant iPermGrant;
       
   236 	
       
   237 	//permanently denied permission
       
   238 	TPermGrant iPermDenied; //separate bit-patterns for permanently allowed & denied
       
   239 	
       
   240 	//hash value of the script
       
   241 	HBufC* iHashMark;	
       
   242 	};
       
   243 
       
   244 /*
       
   245  * Sets hash value of the script
       
   246  * 
       
   247  * @param aHashMark TDesC hash value of the script
       
   248  * 
       
   249  */
       
   250 inline void CScript::SetHashMarkL(const TDesC& aHashMark)
       
   251 	{
       
   252 	if ( iHashMark)
       
   253 		{
       
   254 		delete iHashMark;
       
   255 		}
       
   256 	iHashMark = aHashMark.AllocLC ();
       
   257 	CleanupStack::Pop ();
       
   258 	}
       
   259 
       
   260 /*
       
   261  * 
       
   262  * 
       
   263  * @return TBool Etrue
       
   264  * 
       
   265  */
       
   266 inline TBool CScript::HashMatch(const TDesC& aHashValue) const
       
   267 	{
       
   268 	TBool matches(EFalse);
       
   269 	if(iHashMark)
       
   270 		{
       
   271 		if(0==aHashValue.CompareF(*iHashMark))	
       
   272 			{
       
   273 			return !matches;
       
   274 			}
       
   275 		}
       
   276 	return matches;
       
   277 	}
       
   278 
       
   279 /*
       
   280  *
       
   281  * @return TDesC hash value of the script.
       
   282  *
       
   283  */
       
   284 
       
   285 inline TDesC CScript::Hash()
       
   286 	{
       
   287 	if(iHashMark)
       
   288 		return *iHashMark;
       
   289 	else
       
   290 		return KNullDesC;
       
   291 	}
       
   292 
       
   293 #endif //_CSCRIPT_H_
       
   294 
       
   295 // End of file