1 |
## ------------------------------------------------------------------------ |
2 |
## $Id$ |
3 |
## ------------------------------------------------------------------------ |
4 |
## $Log$ |
5 |
## ------------------------------------------------------------------------ |
6 |
|
7 |
|
8 |
package Torus::Config; |
9 |
|
10 |
use strict; |
11 |
use warnings; |
12 |
|
13 |
use mixin::with qw( Torus ); |
14 |
|
15 |
use AppConfig qw(:expand :argcount); |
16 |
use Data::Dumper; |
17 |
|
18 |
sub raiseAppConfigError { |
19 |
my $error = shift; |
20 |
my $errmsg = "error while accessing configuration-data: "; |
21 |
$errmsg .= $error if $error; |
22 |
die($errmsg); |
23 |
} |
24 |
|
25 |
sub loadConfig { |
26 |
my $self = shift; |
27 |
|
28 |
my $config = AppConfig->new({ |
29 |
CASE => 1, |
30 |
ERROR => \&raiseAppConfigError, |
31 |
GLOBAL => { |
32 |
#DEFAULT => "<unset>", |
33 |
DEFAULT => "", |
34 |
ARGCOUNT => ARGCOUNT_ONE, |
35 |
}, |
36 |
CREATE => 1, |
37 |
}); |
38 |
|
39 |
#$config->define("debug_level", { ARGCOUNT => ARGCOUNT_ONE } ); |
40 |
$config->define("mapi_ProfilePass", { ARGCOUNT => ARGCOUNT_NONE, DEFAULT => "" } ); |
41 |
$config->define("sync_map", { ARGCOUNT => ARGCOUNT_LIST } ); |
42 |
$config->define("sync_mapping", { ARGCOUNT => ARGCOUNT_HASH } ); |
43 |
|
44 |
$config->define("folders_use", { ARGCOUNT => ARGCOUNT_LIST } ); |
45 |
$config->define("folders_map", { ARGCOUNT => ARGCOUNT_HASH } ); |
46 |
|
47 |
#print Dumper($self); |
48 |
|
49 |
my $cfgfile_name = $self->{config_metadata}->{file}; |
50 |
|
51 |
if (! -e $cfgfile_name) { |
52 |
print "config-file \"$cfgfile_name\"does not exist.", "\n"; |
53 |
exit; |
54 |
} |
55 |
$config->file($cfgfile_name); |
56 |
|
57 |
$self->{config} = $config; |
58 |
|
59 |
#print Dumper($self->{config}); |
60 |
|
61 |
return 1; |
62 |
|
63 |
} |
64 |
|
65 |
1; |