|
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 // |
|
15 |
|
16 #include "pbapauthpasswordgetter.h" |
|
17 #include "pbapserver.h" |
|
18 #include "btaccesshostlog.h" |
|
19 |
|
20 |
|
21 /*static*/ CPbapAuthPasswordGetter* CPbapAuthPasswordGetter::NewL(CPbapServer& aParent) |
|
22 { |
|
23 LOG_STATIC_FUNC |
|
24 CPbapAuthPasswordGetter* self = new (ELeave) CPbapAuthPasswordGetter(aParent); |
|
25 CleanupStack::PushL(self); |
|
26 self->ConstructL(); |
|
27 CleanupStack::Pop(self); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CPbapAuthPasswordGetter::CPbapAuthPasswordGetter(CPbapServer& aParent) |
|
32 : CActive(CActive::EPriorityUserInput), iParent(aParent) |
|
33 { |
|
34 LOG_FUNC |
|
35 CActiveScheduler::Add(this); |
|
36 } |
|
37 |
|
38 CPbapAuthPasswordGetter::~CPbapAuthPasswordGetter() |
|
39 { |
|
40 LOG_FUNC |
|
41 Cancel(); |
|
42 iNotifier.Close(); |
|
43 } |
|
44 |
|
45 void CPbapAuthPasswordGetter::ConstructL() |
|
46 { |
|
47 LOG_FUNC |
|
48 User::LeaveIfError(iNotifier.Connect()); |
|
49 } |
|
50 |
|
51 void CPbapAuthPasswordGetter::GetPassword(const TDesC& aRealm, const TBTDevAddr& aAddress) |
|
52 { |
|
53 LOG_FUNC |
|
54 |
|
55 // create parameter package |
|
56 TPbapAuthNotifierParamsPckg paramsPckg; |
|
57 paramsPckg().SetRealm(aRealm); |
|
58 paramsPckg().SetRemoteAddr(aAddress); |
|
59 |
|
60 // clear password buffer |
|
61 iResultsPckg().ResetPassword(); |
|
62 |
|
63 // launch password notifier |
|
64 iNotifier.StartNotifierAndGetResponse(iStatus, KPbapAuthNotifierUid, paramsPckg, iResultsPckg); |
|
65 SetActive(); |
|
66 } |
|
67 |
|
68 void CPbapAuthPasswordGetter::RunL() |
|
69 { |
|
70 LOG_FUNC |
|
71 iNotifier.CancelNotifier(KPbapAuthNotifierUid); |
|
72 if (iResultsPckg().IsValidPassword()) |
|
73 { |
|
74 iParent.HandlePasswordRetrieved(iStatus.Int(), iResultsPckg().Password()); |
|
75 } |
|
76 else |
|
77 { |
|
78 iParent.HandlePasswordRetrieved(iStatus.Int(), KNullDesC); |
|
79 } |
|
80 } |
|
81 |
|
82 void CPbapAuthPasswordGetter::DoCancel() |
|
83 { |
|
84 LOG_FUNC |
|
85 iNotifier.CancelNotifier(KPbapAuthNotifierUid); |
|
86 |
|
87 // inform parent that password will not be retrieved |
|
88 iParent.HandlePasswordRetrieved(KErrCancel, KNullDesC); |
|
89 } |