1 /* |
|
2 * Copyright (c) 2010 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: The repository of remote devices from BT registry |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef BTDEVICEREPOSITORY_H |
|
19 #define BTDEVICEREPOSITORY_H |
|
20 |
|
21 #include <btdevice.h> |
|
22 #include <btmanclient.h> |
|
23 #include <btservices/btdevextension.h> |
|
24 |
|
25 class CBtDevRepositoryImpl; |
|
26 |
|
27 /** |
|
28 * APIs from this class offer functionalities that are common in mw and app |
|
29 * components of Bluetooth packages. They do not serve as domain APIs. |
|
30 * |
|
31 * Using these from external components is risky, due to possible source |
|
32 * and binary breaks in future. |
|
33 * |
|
34 */ |
|
35 |
|
36 /** |
|
37 * Class MBtDevRepositoryObserver |
|
38 * |
|
39 * Callback class to notify changes in BT registry. |
|
40 */ |
|
41 class MBtDevRepositoryObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Callback to notify that the repository has finished initialization. |
|
47 * Initialization completion means the repository has retieved all |
|
48 * Bluetooth devices from BT registry, and it is subscribing to |
|
49 * registry update events. |
|
50 * |
|
51 */ |
|
52 virtual void RepositoryInitialized() = 0; |
|
53 |
|
54 /** |
|
55 * Callback to notify that a device has been deleted from BT registry. |
|
56 * |
|
57 * |
|
58 * @param aAddr the bd_addr of the deleted device |
|
59 */ |
|
60 virtual void DeletedFromRegistry( const TBTDevAddr& aAddr ) = 0; |
|
61 |
|
62 /** |
|
63 * Callback to notify that the device has been added to BT registry. |
|
64 * |
|
65 * @param aDevice the device that has been added to registry |
|
66 */ |
|
67 virtual void AddedToRegistry( const CBtDevExtension& aDevice ) = 0; |
|
68 |
|
69 /** |
|
70 * Callback to notify that the property of a device in BT registry has been |
|
71 * changed. |
|
72 * |
|
73 * @param aDevice the device that possesses the latest properties. |
|
74 * @param aSimilarity the similarity of the properties comparing to the ones |
|
75 * prior to this change. |
|
76 * Refer CBTDevice::TBTDeviceNameSelector and |
|
77 * TBTNamelessDevice::TBTDeviceSet for the meanings of the bits |
|
78 * in this parameter. |
|
79 */ |
|
80 virtual void ChangedInRegistry( |
|
81 const CBtDevExtension& aDevice, TUint aSimilarity ) = 0; |
|
82 |
|
83 /** |
|
84 * Callback to notify that the status of service (limited to |
|
85 * services maintained in btengsrv scope) connections with |
|
86 * a device has changed. |
|
87 * |
|
88 * @param aDevice the device to which the status change refers |
|
89 * @param aConnected ETrue if at least one service is currently connected. |
|
90 * EFalse if no service is currently connected. |
|
91 */ |
|
92 virtual void ServiceConnectionChanged( |
|
93 const CBtDevExtension& aDevice, TBool aConnected ) = 0; |
|
94 }; |
|
95 |
|
96 /** |
|
97 * Class CBtDevRepository |
|
98 * |
|
99 * This class provides the full access to remote devices in BT registry, |
|
100 * and informs client when the properties of remote devices are changed. |
|
101 * |
|
102 */ |
|
103 NONSHARABLE_CLASS( CBtDevRepository ) : public CBase |
|
104 { |
|
105 public: |
|
106 |
|
107 /** |
|
108 * Two-phase constructor |
|
109 */ |
|
110 IMPORT_C static CBtDevRepository* NewL(); |
|
111 |
|
112 /** |
|
113 * Destructor |
|
114 */ |
|
115 IMPORT_C virtual ~CBtDevRepository(); |
|
116 |
|
117 /** |
|
118 * Add an observer to this reposity for receivng repository update |
|
119 * events. |
|
120 * @param aObserver the observer to be added. |
|
121 */ |
|
122 IMPORT_C void AddObserverL( MBtDevRepositoryObserver* aObserver ); |
|
123 |
|
124 /** |
|
125 * Remove an observer from this repository. |
|
126 * @param aObserver the observer to be removed. |
|
127 */ |
|
128 IMPORT_C void RemoveObserver( MBtDevRepositoryObserver* aObserver ); |
|
129 |
|
130 /** |
|
131 * Tells if this repository has finished the initialization. |
|
132 * Initialization completion means the repository has retieved all |
|
133 * Bluetooth devices from BT registry, and it is subscribing to |
|
134 * registry update events. |
|
135 */ |
|
136 IMPORT_C TBool IsInitialized() const; |
|
137 |
|
138 /** |
|
139 * Get all devices in this repository. |
|
140 * @return the device list |
|
141 */ |
|
142 IMPORT_C const RDevExtensionArray& AllDevices() const; |
|
143 |
|
144 /** |
|
145 * Get a specific device by the given address. |
|
146 * @param aAddr the address of the device to be retrieved |
|
147 * @return the device pointer, NULL if the device is unavailable. |
|
148 */ |
|
149 IMPORT_C const CBtDevExtension* Device( const TBTDevAddr& aAddr ) const; |
|
150 |
|
151 /** |
|
152 * Forces the repository to initialize its data store. |
|
153 * At Initialization completion, corresponding callback will be invoked. |
|
154 * Initialization completion means the repository has retieved all |
|
155 * Bluetooth devices from BT registry, and it is subscribing to |
|
156 * registry update events. |
|
157 * |
|
158 */ |
|
159 IMPORT_C void ReInitialize(); |
|
160 |
|
161 private: |
|
162 |
|
163 /** |
|
164 * C++ default constructor |
|
165 */ |
|
166 CBtDevRepository(); |
|
167 |
|
168 /** |
|
169 * Symbian 2nd-phase constructor |
|
170 */ |
|
171 void ConstructL(); |
|
172 |
|
173 private: |
|
174 |
|
175 CBtDevRepositoryImpl* iImpl; |
|
176 }; |
|
177 |
|
178 #endif /*BTDEVICEREPOSITORY_H*/ |
|