~snapd-glib-team/snapd-glib/master

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
/*
 * Copyright (C) 2019 Canonical Ltd.
 *
 * 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 or version 3 of the License.
 * See http://www.gnu.org/copyleft/lgpl.html the full text of the license.
 */

#include <snapd-glib/snapd-glib.h>

#include "Snapd/interface.h"

QSnapdInterface::QSnapdInterface (void *snapd_object, QObject *parent) : QSnapdWrappedObject (g_object_ref (snapd_object), g_object_unref, parent) {}

QString QSnapdInterface::name () const
{
    return snapd_interface_get_name (SNAPD_INTERFACE (wrapped_object));
}

QString QSnapdInterface::summary () const
{
    return snapd_interface_get_summary (SNAPD_INTERFACE (wrapped_object));
}

QString QSnapdInterface::docUrl () const
{
    return snapd_interface_get_doc_url (SNAPD_INTERFACE (wrapped_object));
}

int QSnapdInterface::slotCount () const
{
    GPtrArray *slots;

    slots = snapd_interface_get_slots (SNAPD_INTERFACE (wrapped_object));
    return slots != NULL ? slots->len : 0;
}

QSnapdSlot *QSnapdInterface::slot (int n) const
{
    GPtrArray *slots;

    slots = snapd_interface_get_slots (SNAPD_INTERFACE (wrapped_object));
    if (slots == NULL || n < 0 || (guint) n >= slots->len)
        return NULL;
    return new QSnapdSlot (slots->pdata[n]);
}

int QSnapdInterface::plugCount () const
{
    GPtrArray *plugs;

    plugs = snapd_interface_get_plugs (SNAPD_INTERFACE (wrapped_object));
    return plugs != NULL ? plugs->len : 0;
}

QSnapdPlug *QSnapdInterface::plug (int n) const
{
    GPtrArray *plugs;

    plugs = snapd_interface_get_plugs (SNAPD_INTERFACE (wrapped_object));
    if (plugs == NULL || n < 0 || (guint) n >= plugs->len)
        return NULL;
    return new QSnapdPlug (plugs->pdata[n]);
}

QString QSnapdInterface::makeLabel () const
{
    g_autofree gchar *label = snapd_interface_make_label (SNAPD_INTERFACE (wrapped_object));
    return label;
}