1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* NetworkManager Connection editor -- Connection editor for NetworkManager
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
* Copyright 2012 Red Hat, Inc.
24
#include <glib/gi18n.h>
26
#include <nm-setting-connection.h>
27
#include <nm-setting-wimax.h>
28
#include <nm-device-wimax.h>
31
#include "page-wimax.h"
33
G_DEFINE_TYPE (CEPageWimax, ce_page_wimax, CE_TYPE_PAGE)
35
#define CE_PAGE_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CE_TYPE_PAGE_WIMAX, CEPageWimaxPrivate))
38
NMSettingWimax *setting;
41
#if GTK_CHECK_VERSION (2,24,0)
42
GtkComboBoxText *device_mac; /* Permanent MAC of the device */
44
GtkComboBoxEntry *device_mac;
51
wimax_private_init (CEPageWimax *self)
53
CEPageWimaxPrivate *priv = CE_PAGE_WIMAX_GET_PRIVATE (self);
58
builder = CE_PAGE (self)->builder;
60
priv->name = GTK_ENTRY (gtk_builder_get_object (builder, "wimax_name"));
62
#if GTK_CHECK_VERSION(2,24,0)
63
priv->device_mac = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new_with_entry ());
64
gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->device_mac), 0);
66
priv->device_mac = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new_text ());
67
gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (priv->device_mac), 0);
69
gtk_widget_set_tooltip_text (GTK_WIDGET (priv->device_mac),
70
_("This option locks this connection to the network device specified by its permanent MAC address entered here. Example: 00:11:22:33:44:55"));
72
align = GTK_WIDGET (gtk_builder_get_object (builder, "wimax_device_mac_alignment"));
73
gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (priv->device_mac));
74
gtk_widget_show_all (GTK_WIDGET (priv->device_mac));
76
/* Set mnemonic widget for device MAC label */
77
label = GTK_LABEL (GTK_WIDGET (gtk_builder_get_object (builder, "wimax_device_mac_label")));
78
gtk_label_set_mnemonic_widget (label, GTK_WIDGET (priv->device_mac));
82
populate_ui (CEPageWimax *self)
84
CEPageWimaxPrivate *priv = CE_PAGE_WIMAX_GET_PRIVATE (self);
85
NMSettingWimax *setting = priv->setting;
87
const GByteArray *s_mac;
90
gtk_entry_set_text (priv->name, nm_setting_wimax_get_network_name (setting));
91
g_signal_connect_swapped (priv->name, "changed", G_CALLBACK (ce_page_changed), self);
93
/* Device MAC address */
94
mac_list = ce_page_get_mac_list (CE_PAGE (self), NM_TYPE_DEVICE_WIMAX,
95
NM_DEVICE_WIMAX_HW_ADDRESS);
96
s_mac = nm_setting_wimax_get_mac_address (setting);
97
s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_ETHER) : NULL;
98
ce_page_setup_mac_combo (CE_PAGE (self), GTK_COMBO_BOX (priv->device_mac),
101
g_strfreev (mac_list);
102
g_signal_connect_swapped (priv->device_mac, "changed", G_CALLBACK (ce_page_changed), self);
106
finish_setup (CEPageWimax *self, gpointer unused, GError *error, gpointer user_data)
115
ce_page_wimax_new (NMConnection *connection,
116
GtkWindow *parent_window,
118
NMRemoteSettings *settings,
119
const char **out_secrets_setting_name,
123
CEPageWimaxPrivate *priv;
125
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
127
self = CE_PAGE_WIMAX (ce_page_new (CE_TYPE_PAGE_WIMAX,
132
UIDIR "/ce-page-wimax.ui",
136
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC,
137
_("Could not load WiMAX user interface."));
141
wimax_private_init (self);
142
priv = CE_PAGE_WIMAX_GET_PRIVATE (self);
144
priv->setting = nm_connection_get_setting_wimax (connection);
145
if (!priv->setting) {
146
priv->setting = NM_SETTING_WIMAX (nm_setting_wimax_new ());
147
nm_connection_add_setting (connection, NM_SETTING (priv->setting));
150
g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
152
return CE_PAGE (self);
156
ui_to_setting (CEPageWimax *self)
158
CEPageWimaxPrivate *priv = CE_PAGE_WIMAX_GET_PRIVATE (self);
160
GByteArray *device_mac = NULL;
163
name = gtk_entry_get_text (priv->name);
165
entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
167
device_mac = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, NULL);
169
g_object_set (priv->setting,
170
NM_SETTING_WIMAX_NETWORK_NAME, name,
171
NM_SETTING_WIMAX_MAC_ADDRESS, device_mac,
175
g_byte_array_free (device_mac, TRUE);
179
validate (CEPage *page, NMConnection *connection, GError **error)
181
CEPageWimax *self = CE_PAGE_WIMAX (page);
182
CEPageWimaxPrivate *priv = CE_PAGE_WIMAX_GET_PRIVATE (self);
184
gboolean invalid = FALSE;
188
name = gtk_entry_get_text (priv->name);
192
entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
194
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
198
g_byte_array_free (ignore, TRUE);
201
ui_to_setting (self);
206
ce_page_wimax_init (CEPageWimax *self)
211
ce_page_wimax_class_init (CEPageWimaxClass *wimax_class)
213
GObjectClass *object_class = G_OBJECT_CLASS (wimax_class);
214
CEPageClass *parent_class = CE_PAGE_CLASS (wimax_class);
216
g_type_class_add_private (object_class, sizeof (CEPageWimaxPrivate));
218
/* virtual methods */
219
parent_class->validate = validate;
224
wimax_connection_new (GtkWindow *parent,
226
NMRemoteSettings *settings,
227
PageNewConnectionResultFunc result_func,
230
NMConnection *connection;
233
connection = ce_page_new_connection (_("WiMAX connection %d"),
234
NM_SETTING_WIMAX_SETTING_NAME,
238
s_wimax = nm_setting_wimax_new ();
239
nm_connection_add_setting (connection, s_wimax);
241
(*result_func) (connection, FALSE, NULL, user_data);