disabled irc in bluemonkey
[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 "abstractsource.h"
24 #include "ambpluginimpl.h"
25
26 #include <map>
27
28 #include <QObject>
29 #include <QVariant>
30 #include <QJsonDocument>
31 #include <QDateTime>
32 #include <QScriptValue>
33 #include "uuidhelper.h"
34
35 #include "authenticate.h"
36 #include "agent.h"
37
38 class QScriptEngine;
39
40 class ModuleInterface
41 {
42 public:
43         virtual std::map<std::string, QObject*> objects(std::map<string, string> config) = 0;
44 };
45
46 Q_DECLARE_INTERFACE(ModuleInterface, "org.automotive.bluemonkey.moduleinterface")
47
48 class Property: public QObject, public AbstractSink
49 {
50         Q_OBJECT
51         Q_PROPERTY(QString type READ type)
52         Q_PROPERTY(QVariant value READ value WRITE setValue)
53
54 public:
55         Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, QObject *parent = 0);
56
57         QString type();
58         void setType(QString t);
59
60         virtual PropertyList subscriptions() { return PropertyList(); }
61         virtual void supportedChanged(const PropertyList &)
62         {
63                 DebugOut()<<"Bluemonkey Property Supported Changed"<<endl;
64         }
65
66         virtual void propertyChanged(AbstractPropertyType* value);
67
68         virtual const std::string uuid() { return mUuid; }
69
70         QVariant value();
71         void setValue(QVariant v);
72
73         void getHistory(QDateTime begin, QDateTime end, QScriptValue cbFunction);
74 Q_SIGNALS:
75
76         void changed(QVariant val);
77
78 private:
79         AbstractPropertyType* mValue;
80         const std::string mUuid;
81
82 };
83
84 class BluemonkeySink : public QObject, public AmbPluginImpl
85 {
86 Q_OBJECT
87 public:
88         BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config,  AbstractSource& parent);
89         virtual PropertyList subscriptions();
90         virtual void supportedChanged(const PropertyList & supportedProperties);
91         virtual void propertyChanged(AbstractPropertyType* value);
92         virtual const std::string uuid() const;
93
94         QScriptEngine* engine;
95
96         virtual int supportedOperations();
97
98 private: //source privates
99
100         PropertyList mSupported;
101         std::list<AbstractPropertyType*> propertyValueCache;
102
103
104 public Q_SLOTS:
105
106         QObject* subscribeTo(QString str);
107         QObject* subscribeTo(QString str, QString srcFilter);
108
109         QStringList sourcesForProperty(QString property);
110
111         QStringList supportedProperties();
112
113         bool authenticate(QString pass);
114
115         void loadConfig(QString str);
116
117         void loadModule(QString path);
118
119         void reloadEngine();
120
121         void writeProgram(QString program);
122
123         void log(QString str);
124
125         void getHistory(QStringList properties, QDateTime begin, QDateTime end, QScriptValue cbFunction);
126
127         void setSilentMode(bool m)
128         {
129                 mSilentMode = m;
130         }
131
132         void createCustomProperty(QString name, QScriptValue defaultValue);
133
134 private:
135         QStringList configsToLoad;
136
137         Authenticate* auth;
138         BluemonkeyAgent* agent;
139         bool mSilentMode;
140 };
141
142
143 #endif // BluemonkeySink_H