|
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-12DA697C-1BB0-489F-98E1-F9B81E4A2F4D" xml:lang="en"><title>Creating |
|
13 a Privacy Notification Notifier</title><shortdesc>To use the LBS Privacy Notifiers for privacy verification and privacy |
|
14 notification a licensee must implement a Privacy Notification Notifier. The |
|
15 licensee should override the synchronous <apiname>MEikSrvNotifierBase2::StartL()</apiname> method |
|
16 that does not return a response. This is because the user cannot send a response |
|
17 to a privacy notification. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
18 <p>This topic describes how to implement a Privacy Notification Notifier, |
|
19 which is used to handle privacy notification requests. </p> |
|
20 <p>The implementation of a Privacy Notification Notifier is similar to that |
|
21 of a Privacy Verification Notifier. In particular, the same <codeph>TLbsExternalRequestInfo</codeph> object |
|
22 is passed for privacy notification as for privacy verification. The most notable |
|
23 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 |
|
24 implemented. This is because the notifier is used only for privacy notification |
|
25 and it is not possible to respond to it. This makes implementation of the |
|
26 notifier easier. </p> |
|
27 <section> <title>Defining the Privacy Notification Notifier</title> |
|
28 <p>The code below shows a definition of a Privacy Notification Notifier |
|
29 class. </p><p>The notifier owns a <codeph>CMyLBSPrivacyNotifierDialog</codeph> dialog |
|
30 class to show details of the privacy request to the end user and to obtain |
|
31 the response. </p><codeblock xml:space="preserve">/* |
|
32 ============================================================================ |
|
33 Name : MyLBSPrivacyNotifier.h |
|
34 Description : This file defines a LBS Privacy Notification Notifier |
|
35 ============================================================================ |
|
36 */ |
|
37 |
|
38 #ifndef __MYLBSPRIVACYNOTIFIER_H__ |
|
39 #define __MYLBSPRIVACYNOTIFIER_H__ |
|
40 |
|
41 #define NOTIFY_RESOURCE_PATH "\\private\\10003a4a\\" // Default location for dialog GUI resources |
|
42 #define NOTIFY_RESOURCE "MyLBSPrivacyDialogs.rsc" // Compiled dialog resource file name |
|
43 |
|
44 // This value is defined in MyLBSPrivacyVerifier.h |
|
45 //const TUid KScreenOutputChannel={0x1000ABEF}; |
|
46 |
|
47 // Include Files |
|
48 #include <e32base.h> |
|
49 #include <eiknotapi.h> |
|
50 #include <eikdialg.h> |
|
51 #include "lbsprivacyextnotifiers.h" // Defines privacy data types |
|
52 #include "MyLBSNotifiersChannel.h" // Channel for notifier display |
|
53 |
|
54 // Dialog forward declaration for notifier |
|
55 class CMyLBSPrivacyNotifierDialog; |
|
56 |
|
57 // Privacy verification notifier class definintion |
|
58 class CMyLBSPrivacyNotifier : public CBase, public MEikSrvNotifierBase2 |
|
59 { |
|
60 public: |
|
61 static CMyLBSPrivacyNotifier* NewL(); |
|
62 ~CMyLBSPrivacyNotifier(); |
|
63 |
|
64 // Called when the dialog is hidden |
|
65 void DialogDismissed(); |
|
66 |
|
67 private: // From MEikSrvNotifierBase2 |
|
68 |
|
69 // Not used for location notification - no response is required |
|
70 void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); |
|
71 |
|
72 // Synchronous StartL is used for location notification |
|
73 TPtrC8 StartL(const TDesC8& aBuffer); |
|
74 |
|
75 // Not implemented for LBS privacy notifiers |
|
76 TPtrC8 UpdateL(const TDesC8& aBuffer); |
|
77 |
|
78 TNotifierInfo RegisterL(); |
|
79 TNotifierInfo Info() const; |
|
80 void Cancel(); |
|
81 void Release(); |
|
82 |
|
83 private: |
|
84 CMyLBSPrivacyNotifier(); |
|
85 void ConstructL(); |
|
86 |
|
87 private: |
|
88 // Data members |
|
89 TNotifierInfo iInfo; |
|
90 |
|
91 // From lbsprivacyextnotifiers.h - request parameters |
|
92 TLbsPrivacyNotifierParams iRequestParams; |
|
93 |
|
94 // Verification Dialog |
|
95 CMyLBSPrivacyNotifierDialog* iDlg; |
|
96 |
|
97 }; |
|
98 |
|
99 #endif // __MYLBSPRIVACYNOTIFIER_H__</codeblock> </section> |
|
100 <section><title>Defining the Privacy Notification Dialog</title><p>The following |
|
101 is the definition of the dialog used by the example Privacy Notification Notifier: </p><codeblock xml:space="preserve">/* |
|
102 ============================================================================ |
|
103 Name : MyLBSPrivacyNotifier.cpp |
|
104 Description : Source for LBS location notification notifier and dialog |
|
105 ============================================================================ |
|
106 */ |
|
107 |
|
108 // System headers |
|
109 #include <eikdialg.h> |
|
110 #include <eikmfne.h> |
|
111 #include <eikenv.h> |
|
112 #include <bautils.h> |
|
113 #include <eikappui.h> |
|
114 #include <e32cmn.h> |
|
115 |
|
116 // LBS headers |
|
117 #include <lbsprivacyextnotifiers.h> |
|
118 |
|
119 // project headers |
|
120 #include <MyLBSPrivacyDialogs.rsg> |
|
121 #include "MyLBSPrivacyNotifier.h" |
|
122 #include "MyLBSDialogs.hrh" |
|
123 |
|
124 /* CMyLBSPrivacyNotifierDialog |
|
125 The resource for this dialog defines it as a sleeping dialog |
|
126 Resources are allocated for it when the owning notifier is loaded by ECom |
|
127 This is a good idea for situations where emergency requests notify the user |
|
128 so that a confirmation dialog is shown even in low memory conditions |
|
129 */ |
|
130 |
|
131 class CMyLBSPrivacyNotifierDialog : public CEikDialog |
|
132 { |
|
133 public: |
|
134 static CMyLBSPrivacyNotifierDialog* NewLD(CMyLBSPrivacyNotifier* aNotifier); |
|
135 ~CMyLBSPrivacyNotifierDialog(); |
|
136 |
|
137 void ShowDialog(TLbsExternalRequestInfo& aInfo); |
|
138 void HideDialog(); |
|
139 |
|
140 public: // from CEikDialog |
|
141 TBool OkToExitL(TInt aButtonId); |
|
142 void PreLayoutDynInitL(); |
|
143 |
|
144 private: |
|
145 CMyLBSPrivacyNotifierDialog(CMyLBSPrivacyNotifier* aNotifier); |
|
146 void LoadResourceL(); |
|
147 void FreeResource(); |
|
148 void ConstructL(); |
|
149 |
|
150 private: |
|
151 |
|
152 // The notifier that calls this dialog |
|
153 CMyLBSPrivacyNotifier* iNotifier; |
|
154 |
|
155 // Library resource containing dialog resources |
|
156 TInt iResourceFile; |
|
157 |
|
158 // The privacy requester info - contains requester id and name |
|
159 TLbsExternalRequestInfo iInfo; |
|
160 };</codeblock><p>The dialog requires a resource definition. In this case |
|
161 the dialog has only a <uicontrol>continue</uicontrol> button because no response |
|
162 can be made to the notification. </p><codeblock xml:space="preserve">RESOURCE DIALOG r_lbs_notify_dialog |
|
163 { |
|
164 title = "Privacy Notification Dialog"; |
|
165 flags=EEikDialogFlagNotifyEsc; |
|
166 buttons = R_EIK_BUTTONS_CONTINUE; |
|
167 items = |
|
168 { |
|
169 DLG_LINE |
|
170 { |
|
171 type = EEikCtLabel; |
|
172 control = LABEL |
|
173 { |
|
174 standard_font = EEikLabelFontAnnotation; |
|
175 txt = "Sending your location to :"; |
|
176 }; |
|
177 }, |
|
178 DLG_LINE |
|
179 { |
|
180 type = EEikCtEdwin; |
|
181 id = EPrivacyClientName; |
|
182 control = EDWIN |
|
183 { |
|
184 width = 10; |
|
185 maxlength = 25; |
|
186 }; |
|
187 } |
|
188 }; |
|
189 }</codeblock></section> |
|
190 <section><title>Notifier and dialog method implementations</title><p>Much |
|
191 of the implementation of a Privacy Notification Notifier is similar to that |
|
192 for a Privacy Verification Notifier. The most relevant differences are in |
|
193 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 |
|
194 must be used for the notifier registration. The choice of notifier priority |
|
195 is a licensee decision, but a high priority is recommended because a location |
|
196 notification can be sent as part of an emergency services request and the |
|
197 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 |
|
198 MEikSrvNotifierBase2::TNotifierInfo CMyLBSPrivacyNotifier::RegisterL() |
|
199 { |
|
200 iInfo.iUid = KLbsExtLocationRequestNotifyUid; |
|
201 iInfo.iChannel = KScreenOutputChannel; |
|
202 |
|
203 // High priority privacy request |
|
204 iInfo.iPriority = ENotifierPriorityVHigh; |
|
205 return iInfo; |
|
206 }</codeblock><p>The notifier implements only the synchronous version of <codeph>StartL()</codeph>. </p><codeblock xml:space="preserve">// Synchronous StartL is used for location |
|
207 // notification because no response is required |
|
208 TPtrC8 CMyLBSPrivacyNotifier::StartL(const TDesC8& aBuffer) |
|
209 { |
|
210 TBuf8<KLbsMaxClientNameSize> clientName; |
|
211 TBuf8<KLbsMaxRequesterIdSize> requesterId; |
|
212 |
|
213 TLbsPrivacyNotifierParamsPckg pckg; |
|
214 pckg.Copy(aBuffer); |
|
215 TLbsPrivacyNotifierParams params = pckg(); |
|
216 TLbsExternalRequestInfo info; |
|
217 params.GetRequesterInfo(info); |
|
218 |
|
219 // Show the dialog with the requester details |
|
220 iDlg->ShowDialog(info); |
|
221 |
|
222 return TPtrC8(); |
|
223 }</codeblock><p><codeph>OkToExit(</codeph>) does not write any notifier |
|
224 response parameters. </p><codeblock xml:space="preserve">// From CEikDialog - called when a dialog button is pressed |
|
225 TBool CMyLBSPrivacyNotifierDialog::OkToExitL(TInt aButtonId) |
|
226 { |
|
227 // No response parameters to set for location notification |
|
228 |
|
229 // Inform the notifier that this dialog |
|
230 // is exiting so that it can inform the notifier manager |
|
231 iNotifier->DialogDismissed(); |
|
232 return ETrue; |
|
233 }</codeblock></section> |
|
234 </conbody></concept> |