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

« back to all changes in this revision

Viewing changes to src/EBox/OpenVPN/ModulePartition.pm

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-08-02 10:38:13 UTC
  • Revision ID: james.westby@ubuntu.com-20070802103813-dfbetdraf1435qoq
Tags: upstream-0.9.3
ImportĀ upstreamĀ versionĀ 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package EBox::OpenVPN::ModulePartition; 
 
2
# this module may become EBox::GConfModule if other modules found it useful
 
3
# package: create a kind of pseudo-partition in the configuration tree of a module
 
4
use strict;
 
5
use warnings;
 
6
use EBox::GConfModule;
 
7
 
 
8
#
 
9
# Constructor: new
 
10
#
 
11
#   Creates a new module partition
 
12
#
 
13
#  Parametes:
 
14
#        $base        - the portion of configuration namespace used for the partition
 
15
#        $fullModule  - a instance of the GConfModule to which belongs the partition
 
16
#
 
17
# Returns:
 
18
#
 
19
#    a blessed instance of the partition
 
20
sub new
 
21
{
 
22
    my ($class, $base, $fullModule) = @_;
 
23
    
 
24
    if (!$fullModule->dir_exists($base) ) {
 
25
        throw EBox::Exceptions::Internal("Tried to instantiate a module partition with a space not found in module configuration: $base");
 
26
    }
 
27
 
 
28
    my $self = { fullModule => $fullModule, confKeysBase => $base   };
 
29
    bless $self, $class;
 
30
 
 
31
    return $self;
 
32
}
 
33
 
 
34
 
 
35
sub confKey
 
36
{
 
37
    my ($self, $key) = @_;
 
38
    return $self->{confKeysBase} . "/$key";
 
39
}
 
40
 
 
41
#
 
42
# Method: fullModule
 
43
#
 
44
#   gets the module which contains the partition
 
45
#
 
46
# Returns:
 
47
#
 
48
#    the module which contais the partition
 
49
sub fullModule
 
50
{
 
51
    my ($self) = @_;
 
52
    return $self->{fullModule};
 
53
}
 
54
 
 
55
 
 
56
#
 
57
# Method: confKeysBase
 
58
#
 
59
#   gets the configuration directory where the partition's configuration resides
 
60
#
 
61
# Returns:
 
62
#
 
63
#    the partition's configuration directory as string
 
64
sub confKeysBase
 
65
{
 
66
  my ($self, $key) = @_;
 
67
  return $self->{confKeysBase};
 
68
}
 
69
 
 
70
sub getConfString
 
71
{
 
72
    my ($self, $key) = @_;
 
73
    $key = $self->confKey($key);
 
74
    $self->fullModule->get_string($key);
 
75
}
 
76
 
 
77
sub setConfString
 
78
{
 
79
    my ($self, $key, $value) = @_;
 
80
    $key = $self->confKey($key);
 
81
    $self->fullModule->set_string($key, $value);
 
82
}
 
83
 
 
84
 
 
85
sub getConfInt
 
86
{
 
87
    my ($self, $key) = @_;
 
88
    $key = $self->confKey($key);
 
89
    $self->fullModule->get_int($key);
 
90
}
 
91
 
 
92
sub setConfInt
 
93
{
 
94
    my ($self, $key, $value) = @_;
 
95
    $key = $self->confKey($key);
 
96
    $self->fullModule->set_int($key, $value);
 
97
}
 
98
 
 
99
 
 
100
sub confDirExists
 
101
{
 
102
    my ($self, $key) = @_;
 
103
    $key = $self->confKey($key);
 
104
    return $self->fullModule->dir_exists($key);
 
105
}
 
106
 
 
107
 
 
108
sub deleteConfDir
 
109
 
 
110
{    my ($self, $key) = @_;
 
111
    $key = $self->confKey($key);
 
112
    return $self->fullModule->delete_dir($key);
 
113
}
 
114
 
 
115
sub allConfEntriesBase
 
116
{
 
117
    my ($self, $key) = @_;
 
118
    $key = $self->confKey($key);
 
119
    return $self->fullModule->all_entries_base($key);
 
120
}
 
121
 
 
122
 
 
123
sub unsetConf
 
124
{
 
125
    my ($self, $key) = @_;
 
126
    $key = $self->confKey($key);
 
127
    return $self->fullModule->unset($key);
 
128
}
 
129
 
 
130
 
 
131
sub getConfBool
 
132
{
 
133
    my ($self, $key) = @_;
 
134
    $key = $self->confKey($key);
 
135
    $self->fullModule->get_bool($key);
 
136
}
 
137
 
 
138
sub setConfBool
 
139
{
 
140
    my ($self, $key, $value) = @_;
 
141
    $key = $self->confKey($key);
 
142
    $self->fullModule->set_bool($key, $value);
 
143
}
 
144
 
 
145
 
 
146
1;