mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-30 15:52:11 +02:00
src: format using clang-format
This commit is contained in:
@@ -12,11 +12,11 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static void state_changed_cb(MMModem *modem,
|
||||
MMModemState old,
|
||||
MMModemState new,
|
||||
MMModemStateChangeReason reason,
|
||||
struct EG25Manager *manager)
|
||||
static void state_changed_cb(MMModem *modem,
|
||||
MMModemState old,
|
||||
MMModemState new,
|
||||
MMModemStateChangeReason reason,
|
||||
struct EG25Manager *manager)
|
||||
{
|
||||
if (manager->modem_state >= EG25_STATE_CONFIGURED)
|
||||
modem_update_state(manager, new);
|
||||
@@ -24,13 +24,13 @@ static void state_changed_cb(MMModem *modem,
|
||||
|
||||
static void add_modem(struct EG25Manager *manager, GDBusObject *object)
|
||||
{
|
||||
const gchar *path;
|
||||
const gchar *path;
|
||||
MmGdbusModem *gdbus_modem;
|
||||
|
||||
path = g_dbus_object_get_object_path(object);
|
||||
g_message("Adding new modem `%s'", path);
|
||||
|
||||
g_assert(MM_IS_OBJECT (object));
|
||||
g_assert(MM_IS_OBJECT(object));
|
||||
manager->mm_modem = mm_object_get_modem(MM_OBJECT(object));
|
||||
g_assert_nonnull(manager->mm_modem);
|
||||
|
||||
@@ -70,15 +70,16 @@ static void add_modem_location(struct EG25Manager *manager, GDBusObject *object)
|
||||
g_assert_nonnull(manager->mm_location);
|
||||
}
|
||||
|
||||
static void interface_added_cb (struct EG25Manager *manager,
|
||||
GDBusObject *object,
|
||||
GDBusInterface *interface)
|
||||
static void interface_added_cb(struct EG25Manager *manager,
|
||||
GDBusObject *object,
|
||||
GDBusInterface *interface)
|
||||
{
|
||||
GDBusInterfaceInfo *info;
|
||||
|
||||
info = g_dbus_interface_get_info(interface);
|
||||
g_message("ModemManager interface `%s' found on object `%s'",
|
||||
info->name, g_dbus_object_get_object_path(object));
|
||||
info->name,
|
||||
g_dbus_object_get_object_path(object));
|
||||
|
||||
if (g_strcmp0(info->name, MM_DBUS_INTERFACE_MODEM) == 0)
|
||||
add_modem(manager, object);
|
||||
@@ -87,12 +88,11 @@ static void interface_added_cb (struct EG25Manager *manager,
|
||||
add_modem_location(manager, object);
|
||||
}
|
||||
|
||||
|
||||
static void interface_removed_cb(struct EG25Manager *manager,
|
||||
GDBusObject *object,
|
||||
GDBusInterface *interface)
|
||||
{
|
||||
const gchar *path;
|
||||
const gchar *path;
|
||||
GDBusInterfaceInfo *info;
|
||||
|
||||
path = g_dbus_object_get_object_path(object);
|
||||
@@ -104,7 +104,6 @@ static void interface_removed_cb(struct EG25Manager *manager,
|
||||
manager->mm_modem = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void add_mm_object(struct EG25Manager *manager, GDBusObject *object)
|
||||
{
|
||||
GList *ifaces, *node;
|
||||
@@ -116,7 +115,6 @@ static void add_mm_object(struct EG25Manager *manager, GDBusObject *object)
|
||||
g_list_free_full(ifaces, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
static void add_mm_objects(struct EG25Manager *manager)
|
||||
{
|
||||
GList *objects, *node;
|
||||
@@ -128,14 +126,12 @@ static void add_mm_objects(struct EG25Manager *manager)
|
||||
g_list_free_full(objects, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
static void object_added_cb(struct EG25Manager *manager, GDBusObject *object)
|
||||
{
|
||||
g_message("ModemManager object `%s' added", g_dbus_object_get_object_path(object));
|
||||
add_mm_object(manager, object);
|
||||
}
|
||||
|
||||
|
||||
static void object_removed_cb(struct EG25Manager *manager, GDBusObject *object)
|
||||
{
|
||||
const gchar *path;
|
||||
@@ -146,25 +142,32 @@ static void object_removed_cb(struct EG25Manager *manager, GDBusObject *object)
|
||||
manager->mm_modem = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void mm_manager_new_cb(GDBusConnection *connection,
|
||||
GAsyncResult *res,
|
||||
struct EG25Manager *manager)
|
||||
{
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
manager->mm_manager = mm_manager_new_finish(res, &error);
|
||||
if (!manager->mm_manager)
|
||||
g_critical("Error creating ModemManager Manager: %s", error->message);
|
||||
|
||||
g_signal_connect_swapped(G_DBUS_OBJECT_MANAGER(manager->mm_manager),
|
||||
"interface-added", G_CALLBACK(interface_added_cb), manager);
|
||||
"interface-added",
|
||||
G_CALLBACK(interface_added_cb),
|
||||
manager);
|
||||
g_signal_connect_swapped(G_DBUS_OBJECT_MANAGER(manager->mm_manager),
|
||||
"interface-removed", G_CALLBACK(interface_removed_cb), manager);
|
||||
"interface-removed",
|
||||
G_CALLBACK(interface_removed_cb),
|
||||
manager);
|
||||
g_signal_connect_swapped(G_DBUS_OBJECT_MANAGER(manager->mm_manager),
|
||||
"object-added", G_CALLBACK(object_added_cb), manager);
|
||||
"object-added",
|
||||
G_CALLBACK(object_added_cb),
|
||||
manager);
|
||||
g_signal_connect_swapped(G_DBUS_OBJECT_MANAGER(manager->mm_manager),
|
||||
"object-removed", G_CALLBACK(object_removed_cb), manager);
|
||||
"object-removed",
|
||||
G_CALLBACK(object_removed_cb),
|
||||
manager);
|
||||
|
||||
add_mm_objects(manager);
|
||||
}
|
||||
@@ -177,13 +180,18 @@ static void mm_appeared_cb(GDBusConnection *connection,
|
||||
g_message("ModemManager appeared on D-Bus");
|
||||
|
||||
if (manager->modem_iface != MODEM_IFACE_NONE) {
|
||||
g_critical("Modem interface already found! Make sure to only run either of ModemManager or oFono.");
|
||||
g_critical("Modem interface already found! Make sure to only run either of "
|
||||
"ModemManager or "
|
||||
"oFono.");
|
||||
return;
|
||||
}
|
||||
manager->modem_iface = MODEM_IFACE_MODEMMANAGER;
|
||||
|
||||
mm_manager_new(connection, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
|
||||
NULL, (GAsyncReadyCallback)mm_manager_new_cb, manager);
|
||||
mm_manager_new(connection,
|
||||
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)mm_manager_new_cb,
|
||||
manager);
|
||||
}
|
||||
|
||||
static void mm_iface_clean(struct EG25Manager *manager)
|
||||
@@ -201,9 +209,7 @@ static void mm_iface_clean(struct EG25Manager *manager)
|
||||
}
|
||||
}
|
||||
|
||||
static void mm_vanished_cb(GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
struct EG25Manager *manager)
|
||||
static void mm_vanished_cb(GDBusConnection *connection, const gchar *name, struct EG25Manager *manager)
|
||||
{
|
||||
g_message("ModemManager vanished from D-Bus");
|
||||
mm_iface_clean(manager);
|
||||
@@ -211,11 +217,13 @@ static void mm_vanished_cb(GDBusConnection *connection,
|
||||
|
||||
void mm_iface_init(struct EG25Manager *manager, toml_table_t *config[])
|
||||
{
|
||||
manager->mm_watch = g_bus_watch_name(G_BUS_TYPE_SYSTEM, MM_DBUS_SERVICE,
|
||||
manager->mm_watch = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
|
||||
MM_DBUS_SERVICE,
|
||||
G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
|
||||
(GBusNameAppearedCallback)mm_appeared_cb,
|
||||
(GBusNameVanishedCallback)mm_vanished_cb,
|
||||
manager, NULL);
|
||||
manager,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void mm_iface_destroy(struct EG25Manager *manager)
|
||||
|
Reference in New Issue
Block a user