networkprotocolmodules/privacyprotocolmodule/ClientAPI/PrivacyRequestAPI/src/lbsprivacyrequest.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32base.h>
       
    17 #include "lbsdevloggermacros.h"
       
    18 #include "lbsprivacyrequest.h"
       
    19 #include "lbsprivacyrequestimpl.h"
       
    20 
       
    21 
       
    22 //=============================================================================
       
    23 // MLbsPrivacyRequestObserver
       
    24 //=============================================================================
       
    25 
       
    26 /**
       
    27 Class version control.
       
    28 @return the version of the interface
       
    29 */
       
    30 EXPORT_C TVersion MLbsPrivacyRequestObserver::Version() const
       
    31 	{
       
    32 	return TVersion(1, 0, 0);
       
    33 	}
       
    34 
       
    35 /**
       
    36 Should not be used. Provides for future expansion of the observer interface. 
       
    37 */  
       
    38 /*virtual*/ EXPORT_C TAny* MLbsPrivacyRequestObserver::ExtendedInterface
       
    39 	(
       
    40 	TInt  /*aFunctionNumber*/,
       
    41 	TAny* /*aPtr1*/,
       
    42 	TAny* /*aPtr2*/
       
    43 	)
       
    44 	{
       
    45 	return NULL;
       
    46 	}
       
    47 
       
    48 
       
    49 //=============================================================================
       
    50 // CLbsPrivacyRequest
       
    51 //=============================================================================
       
    52 /**
       
    53 Static constructor for CLbsPrivacyRequest
       
    54 @param aObserver [In] The observer class that receives privacy responses.
       
    55 */
       
    56 EXPORT_C CLbsPrivacyRequest* CLbsPrivacyRequest::NewL(MLbsPrivacyRequestObserver& aObserver /*in*/)
       
    57 	{
       
    58 	LBSLOG(ELogP9, "<-S CLbsPrivacyRequest::NewL()\n");
       
    59     LBSLOG(ELogP9, " > MLbsPrivacyRequestObserver aObserver = unrecorded \n"); 
       
    60 	CLbsPrivacyRequest* self = new (ELeave) CLbsPrivacyRequest;
       
    61     CleanupStack::PushL(self);
       
    62     self->ConstructL(aObserver);
       
    63     CleanupStack::Pop(self);
       
    64     return self;
       
    65 	}
       
    66 	
       
    67 /**
       
    68 Default constructor.
       
    69 
       
    70 @internalComponent
       
    71 @prototype
       
    72 */
       
    73 CLbsPrivacyRequest::CLbsPrivacyRequest()
       
    74 	{
       
    75 	}
       
    76 	
       
    77 /**
       
    78 2nd phase static constructor.
       
    79 @internalComponent
       
    80 @prototype
       
    81 */
       
    82 void CLbsPrivacyRequest::ConstructL(MLbsPrivacyRequestObserver& aObserver)
       
    83 	{
       
    84 	iImpl = CLbsPrivacyRequestImpl::NewL(aObserver);
       
    85 	}
       
    86 
       
    87 /**
       
    88 Closes the interface and frees all the resources used.
       
    89 */	
       
    90 /*virtual*/ CLbsPrivacyRequest::~CLbsPrivacyRequest()
       
    91 	{
       
    92     LBSLOG(ELogP9, "<-S CLbsPrivacyRequest::~CLbsPrivacyRequest()\n");
       
    93     delete iImpl;
       
    94 	}
       
    95 
       
    96 /**
       
    97 Asks the LBS subsystem to process a privacy request from either a network or a local application.
       
    98 
       
    99 NewPrivacyRequest() is the first stage of a privacy verification or notification process and
       
   100 supplies information about the requester but does not actually ask the device for its position.
       
   101 
       
   102 The NewPrivacyRequest() method returns quickly but does not indicate if the 
       
   103 request should be accepted or rejected. When the LBS subsystem has determined whether the user 
       
   104 wants to accept or reject the request (or it times out), it responds via a call to MLbsPrivacyRequestObserver::OnPrivacyResponse(). 
       
   105 The response indicates if a user is willing to accept a location request.
       
   106 
       
   107 Default timeout may be controlled through the LBS Admin API.
       
   108 
       
   109 Note on capabilities: Calling this method only requires the capability NetworkServices 
       
   110 is the request is from the network as indicated by the TLbsExternalRequestInfo
       
   111 
       
   112 @param aRequestId    [Out] Unique identifier of a request.
       
   113 @param aPrivacy      [In]  Specifies the type of a request and a default action.
       
   114 @param aRequestInfo  [In]  Detailed information about the request.
       
   115 
       
   116 The following table presents valid privacy requests.
       
   117 If a request is found invalid, the method will return with
       
   118 the KErrArgument error code(if the combination of different values is incorrect)
       
   119 or the KErrNotSupported error code (if the functionality is not supported).
       
   120 
       
   121 @code
       
   122 TLbsPrivacyRequest::
       
   123 ||================================================||
       
   124 || TLbsRequestAdvice      | TLbsRequestAction     ||
       
   125 ||================================================||
       
   126 || any, except            | any, except           ||
       
   127 || ERequestAdviceNotUsed, | ERequestActionNotUsed ||
       
   128 || ERequestAdviceStealth  |                       ||
       
   129 ||================================================||
       
   130 
       
   131 
       
   132 TLbsExternalRequestInfo::
       
   133 ||=======================================================================================================||
       
   134 || TRequestSource         | TRequestType        | TNetworkType        | TFormatIndicator                 ||
       
   135 ||=======================================================================================================||
       
   136 || ERequestSourceLocal    | ERequestSingleShot  | ENetworkTypeUnknown | any except                       ||
       
   137 ||                        | ERequestPeriodic    |                     | EFormatUnknown                   ||
       
   138 ||-------------------------------------------------------------------------------------------------------||
       
   139 || ERequestSourceNetwork  | any except          | GSM/WCDMA           | any, except EFormatUnknown,      ||
       
   140 ||                        | ERequestTypeUnknown |                     | EFormatMIN, EFormatMDN and       ||
       
   141 ||                        |                     |                     | EFormatAppUID                    ||
       
   142 ||                        |                     |---------------------|----------------------------------||
       
   143 ||                        |                     | SUPL                | any, except EFormatUnknown       ||
       
   144 ||                        |                     |                     | and EFormatAppUID                ||
       
   145 ||=======================================================================================================||
       
   146 @endcode
       
   147 
       
   148 @see MLbsPrivacyRequestObserver::OnPrivacyResponse
       
   149 
       
   150 @param aRequestId    [Out] A unique identifier of the request. 
       
   151 @param aPrivacy      [In]  Type of a request (e.g. notification)
       
   152 @param aRequestInfo  [In]  Detailed information about the request (e.g. source, client name)
       
   153 
       
   154 @return KErrArgument If the arguments are not valid, or any other system-wide error code
       
   155 
       
   156 @see CLbsAdmin
       
   157 @see KLbsSettingHomeExternalLocate
       
   158 @see KLbsSettingRoamingExternalLocate
       
   159 @see CLbsAdmin::ExternalLocateService
       
   160 @see KLbsSettingPrivacyTimeoutAction
       
   161 @see CLbsAdmin::TPrivacyTimeoutAction
       
   162 @see TLbsExternalRequestInfo::_TRequestSource
       
   163 				
       
   164 */
       
   165 EXPORT_C TInt CLbsPrivacyRequest::NewPrivacyRequest(TLbsPrivacyRequestId& aRequestId, /*out*/
       
   166 												 const TLbsPrivacyRequest& aPrivacy,/*in*/
       
   167 												 const TLbsExternalRequestInfo& aRequestInfo/*in*/)
       
   168 	{
       
   169     LBSLOG(ELogP9, "->A CLbsPrivacyRequest::NewPrivacyRequest(aRequestId, aPrivacy, aRequestInfo) LbsPrivacyProtocolModule\n");
       
   170     TInt err = iImpl->NewPrivacyRequest(aRequestId, aPrivacy, aRequestInfo);
       
   171 
       
   172 #ifdef ENABLE_LBS_DEV_LOGGER
       
   173     LBSLOG2(ELogP8, "\t < TLbsPrivacyRequestId aRequestId = %d\n", aRequestId);
       
   174     LBSLOG(ELogP8, "\t > TLbsPrivacyRequest aPrivacy = \n");
       
   175     LBSLOG2(ELogP8, "\t\t > TLbsRequestAdvice iAdvice = %d\n", aPrivacy.RequestAdvice());
       
   176     LBSLOG2(ELogP8, "\t\t > TLbsRequestAction iAction = %d\n", aPrivacy.RequestAction());
       
   177     TBuf8<256> logInfo8;
       
   178     LBSLOG(ELogP8, "\t > TLbsExternalRequestInfo aRequestInfo = \n");
       
   179     aRequestInfo.GetRequesterId(logInfo8);
       
   180     LBSLOG2(ELogP8, "\t\t > TLbsRequesterId iRequesterId = %S\n", &logInfo8);
       
   181     aRequestInfo.GetClientName(logInfo8);
       
   182     LBSLOG2(ELogP8, "\t\t > TLbsClientName iClientName = %S\n", &logInfo8);
       
   183     aRequestInfo.GetClientExternalId(logInfo8);
       
   184     LBSLOG2(ELogP8, "\t\t > TLbsClientExternalId iClientExternalId = %S\n", &logInfo8);
       
   185     LBSLOG2(ELogP8, "\t\t > TRequestType iRequestType = %d\n", aRequestInfo.RequestType());
       
   186     LBSLOG2(ELogP8, "\t\t > TRequestSource iRequestSource = %d\n", aRequestInfo.RequestSource());
       
   187     LBSLOG2(ELogP8, "\t\t > TNetworkType iNetworkType = %d\n", aRequestInfo.NetworkType());
       
   188     LBSLOG2(ELogP8, "\t\t > TFormatIndicator iRequesterFormat = %d\n", aRequestInfo.RequesterIdFormat());
       
   189     LBSLOG2(ELogP8, "\t\t > TFormatIndicator iClientFormat = %d\n", aRequestInfo.ClientNameFormat());
       
   190     LBSLOG2(ELogP8, "\t\t > TCodingScheme iRequesterCoding = %d\n", aRequestInfo.RequesterIdCodingScheme());
       
   191     LBSLOG2(ELogP8, "\t\t > TCodingScheme iClientCoding = %d\n", aRequestInfo.ClientNameCodingScheme());
       
   192     LBSLOG2(ELogP8, "\t return = %d\n", err);
       
   193 #endif
       
   194     return err;
       
   195 	}
       
   196 
       
   197 /**
       
   198 RepeatPrivacyRequest is an optional variation of the NewPrivacyRequest() method and may be used to 
       
   199 notify a user about a difference between the action that was specified in the privacy response and the action 
       
   200 taken by the network.
       
   201 
       
   202 For example, this situation may happen if the API client process decides to ignore a user's privacy response
       
   203 or not to wait for a user's privacy response before processing a location request from the network.
       
   204 This is not recommended because of the private nature of a user's location information - in most cases it should only
       
   205 be revealed with the permission of the mobile device user. In general it is recommended that the API client process
       
   206 always waits for the privacy response to a NewPrivacyRequest() call before disclosing a user's position.
       
   207 
       
   208 Note that before calling RepeatPrivacyRequest() a client must always have previously called both NewPrivacyRequest() and CompleteRequest().
       
   209 The client must provide a known request id parameter which is a return parameter from NewPrivacyRequest().
       
   210 If the client provides an unknown request id parameter LBS will still process the request and return KErrNone.
       
   211 Request ids that are less than 1, or greater than KTIntMax are not valid, LBS will not process them and KErrArgument will be returned.
       
   212 
       
   213 Default timeout may be controlled through the LBS Admin API.
       
   214 
       
   215 The following table presents valid privacy requests.
       
   216 If a request is found invalid, the method will return with
       
   217 the KErrArgument error code (if the combination of different values is incorrect)
       
   218 or the KErrNotSupported error code (if the functionality is not supported).
       
   219 
       
   220 @code
       
   221 TLbsPrivacyRequest::
       
   222 ||================================================||
       
   223 || TLbsRequestAdvice      | TLbsRequestAction     ||
       
   224 ||================================================||
       
   225 || ERequestAdviceNotify   | any, except           ||
       
   226 ||                        | ERequestActionNotUsed ||
       
   227 ||================================================||
       
   228 
       
   229 TLbsExternalRequestInfo::
       
   230 ||=======================================================================================================||
       
   231 || TRequestSource         | TRequestType        | TNetworkType        | TFormatIndicator                 ||
       
   232 ||=======================================================================================================||
       
   233 || ERequestSourceNetwork  | any except          | GSM/WCDMA           | any, except EFormatUnknown,      ||
       
   234 ||                        | ERequestTypeUnknown |                     | EFormatMIN, EFormatMDN and       ||
       
   235 ||                        |                     |                     | EFormatAppUID                    ||
       
   236 ||                        |                     |---------------------|----------------------------------||
       
   237 ||                        |                     | SUPL                | any, except EFormatUnknown       ||
       
   238 ||                        |                     |                     | and EFormatAppUID                ||
       
   239 ||=======================================================================================================||
       
   240 @endcode
       
   241 
       
   242 @param aRequestId    [In]  The unique identifier of the request (as returned from previous call to NewPrivacyRequest())
       
   243 @param aPrivacy      [In]  Type of a request (e.g. notification)
       
   244 @param aRequestInfo  [In]  Detailed information about the request (e.g. source, client name)
       
   245 
       
   246 @return KErrArgument If the arguments are not valid, or any other system-wide error code
       
   247 				
       
   248 @see CLbsPrivacyRequest::NewPrivacyRequest()
       
   249 @see CLbsAdmin
       
   250 @see KLbsSettingHomeExternalLocate
       
   251 @see KLbsSettingRoamingExternalLocate
       
   252 @see CLbsAdmin::ExternalLocateService
       
   253 @see KLbsSettingPrivacyTimeoutAction
       
   254 @see CLbsAdmin::TPrivacyTimeoutAction
       
   255 @see TLbsExternalRequestInfo::_TRequestSource
       
   256 
       
   257 */
       
   258 EXPORT_C TInt CLbsPrivacyRequest::RepeatPrivacyRequest(const TLbsPrivacyRequestId aRequestId, /*in*/
       
   259 								 const TLbsPrivacyRequest& aPrivacy,/*in*/
       
   260 								 const TLbsExternalRequestInfo& aRequestInfo/*in*/)
       
   261 	{
       
   262     LBSLOG(ELogP9, "->A CLbsPrivacyRequest::RepeatPrivacyRequest(aRequestId, aPrivacy, aRequestInfo) LbsPrivacyProtocolModule\n");
       
   263     TInt err = iImpl->RepeatPrivacyRequest(aRequestId, aPrivacy, aRequestInfo);
       
   264 #ifdef ENABLE_LBS_DEV_LOGGER
       
   265     LBSLOG2(ELogP8, "\t > TLbsPrivacyRequestId aRequestId = %d\n", aRequestId);
       
   266     LBSLOG(ELogP8, "\t > TLbsPrivacyRequest aPrivacy = \n");
       
   267     LBSLOG2(ELogP8, "\t\t > TLbsRequestAdvice iAdvice = %d\n", aPrivacy.RequestAdvice());
       
   268     LBSLOG2(ELogP8, "\t\t > TLbsRequestAction iAction = %d\n", aPrivacy.RequestAction());
       
   269     TBuf8<256> logInfo8;
       
   270     LBSLOG(ELogP8, "\t > TLbsExternalRequestInfo aRequestInfo = \n");
       
   271     aRequestInfo.GetRequesterId(logInfo8);
       
   272     LBSLOG2(ELogP8, "\t\t > TLbsRequesterId iRequesterId = %S\n", &logInfo8);
       
   273     aRequestInfo.GetClientName(logInfo8);
       
   274     LBSLOG2(ELogP8, "\t\t > TLbsClientName iClientName = %S\n", &logInfo8);
       
   275     aRequestInfo.GetClientExternalId(logInfo8);
       
   276     LBSLOG2(ELogP8, "\t\t > TLbsClientExternalId iClientExternalId = %S\n", &logInfo8);
       
   277     LBSLOG2(ELogP8, "\t\t > TRequestType iRequestType = %d\n", aRequestInfo.RequestType());
       
   278     LBSLOG2(ELogP8, "\t\t > TRequestSource iRequestSource = %d\n", aRequestInfo.RequestSource());
       
   279     LBSLOG2(ELogP8, "\t\t > TNetworkType iNetworkType = %d\n", aRequestInfo.NetworkType());
       
   280     LBSLOG2(ELogP8, "\t\t > TFormatIndicator iRequesterFormat = %d\n", aRequestInfo.RequesterIdFormat());
       
   281     LBSLOG2(ELogP8, "\t\t > TFormatIndicator iClientFormat = %d\n", aRequestInfo.ClientNameFormat());
       
   282     LBSLOG2(ELogP8, "\t\t > TCodingScheme iRequesterCoding = %d\n", aRequestInfo.RequesterIdCodingScheme());
       
   283     LBSLOG2(ELogP8, "\t\t > TCodingScheme iClientCoding = %d\n", aRequestInfo.ClientNameCodingScheme());
       
   284     LBSLOG2(ELogP8, "\t return = %d\n", err);
       
   285 #endif
       
   286     return err;
       
   287 	}
       
   288 	
       
   289 /**
       
   290 An application issues a single call to RequestComplete() to complete a request and to
       
   291 return the final result code to the LBS subsystem. 
       
   292 
       
   293 In normal situations, RequestComplete() will be invoked when the overall request has
       
   294 finished. However, it may occur at any stage - for example to cancel an outstanding request.
       
   295 
       
   296 An application MUST invoke RequestComplete() at the end of every privacy verification/notification sequence.
       
   297 
       
   298 @param aRequestId [In] A unique identifier of the request to be completed. This ID is allocated when a 
       
   299                        new request is created.
       
   300 @param aReason    [In] Reason for the completion of the request. 
       
   301                        Indicates the overall success or failure of the request. 
       
   302                        KErrNone if the request has been completed successfully, 
       
   303                        KErrCancel if the application wants to completed the request prematurely 
       
   304                        (before a response has been received) or any other system wide error code.
       
   305 
       
   306 @return A system-wide error code
       
   307                   
       
   308 @capability Location
       
   309 @capability ReadDeviceData
       
   310 
       
   311 @see TLbsExternalRequestInfo::TRequestType
       
   312 
       
   313 */
       
   314 EXPORT_C TInt CLbsPrivacyRequest::CompleteRequest(TLbsPrivacyRequestId aRequestId/*in*/,
       
   315 								  				  TInt aReason/*in*/)
       
   316 	{
       
   317     LBSLOG(ELogP9, "->S CLbsPrivacyRequest::CompleteRequest(aRequestId, aReason) LbsPrivacyProtocolModule\n");
       
   318     LBSLOG2(ELogP8, "\t > TLbsPrivacyRequestId aRequestId = %d\n", aRequestId);
       
   319     LBSLOG2(ELogP8, "\t > TLbsPrivacyRequestId aReason = %d\n", aReason);
       
   320     return iImpl->CompleteRequest(aRequestId, aReason);
       
   321 	}
       
   322