Skip to content

Commit

Permalink
event edited
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Oct 22, 2024
1 parent 53f37ca commit 875adb2
Show file tree
Hide file tree
Showing 2 changed files with 265 additions and 92 deletions.
65 changes: 64 additions & 1 deletion GnomeProxy/NetworkManagerGnomeEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,54 @@ namespace WPEFramework
g_variant_unref(value);
}

static void primaryConnectionChanged(GDBusProxy *proxy,
GVariant *changed_properties,
GStrv invalidated_properties,
gpointer user_data)
{
GVariant *primary_connection_variant = g_variant_lookup_value(changed_properties, "PrimaryConnection", NULL);
if (primary_connection_variant != NULL)
{
// Process the new value of the 'PrimaryConnection' property
const gchar *primary_connection;
primary_connection = g_variant_get_string(primary_connection_variant, NULL);
NMLOG_INFO("PrimaryConnection changed: %s", primary_connection);
}
}

static void deviceSignalCB(GDBusProxy *proxy,
gchar *sender_name,
gchar *signal_name,
GVariant *parameters,
gpointer user_data) {

if (proxy == NULL) {
NMLOG_FATAL("cb doesn't have proxy ");
return;
}

if (g_strcmp0(signal_name, "DeviceAdded") == 0 || g_strcmp0(signal_name, "DeviceRemoved") == 0)
{
if (g_variant_is_of_type(parameters, G_VARIANT_TYPE_TUPLE)) {
GVariant *first_element = g_variant_get_child_value(parameters, 0);

if (g_variant_is_of_type(first_element, G_VARIANT_TYPE_OBJECT_PATH)) {
const gchar *object_path = g_variant_get_string(first_element, NULL);
NMLOG_DEBUG("Extracted object path: %s", object_path);
} else {
NMLOG_DEBUG("First element is not of type object path, actual type: %s", g_variant_get_type_string(first_element));
}
g_variant_unref(first_element);
}

if (g_strcmp0(signal_name, "DeviceAdded") == 0) {
NMLOG_INFO("Device Added: %s", object_path);
}
else if(g_strcmp0(signal_name, "DeviceRemoved")) {
NMLOG_INFO("Device Removed: %s", object_path);
}
}
}

void* NetworkManagerEvents::networkMangerEventMonitor(void *arg)
{
Expand All @@ -126,7 +174,22 @@ namespace WPEFramework
return nullptr;
}

g_signal_connect(proxy, "notify::DeviceAdded", G_CALLBACK(on_signal), NULL);
g_signal_connect(nmProxy, "g-signal", G_CALLBACK(deviceSignalCB), NULL);
g_signal_connect(nmPropertyproxy, "g-properties-changed", G_CALLBACK(primaryConnectionChanged), NULL);

GVariant *devices = g_dbus_proxy_get_cached_property(nmProxy, "Devices");
if (devices != NULL) {
GVariantIter iter;
const gchar *devicePath;

g_variant_iter_init(&iter, devices);
while (g_variant_iter_loop(&iter, "&o", &devicePath)) {
GDBusProxy *deviceProxy;
monitorDevice(devicePath, deviceProxy);
}
g_variant_unref(devices);
}

//g_signal_connect(_NetworkManagerEvents->eventDbus.getConnection(), "signal", G_CALLBACK(on_property_changed), NULL);

// g_bus_add_match(_NetworkManagerEvents->eventDbus.getConnection(),
Expand Down
Loading

0 comments on commit 875adb2

Please sign in to comment.