contextframework/cfw/inc/cfserver/CFEngine.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2002-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 "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:  CCFEngine class declaration.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CFENGINE_H
       
    20 #define C_CFENGINE_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 #include "cfcontextobject.h"
       
    27 #include "CFServSession.h"
       
    28 #include "cfextendedcontextinterface.h"
       
    29 #include "CFActionInterface.h"
       
    30 #include "CFScriptInterface.h"
       
    31 #include "cfactionhandler.h"
       
    32 #include "cfcommon.h"
       
    33 #include "CFSecurityChecker.h"
       
    34 #include "cfcontextsourcecommandinterface.h"
       
    35 
       
    36 class CCFContextManager;
       
    37 class CCFStarter;
       
    38 class CCFEComObserver;
       
    39 class CCFServSession;
       
    40 class CCFContextSourceManager;
       
    41 class CCFScriptHandler;
       
    42 class CCFActivator;
       
    43 class MCFActionSubscriptionListener;
       
    44 class CCFAsyncCmdQueue;
       
    45 class CCFScriptEvent;
       
    46 
       
    47 
       
    48 /**
       
    49 * Context Framework Engine class.
       
    50 */
       
    51 NONSHARABLE_CLASS( CCFEngine ): public CBase,
       
    52     public MCFExtendedContextInterface,
       
    53     public MCFActionInterface,
       
    54     public MCFScriptInterface,
       
    55     public MCFActionHandler,
       
    56     public MCFContextSourceCommand
       
    57     {
       
    58     public: // New methods
       
    59     
       
    60         static CCFEngine* NewL( MCFSecurityChecker& aSecurityChecker );
       
    61         static CCFEngine* NewLC( MCFSecurityChecker& aSecurityChecker );
       
    62 
       
    63         ~CCFEngine();
       
    64         
       
    65     private: // From base classes
       
    66     
       
    67         // @see MCFContextInterface
       
    68         TInt DefineContext( const TDesC& aContextSource,
       
    69             const TDesC& aContextType,
       
    70             const TSecurityPolicy& aReadWritePolicy );
       
    71             
       
    72         // @see MCFContextInterface
       
    73         TInt DefineContext( const TDesC& aContextSource,
       
    74             const TDesC& aContextType,
       
    75             const TSecurityPolicy& aReadWritePolicy,
       
    76             MCFContextSource& aOwner );
       
    77             
       
    78         // @see MCFContextInterface
       
    79         TInt DefineContext( const TDesC& aContextSource,
       
    80             const TDesC& aContextType,
       
    81             const TSecurityPolicy& aReadPolicy,
       
    82             const TSecurityPolicy& aWritePolicy,
       
    83             MCFContextSource& aOwner );
       
    84 
       
    85         // @see MCFContextInterface
       
    86         TInt PublishContext( CCFContextObject& aContext,
       
    87             RThread& aClientThread );
       
    88         
       
    89         // @see MCFContextInterface
       
    90         TInt PublishContext( CCFContextObject& aContext,
       
    91             CCFContextDataObject& aData,
       
    92             RThread& aClientThread );
       
    93         
       
    94         // @see MCFContextInterface
       
    95         TInt SubscribeContext( CCFContextSubscription* aSubscription,
       
    96             MCFContextSubscriptionListener* aListener,
       
    97             RThread& aClientThread );
       
    98         
       
    99         // @see MCFContextInterface
       
   100         void UnsubscribeContext( CCFContextSubscription& aSubscription,
       
   101             MCFContextSubscriptionListener& aListener );
       
   102                 
       
   103         // @see MCFContextInterface
       
   104         void UnsubscribeContexts(
       
   105             MCFContextSubscriptionListener& aObserver );
       
   106         
       
   107         // @see MCFContextInterface
       
   108         TInt RequestContext(
       
   109             RContextObjectArray& aResultBuffer,
       
   110             CCFContextQuery& aContextQuery,
       
   111             RThread& aClientThread );
       
   112 
       
   113 		// @see MCFContextInterface            
       
   114         TInt GetSecurityPolicy( const TDesC& aContextSource,
       
   115             const TDesC& aContextType,
       
   116 			TSecurityPolicy& aPolicy );
       
   117 
       
   118         // @see MCFExtendedContextInterface
       
   119 		TInt GetReadSecurityPolicy( const TDesC& aContextSource,
       
   120 				const TDesC& aContextType,
       
   121 				TSecurityPolicy& aPolicy );
       
   122 
       
   123 		// @see MCFExtendedContextInterface
       
   124 		TInt GetWriteSecurityPolicy( const TDesC& aContextSource,
       
   125 				const TDesC& aContextType,
       
   126 				TSecurityPolicy& aPolicy );
       
   127 		
       
   128 		// @see MCFExtendedContextInterface
       
   129         TInt DefineContext( const TDesC& aContextSource,
       
   130                 const TDesC& aContextType,
       
   131                 const TSecurityPolicy& aReadPolicy,
       
   132                 const TSecurityPolicy& aWritePolicy,
       
   133                 MCFContextSource* aPublisher, const TUid& aPublisherUid );
       
   134             
       
   135         // @see MCFExtendedContextInterface
       
   136         void DeregisterPublisher( MCFContextSource& aPublisher );
       
   137 
       
   138         // @see MCFExtendedContextInterface
       
   139         TInt InstallContextSourceSetting( RFile& aSettingFile,
       
   140                 const TUid& aContextSourceUid,
       
   141                 RThread& aClientThread );
       
   142         
       
   143         // @see MCFExtendedContextInterface
       
   144         TInt UninstallContextSourceSetting( const TDesC& aSettingFilename,
       
   145                 const TUid& aContextSourceUid,
       
   146                 RThread& aClientThread );
       
   147         
       
   148         // @see MCFExtendedContextInterface
       
   149         TInt UninstallContextSourceSettings( const TUid& aContextSourceUid,
       
   150                 RThread& aClientThread );
       
   151         
       
   152         // @see MCFExtendedContextInterface
       
   153         TInt PublishContextFromAction( CCFContextObject& aContext,
       
   154             TBool aAutoDefine );
       
   155         
       
   156         // @see MCFActionInterface
       
   157         TInt DefineAction( const TDesC& aActionIdentifier,
       
   158             const TSecurityPolicy& aSecurityPolicy,
       
   159             const TUid& aOwnerUid,
       
   160             MCFActionOwner* aOwner );
       
   161         
       
   162         // @see MCFActionInterface
       
   163         TInt SubscribeAction(
       
   164             CCFActionSubscription* aActionSubscription,
       
   165             MCFActionSubscriptionListener* aListener,
       
   166             RThread& aClientThread );            
       
   167 
       
   168         // @see MCFActionInterface
       
   169         void UnsubscribeAction( CCFActionSubscription& aActionSubscription,
       
   170             MCFActionSubscriptionListener& aListener );
       
   171             
       
   172         // @see MCFActionInterface
       
   173         void UnsubscribeActions( MCFActionSubscriptionListener& aListener );
       
   174         
       
   175         // @see MCFActionInterface
       
   176         void DeregisterActions( MCFActionOwner* aOwner );
       
   177         
       
   178         // @see MCFScriptInterface 
       
   179         TInt RegisterScript( const TDesC& aName,
       
   180             const TDesC8& aScript,
       
   181             TInt& aScriptId,
       
   182             const RThread& aClientThread,
       
   183             MCFScriptOwner& aOwner );
       
   184         
       
   185         // @see MCFScriptInterface 
       
   186         TInt DeregisterScript( TInt aScriptId,
       
   187             const RThread& aClientThread );
       
   188 
       
   189         // @see MCFScriptInterface 
       
   190         TInt DeregisterScript( const TDesC& aScriptName,
       
   191             const RThread& aClientThread );
       
   192         
       
   193         // @see MCFScriptInterface
       
   194         TInt DeregisterScripts( const RThread& aClientThread );
       
   195 
       
   196         // @see MCFScriptInterface
       
   197         void DeregisterScriptOwner( MCFScriptOwner& aOwner );
       
   198 
       
   199         // @see MCFScriptInterface 
       
   200         TInt SaveScript( const TDesC8& aScript,
       
   201             TInt aScriptId,
       
   202             const RThread& aClient );
       
   203 
       
   204         // @see MCFScriptInterface 
       
   205         TInt DeleteScript( const TDesC& aScriptName,
       
   206             RThread& aClientThread );
       
   207         
       
   208         // @see MCFScriptInterface 
       
   209         TInt DeleteScripts( RThread& aClientThread );
       
   210         
       
   211         // @see MCFScriptInterface 
       
   212         TBool AlreadyExists( const TDesC& aScriptName,
       
   213             const RThread& aClient,
       
   214             TInt& aScriptId ) const;
       
   215             
       
   216         // @see MCFScriptInterface 
       
   217         void CleanupPersistentDataByName( const TDesC& aScriptName,
       
   218             const RThread& aClientThread );
       
   219         
       
   220         // @see MCFScriptInterface 
       
   221         void CleanupPersistentDataByUid( const RThread& aClient );
       
   222         
       
   223         // @see MCFScriptInterface 
       
   224         TInt UpdateScript( TInt aScriptID,
       
   225             const RThread& aOwnerThread,
       
   226             const TDesC8& aUpdatedScript,
       
   227             MCFScriptOwner& aOwner );
       
   228         
       
   229         // @see MCFScriptInterface 
       
   230         TInt RestoreRomScript( TInt aScriptId, const RThread& aClient );
       
   231 
       
   232         // @see MCFScriptInterface 
       
   233         TInt IsUpgradeAllowed( const TDesC& aName,
       
   234             const TDesC8& aScript,
       
   235             const RThread& aOwnerThread );
       
   236 
       
   237         // @see MCFActionHandler 
       
   238         void FireActionL( CCFScriptEvent* aEvent );
       
   239 
       
   240         // From MCFActionHandler
       
   241         void FireActionL( const CCFContextSourceCommand& aCommand );
       
   242 
       
   243         // @see MCFActionHandler 
       
   244         TInt GetActionSecurityPolicy( const TDesC& aActionIdentifier,
       
   245             TSecurityPolicy& aPolicy );
       
   246 
       
   247         // @see MCFContextSourceCommand
       
   248         void HandleCommandL( const CCFContextSourceCommand& aCommand );
       
   249 
       
   250     private: // New functions
       
   251 
       
   252         /**
       
   253          * Appends publish context into asynchronous command queue if the
       
   254          * context publication is valid.
       
   255          * 
       
   256          * Leaves with:
       
   257          * - KErrNotFound, context not defined
       
   258          * - KErrAccessDenied, insufficient capabilities to write the context
       
   259          * - any other system-wide error code
       
   260          * 
       
   261          * @since S60 5.0
       
   262          * @param aContext Context object to be published.
       
   263          * @param aClientThread Handle to the current client.
       
   264          * @param aData Data object associated with the context.
       
   265          * @return None.
       
   266          */
       
   267         void EnqueuePublishContextL( CCFContextObject& aContext,
       
   268             RThread& aClientThread,
       
   269             CCFContextDataObject* aData = NULL );
       
   270 
       
   271         /**
       
   272          * Adds unsubscribe context cleanup into front of asynchronous command
       
   273          * queue.
       
   274          * 
       
   275          * Leaves with:
       
   276          * - KErrNoMemory, no memory to create the command
       
   277          * - any other system-wide error code
       
   278          * 
       
   279          * @since S60 5.0
       
   280          * @return None.
       
   281          */
       
   282         void EnqueueUnsubscribeContextCleanupL();
       
   283 
       
   284         /**
       
   285          * Appends fire action into asynchronous command queue.
       
   286          * 
       
   287          * Leaves with:
       
   288          * - KErrNoMemory, no memory to create the command
       
   289          * - any other system-wide error code
       
   290          * 
       
   291          * @since S60 5.0
       
   292          * @param aActionHandler Action handler for firing the action.
       
   293          * @param aEvent The action (script event). Ownership is transferred.
       
   294          * @return None.
       
   295          */
       
   296         void EnqueueFireActionL( MCFActionHandler& aActionHandler,
       
   297                 CCFScriptEvent* aEvent );
       
   298 
       
   299         /**
       
   300          * Appends source command action into asynchronous command queue.
       
   301          * 
       
   302          * Leaves with:
       
   303          * - KErrNoMemory, no memory to create the command
       
   304          * - any other system-wide error code
       
   305          * 
       
   306          * @since S60 5.0
       
   307          * @param aSourceCommandHandler Source command handler.
       
   308          * @param aCommand The context source command action.
       
   309          * @return None.
       
   310          */
       
   311         void EnqueueSourceCommandActionL(
       
   312                 MCFContextSourceCommand& aSourceCommandHandler,
       
   313                 const CCFContextSourceCommand& aCommand );
       
   314 
       
   315     private:
       
   316     
       
   317         void ConstructL();
       
   318         CCFEngine( MCFSecurityChecker& aSecurityChecker );
       
   319         
       
   320     private: // Data
       
   321     
       
   322         // Own: CF starter
       
   323         CCFStarter* iStarter;
       
   324         
       
   325         // Own: ECom observer
       
   326         CCFEComObserver* iEComObserver;
       
   327     
       
   328         // Own: Data manager
       
   329         CCFContextManager* iContextManager;
       
   330         
       
   331         // Own: Context source manager
       
   332         CCFContextSourceManager* iContextSourceManager;
       
   333         
       
   334         // Own: Script Engine
       
   335         CCFScriptHandler* iScriptEngine;
       
   336         
       
   337         // Own: Activator engine
       
   338         CCFActivator* iActivatorEngine;
       
   339         
       
   340         // Own: File server session.
       
   341         // Keep this as the only session for whole CF!
       
   342         RFs iFs;
       
   343         
       
   344         // CFSecurityChecker
       
   345         MCFSecurityChecker* iSecurityChecker;
       
   346         
       
   347         // Maximum data object size
       
   348         TInt iMaxDataObjectSize;
       
   349 
       
   350         // Own: Queue for asynchronous commands.
       
   351         CCFAsyncCmdQueue* iAsyncCmdQueue;
       
   352     };
       
   353 
       
   354 #endif  // C_CFENGINE_H