SnapdConnection: snapd-glib Reference Manual

## SnapdConnection SnapdConnection — Plug to slot connections |

## Functions

const gchar * | snapd_connection_get_interface ()
SnapdSlotRef * | snapd_connection_get_slot ()
SnapdPlugRef * | snapd_connection_get_plug ()
gboolean | snapd_connection_get_manual ()
gboolean | snapd_connection_get_gadget ()
GStrv | snapd_connection_get_slot_attribute_names ()
gboolean | snapd_connection_has_slot_attribute ()
GVariant * | snapd_connection_get_slot_attribute ()
GStrv | snapd_connection_get_plug_attribute_names ()
gboolean | snapd_connection_has_plug_attribute ()
GVariant * | snapd_connection_get_plug_attribute ()
const gchar * | snapd_connection_get_name ()
const gchar * | snapd_connection_get_snap ()

## Properties

gboolean | gadget | Read / Write / Construct Only
char * | interface | Read / Write / Construct Only
gboolean | manual | Read / Write / Construct Only
char * | name | Read / Write / Construct Only
SnapdPlugRef * | plug | Read / Write / Construct Only
GHashTable * | plug-attrs | Read / Write / Construct Only
SnapdSlotRef * | slot | Read / Write / Construct Only
GHashTable * | slot-attrs | Read / Write / Construct Only
char * | snap | Read / Write / Construct Only

## Types and Values

| SnapdConnection

## Object Hierarchy

        GObject
        ╰── SnapdConnection

## Includes

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

## Description

A SnapdConnection contains information about how a SnapdPlug is connected to a SnapdSlot. Connections are queried using `snapd_client_get_connections_sync()`.

## Functions

### snapd_connection_get_interface ()

    const gchar *
    snapd_connection_get_interface (SnapdConnection *connection);

Get the interface this connections uses.

#### Parameters

connection | a SnapdConnection. |

#### Returns

an interface name.

Since: 1.48

### snapd_connection_get_slot ()

    SnapdSlotRef *
    snapd_connection_get_slot (SnapdConnection *connection);

Get the slot this connection is made with.

#### Parameters

connection | a SnapdConnection. |

#### Returns

a reference to a slot.

[transfer none]

Since: 1.48

### snapd_connection_get_plug ()

    SnapdPlugRef *
    snapd_connection_get_plug (SnapdConnection *connection);

Get the plug this connection is made with.

#### Parameters

connection | a SnapdConnection. |

#### Returns

a reference to a plug.

[transfer none]

Since: 1.48

### snapd_connection_get_manual ()

    gboolean
    snapd_connection_get_manual (SnapdConnection *connection);

Get if this connection was made manually.

#### Parameters

connection | a SnapdConnection. |

#### Returns

`TRUE` if connection was made manually.

Since: 1.48

### snapd_connection_get_gadget ()

    gboolean
    snapd_connection_get_gadget (SnapdConnection *connection);

Get if this connection was made by the gadget snap.

#### Parameters

connection | a SnapdConnection. |

#### Returns

`TRUE` if connection was made by the gadget snap.

Since: 1.48

### snapd_connection_get_slot_attribute_names ()

    GStrv
    snapd_connection_get_slot_attribute_names
                                   (SnapdConnection *connection,
                                    guint *length);

Get the names of the attributes the connected slot has.

#### Parameters

connection | a SnapdConnection. |
length | location to write number of attributes or `NULL` if not required. | [out][allow-none]

#### Returns

a string array of attribute names. Free with `g_strfreev()`.

[transfer full][array zero-terminated=1]

Since: 1.48

### snapd_connection_has_slot_attribute ()

    gboolean
    snapd_connection_has_slot_attribute (SnapdConnection *connection,
                                         const gchar *name);

Check if the connected slot has an attribute.

#### Parameters

connection | a SnapdConnection. |
name | an attribute name. |

#### Returns

`TRUE` if this attribute exists.

Since: 1.48

### snapd_connection_get_slot_attribute ()

    GVariant *
    snapd_connection_get_slot_attribute (SnapdConnection *connection,
                                         const gchar *name);

Get an attribute for connected slot.

#### Parameters

connection | a SnapdConnection. |
name | an attribute name. |

#### Returns

an attribute value or `NULL` if not set.

[transfer none][allow-none]

Since: 1.48

### snapd_connection_get_plug_attribute_names ()

    GStrv
    snapd_connection_get_plug_attribute_names
                                   (SnapdConnection *connection,
                                    guint *length);

Get the names of the attributes the connected plug has.

#### Parameters

connection | a SnapdConnection. |
length | location to write number of attributes or `NULL` if not required. | [out][allow-none]

#### Returns

a string array of attribute names. Free with `g_strfreev()`.

[transfer full][array zero-terminated=1]

Since: 1.48

### snapd_connection_has_plug_attribute ()

    gboolean
    snapd_connection_has_plug_attribute (SnapdConnection *connection,
                                         const gchar *name);

Check if the connected plug has an attribute.

#### Parameters

connection | a SnapdConnection. |
name | an attribute name. |

#### Returns

`TRUE` if this attribute exists.

Since: 1.48

### snapd_connection_get_plug_attribute ()

    GVariant *
    snapd_connection_get_plug_attribute (SnapdConnection *connection,
                                         const gchar *name);

Get an attribute for connected plug.

#### Parameters

connection | a SnapdConnection. |
name | an attribute name. |

#### Returns

an attribute value or `NULL` if not set.

[transfer none][allow-none]

Since: 1.48

### snapd_connection_get_name ()

    const gchar *
    snapd_connection_get_name (SnapdConnection *connection);

`snapd_connection_get_name` has been deprecated since version 1.48 and should not be used in newly-written code.

Use `snapd_plug_ref_get_plug()` or `snapd_slot_ref_get_slot()`

Get the name of this connection (i.e. a slot or plug name).

#### Parameters

connection | a SnapdConnection. |

#### Returns

a name.

Since: 1.0

### snapd_connection_get_snap ()

    const gchar *
    snapd_connection_get_snap (SnapdConnection *connection);

`snapd_connection_get_snap` has been deprecated since version 1.48 and should not be used in newly-written code.

Use `snapd_plug_ref_get_snap()` or `snapd_slot_ref_get_snap()`

Get the snap this connection is on.

#### Parameters

connection | a SnapdConnection. |

#### Returns

a snap name.

Since: 1.0

## Types and Values

### SnapdConnection

    typedef struct _SnapdConnection SnapdConnection;

SnapdConnection contains the state of Snap a interface connection.

Since: 1.0

## Property Details

### The `“gadget”` property

      “gadget”                   gboolean

TRUE if connection was made by the gadget snap.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

Default value: FALSE

### The `“interface”` property

      “interface”                char *

Interface this connection uses.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

Default value: NULL

### The `“manual”` property

      “manual”                   gboolean

TRUE if connection was made manually.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

Default value: FALSE

### The `“name”` property

      “name”                     char *

Name of connection/plug on snap.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

Default value: NULL

### The `“plug”` property

      “plug”                     SnapdPlugRef *

Plug this connection is made with.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

### The `“plug-attrs”` property

      “plug-attrs”               GHashTable *

Attributes for connected plug.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

### The `“slot”` property

      “slot”                     SnapdSlotRef *

Slot this connection is made with.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

### The `“slot-attrs”` property

      “slot-attrs”               GHashTable *

Attributes for connected slot.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

### The `“snap”` property

      “snap”                     char *

Snap this connection is made to.

Owner: SnapdConnection

Flags: Read / Write / Construct Only

Default value: NULL