Symbian3/PDK/Source/GUID-5008C3E6-4D12-5BA3-A95A-7CAB02ED0594.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Fri, 22 Jan 2010 18:26:19 +0000
changeset 1 25a17d01db0c
child 3 46218c8b8afa
permissions -rw-r--r--
Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     1
<?xml version="1.0" encoding="utf-8"?>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     2
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     3
<!-- This component and the accompanying materials are made available under the terms of the License 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     4
"Eclipse Public License v1.0" which accompanies this distribution, 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     5
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     6
<!-- Initial Contributors:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     7
    Nokia Corporation - initial contribution.
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     8
Contributors: 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     9
-->
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    10
<!DOCTYPE task
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    11
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    12
<task xml:lang="en" id="GUID-5008C3E6-4D12-5BA3-A95A-7CAB02ED0594"><title>Privacy Request API Tutorial</title><shortdesc>This topic describes how to use the <codeph>Privacy
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    13
        Request API</codeph>. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody><prereq><p>The reader must be familiar with the Privacy Protocol Module and the Privacy Request API. </p> </prereq> <context><p>When LBS is configured to load the Privacy Protocol Module, it handles only privacy requests and does not calculate position fixes. It is the responsibility of licensee domestic OS components to obtain the device's position. The <xref href="GUID-E1710E40-B8F5-5CF8-B9FE-698869A1770F.dita">Privacy Request API</xref> provides the means to send privacy requests into the LBS subsystem. </p> <p>To use the Network Privacy API a licensee must create a client component that runs in the licensee domestic OS. This component receives privacy and location requests from the network or from an installed application and forwards them to the LBS subsystem via the Privacy Request API. </p> <p>The Privacy Request API is only available with the Privacy Protocol Module. The first privacy request sent via the Network Privacy API causes the LBS subsystem components to be started. </p> <p>Many of the implementation details of creating a Privacy Request API client are licensee-specific. Generally, the client must: </p> <ul><li id="GUID-6F4E4B47-707B-574E-B84D-A56735BA956F"><p>Listen for privacy and location requests received from the client. </p> </li> <li id="GUID-7A907A6B-8A62-50F7-B80D-0CEC892DDE64"><p>Use the Privacy Request API to forward privacy requests to the LBS subsystem. </p> </li> <li id="GUID-37006B7B-FE52-5BCE-A16E-3DC200B0C5F9"><p>Receive responses to privacy requests from the LBS subsystem via the Privacy Request API and return them to the client. </p> </li> <li id="GUID-BCA372D2-FCF5-542A-BC1D-BE456BA5694E"><p>If a privacy request is accepted, forward the subsequent location request to a component in the licensee domestic OS so that a position fix can be obtained. </p> </li> </ul> <p>The steps that follow describe only the interactions of the client with the Privacy Request API. </p> </context> <steps id="GUID-70CE3988-65BE-5175-9E49-C83075FDBA99"><step id="GUID-4CF0205F-0392-593F-AE1A-9763D65B5DF4"><cmd>Create a Privacy Request API client. </cmd> <info>The code example below shows a simple implementation of an <xref href="GUID-BD22CA43-FDAF-3809-8172-6403B4D7529A.dita"><apiname>MLbsPrivacyRequestObserver</apiname></xref> subclass that uses the Privacy Request API. Such a class could be the basis of an observer class in a licensee client application. </info> <stepxmp><codeblock id="GUID-026AAC28-BE07-5CFB-BAA2-DD346AB8F51C" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    14
#ifndef CMYPRIVACYREQUESTLISTENER_H_
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    15
#define CMYPRIVACYREQUESTLISTENER_H_
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    16
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    17
#include &lt;lbsprivacyrequest.h&gt;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    18
#include &lt;lbsloccommon.h&gt;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    19
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    20
class CMyPrivacyRequestObserver : public MLbsPrivacyRequestObserver
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    21
{
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    22
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    23
public:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    24
    static CMyPrivacyRequestObserver* NewL();
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    25
    virtual ~CMyPrivacyRequestObserver();
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    26
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    27
// From MLbsPrivacyRequestObserver
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    28
public:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    29
    void OnPrivacyResponse(TLbsPrivacyRequestId aRequestId, const TLbsPrivacyResponse&amp; aResponse, TInt aError);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    30
    
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    31
public:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    32
    void VerifyPrivacyRequest(const TLbsExternalRequestInfo&amp; aInfo);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    33
    void NotifyPrivacyRequest(const TLbsExternalRequestInfo&amp; aInfo);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    34
    void CancelPrivacyRequest(TLbsPrivacyRequestId&amp; aRequestId);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    35
    void TimeoutPrivacyRequest(TLbsPrivacyRequestId&amp; aRequestId);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    36
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    37
protected:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    38
CMyPrivacyRequestObserver();
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    39
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    40
private:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    41
    CLbsPrivacyRequest* iPrivacy;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    42
    TLbsPrivacyRequestId iRequestId; // This demo client just stores a single request ID
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    43
    void ConstructL();
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    44
};
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    45
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    46
#endif /*CMYPRIVACYREQUESTLISTENER_H_*/
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    47
</codeblock> </stepxmp> <info>The code below shows the creation of a <xref href="GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47.dita"><apiname>CLbsPrivacyRequest</apiname></xref> object in the second phase constructor of the observer. The LBS subsystem is transient when it uses the Privacy Protocol Module. Creating an instance of <codeph>CMyPrivacyRequestObserver</codeph> does not cause the LBS subsystem to be started. </info> <stepxmp><codeblock id="GUID-2FCE526A-8349-5DBB-9BCA-9F6E47D55AF2" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    48
CMyPrivacyRequestObserver* CMyPrivacyRequestObserver::NewL()
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    49
    {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    50
    CMyPrivacyRequestObserver* listener = 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    51
                  new (ELeave)CMyPrivacyRequestObserver();
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    52
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    53
    CleanupStack::PushL(listener);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    54
    listener-&gt;ConstructL();
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    55
    CleanupStack::Pop(listener);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    56
    return listener;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    57
    }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    58
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    59
void CMyPrivacyRequestObserver::ConstructL()
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    60
    {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    61
    iPrivacy = CLbsPrivacyRequest::NewL(*this);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    62
    }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    63
</codeblock> </stepxmp> </step> <step id="GUID-B1A1D2EE-267B-5830-9C3F-4DE61073600E"><cmd>Write code to send a privacy verification request. </cmd> <info>The licensee client receives a privacy verification request from the network or a local application. The privacy request requires user verification. The following describes the steps the licensee client application performs for a privacy verification request: </info> <substeps id="GUID-87F96DA5-B499-5BB9-8807-CE49953FEC5E"><substep id="GUID-76014EDA-5867-5AB4-A68A-EC2FB293F0BC"><cmd/><info>The client creates an instance of class <xref href="GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08.dita"><apiname>TLbsExternalRequestInfo</apiname></xref> (or <xref href="GUID-EB52E7D5-55AE-3539-A212-AB2B5430D407.dita"><apiname>TLbsExternalRequestInfo2</apiname></xref>) and populates it with the privacy request data. </info> <info>For a local privacy request, the client must call <xref href="GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08.dita#GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08/GUID-A7DF2BBC-B2E9-39CB-B8D0-1A1B9D4018AC"><apiname>TLbsExternalRequestInfo::SetRequestSource()</apiname></xref> with a parameter of <xref href="GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08.dita#GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08/GUID-4FF586E1-4503-32CC-BF50-414D7F02034C"><apiname>TLbsExternalRequestInfo::ERequestSourceLocal</apiname></xref>. The client must have the capabilities <codeph>Location</codeph> and <codeph>ReadDeviceData</codeph>. For a privacy request from the network, a parameter of <xref href="GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08.dita#GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08/GUID-9396B026-170A-33B2-80DF-8FFB112EE9EC"><apiname>TLbsExternalRequestInfo::ERequestSourceNetwork</apiname></xref> must be passed. The client must have the capabilities <codeph>Location</codeph>, <codeph>ReadDeviceData</codeph> and <codeph>NetworkServices</codeph>. </info> <info>The client creates an instance of an object of class <xref href="GUID-DA7E60CF-52F9-3ACF-AB12-E647AD980C81.dita"><apiname>TLbsPrivacyRequest</apiname></xref> and defines the privacy advice and privacy action. For a privacy verification request, the privacy advice is set to <codeph>TLbsPrivacyRequest::ERequestAdviceVerify</codeph>. </info> </substep> <substep id="GUID-FE378075-4070-5AA2-B8B3-F8B8775970F4"><cmd/><info>The client calls <xref href="GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47.dita#GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47/GUID-456AB7A5-73D7-36E3-B455-6B9D6B8B598D"><apiname>CLbsPrivacyRequest::NewPrivacyRequest()</apiname></xref>. This method is asynchronous and non-blocking. The client can process multiple privacy requests by calling <codeph>NewPrivacyRequest()</codeph> multiple times. Each request is identified by a unique request ID which is returned by LBS as an output parameter. The LBS subsystem is started if it is not running when a request is made. </info> </substep> <substep id="GUID-9AFB9D8A-765F-588B-8505-360675062665"><cmd/><info>When the privacy request is completed, the method <xref href="GUID-BD22CA43-FDAF-3809-8172-6403B4D7529A.dita#GUID-BD22CA43-FDAF-3809-8172-6403B4D7529A/GUID-14A97B64-59EF-3AE0-B144-3EE66754F610"><apiname>MLbsPrivacyRequestObserver::OnPrivacyResponse()</apiname></xref> is called on the client observer. The licensee client sends the privacy response to the local application or the network (whichever made the privacy request). </info> </substep> </substeps> <info>The following code example demonstrates how to use the Privacy Request API to verify a privacy request. </info> <stepxmp><codeblock id="GUID-84CB99B1-55CA-5BBD-9723-44A28D057383" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    64
// In this example, the TLbsExternalRequestInfo object
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    65
// is created by the client application
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    66
void CMyPrivacyRequestObserver::VerifyPrivacyRequest(const TLbsExternalRequestInfo&amp; aInfo)
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    67
    {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    68
    
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    69
    // Example shows how to set the privacy advice to verify the request
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    70
    // and set the privacy action to reject if there is no privacy response
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    71
    
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    72
    TLbsPrivacyRequest privacy;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    73
    privacy.SetRequestAdvice(TLbsPrivacyRequest::ERequestAdviceVerify);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    74
    privacy.SetRequestAction(TLbsPrivacyRequest::ERequestActionReject);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    75
    TInt err = iPrivacy-&gt;NewPrivacyRequest(iRequestId, privacy, aInfo);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    76
    if (err != KErrNone)
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    77
        {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    78
        // Error could be KErrArgument if incorrect parameters passed
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    79
        // or any other Symbian error code
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    80
        }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    81
    }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    82
</codeblock> </stepxmp> <info> <xref href="GUID-BD22CA43-FDAF-3809-8172-6403B4D7529A.dita#GUID-BD22CA43-FDAF-3809-8172-6403B4D7529A/GUID-14A97B64-59EF-3AE0-B144-3EE66754F610"><apiname>MLbsPrivacyRequestObserver::OnPrivacyResponse()</apiname></xref> is called to complete the request. </info> <stepxmp><codeblock id="GUID-453FAE11-5351-5F8E-838B-A9C325C7AB21" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    83
void CMyPrivacyRequestObserver::OnPrivacyResponse(TLbsPrivacyRequestId aRequestId, const TLbsPrivacyResponse&amp; aResponse, TInt aError)
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    84
    {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    85
    // Forward privacy response to client then call CompleteRequest...
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    86
    iPrivacy-&gt;CompleteRequest(aRequestId, KErrNone);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    87
    }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    88
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    89
</codeblock> </stepxmp> </step> <step id="GUID-5CEAAB5D-DF37-5503-926B-65D5DFD1CB40"><cmd>Write code to send a privacy notification request. </cmd> <info>The licensee client receives a privacy request from the network or a local application. The privacy request does not require verification. The following describes the steps the licensee client application performs for a privacy notification request: </info> <substeps id="GUID-5A0F5796-5BFC-50F9-B8A0-6F3511050EBA"><substep id="GUID-FAFF077E-9100-58C5-B025-80A31302066A"><cmd/><info>The client creates an instance of class <xref href="GUID-D6E1F012-8C98-3B10-9601-3F665CFD5F08.dita"><apiname>TLbsExternalRequestInfo</apiname></xref> as described for privacy verification in the previous section. </info> <info>The client creates an instance of an object of class <xref href="GUID-DA7E60CF-52F9-3ACF-AB12-E647AD980C81.dita"><apiname>TLbsPrivacyRequest</apiname></xref> and defines the privacy advice and privacy action. For a privacy notification request, the privacy advice is set to <codeph>TLbsPrivacyRequest::ERequestAdviceNotify</codeph>. </info> </substep> <substep id="GUID-F4E6E508-3BE1-5A44-A396-213A1B178664"><cmd/><info>The client calls <xref href="GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47.dita#GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47/GUID-456AB7A5-73D7-36E3-B455-6B9D6B8B598D"><apiname>CLbsPrivacyRequest::NewPrivacyRequest()</apiname></xref>. This method is asynchronous and non-blocking. The client can process multiple privacy requests by calling <codeph>NewPrivacyRequest()</codeph> multiple times. Each request is identified by a unique request ID which must be passed as a parameter. The LBS subsystem is started if it is not running when a request is made. </info> </substep> </substeps> <info>The following code example demonstrates how to use the Privacy Request API to notify a privacy request. </info> <stepxmp><codeblock id="GUID-E95AA02F-6D06-5765-9813-9D399E4594DB" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    90
// In this example, the TLbsExternalRequestInfo object
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    91
// is created by the client application
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    92
void CMyPrivacyRequestObserver::NotifyPrivacyRequest(const TLbsExternalRequestInfo&amp; aInfo)
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    93
    {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    94
    
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    95
    // Example shows how to set the privacy advice to verify the request
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    96
    // and set the privacy action to reject if there is no privacy response
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    97
    
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    98
    TLbsPrivacyRequest privacy;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    99
    privacy.SetRequestAdvice(TLbsPrivacyRequest::ERequestAdviceNotify);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   100
    privacy.SetRequestAction(TLbsPrivacyRequest::ERequestActionReject);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   101
    TInt err = iPrivacy-&gt;NewPrivacyRequest(iRequestId, privacy, aInfo);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   102
    if (err != KErrNone)
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   103
        {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   104
        // Error could be KErrArgument if incorrect parameters passed
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   105
        // or any other Symbian error code
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   106
        }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   107
    }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   108
</codeblock> </stepxmp> <info> <xref href="GUID-BD22CA43-FDAF-3809-8172-6403B4D7529A.dita#GUID-BD22CA43-FDAF-3809-8172-6403B4D7529A/GUID-14A97B64-59EF-3AE0-B144-3EE66754F610"><apiname>MLbsPrivacyRequestObserver::OnPrivacyResponse()</apiname></xref> is called to complete the request. </info> </step> <step id="GUID-DBF06C5A-5974-5A43-A4B7-18211AF527F1"><cmd>Write code to cancel a pending privacy verification request. </cmd> <info>The code example below shows how a client can cancel an outstanding request by calling <xref href="GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47.dita#GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47/GUID-65A421D0-4A31-39F2-871A-A7A3C63ACC32"><apiname>CLbsPrivacyRequest::CompleteRequest()</apiname></xref>. </info> <stepxmp><codeblock id="GUID-15C9421E-5CCA-54CE-AFE1-D8C43D2302DD" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   109
void CMyPrivacyRequestObserver::CancelPrivacyRequest(TLbsPrivacyRequestId&amp; aRequestId)
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   110
    {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   111
    iPrivacy-&gt;CompleteRequest(aRequestId, KErrCancel);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   112
    }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   113
</codeblock> </stepxmp> </step> <step id="GUID-6551A2BD-49D6-5867-AD20-BC9E9B929217"><cmd>Write code to send a timeout notification. </cmd> <info>The code example below shows how a request can be timed out. The timeout is sent to the LBS subsystem by calling <xref href="GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47.dita#GUID-FA2B30DF-81BC-3BCD-9EE6-01A961291D47/GUID-65A421D0-4A31-39F2-871A-A7A3C63ACC32"><apiname>CLbsPrivacyRequest::CompleteRequest()</apiname></xref>. </info> <stepxmp><codeblock id="GUID-0928FEEA-610F-54A6-9937-DA305D654634" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   114
void CMyPrivacyRequestObserver::TimeoutPrivacyRequest(TLbsPrivacyRequestId&amp; aRequestId)
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   115
    {
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   116
        iPrivacy-&gt;CompleteRequest(aRequestId, KErrTimedOut);
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   117
    }
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   118
</codeblock> </stepxmp> </step> <step id="GUID-79F7D826-E965-5603-A5DD-4FEDDC1F1B61"><cmd>Define client capabilities. </cmd> <info>The following is a simple MMP file for the client. The header files for the Privacy Request API are located at <filepath>\epoc32\include\lbs</filepath> and the client links to <filepath>lbsprivacyrequest.lib</filepath>. All clients require the capabilities <codeph>Location</codeph> and <codeph>ReadDeviceData</codeph>. Clients that create network privacy requests also require the capability <codeph>NetworkServices</codeph>. </info> <stepxmp><codeblock id="GUID-250CD303-C15C-55FB-A1A1-E09E0C37180A" xml:space="preserve">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   119
TARGET          PrivacyRequestAPI_Example.exe
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   120
TARGETTYPE      exe
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   121
UID             0 0x12345678
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   122
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   123
USERINCLUDE     ..\inc
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   124
SYSTEMINCLUDE   \epoc32\include \epoc32\include\lbs
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   125
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   126
SOURCEPATH      ..\src
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   127
SOURCE          PrivacyRequestAPI_Example.cpp CMyPrivacyRequestListener.cpp
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   128
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   129
LIBRARY         euser.lib lbsprivacyrequest.lib
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   130
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   131
CAPABILITY Location ReadDeviceData NetworkServices</codeblock> </stepxmp> </step> </steps> </taskbody><related-links><link href="GUID-0BF06E5D-BEEF-5E15-894E-FA605FA12E33.dita"><linktext>Privacy
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   132
                Protocol Module Overview</linktext> </link> <link href="GUID-E1710E40-B8F5-5CF8-B9FE-698869A1770F.dita"><linktext>Privacy
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
   133
                Request API</linktext> </link> </related-links></task>