/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* * libnm_glib -- Access network 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) 2008 Red Hat, Inc. * Copyright (C) 2008 Novell, Inc. */ #include "nm-cdma-device.h" #include "nm-device-private.h" #include "nm-object-private.h" G_DEFINE_TYPE (NMCdmaDevice, nm_cdma_device, NM_TYPE_SERIAL_DEVICE) #define NM_CDMA_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CDMA_DEVICE, NMCdmaDevicePrivate)) typedef struct { DBusGProxy *proxy; gboolean disposed; } NMCdmaDevicePrivate; static void nm_cdma_device_init (NMCdmaDevice *device) { } static void register_for_property_changed (NMCdmaDevice *device) { NMCdmaDevicePrivate *priv = NM_CDMA_DEVICE_GET_PRIVATE (device); const NMPropertiesChangedInfo property_changed_info[] = { { NULL }, }; _nm_object_handle_properties_changed (NM_OBJECT (device), priv->proxy, property_changed_info); } static GObject* constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params) { GObject *object; NMCdmaDevicePrivate *priv; object = G_OBJECT_CLASS (nm_cdma_device_parent_class)->constructor (type, n_construct_params, construct_params); if (!object) return NULL; priv = NM_CDMA_DEVICE_GET_PRIVATE (object); priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), NM_DBUS_SERVICE, nm_object_get_path (NM_OBJECT (object)), NM_DBUS_INTERFACE_CDMA_DEVICE); register_for_property_changed (NM_CDMA_DEVICE (object)); return object; } static void dispose (GObject *object) { NMCdmaDevicePrivate *priv = NM_CDMA_DEVICE_GET_PRIVATE (object); if (priv->disposed) { G_OBJECT_CLASS (nm_cdma_device_parent_class)->dispose (object); return; } priv->disposed = TRUE; g_object_unref (priv->proxy); G_OBJECT_CLASS (nm_cdma_device_parent_class)->dispose (object); } static void nm_cdma_device_class_init (NMCdmaDeviceClass *device_class) { GObjectClass *object_class = G_OBJECT_CLASS (device_class); g_type_class_add_private (device_class, sizeof (NMCdmaDevicePrivate)); /* virtual methods */ object_class->constructor = constructor; object_class->dispose = dispose; } /** * nm_cdma_device_new: * @connection: the #DBusGConnection * @path: the DBus object path of the device * * Creates a new #NMCdmaDevice. * * Returns: a new device **/ GObject * nm_cdma_device_new (DBusGConnection *connection, const char *path) { g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); return g_object_new (NM_TYPE_CDMA_DEVICE, NM_OBJECT_DBUS_CONNECTION, connection, NM_OBJECT_DBUS_PATH, path, NULL); }