a7bf19072089bf3473f4758dccdca53de095349a
[profile/ivi/settings-daemon.git] / plugins / connman / technology.hpp
1 /**
2  * @file technology.hpp
3  *
4  * @brief Connman technology request handling.
5  *
6  * @author Ossama Othman @<ossama.othman@@intel.com@>
7  *
8  * @copyright @par
9  * Copyright 2013 Intel Corporation All Rights Reserved.
10  * @par
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation;
14  * version 2.1 of the License.
15  * @par
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  * @par
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  * Boston, MA  02110-1301  USA
25  */
26
27 #ifndef IVI_SETTINGS_CONNMAN_TECHNOLOGY_HPP
28 #define IVI_SETTINGS_CONNMAN_TECHNOLOGY_HPP
29
30 #include "connman.hpp"
31
32 #include <string>
33
34 #include <json-glib/json-glib.h>
35
36
37 namespace ivi
38 {
39   namespace settings
40   {
41     class response_callback;
42     class connman_manager;
43
44     /**
45      * @class technology
46      *
47      * @brief Common technology-based settings functionality.
48      *
49      * This class implements functionality common to all technology-based
50      * settings, such as bluetooth, wifi, date/time, etc.
51      */
52     class technology
53     {
54     public:
55
56       /**
57        * Constructor.
58        *
59        * @param[in] tech The connman technology, e.g. "bluetooth".
60        * @param[in] e    Callback through which events will be sent to
61        *                 clients.
62        */
63       technology(std::string tech,
64                  connman_manager & manager,
65                  event_callback const & e);
66
67       /// Handle requests common to all connman technologies.
68       void handle_request(std::string request,
69                           response_callback response);
70
71     private:
72
73       /// Get technology "Powered" state.
74       void get_powered(JsonReader * reader,
75                        response_callback response);
76
77       /// Set technology "Powered" state.
78       void set_powered(JsonReader * reader,
79                        response_callback response);
80
81       /**
82        * Scan for services that implement the technology, e.g. WiFi
83        * access points.
84        */
85       void scan(JsonReader * reader,
86                 response_callback response);
87
88       /**
89        * Connect to service whose object path is found in the JSON
90        * request.
91        */
92       void connect(JsonReader * reader,
93                    response_callback response);
94
95       /**
96        * Disconnect from service whose object path is found in the
97        * JSON request.
98        */
99       void disconnect(JsonReader * reader,
100                       response_callback response);
101
102       /// Send list of services to caller.
103       void send_services(response_callback response,
104                          GError *& error);
105
106       /**
107        * Get property for this technology.
108        *
109        * @param[in] name     Name of the connman technology property
110        *                     to retrieve.
111        * @param[in] type     The type of property being retrieved.
112        * @param[in] response The response callback through errors will
113        *                     be sent to the caller.
114        *
115        * @returns A @c GVariant containing the retrieved property.
116        */
117       GVariant * get_property(char const * name,
118                               GVariantType const * type,
119                               response_callback response);
120
121     private:
122
123       /// The proxy used to access the connman Technology D-Bus API.
124       connman connman_;
125
126       /// The proxy used to access the connman Manager D-Bus API.
127       connman_manager & manager_;
128
129       /// Technology name, e.g. "bluetooth" or "wifi".
130       std::string const technology_;
131
132       /// Callback through which events will be sent to clients.
133       event_callback event_callback_;
134
135     };
136
137   }
138 }
139
140
141 #endif  /* IVI_SETTINGS_CONNMAN_TECHNOLOGY_HPP */
142
143
144 // Local Variables:
145 // mode:c++
146 // c-basic-offset:2
147 // indent-tabs-mode: nil
148 // End: