Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Using RProperty for publishing

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia N93
Keywords: RProperty, RProperty::Define(), RProperty::Delete(), RProperty::Attach(), RProperty::Set(), RProperty::Close()
Created: aknyman (15 Apr 2008)
Last edited: hamishwillee (18 Sep 2012)



This code snippet shows how the class RProperty can be used to publish user-defined properties with Symbian's IPC Publish and Subscribe mechanism.

A property is published using the RProperty::Set() function. This means that the value of the property is updated. Whenever a property is published, all outstanding subscriptions are completed.

The code snippet Archived:Using RProperty for subscribing shows how to subscribe these user-defined properties. The property definitions are shared between a publisher and a subscriber through the common header file ExampleProperties.h.

const TInt KMaxStrLen = 10;
const TUid KExampleProperty = {0xED1917A8};
enum TExamplePropertyKeys { EIntProperty, EStrProperty };

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY euser.lib


The publisher or the subscriber thread can be the one to define properties by calling RProperty::Define(). The user-defined properties persist in the kernel until the operating system reboots or the properties are deleted.

TInt ret=RProperty::Define(KExampleProperty,EIntProperty,RProperty::EInt);
if (ret != KErrAlreadyExists)
ret= RProperty::Define(KExampleProperty,EStrProperty,RProperty::EByteArray,KMaxStrLen);
if (ret != KErrAlreadyExists)

Source file

#include <e32base.h>
#include <e32property.h>
#include "exampleproperties.h"
LOCAL_C void SetExamplePropertiesL()
TInt err(KErrNone);
// Use handle to publish EIntProperty
RProperty intProperty;
err = intProperty.Attach(KExampleProperty, EIntProperty, EOwnerThread);
err = intProperty.Set(123);
// Use category and key to publish EStrProperty
// Global Functions
GLDEF_C TInt E32Main()
// Create cleanup stack
CTrapCleanup* cleanup = CTrapCleanup::New();
// Run application code inside TRAP harness
TRAPD(mainError, SetExamplePropertiesL());
if (mainError)
//SetExamplePropertiesL leaves...
//Properties updated ok
delete cleanup;
return KErrNone;


Two example properties are published using the class RProperty.

If the publisher thread has defined the properties, it is also capable of deleting properties by using RProperty::Delete() as follows:

TInt err(KErrNone);
err = RProperty::Delete(KExampleProperty,EIntProperty);
if (err != KErrNotFound)
err = RProperty::Delete(KExampleProperty,EStrProperty);
if (err != KErrNotFound)

When properties are deleted, any outstanding subscriptions will be completed with KErrNotFound.

See also

Using RProperty for subscribing

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

This page was last modified on 18 September 2012, at 05:58.
57 page views in the last 30 days.