automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
bluetoothplugin.h
1 /*
2 Copyright (C) 2012 Intel Corporation
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef BT_PLUGIN_H_
20 #define BT_PLUGIN_H_
21 
22 #include <abstractsink.h>
23 #include <serialport.hpp>
24 #include <jsonprotocol.h>
25 
26 #include <string>
27 
28 #include <QDBusAbstractAdaptor>
29 #include <QDBusObjectPath>
30 #include <QVariantMap>
31 #include <QTcpSocket>
32 #include <QDBusUnixFileDescriptor>
33 
35 
36 class BtProfileAdaptor : public QDBusAbstractAdaptor
37 {
38  Q_OBJECT
39  Q_CLASSINFO("D-Bus Interface", "org.bluez.Profile1")
40 
41 public:
42 
44 
45 public Q_SLOTS:
46 
47  void Release();
48 
49  void NewConnection(QDBusObjectPath device, QDBusUnixFileDescriptor fd, QVariantMap fd_properties);
50 
51  void RequestDisconnection(QDBusObjectPath device);
52 
53 private:
54 
56 
57 };
58 
59 class AbstractBluetoothSerialProfile: public QObject
60 {
61  Q_OBJECT
62 
63 public:
64  AbstractBluetoothSerialProfile(QString role = "server");
65 
66  virtual void connect(std::string hwaddy);
67 
68  virtual void release();
69 
70  virtual void newConnection(std::string path, QDBusUnixFileDescriptor fd, QVariantMap props);
71 
72  virtual void requestDisconnection(std::string path);
73 
74 protected:
75  virtual void connected() {}
76  virtual void disconnected() {}
77 
78 private:
79  QString role;
80 };
81 
82 
84 {
85  Q_OBJECT
86 
87 public:
88  BluetoothSinkPlugin(AbstractRoutingEngine* re, map<string, string> config);
89 
90  const string uuid();
91 
92  void supportedChanged(const PropertyList &) {}
93 
95 
96 private:
97  std::vector<amb::AmbRemoteServer::Ptr> clients;
98 
99  // AbstractBluetoothSerialProfile interface
100 public:
101  void newConnection(string path, QDBusUnixFileDescriptor fd, QVariantMap props);
102  void requestDisconnection(string path);
103 };
104 
105 
106 
107 #endif // EXAMPLEPLUGIN_H