Skip to content
Snippets Groups Projects

Draft: Enable subscription for individual vehicle property

Open Nithin Mysore Nagesh requested to merge wip/nht4kor-subscription into apertis/v2024pre
All threads resolved!
6 files
+ 192
59
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 30
11
@@ -538,25 +538,28 @@ command_monitor_vehicle (RsdVehicleManager *manager,
const gchar * const *args,
GTask *task)
{
g_autoptr (RsdVehicle) vehicle = NULL;
GError *error = NULL;
g_autoptr (GPtrArray/*<owned RsdSubscription>*/) subscriptions = NULL;
g_autoptr (GPtrArray/*<owned RsdSubscription>*/) unsubscriptions = NULL;
if (g_strv_length ((gchar **) args) != 1)
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
_("Missing vehicle ID or object path."));
return;
}
if (g_strv_length((gchar **)args) != 1 && g_strv_length((gchar **)args) != 2)
{
g_task_return_new_error(task, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
_("Missing vehicle ID or object path "
"or attribute name."));
return;
}
vehicle = args_get_vehicle (manager, args, 0, &error);
if (error != NULL)
{
g_task_return_error (task, error);
return;
}
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
_("Vehicle not found"));
return;
}
g_signal_connect (vehicle, "attributes-changed",
(GCallback) attributes_changed_cb, NULL);
@@ -566,7 +569,23 @@ command_monitor_vehicle (RsdVehicleManager *manager,
subscriptions = g_ptr_array_new_with_free_func ((GDestroyNotify) rsd_subscription_free);
unsubscriptions = g_ptr_array_new_with_free_func ((GDestroyNotify) rsd_subscription_free);
g_ptr_array_add (subscriptions, rsd_subscription_new_wildcard ());
if (g_strv_length((gchar **)args) == 2)
{
const gchar *attribute_name = args_get_attribute_name(args, 1, &error);
if (error != NULL)
{
g_task_return_error (task, error);
return;
}
g_ptr_array_add(subscriptions, rsd_subscription_new(attribute_name, NULL, NULL, NULL, 0, G_MAXUINT));
}
else
{
g_ptr_array_add (subscriptions, rsd_subscription_new_wildcard ());
}
rsd_vehicle_update_subscriptions_async (vehicle, subscriptions,
unsubscriptions,
Loading