
Both the ModemManager daemon and the mmcli will now include `libmm-glib.h' only. We also handle two new special `_LIBMM_INSIDE_MM' and `LIBMM_INSIDE_MMCLI' symbols, which if included before the `libmm-glib.h' library allow us to: * Don't include the libmm-glib high level API in the ModemManager daemon, as the object names would clash with those in the core. * Define some of the methods of helper objects to be included only if compiling ModemManager daemon or the mmcli.
424 lines
14 KiB
C
424 lines
14 KiB
C
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* libmm -- Access modem status & information from glib applications
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*
|
|
* Copyright (C) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org>
|
|
* Copyright (C) 2012 Google, Inc.
|
|
*/
|
|
|
|
#include "mm-errors-types.h"
|
|
#include "mm-object.h"
|
|
|
|
/**
|
|
* SECTION: mm-object
|
|
* @title: MMObject
|
|
* @short_description: Generic object representing a modem in ModemManager
|
|
*
|
|
* The #MMObject is a generic object which represents any kind of modem exposed
|
|
* in ModemManager, and allows accessing the exported interfaces one by one.
|
|
*
|
|
* When this object is available, it is ensured that at least the Modem
|
|
* interface is also available.
|
|
*/
|
|
|
|
G_DEFINE_TYPE (MMObject, mm_object, MM_GDBUS_TYPE_OBJECT_PROXY)
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_path: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the DBus path of the #MMObject object.
|
|
*
|
|
* Returns: (transfer none): The DBus path of the #MMObject object.
|
|
*/
|
|
const gchar *
|
|
mm_object_get_path (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (self), NULL);
|
|
|
|
return g_dbus_object_get_object_path (G_DBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_dup_path:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets a copy of the DBus path of the #MMObject object.
|
|
*
|
|
* Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free().
|
|
*/
|
|
gchar *
|
|
mm_object_dup_path (MMObject *self)
|
|
{
|
|
gchar *value;
|
|
|
|
g_return_val_if_fail (MM_IS_OBJECT (self), NULL);
|
|
|
|
g_object_get (G_OBJECT (self),
|
|
"g-object-path", &value,
|
|
NULL);
|
|
|
|
return value;
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem:
|
|
* @self: A #MMModem
|
|
*
|
|
* Gets the #MMModem instance for the D-Bus interface org.freedesktop.ModemManager1.Modem on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModem that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModem *
|
|
mm_object_get_modem (MMObject *self)
|
|
{
|
|
MMModem *modem;
|
|
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
modem = (MMModem *)mm_gdbus_object_get_modem (MM_GDBUS_OBJECT (self));
|
|
g_warn_if_fail (MM_IS_MODEM (modem));
|
|
return modem;
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModem or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModem *
|
|
mm_object_peek_modem (MMObject *self)
|
|
{
|
|
MMModem *modem;
|
|
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
modem = (MMModem *) mm_gdbus_object_peek_modem (MM_GDBUS_OBJECT (self));
|
|
g_warn_if_fail (MM_IS_MODEM (modem));
|
|
return modem;
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_3gpp:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModem3gpp instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modem3gpp on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModem3gpp that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModem3gpp *
|
|
mm_object_get_modem_3gpp (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModem3gpp *)mm_gdbus_object_get_modem3gpp (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_3gpp: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_3gpp() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModem3gpp or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModem3gpp *
|
|
mm_object_peek_modem_3gpp (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModem3gpp *)mm_gdbus_object_peek_modem3gpp (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_3gpp_ussd:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModem3gppUssd instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modem3gpp-Ussd on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModem3gppUssd that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModem3gppUssd *
|
|
mm_object_get_modem_3gpp_ussd (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModem3gppUssd *)mm_gdbus_object_get_modem3gpp_ussd (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_3gpp_ussd: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_3gpp_ussd() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModem3gppUssd or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModem3gppUssd *
|
|
mm_object_peek_modem_3gpp_ussd (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModem3gppUssd *)mm_gdbus_object_peek_modem3gpp_ussd (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_cdma:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModemCdma instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.ModemCdma on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModemCdma that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModemCdma *
|
|
mm_object_get_modem_cdma (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemCdma *)mm_gdbus_object_get_modem_cdma (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_cdma: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_cdma() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModemCdma or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModemCdma *
|
|
mm_object_peek_modem_cdma (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemCdma *)mm_gdbus_object_peek_modem_cdma (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_simple:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModemSimple instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modemsimple on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModemSimple that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModemSimple *
|
|
mm_object_get_modem_simple (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemSimple *)mm_gdbus_object_get_modem_simple (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_simple: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_simple() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModemSimple or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModemSimple *
|
|
mm_object_peek_modem_simple (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemSimple *)mm_gdbus_object_peek_modem_simple (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_location:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModemLocation instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modemlocation on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModemLocation that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModemLocation *
|
|
mm_object_get_modem_location (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemLocation *)mm_gdbus_object_get_modem_location (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_location: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_location() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModemLocation or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModemLocation *
|
|
mm_object_peek_modem_location (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemLocation *)mm_gdbus_object_peek_modem_location (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_messaging:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModemMessaging instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Modemmessaging on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModemMessaging that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModemMessaging *
|
|
mm_object_get_modem_messaging (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemMessaging *)mm_gdbus_object_get_modem_messaging (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_messaging: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_messaging() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModemMessaging or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModemMessaging *
|
|
mm_object_peek_modem_messaging (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemMessaging *)mm_gdbus_object_peek_modem_messaging (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_time:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModemTime instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Time on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModemTime that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModemTime *
|
|
mm_object_get_modem_time (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemTime *)mm_gdbus_object_get_modem_time (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_time: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_time() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModemTime or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModemTime *
|
|
mm_object_peek_modem_time (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemTime *)mm_gdbus_object_peek_modem_time (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* mm_object_get_modem_firmware:
|
|
* @self: A #MMObject.
|
|
*
|
|
* Gets the #MMModemFirmware instance for the D-Bus interface org.freedesktop.ModemManager1.Modem.Firmware on @self, if any.
|
|
*
|
|
* Returns: (transfer full): A #MMModemFirmware that must be freed with g_object_unref() or %NULL if @self does not implement the interface.
|
|
*/
|
|
MMModemFirmware *
|
|
mm_object_get_modem_firmware (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemFirmware *)mm_gdbus_object_get_modem_firmware (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/**
|
|
* mm_object_peek_modem_firmware: (skip)
|
|
* @self: A #MMObject.
|
|
*
|
|
* Like mm_object_get_modem_firmware() but doesn't increase the reference count on the returned object.
|
|
*
|
|
* <warning>It is not safe to use the returned object if you are on another thread than the one where the #MMManager is running.</warning>
|
|
*
|
|
* Returns: (transfer none): A #MMModemFirmware or %NULL if @self does not implement the interface. Do not free the returned object, it is owned by @self.
|
|
*/
|
|
MMModemFirmware *
|
|
mm_object_peek_modem_firmware (MMObject *self)
|
|
{
|
|
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
|
|
|
return (MMModemFirmware *)mm_gdbus_object_peek_modem_firmware (MM_GDBUS_OBJECT (self));
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
|
|
static void
|
|
mm_object_init (MMObject *self)
|
|
{
|
|
}
|
|
|
|
static void
|
|
mm_object_class_init (MMObjectClass *object_class)
|
|
{
|
|
}
|