class MCFContextInterface |
Define contexts
Publish contexts
Subscribe contexts
Unsubscribe contexts
Request contexts Every context source plug-in has a reference to MCFContextInterface by default.
_LIT( KSource, "Source" ); _LIT( KType, "Type" ); _LIT_SECURITY_POLICY_PASS( KPassSec ); TInt err = iCF.DefineContext( KSource, KType, KPassSec ); if( err != KErrNone ) { // Handle error... }
_LIT( KSource, "Source" ); _LIT( KType, "Type" ); _LIT( KValue, "NewValue" ); CCFContextObject* context = CCFContextObject::NewLC(); context->SetSourceL( KSource ); context->SetTypeL( KType ); context->SetValueL( KValue ); RThread thread; CleanupClosePushL( thread ); TInt err = iCF.PublishContext( *context, thread ); if( err != KErrNone ) { // Handle error... } CleanupStack::PopAndDestroy( &thread ); CleanupStack::PopAndDestroy( context );It is suggested that only one CCFContextObject* instance is kept as a member variable to save memory.
_LIT( KSource, "Source" ); _LIT( KType, "Type" ); CCFContextSubscription* subscription = CCFContextSubscription::NewLC(); subscription->SetContextSourceL( KSource ); subscription->SetContextTypeL( KType ); RThread thread; CleanupClosePushL( thread ); TInt err = iCF.SubscribeContext( *subscription, this, thread ); if( err != KErrNone ) { // Handle error... } CleanupStack::PopAndDestroy( &thread ); CleanupStack::PopAndDestroy( subscription );It is assumed that 'this' is derived directly from MCFContextSubscriptionListener interface. Context subscription can also be configured more to give more precise indications.
_LIT( KSource, "Source" ); _LIT( KType, "Type" ); CCFContextQuery* query = CCFContextQuery::NewLC( KSource, KType ); RThread thread; CleanupClosePushL( thread ); RContextObjectArray results; TInt err = iCF.RequestContext( results, *query, thread ); if( err == KErrNone && results.Count() ) { // Handle request results... } else { // Handle error... } results.ResetAndDestroy(); CleanupStack::PopAndDestroy( &thread ); CleanupStack::PopAndDestroy( query );
_LIT( KSource, "Source" ); _LIT( KType, "Type" ); CCFContextSubscription* subscription = CCFContextSubscription::NewLC(); subscription->SetContextSourceL( KSource ); subscription->SetContextTypeL( KType ); iCF.UnsubscribeContext( *subscription, *this ); CleanupStack::PopAndDestroy( subscription );
iCF.UnsubscribeContexts( *this );It is assumed that 'this' is derived directly from MCFContextSubscriptionListener interface.
Public Member Functions | |
---|---|
TInt | DefineContext(const TDesC &, const TDesC &, const TSecurityPolicy &) |
TInt | DefineContext(const TDesC &, const TDesC &, const TSecurityPolicy &, MCFContextSource &) |
TInt | DefineContext(const TDesC &, const TDesC &, const TSecurityPolicy &, const TSecurityPolicy &, MCFContextSource &) |
TInt | GetSecurityPolicy(const TDesC &, const TDesC &, TSecurityPolicy &) |
TInt | PublishContext(CCFContextObject &, RThread &) |
TInt | PublishContext(CCFContextObject &, CCFContextDataObject &, RThread &) |
TInt | RequestContext(RContextObjectArray &, CCFContextQuery &, RThread &) |
TInt | SubscribeContext(CCFContextSubscription *, MCFContextSubscriptionListener *, RThread &) |
void | UnsubscribeContext(CCFContextSubscription &, MCFContextSubscriptionListener &) |
void | UnsubscribeContexts(MCFContextSubscriptionListener &) |
Protected Member Functions | |
---|---|
~MCFContextInterface() |
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 not be notified. Use one of the followinf DefineContext methods to receive context susbsription notifications.
const TDesC & aContextSource | Source of the context. |
const TDesC & aContextType | Type of the context. |
const TSecurityPolicy & aReadWritePolicy | Needed capabilities for reading and writing of the context. |
TInt | DefineContext | ( | const TDesC & | aContextSource, |
const TDesC & | aContextType, | |||
const TSecurityPolicy & | aReadWritePolicy, | |||
MCFContextSource & | aOwner | |||
) | [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.
const TDesC & aContextSource | Source of the context. |
const TDesC & aContextType | Type of the context. |
const TSecurityPolicy & aReadWritePolicy | Needed capabilities for reading and writing of the context. |
MCFContextSource & aOwner | Owner of the context. |
TInt | DefineContext | ( | const TDesC & | aContextSource, |
const TDesC & | aContextType, | |||
const TSecurityPolicy & | aReadPolicy, | |||
const TSecurityPolicy & | aWritePolicy, | |||
MCFContextSource & | aOwner | |||
) | [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.
const TDesC & aContextSource | Source of the context. |
const TDesC & aContextType | Type of the context. |
const TSecurityPolicy & aReadPolicy | |
const TSecurityPolicy & aWritePolicy | |
MCFContextSource & aOwner |
TInt | GetSecurityPolicy | ( | const TDesC & | aContextSource, |
const TDesC & | aContextType, | |||
TSecurityPolicy & | aPolicy | |||
) | [pure virtual] |
Gets the security policy of particular action.
const TDesC & aContextSource | Context Source. |
const TDesC & aContextType | Context Type. |
TSecurityPolicy & aPolicy | security policy which will be set by this method. |
TInt | PublishContext | ( | CCFContextObject & | aContext, |
RThread & | aClientThread | |||
) | [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. |
RThread & aClientThread |
TInt | PublishContext | ( | CCFContextObject & | aContext, |
CCFContextDataObject & | aData, | |||
RThread & | aClientThread | |||
) | [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. |
RThread & aClientThread |
TInt | RequestContext | ( | RContextObjectArray & | aResultBuffer, |
CCFContextQuery & | aContextQuery, | |||
RThread & | aClientThread | |||
) | [pure virtual] |
KErrNotFound: Requested context not defined
KErrAccessDenied: Insufficient capabilities for the context
RContextObjectArray & aResultBuffer | Context objects. |
CCFContextQuery & aContextQuery | Context query. |
RThread & aClientThread | Client thread where function is called. |
TInt | SubscribeContext | ( | CCFContextSubscription * | aSubscription, |
MCFContextSubscriptionListener * | aListener, | |||
RThread & | aClientThread | |||
) | [pure virtual] |
KErrNotFound: Published context not defined
KErrAccessDenied: Insufficient capabilities for the context
CCFContextSubscription * aSubscription | New subscription. |
MCFContextSubscriptionListener * aListener | Subscription listener. |
RThread & aClientThread | Client thread where function is called. |
void | UnsubscribeContext | ( | CCFContextSubscription & | aSubscription, |
MCFContextSubscriptionListener & | aListener | |||
) | [pure virtual] |
Remove a context subscription from Context Framework.
CCFContextSubscription & aSubscription | New subscription. |
MCFContextSubscriptionListener & aListener | Subscription listener. |
void | UnsubscribeContexts | ( | MCFContextSubscriptionListener & | aObserver | ) | [pure virtual] |
Remove all subscriptions for the particular listener.
MCFContextSubscriptionListener & aObserver | Listener whose subscriptions will be removed. |
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.