refactored setProperty: made it async with callback
[profile/ivi/automotive-message-broker.git] / plugins / websocketsourceplugin / websocketsource.h
1
2 /*
3 Copyright (C) 2012 Intel Corporation
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20
21 #ifndef WEBSOCKETSOURCE_H
22 #define WEBSOCKETSOURCE_H
23
24
25
26 #include <abstractsource.h>
27 #include <string>
28 #include <libwebsockets.h>
29
30
31 class WebSocketSource : public AbstractSource
32 {
33
34 public:
35         WebSocketSource(AbstractRoutingEngine* re, map<string, string> config);
36     string uuid();
37         void getPropertyAsync(AsyncPropertyReply *reply);
38         void getRangePropertyAsync(AsyncRangePropertyReply *reply);
39         AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
40         void subscribeToPropertyChanges(VehicleProperty::Property property);
41         void unsubscribeToPropertyChanges(VehicleProperty::Property property);
42         PropertyList supported();
43         libwebsocket *clientsocket;
44         PropertyList queuedRequests;
45         bool clientConnected;
46         void checkSubscriptions();
47         PropertyList activeRequests;
48         PropertyList removeRequests;
49         void setSupported(PropertyList list);
50         void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {}
51         void supportedChanged(PropertyList) {}
52         void setConfiguration(map<string, string> config);
53
54 private:
55         PropertyList m_supportedProperties;
56
57 };
58
59 #endif // WEBSOCKETSOURCE_H