summaryrefslogtreecommitdiff
path: root/osinfo/osinfo_device.c
blob: b1e3ea03a6d63d86eb64af6b9083239f028ec1cb (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
/*
 * libosinfo:
 *
 * Copyright (C) 2009-2020 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 */

#include <osinfo/osinfo.h>
#include <glib/gi18n-lib.h>

/**
 * SECTION:osinfo_device
 * @short_description: A hardware device
 * @see_also: #OsinfoOs, #OsinfoPlatform
 *
 * #OsinfoDevice is an entity representing some kind of hardware
 * device. Devices can be associated with operating systems
 * and platforms.
 */

struct _OsinfoDevicePrivate
{
    gboolean unused;
};

G_DEFINE_TYPE_WITH_PRIVATE(OsinfoDevice, osinfo_device, OSINFO_TYPE_ENTITY);

static void osinfo_device_finalize(GObject *object);

static void
osinfo_device_finalize(GObject *object)
{
    /* Chain up to the parent class */
    G_OBJECT_CLASS(osinfo_device_parent_class)->finalize(object);
}

/* Init functions */
static void
osinfo_device_class_init(OsinfoDeviceClass *klass)
{
    GObjectClass *g_klass = G_OBJECT_CLASS(klass);

    g_klass->finalize = osinfo_device_finalize;
}

static void
osinfo_device_init(OsinfoDevice *device)
{
    device->priv = osinfo_device_get_instance_private(device);
}

OsinfoDevice *osinfo_device_new(const gchar *id)
{
    return g_object_new(OSINFO_TYPE_DEVICE,
                        "id", id,
                        NULL);
}


const gchar *osinfo_device_get_vendor(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_VENDOR);
}

const gchar *osinfo_device_get_vendor_id(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_VENDOR_ID);
}

const gchar *osinfo_device_get_product(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_PRODUCT);
}

const gchar *osinfo_device_get_product_id(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_PRODUCT_ID);
}

const gchar *osinfo_device_get_bus_type(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_BUS_TYPE);
}

const gchar *osinfo_device_get_class(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_CLASS);
}

const gchar *osinfo_device_get_name(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_NAME);
}

/**
 * osinfo_device_get_subsystem:
 * @dev: the device
 *
 * Returns: the value of the device's subsystem.
 *
 * Since: 0.2.1
 */
const gchar *osinfo_device_get_subsystem(OsinfoDevice *dev)
{
    return osinfo_entity_get_param_value(OSINFO_ENTITY(dev), OSINFO_DEVICE_PROP_SUBSYSTEM);
}