|
1 // Copyright (c) 2005-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 CLbsPrivacyNotifierImpl |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #include "e32debug.h" |
|
24 #include "lbsprivacynotifierimpl.h" |
|
25 #include "lbsdevloggermacros.h" |
|
26 |
|
27 /* |
|
28 Static constructor |
|
29 */ |
|
30 CLbsPrivacyNotifierImpl* CLbsPrivacyNotifierImpl::NewL(TPrivacyDialogType aDlg) |
|
31 { |
|
32 CLbsPrivacyNotifierImpl* self=new (ELeave) CLbsPrivacyNotifierImpl; |
|
33 CleanupStack::PushL(self); |
|
34 self->ConstructL(aDlg); |
|
35 CleanupStack::Pop(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 /* |
|
40 Static constructor |
|
41 */ |
|
42 CLbsPrivacyNotifierImpl* CLbsPrivacyNotifierImpl::NewL(TPrivacyDialogType aDlg, TTimeIntervalMicroSeconds32 aTimeout) |
|
43 { |
|
44 CLbsPrivacyNotifierImpl* self=new (ELeave) CLbsPrivacyNotifierImpl; |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(aDlg, aTimeout); |
|
47 CleanupStack::Pop(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 /* |
|
53 1st phase Constructor |
|
54 */ |
|
55 CLbsPrivacyNotifierImpl::CLbsPrivacyNotifierImpl() |
|
56 : CActive(EPriorityNormal), |
|
57 iNotifierUid(TUid::Uid(0)) |
|
58 { |
|
59 CActiveScheduler::Add(this); |
|
60 } |
|
61 |
|
62 /* |
|
63 2nd phase Constructor |
|
64 */ |
|
65 void CLbsPrivacyNotifierImpl::ConstructL(TPrivacyDialogType aDlg) |
|
66 { |
|
67 // |
|
68 // Timeout for notifier display. |
|
69 // NB Arbitrarily cchosen and not actually used; left here in case |
|
70 // a specific timeout for an unacknowleged notifier is required. |
|
71 // |
|
72 const TTimeIntervalMicroSeconds32 KNotifierDisplayTimeout = 10000000; |
|
73 |
|
74 ConstructL(aDlg, KNotifierDisplayTimeout); |
|
75 } |
|
76 |
|
77 /* |
|
78 2nd phase Constructor |
|
79 */ |
|
80 void CLbsPrivacyNotifierImpl::ConstructL(TPrivacyDialogType aDlg, TTimeIntervalMicroSeconds32 aTimeout) |
|
81 { |
|
82 User::LeaveIfError(Connect()); |
|
83 iDialog = aDlg; |
|
84 iTimeout = aTimeout; |
|
85 } |
|
86 |
|
87 /* |
|
88 Destructor |
|
89 */ |
|
90 CLbsPrivacyNotifierImpl::~CLbsPrivacyNotifierImpl() |
|
91 { |
|
92 Cancel(); |
|
93 iNotifier.Close(); |
|
94 } |
|
95 |
|
96 /* |
|
97 Dummy implementation |
|
98 */ |
|
99 void CLbsPrivacyNotifierImpl::DoCancel() |
|
100 { |
|
101 if (iNotifierUid != TUid::Uid(0)) |
|
102 { |
|
103 iNotifier.CancelNotifier(iNotifierUid); |
|
104 iNotifierUid = TUid::Uid(0); |
|
105 } |
|
106 } |
|
107 |
|
108 |
|
109 /* |
|
110 Connect to RNotifier |
|
111 */ |
|
112 TInt CLbsPrivacyNotifierImpl::Connect() |
|
113 { |
|
114 TInt err = iNotifier.Connect(); |
|
115 return(err); |
|
116 } |
|
117 |
|
118 /* |
|
119 Process the user's reply |
|
120 */ |
|
121 void CLbsPrivacyNotifierImpl::RunL() |
|
122 { |
|
123 // Cancel the existing RNotifier if there is one. |
|
124 if (iNotifierUid != TUid::Uid(0)) |
|
125 { |
|
126 iNotifier.CancelNotifier(iNotifierUid); |
|
127 iNotifierUid = TUid::Uid(0); |
|
128 } |
|
129 |
|
130 // Here when user dismisses dialogue or there is an error |
|
131 TInt err = iStatus.Int(); |
|
132 if(err == KErrNone) |
|
133 { |
|
134 TLbsPrivacyNotifierResponse response; |
|
135 iPrivacyResponsePckg().GetResponseType(response); |
|
136 if (iObserver) |
|
137 { |
|
138 LBSLOG(ELogP9, "<-S MLbsPrivacyNotifierObserver::OnNotificationDialogResponse() lbsnetworkrequesthandler.exe\n"); |
|
139 LBSLOG(ELogP9, " > TInt aErr = KErrNone\n"); |
|
140 LBSLOG2(ELogP9, " > TLbsPrivacyNotifierResponse aResponse = %d\n", response); |
|
141 iObserver->OnNotificationDialogResponse(0, response); |
|
142 } |
|
143 } |
|
144 else |
|
145 { |
|
146 LBSLOG(ELogP9, "<-S MLbsPrivacyNotifierObserver::OnNotificationDialogResponse() lbsnetworkrequesthandler.exe\n"); |
|
147 LBSLOG2(ELogP9, " > TInt aErr = %d\n", err); |
|
148 LBSLOG2(ELogP9, " > TLbsPrivacyNotifierResponse aResponse = %d\n", EResponseUnknown); |
|
149 iObserver->OnNotificationDialogResponse(err, EResponseUnknown); |
|
150 } |
|
151 } |
|
152 |
|
153 |
|
154 /* |
|
155 Observer |
|
156 */ |
|
157 void CLbsPrivacyNotifierImpl::SetObserver(MLbsPrivacyNotifierObserver* aObserver) |
|
158 { |
|
159 iObserver = aObserver; |
|
160 } |
|
161 |
|
162 |
|
163 void CLbsPrivacyNotifierImpl::DisplayL(TInt& /*aErr*/, const TLbsExternalRequestInfo& aRequestInfo) |
|
164 { |
|
165 TLbsPrivacyNotifierParams params; |
|
166 params.SetRequesterInfo(aRequestInfo); |
|
167 TLbsPrivacyNotifierParamsPckg pckg(params); |
|
168 |
|
169 // Cancel the existing RNotifier if there is one. |
|
170 if (iNotifierUid != TUid::Uid(0)) |
|
171 { |
|
172 iNotifier.CancelNotifier(iNotifierUid); |
|
173 iNotifierUid = TUid::Uid(0); |
|
174 } |
|
175 |
|
176 // Start the new notifier/verifier |
|
177 switch (iDialog) |
|
178 { |
|
179 case EPrivacyDialogNotification: |
|
180 { |
|
181 #if defined(NRH_UNIT_TEST) |
|
182 // This is a special unit-test notifier implementation UID. |
|
183 // It means that we can have the unit-test notifier and |
|
184 // the integration test notifier in the same ROM. |
|
185 iNotifierUid = TUid::Uid(0x10283742); |
|
186 #else |
|
187 iNotifierUid = KLbsExtLocationRequestNotifyUid; |
|
188 #endif |
|
189 |
|
190 // Start the notify RNotifier |
|
191 TInt err = iNotifier.StartNotifier(iNotifierUid, pckg); |
|
192 User::LeaveIfError(err); |
|
193 |
|
194 // Finish (cancel) the RNotifier |
|
195 iNotifier.CancelNotifier(iNotifierUid); |
|
196 iNotifierUid = TUid::Uid(0); |
|
197 break; |
|
198 } |
|
199 case EPrivacyDialogVerification: |
|
200 { |
|
201 #if defined(NRH_UNIT_TEST) |
|
202 // This is a special unit-test verifier implementation UID. |
|
203 // It means that we can have the unit-test verifier and |
|
204 // the integration test verifier in the same ROM. |
|
205 iNotifierUid = TUid::Uid(0x10283743); |
|
206 #else |
|
207 iNotifierUid = KLbsExtLocationRequestVerifyUid; |
|
208 #endif |
|
209 // Start the verify RNotifier |
|
210 iNotifier.StartNotifierAndGetResponse(iStatus, |
|
211 iNotifierUid, |
|
212 pckg, |
|
213 iPrivacyResponsePckg); |
|
214 |
|
215 SetActive(); |
|
216 break; |
|
217 } |
|
218 default: |
|
219 { |
|
220 User::Leave(KErrArgument); |
|
221 break; |
|
222 } |
|
223 } |
|
224 } |
|
225 |