core: fix serial port base class callback types

This commit is contained in:
Dan Williams
2010-03-15 14:51:18 -07:00
parent 3151e0e298
commit d9a47ef2e8
4 changed files with 30 additions and 10 deletions

View File

@@ -238,7 +238,7 @@ mm_at_serial_port_queue_command (MMAtSerialPort *self,
buf, buf,
TRUE, TRUE,
timeout_seconds, timeout_seconds,
G_CALLBACK (callback), (MMSerialResponseFn) callback,
user_data); user_data);
} }
@@ -262,7 +262,7 @@ mm_at_serial_port_queue_command_cached (MMAtSerialPort *self,
buf, buf,
TRUE, TRUE,
timeout_seconds, timeout_seconds,
G_CALLBACK (callback), (MMSerialResponseFn) callback,
user_data); user_data);
} }

View File

@@ -104,7 +104,7 @@ mm_qcdm_serial_port_queue_command (MMQcdmSerialPort *self,
command, command,
TRUE, TRUE,
timeout_seconds, timeout_seconds,
G_CALLBACK (callback), (MMSerialResponseFn) callback,
user_data); user_data);
} }
@@ -124,7 +124,7 @@ mm_qcdm_serial_port_queue_command_cached (MMQcdmSerialPort *self,
command, command,
TRUE, TRUE,
timeout_seconds, timeout_seconds,
G_CALLBACK (callback), (MMSerialResponseFn) callback,
user_data); user_data);
} }

View File

@@ -1,3 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -491,6 +492,18 @@ mm_serial_port_schedule_queue_process (MMSerialPort *self)
g_source_unref (source); g_source_unref (source);
} }
static void
real_handle_response (MMSerialPort *self,
GByteArray *response,
GError *error,
GCallback callback,
gpointer callback_data)
{
MMSerialResponseFn response_callback = (MMSerialResponseFn) callback;
response_callback (self, response, error, callback_data);
}
static void static void
mm_serial_port_got_response (MMSerialPort *self, GError *error) mm_serial_port_got_response (MMSerialPort *self, GError *error)
{ {
@@ -825,7 +838,7 @@ internal_queue_command (MMSerialPort *self,
gboolean take_command, gboolean take_command,
gboolean cached, gboolean cached,
guint32 timeout_seconds, guint32 timeout_seconds,
GCallback callback, MMSerialResponseFn callback,
gpointer user_data) gpointer user_data)
{ {
MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self);
@@ -843,7 +856,7 @@ internal_queue_command (MMSerialPort *self,
} }
info->cached = cached; info->cached = cached;
info->timeout = timeout_seconds; info->timeout = timeout_seconds;
info->callback = callback; info->callback = (GCallback) callback;
info->user_data = user_data; info->user_data = user_data;
/* Clear the cached value for this command if not asking for cached value */ /* Clear the cached value for this command if not asking for cached value */
@@ -861,7 +874,7 @@ mm_serial_port_queue_command (MMSerialPort *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
GCallback callback, MMSerialResponseFn callback,
gpointer user_data) gpointer user_data)
{ {
internal_queue_command (self, command, take_command, FALSE, timeout_seconds, callback, user_data); internal_queue_command (self, command, take_command, FALSE, timeout_seconds, callback, user_data);
@@ -872,7 +885,7 @@ mm_serial_port_queue_command_cached (MMSerialPort *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
GCallback callback, MMSerialResponseFn callback,
gpointer user_data) gpointer user_data)
{ {
internal_queue_command (self, command, take_command, TRUE, timeout_seconds, callback, user_data); internal_queue_command (self, command, take_command, TRUE, timeout_seconds, callback, user_data);
@@ -1202,6 +1215,7 @@ mm_serial_port_class_init (MMSerialPortClass *klass)
object_class->finalize = finalize; object_class->finalize = finalize;
klass->config_fd = real_config_fd; klass->config_fd = real_config_fd;
klass->handle_response = real_handle_response;
/* Properties */ /* Properties */
g_object_class_install_property g_object_class_install_property

View File

@@ -43,6 +43,12 @@ typedef void (*MMSerialFlashFn) (MMSerialPort *port,
GError *error, GError *error,
gpointer user_data); gpointer user_data);
typedef void (*MMSerialResponseFn) (MMSerialPort *port,
GByteArray *response,
GError *error,
gpointer user_data);
struct _MMSerialPort { struct _MMSerialPort {
MMPort parent; MMPort parent;
}; };
@@ -106,14 +112,14 @@ void mm_serial_port_queue_command (MMSerialPort *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
GCallback callback, MMSerialResponseFn callback,
gpointer user_data); gpointer user_data);
void mm_serial_port_queue_command_cached (MMSerialPort *self, void mm_serial_port_queue_command_cached (MMSerialPort *self,
GByteArray *command, GByteArray *command,
gboolean take_command, gboolean take_command,
guint32 timeout_seconds, guint32 timeout_seconds,
GCallback callback, MMSerialResponseFn callback,
gpointer user_data); gpointer user_data);
#endif /* MM_SERIAL_PORT_H */ #endif /* MM_SERIAL_PORT_H */