network-manager-applet r689 - in trunk: . src/connection-editor
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r689 - in trunk: . src/connection-editor
- Date: Sat, 19 Apr 2008 02:31:31 +0100 (BST)
Author: dcbw
Date: Sat Apr 19 01:31:31 2008
New Revision: 689
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=689&view=rev
Log:
2008-04-18 Dan Williams <dcbw redhat com>
* src/connection-editor/Makefile.am
src/connection-editor/page-ppp.c
src/connection-editor/page-ppp.h
src/connection-editor/ce-page-ppp.glade
- Add PPP settings page
* src/connection-editor/page-dsl.c
- (validate): need the PPP setting to valide the PPPoE setting
* src/connection-editor/nm-connection-list.c
- (create_new_connection_for_type): add PPP settings for mobile broadband
and DSL
* src/connection-editor/nm-connection-editor.c
- (nm_connection_editor_set_connection): add PPP page for DSL and
mobile broadband
Added:
trunk/src/connection-editor/ce-page-ppp.glade
trunk/src/connection-editor/page-ppp.c
trunk/src/connection-editor/page-ppp.h
Modified:
trunk/ChangeLog
trunk/src/connection-editor/Makefile.am
trunk/src/connection-editor/nm-connection-editor.c
trunk/src/connection-editor/nm-connection-list.c
trunk/src/connection-editor/page-dsl.c
Modified: trunk/src/connection-editor/Makefile.am
==============================================================================
--- trunk/src/connection-editor/Makefile.am (original)
+++ trunk/src/connection-editor/Makefile.am Sat Apr 19 01:31:31 2008
@@ -41,7 +41,9 @@
page-mobile.h \
page-mobile.c \
mobile-wizard.h \
- mobile-wizard.c
+ mobile-wizard.c \
+ page-ppp.h \
+ page-ppp.c
nm_connection_editor_LDADD = \
$(top_builddir)/src/gconf-helpers/libgconf-helpers.la \
@@ -58,7 +60,8 @@
ce-page-ip4.glade \
ce-page-dsl.glade \
ce-page-mobile.glade \
- ce-mobile-wizard.glade
+ ce-mobile-wizard.glade \
+ ce-page-ppp.glade
CLEANFILES = *.bak *.gladep
Added: trunk/src/connection-editor/ce-page-ppp.glade
==============================================================================
--- (empty file)
+++ trunk/src/connection-editor/ce-page-ppp.glade Sat Apr 19 01:31:31 2008
@@ -0,0 +1,449 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkWindow" id="ppp_page_widget">
+ <property name="title" translatable="yes">window1</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+
+ <child>
+ <widget class="GtkVBox" id="PppPage">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">16</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label28">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Authentication</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_use_auth">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use Authentication</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment2">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTreeView" id="ppp_auth_methods">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">False</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
+ <property name="hover_selection">False</property>
+ <property name="hover_expand">False</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label29">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Compression</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox6">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox7">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_use_mppe">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use Point-to-Point Encryption (MPPE)</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox8">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_require_mppe_128">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Require 128-bit encryption</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_use_stateful_mppe">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use Stateful MPPE</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_allow_bsdcomp">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Allow BSD data compression</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_allow_deflate">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Allow Deflate data compression</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_usevj">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Use TCP header compression</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox9">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label31">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Echo</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">1</property>
+ <property name="yscale">1</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="ppp_send_echo_packets">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Send PPP echo packets</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
Modified: trunk/src/connection-editor/nm-connection-editor.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-editor.c (original)
+++ trunk/src/connection-editor/nm-connection-editor.c Sat Apr 19 01:31:31 2008
@@ -41,6 +41,7 @@
#include <nm-setting-wireless-security.h>
#include <nm-setting-vpn.h>
#include <nm-setting-pppoe.h>
+#include <nm-setting-ppp.h>
#include <nm-setting-gsm.h>
#include <nm-setting-cdma.h>
#include <nm-utils.h>
@@ -57,6 +58,7 @@
#include "page-ip4.h"
#include "page-dsl.h"
#include "page-mobile.h"
+#include "page-ppp.h"
G_DEFINE_TYPE (NMConnectionEditor, nm_connection_editor, G_TYPE_OBJECT)
@@ -394,9 +396,11 @@
add_page (editor, CE_PAGE (ce_page_ip4_new (editor->connection)));
} else if (!strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_dsl_new (editor->connection)));
+ add_page (editor, CE_PAGE (ce_page_ppp_new (editor->connection)));
} else if (!strcmp (s_con->type, NM_SETTING_GSM_SETTING_NAME) ||
!strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_mobile_new (editor->connection)));
+ add_page (editor, CE_PAGE (ce_page_ppp_new (editor->connection)));
} else {
g_warning ("Unhandled setting type '%s'", s_con->type);
}
Modified: trunk/src/connection-editor/nm-connection-list.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.c (original)
+++ trunk/src/connection-editor/nm-connection-list.c Sat Apr 19 01:31:31 2008
@@ -43,6 +43,7 @@
#include <nm-setting-gsm.h>
#include <nm-setting-cdma.h>
#include <nm-setting-pppoe.h>
+#include <nm-setting-ppp.h>
#include <nm-setting-serial.h>
#include "nm-connection-editor.h"
@@ -363,6 +364,8 @@
type_setting = nm_setting_gsm_new ();
s_gsm = NM_SETTING_GSM (type_setting);
s_gsm->number = g_strdup ("*99#"); /* De-facto standard for GSM */
+
+ nm_connection_add_setting (connection, nm_setting_ppp_new ());
} else if (mb_type == NM_TYPE_SETTING_CDMA) {
NMSettingCdma *s_cdma;
@@ -375,6 +378,8 @@
type_setting = nm_setting_cdma_new ();
s_cdma = NM_SETTING_CDMA (type_setting);
s_cdma->number = g_strdup ("#777"); /* De-facto standard for CDMA */
+
+ nm_connection_add_setting (connection, nm_setting_ppp_new ());
} else {
/* user canceled; do nothing */
}
@@ -384,14 +389,13 @@
type_setting = nm_setting_vpn_new ();
} else if (ctype == NM_TYPE_SETTING_PPPOE) {
- NMSetting *s_wired;
-
s_con->id = get_next_available_name (list, _("DSL connection %d"));
s_con->type = g_strdup (NM_SETTING_PPPOE_SETTING_NAME);
type_setting = nm_setting_pppoe_new ();
- s_wired = nm_setting_wired_new ();
- nm_connection_add_setting (connection, s_wired);
+
+ nm_connection_add_setting (connection, nm_setting_wired_new ());
+ nm_connection_add_setting (connection, nm_setting_ppp_new ());
} else {
g_warning ("%s: unhandled connection type '%s'", __func__, g_type_name (ctype));
}
Modified: trunk/src/connection-editor/page-dsl.c
==============================================================================
--- trunk/src/connection-editor/page-dsl.c (original)
+++ trunk/src/connection-editor/page-dsl.c Sat Apr 19 01:31:31 2008
@@ -27,6 +27,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-pppoe.h>
+#include <nm-setting-ppp.h>
#include "page-dsl.h"
#include "nm-connection-editor.h"
@@ -38,6 +39,7 @@
typedef struct {
NMSettingPPPOE *setting;
+ NMConnection *connection; /* ugh */
GtkEntry *username;
GtkEntry *password;
@@ -150,6 +152,8 @@
else
priv->setting = NM_SETTING_PPPOE (nm_setting_pppoe_new ());
+ priv->connection = connection;
+
populate_ui (self, connection);
g_signal_connect (priv->username, "changed", G_CALLBACK (stuff_changed), self);
@@ -194,9 +198,16 @@
{
CEPageDsl *self = CE_PAGE_DSL (page);
CEPageDslPrivate *priv = CE_PAGE_DSL_GET_PRIVATE (self);
+ GSList *foo;
+ gboolean valid;
ui_to_setting (self);
- return nm_setting_verify (NM_SETTING (priv->setting), NULL);
+
+ foo = g_slist_append (NULL, nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_PPP));
+ valid = nm_setting_verify (NM_SETTING (priv->setting), foo);
+ g_slist_free (foo);
+
+ return valid;
}
static void
Added: trunk/src/connection-editor/page-ppp.c
==============================================================================
--- (empty file)
+++ trunk/src/connection-editor/page-ppp.c Sat Apr 19 01:31:31 2008
@@ -0,0 +1,381 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Connection editor -- Connection editor for NetworkManager
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include <nm-setting-connection.h>
+#include <nm-setting-ppp.h>
+
+#include "page-ppp.h"
+#include "nm-connection-editor.h"
+
+G_DEFINE_TYPE (CEPagePpp, ce_page_ppp, CE_TYPE_PAGE)
+
+#define CE_PAGE_PPP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CE_TYPE_PAGE_PPP, CEPagePppPrivate))
+
+#define COL_NAME 0
+#define COL_VALUE 1
+#define COL_TAG 2
+
+#define TAG_EAP 0
+#define TAG_PAP 1
+#define TAG_CHAP 2
+#define TAG_MSCHAP 3
+#define TAG_MSCHAPV2 4
+
+typedef struct {
+ NMSettingPPP *setting;
+
+ GtkToggleButton *use_auth;
+
+ GtkTreeView *auth_methods_view;
+ GtkCellRendererToggle *check_renderer;
+ GtkListStore *auth_methods_list;
+
+ GtkToggleButton *use_mppe;
+ GtkToggleButton *mppe_require_128;
+ GtkToggleButton *use_mppe_stateful;
+
+ GtkToggleButton *allow_bsdcomp;
+ GtkToggleButton *allow_deflate;
+ GtkToggleButton *use_vj_comp;
+
+ GtkToggleButton *send_ppp_echo;
+
+ gboolean disposed;
+} CEPagePppPrivate;
+
+static void
+ppp_private_init (CEPagePpp *self)
+{
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);
+ GladeXML *xml;
+
+ xml = CE_PAGE (self)->xml;
+
+ priv->auth_methods_list = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_UINT);
+
+ priv->use_auth = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_use_auth"));
+ priv->auth_methods_view = GTK_TREE_VIEW (glade_xml_get_widget (xml, "ppp_auth_methods"));
+ priv->use_mppe = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_use_mppe"));
+ priv->mppe_require_128 = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_require_mppe_128"));
+ priv->use_mppe_stateful = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_use_stateful_mppe"));
+ priv->allow_bsdcomp = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_allow_bsdcomp"));
+ priv->allow_deflate = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_allow_deflate"));
+ priv->use_vj_comp = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_usevj"));
+ priv->send_ppp_echo = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "ppp_send_echo_packets"));
+}
+
+static void
+set_auth_items_sensitive (CEPagePpp *self, gboolean sensitive)
+{
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);
+
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->auth_methods_view), sensitive);
+ g_object_set (G_OBJECT (priv->check_renderer), "sensitive", sensitive, NULL);
+
+ /* MPPE depends on MSCHAPv2 auth */
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->use_mppe), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->mppe_require_128), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->use_mppe_stateful), sensitive);
+}
+
+static void
+use_auth_toggled_cb (GtkToggleButton *check, gpointer user_data)
+{
+ CEPagePpp *self = CE_PAGE_PPP (user_data);
+
+ set_auth_items_sensitive (self, gtk_toggle_button_get_active (check));
+}
+
+static void
+add_one_auth_method (GtkListStore *store, const char *name, gboolean allowed, guint32 tag)
+{
+ GtkTreeIter iter;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, COL_NAME, name, COL_VALUE, allowed, COL_TAG, tag, -1);
+}
+
+static void
+populate_ui (CEPagePpp *self, NMConnection *connection)
+{
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);
+ NMSettingPPP *setting = priv->setting;
+
+ add_one_auth_method (priv->auth_methods_list, _("PAP"), !setting->refuse_pap, TAG_PAP);
+ add_one_auth_method (priv->auth_methods_list, _("CHAP"), !setting->refuse_chap, TAG_CHAP);
+ add_one_auth_method (priv->auth_methods_list, _("MSCHAPv2"), !setting->refuse_mschapv2, TAG_MSCHAPV2);
+ add_one_auth_method (priv->auth_methods_list, _("MSCHAP"), !setting->refuse_mschap, TAG_MSCHAP);
+ add_one_auth_method (priv->auth_methods_list, _("EAP"), !setting->refuse_eap, TAG_EAP);
+
+ gtk_toggle_button_set_active (priv->use_auth, !setting->noauth);
+ if (setting->noauth)
+ set_auth_items_sensitive (self, !setting->noauth);
+ g_signal_connect (G_OBJECT (priv->use_auth), "toggled", G_CALLBACK (use_auth_toggled_cb), self);
+
+ gtk_toggle_button_set_active (priv->use_mppe, setting->require_mppe);
+ gtk_toggle_button_set_active (priv->mppe_require_128, setting->require_mppe_128);
+ gtk_toggle_button_set_active (priv->use_mppe_stateful, setting->mppe_stateful);
+
+ gtk_toggle_button_set_active (priv->allow_bsdcomp, !setting->nobsdcomp);
+ gtk_toggle_button_set_active (priv->allow_deflate, !setting->nodeflate);
+ gtk_toggle_button_set_active (priv->use_vj_comp, !setting->no_vj_comp);
+
+ gtk_toggle_button_set_active (priv->send_ppp_echo, (setting->lcp_echo_interval > 0) ? TRUE : FALSE);
+}
+
+static void
+check_toggled_cb (GtkCellRendererToggle *cell, gchar *path_str, gpointer user_data)
+{
+ CEPagePpp *self = CE_PAGE_PPP (user_data);
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);
+ GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->auth_methods_list);
+ GtkTreeIter iter;
+ gboolean toggle_item;
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, COL_VALUE, &toggle_item, -1);
+
+ toggle_item ^= 1;
+
+ /* set new value */
+ gtk_list_store_set (priv->auth_methods_list, &iter, COL_VALUE, toggle_item, -1);
+
+ gtk_tree_path_free (path);
+}
+
+CEPagePpp *
+ce_page_ppp_new (NMConnection *connection)
+{
+ CEPagePpp *self;
+ CEPagePppPrivate *priv;
+ CEPage *parent;
+ NMSettingPPP *s_ppp;
+ GtkCellRenderer *renderer;
+ gint offset;
+ GtkTreeViewColumn *column;
+
+ self = CE_PAGE_PPP (g_object_new (CE_TYPE_PAGE_PPP, NULL));
+ parent = CE_PAGE (self);
+
+ parent->xml = glade_xml_new (GLADEDIR "/ce-page-ppp.glade", "PppPage", NULL);
+ if (!parent->xml) {
+ g_warning ("%s: Couldn't load ppp page glade file.", __func__);
+ g_object_unref (self);
+ return NULL;
+ }
+
+ parent->page = glade_xml_get_widget (parent->xml, "PppPage");
+ if (!parent->page) {
+ g_warning ("%s: Couldn't load ppp page from glade file.", __func__);
+ g_object_unref (self);
+ return NULL;
+ }
+ g_object_ref_sink (parent->page);
+
+ parent->title = g_strdup (_("Point-to-Point Protocol (PPP)"));
+
+ ppp_private_init (self);
+ priv = CE_PAGE_PPP_GET_PRIVATE (self);
+
+ s_ppp = (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
+ if (s_ppp)
+ priv->setting = NM_SETTING_PPP (nm_setting_duplicate (NM_SETTING (s_ppp)));
+ else
+ priv->setting = NM_SETTING_PPP (nm_setting_ppp_new ());
+
+ populate_ui (self, connection);
+
+ gtk_tree_view_set_model (priv->auth_methods_view, GTK_TREE_MODEL (priv->auth_methods_list));
+
+ priv->check_renderer = GTK_CELL_RENDERER_TOGGLE (gtk_cell_renderer_toggle_new ());
+ g_signal_connect (priv->check_renderer, "toggled", G_CALLBACK (check_toggled_cb), self);
+
+ offset = gtk_tree_view_insert_column_with_attributes (priv->auth_methods_view,
+ -1, "", GTK_CELL_RENDERER (priv->check_renderer),
+ "active", COL_VALUE,
+ NULL);
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (priv->auth_methods_view), offset - 1);
+ gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 30);
+ gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
+
+ renderer = gtk_cell_renderer_text_new ();
+ offset = gtk_tree_view_insert_column_with_attributes (priv->auth_methods_view,
+ -1, "", renderer,
+ "text", COL_NAME,
+ NULL);
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (priv->auth_methods_view), offset - 1);
+ gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
+
+ return self;
+}
+
+static void
+ui_to_setting (CEPagePpp *self)
+{
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);
+ gboolean noauth;
+ gboolean refuse_eap = FALSE;
+ gboolean refuse_pap = FALSE;
+ gboolean refuse_chap = FALSE;
+ gboolean refuse_mschap = FALSE;
+ gboolean refuse_mschapv2 = FALSE;
+ gboolean require_mppe;
+ gboolean require_mppe_128;
+ gboolean mppe_stateful;
+ gboolean nobsdcomp;
+ gboolean nodeflate;
+ gboolean no_vj_comp;
+ guint32 lcp_echo_failure;
+ guint32 lcp_echo_interval;
+ GtkTreeIter iter;
+ gboolean valid;
+
+ noauth = !gtk_toggle_button_get_active (priv->use_auth);
+
+ valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->auth_methods_list), &iter);
+ while (valid) {
+ gboolean allowed;
+ guint32 tag;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->auth_methods_list), &iter,
+ COL_VALUE, &allowed,
+ COL_TAG, &tag,
+ -1);
+
+ switch (tag) {
+ case TAG_EAP:
+ refuse_eap = !allowed;
+ break;
+ case TAG_PAP:
+ refuse_pap = !allowed;
+ break;
+ case TAG_CHAP:
+ refuse_chap = !allowed;
+ break;
+ case TAG_MSCHAP:
+ refuse_mschap = !allowed;
+ break;
+ case TAG_MSCHAPV2:
+ refuse_mschapv2 = !allowed;
+ break;
+ default:
+ break;
+ }
+
+ valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->auth_methods_list), &iter);
+ }
+
+ require_mppe = gtk_toggle_button_get_active (priv->use_mppe);
+ require_mppe_128 = gtk_toggle_button_get_active (priv->mppe_require_128);
+ mppe_stateful = gtk_toggle_button_get_active (priv->use_mppe_stateful);
+
+ nobsdcomp = !gtk_toggle_button_get_active (priv->allow_bsdcomp);
+ nodeflate = !gtk_toggle_button_get_active (priv->allow_deflate);
+ no_vj_comp = !gtk_toggle_button_get_active (priv->use_vj_comp);
+
+ if (gtk_toggle_button_get_active (priv->send_ppp_echo)) {
+ lcp_echo_failure = 5;
+ lcp_echo_interval = 30;
+ } else {
+ lcp_echo_failure = 0;
+ lcp_echo_interval = 0;
+ }
+
+ g_object_set (priv->setting,
+ NM_SETTING_PPP_NOAUTH, noauth,
+ NM_SETTING_PPP_REFUSE_EAP, refuse_eap,
+ NM_SETTING_PPP_REFUSE_PAP, refuse_pap,
+ NM_SETTING_PPP_REFUSE_CHAP, refuse_chap,
+ NM_SETTING_PPP_REFUSE_MSCHAP, refuse_mschap,
+ NM_SETTING_PPP_REFUSE_MSCHAPV2, refuse_mschapv2,
+ NM_SETTING_PPP_NOBSDCOMP, nobsdcomp,
+ NM_SETTING_PPP_NODEFLATE, nodeflate,
+ NM_SETTING_PPP_NO_VJ_COMP, no_vj_comp,
+ NM_SETTING_PPP_REQUIRE_MPPE, require_mppe,
+ NM_SETTING_PPP_REQUIRE_MPPE_128, require_mppe_128,
+ NM_SETTING_PPP_MPPE_STATEFUL, mppe_stateful,
+ NM_SETTING_PPP_LCP_ECHO_FAILURE, lcp_echo_failure,
+ NM_SETTING_PPP_LCP_ECHO_INTERVAL, lcp_echo_interval,
+ NULL);
+}
+
+static gboolean
+validate (CEPage *page)
+{
+ CEPagePpp *self = CE_PAGE_PPP (page);
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);
+
+ ui_to_setting (self);
+ return nm_setting_verify (NM_SETTING (priv->setting), NULL);
+}
+
+static void
+update_connection (CEPage *page, NMConnection *connection)
+{
+ CEPagePpp *self = CE_PAGE_PPP (page);
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (self);
+
+ ui_to_setting (self);
+ g_object_ref (priv->setting); /* Add setting steals the reference. */
+ nm_connection_add_setting (connection, NM_SETTING (priv->setting));
+}
+
+static void
+ce_page_ppp_init (CEPagePpp *self)
+{
+}
+
+static void
+dispose (GObject *object)
+{
+ CEPagePppPrivate *priv = CE_PAGE_PPP_GET_PRIVATE (object);
+
+ if (priv->disposed)
+ return;
+
+ priv->disposed = TRUE;
+ g_object_unref (priv->setting);
+
+ G_OBJECT_CLASS (ce_page_ppp_parent_class)->dispose (object);
+}
+
+static void
+ce_page_ppp_class_init (CEPagePppClass *ppp_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (ppp_class);
+ CEPageClass *parent_class = CE_PAGE_CLASS (ppp_class);
+
+ g_type_class_add_private (object_class, sizeof (CEPagePppPrivate));
+
+ /* virtual methods */
+ object_class->dispose = dispose;
+
+ parent_class->validate = validate;
+ parent_class->update_connection = update_connection;
+}
Added: trunk/src/connection-editor/page-ppp.h
==============================================================================
--- (empty file)
+++ trunk/src/connection-editor/page-ppp.h Sat Apr 19 01:31:31 2008
@@ -0,0 +1,52 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Connection editor -- Connection editor for NetworkManager
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2008 Red Hat, Inc.
+ */
+
+#ifndef __PAGE_PPP_H__
+#define __PAGE_PPP_H__
+
+#include <nm-connection.h>
+
+#include <glib/gtypes.h>
+#include <glib-object.h>
+
+#include "ce-page.h"
+
+#define CE_TYPE_PAGE_PPP (ce_page_ppp_get_type ())
+#define CE_PAGE_PPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CE_TYPE_PAGE_PPP, CEPagePpp))
+#define CE_PAGE_PPP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CE_TYPE_PAGE_PPP, CEPagePppClass))
+#define CE_IS_PAGE_PPP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CE_TYPE_PAGE_PPP))
+#define CE_IS_PAGE_PPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), CE_TYPE_PAGE_PPP))
+#define CE_PAGE_PPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CE_TYPE_PAGE_PPP, CEPagePppClass))
+
+typedef struct {
+ CEPage parent;
+} CEPagePpp;
+
+typedef struct {
+ CEPageClass parent;
+} CEPagePppClass;
+
+GType ce_page_ppp_get_type (void);
+
+CEPagePpp *ce_page_ppp_new (NMConnection *connection);
+
+#endif /* __PAGE_PPP_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]