Creating a Notifier ECOM Plug-in

To use the Privacy Query and Notification API to create a notifier a licensee must secondly create a notifier ECOM plug-in.

Exporting a factory method

The notifier is implemented as an ECOM plug-in and has typical ECOM entry point methods. The following code example shows how the CPosPrivacyNotifier::NotifierBase() method is used to return the MEikSrvNotifierBase2 pointer required by the Extended Notifier Framework.

The UID specified in IMPLEMENTATION_PROXY_ENTRY is the constant KPosPrivacyNotifierImplUid as defined in EPos_PrivacyNotifier.hrh.

#include <e32base.h>
#include <eiknotapi.h>
#include <ImplementationProxy.h>
#include <EPos_PrivacyNotifier.hrh>
#include "CMyPrivacyNotifier.h"

// Creates the notifier. Used by the NotifierArray() factory method.
LOCAL_C void CreateNotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers)
    {
    CMyPrivacyNotifier* notifier = CMyPrivacyNotifier::NewLC();
    aNotifiers->AppendL(notifier->NotifierBase());
    CleanupStack::Pop(notifier); // Do not destroy
    }
// Notifier entry point. Note that the factory method must not leave
LOCAL_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
    {
    CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers =
        new CArrayPtrFlat<MEikSrvNotifierBase2>(1);
    if (notifiers)
        {
        TRAPD(err, CreateNotifiersL(notifiers));
        if (err)
            { // release any notifiers we have created
            TInt count = notifiers->Count();
            while (--count >= 0)
                {
                (*notifiers)[count]->Release();
                }
            delete notifiers;
            notifiers = NULL;
            }
        }
    return notifiers;
    }

const TImplementationProxy KPosImplTable[] =
    {
    IMPLEMENTATION_PROXY_ENTRY(KPosPrivacyNotifierImplUid, NotifierArray)
    };

EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
    {
    aTableCount = sizeof(KPosImplTable) / sizeof(TImplementationProxy);

    return KPosImplTable;
    }

Defining the ECOM resource file

The following is an example ECOM resource file for a Privacy Q&N Notifier:

#include <RegistryInfo.rh>
#include <Uikon.hrh>
#include <EPos_PrivacyNotifier.hrh>


// RESOURCE DEFINITIONS
// -----------------------------------------------------------------------------
//
// r_registry
// ECOM registry information for Privacy UI
//
// -----------------------------------------------------------------------------
//
RESOURCE REGISTRY_INFO r_registry
    {
    dll_uid = 0x01234123;
    interfaces =
        {
        INTERFACE_INFO
            {
            interface_uid = KUikonUidPluginInterfaceNotifiers;
            implementations =
                {
                IMPLEMENTATION_INFO
                    {
                    implementation_uid = KPosPrivacyNotifierImplUid;
                    version_no = 1;
                    display_name = "Privacy UI";
                    }
                };
            }
        };
    }

The most important points about this file are:

  • dll_uid is the UID of the notifier DLL. This should be the same as specified in the MMP file (see below).

  • interface_uid is the UID of the MEikSrvNotifierBase2 interface. This should be set to the constant KUikonUidPluginInterfaceNotifiers defined in Uikon.hrh.

  • implementation_uid is the notifier implementation UID. This UID is defined as the constant KPosPrivacyNotifierImplUid in EPos_PrivacyNotifier.hrh.

Defining the MMP file

The following is an example MMP file for a Privacy Q&N Notifier:

TARGET          myprivnot.dll
TARGETTYPE      PLUGIN
UID             0x10009D8D 0x01234123 // Notifier type uid = 0x10009D8D
VENDORID        VID_DEFAULTCAPABILITY      ProtServ TrustedUI
SOURCEPATH      ..\src
SOURCE          MyPrivacyNotifierMain.cpp
SOURCE          CMyPrivacyNotifier.cpp
START RESOURCE  PrivacyNotifier.rss
TARGET          myprivnot.rsc
END
SYSTEMINCLUDE   \Epoc32\Include
SYSTEMINCLUDE   \Epoc32\Include\ECom
SYSTEMINCLUDE   \Epoc32\Include\lbs
LIBRARY         euser.lib
LIBRARY         eposprvqnif.lib
LIBRARY         eposprvtyp.lib
LIBRARY         bafl.lib

The most important points about this file are:

  • The target type is PLUGIN because the notifier is implemented as an ECOM plug-in.

  • The second UID is 0x10009D8D to identify the DLL as an ECOM plug-in.

  • The third UID is the DLL UID and is allocated by Symbian. Note that this is not the same as the implementation UID specified in the ECOM resource file.

  • \epoc32\include\lbs is included in order to find the Privacy Query and Notification API header files.

  • eposprvqnif.lib is included to link against the Privacy Query and Notification API library.

  • The notifier must have the ProtServ and TrustedUI capabilities as required by the Extended Notifier Framework.