36
|
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 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <e32std.h>
|
|
20 |
#include <bt_sock.h>
|
|
21 |
#include <btdevice.h>
|
|
22 |
#include "BTGPSDeviceManager.h"
|
|
23 |
#include "BTGPSDeviceSelector.h"
|
|
24 |
#include "BTGPSConnectManagerExt.h"
|
|
25 |
#include "BTGPSHandlerFactory.h"
|
|
26 |
#include "BTGPSLogging.h"
|
|
27 |
#include "btgpsdevicelistmanager.h"
|
|
28 |
|
|
29 |
// EXTERNAL DATA STRUCTURES
|
|
30 |
|
|
31 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
32 |
|
|
33 |
// CONSTANTS
|
|
34 |
|
|
35 |
// MACROS
|
|
36 |
|
|
37 |
// LOCAL CONSTANTS AND MACROS
|
|
38 |
//SerialPort
|
|
39 |
const TInt KSerialPortServiceClass = 0x1101;
|
|
40 |
|
|
41 |
// MODULE DATA STRUCTURES
|
|
42 |
|
|
43 |
// LOCAL FUNCTION PROTOTYPES
|
|
44 |
|
|
45 |
// FORWARD DECLARATIONS
|
|
46 |
|
|
47 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
48 |
|
|
49 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
50 |
|
|
51 |
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
// CBTGPSDeviceSelector::NewL
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
CBTGPSDeviceSelector* CBTGPSDeviceSelector::NewL(
|
|
56 |
MBTGPSConnectManagerExt& aManagerExt)
|
|
57 |
{
|
|
58 |
CBTGPSDeviceSelector* self = new (ELeave) CBTGPSDeviceSelector(
|
|
59 |
aManagerExt);
|
|
60 |
CleanupStack::PushL(self);
|
|
61 |
self->ConstructL();
|
|
62 |
CleanupStack::Pop();
|
|
63 |
return self;
|
|
64 |
}
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
// CBTGPSDeviceSelector::~CBTGPSDeviceSelector
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
CBTGPSDeviceSelector::~CBTGPSDeviceSelector()
|
|
70 |
{
|
|
71 |
Cancel();
|
|
72 |
iNotifier.Close();
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// CBTGPSDeviceSelector::ConstructL
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
void CBTGPSDeviceSelector::ConstructL()
|
|
80 |
{
|
|
81 |
TRACESTRING("CBTGPSDeviceSelector::ConstructL start...")
|
|
82 |
//If the device is still coneected, then disconnect it
|
|
83 |
iManagerExt.DisconnectBtDevice();
|
|
84 |
|
|
85 |
//Set device type as unkown
|
|
86 |
iManagerExt.DeviceManager().SetBTDeviceType(EBTDeviceTypeUnknown);
|
|
87 |
|
|
88 |
//Connect to notifier server
|
|
89 |
User::LeaveIfError(iNotifier.Connect());
|
|
90 |
|
|
91 |
//Request a device selection
|
|
92 |
TBTDeviceSelectionParamsPckg selectionFilter;
|
|
93 |
|
|
94 |
//Set UUID
|
|
95 |
selectionFilter().SetUUID(KSerialPortServiceClass);
|
|
96 |
|
|
97 |
//Apply No filter: To support BC - Some older Nokia (or other) devices do not specify
|
|
98 |
//one or other Class causing filter out if filtered for Positioning
|
|
99 |
//Major Service Class, Major Device Class and Minor device class unspecified
|
|
100 |
TBTDeviceClass selectionDeviceClass(
|
|
101 |
0,
|
|
102 |
0,
|
|
103 |
0);
|
|
104 |
|
|
105 |
//Set device class
|
|
106 |
selectionFilter().SetDeviceClass(selectionDeviceClass);
|
|
107 |
|
|
108 |
iNotifier.StartNotifierAndGetResponse(
|
|
109 |
iStatus,
|
|
110 |
KDeviceSelectionNotifierUid,
|
|
111 |
selectionFilter,
|
|
112 |
iBTSelectionResponse
|
|
113 |
);
|
|
114 |
|
|
115 |
SetActive();
|
|
116 |
TRACESTRING("CBTGPSDeviceSelector::ConstructL end")
|
|
117 |
}
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// CBTGPSDeviceSelector::CBTGPSDeviceSelector
|
|
121 |
// C++ default constructor can NOT contain any code, that
|
|
122 |
// might leave.
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
CBTGPSDeviceSelector::CBTGPSDeviceSelector(
|
|
125 |
MBTGPSConnectManagerExt& aManagerExt)
|
|
126 |
: CActive(EPriorityStandard),
|
|
127 |
iManagerExt(aManagerExt)
|
|
128 |
{
|
|
129 |
CActiveScheduler::Add(this);
|
|
130 |
}
|
|
131 |
|
|
132 |
// -----------------------------------------------------------------------------
|
|
133 |
// CBTGPSDeviceSelector::RunL
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
void CBTGPSDeviceSelector::RunL()
|
|
136 |
{
|
|
137 |
TRACESTRING2("CBTGPSDeviceSelector::RunL start...%d", iStatus.Int())
|
|
138 |
//Selection Complete
|
|
139 |
if(iStatus == KErrNone)
|
|
140 |
{
|
|
141 |
iManagerExt.DeviceManager().BtDevice().SetDeviceAddress(
|
|
142 |
iBTSelectionResponse().BDAddr());
|
|
143 |
iManagerExt.DeviceManager().BtDevice().SetDeviceClass(
|
|
144 |
iBTSelectionResponse().DeviceClass());
|
|
145 |
#ifdef SYMBIAN_LOCATION_BTGPSCONFIG
|
|
146 |
//Add this device to the list
|
|
147 |
iManagerExt.DeviceListManager().AddDeviceInfo(iBTSelectionResponse().BDAddr());
|
|
148 |
#endif
|
|
149 |
|
|
150 |
//Name field is ignored
|
|
151 |
}
|
|
152 |
iManagerExt.HandlerComplete(EDeviceSelector,iStatus.Int());
|
|
153 |
TRACESTRING("CBTGPSDeviceSelector::RunL end")
|
|
154 |
}
|
|
155 |
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
// CBTGPSDeviceSelector::DoCancel
|
|
158 |
// -----------------------------------------------------------------------------
|
|
159 |
void CBTGPSDeviceSelector::DoCancel()
|
|
160 |
{
|
|
161 |
iNotifier.CancelNotifier(KDeviceSelectionNotifierUid);
|
|
162 |
}
|
|
163 |
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
// CBTGPSDeviceSelector::RunError
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
TInt CBTGPSDeviceSelector::RunError(TInt /*aError*/)
|
|
168 |
{
|
|
169 |
//Leaves in RunL. Should not happen
|
|
170 |
return KErrNone;
|
|
171 |
}
|
|
172 |
|
|
173 |
// End of File
|
|
174 |
|
|
175 |
|
|
176 |
|