diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-12-21 19:57:47 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:36 +0100 |
commit | 7ea8bf59fb1ed202320aa525c83d56e290d494fe (patch) | |
tree | 7b3e0252f7c83e3a139031e1a42dfc3d12a6b8bd | |
parent | ea934148304388f02435253f371c1af201f9116d (diff) |
iface-modem-simple: new interface to handle the Simple interface
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/mm-iface-modem-simple.c | 136 | ||||
-rw-r--r-- | src/mm-iface-modem-simple.h | 43 |
3 files changed, 181 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 590cd341..f4253807 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -142,6 +142,8 @@ modem_manager_SOURCES = \ mm-iface-modem.c \ mm-iface-modem-3gpp.h \ mm-iface-modem-3gpp.c \ + mm-iface-modem-simple.h \ + mm-iface-modem-simple.c \ mm-broadband-modem.h \ mm-broadband-modem.c \ mm-serial-parsers.c \ diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c new file mode 100644 index 00000000..b70b6b78 --- /dev/null +++ b/src/mm-iface-modem-simple.c @@ -0,0 +1,136 @@ +/* -*- 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 + * 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: + * + * Copyright (C) 2009 Novell, Inc. + * Copyright (C) 2009 - 2011 Red Hat, Inc. + * Copyright (C) 2011 Google, Inc. + */ + +#include <ModemManager.h> +#include <libmm-common.h> + +#include "mm-iface-modem.h" +#include "mm-iface-modem-simple.h" +#include "mm-log.h" + +/* typedef struct { */ +/* MmGdbusModemSimple *skeleton; */ +/* GDBusMethodInvocation *invocation; */ +/* MMIfaceModemSimple *self; */ +/* } DbusCallContext; */ + +/* static void */ +/* dbus_call_context_free (DbusCallContext *ctx) */ +/* { */ +/* g_object_unref (ctx->skeleton); */ +/* g_object_unref (ctx->invocation); */ +/* g_object_unref (ctx->self); */ +/* g_free (ctx); */ +/* } */ + +/* static DbusCallContext * */ +/* dbus_call_context_new (MmGdbusModemSimple *skeleton, */ +/* GDBusMethodInvocation *invocation, */ +/* MMIfaceModemSimple *self) */ +/* { */ +/* DbusCallContext *ctx; */ + +/* ctx = g_new (DbusCallContext, 1); */ +/* ctx->skeleton = g_object_ref (skeleton); */ +/* ctx->invocation = g_object_ref (invocation); */ +/* ctx->self = g_object_ref (self); */ +/* return ctx; */ +/* } */ + +/*****************************************************************************/ + +void +mm_iface_modem_simple_initialize (MMIfaceModemSimple *self) +{ + MmGdbusModemSimple *skeleton = NULL; + + g_return_if_fail (MM_IS_IFACE_MODEM_SIMPLE (self)); + + /* Did we already create it? */ + g_object_get (self, + MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, &skeleton, + NULL); + if (!skeleton) { + skeleton = mm_gdbus_modem_simple_skeleton_new (); + + g_object_set (self, + MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, skeleton, + NULL); + + /* Finally, export the new interface */ + mm_gdbus_object_skeleton_set_modem_simple (MM_GDBUS_OBJECT_SKELETON (self), + MM_GDBUS_MODEM_SIMPLE (skeleton)); + } + g_object_unref (skeleton); +} + +void +mm_iface_modem_simple_shutdown (MMIfaceModemSimple *self) +{ + g_return_if_fail (MM_IS_IFACE_MODEM_SIMPLE (self)); + + /* Unexport DBus interface and remove the skeleton */ + mm_gdbus_object_skeleton_set_modem_simple (MM_GDBUS_OBJECT_SKELETON (self), NULL); + g_object_set (self, + MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, NULL, + NULL); +} + +/*****************************************************************************/ + +static void +iface_modem_simple_init (gpointer g_iface) +{ + static gboolean initialized = FALSE; + + if (initialized) + return; + + /* Properties */ + g_object_interface_install_property + (g_iface, + g_param_spec_object (MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, + "Simple DBus skeleton", + "DBus skeleton for the Simple interface", + MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON, + G_PARAM_READWRITE)); + + initialized = TRUE; +} + +GType +mm_iface_modem_simple_get_type (void) +{ + static GType iface_modem_simple_type = 0; + + if (!G_UNLIKELY (iface_modem_simple_type)) { + static const GTypeInfo info = { + sizeof (MMIfaceModemSimple), /* class_size */ + iface_modem_simple_init, /* base_init */ + NULL, /* base_finalize */ + }; + + iface_modem_simple_type = g_type_register_static (G_TYPE_INTERFACE, + "MMIfaceModemSimple", + &info, + 0); + + g_type_interface_add_prerequisite (iface_modem_simple_type, MM_TYPE_IFACE_MODEM); + } + + return iface_modem_simple_type; +} diff --git a/src/mm-iface-modem-simple.h b/src/mm-iface-modem-simple.h new file mode 100644 index 00000000..fb942094 --- /dev/null +++ b/src/mm-iface-modem-simple.h @@ -0,0 +1,43 @@ +/* -*- 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 + * 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: + * + * Copyright (C) 2011 Google, Inc. + */ + +#ifndef MM_IFACE_MODEM_SIMPLE_H +#define MM_IFACE_MODEM_SIMPLE_H + +#include <glib-object.h> +#include <gio/gio.h> + +#define MM_TYPE_IFACE_MODEM_SIMPLE (mm_iface_modem_simple_get_type ()) +#define MM_IFACE_MODEM_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM_SIMPLE, MMIfaceModemSimple)) +#define MM_IS_IFACE_MODEM_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_IFACE_MODEM_SIMPLE)) +#define MM_IFACE_MODEM_SIMPLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_IFACE_MODEM_SIMPLE, MMIfaceModemSimple)) + +#define MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON "iface-modem-simple-dbus-skeleton" + +typedef struct _MMIfaceModemSimple MMIfaceModemSimple; + +struct _MMIfaceModemSimple { + GTypeInterface g_iface; +}; + +GType mm_iface_modem_simple_get_type (void); + +/* Initialize Modem Simple interface */ +void mm_iface_modem_simple_initialize (MMIfaceModemSimple *self); + +/* Shutdown Modem Simple interface */ +void mm_iface_modem_simple_shutdown (MMIfaceModemSimple *self); + +#endif /* MM_IFACE_MODEM_SIMPLE_H */ |