| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package ZConf::GUI; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24398
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
5
|
1
|
|
|
1
|
|
842
|
use Module::List qw(list_modules); |
|
|
1
|
|
|
|
|
37998
|
|
|
|
1
|
|
|
|
|
70
|
|
|
6
|
1
|
|
|
1
|
|
1277
|
use ZConf; |
|
|
1
|
|
|
|
|
139634
|
|
|
|
1
|
|
|
|
|
44
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use base 'Error::Helper'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
242
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
ZConf::GUI - A GUI backend chooser. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 1.1.0 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.1.0'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use ZConf::GUI; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $zg = ZConf::GUI->new(); |
|
26
|
|
|
|
|
|
|
... |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This initiates it. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
One arguement is taken. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
If this errors, it errors permanently. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 hash args |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head4 zconf |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
A already initialized ZConf object. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $zg=ZConf::GUI->new({ zconf=>$zconf }); |
|
45
|
|
|
|
|
|
|
if($zg->{error}){ |
|
46
|
|
|
|
|
|
|
print "Error!\n"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
|
52
|
0
|
|
|
0
|
1
|
|
my %args; |
|
53
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
54
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $self={ |
|
58
|
|
|
|
|
|
|
error=>undef, |
|
59
|
|
|
|
|
|
|
errorString=>undef, |
|
60
|
|
|
|
|
|
|
perror=>undef, |
|
61
|
|
|
|
|
|
|
errorExtra=>{ |
|
62
|
|
|
|
|
|
|
flags=>{ |
|
63
|
|
|
|
|
|
|
1=>'zconf', |
|
64
|
|
|
|
|
|
|
2=>'missingArg', |
|
65
|
|
|
|
|
|
|
3=>'missingArg', |
|
66
|
|
|
|
|
|
|
4=>'colon', |
|
67
|
|
|
|
|
|
|
5=>'noPrefs', |
|
68
|
|
|
|
|
|
|
6=>'lmFailed', |
|
69
|
|
|
|
|
|
|
7=>'modDNE', |
|
70
|
|
|
|
|
|
|
8=>'missingArg', |
|
71
|
|
|
|
|
|
|
9=>'notBoolean', |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
}, |
|
74
|
|
|
|
|
|
|
}; |
|
75
|
0
|
|
|
|
|
|
bless $self; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#this sets the set to undef if it is not defined |
|
78
|
0
|
0
|
|
|
|
|
if (!defined($args{set})) { |
|
79
|
0
|
|
|
|
|
|
$self->{set}=undef; |
|
80
|
|
|
|
|
|
|
}else { |
|
81
|
0
|
|
|
|
|
|
$self->{set}=$args{set}; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if (!defined($args{zconf})) { |
|
85
|
1
|
|
|
1
|
|
7
|
use ZConf; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
4914
|
|
|
86
|
0
|
|
|
|
|
|
$self->{zconf}=ZConf->new(); |
|
87
|
0
|
0
|
|
|
|
|
if(defined($self->{zconf}->error)){ |
|
88
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
89
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
90
|
0
|
|
|
|
|
|
$self->{errorString}="Could not initiate ZConf. It failed with '" |
|
91
|
|
|
|
|
|
|
.$self->{zconf}->error."', '". |
|
92
|
|
|
|
|
|
|
$self->{zconf}->errorString."'"; |
|
93
|
0
|
|
|
|
|
|
$self->warn; |
|
94
|
0
|
|
|
|
|
|
return $self; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
}else { |
|
97
|
0
|
|
|
|
|
|
$self->{zconf}=$args{zconf}; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#create the config if it does not exist |
|
101
|
|
|
|
|
|
|
#if it does exist, make sure the set we are using exists |
|
102
|
0
|
|
|
|
|
|
$self->{init} = $self->{zconf}->configExists("gui"); |
|
103
|
0
|
0
|
|
|
|
|
if( $self->{zconf}->error ){ |
|
104
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
105
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
106
|
0
|
|
|
|
|
|
$self->{errorString}="Could not check if the config 'gu'i exists.". |
|
107
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
108
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
109
|
0
|
|
|
|
|
|
$self->warn; |
|
110
|
0
|
|
|
|
|
|
return $self; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#this checks to make sure the set exists, if init is already 1 |
|
114
|
0
|
0
|
|
|
|
|
if ( $self->{init} ) { |
|
115
|
0
|
|
|
|
|
|
$self->{init}=$self->{zconf}->defaultSetExists('gui', $self->{set}); |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
118
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
119
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
120
|
0
|
|
|
|
|
|
$self->{errorString}="Could not check if the config 'gu'i exists.". |
|
121
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
122
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
123
|
0
|
|
|
|
|
|
$self->warn; |
|
124
|
0
|
|
|
|
|
|
return $self; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#if it is not inited, check to see if it needs to do so |
|
129
|
0
|
0
|
|
|
|
|
if ( !$self->{init} ) { |
|
130
|
0
|
|
|
|
|
|
$self->init($self->{set}); |
|
131
|
0
|
0
|
|
|
|
|
if ( $self->error ) { |
|
132
|
0
|
|
|
|
|
|
warn('ZConf-GUI new: init failed.'); |
|
133
|
|
|
|
|
|
|
}else { |
|
134
|
|
|
|
|
|
|
#if init works, it is now inited and thus we set it to one |
|
135
|
0
|
|
|
|
|
|
$self->{init}=1; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
#we don't set any error stuff here even if the above action failed... |
|
138
|
|
|
|
|
|
|
#it will have been set any ways by init methode |
|
139
|
0
|
|
|
|
|
|
return $self; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#checks wether the specified set exists or not |
|
143
|
0
|
|
|
|
|
|
$self->{init}=$self->{zconf}->setExists('gui', $self->{set}); |
|
144
|
0
|
0
|
|
|
|
|
if( $self->{zconf}->error ){ |
|
145
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
146
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
147
|
0
|
|
|
|
|
|
$self->{errorString}="defaultSetExists failed for 'gui'.". |
|
148
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
149
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
150
|
0
|
|
|
|
|
|
$self->warn; |
|
151
|
0
|
|
|
|
|
|
return $self; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#the first one does this if the config has not been done yet |
|
155
|
|
|
|
|
|
|
#this one does it if the set has not been done yet |
|
156
|
|
|
|
|
|
|
#if it is not inited, check to see if it needs to do so |
|
157
|
0
|
0
|
|
|
|
|
if (!$self->{init}) { |
|
158
|
0
|
|
|
|
|
|
$self->init($self->{set}); |
|
159
|
0
|
0
|
|
|
|
|
if ( $self->error ) { |
|
160
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
161
|
0
|
|
|
|
|
|
warn('ZConf-GUI new:4: Autoinit failed.'); |
|
162
|
|
|
|
|
|
|
}else { |
|
163
|
|
|
|
|
|
|
#if init works, it is now inited and thus we set it to one |
|
164
|
0
|
|
|
|
|
|
$self->{init}=1; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
#we don't set any error stuff here even if the above action failed... |
|
167
|
|
|
|
|
|
|
#it will have been set any ways by init methode |
|
168
|
0
|
|
|
|
|
|
return $self; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
#reads it if it does not need to be initiated |
|
172
|
0
|
0
|
|
|
|
|
if ($self->{init}) { |
|
173
|
0
|
|
|
|
|
|
$self->{zconf}->read({set=>$self->{set}, config=>'gui'}); |
|
174
|
|
|
|
|
|
|
}else{ |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
return $self; |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 getAppendOthers |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This gets the value for 'appendOthers'. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
my $appendOthers=$zg->getAppendOthers; |
|
186
|
|
|
|
|
|
|
if($zg->{error}){ |
|
187
|
|
|
|
|
|
|
print "Error!\n"; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub getAppendOthers{ |
|
193
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
196
|
0
|
|
|
|
|
|
return undef; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
#fetch the preferences for the module |
|
200
|
0
|
|
|
|
|
|
my %vars=$self->{zconf}->regexVarGet('gui', '^appendOthers$'); |
|
201
|
0
|
0
|
|
|
|
|
if( $self->{zconf}->error ){ |
|
202
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
203
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error getting value "appendOthers" in "gui".'. |
|
204
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
205
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
206
|
0
|
|
|
|
|
|
$self->warn; |
|
207
|
0
|
|
|
|
|
|
return undef; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
#if we don't have it, return true |
|
211
|
0
|
0
|
|
|
|
|
if (!defined($vars{appendOthers})) { |
|
212
|
0
|
|
|
|
|
|
return 1; |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
#return it's value |
|
216
|
0
|
|
|
|
|
|
return $vars{appendOthers} |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 getPreferred |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This gets the preferred for a module. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
my @prefs=$zg->getPreferred('ZConf::Runner'); |
|
224
|
|
|
|
|
|
|
if($zg->{error}){ |
|
225
|
|
|
|
|
|
|
print "Error!\n"; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=cut |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub getPreferred{ |
|
231
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
232
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
233
|
|
|
|
|
|
|
|
|
234
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
235
|
0
|
|
|
|
|
|
return undef; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
|
|
238
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
239
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
240
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
241
|
0
|
|
|
|
|
|
$self->warn; |
|
242
|
0
|
|
|
|
|
|
return undef; |
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
#the change it for fetching the info |
|
246
|
0
|
|
|
|
|
|
my $module2=$module; |
|
247
|
0
|
|
|
|
|
|
$module2=~s/\:\:/\//g; |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
#fetch the preferences for the module |
|
250
|
0
|
|
|
|
|
|
my %vars=$self->{zconf}->regexVarGet('gui', '^modules/'.quotemeta($module2).'$'); |
|
251
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
252
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
253
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "gui".'. |
|
254
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
255
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
256
|
0
|
|
|
|
|
|
$self->warn; |
|
257
|
0
|
|
|
|
|
|
return undef; |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
#if we don't get it, try the default |
|
261
|
0
|
0
|
|
|
|
|
if (!defined($vars{'modules/'.$module2})) { |
|
262
|
0
|
|
|
|
|
|
%vars=$self->{zconf}->regexVarGet('gui', '^default$'); |
|
263
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
264
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
265
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "gui".'. |
|
266
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
267
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
268
|
0
|
|
|
|
|
|
$self->warn; |
|
269
|
0
|
|
|
|
|
|
return undef; |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
#if the default does not exist |
|
273
|
0
|
0
|
|
|
|
|
if (!defined($vars{default})) { |
|
274
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
275
|
0
|
|
|
|
|
|
$self->{errorString}='No preferences for "'.$module.'" and there is no default'; |
|
276
|
0
|
|
|
|
|
|
$self->warn; |
|
277
|
0
|
|
|
|
|
|
return undef; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
|
|
280
|
0
|
|
|
|
|
|
return split(/:/, $vars{default}); |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
|
|
283
|
0
|
|
|
|
|
|
return split(/:/, $vars{'modules/'.$module2}); |
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head2 getSet |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
This gets what the current set is. |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
my $set=$zg->getSet; |
|
291
|
|
|
|
|
|
|
if($zg->{error}){ |
|
292
|
|
|
|
|
|
|
print "Error!\n"; |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=cut |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub getSet{ |
|
298
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
299
|
|
|
|
|
|
|
|
|
300
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
301
|
0
|
|
|
|
|
|
return undef; |
|
302
|
|
|
|
|
|
|
} |
|
303
|
|
|
|
|
|
|
|
|
304
|
0
|
|
|
|
|
|
my $set=$self->{zconf}->getSet('gui'); |
|
305
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
306
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
307
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error getting the loaded set the config "gui".'. |
|
308
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
309
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
310
|
0
|
|
|
|
|
|
$self->warn; |
|
311
|
0
|
|
|
|
|
|
return undef; |
|
312
|
|
|
|
|
|
|
} |
|
313
|
|
|
|
|
|
|
|
|
314
|
0
|
|
|
|
|
|
return $set; |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head2 getUseX |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
This fetches if X should be used or not for a module. |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
$zcgui->getUseX('ZConf::Runner'); |
|
322
|
|
|
|
|
|
|
if($zcgui->{error}){ |
|
323
|
|
|
|
|
|
|
print "Error!"; |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
sub getUseX{ |
|
329
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
330
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
331
|
|
|
|
|
|
|
|
|
332
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
333
|
0
|
|
|
|
|
|
return undef; |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
|
|
336
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
337
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
338
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
339
|
0
|
|
|
|
|
|
$self->warn; |
|
340
|
0
|
|
|
|
|
|
return undef; |
|
341
|
|
|
|
|
|
|
} |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
#the change it for fetching the info |
|
344
|
0
|
|
|
|
|
|
my $module2=$module; |
|
345
|
0
|
|
|
|
|
|
$module2=~s/\:\:/\//g; |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
#fetch the preferences for the module |
|
348
|
0
|
|
|
|
|
|
my %vars=$self->{zconf}->regexVarGet('gui', '^useX/'.quotemeta($module2).'$'); |
|
349
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
350
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
351
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "gui".'. |
|
352
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
353
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
354
|
0
|
|
|
|
|
|
$self->warn; |
|
355
|
0
|
|
|
|
|
|
return undef; |
|
356
|
|
|
|
|
|
|
} |
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
#if we don't get it, try the default |
|
359
|
0
|
0
|
|
|
|
|
if (!defined($vars{'modules/'.$module2})) { |
|
360
|
0
|
|
|
|
|
|
return 1; |
|
361
|
|
|
|
|
|
|
} |
|
362
|
|
|
|
|
|
|
|
|
363
|
0
|
|
|
|
|
|
return $vars{'modules/'.$module2}; |
|
364
|
|
|
|
|
|
|
} |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=head2 hasPreferred |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
This checks to make sure a module has any prefences or not. The |
|
369
|
|
|
|
|
|
|
returned value is a perl bolean value. |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
my $returned=$zg->hasPreferred("ZConf::BGSet"); |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=cut |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
sub hasPreferred{ |
|
376
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
377
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
378
|
|
|
|
|
|
|
|
|
379
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
380
|
0
|
|
|
|
|
|
return undef; |
|
381
|
|
|
|
|
|
|
} |
|
382
|
|
|
|
|
|
|
|
|
383
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
384
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
385
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
386
|
0
|
|
|
|
|
|
$self->warn; |
|
387
|
0
|
|
|
|
|
|
return undef; |
|
388
|
|
|
|
|
|
|
} |
|
389
|
|
|
|
|
|
|
|
|
390
|
0
|
|
|
|
|
|
my %vars=$self->{zconf}->regexVarGet('gui', '^modules/'.quotemeta($module).'$'); |
|
391
|
0
|
0
|
|
|
|
|
if( $self->{zconf}->error ){ |
|
392
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
393
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "gui".'. |
|
394
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
395
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
396
|
0
|
|
|
|
|
|
$self->warn; |
|
397
|
0
|
|
|
|
|
|
return undef; |
|
398
|
|
|
|
|
|
|
} |
|
399
|
|
|
|
|
|
|
|
|
400
|
0
|
0
|
|
|
|
|
if (!defined($vars{'modules/'.$module})) { |
|
401
|
0
|
|
|
|
|
|
return undef; |
|
402
|
|
|
|
|
|
|
} |
|
403
|
|
|
|
|
|
|
|
|
404
|
0
|
|
|
|
|
|
return 1; |
|
405
|
|
|
|
|
|
|
} |
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=head2 init |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
This initializes it or a new set. |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
If the specified set already exists, it will be reset. |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
One arguement is required and it is the name of the set. If |
|
414
|
|
|
|
|
|
|
it is not defined, ZConf will use the default one. |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
#creates a new set named foo |
|
417
|
|
|
|
|
|
|
$zcw->init('foo'); |
|
418
|
|
|
|
|
|
|
if($zg->{error}){ |
|
419
|
|
|
|
|
|
|
print "Error!\n"; |
|
420
|
|
|
|
|
|
|
} |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
#creates a new set with ZConf choosing it's name |
|
423
|
|
|
|
|
|
|
$zg->init(); |
|
424
|
|
|
|
|
|
|
if($zg->{error}){ |
|
425
|
|
|
|
|
|
|
print "Error!\n"; |
|
426
|
|
|
|
|
|
|
} |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=cut |
|
429
|
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
sub init{ |
|
431
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
432
|
0
|
|
|
|
|
|
my $set=$_[1]; |
|
433
|
|
|
|
|
|
|
|
|
434
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
435
|
0
|
|
|
|
|
|
return undef; |
|
436
|
|
|
|
|
|
|
} |
|
437
|
|
|
|
|
|
|
|
|
438
|
0
|
|
|
|
|
|
my $returned = $self->{zconf}->configExists("gui"); |
|
439
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
440
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
441
|
0
|
|
|
|
|
|
$self->{errorString}="Could not check if the config 'gui' exists.". |
|
442
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
443
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
444
|
0
|
|
|
|
|
|
$self->warn; |
|
445
|
0
|
|
|
|
|
|
return undef; |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
#create the config if it does not exist |
|
449
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
450
|
0
|
|
|
|
|
|
$self->{zconf}->createConfig("gui"); |
|
451
|
0
|
0
|
|
|
|
|
if ($self->{zconf}->{error}) { |
|
452
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
453
|
0
|
|
|
|
|
|
$self->{errorString}="Could not create the ZConf config 'gui'.". |
|
454
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
455
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
456
|
0
|
|
|
|
|
|
$self->warn; |
|
457
|
0
|
|
|
|
|
|
return undef; |
|
458
|
|
|
|
|
|
|
} |
|
459
|
|
|
|
|
|
|
} |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
#create the new set |
|
462
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromHash({config=>"gui", set=>$set}, |
|
463
|
|
|
|
|
|
|
{ |
|
464
|
|
|
|
|
|
|
default=>"GTK:Curses", |
|
465
|
|
|
|
|
|
|
appendOthers=>'1', |
|
466
|
|
|
|
|
|
|
} |
|
467
|
|
|
|
|
|
|
); |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
#error if the write failed |
|
470
|
0
|
0
|
|
|
|
|
if ( $self->{zconf}->error ) { |
|
471
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
472
|
0
|
|
|
|
|
|
$self->{errorString}="writeSetFromHash failed.". |
|
473
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
474
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
475
|
0
|
|
|
|
|
|
$self->warn; |
|
476
|
0
|
|
|
|
|
|
return undef; |
|
477
|
|
|
|
|
|
|
} |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
#now that it is initiated, load it |
|
480
|
0
|
|
|
|
|
|
$self->{zconf}->read({config=>'gui', set=>$set}); |
|
481
|
0
|
0
|
|
|
|
|
if ( $self->{zconf}->error ) { |
|
482
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
483
|
0
|
|
|
|
|
|
$self->{errorString}="read failed.". |
|
484
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
485
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
486
|
0
|
|
|
|
|
|
$self->warn; |
|
487
|
0
|
|
|
|
|
|
return undef; |
|
488
|
|
|
|
|
|
|
} |
|
489
|
|
|
|
|
|
|
|
|
490
|
0
|
|
|
|
|
|
return 1; |
|
491
|
|
|
|
|
|
|
} |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=head2 listAvailable |
|
494
|
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
This is the available GUI modules for a module. |
|
496
|
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
my @available=$zg->listAvailable('ZConf::Runner'); |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=cut |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
sub listAvailable{ |
|
502
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
503
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
504
|
|
|
|
|
|
|
|
|
505
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
506
|
0
|
|
|
|
|
|
return undef; |
|
507
|
|
|
|
|
|
|
} |
|
508
|
|
|
|
|
|
|
|
|
509
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
510
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
511
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
512
|
0
|
|
|
|
|
|
$self->warn; |
|
513
|
0
|
|
|
|
|
|
return undef; |
|
514
|
|
|
|
|
|
|
} |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
#this is what will be checked for and scrubbed upon return |
|
517
|
0
|
|
|
|
|
|
my $check=$module.'::GUI::'; |
|
518
|
|
|
|
|
|
|
|
|
519
|
0
|
|
|
|
|
|
my $modules=list_modules($check,{ list_modules => 1}); |
|
520
|
|
|
|
|
|
|
#testing shows this should not happen, but in case it does, handle it |
|
521
|
0
|
0
|
|
|
|
|
if ( ! defined($modules) ) { |
|
522
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
523
|
0
|
|
|
|
|
|
$self->{errorString}='list_modules failed'; |
|
524
|
0
|
|
|
|
|
|
$self->warn; |
|
525
|
0
|
|
|
|
|
|
return undef; |
|
526
|
|
|
|
|
|
|
} |
|
527
|
|
|
|
|
|
|
|
|
528
|
0
|
|
|
|
|
|
my @mods=keys(%{$modules}); |
|
|
0
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
|
|
530
|
0
|
|
|
|
|
|
my $int=0; |
|
531
|
0
|
|
|
|
|
|
while ($mods[$int]) { |
|
532
|
0
|
|
|
|
|
|
$mods[$int]=~s/^$check//; |
|
533
|
0
|
|
|
|
|
|
$int++; |
|
534
|
|
|
|
|
|
|
} |
|
535
|
|
|
|
|
|
|
|
|
536
|
0
|
|
|
|
|
|
return @mods; |
|
537
|
|
|
|
|
|
|
} |
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=head2 listModules |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
This lists configured modules. |
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
my @modules=$zg->listModules; |
|
544
|
|
|
|
|
|
|
if($zg->{error}){ |
|
545
|
|
|
|
|
|
|
print "Error!\n"; |
|
546
|
|
|
|
|
|
|
} |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=cut |
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
sub listModules{ |
|
551
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
552
|
|
|
|
|
|
|
|
|
553
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
554
|
0
|
|
|
|
|
|
return undef; |
|
555
|
|
|
|
|
|
|
} |
|
556
|
|
|
|
|
|
|
|
|
557
|
0
|
|
|
|
|
|
my @modules=$self->{zconf}->regexVarSearch('gui', '^modules'); |
|
558
|
0
|
0
|
|
|
|
|
if ( $self->{zconf}->error ) { |
|
559
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
560
|
0
|
|
|
|
|
|
$self->{errorString}="regexVarSearch failed.". |
|
561
|
|
|
|
|
|
|
" It failed with '".$self->{zconf}->error."', '" |
|
562
|
|
|
|
|
|
|
.$self->{zconf}->errorString."'"; |
|
563
|
0
|
|
|
|
|
|
$self->warn; |
|
564
|
0
|
|
|
|
|
|
return undef; |
|
565
|
|
|
|
|
|
|
} |
|
566
|
|
|
|
|
|
|
|
|
567
|
0
|
|
|
|
|
|
my $int=0; |
|
568
|
|
|
|
|
|
|
#removes leading /^modules\// |
|
569
|
|
|
|
|
|
|
#also make sure that the ZConf var stuff is replaced with :: |
|
570
|
0
|
|
|
|
|
|
while (defined($modules[$int])) { |
|
571
|
0
|
|
|
|
|
|
$modules[$int]=~s/^modules\///; |
|
572
|
0
|
|
|
|
|
|
$modules[$int]=~s/\//\:\:/g; |
|
573
|
|
|
|
|
|
|
|
|
574
|
0
|
|
|
|
|
|
$int++; |
|
575
|
|
|
|
|
|
|
} |
|
576
|
|
|
|
|
|
|
|
|
577
|
0
|
|
|
|
|
|
return @modules; |
|
578
|
|
|
|
|
|
|
} |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
=head2 listSets |
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
This lists the available sets. |
|
583
|
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
my @sets=$zg->listSets; |
|
585
|
|
|
|
|
|
|
if($zg->{error}){ |
|
586
|
|
|
|
|
|
|
print "Error!"; |
|
587
|
|
|
|
|
|
|
} |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=cut |
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
sub listSets{ |
|
592
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
593
|
|
|
|
|
|
|
|
|
594
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
595
|
0
|
|
|
|
|
|
return undef; |
|
596
|
|
|
|
|
|
|
} |
|
597
|
|
|
|
|
|
|
|
|
598
|
0
|
|
|
|
|
|
my @sets=$self->{zconf}->getAvailableSets('gui'); |
|
599
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
600
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
601
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "gui".'. |
|
602
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
603
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
604
|
0
|
|
|
|
|
|
$self->warn; |
|
605
|
0
|
|
|
|
|
|
return undef; |
|
606
|
|
|
|
|
|
|
} |
|
607
|
|
|
|
|
|
|
|
|
608
|
0
|
|
|
|
|
|
return @sets; |
|
609
|
|
|
|
|
|
|
} |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
=head2 readSet |
|
612
|
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
This reads a specific set. If the set specified |
|
614
|
|
|
|
|
|
|
is undef, the default set is read. |
|
615
|
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
#read the default set |
|
617
|
|
|
|
|
|
|
$zg->readSet(); |
|
618
|
|
|
|
|
|
|
if($zg->{error}){ |
|
619
|
|
|
|
|
|
|
print "Error!\n"; |
|
620
|
|
|
|
|
|
|
} |
|
621
|
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
#read the set 'someSet' |
|
623
|
|
|
|
|
|
|
$zg->readSet('someSet'); |
|
624
|
|
|
|
|
|
|
if($zg->{error}){ |
|
625
|
|
|
|
|
|
|
print "Error!\n"; |
|
626
|
|
|
|
|
|
|
} |
|
627
|
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=cut |
|
629
|
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
sub readSet{ |
|
631
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
632
|
0
|
|
|
|
|
|
my $set=$_[1]; |
|
633
|
|
|
|
|
|
|
|
|
634
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
635
|
0
|
|
|
|
|
|
return undef; |
|
636
|
|
|
|
|
|
|
} |
|
637
|
|
|
|
|
|
|
|
|
638
|
0
|
|
|
|
|
|
$self->{zconf}->read({config=>'gui', set=>$set}); |
|
639
|
0
|
0
|
|
|
|
|
if ( $self->{zconf}->error ) { |
|
640
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
641
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error reading the config "gui".'. |
|
642
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
643
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
644
|
0
|
|
|
|
|
|
$self->warn; |
|
645
|
0
|
|
|
|
|
|
return undef; |
|
646
|
|
|
|
|
|
|
} |
|
647
|
|
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
return 1; |
|
649
|
|
|
|
|
|
|
} |
|
650
|
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
=head2 rmPreferred |
|
652
|
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
This removes a the preferences for a module. |
|
654
|
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
$zg->rmPreferred('ZConf::BGSet'); |
|
656
|
|
|
|
|
|
|
if($zg->{error}){ |
|
657
|
|
|
|
|
|
|
print "Error:".$self->{error}.":".$self->{errorString}; |
|
658
|
|
|
|
|
|
|
} |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=cut |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
sub rmPreferred{ |
|
663
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
664
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
665
|
|
|
|
|
|
|
|
|
666
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
667
|
0
|
|
|
|
|
|
return undef; |
|
668
|
|
|
|
|
|
|
} |
|
669
|
|
|
|
|
|
|
|
|
670
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
671
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
672
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
673
|
0
|
|
|
|
|
|
$self->warn; |
|
674
|
0
|
|
|
|
|
|
return undef; |
|
675
|
|
|
|
|
|
|
} |
|
676
|
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
#remove any specifical characters that have been passed |
|
678
|
0
|
|
|
|
|
|
my $safemodule=quotemeta($module); |
|
679
|
|
|
|
|
|
|
|
|
680
|
0
|
|
|
|
|
|
my @deleted=$self->{zconf}->regexVarDel('gui', '^modules/'.$safemodule.'$'); |
|
681
|
0
|
0
|
|
|
|
|
if ( $self->{zconf}->error ) { |
|
682
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
683
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error reading the config "gui".'. |
|
684
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
685
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
686
|
0
|
|
|
|
|
|
$self->warn; |
|
687
|
0
|
|
|
|
|
|
return undef; |
|
688
|
|
|
|
|
|
|
} |
|
689
|
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
#only one will be matched so we just need to check the first |
|
691
|
0
|
0
|
|
|
|
|
if ( $deleted[0] ne 'modules/'.$module ) { |
|
692
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$module.' not matched"'; |
|
693
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
694
|
0
|
|
|
|
|
|
$self->warn; |
|
695
|
0
|
|
|
|
|
|
return undef; |
|
696
|
|
|
|
|
|
|
} |
|
697
|
|
|
|
|
|
|
|
|
698
|
0
|
|
|
|
|
|
return 1; |
|
699
|
|
|
|
|
|
|
} |
|
700
|
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
=head2 setAppendOthers |
|
702
|
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
This sets the value for append others. |
|
704
|
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
Only one value is accepted and that is a boolean |
|
706
|
|
|
|
|
|
|
value. |
|
707
|
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
$zg->setAppendOthers($boolean); |
|
709
|
|
|
|
|
|
|
if($zg->{error}){ |
|
710
|
|
|
|
|
|
|
print "Error!\n"; |
|
711
|
|
|
|
|
|
|
} |
|
712
|
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
=cut |
|
714
|
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
sub setAppendOthers{ |
|
716
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
717
|
0
|
|
|
|
|
|
my $boolean=$_[1]; |
|
718
|
|
|
|
|
|
|
|
|
719
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
720
|
0
|
|
|
|
|
|
return undef; |
|
721
|
|
|
|
|
|
|
} |
|
722
|
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
#make sure we were passed something |
|
724
|
0
|
0
|
|
|
|
|
if (!defined($boolean)) { |
|
725
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
726
|
0
|
|
|
|
|
|
$self->{errorString}='No value specified to set "appendOthers" to'; |
|
727
|
0
|
|
|
|
|
|
$self->warn; |
|
728
|
0
|
|
|
|
|
|
return undef; |
|
729
|
|
|
|
|
|
|
} |
|
730
|
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
#make sure it is a 0 or 1 |
|
732
|
0
|
0
|
|
|
|
|
if ($boolean !~ /^[01]$/) { |
|
733
|
0
|
|
|
|
|
|
$self->{error}=9; |
|
734
|
0
|
|
|
|
|
|
$self->{errorString}='The value "'.$boolean.'" does not match /^[01]$/'; |
|
735
|
0
|
|
|
|
|
|
$self->warn; |
|
736
|
0
|
|
|
|
|
|
return undef; |
|
737
|
|
|
|
|
|
|
} |
|
738
|
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
#set the value |
|
740
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('gui', 'appendOther'); |
|
741
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
742
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
743
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error setting "appendOthers" for "gui".'. |
|
744
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
745
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
746
|
0
|
|
|
|
|
|
$self->warn; |
|
747
|
0
|
|
|
|
|
|
return undef; |
|
748
|
|
|
|
|
|
|
} |
|
749
|
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
#update it |
|
751
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromLoadedConfig({config=>'gui'}); |
|
752
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
753
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
754
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error saving config "gui".'. |
|
755
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
756
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
757
|
0
|
|
|
|
|
|
$self->warn; |
|
758
|
0
|
|
|
|
|
|
return undef; |
|
759
|
|
|
|
|
|
|
} |
|
760
|
|
|
|
|
|
|
|
|
761
|
0
|
|
|
|
|
|
return 1; |
|
762
|
|
|
|
|
|
|
} |
|
763
|
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=head2 setPreferred |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
This sets the preferred GUI back ends. The first arguement is the module. |
|
767
|
|
|
|
|
|
|
The second is a array reference of the prefences. |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
my @prefs=('GUI', 'Curses'); |
|
770
|
|
|
|
|
|
|
#set it for ZConf::BGSet |
|
771
|
|
|
|
|
|
|
my $zg->setPreferred('ZConf::BGSet', \@prefs); |
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
=cut |
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
sub setPreferred{ |
|
776
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
777
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
778
|
0
|
|
|
|
|
|
my $prefs; |
|
779
|
0
|
0
|
|
|
|
|
if (defined($_[2])) { |
|
780
|
0
|
|
|
|
|
|
$prefs=$_[2]; |
|
781
|
|
|
|
|
|
|
} |
|
782
|
|
|
|
|
|
|
|
|
783
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
784
|
0
|
|
|
|
|
|
return undef; |
|
785
|
|
|
|
|
|
|
} |
|
786
|
|
|
|
|
|
|
|
|
787
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
788
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
789
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
790
|
0
|
|
|
|
|
|
$self->warn; |
|
791
|
0
|
|
|
|
|
|
return undef; |
|
792
|
|
|
|
|
|
|
} |
|
793
|
|
|
|
|
|
|
|
|
794
|
0
|
0
|
|
|
|
|
if (!defined(@{$prefs}[0])) { |
|
|
0
|
|
|
|
|
|
|
|
795
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
796
|
0
|
|
|
|
|
|
$self->{errorString}='No prefs specified'; |
|
797
|
0
|
|
|
|
|
|
$self->warn; |
|
798
|
0
|
|
|
|
|
|
return undef; |
|
799
|
|
|
|
|
|
|
} |
|
800
|
|
|
|
|
|
|
|
|
801
|
0
|
|
|
|
|
|
my $int=0; |
|
802
|
0
|
|
|
|
|
|
while (defined(@{$prefs}[$int])){ |
|
|
0
|
|
|
|
|
|
|
|
803
|
0
|
0
|
|
|
|
|
if (@{$prefs}[$int] =~ /:/) { |
|
|
0
|
|
|
|
|
|
|
|
804
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
805
|
0
|
|
|
|
|
|
$self->{errorString}='"'.@{$prefs}[$int].'" matched /:/'; |
|
|
0
|
|
|
|
|
|
|
|
806
|
0
|
|
|
|
|
|
$self->warn; |
|
807
|
0
|
|
|
|
|
|
return undef; |
|
808
|
|
|
|
|
|
|
} |
|
809
|
|
|
|
|
|
|
|
|
810
|
0
|
|
|
|
|
|
$int++; |
|
811
|
|
|
|
|
|
|
} |
|
812
|
|
|
|
|
|
|
|
|
813
|
0
|
|
|
|
|
|
$module=~s/::/\//g; |
|
814
|
|
|
|
|
|
|
|
|
815
|
0
|
|
|
|
|
|
my $joinedprefs=join(':', @{$prefs}); |
|
|
0
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
|
|
817
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('gui', 'modules/'.$module, $joinedprefs); |
|
818
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
819
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
820
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "gui".'. |
|
821
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
822
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
823
|
0
|
|
|
|
|
|
$self->warn; |
|
824
|
0
|
|
|
|
|
|
return undef; |
|
825
|
|
|
|
|
|
|
} |
|
826
|
|
|
|
|
|
|
|
|
827
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromLoadedConfig({config=>'gui'}); |
|
828
|
0
|
0
|
|
|
|
|
if($self->{zconf}->error){ |
|
829
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
830
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error saving config "gui".'. |
|
831
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
832
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
833
|
0
|
|
|
|
|
|
$self->warn; |
|
834
|
0
|
|
|
|
|
|
return undef; |
|
835
|
|
|
|
|
|
|
} |
|
836
|
|
|
|
|
|
|
|
|
837
|
0
|
|
|
|
|
|
return 1; |
|
838
|
|
|
|
|
|
|
} |
|
839
|
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=head2 setUseX |
|
841
|
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
This determines if X should be used or not. This only affects terminal |
|
843
|
|
|
|
|
|
|
related modules that respect this. |
|
844
|
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
$zcgui->setUseX('ZConf::Runner', '1'); |
|
846
|
|
|
|
|
|
|
if($zcgui->{error}){ |
|
847
|
|
|
|
|
|
|
print "Error!"; |
|
848
|
|
|
|
|
|
|
} |
|
849
|
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
=cut |
|
851
|
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
sub setUseX{ |
|
853
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
854
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
855
|
0
|
|
|
|
|
|
my $useX=$_[2]; |
|
856
|
|
|
|
|
|
|
|
|
857
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
858
|
0
|
|
|
|
|
|
return undef; |
|
859
|
|
|
|
|
|
|
} |
|
860
|
|
|
|
|
|
|
|
|
861
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
862
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
863
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
864
|
0
|
|
|
|
|
|
$self->warn; |
|
865
|
0
|
|
|
|
|
|
return undef; |
|
866
|
|
|
|
|
|
|
} |
|
867
|
|
|
|
|
|
|
|
|
868
|
0
|
0
|
|
|
|
|
if (!defined($useX)) { |
|
869
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
870
|
0
|
|
|
|
|
|
$self->{errorString}='No prefs specified'; |
|
871
|
0
|
|
|
|
|
|
$self->warn; |
|
872
|
0
|
|
|
|
|
|
return undef; |
|
873
|
|
|
|
|
|
|
} |
|
874
|
|
|
|
|
|
|
|
|
875
|
0
|
|
|
|
|
|
$module=~s/::/\//g; |
|
876
|
|
|
|
|
|
|
|
|
877
|
0
|
|
|
|
|
|
$self->{zconf}->setVar('gui', 'useX/'.$module, $useX); |
|
878
|
0
|
0
|
|
|
|
|
if($self->{zconf}->{error}){ |
|
879
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
880
|
0
|
|
|
|
|
|
$self->{errorString}='ZConf error listing sets for the config "gui".'. |
|
881
|
|
|
|
|
|
|
' ZConf error="'.$self->{zconf}->error.'" '. |
|
882
|
|
|
|
|
|
|
'ZConf error string="'.$self->{zconf}->errorString.'"'; |
|
883
|
0
|
|
|
|
|
|
$self->warn; |
|
884
|
0
|
|
|
|
|
|
return undef; |
|
885
|
|
|
|
|
|
|
} |
|
886
|
|
|
|
|
|
|
|
|
887
|
0
|
|
|
|
|
|
$self->{zconf}->writeSetFromLoadedConfig({config=>'gui'}); |
|
888
|
|
|
|
|
|
|
|
|
889
|
0
|
|
|
|
|
|
return 1; |
|
890
|
|
|
|
|
|
|
} |
|
891
|
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
=head2 termAvailable |
|
893
|
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
This checks to see if a terminal is available. It checks |
|
895
|
|
|
|
|
|
|
if $ENV{TERM} is set or not. If this is not set, it was most |
|
896
|
|
|
|
|
|
|
likely not ran from with a terminal. |
|
897
|
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
if($zg->termAvailable){ |
|
899
|
|
|
|
|
|
|
print "a terminal is available"; |
|
900
|
|
|
|
|
|
|
}else{ |
|
901
|
|
|
|
|
|
|
print "no terminal is available"; |
|
902
|
|
|
|
|
|
|
} |
|
903
|
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
=cut |
|
905
|
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
sub termAvailable{ |
|
907
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
908
|
|
|
|
|
|
|
|
|
909
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
910
|
0
|
|
|
|
|
|
return undef; |
|
911
|
|
|
|
|
|
|
} |
|
912
|
|
|
|
|
|
|
|
|
913
|
0
|
0
|
|
|
|
|
if (!defined($ENV{TERM})) { |
|
914
|
0
|
|
|
|
|
|
return undef; |
|
915
|
|
|
|
|
|
|
} |
|
916
|
|
|
|
|
|
|
|
|
917
|
0
|
|
|
|
|
|
return 1; |
|
918
|
|
|
|
|
|
|
} |
|
919
|
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
=head2 Xavailable |
|
921
|
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
This checks if X is available. This is checked for by trying to run |
|
923
|
|
|
|
|
|
|
'/bin/sh -c \'xhost 2> /dev/null > /dev/null\'' and is assumed if a |
|
924
|
|
|
|
|
|
|
non-zero exit code is returned then it failed and thus X is not |
|
925
|
|
|
|
|
|
|
available. |
|
926
|
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
There is no reason to ever check $zcr->{error} with |
|
928
|
|
|
|
|
|
|
this as this function will not set it. It just returns |
|
929
|
|
|
|
|
|
|
a boolean value. |
|
930
|
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
if($zg->Xavailable()){ |
|
932
|
|
|
|
|
|
|
print "X is available\n"; |
|
933
|
|
|
|
|
|
|
} |
|
934
|
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
=cut |
|
936
|
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
sub Xavailable{ |
|
938
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
939
|
|
|
|
|
|
|
|
|
940
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
941
|
0
|
|
|
|
|
|
return undef; |
|
942
|
|
|
|
|
|
|
} |
|
943
|
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
#if this is defined, the next one definitely will not work |
|
945
|
0
|
0
|
|
|
|
|
if (!defined($ENV{DISPLAY})) { |
|
946
|
0
|
|
|
|
|
|
return undef; |
|
947
|
|
|
|
|
|
|
} |
|
948
|
|
|
|
|
|
|
|
|
949
|
|
|
|
|
|
|
#exists non-zero if it fails |
|
950
|
0
|
|
|
|
|
|
my $command='/bin/sh -c \'xhost 2> /dev/null > /dev/null\''; |
|
951
|
0
|
|
|
|
|
|
system($command); |
|
952
|
|
|
|
|
|
|
#if xhost exits with a non-zero then X is not available |
|
953
|
0
|
|
|
|
|
|
my $exitcode=$? >> 8; |
|
954
|
0
|
0
|
|
|
|
|
if ($exitcode ne '0'){ |
|
955
|
0
|
|
|
|
|
|
return undef; |
|
956
|
|
|
|
|
|
|
} |
|
957
|
|
|
|
|
|
|
|
|
958
|
0
|
|
|
|
|
|
return 1; |
|
959
|
|
|
|
|
|
|
} |
|
960
|
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
=head2 useX |
|
962
|
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
This checks to see if a terminal interface should try to use X or not by |
|
964
|
|
|
|
|
|
|
trying to spawn a X terminal. |
|
965
|
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
This calls getUseX and if it is true, it calls Xavailable and returns it's |
|
967
|
|
|
|
|
|
|
value. |
|
968
|
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
my $useX=$zcgui->useX('ZConf::Runner'); |
|
970
|
|
|
|
|
|
|
|
|
971
|
|
|
|
|
|
|
=cut |
|
972
|
|
|
|
|
|
|
|
|
973
|
|
|
|
|
|
|
sub useX{ |
|
974
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
975
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
976
|
|
|
|
|
|
|
|
|
977
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
978
|
0
|
|
|
|
|
|
return undef; |
|
979
|
|
|
|
|
|
|
} |
|
980
|
|
|
|
|
|
|
|
|
981
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
982
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
983
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
984
|
0
|
|
|
|
|
|
$self->warn; |
|
985
|
0
|
|
|
|
|
|
return undef; |
|
986
|
|
|
|
|
|
|
} |
|
987
|
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
#get if X should be used |
|
989
|
0
|
|
|
|
|
|
my $useX=$self->getUseX($module); |
|
990
|
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
#if it should be used, make sure it is available |
|
992
|
0
|
0
|
|
|
|
|
if ($useX) { |
|
993
|
0
|
|
|
|
|
|
return $self->Xavailable; |
|
994
|
|
|
|
|
|
|
} |
|
995
|
|
|
|
|
|
|
|
|
996
|
0
|
|
|
|
|
|
return undef; |
|
997
|
|
|
|
|
|
|
} |
|
998
|
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
=head2 which |
|
1000
|
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
This chooses which should be used. This returns all available |
|
1002
|
|
|
|
|
|
|
backends in order of preference. |
|
1003
|
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
my @choosen=$zg->which('ZConf::BGSet'); |
|
1005
|
|
|
|
|
|
|
if($zg->{error}){ |
|
1006
|
|
|
|
|
|
|
print "Error!"; |
|
1007
|
|
|
|
|
|
|
} |
|
1008
|
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
print 'The primary preferred module is "'.$choosen[0].'"'; |
|
1010
|
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
=cut |
|
1012
|
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
sub which{ |
|
1014
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
1015
|
0
|
|
|
|
|
|
my $module=$_[1]; |
|
1016
|
|
|
|
|
|
|
|
|
1017
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
1018
|
0
|
|
|
|
|
|
return undef; |
|
1019
|
|
|
|
|
|
|
} |
|
1020
|
|
|
|
|
|
|
|
|
1021
|
0
|
0
|
|
|
|
|
if (!defined($module)) { |
|
1022
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
1023
|
0
|
|
|
|
|
|
$self->{errorString}='No module specified'; |
|
1024
|
0
|
|
|
|
|
|
$self->warn; |
|
1025
|
0
|
|
|
|
|
|
return undef; |
|
1026
|
|
|
|
|
|
|
} |
|
1027
|
|
|
|
|
|
|
|
|
1028
|
0
|
|
|
|
|
|
my @prefs=$self->getPreferred($module); |
|
1029
|
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
#checks if X and/or a terminal is available |
|
1031
|
0
|
|
|
|
|
|
my $Xavailable=$self->Xavailable(); |
|
1032
|
0
|
|
|
|
|
|
my $termAvailable=$self->termAvailable(); |
|
1033
|
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
#gets usable modules |
|
1035
|
0
|
|
|
|
|
|
my @available=$self->listAvailable($module); |
|
1036
|
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
#this will be returned |
|
1038
|
0
|
|
|
|
|
|
my @usable; |
|
1039
|
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
#get the preferred ones |
|
1041
|
0
|
|
|
|
|
|
my @preferred=$self->getPreferred($module); |
|
1042
|
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
#builds the list out of the prefered modules initially |
|
1044
|
0
|
|
|
|
|
|
my $int=0; |
|
1045
|
0
|
|
|
|
|
|
while (defined($preferred[$int])) { |
|
1046
|
0
|
|
|
|
|
|
my $aint=0; |
|
1047
|
0
|
|
|
|
|
|
my $matched=0; |
|
1048
|
0
|
|
0
|
|
|
|
while ((defined($available[$aint])) && (!$matched)) { |
|
1049
|
0
|
0
|
|
|
|
|
if ($preferred[$int] eq $available[$aint]) { |
|
1050
|
0
|
0
|
|
|
|
|
if ($Xavailable) { |
|
1051
|
0
|
|
|
|
|
|
push(@usable, $preferred[$int]); |
|
1052
|
0
|
|
|
|
|
|
$matched=1; |
|
1053
|
|
|
|
|
|
|
}else { |
|
1054
|
0
|
0
|
|
|
|
|
if ($preferred[$int]=~/^Term/) { |
|
1055
|
0
|
|
|
|
|
|
push(@usable, $preferred[$int]); |
|
1056
|
|
|
|
|
|
|
} |
|
1057
|
0
|
0
|
|
|
|
|
if ($preferred[$int]=~/^Curses/) { |
|
1058
|
0
|
|
|
|
|
|
push(@usable, $preferred[$int]); |
|
1059
|
|
|
|
|
|
|
} |
|
1060
|
0
|
|
|
|
|
|
$matched=1; |
|
1061
|
|
|
|
|
|
|
} |
|
1062
|
|
|
|
|
|
|
|
|
1063
|
0
|
|
|
|
|
|
$aint++; |
|
1064
|
|
|
|
|
|
|
} |
|
1065
|
|
|
|
|
|
|
|
|
1066
|
0
|
|
|
|
|
|
$aint++; |
|
1067
|
|
|
|
|
|
|
} |
|
1068
|
|
|
|
|
|
|
|
|
1069
|
0
|
|
|
|
|
|
$int++; |
|
1070
|
|
|
|
|
|
|
} |
|
1071
|
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
|
|
1073
|
|
|
|
|
|
|
#determine if we should append others or not |
|
1074
|
0
|
|
|
|
|
|
my $ao=$self->getAppendOthers; |
|
1075
|
0
|
0
|
|
|
|
|
if ($self->error) { |
|
1076
|
0
|
|
|
|
|
|
$self->warnString('getAppendOthers errored'); |
|
1077
|
0
|
|
|
|
|
|
return undef; |
|
1078
|
|
|
|
|
|
|
} |
|
1079
|
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
#only process AO if we need to |
|
1081
|
0
|
0
|
|
|
|
|
if (!$ao) { |
|
1082
|
0
|
|
|
|
|
|
return @usable; |
|
1083
|
|
|
|
|
|
|
} |
|
1084
|
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
#append others if we need to |
|
1086
|
0
|
|
|
|
|
|
$int=0; |
|
1087
|
0
|
|
|
|
|
|
while (defined($available[$int])) { |
|
1088
|
|
|
|
|
|
|
#make sure it has not been added previously |
|
1089
|
0
|
|
|
|
|
|
my $matched=0; |
|
1090
|
0
|
|
|
|
|
|
my $int2=0; |
|
1091
|
0
|
|
|
|
|
|
while ($usable[$int2]) { |
|
1092
|
0
|
0
|
|
|
|
|
if ($usable[$int2] eq $available[$int]) { |
|
1093
|
0
|
|
|
|
|
|
$matched=1; |
|
1094
|
|
|
|
|
|
|
} |
|
1095
|
|
|
|
|
|
|
|
|
1096
|
0
|
|
|
|
|
|
$int2++; |
|
1097
|
|
|
|
|
|
|
} |
|
1098
|
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
#if it is not matched, added it |
|
1100
|
0
|
0
|
|
|
|
|
if (!$matched) { |
|
1101
|
0
|
|
|
|
|
|
push(@usable, $available[$int]); |
|
1102
|
|
|
|
|
|
|
} |
|
1103
|
|
|
|
|
|
|
|
|
1104
|
0
|
|
|
|
|
|
$int++; |
|
1105
|
|
|
|
|
|
|
} |
|
1106
|
|
|
|
|
|
|
|
|
1107
|
0
|
|
|
|
|
|
return @usable; |
|
1108
|
|
|
|
|
|
|
} |
|
1109
|
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
=head2 ERROR CODES/FLAGS HANDLING |
|
1111
|
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
This module L for error handling. |
|
1113
|
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
=head3 1, zconf |
|
1115
|
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
ZConf error. Check $self->{zconf}->error. |
|
1117
|
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
=head3 2, missingArg |
|
1119
|
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
No module specified. |
|
1121
|
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
=head3 3, missingArg |
|
1123
|
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
No preferences specified. |
|
1125
|
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
=head3 4, colon |
|
1127
|
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
A preference matched /:/. |
|
1129
|
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=head3 5, noPrefs |
|
1131
|
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
No preferences for the listed module. |
|
1133
|
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
=head3 6, lmFailed |
|
1135
|
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
'list_modules' failed. |
|
1137
|
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
=head3 7, modDNE |
|
1139
|
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
The specified module does not exist. |
|
1141
|
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
=head3 8, missingArg |
|
1143
|
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
No value for what to set appendOthers to specified. |
|
1145
|
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
=head3 9, notBoolean |
|
1147
|
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
The value specified for appendOthers is not boolean. |
|
1149
|
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
=head1 ZConf Keys |
|
1151
|
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
These are stored in config 'gui'. |
|
1153
|
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
Each preference is stored as a string for a module. Each preference is seperated |
|
1155
|
|
|
|
|
|
|
as by ':'. The order of the preferred go from favorite to least favorite. |
|
1156
|
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
=head2 default |
|
1158
|
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
This is the default to use if nothing is setup for a module. The default value is |
|
1160
|
|
|
|
|
|
|
'GTK:Curses'. |
|
1161
|
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
=head2 appendOthers |
|
1163
|
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
If this is set to true, "1", when which is called, all the others will be appended after |
|
1165
|
|
|
|
|
|
|
the list of available preferred ones. |
|
1166
|
|
|
|
|
|
|
|
|
1167
|
|
|
|
|
|
|
If this is not defined, it will default to true. |
|
1168
|
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
=head2 modules/* |
|
1170
|
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
This contains the a list of preferences for a module. |
|
1172
|
|
|
|
|
|
|
|
|
1173
|
|
|
|
|
|
|
The module name is converted to a ZConf variable name by replacing '::' with '/'. |
|
1174
|
|
|
|
|
|
|
|
|
1175
|
|
|
|
|
|
|
=head2 useX/* |
|
1176
|
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
This is if a cuses module should use X or not. If it is true, it will pass |
|
1178
|
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
If if is not defined, it is set to true. |
|
1180
|
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
The module name is converted to a ZConf variable name by replacing '::' with '/'. |
|
1182
|
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
=head1 USING ZConf::GUI |
|
1184
|
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
A backend is considered to be any thing directly under ::GUI. How to call it |
|
1186
|
|
|
|
|
|
|
or etc is directly up to the calling module though. |
|
1187
|
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
Any module using this, should have it's widgets and dialogs use a single hash for all it's |
|
1189
|
|
|
|
|
|
|
arguements. This is currently not a requirement, but will be in future versions for future |
|
1190
|
|
|
|
|
|
|
automated calling. |
|
1191
|
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
=head2 suggested methods |
|
1193
|
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
=head3 app |
|
1195
|
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
This initiates a application. If it is called, it is not expected to return. |
|
1197
|
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
=head3 hasApp |
|
1199
|
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
This quaries a module to check to see if it has a app. |
|
1201
|
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
=head3 dialogs |
|
1203
|
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
This returns a array of dialogs that can be called. These interupt execution till returned. |
|
1205
|
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
=head3 windows |
|
1207
|
|
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
This is a list of windows that can be created. These should return immediately after creating |
|
1209
|
|
|
|
|
|
|
the window. |
|
1210
|
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
=head1 AUTHOR |
|
1212
|
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
|
1214
|
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
=head1 BUGS |
|
1216
|
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
1218
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
1219
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
1220
|
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
|
|
1222
|
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
=head1 SUPPORT |
|
1225
|
|
|
|
|
|
|
|
|
1226
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
1227
|
|
|
|
|
|
|
|
|
1228
|
|
|
|
|
|
|
perldoc ZConf::GUI |
|
1229
|
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
You can also look for information at: |
|
1232
|
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
=over 4 |
|
1234
|
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
1236
|
|
|
|
|
|
|
|
|
1237
|
|
|
|
|
|
|
L |
|
1238
|
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
1240
|
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
L |
|
1242
|
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
1244
|
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
L |
|
1246
|
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
=item * Search CPAN |
|
1248
|
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
L |
|
1250
|
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
=back |
|
1252
|
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
1255
|
|
|
|
|
|
|
|
|
1256
|
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
1258
|
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
|
1260
|
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
1262
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
1263
|
|
|
|
|
|
|
|
|
1264
|
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
=cut |
|
1266
|
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
1; # End of ZConf::GUI |