author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:37:10 +0300 | |
branch | RCL_3 |
changeset 24 | 269724087bed |
parent 23 | 9386f31cc85b |
permissions | -rw-r--r-- |
23 | 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 |
// ---------------------------------------------------------- |
|
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
80 |
// CBTInqNotifier::ProcessStartParamsL |
23 | 81 |
// Initialize parameters and launch device search. |
82 |
// ---------------------------------------------------------- |
|
83 |
// |
|
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
84 |
void CBTInqNotifier::ProcessStartParamsL() |
23 | 85 |
{ |
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
86 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::ProcessStartParamsL()")); |
23 | 87 |
|
88 |
TBTDeviceClass cod; |
|
89 |
TBTDeviceSelectionParamsPckg pckg; |
|
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
90 |
pckg.Copy(*iParamBuffer); |
23 | 91 |
|
92 |
LaunchInquiryL(pckg().DeviceClass()); |
|
93 |
||
24
269724087bed
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
94 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::ProcessStartParamsL() completed ")); |
23 | 95 |
} |
96 |
||
97 |
// ---------------------------------------------------------- |
|
98 |
// CBTInqNotifier::NotifyDeviceSearchCompleted |
|
99 |
// Notified by InquiryUI, return to caller by completing message |
|
100 |
// ---------------------------------------------------------- |
|
101 |
// |
|
102 |
void CBTInqNotifier::NotifyDeviceSearchCompleted(TInt aErr, const TBTDeviceResponseParams& aDevice) |
|
103 |
{ |
|
104 |
FTRACE(FPrint( _L("[BTNOTIF]\t CBTInqNotifier::NotifyDeviceSearchCompleted aErr %d"), aErr )); |
|
105 |
CompleteMessage(TBTDeviceResponseParamsPckg( aDevice ), aErr); |
|
106 |
} |
|
107 |
||
108 |
// ---------------------------------------------------------- |
|
109 |
// CBTInqNotifier::Cancel |
|
110 |
// Release all own resources (member variables) |
|
111 |
// ---------------------------------------------------------- |
|
112 |
// |
|
113 |
void CBTInqNotifier::Cancel() |
|
114 |
{ |
|
115 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::Cancel()")); |
|
116 |
if( iUi ) |
|
117 |
{ |
|
118 |
iUi->Cancel(); |
|
119 |
delete iUi; |
|
120 |
iUi = NULL; |
|
121 |
} |
|
122 |
CBTNotifierBase::Cancel(); |
|
123 |
FLOG(_L("[BTNOTIF]\t CBTInqNotifier::Cancel() completed")); |
|
124 |
} |
|
125 |
||
126 |
// ---------------------------------------------------------- |
|
127 |
// Ensure BT is ON; there are not too many connections; InqUi |
|
128 |
// is launched successfully. |
|
129 |
// ---------------------------------------------------------- |
|
130 |
// |
|
131 |
void CBTInqNotifier::LaunchInquiryL(const TBTDeviceClass& aDesiredDevice) |
|
132 |
{ |
|
133 |
// Turn BT on if it is not yet. |
|
134 |
if ( !CheckAndSetPowerOnL() ) |
|
135 |
{ |
|
136 |
CompleteMessage(KErrGeneral); |
|
137 |
return; |
|
138 |
} |
|
139 |
||
140 |
TInt linkCount; |
|
141 |
User::LeaveIfError(RProperty::Get(KPropertyUidBluetoothCategory, |
|
142 |
KPropertyKeyBluetoothGetPHYCount, linkCount)); |
|
143 |
if ( linkCount > 6 ) //support only piconet |
|
144 |
{ |
|
145 |
iNotifUiUtil->ShowInfoNoteL( R_BT_BUSY_NOTE, ECmdBTnotifUnavailable ); |
|
146 |
User::Leave(KErrInUse); |
|
147 |
} |
|
148 |
||
149 |
// launch Inquiry UI |
|
150 |
||
151 |
iUi = new (ELeave) CBTInqUI( this, iNotifUiUtil, aDesiredDevice); |
|
152 |
||
153 |
||
154 |
iUi->ConstructL(); |
|
155 |
} |
|
156 |
||
157 |
// End of File |