sl@0: /* sl@0: * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: sl@0: using namespace UserPromptService; sl@0: sl@0: EXPORT_C CPromptRequest* CPromptRequest::NewL( sl@0: const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId, sl@0: const TSecureId& aServerSid, const TServiceId& aServiceId, RBuf& aDestination, RBuf8& aOpaqueData, sl@0: TBool aSecurityResult) sl@0: /** sl@0: Creates a new prompt request object.\n sl@0: sl@0: The ownership of the aDestination and aOpaqueData RBufs is transfered sl@0: to this class. The callers RBufs will be empty after this call. sl@0: sl@0: sl@0: @param aClientSid The SID of the client process requesting the service. sl@0: @param aClientVid The VID of the client process requesting the service. sl@0: @param aClientThreadId The id of the thread within the client process requesting the service. sl@0: @param aServerSid The SID of the system server that provides the service. sl@0: @param aServiceId The UID of the requested service. sl@0: @param aDestination The data that the service acts on E.g. A phone number, IAP, domain name sl@0: @param aOpaqueData Opaque data structure populated by the system server. Typically, this sl@0: contains extra information about the requested service. sl@0: @param aSecurityResult ETrue if client passed system server's security check; otherwise, EFalse. sl@0: sl@0: @return A pointer to the new prompt request object. sl@0: */ sl@0: { sl@0: CPromptRequest* self = CPromptRequest::NewLC( sl@0: aClientSid, aClientVid, aClientThreadId, aClientProcessId, sl@0: aServerSid, aServiceId, aDestination, aOpaqueData, aSecurityResult); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: EXPORT_C CPromptRequest* CPromptRequest::NewLC( sl@0: const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId, sl@0: const TSecureId& aServerSid, const TServiceId& aServiceId, RBuf& aDestination, RBuf8& aOpaqueData, sl@0: TBool aSecurityResult) sl@0: /** sl@0: Creates a new prompt request object and places the pointer on the cleanup stack.\n sl@0: sl@0: The ownership of the aDestination and aOpaqueData RBufs is transfered sl@0: to this class. The callers RBufs will be empty after this call. sl@0: sl@0: @param aClientSid The SID of the client process requesting the service. sl@0: @param aClientVid The VID of the client process requesting the service. sl@0: @param aClientThreadId The id of the thread within the client process requesting the service. sl@0: @param aServerSid The SID of the system server that provides the service. sl@0: @param aServiceId The UID of the requested service. sl@0: @param aDestination The data that the service acts on E.g. A phone number, IAP, domain name sl@0: @param aOpaqueData Opaque data structure populated by the system server. Typically, this sl@0: contains extra information about the requested service. sl@0: @param aSecurityResult ETrue if client passed system server's security check; otherwise, EFalse. sl@0: sl@0: @return A pointer to the new prompt request object. sl@0: */ sl@0: { sl@0: CPromptRequest* self = new(ELeave) sl@0: CPromptRequest(aClientSid, aClientVid, aClientThreadId, aClientProcessId, sl@0: aServerSid, aServiceId, aDestination, aOpaqueData, aSecurityResult); sl@0: CleanupStack::PushL(self); sl@0: return self; sl@0: } sl@0: sl@0: CPromptRequest::CPromptRequest( sl@0: const TSecureId& aClientSid, const TVendorId& aClientVid, const TThreadId& aClientThreadId, TProcessId &aClientProcessId, sl@0: const TSecureId& aServerSid, const TServiceId& aServiceId, sl@0: RBuf& aDestination, RBuf8& aOpaqueData, sl@0: TBool aSecurityResult) sl@0: /** sl@0: Constructor sl@0: @param aClientSid The client's SID sl@0: @param aClientVid The client's VID sl@0: @param aClientThreadId The client's thread id. sl@0: @param aServerId The system server's SID. sl@0: @param aServiceId The id of the service. sl@0: @param aDestination The destination. sl@0: @param aOpaqueData The opaque data. sl@0: @param aSecurityResult Whether the client passed the system server's security check sl@0: */ sl@0: : iClientSid(aClientSid), iClientVid(aClientVid), iClientThreadId(aClientThreadId), iClientProcessId(aClientProcessId), sl@0: iServerSid(aServerSid), iServiceId(aServiceId), sl@0: iSecurityResult(aSecurityResult) sl@0: { sl@0: iDestination.Close(); sl@0: iDestination.Swap(aDestination); sl@0: iOpaqueData.Close(); sl@0: iOpaqueData.Swap(aOpaqueData); sl@0: } sl@0: sl@0: EXPORT_C const TSecureId& CPromptRequest::ClientSid() const sl@0: /** sl@0: Gets the SID of the client process requesting the service. sl@0: @return The client's SID. sl@0: */ sl@0: { sl@0: return iClientSid; sl@0: } sl@0: sl@0: EXPORT_C TBool CPromptRequest::IsClientSidProtected() const sl@0: /** sl@0: Determines whether the SID of the client process is in the protected range. sl@0: If the SID is not protected then it is likely that identify of the client process sl@0: cannot reliable verified because it may an unsigned application. If so, a warning sl@0: should be displayed in the prompt dialog. sl@0: sl@0: @return ETrue if the SID is in the protected range; otherwise EFalse is returned. sl@0: */ sl@0: { sl@0: return ! (iClientSid.iId & 0x80000000); sl@0: } sl@0: sl@0: EXPORT_C const TVendorId& CPromptRequest::ClientVid() const sl@0: /** sl@0: Gets the VID of the client process requesting the service. sl@0: @return The client's VID. sl@0: */ sl@0: { sl@0: return iClientVid; sl@0: } sl@0: sl@0: EXPORT_C const TThreadId& CPromptRequest::ClientThreadId() const sl@0: /** sl@0: Gets the TThreadId of the client which issued the request to the system server. sl@0: This thread ID may be invalid if the thread has exited (we do NOT hold an open RThread to keep around). sl@0: @return The client's thread id. sl@0: */ sl@0: { sl@0: return iClientThreadId; sl@0: } sl@0: sl@0: EXPORT_C const TProcessId& CPromptRequest::ClientProcessId() const sl@0: /** sl@0: Gets the TProcessId of the client which issued the request to the system server. sl@0: This process ID may be invalid if the process has exited (we do NOT hold an open RProcess to keep around). sl@0: @return The client's process id. sl@0: */ sl@0: { sl@0: return iClientProcessId; sl@0: } sl@0: sl@0: EXPORT_C const TSecureId& CPromptRequest::ServerSid() const sl@0: /** sl@0: Gets the SID of the system server that provides the service. sl@0: @return The system server's SID. sl@0: */ sl@0: { sl@0: return iServerSid; sl@0: } sl@0: sl@0: EXPORT_C const TServiceId& CPromptRequest::ServiceId() const sl@0: /** sl@0: Gets the UID of the requested service. sl@0: @return The service UID. sl@0: */ sl@0: { sl@0: return iServiceId; sl@0: } sl@0: sl@0: EXPORT_C const TDesC& CPromptRequest::Destination() const sl@0: /** sl@0: Gets the data that the service acts on e.g. the phone number to dial. sl@0: @return A reference to a descriptor containing the destination string. sl@0: */ sl@0: { sl@0: return iDestination; sl@0: } sl@0: sl@0: EXPORT_C const TDesC8& CPromptRequest::OpaqueData() const sl@0: /** sl@0: Gets the opaque data structure provided by the system server. sl@0: @return A reference to a descriptor containing the opaque data. sl@0: */ sl@0: { sl@0: return iOpaqueData; sl@0: } sl@0: sl@0: EXPORT_C TBool CPromptRequest::SecurityResult() const sl@0: /** sl@0: Whether the client processed the system server's security check. sl@0: @return ETrue, if the client process passed the system server's sl@0: security check; otherwise, EFalse is returned. sl@0: */ sl@0: { sl@0: return iSecurityResult; sl@0: } sl@0: sl@0: CPromptRequest::~CPromptRequest() sl@0: /** sl@0: Destructor sl@0: */ sl@0: { sl@0: iDestination.Close(); sl@0: iOpaqueData.Close(); sl@0: }