Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Bluetooth / BluetoothHealthProfileHandler.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef __TIZEN_HEALTH_PROFILE_HANDLER_H__
19 #define __TIZEN_HEALTH_PROFILE_HANDLER_H__
20
21 #include <string>
22 #include <map>
23 #include <vector>
24
25 #include <JavaScriptCore/JavaScript.h>
26
27 #include <MultiCallbackUserData.h>
28 #include <PlatformException.h>
29 #include <bluetooth.h>
30
31 #include "BluetoothHealthChannel.h"
32 #include "BluetoothHealthApplication.h"
33 #include "BluetoothDevice.h"
34
35
36 namespace DeviceAPI {
37 namespace Bluetooth {
38
39 class HealthConnReq
40 {
41 public:
42     HealthConnReq(BluetoothDeviceSharedPtr remoteDevice, Common::MultiCallbackUserDataPtr userData) 
43     {
44         mRemoteDevice = remoteDevice;
45         mUserData = userData;
46     };
47     
48     BluetoothDeviceSharedPtr mRemoteDevice;
49     Common::MultiCallbackUserDataPtr mUserData;
50 };
51 typedef HealthConnReq* HealthConnReqPtr;
52
53 class BluetoothHealthProfileHandler : public Common::SecurityAccessor
54 {
55 public:    
56     static BluetoothHealthProfileHandler* getInstance();    
57     void registerSinkApp(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback);
58     void returnRegisteringSinkAppResult(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback);
59 //    void unregisterSinkApplication(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);
60 //    void returnUnregisteringResult(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);
61     void unregisterApp(std::string appID, Common::MultiCallbackUserDataPtr callback);
62     void returnUnregisteringAppResult(std::string appID, Common::MultiCallbackUserDataPtr callback);
63     void connectToSource(JSObjectRef remoteDeviceObj, JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);
64         
65 private:  
66     BluetoothHealthProfileHandler();
67     virtual ~BluetoothHealthProfileHandler();
68
69     static void onConnected(int result, const char *remote_address, const char *app_id,
70             bt_hdp_channel_type_e type, unsigned int channel, void *userData);
71     static void onDisconnected(int result, const char *remote_address, unsigned int channel, void *userData);
72     static void onDataReceivedCB(unsigned int channel, const char *data, unsigned int size, void *userData);
73
74     typedef std::map<BluetoothHealthApplicationSharedPtr, HealthConnReqPtr> HealthConnReqMapT;
75     typedef std::map<unsigned int, BluetoothHealthChannelPtr> HealthConnectedSocketMapT;    // <channel, BluetoothHealthChannelPtr>
76     typedef std::map<std::string, BluetoothHealthApplicationSharedPtr> RegisteredHealthAppMapT; // <app_id, BluetoothHealthApplicationSharedPtr>
77
78         
79     HealthConnReqMapT mHealthConnReqMap;
80     HealthConnectedSocketMapT mConnectedSocketMap;
81     RegisteredHealthAppMapT mRegisteredHealthAppMap;
82 };
83
84 typedef BluetoothHealthProfileHandler* HealthProfileHandlerPtr;
85
86 } // Bluetooth
87 } // DeviceAPI
88
89 #endif // __TIZEN_HEALTH_PROFILE_HANDLER_H__