~ubuntu-branches/ubuntu/lucid/ebox-openvpn/lucid

« back to all changes in this revision

Viewing changes to src/EBox/OpenVPN/Model/ExposedNetworks.pm

  • Committer: Bazaar Package Importer
  • Author(s): Javier Uruen Val, Javier Uruen Val
  • Date: 2010-02-07 18:51:11 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100207185111-jo3dsibp35f0xr6u
Tags: 1.5-0ubuntu1
 [Javier Uruen Val]
 * New upstream release (LP: #521808)
 * debian/control
   - Bump eBox dependency
   - Update description
   - Bump Standards-version to 3.8.4. No changes required.
 * debian/copyright: updated emails and dates.
 * debian/ebox-openvpn.postinst
   - Do not run migration scripts as upstream dropped them for 1.4
 * Drop debian/patches as upstream already ships them
 * debian/rules: Drop simple-patchsys

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 Warp Networks S.L.
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License, version 2, as
 
5
# published by the Free Software Foundation.
 
6
#
 
7
# This program is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
# GNU General Public License for more details.
 
11
#
 
12
# You should have received a copy of the GNU General Public License
 
13
# along with this program; if not, write to the Free Software
 
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
 
 
16
# Class:
 
17
#
 
18
#
 
19
 
 
20
#
 
21
package EBox::OpenVPN::Model::ExposedNetworks;
 
22
use base 'EBox::Model::DataTable';
 
23
 
 
24
use strict;
 
25
use warnings;
 
26
 
 
27
use EBox::Global;
 
28
use EBox::Gettext;
 
29
use EBox::Validate qw(:all);
 
30
use EBox::Exceptions::External;
 
31
use EBox::Exceptions::DataExists;
 
32
 
 
33
use EBox::Types::IPNetwork;
 
34
 
 
35
# Group: Public methods
 
36
 
 
37
sub new
 
38
{
 
39
    my $class = shift;
 
40
 
 
41
    my $self = $class->SUPER::new(@_);
 
42
    bless($self, $class);
 
43
 
 
44
    return $self;
 
45
}
 
46
 
 
47
sub name
 
48
{
 
49
    __PACKAGE__->nameFromClass(),
 
50
}
 
51
 
 
52
# Group: Protected methods
 
53
 
 
54
sub _table
 
55
{
 
56
    my @tableHead =
 
57
        (
 
58
          new EBox::Types::IPNetwork(
 
59
                                     fieldName => 'network',
 
60
                                     printableName => __('Advertised network'),
 
61
                                     unique => 1,
 
62
                                     editable => 1,
 
63
                                    ),
 
64
          );
 
65
 
 
66
    my $dataTable =
 
67
        {
 
68
            'tableName'              => __PACKAGE__->name(),
 
69
            'printableTableName' => __('List of Advertised Networks'),
 
70
            'automaticRemove' => 1,
 
71
            'defaultController' => '/ebox/OpenVPN/Controller/ExposedNetworks',
 
72
            'defaultActions' => ['add', 'del', 'editField',  'changeView' ],
 
73
            'tableDescription' => \@tableHead,
 
74
            'class' => 'dataTable',
 
75
            'printableRowName' => __('Advertised network'),
 
76
            'sortedBy' => 'network',
 
77
            'modelDomain' => 'OpenVPN',
 
78
            'help'  => _help(),
 
79
        };
 
80
 
 
81
    return $dataTable;
 
82
}
 
83
 
 
84
 
 
85
 
 
86
sub validateTypedRow
 
87
{
 
88
    my ($self, $action, $changedFields) = @_;
 
89
 
 
90
    if (not exists $changedFields->{network}) {
 
91
        return;
 
92
    }
 
93
 
 
94
    my $net = $changedFields->{network}->printableValue();
 
95
    my $serverConf = 
 
96
  $self->parentRow()->elementByName('configuration')->foreignModelInstance();
 
97
    my $vpn = $serverConf->row()->elementByName('vpn')->printableValue();
 
98
 
 
99
    if ($net eq $vpn) {
 
100
        throw EBox::Exceptions::External(
 
101
__('The advertised network address could not be the same than the VPN address' )
 
102
                                        );
 
103
    }
 
104
 
 
105
}
 
106
 
 
107
 
 
108
 
 
109
# Method: pageTitle
 
110
#
 
111
#   Overrides <EBox::Model::DataTable::pageTitle>
 
112
#   to show the name of the domain
 
113
sub pageTitle
 
114
{
 
115
        my ($self) = @_;
 
116
 
 
117
        return $self->parentRow()->printableValueByName('name');
 
118
}
 
119
 
 
120
 
 
121
# Group: Private methods
 
122
 
 
123
# Return the help message
 
124
sub _help
 
125
{
 
126
    return __x('{openpar}You can add here those networks which you want to make ' .
 
127
              'available to clients connecting to this VPN.{closepar}' .
 
128
              '{openpar}Typically, you will allow access to your LAN by advertising' .
 
129
              ' its network address here{closepar}',
 
130
              openpar => '<p>', closepar => '</p>');
 
131
}
 
132
 
 
133
1;