aboutsummaryrefslogtreecommitdiff
path: root/src/mm-plugin.h
blob: 696cf668ac2532481eb051e3c571303d7ae09353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

#ifndef MM_PLUGIN_H
#define MM_PLUGIN_H

#include <glib-object.h>
#include <mm-modem.h>

#define MM_PLUGIN_MAJOR_VERSION 3
#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))

typedef struct _MMPlugin MMPlugin;

typedef MMPlugin *(*MMPluginCreateFunc) (void);

struct _MMPlugin {
    GTypeInterface g_iface;

    /* Methods */
    const char *(*get_name)   (MMPlugin *self);

    /* Check whether a plugin supports a particular modem port, and what level
     * of support the plugin has for the device.  The plugin should return a
     * value between 0 and 100 inclusive, where 0 means the plugin has no
     * support for the device, and 100 means the plugin has full support for the
     * device.
     */
    guint32 (*supports_port)  (MMPlugin *self,
                               const char *subsys,
                               const char *name);

    /* Will only be called if the plugin returns a value greater than 0 for
     * the supports_port() method for this port.  The plugin should create and
     * return a  new modem for the port's device if there is no existing modem
     * to handle the port's hardware device, or should add the port to an
     * existing modem and return that modem object.  If an error is encountered
     * while claiming the port, the error information should be returned in the
     * error argument, and the plugin should return NULL.
     */
    MMModem * (*grab_port)    (MMPlugin *self,
                               const char *subsys,
                               const char *name,
                               GError **error);
};

GType mm_plugin_get_type (void);

const char *mm_plugin_get_name   (MMPlugin *plugin);

guint32 mm_plugin_supports_port  (MMPlugin *plugin,
                                  const char *subsys,
                                  const char *name);

MMModem *mm_plugin_grab_port     (MMPlugin *plugin,
                                  const char *subsys,
                                  const char *name,
                                  GError **error);

#endif /* MM_PLUGIN_H */