aboutsummaryrefslogtreecommitdiff
path: root/src/mm-port-probe.h
blob: 669578a713b101ef7c0e60c18f1353e771dd92ba (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
/* -*- 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 Aleksander Morgado <aleksander@gnu.org>
 */

#ifndef MM_PORT_PROBE_H
#define MM_PORT_PROBE_H

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gudev/gudev.h>

#include "mm-port-probe-at.h"
#include "mm-at-serial-port.h"

#define MM_TYPE_PORT_PROBE            (mm_port_probe_get_type ())
#define MM_PORT_PROBE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PORT_PROBE, MMPortProbe))
#define MM_PORT_PROBE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  MM_TYPE_PORT_PROBE, MMPortProbeClass))
#define MM_IS_PORT_PROBE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PORT_PROBE))
#define MM_IS_PLUBIN_PROBE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  MM_TYPE_PORT_PROBE))
#define MM_PORT_PROBE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  MM_TYPE_PORT_PROBE, MMPortProbeClass))

/* Flags to request port probing */
typedef enum { /*< underscore_name=mm_port_probe_flag >*/
	MM_PORT_PROBE_NONE       = 0,
	MM_PORT_PROBE_AT         = 1 << 0,
	MM_PORT_PROBE_AT_VENDOR  = 1 << 1,
	MM_PORT_PROBE_AT_PRODUCT = 1 << 2,
	MM_PORT_PROBE_QCDM       = 1 << 3,
} MMPortProbeFlag;

typedef struct _MMPortProbe MMPortProbe;
typedef struct _MMPortProbeClass MMPortProbeClass;
typedef struct _MMPortProbePrivate MMPortProbePrivate;

struct _MMPortProbe {
    GObject parent;
    MMPortProbePrivate *priv;
};

struct _MMPortProbeClass {
    GObjectClass parent;
};

GType mm_port_probe_get_type (void);

MMPortProbe *mm_port_probe_new (GUdevDevice *port,
                                const gchar *physdev_path,
                                const gchar *driver);

GUdevDevice *mm_port_probe_get_port         (MMPortProbe *self);
const gchar *mm_port_probe_get_port_name    (MMPortProbe *self);
const gchar *mm_port_probe_get_port_subsys  (MMPortProbe *self);
const gchar *mm_port_probe_get_port_physdev (MMPortProbe *self);
const gchar *mm_port_probe_get_port_driver  (MMPortProbe *self);

/* Probing result setters */
void mm_port_probe_set_result_at         (MMPortProbe *self,
                                          gboolean at);
void mm_port_probe_set_result_at_vendor  (MMPortProbe *self,
                                          const gchar *at_vendor);
void mm_port_probe_set_result_at_product (MMPortProbe *self,
                                          const gchar *at_product);
void mm_port_probe_set_result_qcdm       (MMPortProbe *self,
                                          gboolean qcdm);

/* Run probing */
void     mm_port_probe_run        (MMPortProbe *self,
                                   MMPortProbeFlag flags,
                                   guint64 at_send_delay,
                                   const MMPortProbeAtCommand *at_custom_init,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data);
gboolean mm_port_probe_run_finish (MMPortProbe *self,
                                   GAsyncResult *result,
                                   GError **error);
gboolean mm_port_probe_run_cancel (MMPortProbe *self);

gboolean mm_port_probe_run_cancel_at_probing (MMPortProbe *self);

/* Probing result getters */
MMPortType    mm_port_probe_get_port_type    (MMPortProbe *self);
gboolean      mm_port_probe_is_at            (MMPortProbe *self);
gboolean      mm_port_probe_is_qcdm          (MMPortProbe *self);
const gchar  *mm_port_probe_get_vendor       (MMPortProbe *self);
const gchar  *mm_port_probe_get_product      (MMPortProbe *self);

#endif /* MM_PORT_PROBE_H */