added parking and environment properties
[profile/ivi/automotive-message-broker.git] / plugins / dbus / dbusinterfacemanager.cpp
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 #include "dbusinterfacemanager.h"
20
21
22 #include <gio/gio.h>
23 #include <string>
24
25 ///properties:
26 #include "accelerationproperty.h"
27 #include "runningstatus.h"
28 #include "custompropertyinterface.h"
29 #include "environmentproperties.h"
30 #include "vehicleinfo.h"
31 #include "maintenance.h"
32 #include "parking.h"
33
34 #define ConstructProperty(property) \
35         new property(iface->re, connection);
36
37 using namespace std;
38
39 static void
40 on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data)
41 {
42         DBusInterfaceManager* iface = static_cast<DBusInterfaceManager*>(user_data);
43
44         AbstractDBusInterface* acceleration = new AccelerationProperty(iface->re, connection);
45         AbstractDBusInterface* vehicleSpeed = new VehicleSpeedProperty(iface->re, connection);
46         AbstractDBusInterface* tirePressure = new TirePressureProperty(iface->re, connection);
47         AbstractDBusInterface* engineSpeed = new EngineSpeedProperty(iface->re, connection);
48         ConstructProperty(VehiclePowerModeProperty);
49         ConstructProperty(TripMeterProperty);
50         ConstructProperty(TransmissionProperty);
51         ConstructProperty(TireTemperatureProperty);
52         ConstructProperty(CruiseControlProperty);
53         ConstructProperty(WheelBrakeProperty);
54         ConstructProperty(LightStatusProperty);
55         ConstructProperty(HornProperty);
56         ConstructProperty(FuelProperty);
57         ConstructProperty(EngineOilProperty);
58         ConstructProperty(ExteriorBrightnessProperty);
59         ConstructProperty(VehicleId);
60         ConstructProperty(TransmissionInfoProperty);
61         ConstructProperty(VehicleTypeProperty);
62         ConstructProperty(FuelInfoProperty);
63         ConstructProperty(SizeProperty);
64         ConstructProperty(DoorsProperty);
65         ConstructProperty(WheelInformationProperty);
66         ConstructProperty(OdometerProperty);
67         ConstructProperty(BatteryProperty);
68         ConstructProperty(SecurityAlertProperty);
69         ConstructProperty(ParkingBrakeProperty);
70         ConstructProperty(ParkingLightProperty);
71         ConstructProperty(HazardLightProperty);
72
73         PropertyList list = VehicleProperty::customProperties();
74
75         for (auto itr = list.begin(); itr != list.end(); itr++)
76         {
77                 VehicleProperty::Property prop = *itr;
78
79                 new CustomPropertyInterface(prop,iface->re,connection);
80         }
81
82
83 }
84
85 static void
86 on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data)
87 {
88
89 }
90
91 static void
92 on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data)
93 {
94
95 }
96
97
98
99 DBusInterfaceManager::DBusInterfaceManager(AbstractRoutingEngine* engine)
100         :re(engine)
101 {
102         g_type_init();
103
104         ownerId = g_bus_own_name(G_BUS_TYPE_SYSTEM,
105                                         DBusServiceName,
106                                         G_BUS_NAME_OWNER_FLAGS_NONE,
107                                         on_bus_acquired,
108                                         on_name_acquired,
109                                         on_name_lost,
110                                         this,
111                                         NULL);
112
113 }
114
115 DBusInterfaceManager::~DBusInterfaceManager()
116 {
117         g_bus_unown_name(ownerId);
118 }
119
120