port: make 'timed-out' a signal for all port types, not just serial
This commit is contained in:
@@ -207,7 +207,7 @@ base_modem_create_tty_port (MMBaseModem *self,
|
||||
/* Enable port timeout checks if requested to do so */
|
||||
if (self->priv->max_timeouts > 0)
|
||||
g_signal_connect (port,
|
||||
"timed-out",
|
||||
MM_PORT_SIGNAL_TIMED_OUT,
|
||||
G_CALLBACK (serial_port_timed_out_cb),
|
||||
self);
|
||||
|
||||
|
@@ -65,9 +65,7 @@ enum {
|
||||
|
||||
enum {
|
||||
BUFFER_FULL,
|
||||
TIMED_OUT,
|
||||
FORCED_CLOSE,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
@@ -604,7 +602,7 @@ port_serial_process_command (MMPortSerial *self,
|
||||
if (ctx->eagain_count <= 0) {
|
||||
/* If we reach the limit of EAGAIN errors, treat as a timeout error. */
|
||||
self->priv->n_consecutive_timeouts++;
|
||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
||||
g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, self->priv->n_consecutive_timeouts);
|
||||
|
||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||
"Sending command failed: '%s'", g_strerror (errno));
|
||||
@@ -640,7 +638,7 @@ port_serial_process_command (MMPortSerial *self,
|
||||
if (ctx->eagain_count <= 0) {
|
||||
/* If we reach the limit of EAGAIN errors, treat as a timeout error. */
|
||||
self->priv->n_consecutive_timeouts++;
|
||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
||||
g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, self->priv->n_consecutive_timeouts);
|
||||
g_set_error (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_SEND_FAILED,
|
||||
"Sending command failed: '%s'", g_strerror (errno));
|
||||
return FALSE;
|
||||
@@ -786,7 +784,7 @@ port_serial_timed_out (gpointer data)
|
||||
|
||||
/* Emit a timed out signal, used by upper layers to identify a disconnected
|
||||
* serial port */
|
||||
g_signal_emit (self, signals[TIMED_OUT], 0, self->priv->n_consecutive_timeouts);
|
||||
g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, self->priv->n_consecutive_timeouts);
|
||||
}
|
||||
g_object_unref (self);
|
||||
|
||||
@@ -2177,15 +2175,6 @@ mm_port_serial_class_init (MMPortSerialClass *klass)
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE, 1, G_TYPE_POINTER);
|
||||
|
||||
signals[TIMED_OUT] =
|
||||
g_signal_new ("timed-out",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (MMPortSerialClass, timed_out),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE, 1, G_TYPE_UINT);
|
||||
|
||||
signals[FORCED_CLOSE] =
|
||||
g_signal_new ("forced-close",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
|
@@ -102,7 +102,6 @@ struct _MMPortSerialClass {
|
||||
|
||||
/* Signals */
|
||||
void (*buffer_full) (MMPortSerial *port, const GByteArray *buffer);
|
||||
void (*timed_out) (MMPortSerial *port, guint n_consecutive_replies);
|
||||
void (*forced_close) (MMPortSerial *port);
|
||||
};
|
||||
|
||||
|
@@ -37,6 +37,14 @@ enum {
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
TIMED_OUT,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
struct _MMPortPrivate {
|
||||
gchar *device;
|
||||
MMPortSubsys subsys;
|
||||
@@ -270,4 +278,13 @@ mm_port_class_init (MMPortClass *klass)
|
||||
"kernel device object",
|
||||
MM_TYPE_KERNEL_DEVICE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
signals[TIMED_OUT] =
|
||||
g_signal_new (MM_PORT_SIGNAL_TIMED_OUT,
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (MMPortClass, timed_out),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE, 1, G_TYPE_UINT);
|
||||
}
|
||||
|
@@ -60,6 +60,8 @@ typedef enum { /*< underscore_name=mm_port_type >*/
|
||||
#define MM_PORT_CONNECTED "connected"
|
||||
#define MM_PORT_KERNEL_DEVICE "kernel-device"
|
||||
|
||||
#define MM_PORT_SIGNAL_TIMED_OUT "timed-out"
|
||||
|
||||
typedef struct _MMPort MMPort;
|
||||
typedef struct _MMPortClass MMPortClass;
|
||||
typedef struct _MMPortPrivate MMPortPrivate;
|
||||
@@ -71,6 +73,9 @@ struct _MMPort {
|
||||
|
||||
struct _MMPortClass {
|
||||
GObjectClass parent;
|
||||
|
||||
/* signals */
|
||||
void (* timed_out) (MMPort *port, guint n_consecutive_replies);
|
||||
};
|
||||
|
||||
GType mm_port_get_type (void);
|
||||
|
Reference in New Issue
Block a user