Symbian3/PDK/Source/GUID-12DA697C-1BB0-489F-98E1-F9B81E4A2F4D.dita
author Graeme Price <GRAEME.PRICE@NOKIA.COM>
Fri, 15 Oct 2010 14:32:18 +0100
changeset 15 307f4279f433
parent 14 578be2adaf3e
permissions -rw-r--r--
Initial contribution of the Adaptation Documentation.

<?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-12DA697C-1BB0-489F-98E1-F9B81E4A2F4D" xml:lang="en"><title>Creating
a Privacy Notification Notifier</title><shortdesc>To use the LBS Privacy Notifiers for privacy verification and privacy
notification a licensee must implement a Privacy Notification Notifier. The
licensee should override the synchronous <codeph>MEikSrvNotifierBase2::StartL()</codeph> method
that does not return a response. This is because the user cannot send a response
to a privacy notification. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>This topic describes how to implement a Privacy Notification Notifier,
which is used to handle privacy notification requests.     </p>
<p>The implementation of a Privacy Notification Notifier is similar to that
of a Privacy Verification Notifier. In particular, the same <codeph>TLbsExternalRequestInfo</codeph> object
is passed for privacy notification as for privacy verification. The most notable
difference for privacy notification is that the synchronous method <xref href="GUID-2BA43B57-610F-324F-B5E0-590174A6D1BF.dita#GUID-2BA43B57-610F-324F-B5E0-590174A6D1BF/GUID-21C2E5DC-5DA4-35E3-A605-AE6DCB1BB3CE"><apiname>MEikSrvNotifierBase::StartL()</apiname></xref> is
implemented. This is because the notifier is used only for privacy notification
and it is not possible to respond to it. This makes implementation of the
notifier easier.  </p>
<section id="GUID-5A3C2A41-F6F1-4CBA-9DD0-180958C6B628">       <title>Defining the Privacy Notification Notifier</title> 
     <p>The code below shows a definition of a Privacy Notification Notifier
class.     </p><p>The notifier owns a <codeph>CMyLBSPrivacyNotifierDialog</codeph> dialog
class to show details of the privacy request to the end user and to obtain
the response.  </p><codeblock xml:space="preserve">/*
============================================================================
 Name		 : MyLBSPrivacyNotifier.h
 Description : This file defines a LBS Privacy Notification Notifier
============================================================================
*/

#ifndef __MYLBSPRIVACYNOTIFIER_H__
#define __MYLBSPRIVACYNOTIFIER_H__

#define NOTIFY_RESOURCE_PATH	"\\private\\10003a4a\\"  // Default location for dialog GUI resources
#define NOTIFY_RESOURCE			"MyLBSPrivacyDialogs.rsc" // Compiled dialog resource file name

// This value is defined in MyLBSPrivacyVerifier.h
//const TUid KScreenOutputChannel={0x1000ABEF};

//  Include Files
#include &lt;e32base.h&gt;
#include &lt;eiknotapi.h&gt;
#include &lt;eikdialg.h&gt;
#include "lbsprivacyextnotifiers.h" // Defines privacy data types
#include "MyLBSNotifiersChannel.h" // Channel for notifier display

// Dialog forward declaration for notifier
class CMyLBSPrivacyNotifierDialog;

//  Privacy verification notifier class definintion
class CMyLBSPrivacyNotifier : public CBase, public MEikSrvNotifierBase2
	{
public:	
		static CMyLBSPrivacyNotifier* NewL();
		~CMyLBSPrivacyNotifier();
		
		// Called when the dialog is hidden
		void DialogDismissed();

private: // From MEikSrvNotifierBase2

	// Not used for location notification - no response is required
	void StartL(const TDesC8&amp; aBuffer, TInt aReplySlot, const RMessagePtr2&amp; aMessage); 
	
	// Synchronous StartL is used for location notification
	TPtrC8 StartL(const TDesC8&amp; aBuffer);
	
	// Not implemented for LBS privacy notifiers
	TPtrC8 UpdateL(const TDesC8&amp; aBuffer);
	
	TNotifierInfo RegisterL();
	TNotifierInfo Info() const;
	void Cancel();
	void Release();

private:
	CMyLBSPrivacyNotifier();
	void ConstructL();

private:
		// Data members
		TNotifierInfo iInfo;
		
		// From lbsprivacyextnotifiers.h - request parameters
		TLbsPrivacyNotifierParams iRequestParams;

		// Verification Dialog
		CMyLBSPrivacyNotifierDialog* iDlg;

	};

#endif  // __MYLBSPRIVACYNOTIFIER_H__</codeblock>     </section>
<section id="GUID-27A3C22E-8222-4C09-95BE-7EE3F8F56C82"><title>Defining the Privacy Notification Dialog</title><p>The following
is the definition of the dialog used by the example Privacy Notification Notifier: </p><codeblock xml:space="preserve">/*
============================================================================
 Name		 : MyLBSPrivacyNotifier.cpp
 Description : Source for LBS location notification notifier and dialog
============================================================================
*/

// System headers
#include &lt;eikdialg.h&gt;
#include &lt;eikmfne.h&gt;
#include &lt;eikenv.h&gt;
#include &lt;bautils.h&gt;
#include &lt;eikappui.h&gt;
#include &lt;e32cmn.h&gt;

// LBS headers
#include &lt;lbsprivacyextnotifiers.h&gt;

// project headers
#include &lt;MyLBSPrivacyDialogs.rsg&gt;
#include "MyLBSPrivacyNotifier.h"
#include "MyLBSDialogs.hrh"

/* CMyLBSPrivacyNotifierDialog
   The resource for this dialog defines it as a sleeping dialog
   Resources are allocated for it when the owning notifier is loaded by ECom
   This is a good idea for situations where emergency requests notify the user
   so that a confirmation dialog is shown even in low memory conditions
*/

class CMyLBSPrivacyNotifierDialog : public CEikDialog
	{
public:
	static CMyLBSPrivacyNotifierDialog* NewLD(CMyLBSPrivacyNotifier* aNotifier);
	~CMyLBSPrivacyNotifierDialog();

	void ShowDialog(TLbsExternalRequestInfo&amp; aInfo);
	void HideDialog();

public: // from CEikDialog
	TBool OkToExitL(TInt aButtonId);
	void PreLayoutDynInitL();

private:
	CMyLBSPrivacyNotifierDialog(CMyLBSPrivacyNotifier* aNotifier);
	void LoadResourceL();
	void FreeResource();
	void ConstructL();

private:

	// The notifier that calls this dialog
	CMyLBSPrivacyNotifier* iNotifier;
	
	// Library resource containing dialog resources
	TInt  iResourceFile;
	
	// The privacy requester info - contains requester id and name
	TLbsExternalRequestInfo iInfo;
	};</codeblock><p>The dialog requires a resource definition. In this case
the dialog has only a <uicontrol>continue</uicontrol> button because no response
can be made to the notification. </p><codeblock xml:space="preserve">RESOURCE DIALOG r_lbs_notify_dialog
	{	
	title = "Privacy Notification Dialog";
	flags=EEikDialogFlagNotifyEsc;
	buttons = R_EIK_BUTTONS_CONTINUE;
	items = 
		{
		DLG_LINE
		    {
		    type = EEikCtLabel;
		    control = LABEL
		    	{
		    	standard_font = EEikLabelFontAnnotation;
		    	txt = "Sending your location to :";
		    	};
		    },
		DLG_LINE
		    {
		    type = EEikCtEdwin;
		    id = EPrivacyClientName;
		    control = EDWIN
		    	{
		    	width = 10;
		    	maxlength = 25;
		    	};
		    }
		};
	}</codeblock></section>
<section id="GUID-67771BB3-D9E2-4368-8365-D1BB84CC43C7"><title>Notifier and dialog method implementations</title><p>Much
of the implementation of a Privacy Notification Notifier is similar to that
for a Privacy Verification Notifier. The most relevant differences are in
the implementation of <xref href="GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0.dita#GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0/GUID-7863DC49-9664-390C-AAE1-B3BE043CA108"><apiname>MEikSrvNotifierBase2::RegisterL()</apiname></xref>, <xref href="GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0.dita#GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0/GUID-5DC8D35F-FFA5-3CE8-A06D-303A7E3ECC9B"><apiname>MEikSrvNotifierBase2::StartL()</apiname></xref> and <xref href="GUID-DC21E927-18B3-3BBF-9B67-496F2D158B03.dita#GUID-DC21E927-18B3-3BBF-9B67-496F2D158B03/GUID-6AFDB981-BBA2-3A5E-A7A5-BA6B39BC4CE9"><apiname>CEikDialog::OkToExitL()</apiname></xref>.     </p><p>The value KLbsExtLocationRequestNotifyUid as defined in lbsextprivacynotifiers.h
must be used for the notifier registration. The choice of notifier priority
is a licensee decision, but a high priority is recommended because a location
notification can be sent as part of an emergency services request and the
user may want to know that their location was successfully sent.  </p><codeblock xml:space="preserve">// Called by notifier framework once to register the notifier with ECOM
MEikSrvNotifierBase2::TNotifierInfo CMyLBSPrivacyNotifier::RegisterL()
  {
  iInfo.iUid = KLbsExtLocationRequestNotifyUid;
  iInfo.iChannel = KScreenOutputChannel;

  // High priority privacy request
  iInfo.iPriority = ENotifierPriorityVHigh;
  return iInfo;
  }</codeblock><p>The notifier implements only the synchronous version of <codeph>StartL()</codeph>. </p><codeblock xml:space="preserve">// Synchronous StartL is used for location 
// notification because no response is required
TPtrC8 CMyLBSPrivacyNotifier::StartL(const TDesC8&amp; aBuffer)
  {
  TBuf8&lt;KLbsMaxClientNameSize&gt; clientName;
  TBuf8&lt;KLbsMaxRequesterIdSize&gt; requesterId;
	
  TLbsPrivacyNotifierParamsPckg pckg;
  pckg.Copy(aBuffer);
  TLbsPrivacyNotifierParams params = pckg();
  TLbsExternalRequestInfo info;
  params.GetRequesterInfo(info);
	
  // Show the dialog with the requester details
  iDlg-&gt;ShowDialog(info);
	
  return TPtrC8();
  }</codeblock><p><codeph>OkToExit(</codeph>) does not write any notifier
response parameters. </p><codeblock xml:space="preserve">// From CEikDialog - called when a dialog button is pressed
TBool CMyLBSPrivacyNotifierDialog::OkToExitL(TInt aButtonId)
  {
  // No response parameters to set for location notification
	
  // Inform the notifier that this dialog 
  // is exiting so that it can inform the notifier manager
  iNotifier-&gt;DialogDismissed();
  return ETrue;
  }</codeblock></section>
</conbody></concept>