diff options
author | Dan Williams <dcbw@redhat.com> | 2009-11-23 23:48:26 -0800 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-11-23 23:48:26 -0800 |
commit | 3be4a15189aef361187b86df64f62ca70284dee3 (patch) | |
tree | 6ba226aa1a75afdf8717717fff2baccf5223e3da | |
parent | d8ff5f74e008289ad512bb15f2c4cb1576752221 (diff) | |
parent | e5b5c8339472a37d3a44ac6239fc3d9bdb9ce5cc (diff) |
Merge commit 'origin/master' into states
-rw-r--r-- | plugins/mm-modem-hso.c | 15 | ||||
-rw-r--r-- | src/mm-plugin-base.c | 2 | ||||
-rw-r--r-- | test/lsudev.c | 180 |
3 files changed, 194 insertions, 3 deletions
diff --git a/plugins/mm-modem-hso.c b/plugins/mm-modem-hso.c index 97ff7c36..99c5823d 100644 --- a/plugins/mm-modem-hso.c +++ b/plugins/mm-modem-hso.c @@ -296,8 +296,9 @@ disable (MMModem *modem, { MMCallbackInfo *info; MMSerialPort *primary; + char *cmd; + guint32 cid; - mm_generic_gsm_set_cid (MM_GENERIC_GSM (modem), 0); mm_generic_gsm_pending_registration_stop (MM_GENERIC_GSM (modem)); info = mm_callback_info_new (modem, callback, user_data); @@ -305,7 +306,17 @@ disable (MMModem *modem, /* Kill any existing connection */ primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY); g_assert (primary); - mm_serial_port_queue_command (primary, "AT_OWANCALL=1,0,0", 3, disable_done, info); + + cid = mm_generic_gsm_get_cid (MM_GENERIC_GSM (modem)); + mm_generic_gsm_set_cid (MM_GENERIC_GSM (modem), 0); + + /* Disconnect the data session of the active connection, if any */ + if (cid > 0) { + cmd = g_strdup_printf ("AT_OWANCALL=%u,0,0", cid); + mm_serial_port_queue_command (primary, cmd, 3, disable_done, info); + g_free (cmd); + } else + disable_done (primary, NULL, NULL, info); } static void diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c index 7455046f..540670aa 100644 --- a/src/mm-plugin-base.c +++ b/src/mm-plugin-base.c @@ -489,7 +489,7 @@ mm_plugin_base_probe_port (MMPluginBase *self, serial = mm_serial_port_new (name, MM_PORT_TYPE_PRIMARY); g_object_set (serial, - MM_SERIAL_PORT_SEND_DELAY, 100000, + MM_SERIAL_PORT_SEND_DELAY, (guint64) 100000, MM_PORT_CARRIER_DETECT, FALSE, NULL); diff --git a/test/lsudev.c b/test/lsudev.c new file mode 100644 index 00000000..4b31b316 --- /dev/null +++ b/test/lsudev.c @@ -0,0 +1,180 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) 2009 Red Hat, Inc. + */ + +#include <glib.h> +#define G_UDEV_API_IS_SUBJECT_TO_CHANGE +#include <gudev/gudev.h> + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdarg.h> +#include <signal.h> + +static GMainLoop *loop = NULL; + +static void +signal_handler (int signo) +{ + if (signo == SIGINT || signo == SIGTERM) { + g_message ("Caught signal %d, shutting down...", signo); + g_main_loop_quit (loop); + } +} + +static void +setup_signals (void) +{ + struct sigaction action; + sigset_t mask; + + sigemptyset (&mask); + action.sa_handler = signal_handler; + action.sa_mask = mask; + action.sa_flags = 0; + sigaction (SIGTERM, &action, NULL); + sigaction (SIGINT, &action, NULL); +} + +static void +println (guint indent, const char *fmt, ...) +{ + va_list args; + char real_fmt[1000]; + int i; + + g_return_if_fail (fmt != NULL); + g_return_if_fail (indent < sizeof (real_fmt) - 2 - strlen (fmt)); + + for (i = 0; i < indent; i++) + real_fmt[i] = ' '; + strcpy (&real_fmt[i], fmt); + real_fmt[i + strlen (fmt)] = '\n'; + real_fmt[i + strlen (fmt) + 1] = '\0'; + + va_start (args, fmt); + vprintf (real_fmt, args); + va_end (args); +} + +static void +dump_device_and_parent (GUdevDevice *device, guint indent) +{ + const char **list, **iter; + GUdevDevice *parent; + char propstr[500]; + guint32 namelen = 0, i; + + println (indent, "------------------------------------------------------"); + println (indent, "Name: %s", g_udev_device_get_name (device)); + println (indent, "Type: %s", g_udev_device_get_devtype (device)); + println (indent, "Subsys: %s", g_udev_device_get_subsystem (device)); + println (indent, "Number: %s", g_udev_device_get_number (device)); + println (indent, "Path: %s", g_udev_device_get_sysfs_path (device)); + println (indent, "Driver: %s", g_udev_device_get_driver (device)); + println (indent, "Action: %s", g_udev_device_get_action (device)); + println (indent, "Seq Num: %s", g_udev_device_get_seqnum (device)); + println (indent, "Dev File: %s", g_udev_device_get_device_file (device)); + + println (indent, ""); + println (indent, "Properties:"); + + /* Get longest property name length for alignment */ + list = g_udev_device_get_property_keys (device); + for (iter = list; iter && *iter; iter++) { + if (strlen (*iter) > namelen) + namelen = strlen (*iter); + } + namelen++; + + for (iter = list; iter && *iter; iter++) { + strcpy (propstr, *iter); + strcat (propstr, ":"); + for (i = 0; i < namelen - strlen (*iter); i++) + strcat (propstr, " "); + strcat (propstr, g_udev_device_get_property (device, *iter)); + println (indent + 2, "%s", propstr); + } + + println (indent, ""); + + parent = g_udev_device_get_parent (device); + if (parent) { + dump_device_and_parent (parent, indent + 4); + g_object_unref (parent); + } +} + +static void +handle_uevent (GUdevClient *client, + const char *action, + GUdevDevice *device, + gpointer user_data) +{ + const char *expected_subsys = user_data; + const char *subsys; + + g_return_if_fail (client != NULL); + g_return_if_fail (action != NULL); + g_return_if_fail (device != NULL); + + /* A bit paranoid */ + subsys = g_udev_device_get_subsystem (device); + g_return_if_fail (subsys != NULL); + + g_return_if_fail (!strcmp (subsys, expected_subsys)); + + g_print ("---- (EVENT: %s) ----\n", action); + dump_device_and_parent (device, 0); + g_print ("\n"); +} + +int +main (int argc, char *argv[]) +{ + GUdevClient *client; + const char *subsys[2] = { NULL, NULL }; + GList *list, *iter; + + if (argc != 2) { + g_warning ("Usage: %s [subsystem]", argv[0]); + return 1; + } + + g_type_init (); + + loop = g_main_loop_new (NULL, FALSE); + + setup_signals (); + + subsys[0] = argv[1]; + client = g_udev_client_new (subsys); + g_signal_connect (client, "uevent", G_CALLBACK (handle_uevent), (gpointer) subsys[0]); + + list = g_udev_client_query_by_subsystem (client, subsys[0]); + for (iter = list; iter; iter = g_list_next (iter)) { + dump_device_and_parent (G_UDEV_DEVICE (iter->data), 0); + g_print ("\n"); + g_object_unref (G_UDEV_DEVICE (iter->data)); + } + + g_main_loop_run (loop); + + return 0; +} + |