port-probe: let us peek the `MMDevice' owning the probe from the probe itself
This commit is contained in:
@@ -226,7 +226,7 @@ mm_device_grab_port (MMDevice *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create and store new port probe */
|
/* Create and store new port probe */
|
||||||
probe = mm_port_probe_new (udev_port);
|
probe = mm_port_probe_new (self, udev_port);
|
||||||
self->priv->port_probes = g_list_prepend (self->priv->port_probes, probe);
|
self->priv->port_probes = g_list_prepend (self->priv->port_probes, probe);
|
||||||
|
|
||||||
/* Notify about the grabbed port */
|
/* Notify about the grabbed port */
|
||||||
@@ -472,14 +472,17 @@ mm_device_get_modem (MMDevice *self)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMPortProbe *
|
GObject *
|
||||||
mm_device_peek_port_probe (MMDevice *self,
|
mm_device_peek_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
GUdevDevice *udev_port)
|
||||||
{
|
{
|
||||||
return device_find_probe_with_device (self, udev_port);
|
MMPortProbe *probe;
|
||||||
|
|
||||||
|
probe = device_find_probe_with_device (self, udev_port);
|
||||||
|
return (probe ? G_OBJECT (probe) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MMPortProbe *
|
GObject *
|
||||||
mm_device_get_port_probe (MMDevice *self,
|
mm_device_get_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port)
|
GUdevDevice *udev_port)
|
||||||
{
|
{
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
#include <gudev/gudev.h>
|
#include <gudev/gudev.h>
|
||||||
|
|
||||||
#include "mm-base-modem.h"
|
#include "mm-base-modem.h"
|
||||||
#include "mm-port-probe.h"
|
|
||||||
|
|
||||||
#define MM_TYPE_DEVICE (mm_device_get_type ())
|
#define MM_TYPE_DEVICE (mm_device_get_type ())
|
||||||
#define MM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_DEVICE, MMDevice))
|
#define MM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_DEVICE, MMDevice))
|
||||||
@@ -86,9 +85,9 @@ GObject *mm_device_get_plugin (MMDevice *self);
|
|||||||
MMBaseModem *mm_device_peek_modem (MMDevice *self);
|
MMBaseModem *mm_device_peek_modem (MMDevice *self);
|
||||||
MMBaseModem *mm_device_get_modem (MMDevice *self);
|
MMBaseModem *mm_device_get_modem (MMDevice *self);
|
||||||
|
|
||||||
MMPortProbe *mm_device_peek_port_probe (MMDevice *self,
|
GObject *mm_device_peek_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
GUdevDevice *udev_port);
|
||||||
MMPortProbe *mm_device_get_port_probe (MMDevice *self,
|
GObject *mm_device_get_port_probe (MMDevice *self,
|
||||||
GUdevDevice *udev_port);
|
GUdevDevice *udev_port);
|
||||||
GList *mm_device_peek_port_probe_list (MMDevice *self);
|
GList *mm_device_peek_port_probe_list (MMDevice *self);
|
||||||
GList *mm_device_get_port_probe_list (MMDevice *self);
|
GList *mm_device_get_port_probe_list (MMDevice *self);
|
||||||
|
@@ -505,7 +505,7 @@ mm_plugin_supports_port (MMPlugin *self,
|
|||||||
|
|
||||||
/* Need to launch new probing */
|
/* Need to launch new probing */
|
||||||
|
|
||||||
probe = mm_device_get_port_probe (device, port);
|
probe = MM_PORT_PROBE (mm_device_get_port_probe (device, port));
|
||||||
g_assert (probe);
|
g_assert (probe);
|
||||||
|
|
||||||
/* Before launching any probing, check if the port is a net device (which
|
/* Before launching any probing, check if the port is a net device (which
|
||||||
|
@@ -49,6 +49,7 @@ G_DEFINE_TYPE (MMPortProbe, mm_port_probe, G_TYPE_OBJECT)
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
PROP_DEVICE,
|
||||||
PROP_PORT,
|
PROP_PORT,
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
@@ -83,7 +84,8 @@ typedef struct {
|
|||||||
} PortProbeRunTask;
|
} PortProbeRunTask;
|
||||||
|
|
||||||
struct _MMPortProbePrivate {
|
struct _MMPortProbePrivate {
|
||||||
/* Port and properties */
|
/* Properties */
|
||||||
|
MMDevice *device;
|
||||||
GUdevDevice *port;
|
GUdevDevice *port;
|
||||||
|
|
||||||
/* Probing results */
|
/* Probing results */
|
||||||
@@ -1004,6 +1006,22 @@ mm_port_probe_get_port_type (MMPortProbe *self)
|
|||||||
return MM_PORT_TYPE_UNKNOWN;
|
return MM_PORT_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMDevice *
|
||||||
|
mm_port_probe_peek_device (MMPortProbe *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||||
|
|
||||||
|
return self->priv->device;
|
||||||
|
}
|
||||||
|
|
||||||
|
MMDevice *
|
||||||
|
mm_port_probe_get_device (MMPortProbe *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), NULL);
|
||||||
|
|
||||||
|
return MM_DEVICE (g_object_ref (self->priv->device));
|
||||||
|
}
|
||||||
|
|
||||||
GUdevDevice *
|
GUdevDevice *
|
||||||
mm_port_probe_peek_port (MMPortProbe *self)
|
mm_port_probe_peek_port (MMPortProbe *self)
|
||||||
{
|
{
|
||||||
@@ -1065,10 +1083,12 @@ mm_port_probe_get_port_subsys (MMPortProbe *self)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
MMPortProbe *
|
MMPortProbe *
|
||||||
mm_port_probe_new (GUdevDevice *port)
|
mm_port_probe_new (MMDevice *device,
|
||||||
|
GUdevDevice *port)
|
||||||
{
|
{
|
||||||
return MM_PORT_PROBE (g_object_new (MM_TYPE_PORT_PROBE,
|
return MM_PORT_PROBE (g_object_new (MM_TYPE_PORT_PROBE,
|
||||||
MM_PORT_PROBE_PORT, port,
|
MM_PORT_PROBE_DEVICE, device,
|
||||||
|
MM_PORT_PROBE_PORT, port,
|
||||||
NULL));
|
NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1089,6 +1109,10 @@ set_property (GObject *object,
|
|||||||
MMPortProbe *self = MM_PORT_PROBE (object);
|
MMPortProbe *self = MM_PORT_PROBE (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_DEVICE:
|
||||||
|
/* construct only, no new reference! */
|
||||||
|
self->priv->device = g_value_get_object (value);
|
||||||
|
break;
|
||||||
case PROP_PORT:
|
case PROP_PORT:
|
||||||
/* construct only */
|
/* construct only */
|
||||||
self->priv->port = g_value_dup_object (value);
|
self->priv->port = g_value_dup_object (value);
|
||||||
@@ -1108,6 +1132,9 @@ get_property (GObject *object,
|
|||||||
MMPortProbe *self = MM_PORT_PROBE (object);
|
MMPortProbe *self = MM_PORT_PROBE (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_DEVICE:
|
||||||
|
g_value_set_object (value, self->priv->device);
|
||||||
|
break;
|
||||||
case PROP_PORT:
|
case PROP_PORT:
|
||||||
g_value_set_object (value, self->priv->port);
|
g_value_set_object (value, self->priv->port);
|
||||||
break;
|
break;
|
||||||
@@ -1136,6 +1163,9 @@ dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
MMPortProbe *self = MM_PORT_PROBE (object);
|
MMPortProbe *self = MM_PORT_PROBE (object);
|
||||||
|
|
||||||
|
/* We didn't get a reference to the device */
|
||||||
|
self->priv->device = NULL;
|
||||||
|
|
||||||
g_clear_object (&self->priv->port);
|
g_clear_object (&self->priv->port);
|
||||||
|
|
||||||
G_OBJECT_CLASS (mm_port_probe_parent_class)->dispose (object);
|
G_OBJECT_CLASS (mm_port_probe_parent_class)->dispose (object);
|
||||||
@@ -1154,6 +1184,14 @@ mm_port_probe_class_init (MMPortProbeClass *klass)
|
|||||||
object_class->finalize = finalize;
|
object_class->finalize = finalize;
|
||||||
object_class->dispose = dispose;
|
object_class->dispose = dispose;
|
||||||
|
|
||||||
|
properties[PROP_DEVICE] =
|
||||||
|
g_param_spec_object (MM_PORT_PROBE_DEVICE,
|
||||||
|
"Device",
|
||||||
|
"Device owning this probe",
|
||||||
|
MM_TYPE_DEVICE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||||
|
g_object_class_install_property (object_class, PROP_DEVICE, properties[PROP_DEVICE]);
|
||||||
|
|
||||||
properties[PROP_PORT] =
|
properties[PROP_PORT] =
|
||||||
g_param_spec_object (MM_PORT_PROBE_PORT,
|
g_param_spec_object (MM_PORT_PROBE_PORT,
|
||||||
"Port",
|
"Port",
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "mm-private-boxed-types.h"
|
#include "mm-private-boxed-types.h"
|
||||||
#include "mm-port-probe-at.h"
|
#include "mm-port-probe-at.h"
|
||||||
#include "mm-at-serial-port.h"
|
#include "mm-at-serial-port.h"
|
||||||
|
#include "mm-device.h"
|
||||||
|
|
||||||
#define MM_TYPE_PORT_PROBE (mm_port_probe_get_type ())
|
#define MM_TYPE_PORT_PROBE (mm_port_probe_get_type ())
|
||||||
#define MM_PORT_PROBE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PORT_PROBE, MMPortProbe))
|
#define MM_PORT_PROBE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PORT_PROBE, MMPortProbe))
|
||||||
@@ -45,7 +46,8 @@ typedef struct _MMPortProbe MMPortProbe;
|
|||||||
typedef struct _MMPortProbeClass MMPortProbeClass;
|
typedef struct _MMPortProbeClass MMPortProbeClass;
|
||||||
typedef struct _MMPortProbePrivate MMPortProbePrivate;
|
typedef struct _MMPortProbePrivate MMPortProbePrivate;
|
||||||
|
|
||||||
#define MM_PORT_PROBE_PORT "port"
|
#define MM_PORT_PROBE_DEVICE "device"
|
||||||
|
#define MM_PORT_PROBE_PORT "port"
|
||||||
|
|
||||||
struct _MMPortProbe {
|
struct _MMPortProbe {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
@@ -71,8 +73,11 @@ typedef gboolean (* MMPortProbeAtCustomInitFinish) (MMPortProbe *probe,
|
|||||||
|
|
||||||
GType mm_port_probe_get_type (void);
|
GType mm_port_probe_get_type (void);
|
||||||
|
|
||||||
MMPortProbe *mm_port_probe_new (GUdevDevice *port);
|
MMPortProbe *mm_port_probe_new (MMDevice *device,
|
||||||
|
GUdevDevice *port);
|
||||||
|
|
||||||
|
MMDevice *mm_port_probe_peek_device (MMPortProbe *self);
|
||||||
|
MMDevice *mm_port_probe_get_device (MMPortProbe *self);
|
||||||
GUdevDevice *mm_port_probe_peek_port (MMPortProbe *self);
|
GUdevDevice *mm_port_probe_peek_port (MMPortProbe *self);
|
||||||
GUdevDevice *mm_port_probe_get_port (MMPortProbe *self);
|
GUdevDevice *mm_port_probe_get_port (MMPortProbe *self);
|
||||||
const gchar *mm_port_probe_get_port_name (MMPortProbe *self);
|
const gchar *mm_port_probe_get_port_name (MMPortProbe *self);
|
||||||
|
Reference in New Issue
Block a user