class CCFClient : public CBase |
Client side API of Context Framework.
Define contexts
Publish contexts
Subscribe contexts
Define actions
Subscribe actions
Register new scripts
Deregister scripts
Before contexts can be published or subscribed it first needs to be defined. Otherwise error code will be returned to client side.
Before actions can be subscribed they must be defined. Every action must be secured with a security policy. If your action does not need any security, NONE capabilities can be defined.
Client application can request contexts that have been published in Context Framework. Contexts will be delivered in an array. Array will contain all the context objects where the client has sufficient capabilities.
This class is not intended for user derivation.
Below is described is described examples how to utilze Context Framework Client.
CCFClient* client = CCFClient::NewLC( *this ); CleanupStack::PopAndDestroy( client );
_LIT( KContextSource, "Source" ); _LIT( KContextType, "Type" ); _LIT_SECURITY_POLICY_PASS( KContextSec ); CCFClient* client = CCFClient::NewLC( *this ); TInt err = client->DefineContext( KContextSource, KContextType, KContextSec ); if( err != KErrNone ) { // handle error } CleanupStack::PopAndDestroy( client );
_LIT( KContextSource, "Source" ); _LIT( KContextType, "Type" ); _LIT( KContextValue, "Value" ); CCFContextObject* co = CCFContextObject::NewLC(); co->SetSourceL( KContextSource ); co->SetTypeL( KContextType ); co->SetValueL( KContextValue ); CCFClient* client = CCFClient::NewLC( *this ); TInt err = client->PublishContext( *co ); if( err != KErrNone ) { // handle error } CleanupStack::PopAndDestroy( client ); CleanupStack::PopAndDestroy( co );
_LIT( KContextSource, "Source" ); _LIT( KContextType, "Type" ); _LIT( KContextValue, "Value" ); CCFClient* client = CCFClient::NewLC( *this ); CCFContextSubscription* subscription = CCFContextSubscription::NewLC(); subscription->SetSourceL( KContextSource ); subscription->SetTypeL( KContextType ); TInt err = client->SubscribeContext( *subscription ); if( err != KErrNone ) { // handle error } CleanupStack::PopAndDestroy( subscription ); CleanupStack::PopAndDestroy( client );
_LIT( KContextSource, "Source" ); _LIT( KContextType, "Type" ); CCFContextQuery* query = CCFContextQuery::NewLC(); query->SetSourceL( KContextSource ); query->SetTypeL( KContextType ); CCFClient* client = CCFClient::NewLC( *this ); RContextObjectArray result; TInt err = client->RequestContext( query, result ); if( err != KErrNone ) { // handle error } else if( result.Count() ) { // handle result } result.ResetAndDestroy(); CleanupStack::PopAndDestroy( client ); CleanupStack::PopAndDestroy( query );
_LIT( KAction, "ActionId" ); _LIT_SECURITY_POLICY_PASS( KActionSec ); CCFClient* client = CCFClient::NewLC( *this ); TInt err = client->DefineAction( KAction, KActionSec ); if( err != KErrNone ) { // handle error } CleanupStack::PopAndDestroy( client );
_LIT( KAction, "ActionId" ); CCFClient* client = CCFClient::NewLC( *this ); CCFActionSubscription* subscription = CCFActionSubscription::NewLC(); subscription->SetActionIdentifierL( KAction ); TInt err = client->SubscribeAction( *subscription ); if( err != KErrNone ) { // handle error } CleanupStack::PopAndDestroy( subscription ); CleanupStack::PopAndDestroy( client );
_LIT( KScriptPath, "c:\\data\\myscripts\\script.rul" ); CCFClient* client = CCFClient::NewLC( *this ); TInt ruleId = 0; TInt err = client->RegisterScript( KScriptPath, ruleId ); if( err != KErrNone ) { // handle error } CleanupStack::PopAndDestroy( client );
_LIT( KScriptPath, "c:\\data\\myscripts\\script.rul" ); CCFClient* client = CCFClient::NewLC( *this ); TInt ruleId = 0; TInt err = client->RegisterScript( KScriptPath, ruleId ); if( err != KErrNone ) { // handle error } err = client->DeregisterScript( ruleId ); if( err != KErrNone ) { // handle error } CleanupStack::PopAndDestroy( client );
TInt | DefineAction | ( | const TDesC & | aActionIdentifier, |
const TSecurityPolicy & | aSecurityPolicy | |||
) | [pure virtual] |
Defines an action in Context Framework. When action is defined in Context Framework it can be subscribed. When the action is needed to be executed action indication is received through MCFListener interface. Notice that actions can be defined also from action plug-ins. If some action plug-in has already defined the action in hand action definition will fail.
const TDesC & aActionIdentifier | Action identifier. |
const TSecurityPolicy & aSecurityPolicy | Security policy for the action. |
TInt | DefineContext | ( | const TDesC & | aContextSource, |
const TDesC & | aContextType, | |||
const TSecurityPolicy & | aReadWritePolicy | |||
) | [pure virtual] |
Defines a new context in Context Framework. Every context needs to be defined before it can be published, subscribed or requested.
Security policy for reading and writing is the same.
If some client subscribes for this context, the contex owner will be notified through MCFContextSource interface. MCFContextSource interface will be enquired through MCFListener interface extension.
const TDesC & aContextSource | Source of the context. |
const TDesC & aContextType | Type of the context. |
const TSecurityPolicy & aReadWritePolicy | Needed capabilities for the context. |
TInt | DefineContext | ( | const TDesC & | aContextSource, |
const TDesC & | aContextType, | |||
const TSecurityPolicy & | aReadPolicy, | |||
const TSecurityPolicy & | aWritePolicy | |||
) | [pure virtual] |
Defines a new context in Context Framework. Every context needs to be defined before it can be published, subscribed or requested.
Security policy for reading and writing are different.
If some client subscribes for this context, the contex owner will be notified through MCFContextSource interface. MCFContextSource interface will be enquired through MCFListener interface extension.
const TDesC & aContextSource | Source of the context. |
const TDesC & aContextType | Type of the context. |
const TSecurityPolicy & aReadPolicy | Needed capabilities for reading context value. |
const TSecurityPolicy & aWritePolicy | Needed capabilities for writing context value. |
TInt | DeleteContextSourceSetting | ( | const TDesC & | aSettingFilename, |
const TUid & | aContextSourceUid | |||
) | [pure virtual] |
Deletes a context source setting in Context Framework. Setting is removed if uninstall succeeds.
TInt | DeleteContextSourceSettings | ( | const TUid & | aContextSourceUid | ) | [pure virtual] |
Uninstalls context source settings registered by a client in Context Framework. Uninstalls all settings ever registered by the client for the context source. Settings are removed if uninstall succeeds.
const TUid & aContextSourceUid | Implementation UID of the context source. |
TInt | DeleteScript | ( | const TDesC & | aScriptFileName | ) | [pure virtual] |
Delete a script from Context Framework private folder. The script will be automatically deregistered.
const TDesC & aScriptFileName |
TInt | DeleteScripts | ( | ) | [pure virtual] |
Delete all scripts from Context Framework private folder added by the particular process. All the scripts are automatically deregistered.
TInt | DeregisterScript | ( | TInt | aScriptId | ) | [pure virtual] |
Deregisters a script in Context Framework.
TInt aScriptId | Script obtained from RegisterScript -method. |
IMPORT_C CCFClient * | NewL | ( | MCFListener & | aListener | ) | [static] |
MCFListener & aListener | Context Framework listener interface. |
IMPORT_C CCFClient * | NewLC | ( | MCFListener & | aListener | ) | [static] |
MCFListener & aListener |
TInt | PublishContext | ( | CCFContextObject & | aContext | ) | [pure virtual] |
Publishes a new value of a context into Context Framework. Subscribed clients will be notified of the change. Context must have been defined before it can be published.
CCFContextObject & aContext | Context object to be added. |
TInt | PublishContext | ( | CCFContextObject & | aContext, |
CCFContextDataObject & | aData | |||
) | [pure virtual] |
Publishes a new value of a context into Context Framework. Subscribed clients will be notified of the change. Context can be associated with a specific data object. If a subscriber has requested to receive also data objects the data object is associated in the context indication. Context must have been defined before it can be published.
CCFContextObject & aContext | Context object to be added. |
CCFContextDataObject & aData | Data object associated the context. |
TInt | RegisterScript | ( | const TDesC & | aScriptFileName, |
TInt & | aScriptId | |||
) | [pure virtual] |
Registers a new script in Context Framework. If the client process wants to provide the actions defined in the script it is necessary first to subscribe the actions needed and then register the script. If a script with the same name is found, it will be automatically replaced and the script id remains the same.
Notice that the script is valid until the device is rebooted. After reboot, the script is needed to be registered again.
TInt | RegisterScript | ( | const TDesC & | aScriptFileName, |
const TDesC8 & | aScript, | |||
TInt & | aScriptId | |||
) | [pure virtual] |
Registers a new script in Context Framework. If the client process wants to provide the actions defined in the script it is necessary first to subscribe the actions needed and then register the script. If a script with the same name is found, it will be automatically replaced and the script id remains the same.
Notice that the script is valid until the device is rebooted. After reboot, the script is needed to be registered again.
TInt | RequestContext | ( | CCFContextQuery & | aContextQuery, |
RContextObjectArray & | aRequestResults | |||
) | [pure virtual] |
Requests the latest context of the specified type, source, or type & source from the Context Framework. All the contexts where client has enough capabilities will be returned in aRequestResult array.
CCFContextQuery & aContextQuery | Requirements for context type and source. If the given type is a partial ontology path, all contexts beginning with that will be returned. Accordingly, if the given source is a partial source name, all contexts from a source having that beginning will be returned. |
RContextObjectArray & aRequestResults | Storage for the requested contexts. |
TInt | RequestContextSet | ( | RContextQueryArray & | aContextQuerySet, |
RContextObjectArray & | aRequestResults | |||
) | [pure virtual] |
Requests the latest context of the specified types, sources, or types & sources from the Context Framework. All the contexts where client has enough capabilities will be returned in aRequestResult array.
Using partial ontology paths in types or partial source names may result in repeated occurrence of the same contexts (redundancy), as is also the case with repeating exactly the same definition in the query set.
RContextQueryArray & aContextQuerySet | An array of query definitions containing type and source requirement pairs. If the given type is a partial ontology path, all contexts beginning with that will be stored into the provided storage array. Accordingly,if the given source is a partial source name, all contexts from a source having that beginning will also be stored. The given query set does not have to be analogous. One element may define only the type, another only the source, and finally, some other might define both type and source. |
RContextObjectArray & aRequestResults | Storage for the requested contexts. The call just returns and leaves this set untouchable, if the given query set is empty. |
TInt | RestoreRomScript | ( | const TDesC & | aScriptFileName | ) | [pure virtual] |
Restores the script located in ROM. The script upgrade is deregistered and deleted from file system. The original script located in ROM is registered in to use again.
const TDesC & aScriptFileName | Script which to replace (full path). |
TInt | SaveContextSourceSetting | ( | const TDesC & | aSettingFilename, |
const TUid & | aContextSourceUid | |||
) | [pure virtual] |
Saves a context source setting in Context Framework. Setting is stored if install succeeds.
TInt | SaveScript | ( | const TDesC & | aScriptFileName, |
TInt & | aScriptId | |||
) | [pure virtual] |
Saves a new script in Context Framework private folder. The script will be registered and updated when necessary. The script will be automatically loaded on next device boot up. If a script with the same name already exists, it will be automatically replaced.
TInt | SaveScript | ( | const TDesC & | aScriptFileName, |
const TDesC8 & | aScript, | |||
TInt & | aScriptId | |||
) | [pure virtual] |
Saves a new script in Context Framework private folder. The script will be registered and updated when necessary. The script will be automatically loaded on next device boot up. If a script with the same name already exists, it will be automatically replaced.
TInt | SubscribeAction | ( | CCFActionSubscription & | aSubscription | ) | [pure virtual] |
Subscribes for action. When certain action is needed to be performed action indication is informed through MCFListener API. Every action is needed to be defined before they can be subscribed.
CCFActionSubscription & aSubscription | Action subscription |
TInt | SubscribeContext | ( | CCFContextSubscription & | aSubscription | ) | [pure virtual] |
Add subscription to Context Framework to get indications about context changes of certain type. If client does not have suffcient capabilities error will be informed through MCFListener interface. This can happen if client subscribes in a context that has not yet been defined. When the context is later on defined a check is made against clients process capabilities. If client lacks capabilities error will be notifed.
CCFContextSubscription & aSubscription | Information about which kind of context changes are sent to object implementing MCFListener. |
TInt | UnsubscribeAction | ( | CCFActionSubscription & | aSubscription | ) | [pure virtual] |
Unsubscribes for action.
CCFActionSubscription & aSubscription | Action subscription |
TInt | UnsubscribeContext | ( | CCFContextSubscription & | aSubscription | ) | [pure virtual] |
Remove subscription from context manager. If subscription is not found on the server this method leaves with KErrNotFound.
CCFContextSubscription & aSubscription | Subscription to be removed. This must be the same object that is used in SubscribeL() method. |
TInt | UpgradeRomScript | ( | const TDesC & | aScriptFileName | ) | [pure virtual] |
Upgrade existing script in ROM. The new script is saved in C-drive and registered automatically. The script located in ROM is inactive untill the upgrade will be deleted. If a script with the same name is found, it will be automatically replaced.
The client must have the needed capabilities to be able to upgrade rom script. The script which acts as an upgrade must also have at least the same upgrade security level than the original script located in rom.
const TDesC & aScriptFileName | Script which to replace (full path). |
TInt | UpgradeRomScript | ( | const TDesC & | aScriptFileName, |
const TDesC8 & | aScript | |||
) | [pure virtual] |
Upgrade existing script in ROM. The currently registered ROM based script will be deregistered and the new script will be stored in RAM. The script located in ROM is inactive untill the upgrade will be deleted. If a script with the same name is found, it will be automatically replaced.
The client must have the needed capabilities to be able to upgrade rom script. The script which acts as an upgrade must also have at least the same upgrade security level than the original script located in rom.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.