1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301 USA.
18 * author: Pantelis Koukousoulas <pktoss@gmail.com>
19 * Copyright 2009 - 2011 Red Hat, Inc.
22 #include "nm-default.h"
24 #include "nm-device-adsl.h"
28 #include "nm-device-private.h"
29 #include "nm-object-private.h"
31 #include "nm-setting-adsl.h"
32 #include "nm-setting-connection.h"
35 G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE)
37 #define NM_DEVICE_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ADSL, NMDeviceAdslPrivate))
42 } NMDeviceAdslPrivate;
51 * nm_device_adsl_get_carrier:
52 * @device: a #NMDeviceAdsl
54 * Whether the device has carrier.
56 * Returns: %TRUE if the device has carrier
59 nm_device_adsl_get_carrier (NMDeviceAdsl *device)
61 g_return_val_if_fail (NM_IS_DEVICE_ADSL (device), FALSE);
63 return NM_DEVICE_ADSL_GET_PRIVATE (device)->carrier;
67 connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
69 if (!NM_DEVICE_CLASS (nm_device_adsl_parent_class)->connection_compatible (device, connection, error))
72 if (!nm_connection_is_type (connection, NM_SETTING_ADSL_SETTING_NAME)) {
73 g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
74 _("The connection was not an ADSL connection."));
82 get_setting_type (NMDevice *device)
84 return NM_TYPE_SETTING_ADSL;
87 /******************************************************************/
90 nm_device_adsl_init (NMDeviceAdsl *device)
92 _nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_ADSL);
96 init_dbus (NMObject *object)
98 NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object);
99 const NMPropertiesInfo property_info[] = {
100 { NM_DEVICE_ADSL_CARRIER, &priv->carrier },
104 NM_OBJECT_CLASS (nm_device_adsl_parent_class)->init_dbus (object);
106 _nm_object_register_properties (object,
107 NM_DBUS_INTERFACE_DEVICE_ADSL,
112 get_property (GObject *object,
117 NMDeviceAdsl *device = NM_DEVICE_ADSL (object);
121 g_value_set_boolean (value, nm_device_adsl_get_carrier (device));
124 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
130 nm_device_adsl_class_init (NMDeviceAdslClass *adsl_class)
132 GObjectClass *object_class = G_OBJECT_CLASS (adsl_class);
133 NMObjectClass *nm_object_class = NM_OBJECT_CLASS (adsl_class);
134 NMDeviceClass *device_class = NM_DEVICE_CLASS (adsl_class);
136 g_type_class_add_private (object_class, sizeof (NMDeviceAdslPrivate));
138 _nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_DEVICE_ADSL);
140 /* virtual methods */
141 object_class->get_property = get_property;
143 nm_object_class->init_dbus = init_dbus;
145 device_class->connection_compatible = connection_compatible;
146 device_class->get_setting_type = get_setting_type;
150 * NMDeviceAdsl:carrier:
152 * Whether the device has carrier.
154 g_object_class_install_property
155 (object_class, PROP_CARRIER,
156 g_param_spec_boolean (NM_DEVICE_ADSL_CARRIER, "", "",
159 G_PARAM_STATIC_STRINGS));