summaryrefslogtreecommitdiff
path: root/panels/network/wireless-security/eap-method.h
blob: bd8875a8cd24274d8dbd7506fb4b2f329ef7562b (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
120
121
122
123
124
125
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager Applet -- allow user control over networking
 *
 * Dan Williams <dcbw@redhat.com>
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Copyright 2007 - 2014 Red Hat, Inc.
 */

#ifndef EAP_METHOD_H
#define EAP_METHOD_H

#include <NetworkManager.h>

typedef struct _EAPMethod EAPMethod;

typedef void        (*EMAddToSizeGroupFunc) (EAPMethod *method, GtkSizeGroup *group);
typedef void        (*EMFillConnectionFunc) (EAPMethod *method, NMConnection *connection, NMSettingSecretFlags flags);
typedef void        (*EMUpdateSecretsFunc)  (EAPMethod *method, NMConnection *connection);
typedef void        (*EMDestroyFunc)        (EAPMethod *method);
typedef gboolean    (*EMValidateFunc)       (EAPMethod *method, GError **error);
typedef GtkWidget*  (*EMGetWidgetFunc)      (EAPMethod *method);
typedef const gchar* (*EMGetStringFunc)     (EAPMethod *method);

struct _EAPMethod {
	guint32 refcount;
	gsize obj_size;

	gboolean phase2;

	EMAddToSizeGroupFunc add_to_size_group;
	EMFillConnectionFunc fill_connection;
	EMUpdateSecretsFunc update_secrets;
	EMValidateFunc validate;
	EMGetWidgetFunc get_widget;
	EMGetWidgetFunc get_default_field;
	EMGetStringFunc get_password_flags_name;
	EMDestroyFunc destroy;
};

#define EAP_METHOD(x) ((EAPMethod *) x)


GtkWidget *eap_method_get_widget (EAPMethod *method);

GtkWidget *eap_method_get_default_field (EAPMethod *method);

const gchar *eap_method_get_password_flags_name (EAPMethod *method);

gboolean eap_method_validate (EAPMethod *method, GError **error);

void eap_method_add_to_size_group (EAPMethod *method, GtkSizeGroup *group);

void eap_method_fill_connection (EAPMethod *method,
                                 NMConnection *connection,
                                 NMSettingSecretFlags flags);

EAPMethod *eap_method_ref (EAPMethod *method);

void eap_method_unref (EAPMethod *method);

GType eap_method_get_type (void);

/* Below for internal use only */

EAPMethod *eap_method_init (gsize obj_size,
                            EMValidateFunc validate,
                            EMAddToSizeGroupFunc add_to_size_group,
                            EMFillConnectionFunc fill_connection,
                            EMUpdateSecretsFunc update_secrets,
                            EMGetWidgetFunc get_widget,
                            EMGetWidgetFunc get_default_field,
                            EMGetStringFunc get_password_flags_name,
                            EMDestroyFunc destroy,
                            gboolean phase2);

GtkFileFilter * eap_method_default_file_chooser_filter_new (gboolean privkey);

gboolean eap_method_is_encrypted_private_key (const char *path);

#define TYPE_CLIENT_CERT 0
#define TYPE_CA_CERT     1
#define TYPE_PRIVATE_KEY 2

gboolean eap_method_validate_filepicker (GtkFileChooser *chooser,
                                         guint32 item_type,
                                         const char *password,
                                         NMSetting8021xCKFormat *out_format,
                                         GError **error);

void eap_method_phase2_update_secrets_helper (EAPMethod *method,
                                              NMConnection *connection,
                                              GtkComboBox *combo,
                                              guint32 column);

gboolean eap_method_ca_cert_required (GtkToggleButton *id_ca_cert_is_not_required_checkbutton,
                                      GtkFileChooser *id_ca_cert_chooser);
void eap_method_ca_cert_not_required_toggled (GtkToggleButton *id_ca_cert_is_not_required_checkbox,
                                              GtkFileChooser *id_ca_cert_chooser);

void eap_method_ca_cert_ignore_set (EAPMethod *method,
                                    NMConnection *connection,
                                    const char *filename,
                                    gboolean ca_cert_error);
gboolean eap_method_ca_cert_ignore_get (EAPMethod *method, NMConnection *connection);

void eap_method_ca_cert_ignore_save (NMConnection *connection);
void eap_method_ca_cert_ignore_load (NMConnection *connection);

G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethod, eap_method_unref)

#endif /* EAP_METHOD_H */