author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:43:49 +0300 | |
branch | RCL_3 |
changeset 72 | 4b59561a31c0 |
parent 61 | 269724087bed |
permissions | -rw-r--r-- |
56 | 1 |
/* |
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Declares Bluetooth device inquiry notifier class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <eikenv.h> // Eikon environment |
|
21 |
||
22 |
#include "btninqnotifier.h" // Own class definition |
|
23 |
#include "btNotifDebug.h" // Debugging macros |
|
24 |
#include <StringLoader.h> // Localisation stringloader |
|
25 |
#include <BTNotif.rsg> // Own resources |
|
26 |
||
27 |
||
28 |
// ================= MEMBER FUNCTIONS ======================= |
|
29 |
||
30 |
// ---------------------------------------------------------- |
|
31 |
// CBTInqNotifier::NewL |
|
32 |
// Two-phased constructor. |
|
33 |
// ---------------------------------------------------------- |
|
34 |
// |
|
35 |
CBTInqNotifier* CBTInqNotifier::NewL() |
|
36 |
{ |
|
37 |
CBTInqNotifier* self=new (ELeave) CBTInqNotifier(); |
|
38 |
CleanupStack::PushL(self); |
|
39 |
self->ConstructL(); |
|
40 |
CleanupStack::Pop(); |
|
41 |
return self; |
|
42 |
} |
|
43 |
||
44 |
// ---------------------------------------------------------- |
|
45 |
// CBTInqNotifier::CBTInqNotifier |
|
46 |
// C++ default constructor can NOT contain any code, that |
|
47 |
// might leave. |
|
48 |
// ---------------------------------------------------------- |
|
49 |
// |
|
50 |
CBTInqNotifier::CBTInqNotifier() |
|
51 |
{ |
|
52 |
} |
|
53 |
||
54 |
// ---------------------------------------------------------- |
|
55 |
// Destructor |
|
56 |
// ---------------------------------------------------------- |
|
57 |
// |
|
58 |
CBTInqNotifier::~CBTInqNotifier() |
|
59 |
{ |
|
60 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::~CBTInqNotifier()")); |
|
61 |
delete iUi; |
|
62 |
iUi = NULL; |
|
63 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::~CBTInqNotifier() completed")); |
|
64 |
} |
|
65 |
||
66 |
// ---------------------------------------------------------- |
|
67 |
// CBTInqNotifier::RegisterL |
|
68 |
// ---------------------------------------------------------- |
|
69 |
// |
|
70 |
CBTInqNotifier::TNotifierInfo CBTInqNotifier::RegisterL() |
|
71 |
{ |
|
72 |
||
73 |
iInfo.iUid=KDeviceSelectionNotifierUid; |
|
74 |
iInfo.iChannel=KBTInquiryChannel; |
|
75 |
iInfo.iPriority=ENotifierPriorityVHigh; // User input level |
|
76 |
return iInfo; |
|
77 |
} |
|
78 |
||
79 |
// ---------------------------------------------------------- |
|
72
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
80 |
// CBTInqNotifier::GetParamsL |
56 | 81 |
// Initialize parameters and launch device search. |
82 |
// ---------------------------------------------------------- |
|
83 |
// |
|
72
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
84 |
void CBTInqNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) |
56 | 85 |
{ |
72
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
86 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::GetParamsL()")); |
56 | 87 |
|
72
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
88 |
if( !iMessage.IsNull() ) |
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
89 |
{ |
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
90 |
aMessage.Complete(KErrInUse); |
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
91 |
return; |
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
92 |
} |
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
93 |
|
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
94 |
iMessage = aMessage; |
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
95 |
iReplySlot = aReplySlot; |
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
96 |
|
56 | 97 |
TBTDeviceClass cod; |
98 |
TBTDeviceSelectionParamsPckg pckg; |
|
72
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
99 |
pckg.Copy(aBuffer); |
56 | 100 |
|
101 |
LaunchInquiryL(pckg().DeviceClass()); |
|
102 |
||
72
4b59561a31c0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
61
diff
changeset
|
103 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::GetParamsL() completed ")); |
56 | 104 |
} |
105 |
||
106 |
// ---------------------------------------------------------- |
|
107 |
// CBTInqNotifier::NotifyDeviceSearchCompleted |
|
108 |
// Notified by InquiryUI, return to caller by completing message |
|
109 |
// ---------------------------------------------------------- |
|
110 |
// |
|
111 |
void CBTInqNotifier::NotifyDeviceSearchCompleted(TInt aErr, const TBTDeviceResponseParams& aDevice) |
|
112 |
{ |
|
113 |
FTRACE(FPrint( _L("[BTNOTIF]\t CBTInqNotifier::NotifyDeviceSearchCompleted aErr %d"), aErr )); |
|
114 |
CompleteMessage(TBTDeviceResponseParamsPckg( aDevice ), aErr); |
|
115 |
} |
|
116 |
||
117 |
// ---------------------------------------------------------- |
|
118 |
// CBTInqNotifier::Cancel |
|
119 |
// Release all own resources (member variables) |
|
120 |
// ---------------------------------------------------------- |
|
121 |
// |
|
122 |
void CBTInqNotifier::Cancel() |
|
123 |
{ |
|
124 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::Cancel()")); |
|
125 |
if( iUi ) |
|
126 |
{ |
|
127 |
iUi->Cancel(); |
|
128 |
delete iUi; |
|
129 |
iUi = NULL; |
|
130 |
} |
|
131 |
CBTNotifierBase::Cancel(); |
|
132 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::Cancel() completed")); |
|
133 |
} |
|
134 |
||
135 |
// ---------------------------------------------------------- |
|
136 |
// Ensure BT is ON; there are not too many connections; InqUi |
|
137 |
// is launched successfully. |
|
138 |
// ---------------------------------------------------------- |
|
139 |
// |
|
140 |
void CBTInqNotifier::LaunchInquiryL(const TBTDeviceClass& aDesiredDevice) |
|
141 |
{ |
|
142 |
// Turn BT on if it is not yet. |
|
143 |
if ( !CheckAndSetPowerOnL() ) |
|
144 |
{ |
|
145 |
CompleteMessage(KErrGeneral); |
|
146 |
return; |
|
147 |
} |
|
148 |
||
149 |
TInt linkCount; |
|
150 |
User::LeaveIfError(RProperty::Get(KPropertyUidBluetoothCategory, |
|
151 |
KPropertyKeyBluetoothGetPHYCount, linkCount)); |
|
152 |
if ( linkCount > 6 ) //support only piconet |
|
153 |
{ |
|
154 |
iNotifUiUtil->ShowInfoNoteL( R_BT_BUSY_NOTE, ECmdBTnotifUnavailable ); |
|
155 |
User::Leave(KErrInUse); |
|
156 |
} |
|
157 |
||
158 |
// launch Inquiry UI |
|
159 |
||
160 |
iUi = new (ELeave) CBTInqUI( this, iNotifUiUtil, aDesiredDevice); |
|
161 |
||
162 |
||
163 |
iUi->ConstructL(); |
|
164 |
} |
|
165 |
||
166 |
// End of File |