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 |
// ----------------------------------------------------------
|
|
80 |
// CBTInqNotifier::GetParamsL
|
|
81 |
// Initialize parameters and launch device search.
|
|
82 |
// ----------------------------------------------------------
|
|
83 |
//
|
|
84 |
void CBTInqNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
|
|
85 |
{
|
|
86 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::GetParamsL()"));
|
|
87 |
|
|
88 |
if( !iMessage.IsNull() )
|
|
89 |
{
|
|
90 |
aMessage.Complete(KErrInUse);
|
|
91 |
return;
|
|
92 |
}
|
|
93 |
|
|
94 |
iMessage = aMessage;
|
|
95 |
iReplySlot = aReplySlot;
|
|
96 |
|
|
97 |
TBTDeviceClass cod;
|
|
98 |
TBTDeviceSelectionParamsPckg pckg;
|
|
99 |
pckg.Copy(aBuffer);
|
|
100 |
|
|
101 |
LaunchInquiryL(pckg().DeviceClass());
|
|
102 |
|
|
103 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::GetParamsL() completed "));
|
|
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
|