aboutsummaryrefslogtreecommitdiff
path: root/src/mm-plugin-base.h
blob: a32d53bfa1e0526438418bfe20475532e4079d7d (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* -*- 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/gtypes.h>
#include <glib-object.h>

#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
#include <gudev/gudev.h>

#include "mm-plugin.h"
#include "mm-modem.h"
#include "mm-port.h"

#define MM_PLUGIN_BASE_PORT_CAP_GSM         0x0001 /* GSM */
#define MM_PLUGIN_BASE_PORT_CAP_IS707_A     0x0002 /* CDMA Circuit Switched Data */
#define MM_PLUGIN_BASE_PORT_CAP_IS707_P     0x0004 /* CDMA Packet Switched Data */
#define MM_PLUGIN_BASE_PORT_CAP_DS          0x0008 /* Data compression selection (v.42bis) */
#define MM_PLUGIN_BASE_PORT_CAP_ES          0x0010 /* Error control selection (v.42) */
#define MM_PLUGIN_BASE_PORT_CAP_FCLASS      0x0020 /* Group III Fax */
#define MM_PLUGIN_BASE_PORT_CAP_MS          0x0040 /* Modulation selection */
#define MM_PLUGIN_BASE_PORT_CAP_W           0x0080 /* Wireless commands */
#define MM_PLUGIN_BASE_PORT_CAP_IS856       0x0100 /* CDMA 3G EVDO rev 0 */
#define MM_PLUGIN_BASE_PORT_CAP_IS856_A     0x0200 /* CDMA 3G EVDO rev A */
#define MM_PLUGIN_BASE_PORT_CAP_QCDM        0x0400 /* QCDM-capable port */

#define MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK            (mm_plugin_base_supports_task_get_type ())
#define MM_PLUGIN_BASE_SUPPORTS_TASK(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK, MMPluginBaseSupportsTask))
#define MM_PLUGIN_BASE_SUPPORTS_TASK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK, MMPluginBaseSupportsTaskClass))
#define MM_IS_PLUGIN_BASE_SUPPORTS_TASK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK))
#define MM_IS_PLUBIN_BASE_SUPPORTS_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK))
#define MM_PLUGIN_BASE_SUPPORTS_TASK_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK, MMPluginBaseSupportsTaskClass))

typedef struct {
    GObject parent;
} MMPluginBaseSupportsTask;

typedef struct {
    GObjectClass parent;
} MMPluginBaseSupportsTaskClass;

GType mm_plugin_base_supports_task_get_type (void);

MMPlugin *mm_plugin_base_supports_task_get_plugin (MMPluginBaseSupportsTask *task);

GUdevDevice *mm_plugin_base_supports_task_get_port (MMPluginBaseSupportsTask *task);

const char *mm_plugin_base_supports_task_get_physdev_path (MMPluginBaseSupportsTask *task);

const char *mm_plugin_base_supports_task_get_driver (MMPluginBaseSupportsTask *task);

guint32 mm_plugin_base_supports_task_get_probed_capabilities (MMPluginBaseSupportsTask *task);

void mm_plugin_base_supports_task_complete (MMPluginBaseSupportsTask *task,
                                            guint32 level);

void mm_plugin_base_supports_task_set_custom_init_command (MMPluginBaseSupportsTask *task,
                                                           const char *cmd,
                                                           guint32 delay_seconds,
                                                           guint32 max_tries,
                                                           gboolean fail_if_timeout);

#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"

typedef struct _MMPluginBase MMPluginBase;
typedef struct _MMPluginBaseClass MMPluginBaseClass;

struct _MMPluginBase {
    GObject parent;
};

struct _MMPluginBaseClass {
    GObjectClass parent;

    /* Mandatory subclass functions */
    MMPluginSupportsResult (*supports_port) (MMPluginBase *plugin,
                                             MMModem *existing,
                                             MMPluginBaseSupportsTask *task);

    MMModem *(*grab_port)     (MMPluginBase *plugin,
                               MMModem *existing,
                               MMPluginBaseSupportsTask *task,
                               GError **error);

    /* Optional subclass functions */
    void (*cancel_task)       (MMPluginBase *plugin,
                               MMPluginBaseSupportsTask *task);

    void (*handle_probe_response) (MMPluginBase *plugin,
                                   MMPluginBaseSupportsTask *task,
                                   const char *command,
                                   const char *response,
                                   const GError *error);

    /* Signals */
    void (*probe_result) (MMPluginBase *self,
                          MMPluginBaseSupportsTask *task,
                          guint32 capabilities);
};

GType mm_plugin_base_get_type (void);

gboolean mm_plugin_base_get_device_ids (MMPluginBase *self,
                                        const char *subsys,
                                        const char *name,
                                        guint16 *vendor,
                                        guint16 *product);

gboolean mm_plugin_base_probe_port (MMPluginBase *self,
                                    MMPluginBaseSupportsTask *task,
                                    GError **error);

/* Returns TRUE if the port was previously probed, FALSE if not */
gboolean mm_plugin_base_get_cached_port_capabilities (MMPluginBase *self,
                                                      GUdevDevice *port,
                                                      guint32 *capabilities);

#endif /* MM_PLUGIN_BASE_H */