|
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 // Class implementation of CPrivacyRequestResponseHandler |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "lbsprivacyclient.h" |
|
21 #include "lbsprivacyrequestresponsehandler.h" |
|
22 #include "lbsprivacyserverreturncodes.h" |
|
23 #include "lbsdevloggermacros.h" |
|
24 |
|
25 //----------------------------------------------------------------------------- |
|
26 // CPrivacyRequestResponseHandler |
|
27 //----------------------------------------------------------------------------- |
|
28 |
|
29 // Default constructor |
|
30 CPrivacyRequestResponseHandler::CPrivacyRequestResponseHandler(CLbsPrivacyRequestImpl& aParent, |
|
31 RPrivacyServer& aPrivacyServer, |
|
32 MLbsPrivacyRequestObserver& aObserver) |
|
33 |
|
34 : CActive(EPriorityStandard),iParent(aParent), iPrivacyServer(aPrivacyServer), iObserver(aObserver) |
|
35 { |
|
36 CActiveScheduler::Add(this); |
|
37 } |
|
38 |
|
39 // Static constructor |
|
40 CPrivacyRequestResponseHandler* CPrivacyRequestResponseHandler::NewLC(CLbsPrivacyRequestImpl& aParent, |
|
41 RPrivacyServer& aPrivacyServer, |
|
42 MLbsPrivacyRequestObserver& aObserver) |
|
43 { |
|
44 CPrivacyRequestResponseHandler* self = new (ELeave) CPrivacyRequestResponseHandler(aParent, aPrivacyServer, |
|
45 aObserver); |
|
46 CleanupStack::PushL(self); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // Destructor |
|
51 CPrivacyRequestResponseHandler::~CPrivacyRequestResponseHandler() |
|
52 { |
|
53 Cancel(); |
|
54 } |
|
55 |
|
56 void CPrivacyRequestResponseHandler::NewPrivacyRequest(TUint32& aRequestId, const TLbsExternalRequestInfo& aRequestInfo, |
|
57 const TLbsNetPosRequestPrivacy& aPrivacyRequest) |
|
58 { |
|
59 iPrivacyServer.NewPrivacyRequest(aRequestId, aRequestInfo, aPrivacyRequest, iStatus); |
|
60 SetActive(); |
|
61 iRequestId = aRequestId; |
|
62 } |
|
63 |
|
64 void CPrivacyRequestResponseHandler::RepeatPrivacyRequest(TUint32 aRequestId, const TLbsExternalRequestInfo& aRequestInfo, |
|
65 const TLbsNetPosRequestPrivacy& aPrivacyRequest) |
|
66 { |
|
67 iRequestId = aRequestId; |
|
68 iPrivacyServer.RepeatPrivacyRequest(aRequestId, aRequestInfo, aPrivacyRequest, iStatus); |
|
69 SetActive(); |
|
70 } |
|
71 |
|
72 /** |
|
73 * From CActive. Called when verification is complete |
|
74 */ |
|
75 void CPrivacyRequestResponseHandler::RunL() |
|
76 { |
|
77 TInt response = iStatus.Int(); |
|
78 LBSLOG(ELogP9, "<-A CPrivacyRequestResponseHandler::RunL() LbsPrivacyProtocolModule\n"); |
|
79 LBSLOG2(ELogP8, "\t > TInt iStatus = %d\n", response); |
|
80 |
|
81 if(response == KRequestCancelledByClient) |
|
82 { // If client cancelled then we don't need to call back |
|
83 return; |
|
84 } |
|
85 |
|
86 if(response >= 0) |
|
87 { |
|
88 iObserver.OnPrivacyResponse(iRequestId, response, KErrNone); |
|
89 } |
|
90 else |
|
91 { |
|
92 iObserver.OnPrivacyResponse(iRequestId, |
|
93 MLbsPrivacyRequestObserver::EPrivacyResponseRejected, response); |
|
94 } |
|
95 iParent.RemoveHandler(this); |
|
96 delete this; |
|
97 } |
|
98 |
|
99 /** |
|
100 * From CActive. Cancels the outstanding verification request. |
|
101 */ |
|
102 void CPrivacyRequestResponseHandler::DoCancel() |
|
103 { |
|
104 // Cancel this request in the server |
|
105 iPrivacyServer.CompleteRequest(iRequestId, KErrCancel); |
|
106 } |
|
107 |
|
108 /** |
|
109 * From CActive. Calls this function if RunL() function leaves |
|
110 */ |
|
111 TInt CPrivacyRequestResponseHandler::RunError(TInt aError) |
|
112 { |
|
113 return aError; |
|
114 } |