Top | ![]() |
![]() |
![]() |
![]() |
LdmManager * | ldm_manager_new () |
GPtrArray * | ldm_manager_get_devices () |
GPtrArray * | ldm_manager_get_providers () |
gboolean | ldm_manager_add_modalias_plugin_for_path () |
gboolean | ldm_manager_add_modalias_plugins_for_directory () |
gboolean | ldm_manager_add_system_modalias_plugins () |
void | ldm_manager_add_plugin () |
The manager object is used to introspect the system and discover various devices. Using the LdmManager APIs one can enumerate specific device classes.
LdmManager internally makes use of libudev to provide low level enumeration and hotplug event capabilities, but will convert those raw devices and interfaces into the more readily consumable LdmDevice type.
Using the manager is very simple, and in a few lines you can grab all the devices from the system for introspection.
C example:
1 2 3 |
LdmManager *manager = ldm_manager_new(LDM_MANAGER_FLAGS_NONE); g_autoptr(GPtrArray) devices = ldm_manager_get_devices(LDM_DEVICE_TYPE_ANY); LdmDevice *device = devices->pdata[0]; |
Vala example:
1 2 |
var manager = new Ldm.Manager(); var devices = manager.get_devices(); |
LdmManager *
ldm_manager_new (LdmManagerFlags flags
);
Construct a new LdmManager Without any specified flags, the new LdmManager will default to monitoring for hotplug events.
GPtrArray * ldm_manager_get_devices (LdmManager *manager
,LdmDeviceType class_mask
);
Return a subset of the devices known to this manager that happen to match the given classmask. As an example you might call this function with LDM_DEVICE_TYPE_GPU|LDM_DEVICE_TYPE_PCI to find all PCI GPUs on the system.
This function will return an array of references to our internal storage, so that they persist should hotplugging then disable the device. It is advisable to not rely on the device list staying valid for any duration of time, and instead use it for basic probing, not persistence.
GPtrArray * ldm_manager_get_providers (LdmManager *manager
,LdmDevice *device
);
Walk the plugins and find all known providers for the given device, if they can support it. The returned GPtrArray will free all elements when it itself is freed.
gboolean ldm_manager_add_modalias_plugin_for_path (LdmManager *manager
,const gchar *path
);
Add a new LdmModaliasPlugin to the manager for the given path. This is a convenience wrapper around ldm_modalias_plugin_new_from_filename and ldm_manager_add_plugin.
Note that newer modalias plugins have a higher priority than older plugins, so you should add newest drivers last if you have multiple driver versions. This is already taken care of by using the glob-based function ldm_manager_add_modalias_plugins_for_directory
i.e. insert 380 driver AFTER 340.
gboolean ldm_manager_add_modalias_plugins_for_directory (LdmManager *manager
,const gchar *directory
);
Attempt to bulk-add LdmModaliasPlugin objects from the given directory to ensure preservation of sort order and ease of use.
This function is used to add well known modalias paths to the plugin and construct plugins used for hardware detection.
gboolean
ldm_manager_add_system_modalias_plugins
(LdmManager *manager
);
Attempt to add all modalias plugins directory from the modalias directory set when the library was compiled.
This is a convenience wrapper around ldm_manager_add_modalias_plugins_for_directory.
void ldm_manager_add_plugin (LdmManager *manager
,LdmPlugin *plugin
);
Add a new plugin to the current set of plugins. The plugins are used to provide automatic hardware detection capabilities to the LdmManager and provide the internal API required for ldm_manager_get_providers to work.
“flags”
property“flags” LdmManagerFlags
The flags set at time of construction dictating the behaviour of this manager
Owner: LdmManager
Flags: Read / Write / Construct Only
“device-added”
signalvoid user_function (LdmManager *manager, LdmDevice *device, gpointer user_data)
Connect to this signal to be notified about devices as they become available to the LdmManager.
manager |
The manager owning the device |
|
device |
The newly available device |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action
“device-removed”
signalvoid user_function (LdmManager *manager, LdmDevice *device, gpointer user_data)
Connect to this signal to be notified when a device is about to be removed from the LdmManager. The device being passed will be unreffed after this signal is emitted, so do not attempt to hold any references to it.
manager |
The manager owning the device |
|
device |
The device being removed |
|
user_data |
user data set when the signal handler was connected. |
Flags: Action