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.
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 ============================================================================ */ #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 <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 { 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& 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(); private: CMyLBSPrivacyNotifier(); void ConstructL(); private: // Data members TNotifierInfo iInfo; // From lbsprivacyextnotifiers.h - request parameters TLbsPrivacyNotifierParams iRequestParams; // Verification Dialog CMyLBSPrivacyNotifierDialog* iDlg; }; #endif // __MYLBSPRIVACYNOTIFIER_H__
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 { public: static CMyLBSPrivacyNotifierDialog* NewLD(CMyLBSPrivacyNotifier* aNotifier); ~CMyLBSPrivacyNotifierDialog(); void ShowDialog(TLbsExternalRequestInfo& 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; };
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"; 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; }; } }; }
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; pckg.Copy(aBuffer); TLbsPrivacyNotifierParams params = pckg(); TLbsExternalRequestInfo info; params.GetRequesterInfo(info); // Show the dialog with the requester details iDlg->ShowDialog(info); 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 iNotifier->DialogDismissed(); return ETrue; }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.