summaryrefslogtreecommitdiff
path: root/libnm-util/nm-setting.h
blob: 181e141f699ac175cb0dec8afeb08e8f2666d59c (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
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */

#ifndef NM_SETTING_H
#define NM_SETTING_H

#include <glib/gtypes.h>
#include <glib-object.h>

G_BEGIN_DECLS

#define NM_TYPE_SETTING            (nm_setting_get_type ())
#define NM_SETTING(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING, NMSetting))
#define NM_SETTING_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING, NMSettingClass))
#define NM_IS_SETTING(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING))
#define NM_IS_SETTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING))
#define NM_SETTING_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING, NMSettingClass))

#define NM_SETTING_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
#define NM_SETTING_PARAM_REQUIRED  (1 << (1 + G_PARAM_USER_SHIFT))
#define NM_SETTING_PARAM_SECRET    (1 << (2 + G_PARAM_USER_SHIFT))

#define NM_SETTING_NAME "name"

typedef struct {
	GObject parent;

	char *name;
} NMSetting;

typedef struct {
	GObjectClass parent;

	/* Virtual functions */
	gboolean    (*verify)            (NMSetting  *setting,
	                                  GSList     *all_settings);

	GPtrArray  *(*need_secrets)      (NMSetting  *setting);

	void        (*update_one_secret) (NMSetting  *setting,
	                                  const char *key,
	                                  GValue     *value);
} NMSettingClass;

typedef void (*NMSettingValueIterFn) (NMSetting *setting,
							   const char *key,
							   const GValue *value,
							   gboolean secret,
							   gpointer user_data);


GType nm_setting_get_type (void);

GHashTable *nm_setting_to_hash       (NMSetting *setting);
NMSetting  *nm_setting_from_hash     (GType setting_type,
							   GHashTable *hash);

const char *nm_setting_get_name      (NMSetting *setting);

gboolean    nm_setting_verify        (NMSetting *setting,
							   GSList    *all_settings);

gboolean    nm_setting_compare       (NMSetting *setting,
							   NMSetting *other);

void        nm_setting_enumerate_values (NMSetting *setting,
                                         NMSettingValueIterFn func,
                                         gpointer user_data);

char       *nm_setting_to_string      (NMSetting *setting);

/* Secrets */
void        nm_setting_clear_secrets  (NMSetting *setting);
GPtrArray  *nm_setting_need_secrets   (NMSetting *setting);
void        nm_setting_update_secrets (NMSetting *setting,
							    GHashTable *secrets);

G_END_DECLS

#endif /* NM_SETTING_H */