Creating a Privacy Notification Notifier

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 MEikSrvNotifierBase2::StartL() method that does not return a response. This is because the user cannot send a response to a privacy notification.

This topic describes how to implement a Privacy Notification Notifier, which is used to handle privacy notification requests.

The implementation of a Privacy Notification Notifier is similar to that of a Privacy Verification Notifier. In particular, the same TLbsExternalRequestInfo object is passed for privacy notification as for privacy verification. The most notable difference for privacy notification is that the synchronous method MEikSrvNotifierBase::StartL() 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.

Defining the Privacy Notification Notifier

The code below shows a definition of a Privacy Notification Notifier class.

The notifier owns a CMyLBSPrivacyNotifierDialog dialog class to show details of the privacy request to the end user and to obtain the response.

 Name		 : MyLBSPrivacyNotifier.h
 Description : This file defines a LBS Privacy Notification Notifier


#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 <e32base.h>
#include <eiknotapi.h>
#include <eikdialg.h>
#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
		static CMyLBSPrivacyNotifier* NewL();
		// Called when the dialog is hidden
		void DialogDismissed();

private: // From MEikSrvNotifierBase2

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

	void ConstructL();

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

		// Verification Dialog
		CMyLBSPrivacyNotifierDialog* iDlg;



Defining the Privacy Notification Dialog

The following is the definition of the dialog used by the example Privacy Notification Notifier:

 Name		 : MyLBSPrivacyNotifier.cpp
 Description : Source for LBS location notification notifier and dialog

// System headers
#include <eikdialg.h>
#include <eikmfne.h>
#include <eikenv.h>
#include <bautils.h>
#include <eikappui.h>
#include <e32cmn.h>

// LBS headers
#include <lbsprivacyextnotifiers.h>

// project headers
#include <MyLBSPrivacyDialogs.rsg>
#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
	static CMyLBSPrivacyNotifierDialog* NewLD(CMyLBSPrivacyNotifier* aNotifier);

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

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

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


	// 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;

The dialog requires a resource definition. In this case the dialog has only a continue button because no response can be made to the notification.

RESOURCE DIALOG r_lbs_notify_dialog
	title = "Privacy Notification Dialog";
	items = 
		    type = EEikCtLabel;
		    control = LABEL
		    	standard_font = EEikLabelFontAnnotation;
		    	txt = "Sending your location to :";
		    type = EEikCtEdwin;
		    id = EPrivacyClientName;
		    control = EDWIN
		    	width = 10;
		    	maxlength = 25;

Notifier and dialog method implementations

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 MEikSrvNotifierBase2::RegisterL(), MEikSrvNotifierBase2::StartL() and CEikDialog::OkToExitL().

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.

// 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;

The notifier implements only the synchronous version of StartL().

// Synchronous StartL is used for location 
// notification because no response is required
TPtrC8 CMyLBSPrivacyNotifier::StartL(const TDesC8& aBuffer)
  TBuf8<KLbsMaxClientNameSize> clientName;
  TBuf8<KLbsMaxRequesterIdSize> requesterId;
  TLbsPrivacyNotifierParamsPckg pckg;
  TLbsPrivacyNotifierParams params = pckg();
  TLbsExternalRequestInfo info;
  // Show the dialog with the requester details
  return TPtrC8();

OkToExit() does not write any notifier response parameters.

// 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
  return ETrue;