Symbian3/PDK/Source/GUID-D72A47FE-23D2-4AD1-92B9-53DD9B64733F-GENID-1-12-1-19-1-1-7-1-6-1-5-1-5-1-5-1-4-1.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 16 Jul 2010 17:23:46 +0100
changeset 12 80ef3a206772
permissions -rw-r--r--
Week 28 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 1897, Bug 344, Bug 2681, Bug 463, Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-D72A47FE-23D2-4AD1-92B9-53DD9B64733F-GENID-1-12-1-19-1-1-7-1-6-1-5-1-5-1-5-1-4-1" xml:lang="en"><title>Creating
a Notifier ECOM Plug-in</title><shortdesc>To use the Privacy Query and Notification API to create a notifier
a licensee must secondly create a notifier ECOM plug-in.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section>       <title>Exporting a factory method </title>       <p>The notifier
is implemented as an ECOM plug-in and has typical ECOM entry point methods.
The following code example shows how the <xref href="GUID-56C8D5AB-7D9A-3B20-B699-07F17A87A61C.dita#GUID-56C8D5AB-7D9A-3B20-B699-07F17A87A61C/GUID-38E7BBCF-8F4C-3398-B322-2D3427E4CAC1"><apiname>CPosPrivacyNotifier::NotifierBase(</apiname></xref>)
method is used to return the <codeph>MEikSrvNotifierBase2</codeph> pointer
required by the Extended Notifier Framework.     </p><p>The UID specified
in <codeph>IMPLEMENTATION_PROXY_ENTRY</codeph> is the constant <codeph>KPosPrivacyNotifierImplUid</codeph> as
defined in <filepath>EPos_PrivacyNotifier.hrh</filepath>.  </p>     <codeblock xml:space="preserve">#include &lt;e32base.h&gt;
#include &lt;eiknotapi.h&gt;
#include &lt;ImplementationProxy.h&gt;
#include &lt;EPos_PrivacyNotifier.hrh&gt;
#include "CMyPrivacyNotifier.h"

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

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

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

    return KPosImplTable;
    }</codeblock></section>
<section><title>Defining the ECOM resource file</title><p>The following is
an example ECOM resource file for a Privacy Q&amp;N Notifier: </p><codeblock xml:space="preserve">#include &lt;RegistryInfo.rh&gt;
#include &lt;Uikon.hrh&gt;
#include &lt;EPos_PrivacyNotifier.hrh&gt;


// 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";
                    }
                };
            }
        };
    }</codeblock><p>The most important points about this file are: </p><ul>
<li><p>dll_uid is the UID of the notifier DLL. This should be the same as
specified in the MMP file (see below). </p></li>
<li><p>interface_uid is the UID of the <codeph>MEikSrvNotifierBase2</codeph> interface.
This should be set to the constant <codeph>KUikonUidPluginInterfaceNotifiers</codeph> defined
in <filepath>Uikon.hrh</filepath>. </p></li>
<li><p>implementation_uid is the notifier implementation UID. This UID is
defined as the constant <codeph>KPosPrivacyNotifierImplUid</codeph> in <filepath>EPos_PrivacyNotifier.hrh</filepath>.</p></li>
</ul></section>
<section><title>Defining the MMP file </title><p>The following is an example
MMP file for a Privacy Q&amp;N Notifier:</p><codeblock xml:space="preserve">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
</codeblock><p>The most important points about this file are:</p><ul>
<li><p>The target type is <codeph>PLUGIN</codeph> because the notifier is
implemented as an ECOM plug-in.</p></li>
<li><p>The second UID is <codeph>0x10009D8D</codeph> to identify the DLL as
an ECOM plug-in.</p></li>
<li><p>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. </p></li>
<li><p><filepath>\epoc32\include\lbs</filepath> is included in order to find
the Privacy Query and Notification API header files. </p></li>
<li><p><filepath>eposprvqnif.lib</filepath> is included to link against the
Privacy Query and Notification API library. </p></li>
<li><p>The notifier must have the <codeph>ProtServ</codeph> and <codeph>TrustedUI</codeph> capabilities
as required by the Extended Notifier Framework. </p></li>
</ul></section>
</conbody></concept>