* method.
*/
// Subscribe to PropertyChanged signal for all technologies.
- constexpr gint const timeout = 5000; // milliseconds
GError * error = nullptr;
unique_ptr<GVariant> const dictionary(
- g_dbus_proxy_call_sync(connman_.proxy(),
- "GetTechnologies",
- nullptr, // No parameters
- G_DBUS_CALL_FLAGS_NONE,
- timeout,
- nullptr, // Not cancellable
- &error));
+ call_method("GetTechnologies",
+ nullptr, // No parameters,
+ error));
+
unique_ptr<GError> safe_error(error);
if (dictionary != nullptr) {
+ agent_.object_path());
}
+ error = nullptr;
unique_ptr<GVariant> const ret(
call_method("RegisterAgent",
g_variant_new("(o)",
ivi::settings::connman_manager::get_services(
response_callback & response) const
{
- call_method("GetServices", response);
+ constexpr char name[] = "GetServices";
+ GError * error = nullptr;
+
+ unique_ptr<GVariant> ret(call_method(name,
+ nullptr, // No parameters
+ error));
+
+ unique_ptr<GError> safe_error(error);
+
+ handle_return_value(name, ret.get(), error, response);
}
void
ivi::settings::connman_manager::get_technologies(
response_callback & response) const
{
- call_method("GetTechnologies", response);
+ constexpr char name[] = "GetTechnologies";
+ GError * error = nullptr;
+
+ unique_ptr<GVariant> ret(call_method(name,
+ nullptr, // No parameters
+ error));
+
+ unique_ptr<GError> safe_error(error);
+
+ handle_return_value(name, ret.get(), error, response);
}
-void
+GVariant *
ivi::settings::connman_manager::call_method(
char const * name,
- response_callback & response) const
+ GVariant * parameters,
+ GError *& error) const
{
constexpr gint const timeout = 5000; // milliseconds
- GError * error = nullptr;
- unique_ptr<GVariant> ret(
+ return
g_dbus_proxy_call_sync(connman_.proxy(),
name,
- nullptr, // No parameters
+ parameters,
G_DBUS_CALL_FLAGS_NONE,
timeout,
nullptr, // Not cancellable
- &error));
-
- unique_ptr<GError> safe_error(error);
+ &error);
+}
+void
+ivi::settings::connman_manager::handle_return_value(
+ char const * name,
+ GVariant * ret,
+ GError * error,
+ response_callback & response) const
+{
if (ret != nullptr) {
response.send_response(
- [&ret](JsonBuilder * builder)
+ [ret](JsonBuilder * builder)
{
/**
* @todo Can @c json_gvariant_serialize() ever return a nullptr?
*/
JsonNode * const value =
- json_gvariant_serialize(ret.get());
+ json_gvariant_serialize(ret);
json_builder_set_member_name(builder, "value");
json_builder_add_value(builder, value);
void get_technologies(response_callback & response) const;
/**
- * Call the method @a name on the connman Manager object. This
- * method is meant to be used for @c GetServices and
- * @c GetTechnologies requests.
+ * Call the method @a name on the connman Manager object.
+ *
+ * @param[in] name The connman Manager object method
+ * name.
+ * @param[in] parameters Method parameters.
+ * @param[inout] error Pointer to error object containing
+ * failure related information. Caller
+ * must deallocate if it is not null.
*
- * @param[in] name The connman Manager object method
- * name.
- * @param[inout] response Callback used to inform the caller of
- * the results.
+ * @return Variant containing result of underlying Connman
+ * Manager D-Bus call. The caller must release the
+ * returned @c GVariant.
*/
- void call_method(char const * name,
- response_callback & response) const;
+ GVariant * call_method(char const * name,
+ GVariant * parameters,
+ GError *& error) const;
+
+
+ /**
+ * Send response or error to client that initiated the request.
+ */
+ void handle_return_value(char const * name,
+ GVariant * ret,
+ GError * error,
+ response_callback & response) const;
typedef void (*ivi_signal_callback)(GDBusConnection * connection,
char const * sender_name,
private:
- /**
- * Call the method @a name on the connman Manager object.
- *
- * @param[in] name The connman Manager object method
- * name.
- * @param[in] parameters Method parameters.
- * @param[inout] error Pointer to error object containing
- * failure related information. Caller
- * must deallocate if it is not null.
- */
- GVariant * call_method(char const * name,
- GVariant * parameters,
- GError *& error) const;
-
- private:
-
/// The proxy used to access the connman Manager D-Bus API.
connman connman_;