added overload for subscribe that includes a zone filter. it is unimplemented in...
[profile/ivi/automotive-message-broker.git] / plugins / bluemonkey / bluemonkey.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
20 #ifndef BluemonkeySink_H
21 #define BluemonkeySink_H
22
23 #include "abstractsink.h"
24 #include <QObject>
25 #include <QVariant>
26 #include <QJsonDocument>
27 #include "uuidhelper.h"
28
29 #include "authenticate.h"
30
31 class IrcCommunication;
32 class QScriptEngine;
33
34 class Property: public QObject, public AbstractSink
35 {
36         Q_OBJECT
37         Q_PROPERTY(QString type READ type)
38         Q_PROPERTY(QVariant value READ value WRITE setValue)
39
40 public:
41         Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, QObject *parent = 0);
42
43         QString type();
44         void setType(QString t);
45
46         virtual PropertyList subscriptions() { return PropertyList(); }
47         virtual void supportedChanged(PropertyList ){   }
48
49         virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
50
51         virtual std::string uuid() { return amb::createUuid(); }
52
53         QVariant value();
54         void setValue(QVariant v);
55
56 Q_SIGNALS:
57
58         void changed(QVariant val);
59
60 private:
61         AbstractPropertyType* mValue;
62
63 };
64
65 class BluemonkeySink : public QObject, public AbstractSink
66 {
67 Q_OBJECT
68 public:
69         BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config);
70         virtual PropertyList subscriptions();
71         virtual void supportedChanged(PropertyList supportedProperties);
72         virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
73         virtual std::string uuid();
74
75 public Q_SLOTS:
76
77         QObject* subscribeTo(QString str);
78         QObject* subscribeTo(QString str, QString srcFilter);
79
80         QStringList sourcesForProperty(QString property);
81
82         bool authenticate(QString pass);
83
84         void loadConfig(QString str);
85
86         void reloadEngine();
87
88         void writeProgram(QString program);
89
90         void log(QString str);
91
92 private Q_SLOTS: /// methods:
93
94         void loadConfigPriv();
95
96 private:
97         QStringList configsToLoad;
98         IrcCommunication* irc;
99         QScriptEngine* engine;
100         Authenticate* auth;
101 };
102
103 class BluemonkeySinkManager: public AbstractSinkManager
104 {
105 public:
106         BluemonkeySinkManager(AbstractRoutingEngine* engine, map<string, string> config)
107         :AbstractSinkManager(engine, config)
108         {
109                 new BluemonkeySink(routingEngine, config);
110         }
111 };
112
113 #endif // BluemonkeySink_H