Symbian3/PDK/Source/GUID-AC53C0A0-6990-4BF8-91E9-9AE14169A7BC.dita
changeset 1 25a17d01db0c
child 5 f345bda72bc4
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-AC53C0A0-6990-4BF8-91E9-9AE14169A7BC" xml:lang="en"><title>Creating
       
    13 a Privacy Verification Notifier</title><shortdesc>To use the LBS Privacy Notifiers for privacy verification and privacy
       
    14 notification a licensee must implement a Privacy Verification Notifier that
       
    15 extends from the Extended Notifier Framework base class <apiname>MEikSrvNotifierBase2</apiname>.
       
    16 The licensee must override the asynchronous <apiname>MEikSrvNotifierBase2::StartL()</apiname> method
       
    17 so that the LBS subsystem can receive a privacy response from the user via
       
    18 the notifier. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    19 <p>This topic describes how to implement a Privacy Verification Notifier.
       
    20 The notifier is used to handle privacy verification requests.   </p>
       
    21 <p>A dialog is shown to the user when verification of a privacy request is
       
    22 required. The example shown here uses a CEikDialog derived class, although
       
    23 licensees will most probably want to use a dialog class specific to their
       
    24 own UI framework. Implementation of the notifier can be described in the following
       
    25 steps:</p>
       
    26 <ul>
       
    27 <li><p>Define a notifier that derives from the Extended Notifier Framework
       
    28 base class <xref href="GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0.dita"><apiname>MEikSrvNotifierBase2</apiname></xref>.</p></li>
       
    29 <li><p>Define a dialog class that derives from <codeph>CEikDialog</codeph> (or
       
    30 some licensee UI framework-specific subclass). </p></li>
       
    31 <li><p>Override the necessary virtual methods of the licensee notifier and
       
    32 dialog to handle privacy requests and send the appropriate response when the
       
    33 user dismisses the dialog. </p></li>
       
    34 </ul>
       
    35 <section>       <title>Defining the Privacy Verification Notifier</title> 
       
    36      <p>The code below shows a definition of a Privacy Verification Notifier
       
    37 class.     </p><p>The notifier owns a <xref href="GUID-BFDCA64A-1F55-34E8-8C4D-B0EABBE3A17C.dita"><apiname>CMyLBSPrivacyVerifierDialog</apiname></xref> dialog
       
    38 class to show details of the privacy request to the end user and to obtain
       
    39 the response.  </p><codeblock xml:space="preserve">/*
       
    40 ============================================================================
       
    41  Name		 : MyLBSPrivacyVerifier.h
       
    42  Description : This file defines a LBS Privacy Verification Notifier
       
    43 ============================================================================
       
    44 */
       
    45 
       
    46 #ifndef __MYLBSPRIVACYVERIFIER_H__
       
    47 #define __MYLBSPRIVACYVERIFIER_H__
       
    48 
       
    49 // Default location for dialog GUI resources
       
    50 #define VERIFY_RESOURCE_PATH    "\\private\\10003a4a\\"
       
    51 
       
    52 // Compiled dialog resource file name
       
    53 #define VERIFY_RESOURCE 		"MyLBSPrivacyDialogs.rsc"
       
    54 
       
    55 //  Include Files
       
    56 #include &lt;e32base.h&gt;
       
    57 #include &lt;eiknotapi.h&gt;
       
    58 #include &lt;eikdialg.h&gt;
       
    59 #include "lbsprivacyextnotifiers.h" // Defines privacy data types
       
    60 #include "MyLBSNotifiersChannel.h" // Defines notifier channel
       
    61 
       
    62 // Dialog forward declaration for notifier
       
    63 class CMyLBSPrivacyVerifierDialog;
       
    64 
       
    65 //  Privacy verification notifier class definition
       
    66 class CMyLBSPrivacyVerifier : public CBase, public MEikSrvNotifierBase2
       
    67   {
       
    68 public:	
       
    69   static CMyLBSPrivacyVerifier* NewL();
       
    70   ~CMyLBSPrivacyVerifier();
       
    71 		
       
    72   // Called when the dialog is hidden
       
    73   void DialogDismissed();
       
    74 
       
    75 private: // From MEikSrvNotifierBase2
       
    76 
       
    77   // Asynchronous StartL is used for privacy verification
       
    78   // a response is required
       
    79   void StartL(const TDesC8&amp; aBuffer, TInt aReplySlot,
       
    80               const RMessagePtr2&amp; aMessage); 
       
    81 	
       
    82   // Synchronous StartL is not used for privacy verification
       
    83   TPtrC8 StartL(const TDesC8&amp; aBuffer);
       
    84 	
       
    85   // Not implemented for LBS privacy notifiers
       
    86   TPtrC8 UpdateL(const TDesC8&amp; aBuffer);
       
    87 	
       
    88   TNotifierInfo RegisterL();
       
    89   TNotifierInfo Info() const;
       
    90   void Cancel();
       
    91   void Release();
       
    92 	
       
    93   // Set the response parameters based on the user response
       
    94   void SetResponseParams(TLbsPrivacyResponseParams params);
       
    95 	
       
    96 
       
    97 private:
       
    98   CMyLBSPrivacyVerifier();
       
    99   void ConstructL();
       
   100 
       
   101 private:
       
   102   // Data members
       
   103   TNotifierInfo iInfo;
       
   104   RMessagePtr2 iMessage;
       
   105   TInt iReplySlot;
       
   106 		
       
   107   // From lbsprivacyextnotifiers.h - request parameters
       
   108   TLbsPrivacyNotifierParams iRequestParams;
       
   109 		
       
   110   // From lbsprivacyextnotifiers.h - response parameters
       
   111   TLbsPrivacyResponseParams iResponseParams;
       
   112 
       
   113   // Verification Dialog
       
   114   CMyLBSPrivacyVerifierDialog* iDlg;
       
   115   };
       
   116 
       
   117 #endif  // __MYLBSPRIVACYNOTIFIER_H__</codeblock>     </section>
       
   118 <section><title>Defining the Privacy Verification Dialog </title><p>The following
       
   119 is the definition of the dialog used by the example Privacy Verification Notifier:</p><codeblock xml:space="preserve">/*
       
   120 ============================================================================
       
   121  Name		: MyLBSPrivacyVerifier.cpp
       
   122  Description : Source for LBS privacy verification notifier and dialog
       
   123 ============================================================================
       
   124 */
       
   125 
       
   126 // System headers
       
   127 #include &lt;eikdialg.h&gt;
       
   128 #include &lt;eikmfne.h&gt;
       
   129 #include &lt;eikenv.h&gt;
       
   130 #include &lt;bautils.h&gt;
       
   131 #include &lt;eikappui.h&gt;
       
   132 #include &lt;e32cmn.h&gt;
       
   133 
       
   134 // Console for debugging
       
   135 #include &lt;e32cons.h&gt;		
       
   136 
       
   137 // LBS headers
       
   138 #include &lt;lbsprivacyextnotifiers.h&gt;
       
   139 
       
   140 // project headers
       
   141 #include &lt;MyLBSPrivacyDialogs.rsg&gt;
       
   142 #include "MyLBSPrivacyVerifier.hrh"
       
   143 #include "MyLBSDialogs.hrh"
       
   144 #include "MyLBSPrivacyVerifier.h"
       
   145 
       
   146 
       
   147 /* CMyLBSPrivacyVerifierDialog
       
   148    The resource for this dialog defines it as a sleeping dialog
       
   149    Resources are allocated when the owning notifier is created by ECom
       
   150 */
       
   151 
       
   152 class CMyLBSPrivacyVerifierDialog : public CEikDialog
       
   153   {
       
   154 public:
       
   155   static CMyLBSPrivacyVerifierDialog* NewLD(
       
   156                                CMyLBSPrivacyVerifier* aNotifier,
       
   157                                TLbsPrivacyResponseParams&amp; aResponseParams);
       
   158   ~CMyLBSPrivacyVerifierDialog();
       
   159 
       
   160   void ShowDialog(TLbsExternalRequestInfo&amp; aInfo);
       
   161   void HideDialog();
       
   162 
       
   163 public: // from CEikDialog
       
   164   TBool OkToExitL(TInt aButtonId);
       
   165   void PreLayoutDynInitL();
       
   166 
       
   167 private:
       
   168   CMyLBSPrivacyVerifierDialog(CMyLBSPrivacyVerifier* aNotifier,
       
   169                               TLbsPrivacyResponseParams&amp; aResponseParams);
       
   170   void LoadResourceL();
       
   171   void FreeResource();
       
   172   void ConstructL();
       
   173 
       
   174 private:
       
   175 
       
   176   // The notifier that calls this dialog
       
   177   CMyLBSPrivacyVerifier* iNotifier;
       
   178 	
       
   179   // Library resource containing dialog resources
       
   180   TInt  iResourceFile;
       
   181 	
       
   182   // The privacy requester info - contains requester id and name
       
   183   TLbsExternalRequestInfo iInfo;
       
   184 
       
   185   // The privacy response parameters reference
       
   186   // to iResponseParams in parent notifier
       
   187   TLbsPrivacyResponseParams&amp; iResponseParams;
       
   188 	 };</codeblock><p>The dialog contains a <xref href="GUID-C5EE0092-6EAB-32AA-A58D-A81A883DFEBF.dita"><apiname>CMyLBSPrivacyVerifier</apiname></xref> pointer
       
   189 through which it can set the privacy response chosen by the user.     </p><p>This
       
   190 example defines a simple dialog resource file <filepath>MyLbsPrivacyDialogs.rsg</filepath>.
       
   191 The source of this file contains definitions for a simple dialog that shows
       
   192 the client name of the user making the privacy request and <uicontrol>Accept</uicontrol> and <uicontrol>Reject</uicontrol> buttons
       
   193 to allow the user to accept or reject the request. </p><codeblock xml:space="preserve">// MyLBSPrivacyVerifierDialog.RSS
       
   194 
       
   195 #include &lt;eikon.rh&gt;
       
   196 #include &lt;eikon.rsg&gt;
       
   197 #include &lt;techviewctl.rh&gt;
       
   198 #include &lt;eikcoctl.rsg&gt;
       
   199 #include "MyLBSDialogs.hrh"
       
   200 
       
   201 NAME PRVC
       
   202 
       
   203 RESOURCE RSS_SIGNATURE { }
       
   204 
       
   205 RESOURCE TBUF { buf=""; }
       
   206 
       
   207 RESOURCE DLG_BUTTONS r_privacy_request_buttons
       
   208 {
       
   209 buttons = 
       
   210 	{
       
   211 	DLG_BUTTON
       
   212 		{
       
   213 		id = EPrivacyRequestAccept;
       
   214 		button = CMBUT {txt = "Accept";};
       
   215 		hotkey='1';
       
   216 		},
       
   217 	DLG_BUTTON
       
   218 		{
       
   219 		id = EPrivacyRequestReject;
       
   220 		button = CMBUT {txt = "Reject";};
       
   221 		hotkey='2';
       
   222 		}
       
   223 	};
       
   224 }
       
   225 
       
   226 
       
   227 RESOURCE DIALOG r_lbs_verify_dialog
       
   228 	{
       
   229 	title = "Privacy Verification Dialog";
       
   230 	flags = EEikDialogFlagNotifyEsc;
       
   231 	buttons = r_privacy_request_buttons;
       
   232 	items = 
       
   233 		{
       
   234 		DLG_LINE
       
   235 		    {
       
   236 		    type = EEikCtLabel;
       
   237 		    control = LABEL
       
   238 		    	{
       
   239 		    	standard_font = EEikLabelFontAnnotation;
       
   240 		    	txt = "Location Request received from :";
       
   241 		    	};
       
   242 		    },
       
   243 		DLG_LINE
       
   244 		    {
       
   245 		    type = EEikCtEdwin;
       
   246 		    id = EPrivacyClientName;
       
   247 		    control = EDWIN
       
   248 		    	{
       
   249 		    	width = 10;
       
   250 		    	maxlength = 25;
       
   251 		    	};
       
   252 		    }
       
   253 		};
       
   254 	}</codeblock><p><codeph>KScreenOutputChannel</codeph> is a common channel
       
   255 used by both a Privacy Verification Notifier and a Location Notification Notifier.
       
   256 The real value of the channel is a licensee-specific value. </p><codeblock xml:space="preserve">#ifndef __MYLBSNOTIFIERSCHANNEL_H_
       
   257 #define __MYLBSNOTIFIERSCHANNEL_H_
       
   258 
       
   259 const TUid KScreenOutputChannel={0x1000ABEF};
       
   260 
       
   261 #endif /*MYLBSNOTIFIERSCHANNEL_H_*/</codeblock></section>
       
   262 <section><title>Creating the notifier </title><p>The most important thing
       
   263 to consider when creating a notifier object is if the dialog resources should
       
   264 also be created at the same time.     </p><p>The ECOM framework calls the
       
   265 notifier's <codeph>NewL()</codeph> when the notifier server starts up. Privacy
       
   266 requests and location requests may need to be handled in low memory conditions
       
   267 (where licensees and operators need to support emergency location requests).
       
   268 If this is the case it is prudent to use sleeping dialogs which are created
       
   269 in the notifier's <codeph>ConstructL()</codeph>. All resources for the dialog
       
   270 are allocated when the notifier is loaded by ECOM and showing a dialog should
       
   271 not fail if there are low-memory conditions at runtime when an emergency location
       
   272 request is received.  </p><codeblock xml:space="preserve">CMyLBSPrivacyVerifier* CMyLBSPrivacyVerifier::NewL()
       
   273   {
       
   274   CMyLBSPrivacyVerifier* self = new (ELeave) CMyLBSPrivacyVerifier();	
       
   275   CleanupStack::PushL(self);
       
   276   self-&gt;ConstructL();	
       
   277   CleanupStack::Pop();
       
   278   return self;	
       
   279   }
       
   280 
       
   281 // Construct the dialog - it is a sleeping dialog 
       
   282 // i.e. resources are allocated on construction
       
   283 // This is a good idea for LBS privacy requests which must be handled
       
   284 // in low memory conditions
       
   285 void CMyLBSPrivacyVerifier::ConstructL()
       
   286   {	
       
   287   iDlg = CMyLBSPrivacyVerifierDialog::NewLD(this, iResponseParams);
       
   288   }</codeblock></section>
       
   289 <section><title>Registering the notifier </title><p><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> and <xref href="GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0.dita#GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0/GUID-EC4180F5-AB27-3744-8755-BA59B3BCE19C"><apiname>MEikSrvNotifierBase2::Info()</apiname></xref> are standard notifier methods that can be implemented as shown below: </p><codeblock xml:space="preserve">// Called by notifier framework once to register the notifier with ECOM
       
   290 MEikSrvNotifierBase2::TNotifierInfo CMyLBSPrivacyVerifier::RegisterL()
       
   291   {
       
   292   iInfo.iUid = KLbsExtLocationRequestVerifyUid;
       
   293   iInfo.iChannel = KScreenOutputChannel;
       
   294 
       
   295   // High priority privacy request
       
   296   iInfo.iPriority = ENotifierPriorityVHigh;
       
   297   return iInfo;
       
   298   }
       
   299 
       
   300 MEikSrvNotifierBase2::TNotifierInfo CMyLBSPrivacyVerifier::Info() const
       
   301   {
       
   302   return iInfo;
       
   303   }</codeblock><note>The value <codeph>KLbsExtLocationRequestVerifyUid</codeph> as
       
   304 defined in <filepath>lbsextprivacynotifiers.h</filepath> must be used for
       
   305 the notifier registration. The choice of notifier priority is a licensee decision,
       
   306 but a high priority is recommended because a user response is required. </note></section>
       
   307 <section><title>Starting the notifier </title><p>A Privacy Verification Notifier
       
   308 must implement the asynchronous form of <xref href="GUID-650E29C8-3B2B-3B77-A4E5-766DED0F83F0.dita#GUID-650E29C8-3B2B-3B77-A4E5-766DED0F83F0/GUID-93746BF4-4F20-304A-BC72-2CE0C776D001"><apiname>MEikSrvNortifierBase2::StartL()</apiname></xref>.
       
   309 The code example below shows how to do this. The LBS subsystem sends a <codeph>TLbsPrivacyNotifierParamsPckg</codeph> object
       
   310 to the notifier from which the <codeph>TLbsExternalRequestInfo</codeph> can
       
   311 be extracted. </p><codeblock xml:space="preserve">// Asynchronous StartL is used for privacy verification because a response is required
       
   312 void CMyLBSPrivacyVerifier::StartL(const TDesC8&amp; aBuffer,
       
   313                                    TInt aReplySlot,
       
   314                                    const RMessagePtr2&amp; aMessage)
       
   315   {
       
   316   // Copy aMessage and aReplySlot to reply to the request at a later time
       
   317   iMessage = aMessage;
       
   318   iReplySlot = aReplySlot;
       
   319 	
       
   320   TBuf8&lt;KLbsMaxClientNameSize&gt; clientName;
       
   321   TBuf8&lt;KLbsMaxRequesterIdSize&gt; requesterId;
       
   322 	
       
   323   TLbsPrivacyNotifierParamsPckg pckg;
       
   324   pckg.Copy(aBuffer);
       
   325   TLbsPrivacyNotifierParams params = pckg();
       
   326   TLbsExternalRequestInfo info;
       
   327   params.GetRequesterInfo(info);
       
   328 	
       
   329   // Show the dialog with the requester details
       
   330   iDlg-&gt;ShowDialog(info);
       
   331   }</codeblock><note>A Privacy Verification Notifier need only implement an
       
   332 empty implementation of the synchronous <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> method.
       
   333  </note></section>
       
   334 <section><title>Getting the privacy response parameters </title><p>The example
       
   335 notifier has a method called <codeph>DialogDismissed()</codeph> which is called
       
   336 by the verification dialog when it is closed (either by pressing <uicontrol>Accept</uicontrol> or <uicontrol>Cancel</uicontrol>).
       
   337 The method implementation below shows how to package up the privacy response
       
   338 into a <codeph>TLbsPrivacyReponseParamsPckg</codeph>, complete the message
       
   339 and cancel the notifier. </p><codeblock xml:space="preserve">// Called when dialog is dismissed
       
   340 void CMyLBSPrivacyVerifier::DialogDismissed()
       
   341   {
       
   342   // Set the response on the basis of the response params
       
   343   if (!iMessage.IsNull())
       
   344     {
       
   345     // The dialog has already updated iResponseParams by reference
       
   346     // Create package buf to send parameters to the calling client
       
   347     TLbsPrivacyResponseParamsPckg pckg(iResponseParams);
       
   348     iMessage.WriteL(iReplySlot, pckg);
       
   349     iMessage.Complete(KErrNone);
       
   350 
       
   351     // Cancel the notifier
       
   352     iManager-&gt;CancelNotifier(KLbsExtLocationRequestVerifyUid);
       
   353 		  }
       
   354   }</codeblock></section>
       
   355 <section><title>Cancelling the notifier </title><p>The LBS subsystem has a
       
   356 timeout for Privacy Notifiers that calls the <xref href="GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0.dita#GUID-DE445C4B-22EF-3A1F-8A69-57CB703BFAD0/GUID-D53FC05F-B90A-3CB6-874E-39C4709310C9"><apiname>MEikSrvNotifierBase2::Cancel()</apiname></xref> method. </p><codeblock xml:space="preserve">// Called to cancel the notification (for example for a request timeout)
       
   357 // The LBS subsystem sets the timeout for privacy notifiers
       
   358 void CMyLBSPrivacyVerifier::Cancel()
       
   359   {
       
   360   if (!iMessage.IsNull())
       
   361     {
       
   362 		  iMessage.Complete(KErrCancel);
       
   363 		  }
       
   364   iDlg-&gt;HideDialog();
       
   365   }</codeblock></section>
       
   366 <section><title>Releasing the notifier </title><p>The ECOM release method
       
   367 just calls delete on the notifier.</p><codeblock xml:space="preserve">// Just delete the notifier
       
   368 void CMyLBSPrivacyVerifier::Release()
       
   369   {
       
   370   delete this;
       
   371   }</codeblock></section>
       
   372 <section><title>Notifier destructor </title><p>The destructor method just
       
   373 deletes the dialog object that was created in the notifier's <codeph>ConstructL()</codeph>. </p><codeblock xml:space="preserve">CMyLBSPrivacyVerifier::~CMyLBSPrivacyVerifier()
       
   374   {
       
   375   if (iDlg)
       
   376     {
       
   377     // Delete the dialog
       
   378     delete iDlg;
       
   379     }
       
   380   }</codeblock></section>
       
   381 <section><title>Constructing the dialog </title><p>These methods show how
       
   382 the dialog is constructed. A reference to the response parameters object owned
       
   383 by the parent notifier is passed by reference in the <codeph>NewLD()</codeph> method.
       
   384 This is written to when the user chooses to accept or reject the privacy request. </p><codeblock xml:space="preserve">// Static function to create new dialog
       
   385 // Response parameters passed by reference
       
   386 // They are written when the dialog closes
       
   387 CMyLBSPrivacyVerifierDialog* CMyLBSPrivacyVerifierDialog::NewLD(
       
   388                                 CMyLBSPrivacyVerifier* aNotifier,
       
   389                                 TLbsPrivacyResponseParams&amp; aResponseParams)
       
   390   {
       
   391   CMyLBSPrivacyVerifierDialog* self
       
   392 = new (ELeave) CMyLBSPrivacyVerifierDialog(aNotifier, aResponseParams);
       
   393 
       
   394   CleanupStack::PushL(self);
       
   395   self-&gt;ConstructL();
       
   396   CleanupStack::Pop(self);
       
   397   return self;
       
   398   }
       
   399 
       
   400 // Private dialog constructor 
       
   401 // Set the notifier to be the observer 
       
   402 // and pass a reference to response parameters
       
   403 CMyLBSPrivacyVerifierDialog::CMyLBSPrivacyVerifierDialog(
       
   404 CMyLBSPrivacyVerifier* aNotifier, 
       
   405 TLbsPrivacyResponseParams&amp; aResponseParams) : 
       
   406 iNotifier(aNotifier), iResponseParams(aResponseParams)
       
   407   {
       
   408   }
       
   409 
       
   410 // Second stage constructor - load dialog resources
       
   411 void CMyLBSPrivacyVerifierDialog::ConstructL()
       
   412   {
       
   413   LoadResourceL();	
       
   414   }</codeblock></section>
       
   415 <section><title>Loading dialog resources </title><p>For the example shown,
       
   416 the dialog resources are loaded when it is constructed (a sleeping dialog).
       
   417 This is a good design decision for dialogs that must be shown in low memory
       
   418 conditions, which is the case for the LBS dialogs that must notify of emergency
       
   419 location requests. </p><codeblock xml:space="preserve">// Load resources for the dialog
       
   420 void CMyLBSPrivacyVerifierDialog::LoadResourceL()
       
   421   {
       
   422 	
       
   423   // Notifiers can be loaded from ROM or RAM
       
   424   // resource location is not hard-coded
       
   425   TFileName fileName;
       
   426   Dll::FileName(fileName);
       
   427   fileName.SetLength(KMaxDriveName);
       
   428 
       
   429   // force arg evaluation before calling _LIT
       
   430   #define _LIT1(k,s) _LIT(k,s) 
       
   431         
       
   432   // Values defined in MyLBSPrivacyVerifier.h
       
   433   // Dialog resources
       
   434   _LIT1(KRscFile, VERIFY_RESOURCE);
       
   435   _LIT1(KRscDir,  VERIFY_RESOURCE_PATH);
       
   436    
       
   437   fileName+=KRscDir;
       
   438   fileName+=KRscFile;
       
   439 
       
   440   // Load the dialog resources
       
   441   iEikonEnv = CEikonEnv::Static();
       
   442   BaflUtils::NearestLanguageFile(iEikonEnv-&gt;FsSession(),fileName);
       
   443 		
       
   444   TInt offset = iEikonEnv-&gt;AddLibraryL(&amp;fileName);
       
   445   TRAPD(err, ConstructSleepingDialogL(R_LBS_VERIFY_DIALOG));
       
   446   iEikonEnv-&gt;DeleteResourceFile(offset);
       
   447   User::LeaveIfError(err);
       
   448   }</codeblock></section>
       
   449 <section><title>Showing the dialog </title><p>The method <codeph>ShowDialog()</codeph> is
       
   450 called by the notifier when it is started by a call to <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>.
       
   451 In this example, all dialog resources were allocated at start-up so it is
       
   452 only necessary to show it. </p><codeblock xml:space="preserve">void CMyLBSPrivacyVerifierDialog::ShowDialog(TLbsExternalRequestInfo&amp; aInfo)
       
   453   {
       
   454   iInfo = aInfo;
       
   455   RouseSleepingDialog();
       
   456   }</codeblock><p>The dialog method <xref href="GUID-DC21E927-18B3-3BBF-9B67-496F2D158B03.dita#GUID-DC21E927-18B3-3BBF-9B67-496F2D158B03/GUID-AD6F7AE7-FCB8-38F0-9B6B-9FF24F2863AC"><apiname>CEikDialog::PreLayoutDynInitL()</apiname></xref> is
       
   457 implemented to show the client name from <codeph>TLbsExternalRequestInfo</codeph> before
       
   458 the dialog is shown to the user. This method could also show the other data
       
   459 fields held in <codeph>TLbsExternalRequestInfo</codeph>. </p><codeblock xml:space="preserve">// Populate the privacy verification dialog with the user identity
       
   460 void CMyLBSPrivacyVerifierDialog::PreLayoutDynInitL()
       
   461   {
       
   462   TBuf8&lt;KLbsMaxClientNameSize&gt; clientName;
       
   463   TBuf8&lt;KLbsMaxRequesterIdSize&gt; requesterId;
       
   464   TBuf8&lt;KLbsMaxClientExternalIdSize&gt; externalId;
       
   465 	
       
   466   iInfo.GetClientName(clientName);
       
   467   iInfo.GetRequesterId(requesterId);
       
   468   iInfo.GetClientExternalId(externalId);
       
   469 	
       
   470   // Show the client name
       
   471   // Expand() only works for converting from ASCII
       
   472   // encoded buffer to Unicode
       
   473   // You may need to use CCnvCharacterSetConverter in your implementation
       
   474 
       
   475   CEikEdwin* edwin = STATIC_CAST(CEikEdwin*, 
       
   476                                  this-&gt;Control(EPrivacyClientName));
       
   477   edwin -&gt;SetTextL(&amp;clientName.Expand());
       
   478   edwin-&gt;SetReadOnly(ETrue);
       
   479 	
       
   480   // Could also show the requesterId and externalId in the dialog...
       
   481   }</codeblock></section>
       
   482 <section><title>Making a privacy response </title><p>The dialog's <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> method
       
   483 is called when the user selects <uicontrol>Accept</uicontrol> or <uicontrol>Cancel</uicontrol>.
       
   484 This method is implemented to set the <codeph>TLbsPrivacyResponseParameters</codeph> in
       
   485 the parent notifier with the user response, which is either to accept or reject
       
   486 the privacy request.</p><codeblock xml:space="preserve">// From CEikDialog - called when a dialog button is pressed
       
   487 TBool CMyLBSPrivacyVerifierDialog::OkToExitL(TInt aButtonId)
       
   488   {
       
   489   // Set the notifier response parameters based on user response
       
   490   // Member variable iResponse is reference
       
   491   // to notifier TLbsPrivacyResponseParams
       
   492 	
       
   493   // Get the value of the pressed button
       
   494   if (aButtonId == EPrivacyRequestAccept)
       
   495     {
       
   496     iResponseParams.SetResponseType(EResponseAccepted);
       
   497     }
       
   498   else // Privacy request rejected 
       
   499     {
       
   500     iResponseParams.SetResponseType(EResponseRejected);
       
   501     }
       
   502 
       
   503   // Inform the notifier that this dialog is exiting
       
   504   // so that it can inform the notifier manager
       
   505   iNotifier-&gt;DialogDismissed();
       
   506   return ETrue;
       
   507   }</codeblock></section>
       
   508 <section><title>Hiding the dialog and freeing resources</title><p>The dialog's <codeph>HideDialog()</codeph> method
       
   509 is called by the notifier when LBS cancels the notifier, for example if a
       
   510 timeout occurs or another privacy request is sent (a new privacy request cancels
       
   511 any outstanding privacy request). In this example, the dialog resources are
       
   512 not freed because the dialog is a sleeping dialog. </p><codeblock xml:space="preserve">// Hide the dialog and report to the notifier
       
   513 void CMyLBSPrivacyVerifierDialog::HideDialog()
       
   514   {
       
   515   // Using a sleeping dialog
       
   516   ExitSleepingDialog();
       
   517   iNotifier-&gt;DialogDismissed();
       
   518   }
       
   519 
       
   520 // Destructor frees dialog resources
       
   521 CMyLBSPrivacyVerifierDialog::~CMyLBSPrivacyVerifierDialog()
       
   522   {
       
   523   iEikonEnv-&gt;EikAppUi()-&gt;RemoveFromStack(this);
       
   524   FreeResource();
       
   525   }
       
   526 
       
   527 // Free dialog resources
       
   528 void CMyLBSPrivacyVerifierDialog::FreeResource()
       
   529   {
       
   530   if (iResourceFile)
       
   531     {
       
   532 		  CEikonEnv::Static()-&gt;RemoveLibrary(iResourceFile);
       
   533 		  iResourceFile = 0;
       
   534     }
       
   535   }</codeblock></section>
       
   536 </conbody></concept>