telephonyserver/etelmultimode/CETEL/mm_lcs.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-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 // This file contains the definition for the ETelMM sub-session
       
    15 // RMobileLocationServices, which allows access to MT-LR and MO-LR Requests supporting LBS Framwork
       
    16 // applications and all their functionality.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22 */
       
    23 
       
    24 // From core API
       
    25 #include <etelext.h>
       
    26 
       
    27 // Multimode header files
       
    28 #include <etelmm.h>
       
    29 #include "mm_hold.h"
       
    30 #include "mmretrieve.h"
       
    31 
       
    32 //
       
    33 //
       
    34 //  RMobileLocationServices
       
    35 //
       
    36 //
       
    37 
       
    38 /**
       
    39 Default empty constructor, and is present only to support virtual
       
    40 function table export.
       
    41 @publishedPartner
       
    42 */
       
    43 EXPORT_C RMobileLocationServices::RMobileLocationServices(): iMmPtrHolder(NULL)
       
    44 	{
       
    45         
       
    46 	}
       
    47 
       
    48 EXPORT_C TInt RMobileLocationServices::Open(RMobilePhone& aPhone)
       
    49 /**
       
    50 This function opens a RMobileLocationServices sub-session from a 
       
    51 RMobilePhone sub-session.The name of the sub-session opened in the 
       
    52 TSY will equal the string defined by the KETelLocationServices LIT definition.
       
    53 
       
    54 The API can be called only by the Location Services Network Gateway Process.
       
    55 
       
    56 In case of hardware the API can be called by providing the SID of the 
       
    57 Location Services Network Gateway Process in ETel.iby file 
       
    58 found at \epoc32\rom\include
       
    59 
       
    60 A patchable constant KLocationServicesNetworkGatewaySid is used for 
       
    61 defining the SID value.
       
    62 In ETel.iby file find the following line
       
    63 patchdata etel.dll@KLocationServicesNetworkGatewaySid <SID>
       
    64 For example:
       
    65 patchdata etel.dll@KLocationServicesNetworkGatewaySid 0x12345678
       
    66 
       
    67 In case of emulator the API can be called by providing the SID of the 
       
    68 default phone application in epoc.ini file found at \epoc32\data
       
    69 In epoc.ini file find the following line
       
    70 etel_KLocationServicesNetworkGatewaySid <SID>
       
    71 For example:
       
    72 etel_KLocationServicesNetworkGatewaySid 0x12345678
       
    73 
       
    74 @param aPhone The RMobilePhone sub-session relative to which this
       
    75               sub-session will open.
       
    76 @return KErrNone if successful, otherwise another of the system-wide error 
       
    77 codes.
       
    78 @capability SID
       
    79 @publishedPartner
       
    80 */
       
    81 	{
       
    82 	RSessionBase* session=&aPhone.SessionHandle();
       
    83 	__ASSERT_ALWAYS(session!=NULL,PanicClient(EEtelPanicNullHandle));
       
    84 	TInt subSessionHandle=aPhone.SubSessionHandle();
       
    85 	__ASSERT_ALWAYS(subSessionHandle!=NULL,PanicClient(EEtelPanicNullHandle));
       
    86 
       
    87 	TRAPD(ret,ConstructL());
       
    88 	if (ret)
       
    89 		{
       
    90 		return ret;
       
    91 		}
       
    92 	TPtrC name(KETelLocationServices);
       
    93 
       
    94 	SetSessionHandle(*session);
       
    95 	TIpcArgs args(&name,TIpcArgs::ENothing,subSessionHandle);
       
    96 
       
    97 	ret = CreateSubSession(*session,EEtelOpenFromSubSessionLcs,args);
       
    98 	if (ret)
       
    99 		{
       
   100 		Destruct();	
       
   101 		}
       
   102 	return ret;
       
   103 	}
       
   104 
       
   105 /**
       
   106 This function member closes a RMobileLocationServices sub-session. 
       
   107 @capability None
       
   108 @publishedPartner
       
   109 */
       
   110 EXPORT_C void RMobileLocationServices::Close()
       
   111 	{
       
   112 	CloseSubSession(EEtelClose);
       
   113 	Destruct();
       
   114 	}
       
   115 
       
   116 /**
       
   117 Default constructor, initialising version number of this data
       
   118 structure.
       
   119 
       
   120 @see TMultimodeEtelV7Api
       
   121 
       
   122 @publishedPartner
       
   123 */
       
   124 EXPORT_C RMobileLocationServices::TNotifyMtlrV7::TNotifyMtlrV7()
       
   125 	{
       
   126 	iExtensionId = KEtelExtMultimodeV7;
       
   127 	}
       
   128 
       
   129 /**
       
   130 Default constructor, initialising version number of this data
       
   131 structure.
       
   132 
       
   133 @see TMultimodeEtelV7Api
       
   134 
       
   135 @publishedPartner
       
   136 */
       
   137 EXPORT_C RMobileLocationServices::TStartMolrV7::TStartMolrV7()
       
   138 	{
       
   139 	iExtensionId = KEtelExtMultimodeV7;
       
   140 	}
       
   141 
       
   142 /**
       
   143 Default constructor, initialising version number of this data
       
   144 structure.
       
   145 
       
   146 @see TMultimodeEtelV7Api
       
   147 
       
   148 @publishedPartner
       
   149 */
       
   150 EXPORT_C RMobileLocationServices::TMolrReturnResultV7::TMolrReturnResultV7()
       
   151 	{
       
   152 	iExtensionId = KEtelExtMultimodeV7;
       
   153 	}
       
   154 
       
   155 /**
       
   156 Default constructor, initialising version number of this data
       
   157 structure.
       
   158 
       
   159 @see TMultimodeEtelV7Api
       
   160 
       
   161 @publishedPartner
       
   162 */
       
   163 EXPORT_C RMobileLocationServices::TMeasurementControlV7::TMeasurementControlV7()
       
   164 	{
       
   165 	iExtensionId = KEtelExtMultimodeV7;
       
   166 	}
       
   167 
       
   168 /**
       
   169 Default constructor, initialising version number of this data
       
   170 structure.
       
   171 
       
   172 @see TMultimodeEtelV7Api
       
   173 
       
   174 @publishedPartner
       
   175 */
       
   176 EXPORT_C RMobileLocationServices::TMeasurementReportV7::TMeasurementReportV7()
       
   177 	{
       
   178 	iExtensionId = KEtelExtMultimodeV7;
       
   179 	}
       
   180 
       
   181 EXPORT_C void RMobileLocationServices::NotifyMtlr(TRequestStatus& aReqStatus,TDes8& aNotifyMtlr) 
       
   182 /** 
       
   183 This member function notifies the client about the incoming MTLR requests 
       
   184 and provides the Client with a class reference,Which contains the details 
       
   185 of the request made by the External client via Network.
       
   186 USE CancelAsyncRequest(EMobileLocationServicesNotifyMtlr) to cancel the 
       
   187 previously placed NotifyMtlr() request.
       
   188 
       
   189 As this API can be used for emergency requests as well as the non-emergency 
       
   190 ones, this method is always treated as an emergency request by ETel/TSY. 
       
   191 Clients that need to handle the emergency LCS requests should pre-allocate 
       
   192 enough memory during system initialisation to reserve it for handling of 
       
   193 the emergency LCS MT-LR. The emergency client also needs to establish itself 
       
   194 as an "Emergency Client" to the Etel server at startup, to ensure that enough 
       
   195 memory is pre-allocated by ETel/TSY and that the handling of this notification 
       
   196 will never fail due to lack of memory. The client may establish itself as an 
       
   197 Emergency Client by calling the RPhone::SetEmergencyClient() API, 
       
   198 specifying EEmergencyLCSRequest as the request type. 
       
   199 
       
   200 @param aReqStatus 	On return, KErrNone if successful.
       
   201 @param aNotifyMtlr On completion,the mobile terminated location request 
       
   202 in TNotifyMtlrV7Pckg.
       
   203 @see TNotifyMtlrV7
       
   204 @capability None
       
   205 @publishedPartner
       
   206 */
       
   207 	{
       
   208 	TReqPriorityType type=EIsaEmergencyRequest;
       
   209 	Get(EMobileLocationServicesNotifyMtlr, aReqStatus, aNotifyMtlr, type);
       
   210 	}
       
   211 
       
   212 EXPORT_C void RMobileLocationServices::SendMtlrResponse(TRequestStatus& aReqStatus,const TMtlrResponse aMtlrResponse)  
       
   213 /** 
       
   214 This member function sends the response given by the client to the MTLR request 
       
   215 made by the network
       
   216 
       
   217 Clients that need to handle the emergency LCS requests should pre-allocate enough 
       
   218 memory during system initialisation to reserve it for responding to the 
       
   219 emergency LCS MT-LR. The emergency client also needs to establish itself 
       
   220 as an "Emergency Client" to the Etel server at startup, to ensure that enough 
       
   221 memory is preallocated by ETel/TSY and that the handling of this request will never 
       
   222 fail due to lack of memory. The client may establish itself as an Emergency Client 
       
   223 by calling the RPhone::SetEmergencyClient() API, specifying EEmergencyLCSRequest 
       
   224 as the request type. 
       
   225 
       
   226 @param aReqStatus 	On return, KErrNone if successful.
       
   227 @param aMtlrResponse It holds the response of the UE after a privacy check has being made 
       
   228 					 on the request made by the External Client.
       
   229 @see RMobileLocationServices::NotifyMtlr()
       
   230 @capability None
       
   231 @publishedPartner
       
   232 */
       
   233 	{
       
   234 	__ASSERT_ALWAYS(iMmPtrHolder!=NULL,PanicClient(EEtelPanicNullHandle));
       
   235 	TPtrC8& ptr = iMmPtrHolder->SetC(CMobileLocationServicesPtrHolder::ESlot1LcsSendMtlrResponse,aMtlrResponse);
       
   236 	TReqPriorityType type=EIsaEmergencyRequest;
       
   237 	Set(EMobileLocationServicesSendMtlrResponse,aReqStatus, ptr, type);
       
   238 	}
       
   239 
       
   240 EXPORT_C void RMobileLocationServices::SendMtlrResponse(TRequestStatus& aReqStatus,const TMtlrError aMtlrError) 
       
   241 /**
       
   242 This function sends a response to the MTLR request made by the Network in 
       
   243 erroneous conditions.
       
   244 
       
   245 Clients that need to handle the emergency LCS requests should pre-allocate enough 
       
   246 memory during system initialisation to reserve it for responding to the emergency 
       
   247 LCS MT-LR. The emergency client also needs to establish itself as an 
       
   248 "Emergency Client" to the Etel server at startup, to ensure that enough memory is 
       
   249 preallocated by ETel/TSY and that the handling of this request will never fail due 
       
   250 to lack of memory. The client may establish itself as an Emergency Client by calling 
       
   251 the RPhone::SetEmergencyClient() API, specifying EEmergencyLCSRequest as the request type. 
       
   252 
       
   253 @param aReqStatus 	On return, KErrNone if successful.
       
   254 @param aMtlrError   It contains the error report generated by the UE,which is sent 
       
   255 back to the Network
       
   256 @see RMobileLocationServices::NotifyMtlr
       
   257 @capability None
       
   258 @publishedPartner
       
   259 */
       
   260 	{
       
   261 	__ASSERT_ALWAYS(iMmPtrHolder!=NULL,PanicClient(EEtelPanicNullHandle));
       
   262 	TPtrC8& ptr1 = iMmPtrHolder->SetC(CMobileLocationServicesPtrHolder::ESlot1LcsSendMtlrError, aMtlrError);
       
   263 	TReqPriorityType type=EIsaEmergencyRequest;
       
   264 	Set(EMobileLocationServicesSendMtlrError,aReqStatus, ptr1, type);
       
   265 	}
       
   266 
       
   267 EXPORT_C void RMobileLocationServices::SendMtlrResponse(TRequestStatus& aReqStatus,const TMtlrReject aMtlrReject)
       
   268 /**
       
   269 This function sends a response to the MTLR request made by the Network,When 
       
   270 UE wants to reject the MTLR request made by an External Client.
       
   271 
       
   272 Clients that need to handle the emergency LCS requests should pre-allocate enough 
       
   273 memory during system initialisation to reserve it for responding to the emergency 
       
   274 LCS MT-LR. The emergency client also needs to establish itself as an 
       
   275 "Emergency Client" to the Etel server at startup, to ensure that enough memory 
       
   276 is preallocated by ETel/TSY and that the handling of this request will never fail due to 
       
   277 lack of memory. The client may establish itself as an Emergency Client by calling 
       
   278 the RPhone::SetEmergencyClient() API, specifying EEmergencyLCSRequest as the request type. 
       
   279 
       
   280 @param aReqStatus 	On return, KErrNone if successful.
       
   281 @param aMtlrReject It contains the details of the Rejection made by the UE.
       
   282 @capability None
       
   283 @publishedPartner
       
   284 */
       
   285 	{
       
   286 	__ASSERT_ALWAYS(iMmPtrHolder!=NULL,PanicClient(EEtelPanicNullHandle));
       
   287 	TPtrC8& ptr1 = iMmPtrHolder->SetC(CMobileLocationServicesPtrHolder::ESlot1LcsMtlrReject, aMtlrReject);
       
   288 	TReqPriorityType type=EIsaEmergencyRequest;
       
   289 	Set(EMobileLocationServicesRejectMtlr,aReqStatus, ptr1, type);
       
   290 	}
       
   291 
       
   292 
       
   293 EXPORT_C void RMobileLocationServices::SendMolr(TRequestStatus& aReqStatus,const TDesC8& aStartMolr,TDes8& aMolrReturnResult) 
       
   294 /** 
       
   295 This member function is used to trigger a Molr request. It carries all the details 
       
   296 of the Molr request the UE wants to send to the network.This request is completed 
       
   297 after the completion of SendMeasurementReport API when the Network sends back an Error 
       
   298 report sent by the remote External client which received the UE location via network
       
   299 or a Location estimate response to the Self-Location Molr request i.e being made by 
       
   300 the UE to the Network.
       
   301 
       
   302 @param aReqStatus 	On return, KErrNone if successful.
       
   303 @param aStartMolr   A TStartMolrV7Pckg holding the details of the 
       
   304 MOLR(Mobile Originating Location Request) made by the UE.
       
   305 @see TStartMolrV7
       
   306 @param aMolrReturnResult On completion,result containing the velocity and location 
       
   307 estimate or errors in TMolrReturnResultV7Pckg.
       
   308 @see TMolrReturnResultV7
       
   309 @capability None						 			    
       
   310 @publishedPartner
       
   311 */
       
   312 	{
       
   313 	SetAndGet(EMobileLocationServicesSendMolr,aReqStatus, aStartMolr,aMolrReturnResult);
       
   314 	}
       
   315 
       
   316 EXPORT_C void RMobileLocationServices::NotifyMeasurementControl(TRequestStatus& aReqStatus,TDes8& aMeasurementControl)
       
   317 /**
       
   318 This function waits for the notification of incoming A-GPS assistance 
       
   319 data from the network in continuance of the MTLR or MOLR.
       
   320 
       
   321 As this API can be used for emergency requests as well as the non-emergency ones, 
       
   322 this method is always treated as an emergency request by ETel/TSY. Clients that need to 
       
   323 handle the emergency LCS requests should preallocate enough memory during 
       
   324 system initialisation to reserve it for handling of the emergency LCS Measrement Control. 
       
   325 The emergency client also needs to establish itself as an "Emergency Client" to the Etel 
       
   326 server at startup, to ensure that enough memory is pre-allocated by ETel/TSY and that the
       
   327 handling of this notification will never fail due to lack of memory. The client may 
       
   328 establish itself as an Emergency Client by calling the RPhone::SetEmergencyClient() API, 
       
   329 specifying EEmergencyLCSRequest as the request type. 
       
   330 
       
   331 @param aReqStatus 	On return, KErrNone if successful, a system wide error code if not.
       
   332 @param aMeasurementControl	On completion, A TMeasurementControlV7Pckg holding 
       
   333 the A-GPS assistance data.
       
   334 @see TMeasurementControlV7
       
   335 @see RMobileLocationServices::NotifyMltr()
       
   336 @see RMobileLocationServices::SendMolr()
       
   337 
       
   338 @capability None
       
   339 @publishedPartner
       
   340 */
       
   341 	{
       
   342 	TReqPriorityType type=EIsaEmergencyRequest;
       
   343 	Get(EMobileLocationServicesNotifyMeasurementControl,aReqStatus,aMeasurementControl,type);
       
   344 	}
       
   345 
       
   346 EXPORT_C void RMobileLocationServices::SendMeasurementReport(TRequestStatus& aReqStatus,const TDesC8& aMeasurementReport)
       
   347 /**
       
   348 This function sends the location information, computed by the UE, 
       
   349 to the network. Location information is computed using the A-GPS assistance
       
   350 data received from the network through the NotifyMeasurementControl API.
       
   351 
       
   352 Clients that need to handle the emergency LCS requests should preallocate enough memory 
       
   353 during system initialisation to reserve it for handling of the emergency LCS MT-LR 
       
   354 procedure. The emergency client also needs to establish itself as an "Emergency Client" to the 
       
   355 Etel server at startup, to ensure that enough memory is preallocated by ETel/TSY 
       
   356 and that the handling of this request will never fail due to lack of memory. 
       
   357 The client may establish itself as an Emergency Client by calling the 
       
   358 RPhone::SetEmergencyClient() API, specifying EEmergencyLCSRequest as the request type. 
       
   359 
       
   360 @param aReqStatus 	On return, KErrNone if successful, a system wide error code if not.
       
   361 @param aMeasurementReport	A TMeasurementReportV7Pckg holding the location information 
       
   362 report of the UE to be sent to the network.
       
   363 @see TMeasurementReportV7
       
   364 @see RMobileLocationServices::NotifyMeasurementControl()
       
   365 
       
   366 @capability None
       
   367 @publishedPartner
       
   368 */
       
   369 	{
       
   370 	TReqPriorityType type=EIsaEmergencyRequest;
       
   371 	Set(EMobileLocationServicesSendMeasurementReport,aReqStatus,aMeasurementReport,type);
       
   372 	}
       
   373 
       
   374 EXPORT_C void RMobileLocationServices::SendMeasurementReport(TRequestStatus& aReqStatus,const TMeasurementControlFailure aMeasurementControlFailure)
       
   375 /**
       
   376 This function sends the measurement control failure cause, encountered while processing
       
   377 the A-GPS assistance data to compute location information, to the network. 
       
   378 
       
   379 Clients that need to handle the emergency LCS requests should preallocate enough memory 
       
   380 during system initialisation to reserve it for handling of the emergency LCS MT-LR procedure. 
       
   381 The emergency client also needs to establish itself as an "Emergency Client" to the 
       
   382 Etel server at startup, to ensure that enough memory is preallocated by ETel/TSY and 
       
   383 that the handling of this request will never fail due to lack of memory. The client 
       
   384 may establish itself as an Emergency Client by calling the 
       
   385 RPhone::SetEmergencyClient() API, specifying EEmergencyLCSRequest as the request type. 
       
   386 
       
   387 @param aReqStatus 	On return, KErrNone if successful, a system wide error code if not.
       
   388 @param aMeasurementControlFailure	Holds the measurement control failure cause to be sent
       
   389 									to the network.
       
   390 @see RMobileLocationServices::NotifyMeasurementControl()
       
   391 
       
   392 @capability None
       
   393 @publishedPartner
       
   394 */
       
   395 	{
       
   396 	__ASSERT_ALWAYS(iMmPtrHolder!=NULL,PanicClient(EEtelPanicNullHandle));
       
   397 	TPtrC8& ptr = iMmPtrHolder->SetC(CMobileLocationServicesPtrHolder::ESlot1LcsSendMeasurementControlFailure, aMeasurementControlFailure);
       
   398 	TReqPriorityType type=EIsaEmergencyRequest;
       
   399 	Set(EMobileLocationServicesSendMeasurementControlFailure,aReqStatus,ptr,type);
       
   400 	}
       
   401 
       
   402 /**
       
   403 Delayed construction of heap stored data members.
       
   404 
       
   405 @leave KErrNoMemory Heap memory allocation failure for
       
   406  CMobileLocationServicesPtrHolder object.
       
   407 */
       
   408 void RMobileLocationServices::ConstructL()
       
   409 	{
       
   410 	__ASSERT_ALWAYS(iMmPtrHolder==NULL,PanicClient(EEtelPanicHandleNotClosed));
       
   411 	iMmPtrHolder = CMobileLocationServicesPtrHolder::NewL(CMobileLocationServicesPtrHolder::EMaxNumberLocationServicesPtrSlots,
       
   412 	CMobileLocationServicesPtrHolder::EMaxNumberLocationServicesPtrCSlots);
       
   413 	}
       
   414 
       
   415 
       
   416 /**
       
   417 Called internally when RMobileLocationServices instance is no longer
       
   418 required, to ensure clean up of data members from memory.
       
   419 */
       
   420 void RMobileLocationServices::Destruct()
       
   421 	{
       
   422 	delete iMmPtrHolder;
       
   423 	iMmPtrHolder = NULL;
       
   424 	ResetSessionHandle();
       
   425 	}
       
   426 
       
   427 
       
   428 EXPORT_C TInt RMobileLocationServices::SetLcsDomain(const TDomain aDomain) 
       
   429 /*
       
   430 This function set the domain into either circuit switched or packet switched.
       
   431 This is the domain that applies to MO-LR,if the domain is not specified the default domain
       
   432 will be Packed switched
       
   433 
       
   434 @param TDomain	Holds the domain information of the phone to be sent
       
   435 				to the network.
       
   436 
       
   437 @capability NetworkServices
       
   438 @capability Location
       
   439 @publishedPartner
       
   440 */
       
   441 	{
       
   442 	TPckg<TDomain> ptr(aDomain);
       
   443 	return Set(EMobileLocationServicesSetLcsDomain,ptr);
       
   444 	}
       
   445 
       
   446 /*
       
   447 This function requests a notification when a signal is received from the network 
       
   448 to reset the UE Positioning Information held by the handset.
       
   449 @see 3GPP TS 34.109 V7.2.0 Section 6.10
       
   450 @see TUePosTechnology
       
   451 
       
   452 @param aReqStatus 	On return, KErrNone if successful, a system wide error code if not.
       
   453 @param aUePosTechnology	The positioning data to reset (e.g., A-GPS). See 3GPP TS 34.109 V7.2.0 Section 6.10 
       
   454 @capability None
       
   455 @publishedPartner
       
   456 @released
       
   457 */
       
   458 EXPORT_C void RMobileLocationServices::NotifyResetUePositioningInformation(TRequestStatus& aReqStatus, TUePosTechnology& aUePosTechnology) const
       
   459 	{
       
   460 	__ASSERT_ALWAYS(iMmPtrHolder!=NULL,PanicClient(EEtelPanicNullHandle));
       
   461 	TPtr8& ptr1 = iMmPtrHolder->Set(CMobileLocationServicesPtrHolder::ESlot1LcsNotifyUeResetPositioningInformation, aUePosTechnology);
       
   462 
       
   463 	Get(EMobileLocationServicesNotifyResetUePositioningInformation, aReqStatus, ptr1);
       
   464 	}