core: merge MMPluginBase' and
MMPlugin'
There's no real point in maintaining a separate `MMPlugin' interface, as all the plugins will inherit from `MMPluginBase', so just merge them and simplify everything.
This commit is contained in:
@@ -197,9 +197,7 @@ ModemManager_SOURCES = \
|
||||
mm-port-probe-cache.h \
|
||||
mm-port-probe-cache.c \
|
||||
mm-plugin.c \
|
||||
mm-plugin.h \
|
||||
mm-plugin-base.c \
|
||||
mm-plugin-base.h
|
||||
mm-plugin.h
|
||||
|
||||
# Additional dependency rules
|
||||
mm-bearer.c: mm-daemon-enums-types.h
|
||||
|
1138
src/mm-plugin-base.c
1138
src/mm-plugin-base.c
File diff suppressed because it is too large
Load Diff
@@ -1,79 +0,0 @@
|
||||
/* -*- 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 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_PLUGIN_BASE_H
|
||||
#define MM_PLUGIN_BASE_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gudev/gudev.h>
|
||||
|
||||
#include "mm-plugin.h"
|
||||
#include "mm-base-modem.h"
|
||||
#include "mm-port.h"
|
||||
#include "mm-port-probe.h"
|
||||
|
||||
#define MM_TYPE_PLUGIN_BASE (mm_plugin_base_get_type ())
|
||||
#define MM_PLUGIN_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBase))
|
||||
#define MM_PLUGIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass))
|
||||
#define MM_IS_PLUGIN_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_BASE))
|
||||
#define MM_IS_PLUBIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_BASE))
|
||||
#define MM_PLUGIN_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass))
|
||||
|
||||
#define MM_PLUGIN_BASE_NAME "name"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS "allowed-subsystems"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_DRIVERS "allowed-drivers"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS "allowed-vendor-ids"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS "allowed-product-ids"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS "allowed-vendor-strings"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_PRODUCT_STRINGS "allowed-product-strings"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_UDEV_TAGS "allowed-udev-tags"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_AT "allowed-at"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_SINGLE_AT "allowed-single-at"
|
||||
#define MM_PLUGIN_BASE_ALLOWED_QCDM "allowed-qcdm"
|
||||
#define MM_PLUGIN_BASE_CUSTOM_INIT "custom-init"
|
||||
#define MM_PLUGIN_BASE_SEND_DELAY "send-delay"
|
||||
#define MM_PLUGIN_BASE_SORT_LAST "sort-last"
|
||||
|
||||
typedef struct _MMPluginBase MMPluginBase;
|
||||
typedef struct _MMPluginBaseClass MMPluginBaseClass;
|
||||
|
||||
struct _MMPluginBase {
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
struct _MMPluginBaseClass {
|
||||
GObjectClass parent;
|
||||
|
||||
/* Mandatory subclass functions */
|
||||
|
||||
MMBaseModem *(*create_modem) (MMPluginBase *plugin,
|
||||
const gchar *sysfs_path,
|
||||
const gchar *driver,
|
||||
guint16 vendor,
|
||||
guint16 product,
|
||||
GList *probes,
|
||||
GError **error);
|
||||
|
||||
gboolean (*grab_port) (MMPluginBase *plugin,
|
||||
MMBaseModem *modem,
|
||||
MMPortProbe *probe,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
GType mm_plugin_base_get_type (void);
|
||||
|
||||
|
||||
#endif /* MM_PLUGIN_BASE_H */
|
1122
src/mm-plugin.c
1122
src/mm-plugin.c
File diff suppressed because it is too large
Load Diff
127
src/mm-plugin.h
127
src/mm-plugin.h
@@ -11,30 +11,46 @@
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2012 Google, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_PLUGIN_H
|
||||
#define MM_PLUGIN_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gudev/gudev.h>
|
||||
|
||||
#include "mm-base-modem.h"
|
||||
#include "mm-port.h"
|
||||
#include "mm-port-probe.h"
|
||||
|
||||
#define MM_PLUGIN_GENERIC_NAME "Generic"
|
||||
|
||||
#define MM_PLUGIN_MAJOR_VERSION 4
|
||||
#define MM_PLUGIN_MINOR_VERSION 0
|
||||
|
||||
#define MM_TYPE_PLUGIN (mm_plugin_get_type ())
|
||||
#define MM_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN, MMPlugin))
|
||||
#define MM_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN))
|
||||
#define MM_PLUGIN_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_PLUGIN, MMPlugin))
|
||||
#define MM_TYPE_PLUGIN (mm_plugin_get_type ())
|
||||
#define MM_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN, MMPlugin))
|
||||
#define MM_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN, MMPluginClass))
|
||||
#define MM_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN))
|
||||
#define MM_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN))
|
||||
#define MM_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN, MMPluginClass))
|
||||
|
||||
typedef struct _MMPlugin MMPlugin;
|
||||
|
||||
typedef MMPlugin *(*MMPluginCreateFunc) (void);
|
||||
#define MM_PLUGIN_NAME "name"
|
||||
#define MM_PLUGIN_ALLOWED_SUBSYSTEMS "allowed-subsystems"
|
||||
#define MM_PLUGIN_ALLOWED_DRIVERS "allowed-drivers"
|
||||
#define MM_PLUGIN_ALLOWED_VENDOR_IDS "allowed-vendor-ids"
|
||||
#define MM_PLUGIN_ALLOWED_PRODUCT_IDS "allowed-product-ids"
|
||||
#define MM_PLUGIN_ALLOWED_VENDOR_STRINGS "allowed-vendor-strings"
|
||||
#define MM_PLUGIN_ALLOWED_PRODUCT_STRINGS "allowed-product-strings"
|
||||
#define MM_PLUGIN_ALLOWED_UDEV_TAGS "allowed-udev-tags"
|
||||
#define MM_PLUGIN_ALLOWED_AT "allowed-at"
|
||||
#define MM_PLUGIN_ALLOWED_SINGLE_AT "allowed-single-at"
|
||||
#define MM_PLUGIN_ALLOWED_QCDM "allowed-qcdm"
|
||||
#define MM_PLUGIN_CUSTOM_INIT "custom-init"
|
||||
#define MM_PLUGIN_SEND_DELAY "send-delay"
|
||||
#define MM_PLUGIN_SORT_LAST "sort-last"
|
||||
|
||||
typedef enum {
|
||||
MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED = 0x0,
|
||||
@@ -43,73 +59,56 @@ typedef enum {
|
||||
MM_PLUGIN_SUPPORTS_PORT_SUPPORTED
|
||||
} MMPluginSupportsResult;
|
||||
|
||||
typedef struct _MMPlugin MMPlugin;
|
||||
typedef struct _MMPluginClass MMPluginClass;
|
||||
|
||||
typedef MMPlugin *(*MMPluginCreateFunc) (void);
|
||||
|
||||
struct _MMPlugin {
|
||||
GTypeInterface g_iface;
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
/* Get plugin name */
|
||||
const char *(*get_name) (MMPlugin *self);
|
||||
struct _MMPluginClass {
|
||||
GObjectClass parent;
|
||||
|
||||
/* Returns TRUE if the plugin should be sorted last in the list of plugins
|
||||
* loaded. This is useful to indicate plugins that need an additional check
|
||||
* on the probed vendor ID to see if they can support it. */
|
||||
gboolean (*get_sort_last) (const MMPlugin *self);
|
||||
/* Mandatory subclass functions */
|
||||
|
||||
/* Check whether a plugin supports a particular modem port, and what level
|
||||
* of support the plugin has for the device.
|
||||
* The check is done always asynchronously. When the result of the check is
|
||||
* ready, the passed callback will be called, and the result will be ready
|
||||
* to get retrieved with supports_port_finish().
|
||||
*/
|
||||
void (* supports_port) (MMPlugin *self,
|
||||
const gchar *subsys,
|
||||
const gchar *name,
|
||||
const gchar *physdev_path,
|
||||
MMBaseModem *existing,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
/* Plugins need to provide a method to create a modem object given
|
||||
* a list of port probes */
|
||||
MMBaseModem *(*create_modem) (MMPlugin *plugin,
|
||||
const gchar *sysfs_path,
|
||||
const gchar *driver,
|
||||
guint16 vendor,
|
||||
guint16 product,
|
||||
GList *probes,
|
||||
GError **error);
|
||||
|
||||
/* Allows to get the result of an asynchronous port support check. */
|
||||
MMPluginSupportsResult (* supports_port_finish) (MMPlugin *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
/* Called to cancel an ongoing supports_port() operation or to notify the
|
||||
* plugin to clean up that operation. For example, if two plugins support
|
||||
* a particular port, but the first plugin grabs the port, this method will
|
||||
* be called on the second plugin to allow that plugin to clean up resources
|
||||
* used while determining it's level of support for the port.
|
||||
*/
|
||||
void (*supports_port_cancel) (MMPlugin *self,
|
||||
const char *subsys,
|
||||
const char *name);
|
||||
|
||||
/* Given all the list of ports, launch creation of a new modem object */
|
||||
MMBaseModem * (*create_modem) (MMPlugin *self,
|
||||
GList *ports,
|
||||
GError **error);
|
||||
/* Plugins need to provide a method to grab independent ports
|
||||
* identified by port probes */
|
||||
gboolean (*grab_port) (MMPlugin *plugin,
|
||||
MMBaseModem *modem,
|
||||
MMPortProbe *probe,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
GType mm_plugin_get_type (void);
|
||||
|
||||
const char *mm_plugin_get_name (MMPlugin *plugin);
|
||||
|
||||
gboolean mm_plugin_get_sort_last (const MMPlugin *plugin);
|
||||
|
||||
void mm_plugin_supports_port (MMPlugin *plugin,
|
||||
const gchar *subsys,
|
||||
const gchar *name,
|
||||
const gchar *physdev_path,
|
||||
MMBaseModem *existing,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
const char *mm_plugin_get_name (MMPlugin *plugin);
|
||||
gboolean mm_plugin_get_sort_last (const MMPlugin *plugin);
|
||||
|
||||
void mm_plugin_supports_port (MMPlugin *plugin,
|
||||
const gchar *subsys,
|
||||
const gchar *name,
|
||||
const gchar *physdev_path,
|
||||
MMBaseModem *existing,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
MMPluginSupportsResult mm_plugin_supports_port_finish (MMPlugin *plugin,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
void mm_plugin_supports_port_cancel (MMPlugin *plugin,
|
||||
const char *subsys,
|
||||
const char *name);
|
||||
void mm_plugin_supports_port_cancel (MMPlugin *plugin,
|
||||
const char *subsys,
|
||||
const char *name);
|
||||
|
||||
MMBaseModem *mm_plugin_create_modem (MMPlugin *plugin,
|
||||
GList *ports,
|
||||
|
Reference in New Issue
Block a user