|
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 |
|
26 /* |
|
27 Static constructor |
|
28 */ |
|
29 CLbsPrivacyNotifierImpl* CLbsPrivacyNotifierImpl::NewL(TPrivacyDialogType aDlg) |
|
30 { |
|
31 CLbsPrivacyNotifierImpl* self=new (ELeave) CLbsPrivacyNotifierImpl; |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(aDlg); |
|
34 CleanupStack::Pop(); |
|
35 return self; |
|
36 } |
|
37 |
|
38 /* |
|
39 Static constructor |
|
40 */ |
|
41 CLbsPrivacyNotifierImpl* CLbsPrivacyNotifierImpl::NewL(TPrivacyDialogType aDlg, TTimeIntervalMicroSeconds32 aTimeout) |
|
42 { |
|
43 CLbsPrivacyNotifierImpl* self=new (ELeave) CLbsPrivacyNotifierImpl; |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(aDlg, aTimeout); |
|
46 CleanupStack::Pop(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 /* |
|
52 1st phase Constructor |
|
53 */ |
|
54 CLbsPrivacyNotifierImpl::CLbsPrivacyNotifierImpl() |
|
55 : CActive(EPriorityNormal) |
|
56 { |
|
57 iConnected = EFalse; |
|
58 } |
|
59 |
|
60 /* |
|
61 2nd phase Constructor |
|
62 */ |
|
63 void CLbsPrivacyNotifierImpl::ConstructL(TPrivacyDialogType aDlg) |
|
64 { |
|
65 User::LeaveIfError(iNotifier.Connect()); |
|
66 CActiveScheduler::Add(this); |
|
67 iConnected=ETrue; |
|
68 iDialog = aDlg; |
|
69 } |
|
70 |
|
71 /* |
|
72 2nd phase Constructor |
|
73 */ |
|
74 void CLbsPrivacyNotifierImpl::ConstructL(TPrivacyDialogType aDlg, TTimeIntervalMicroSeconds32 aTimeout) |
|
75 { |
|
76 // for example: User::LeaveIfError(iNotifier.Connect()); |
|
77 User::LeaveIfError(iNotifier.Connect()); |
|
78 CActiveScheduler::Add(this); |
|
79 iConnected=ETrue; |
|
80 iDialog = aDlg; |
|
81 iTimeout = aTimeout; |
|
82 } |
|
83 |
|
84 /* |
|
85 Destructor |
|
86 */ |
|
87 CLbsPrivacyNotifierImpl::~CLbsPrivacyNotifierImpl() |
|
88 { |
|
89 iNotifier.Close(); |
|
90 } |
|
91 |
|
92 /* |
|
93 Dummy implementation |
|
94 */ |
|
95 void CLbsPrivacyNotifierImpl::DoCancel() |
|
96 { |
|
97 //iNotifier.CancelNotifier(/*uid*/); |
|
98 } |
|
99 |
|
100 |
|
101 /* |
|
102 Connect to RNotifier |
|
103 */ |
|
104 TInt CLbsPrivacyNotifierImpl::Connect() |
|
105 { |
|
106 TInt err=KErrNone; |
|
107 TRAP(err, User::LeaveIfError(iNotifier.Connect());) |
|
108 return(err); |
|
109 } |
|
110 |
|
111 /* |
|
112 Process the user's reply |
|
113 */ |
|
114 void CLbsPrivacyNotifierImpl::RunL() |
|
115 { |
|
116 // Here when user dismisses dialogue or when timeout |
|
117 |
|
118 if (iObserver) |
|
119 { |
|
120 iObserver->OnNotificationDialogResponse(0, (iButtonVal ? EResponseRejected : EResponseAccepted)); |
|
121 } |
|
122 |
|
123 CActiveScheduler::Stop(); |
|
124 } |
|
125 |
|
126 |
|
127 /* |
|
128 Observer |
|
129 */ |
|
130 void CLbsPrivacyNotifierImpl::SetObserver(MLbsPrivacyNotifierObserver* aObserver) |
|
131 { |
|
132 iObserver = aObserver; |
|
133 } |
|
134 |
|
135 |
|
136 void CLbsPrivacyNotifierImpl::DisplayL(TInt& /*aErr*/, const TLbsExternalRequestInfo& /*aRequestInfo*/) |
|
137 { |
|
138 switch (iDialog) |
|
139 { |
|
140 case EPrivacyDialogNotification: |
|
141 { |
|
142 // present user a dialogue notify that position will be divulged |
|
143 // implemented,for example, using RNotifier::Notify async request |
|
144 _LIT(KText1, "Test Dialog"); |
|
145 _LIT(KText2, "This is a Test Message."); |
|
146 _LIT(KBut1, "Y"); |
|
147 _LIT(KBut2, ""); |
|
148 iNotifier.Notify(KText1, KText2, KBut1, KBut2, iButtonVal, CActive::iStatus); |
|
149 break; |
|
150 } |
|
151 case EPrivacyDialogVerification: |
|
152 { |
|
153 // present user a dialogue asking Verify - Yes or No? |
|
154 // implemented,for example, using RNotifier::Notify async request |
|
155 _LIT(KText1, "Test Dialog"); |
|
156 _LIT(KText2, "This is a Test"); |
|
157 _LIT(KBut1, "Y"); |
|
158 _LIT(KBut2, "N"); |
|
159 iNotifier.Notify(KText1, KText2, KBut1, KBut2, iButtonVal, CActive::iStatus); |
|
160 break; |
|
161 } |
|
162 default: |
|
163 { |
|
164 User::Leave(KErrArgument); |
|
165 break; |
|
166 } |
|
167 } |
|
168 |
|
169 SetActive(); |
|
170 |
|
171 // if this is a timed dialog, start a timer |
|
172 /*if (iTimeout > TTimeIntervalMicroSeconds32(0)) |
|
173 { |
|
174 User::LeaveIfError(iTimer.CreateLocal()); |
|
175 |
|
176 iStatus = KRequestPending; |
|
177 iTimer.After(iStatus, iTimeout); |
|
178 |
|
179 SetActive(); |
|
180 }*/ |
|
181 |
|
182 } |