blib/lib/Video/DVDRip/Config.pm

filter: Statementstmt 50.6% 126 / 249 Branchbran 22.0% 19 / 86 Conditioncond 20.0% 4 / 20 MC/DCmcdc 7.6% 1 / 13 Subroutinesub 43.1% 25 / 58 Podpod 0.0% 0 / 44 totaltotal 37.2% 175 / 470 CC 56 SCAR 31.0
CC
56
Cov
42%
selected_dvd_device_list
127.3
_executable
56.0
_abs_and_writable
30.0
CRAP 22.1
« blib/lib/Video/DVDRip/GUI/FormFactory/SubtitlePreviews.pm ↑ Summary blib/lib/Event/ExecFlow/Job/Command.pm »
1 # $Id: Config.pm 2376 2009-02-22 18:49:03Z joern $
2  
3 #-----------------------------------------------------------------------
4 # Copyright (C) 2001-2006 Jörn Reder <joern AT zyn.de>.
5 # All Rights Reserved. See file COPYRIGHT for details.
6 #
7 # This module is part of Video::DVDRip, which is free software; you can
8 # redistribute it and/or modify it under the same terms as Perl itself.
9 #-----------------------------------------------------------------------
10  
11 package Video::DVDRip::Config;
12 1 ▶use Locale::TextDomain qw (video.dvdrip);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use POSIX qw(locale_h);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use base Video::DVDRip::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 ▶use Video::DVDRip::Preset;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use FileHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 106 ▶sub config { shift->{config} }
Subroutine config: called CC=1 SCAR=0.0
Pod undocumented
25  
26 0 ▶sub order { shift->{order} }
Subroutine order: not called CC=1 SCAR=6.9
Pod undocumented
27 0 ▶sub presets { shift->{presets} }
Subroutine presets: not called CC=1 SCAR=6.9
Pod undocumented
28 3 ▶sub filename { shift->{filename} }
Subroutine filename: called CC=1 SCAR=0.0
Pod undocumented
29 2 ▶sub last_saved_data { shift->{last_saved_data} }
Subroutine last_saved_data: called CC=1 SCAR=0.0
Pod undocumented
30  
31 0 ▶sub set_order { shift->{order} = $_[1] }
Subroutine set_order: not called CC=1 SCAR=6.9
Pod undocumented
32 0 ▶sub set_presets { shift->{presets} = $_[1] }
Subroutine set_presets: not called CC=1 SCAR=6.9
Pod undocumented
33 1 ▶sub set_filename { shift->{filename} = $_[1] }
Subroutine set_filename: called CC=1 SCAR=0.0
Pod undocumented
34 6 ▶sub set_last_saved_data { shift->{last_saved_data} = $_[1] }
Subroutine set_last_saved_data: called CC=1 SCAR=0.0
Pod undocumented
35  
36 1 my @BPP = '<none>';
37 1 ▶for ( my $b = 1.0; $b > 0 && push @BPP, sprintf( "%.2f", $b ); $b -= 0.05 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b > 0 and push @BPP, sprintf("%.2f", $b)) 20 1 21
Condition66%2/3
$b > 0 and push @BPP, sprintf("%.2f", $b)
!ll&&!rl&&r
1020
MC/DC50%1/2
$b > 0 and push @BPP, sprintf("%.2f", $b)
$b > 0 push @BPP, sprintf("%.2f", $b)
Truth table66%2/3
A and B
A= $b > 0B= push @BPP, sprintf("%.2f", $b)
ABresult
0X0
100
111
38 ;
39 }
40  
41 1 my @LANG = (
42 "en - English",
43 "de - Deutsch",
44 "fr - Francais",
45 "es - Espanol",
46 "it - Italiano",
47 "nl - Nederlands",
48 "aa - Afar",
49 "ab - Abkhazian",
50 "af - Afrikaans",
51 "am - Amharic",
52 "ar - Arabic",
53 "as - Assamese",
54 "ay - Aymara",
55 "az - Azerbaijani",
56 "ba - Bashkir",
57 "be - Byelorussian",
58 "bg - Bulgarian",
59 "bh - Bihari",
60 "bi - Bislama",
61 "bn - Bengali / Bangla",
62 "bo - Tibetan",
63 "br - Breton",
64 "ca - Catalan",
65 "co - Corsican",
66 "cs - Czech",
67 "cy - Welsh",
68 "da - Dansk",
69 "dz - Bhutani",
70 "el - Greek",
71 "eo - Esperanto",
72 "et - Estonian",
73 "eu - Basque",
74 "fa - Persian",
75 "fi - Suomi",
76 "fj - Fiji",
77 "fo - Faroese",
78 "fy - Frisian",
79 "ga - Gaelic",
80 "gd - Scots Gaelic",
81 "gl - Galician",
82 "gn - Guarani",
83 "gu - Gujarati",
84 "ha - Hausa",
85 "he - Hebrew",
86 "hi - Hindi",
87 "hr - Hrvatski",
88 "hu - Magyar",
89 "hy - Armenian",
90 "ia - Interlingua",
91 "id - Indonesian",
92 "ie - Interlingue",
93 "ik - Inupiak",
94 "in - Indonesian",
95 "is - Islenska",
96 "iu - Inuktitut",
97 "iw - Hebrew",
98 "ja - Japanese",
99 "ji - Yiddish",
100 "jw - Javanese",
101 "ka - Georgian",
102 "kk - Kazakh",
103 "kl - Greenlandic",
104 "km - Cambodian",
105 "kn - Kannada",
106 "ko - Korean",
107 "ks - Kashmiri",
108 "ku - Kurdish",
109 "ky - Kirghiz",
110 "la - Latin",
111 "ln - Lingala",
112 "lo - Laothian",
113 "lt - Lithuanian",
114 "lv - Latvian, Lettish",
115 "mg - Malagasy",
116 "mi - Maori",
117 "mk - Macedonian",
118 "ml - Malayalam",
119 "mn - Mongolian",
120 "mo - Moldavian",
121 "mr - Marathi",
122 "ms - Malay",
123 "mt - Maltese",
124 "my - Burmese",
125 "na - Nauru",
126 "ne - Nepali",
127 "no - Norsk",
128 "oc - Occitan",
129 "om - Oromo",
130 "or - Oriya",
131 "pa - Punjabi",
132 "pl - Polish",
133 "ps - Pashto, Pushto",
134 "pt - Portugues",
135 "qu - Quechua",
136 "rm - Rhaeto-Romance",
137 "rn - Kirundi",
138 "ro - Romanian",
139 "ru - Russian",
140 "rw - Kinyarwanda",
141 "sa - Sanskrit",
142 "sd - Sindhi",
143 "sg - Sangho",
144 "sh - Serbo-Croatian",
145 "si - Sinhalese",
146 "sk - Slovak",
147 "sl - Slovenian",
148 "sm - Samoan",
149 "sn - Shona",
150 "so - Somali",
151 "sq - Albanian",
152 "sr - Serbian",
153 "ss - Siswati",
154 "st - Sesotho",
155 "su - Sundanese",
156 "sv - Svenska",
157 "sw - Swahili",
158 "ta - Tamil",
159 "te - Telugu",
160 "tg - Tajik",
161 "th - Thai",
162 "ti - Tigrinya",
163 "tk - Turkmen",
164 "tl - Tagalog",
165 "tn - Setswana",
166 "to - Tonga",
167 "tr - Turkish",
168 "ts - Tsonga",
169 "tt - Tatar",
170 "tw - Twi",
171 "ug - Uighur",
172 "uk - Ukrainian",
173 "ur - Urdu",
174 "uz - Uzbek",
175 "vi - Vietnamese",
176 "vo - Volapuk",
177 "wo - Wolof",
178 "xh - Xhosa",
179 "yi - Yiddish",
180 "yo - Yoruba",
181 "za - Zhuang",
182 "zh - Chinese",
183 "zu - Zulu",
184 );
185  
186 1 my @LANG_POPUP = ( [ "", "<none>" ] );
187 1 push @LANG_POPUP, [ $_, $_ ] for @LANG;
188  
189 1 ▶my %CONFIG_PARAMETER = (
Branch: 1 branch
BranchTrueFalseTotal
check_nptl_workaround_possible() ? : 1 0 1
190 program_name => {
191 type => 'string',
192 value => "dvd::rip",
193 },
194 dvd_device => {
195 label => __ "Default DVD device",
196 type => 'file',
197 value => "",
198 dvd_button => 1,
199 },
200 selected_dvd_device => {
201 value => "/dev/dvd",
202 },
203 eject_command => {
204 label => __ "Eject Command",
205 type => 'string',
206 value => "eject",
207 rules => "executable-command",
208 },
209 play_dvd_command => {
210 label => __ "DVD player command",
211 type => 'string',
212 value =>
213 'mplayer <dvd://%t -aid %(%a+%b) -chapter %c -dvdangle %m -dvd-device %d>',
214 presets => [
215 'mplayer <dvd://%t -aid %(%a+%b) -chapter %c -dvdangle %m -dvd-device %d>',
216 'xine -a %a -p <dvd://%d/%t.%c>',
217 ],
218 rules => "executable-command",
219 },
220 play_file_command => {
221 label => __ "File player command",
222 type => 'string',
223 value => 'mplayer <%f>',
224 presets => [ 'xine -p <%f>', 'mplayer <%f>', ],
225 rules => "executable-command",
226 },
227 play_stdin_command => {
228 label => __ "STDIN player command",
229 type => 'string',
230 value => 'xine stdin://mpeg2 -g -pq -a %a',
231 presets => [
232 'mplayer -aid %(%a+128) -', 'xine stdin://mpeg2 -g -pq -a %a',
233 ],
234 rules => "executable-command",
235 },
236 rar_command => {
237 label => __ "rar command (for vobsub compression)",
238 type => 'string',
239 value => 'rar',
240 presets => [ 'rar', ],
241 rules => "executable-command",
242 },
243 base_project_dir => {
244 label => __ "Default data base directory",
245 type => 'dir',
246 value => "$ENV{HOME}/dvdrip-data",
247 },
248 dvdrip_files_dir => {
249 label => __ "Default directory for .rip project files",
250 type => 'dir',
251 value => "$ENV{HOME}/dvdrip-data",
252 },
253 ogg_file_ext => {
254 label => __ "OGG file extension",
255 type => 'string',
256 value => 'ogm',
257 presets => [ 'ogg', 'ogm', 'ogv' ],
258 },
259 cluster_master_local => {
260 label => __ "Start cluster control daemon locally",
261 type => 'switch',
262 value => 1,
263 },
264 cluster_master_server => {
265 label => __ "Hostname of server with daemon",
266 type => 'string',
267 value => "localhost",
268 },
269 cluster_master_port => {
270 label => __ "TCP port number of daemon",
271 type => 'number',
272 value => 28646,
273 rules => "positive-integer",
274 },
275 default_video_codec => {
276 label => __ "Default video codec",
277 type => 'string',
278 value => 'xvid',
279 presets => [
280 "SVCD", "VCD", "XSVCD", "XVCD", "CVD", "divx4",
281 "divx5", "xvid", "xvidcvs", "xvid2", "xvid3", "xvid4",
282 "ffmpeg", "fame", "af6"
283 ],
284 },
285 default_container => {
286 label => __ "Default container format",
287 type => 'popup',
288 value => 'avi',
289 presets => [ [ "avi", "avi" ], [ "ogg", "ogg" ], [ "mpeg", "mpeg" ] ],
290 },
291 default_bpp => {
292 label => __ "Default BPP value",
293 type => 'number',
294 value => '<none>',
295 presets => \@BPP,
296 tooltip => __ "If this option is set dvd::rip automatically "
297 . "calculates the video bitrate using this BPP value",
298 rules => "positive-float",
299 },
300 default_subtitle_grab => {
301 label => __ "Grab subtitles while ripping",
302 type => "popup",
303 value => 0,
304 presets => [
305 [ 'all' => __"Grab all subtitles" ],
306 [ 'lang' => __"Grab subtitles of preferred language" ],
307 [ 0 => __"Don't grab subtitles" ],
308 ],
309 },
310 default_preset => {
311 label => __"Default Clip & Zoom preset",
312 type => "popup",
313 value => "auto_medium_fast",
314 presets => [],
315 },
316 preferred_lang => {
317 label => __ "Preferred language",
318 type => 'popup',
319 value => '',
320 presets => \@LANG_POPUP,
321 },
322 workaround_nptl_bugs => {
323 label => __ "Workaround transcode NPTL bugs",
324 type => 'switch',
325 value => (check_nptl_workaround_possible() ? 1 : 0),
326 avail_method => "check_nptl_workaround_possible",
327 },
328 nptl_ld_assume_kernel => {
329 label => __ "Set LD_ASSUME_KERNEL to",
330 type => "string",
331 value => "2.4.30",
332 chained => 1,
333 avail_method => "check_nptl_workaround_possible",
334 },
335 small_screen => {
336 label => __ "Optimize layout for small screens",
337 type => "switch",
338 value => get_default_small_screen_value(),
339 tooltip =>
340 __ "With this option the dvd::rip GUI may be tweaked "
341 ."to fit even on small screens by adding scrollbars "
342 ."to the notebook pages. dvd::rip needs to be restarted "
343 ."to take effect"
344 },
345 );
346  
347 1 my @CONFIG_ORDER = (
348 __ "Basic settings" => [
349 qw(
350 dvd_device
351 base_project_dir dvdrip_files_dir
352 preferred_lang small_screen
353 )
354 ],
355 __ "Commands" => [
356 qw(
357 play_dvd_command play_file_command
358 play_stdin_command rar_command
359 )
360 ],
361 __ "Cluster options" => [
362 qw(
363 cluster_master_local cluster_master_server
364 cluster_master_port
365 )
366 ],
367 __ "Miscellaneous options" => [
368 qw(
369 default_video_codec
370 default_container
371 ogg_file_ext
372 default_bpp
373 default_preset
374 default_subtitle_grab
375 workaround_nptl_bugs nptl_ld_assume_kernel
376 )
377 ],
378 );
379  
380 0 ▶sub config_definition { \%CONFIG_PARAMETER }
Subroutine config_definition: not called CC=1 SCAR=6.9
Pod undocumented
381  
382 1 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
383 1 my $type = shift;
384  
385 1 my @presets = (
386 Video::DVDRip::Preset->new(
387 name => "nopreset",
388 title => __ "- No Modifications (anamorph) -",
389 tc_clip1_top => 0,
390 tc_clip1_bottom => 0,
391 tc_clip1_left => 0,
392 tc_clip1_right => 0,
393 tc_zoom_width => undef,
394 tc_zoom_height => undef,
395 tc_clip2_top => 0,
396 tc_clip2_bottom => 0,
397 tc_clip2_left => 0,
398 tc_clip2_right => 0,
399 tc_fast_resize => 0,
400 tc_fast_bisection => 0,
401 ),
402 Video::DVDRip::Preset->new(
403 name => "auto_clip",
404 title => __ "Autoadjust, Clipping only (anamorph)",
405 auto_clip => 1,
406 ),
407 Video::DVDRip::Preset->new(
408 name => "auto_big",
409 title => __ "Autoadjust, Big Frame Size, HQ Resize",
410 tc_fast_resize => 0,
411 auto => 1,
412 frame_size => 'big',
413 ),
414 Video::DVDRip::Preset->new(
415 name => "auto_medium",
416 title => __ "Autoadjust, Medium Frame Size, HQ Resize",
417 tc_fast_resize => 0,
418 auto => 1,
419 frame_size => 'medium',
420 ),
421 Video::DVDRip::Preset->new(
422 name => "auto_small",
423 title => __ "Autoadjust, Small Frame Size, HQ Resize",
424 tc_fast_resize => 0,
425 auto => 1,
426 frame_size => 'small',
427 ),
428 Video::DVDRip::Preset->new(
429 name => "auto_big_fast",
430 title => __ "Autoadjust, Big Frame Size, Fast Resize",
431 tc_fast_resize => 1,
432 auto => 1,
433 frame_size => 'big',
434 ),
435 Video::DVDRip::Preset->new(
436 name => "auto_medium_fast",
437 title => __ "Autoadjust, Medium Frame Size, Fast Resize",
438 tc_fast_resize => 1,
439 auto => 1,
440 frame_size => 'medium',
441 ),
442 Video::DVDRip::Preset->new(
443 name => "auto_small_fast",
444 title => __ "Autoadjust, Small Frame Size, Fast Resize",
445 tc_fast_resize => 1,
446 auto => 1,
447 frame_size => 'small',
448 ),
449 Video::DVDRip::Preset->new(
450 name => "vcd_pal_43",
451 title => __ "VCD 4:3, PAL",
452 tc_clip1_top => 0,
453 tc_clip1_bottom => 0,
454 tc_clip1_left => 0,
455 tc_clip1_right => 0,
456 tc_zoom_width => 352,
457 tc_zoom_height => 288,
458 tc_clip2_top => 0,
459 tc_clip2_bottom => 0,
460 tc_clip2_left => 0,
461 tc_clip2_right => 0,
462 tc_fast_resize => 1,
463 tc_fast_bisection => 0,
464 ),
465 Video::DVDRip::Preset->new(
466 name => "vcd_pal_16_9",
467 title => __ "VCD 16:9, PAL",
468 tc_clip1_top => 0,
469 tc_clip1_bottom => 0,
470 tc_clip1_left => 48,
471 tc_clip1_right => 48,
472 tc_zoom_width => 352,
473 tc_zoom_height => 248,
474 tc_clip2_top => -20,
475 tc_clip2_bottom => -20,
476 tc_clip2_left => 0,
477 tc_clip2_right => 0,
478 tc_fast_resize => 1,
479 tc_fast_bisection => 0,
480 ),
481 Video::DVDRip::Preset->new(
482 name => "svcd_pal_16_9_4_3",
483 title => __ "SVCD 16:9 -> 4:3 letterbox, PAL",
484 tc_clip1_top => 0,
485 tc_clip1_bottom => 0,
486 tc_clip1_left => 0,
487 tc_clip1_right => 0,
488 tc_zoom_width => 480,
489 tc_zoom_height => 432,
490 tc_clip2_top => -72,
491 tc_clip2_bottom => -72,
492 tc_clip2_left => 0,
493 tc_clip2_right => 0,
494 tc_fast_resize => 1,
495 tc_fast_bisection => 0,
496 ),
497 Video::DVDRip::Preset->new(
498 name => "svcd_pal",
499 title => __ "SVCD anamorph, PAL",
500 tc_clip1_top => 0,
501 tc_clip1_bottom => 0,
502 tc_clip1_left => 0,
503 tc_clip1_right => 0,
504 tc_zoom_width => 480,
505 tc_zoom_height => 576,
506 tc_clip2_top => 0,
507 tc_clip2_bottom => 0,
508 tc_clip2_left => 0,
509 tc_clip2_right => 0,
510 tc_fast_resize => 1,
511 tc_fast_bisection => 0,
512 ),
513 Video::DVDRip::Preset->new(
514 name => "xsvcd_pal",
515 title => __ "XSVCD anamorph, PAL",
516 tc_clip1_top => 0,
517 tc_clip1_bottom => 0,
518 tc_clip1_left => 0,
519 tc_clip1_right => 0,
520 tc_zoom_width => 720,
521 tc_zoom_height => 576,
522 tc_clip2_top => 0,
523 tc_clip2_bottom => 0,
524 tc_clip2_left => 0,
525 tc_clip2_right => 0,
526 tc_fast_resize => 1,
527 tc_fast_bisection => 0,
528 ),
529 Video::DVDRip::Preset->new(
530 name => "cvd_pal",
531 title => __ "CVD anamorph, PAL",
532 tc_clip1_top => 0,
533 tc_clip1_bottom => 0,
534 tc_clip1_left => 0,
535 tc_clip1_right => 0,
536 tc_zoom_width => 352,
537 tc_zoom_height => 576,
538 tc_clip2_top => 0,
539 tc_clip2_bottom => 0,
540 tc_clip2_left => 0,
541 tc_clip2_right => 0,
542 tc_fast_resize => 1,
543 tc_fast_bisection => 0,
544 ),
545 Video::DVDRip::Preset->new(
546 name => "vcd_ntsc_43",
547 title => __ "VCD 4:3, NTSC",
548 tc_clip1_top => 0,
549 tc_clip1_bottom => 0,
550 tc_clip1_left => 0,
551 tc_clip1_right => 0,
552 tc_zoom_width => 352,
553 tc_zoom_height => 240,
554 tc_clip2_top => 0,
555 tc_clip2_bottom => 0,
556 tc_clip2_left => 0,
557 tc_clip2_right => 0,
558 tc_fast_resize => 1,
559 tc_fast_bisection => 0,
560 ),
561 Video::DVDRip::Preset->new(
562 name => "vcd_ntsc_16_9",
563 title => __ "VCD 16:9, NTSC",
564 tc_clip1_top => 0,
565 tc_clip1_bottom => 0,
566 tc_clip1_left => 32,
567 tc_clip1_right => 32,
568 tc_zoom_width => 352,
569 tc_zoom_height => 200,
570 tc_clip2_top => -20,
571 tc_clip2_bottom => -20,
572 tc_clip2_left => 0,
573 tc_clip2_right => 0,
574 tc_fast_resize => 1,
575 tc_fast_bisection => 0,
576 ),
577 Video::DVDRip::Preset->new(
578 name => "svcd_ntsc_16_9_4_3",
579 title => __ "SVCD 16:9 -> 4:3 letterbox, NTSC",
580 tc_clip1_top => 0,
581 tc_clip1_bottom => 0,
582 tc_clip1_left => 0,
583 tc_clip1_right => 0,
584 tc_zoom_width => 480,
585 tc_zoom_height => 432,
586 tc_clip2_top => -24,
587 tc_clip2_bottom => -24,
588 tc_clip2_left => 0,
589 tc_clip2_right => 0,
590 tc_fast_resize => 1,
591 tc_fast_bisection => 0,
592 ),
593 Video::DVDRip::Preset->new(
594 name => "svcd_ntsc",
595 title => __ "SVCD anamorph, NTSC",
596 tc_clip1_top => 0,
597 tc_clip1_bottom => 0,
598 tc_clip1_left => 0,
599 tc_clip1_right => 0,
600 tc_zoom_width => 480,
601 tc_zoom_height => 480,
602 tc_clip2_top => 0,
603 tc_clip2_bottom => 0,
604 tc_clip2_left => 0,
605 tc_clip2_right => 0,
606 tc_fast_resize => 1,
607 tc_fast_bisection => 0,
608 ),
609 Video::DVDRip::Preset->new(
610 name => "xsvcd_ntsc",
611 title => __ "XSVCD anamorph, NTSC",
612 tc_clip1_top => 0,
613 tc_clip1_bottom => 0,
614 tc_clip1_left => 0,
615 tc_clip1_right => 0,
616 tc_zoom_width => 720,
617 tc_zoom_height => 480,
618 tc_clip2_top => 0,
619 tc_clip2_bottom => 0,
620 tc_clip2_left => 0,
621 tc_clip2_right => 0,
622 tc_fast_resize => 1,
623 tc_fast_bisection => 0,
624 ),
625 Video::DVDRip::Preset->new(
626 name => "cvd_ntsc",
627 title => __ "CVD anamorph, NTSC",
628 tc_clip1_top => 0,
629 tc_clip1_bottom => 0,
630 tc_clip1_left => 0,
631 tc_clip1_right => 0,
632 tc_zoom_width => 352,
633 tc_zoom_height => 480,
634 tc_clip2_top => 0,
635 tc_clip2_bottom => 0,
636 tc_clip2_left => 0,
637 tc_clip2_right => 0,
638 tc_fast_resize => 1,
639 tc_fast_bisection => 0,
640 ),
641 );
642  
643 1 my $default_presets_lref = $CONFIG_PARAMETER{"default_preset"}->{presets};
644
645 1 foreach my $preset ( @presets ) {
646 20 push @{$default_presets_lref},
647 [ $preset->name, $preset->title ];
648 }
649  
650 1 my %config_parameter = %CONFIG_PARAMETER;
651 1 my @config_order = @CONFIG_ORDER;
652  
653 1 my $self = {
654 config => \%config_parameter,
655 order => \@config_order,
656 presets => \@presets,
657 };
658  
659 1 return bless $self, $type;
660 }
661  
662 3 ▶sub init_nptl_bug_workaround {
Subroutine init_nptl_bug_workaround: called CC=3 SCAR=12.3
Pod undocumented
663 3 my $self = shift;
664  
665 3 ▶ if ( !check_nptl_workaround_possible() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (check_nptl_workaround_possible()) 0 3 3
666 0 $self->set_value("workaround_nptl_bugs", 0);
667 }
668  
669 3 ▶ if ( $self->get_value("workaround_nptl_bugs") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_value('workaround_nptl_bugs')) { } 3 0 3
670 3 $ENV{LD_ASSUME_KERNEL} = $self->get_value('nptl_ld_assume_kernel');
671 }
672 else {
673 0 delete $ENV{LD_ASSUME_KERNEL};
674 }
675  
676 3 1;
677 }
678  
679 1 ▶sub init_settings {
Subroutine init_settings: called CC=7 SCAR=20.0
Pod undocumented
680 1 my $self = shift;
681
682 1 ▶ if ( $self->get_value("dvd_device") eq "" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_value("dvd_device") eq "") 1 0 1
683 1 ▶ $self->set_value( dvd_device => ($self->get_first_dvd_device || "/dev/dvd") );
Condition50%1/2
$self->get_first_dvd_device || '/dev/dvd'
l!l
01
MC/DC0%0/1
$self->get_first_dvd_device || '/dev/dvd'
$self->get_first_dvd_device
Truth table50%1/2
A
A= $self->get_first_dvd_device
Aresult
11
00
684 1 $self->save;
685 }
686
687 1 ▶ if ( $self->get_value("preferred_lang") eq "" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_value("preferred_lang") eq "") 1 0 1
688 1 my $lc_messages = POSIX::setlocale("LC_MESSAGES");
689 1 my ($lang) = split("_", $lc_messages, 2);
690 1 $lang = lc($lang);
691 1 ▶ $lang = "en" if $lang eq "c";
Branch: 1 branch
BranchTrueFalseTotal
if $lang eq "c" 1 0 1
692 1 $self->set_value( preferred_lang => "<none>" );
693 1 foreach my $lang_list ( @LANG ) {
694 1 ▶ if ( $lang_list =~ /$lang -/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang_list =~ /$lang -/i) 1 0 1
695 1 $self->set_value( preferred_lang => $lang_list );
696 1 last;
697 }
698 }
699 }
700
701 1 1;
702 }
703  
704 1 ▶sub load {
Subroutine load: called CC=8 SCAR=23.9
Pod undocumented
705 1 my $self = shift;
706  
707 1 my $filename = $self->filename;
708 1 ▶ die "filename not set" if $filename eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $filename eq "" 0 1 1
709 1 ▶ die "can't read $filename" if not -r $filename;
Branch: 1 branch
BranchTrueFalseTotal
unless -r $filename 0 1 1
710  
711 1 my $loaded;
712 1 $loaded = do $filename;
713  
714 1 ▶ if ( $@ or ref $loaded ne 'Video::DVDRip::Config' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or ref $loaded ne "Video::DVDRip::Config") 0 1 1
Condition33%1/3
$@ or ref $loaded ne "Video::DVDRip::Config"
l!l&&r!l&&!r
001
MC/DC0%0/2
$@ or ref $loaded ne "Video::DVDRip::Config"
$@ ref $loaded ne "Video::DVDRip::Config"
Truth table33%1/3
A or B
A= $@B= ref $loaded ne "Video::DVDRip::Config"
ABresult
1X1
011
000
715 0 print "\nCan't load $filename (Preferences)\n$@\n"
716 . "File is probably broken.\n"
717 . "Remove it (Note: your Preferences will be LOST)\n"
718 . "and try again.\n\n";
719 0 exit 1;
720 }
721  
722 1 foreach my $par ( keys %{ $self->config } ) {
723 23 ▶ if ( exists $loaded->config->{$par} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $loaded->config->{$par}) 23 0 23
724 23 $self->config->{$par}->{value} = $loaded->config->{$par}->{value};
725 }
726 23 ▶ if ( exists $self->config->{$par}->{onload} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->config->{$par}{"onload"}) 0 23 23
727 0 my $onload = $self->config->{$par}->{onload};
728 0 &$onload( $self->get_value($par) );
729 }
730 }
731  
732 1 $self->init_nptl_bug_workaround;
733  
734 1 1;
735 }
736  
737 2 ▶sub get_save_data {
Subroutine get_save_data: called CC=1 SCAR=0.0
Pod undocumented
738 2 my $self = shift;
739  
740 2 my $last_saved_data = $self->last_saved_data;
741 2 $self->set_last_saved_data(undef);
742  
743 2 my $dd = Data::Dumper->new( [$self], ['config'] );
744 2 $dd->Indent(1);
745 2 my $data = $dd->Dump;
746  
747 2 $self->set_last_saved_data($last_saved_data);
748  
749 2 return \$data;
750 }
751  
752 2 ▶sub save {
Subroutine save: called CC=3 SCAR=11.0
Pod undocumented
753 2 my $self = shift;
754  
755 2 my $filename = $self->filename;
756 2 ▶ die "filename not set" if $filename eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $filename eq "" 0 2 2
757  
758 2 my $data_sref = $self->get_save_data;
759  
760 2 my $fh = FileHandle->new;
761  
762 2 ▶ open( $fh, "> $filename" ) or die "can't write $filename";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "> $filename" or die "can't write $filename" 2 0 2
763 2 print $fh q{# $Id: Config.pm 2376 2009-02-22 18:49:03Z joern $},
764 "\n";
765 2 print $fh
766 "# This file was generated by Video::DVDRip Version $Video::DVDRip::VERSION\n\n";
767  
768 2 print $fh ${$data_sref};
769 2 close $fh;
770  
771 2 $self->set_last_saved_data($data_sref);
772  
773 2 $self->init_nptl_bug_workaround;
774  
775 2 1;
776 }
777  
778 0 ▶sub changed {
Subroutine changed: not called CC=2 SCAR=17.9
Pod undocumented
779 0 my $self = shift;
780  
781 0 ▶ return 1 if not $self->last_saved_data;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->last_saved_data 0 0 0
782  
783 0 my $actual_data_sref = $self->get_save_data;
784 0 my $saved_data_sref = $self->last_saved_data;
785  
786 0 my $actual = join( "\n", sort split( /\n/, $$actual_data_sref ) );
787 0 my $saved = join( "\n", sort split( /\n/, $$saved_data_sref ) );
788  
789 0 return $actual ne $saved;
790 }
791  
792 10 ▶sub get_value {
Subroutine get_value: called CC=2 SCAR=7.0
Pod undocumented
793 10 my $self = shift;
794 10 my ($name) = @_;
795 10 my $config = $self->config;
796 confess "Unknown config parameter '$name'"
797 10 ▶ if not exists $config->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $config->{$name} 0 10 10
798 10 return $config->{$name}->{value};
799 }
800  
801 3 ▶sub set_value {
Subroutine set_value: called CC=2 SCAR=7.0
Pod undocumented
802 3 my $self = shift;
803 3 my ( $name, $value ) = @_;
804 3 my $config = $self->config;
805 confess "Unknown config parameter '$name'"
806 3 ▶ if not exists $config->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $config->{$name} 0 3 3
807 3 return $config->{$name}->{value} = $value;
808 }
809  
810 0 ▶sub entries_by_type {
Subroutine entries_by_type: not called CC=3 SCAR=24.8
Pod undocumented
811 0 my $self = shift;
812 0 my ($type) = @_;
813  
814 0 my %result;
815 0 my $config = $self->config;
816 0 my ( $k, $v );
817 0 ▶ while ( ( $k, $v ) = each %{$config} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$config;}) 0 0 0
818 0 ▶ $result{$k} = $v if $v->{type} eq $type;
Branch: 1 branch
BranchTrueFalseTotal
if $v->{"type"} eq $type 0 0 0
819 }
820  
821 0 return \%result;
822 }
823  
824 0 ▶sub set_temporary {
Subroutine set_temporary: not called CC=1 SCAR=6.9
Pod undocumented
825 0 my $self = shift;
826 0 my ( $name, $value ) = @_;
827 0 return $self->config->{$name}->{value} = $value;
828 }
829  
830 0 ▶sub get_preset {
Subroutine get_preset: not called CC=3 SCAR=24.8
Pod undocumented
831 0 my $self = shift;
832 0 my %par = @_;
833 0 my ($name) = @par{'name'};
834  
835 0 my $presets = $self->presets;
836  
837 0 foreach my $preset ( @{$presets} ) {
838 0 ▶ return $preset if $preset->name eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $preset->name eq $name 0 0 0
839 }
840  
841 0 return;
842 }
843  
844 0 ▶sub copy_values_from {
Subroutine copy_values_from: not called CC=2 SCAR=17.9
Pod undocumented
845 0 my $self = shift;
846 0 my ($config) = @_;
847  
848 0 foreach my $par ( keys %CONFIG_PARAMETER ) {
849 0 $self->set_value( $par, $config->get_value($par) );
850 }
851  
852 0 1;
853 }
854  
855 1 ▶sub selected_dvd_device_list {
Subroutine selected_dvd_device_list: called CC=12 SCAR=48.5
Pod undocumented
856 1 my $self = shift;
857  
858 1 ▶ return unless $self->has("hal");
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has("hal") 1 0 1
859
860 #-- scan lshal output for DVD devices
861 0 my %devices;
862 0 ▶ open (my $fh, "LC_ALL=C lshal |") or die "can't fork lshal";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "LC_ALL=C lshal |" or die "can't fork lshal" 0 0 0
863 0 my $entry;
864 0 ▶ while ( <$fh> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
865 0 ▶ if ( /^udi/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^udi/) 0 0 0
866 0 ▶ $devices{$entry->{device}} = $entry->{model} if $entry && $entry->{dvd};
Branch: 1 branch
BranchTrueFalseTotal
if $entry and $entry->{"dvd"} 0 0 0
Condition0%0/3
$entry and $entry->{"dvd"}
!ll&&!rl&&r
000
MC/DC0%0/2
$entry and $entry->{"dvd"}
$entry $entry->{"dvd"}
Truth table0%0/3
A and B
A= $entryB= $entry->{"dvd"}
ABresult
0X0
100
111
867 0 $entry = {};
868 }
869 0 ▶ if ( /storage\.model\s+=\s+'([^']+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/storage\.model\s+=\s+'([^']+)/) 0 0 0
870 0 $entry->{model} = $1;
871 }
872 0 ▶ if ( /block\.device\s+=\s+'([^']+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/block\.device\s+=\s+'([^']+)/) 0 0 0
873 0 $entry->{device} = $1;
874 }
875 0 ▶ if ( /storage\.cdrom\.dvd\s+=\s+true/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/storage\.cdrom\.dvd\s+=\s+true/) 0 0 0
876 0 $entry->{dvd} = 1;
877 }
878 }
879 0 close $fh;
880  
881 0 ▶ $devices{$entry->{device}} = $entry->{model} if $entry && $entry->{dvd};
Branch: 1 branch
BranchTrueFalseTotal
if $entry and $entry->{"dvd"} 0 0 0
Condition0%0/3
$entry and $entry->{"dvd"}
!ll&&!rl&&r
000
MC/DC0%0/2
$entry and $entry->{"dvd"}
$entry $entry->{"dvd"}
Truth table0%0/3
A and B
A= $entryB= $entry->{"dvd"}
ABresult
0X0
100
111
882  
883 0 return \%devices;
884 }
885  
886 1 ▶sub get_first_dvd_device {
Subroutine get_first_dvd_device: called CC=4 SCAR=19.4
Pod undocumented
887 1 my $self = shift;
888
889 1 my $href = $self->selected_dvd_device_list;
890  
891 1 my $first_name;
892 my $first_device;
893 1 foreach my $device ( keys %{$href} ) {
894 0 ▶ if ( !$first_name || $first_name gt $href->{$device} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $first_name or $first_name gt $href->{$device}) 0 0 0
Condition0%0/3
not $first_name or $first_name gt $href->{$device}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $first_name or $first_name gt $href->{$device}
not $first_name $first_name gt $href->{$device}
Truth table0%0/3
not(A) or B
A= not $first_nameB= $first_name gt $href->{$device}
ABresult
1X1
011
000
895 0 $first_device = $device;
896 0 $first_name = $href->{$device};
897 }
898 }
899  
900 1 return $first_device;
901 }
902  
903 #---------------------------------------------------------------------
904 # Test methods
905 #---------------------------------------------------------------------
906  
907 0 ▶sub test_play_dvd_command { _executable(@_) }
Subroutine test_play_dvd_command: not called CC=1 SCAR=6.9
Pod undocumented
908 0 ▶sub test_play_file_command { _executable(@_) }
Subroutine test_play_file_command: not called CC=1 SCAR=6.9
Pod undocumented
909 0 ▶sub test_play_stdin_command { _executable(@_) }
Subroutine test_play_stdin_command: not called CC=1 SCAR=6.9
Pod undocumented
910 0 ▶sub test_rar_command { _executable(@_) }
Subroutine test_rar_command: not called CC=1 SCAR=6.9
Pod undocumented
911 0 ▶sub test_dvd_device { _exists(@_) }
Subroutine test_dvd_device: not called CC=1 SCAR=6.9
Pod undocumented
912 0 ▶sub test_writer_device { _exists(@_) }
Subroutine test_writer_device: not called CC=1 SCAR=6.9
Pod undocumented
913 0 ▶sub test_base_project_dir { _abs_and_writable(@_) }
Subroutine test_base_project_dir: not called CC=1 SCAR=6.9
Pod undocumented
914 0 ▶sub test_dvdrip_files_dir { _abs_and_writable(@_) }
Subroutine test_dvdrip_files_dir: not called CC=1 SCAR=6.9
Pod undocumented
915 0 ▶sub test_burn_writing_speed { _numeric(@_) }
Subroutine test_burn_writing_speed: not called CC=1 SCAR=6.9
Pod undocumented
916 0 ▶sub test_burn_cdrecord_device { _cdrecord_device(@_) }
Subroutine test_burn_cdrecord_device: not called CC=1 SCAR=6.9
Pod undocumented
917 0 ▶sub test_burn_cdrecord_cmd { _executable(@_) }
Subroutine test_burn_cdrecord_cmd: not called CC=1 SCAR=6.9
Pod undocumented
918 0 ▶sub test_burn_cdrdao_cmd { _executable(@_) }
Subroutine test_burn_cdrdao_cmd: not called CC=1 SCAR=6.9
Pod undocumented
919 0 ▶sub test_burn_mkisofs_cmd { _executable(@_) }
Subroutine test_burn_mkisofs_cmd: not called CC=1 SCAR=6.9
Pod undocumented
920 0 ▶sub test_burn_vcdimager_cmd { _executable(@_) }
Subroutine test_burn_vcdimager_cmd: not called CC=1 SCAR=6.9
Pod undocumented
921 0 ▶sub test_burn_cdrdao_buffers { _numeric_or_empty(@_) }
Subroutine test_burn_cdrdao_buffers: not called CC=1 SCAR=6.9
Pod undocumented
922 0 ▶sub test_cluster_master_port { _numeric(@_) }
Subroutine test_cluster_master_port: not called CC=1 SCAR=6.9
Pod undocumented
923 0 ▶sub test_eject_command { _executable(@_) }
Subroutine test_eject_command: not called CC=1 SCAR=6.9
Pod undocumented
924  
925 0 ▶sub _executable {
Subroutine _executable: not called CC=7 SCAR=40.3
926 0 my $self = shift;
927 0 my ( $name, $value ) = @_;
928  
929 0 ▶ $value ||= $self->get_value($name);
Condition0%0/3
$value ||= $self->get_value($name)
l!l&&r!l&&!r
000
MC/DC0%0/2
$value ||= $self->get_value($name)
$value $self->get_value($name)
Truth table0%0/3
A ||= B
A= $valueB= $self->get_value($name)
ABresult
1X1
011
000
930 0 my ($file) = split( / /, $value );
931  
932 0 ▶ if ( not -f $file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $file) 0 0 0
933 0 foreach my $p ( split( /:/, $ENV{PATH} ) ) {
934 0 ▶ $file = "$p/$file", last if -x "$p/$file";
Branch: 1 branch
BranchTrueFalseTotal
if -x "$p/$file" 0 0 0
935 }
936 }
937  
938 0 ▶ if ( -x $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-x $file) { } 0 0 0
939 0 return ( __x( "{file} executable : Ok", file => $file ), 1);
940 }
941 else {
942 0 ▶ return __x( "{file} not found : NOT Ok", file => $file )
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 0 0
943 if not -e $file;
944 0 return __x( "{file} not executable : NOT Ok", file => $file );
945 }
946 }
947  
948 0 ▶sub _abs_and_writable {
Subroutine _abs_and_writable: not called CC=5 SCAR=34.0
949 0 my $self = shift;
950 0 my ($name) = @_;
951  
952 0 my $value = $self->get_value($name);
953  
954 0 ▶ return __("has whitespace : NOT Ok") if $value =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\s/ 0 0 0
955 0 ▶ return __("is no absolute path : NOT Ok") if $value !~ m!^/!;
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ m[^/] 0 0 0
956  
957 0 ▶ if ( not -w $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -w $value) { } 0 0 0
958 0 ▶ return __x( "{file} not found : NOT Ok", file => $value )
Branch: 1 branch
BranchTrueFalseTotal
unless -e $value 0 0 0
959 if not -e $value;
960 0 return __x( "{file} not writable : NOT Ok", file => $value );
961 }
962 else {
963 0 return (__x( "{file} writable : Ok", file => $value ), 1);
964 }
965 }
966  
967 0 ▶sub _numeric {
Subroutine _numeric: not called CC=2 SCAR=17.9
968 0 my $self = shift;
969 0 my ($name) = @_;
970  
971 0 my $value = $self->get_value($name);
972  
973 0 ▶ if ( $value =~ /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^\d+$/) { } 0 0 0
974 0 return (__x( "{value} is numeric : Ok", value => $value ), 1);
975 }
976 else {
977 0 return __x( "{value} isn't numeric : NOT Ok", value => $value );
978 }
979 }
980  
981 0 ▶sub _numeric_or_empty {
Subroutine _numeric_or_empty: not called CC=2 SCAR=17.9
982 0 my $self = shift;
983 0 my ($name) = @_;
984  
985 0 my $value = $self->get_value($name);
986  
987 0 ▶ return (__ "is empty : Ok", 1) if $value eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "" 0 0 0
988 0 return $self->_numeric($name);
989 }
990  
991 0 ▶sub _exists {
Subroutine _exists: not called CC=2 SCAR=17.9
992 0 my $self = shift;
993 0 my ($name) = @_;
994  
995 0 my $value = $self->get_value($name);
996  
997 0 ▶ if ( -e $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $value) { } 0 0 0
998 0 return (__x( "{value} exists : Ok", value => $value ), 1);
999 }
1000 else {
1001 0 return __x( "{value} doesn't exist : NOT Ok", value => $value );
1002 }
1003 }
1004  
1005 0 ▶sub _one_of_these {
Subroutine _one_of_these: not called CC=3 SCAR=24.8
1006 0 my $self = shift;
1007 0 my ( $name, $lref ) = @_;
1008  
1009 0 my $value = $self->get_value($name);
1010  
1011 0 foreach my $val ( @{$lref} ) {
1012 0 ▶ return (__x( "'{value}' is known : Ok", value => $value ), 1)
Branch: 1 branch
BranchTrueFalseTotal
if $val eq $value 0 0 0
1013 if $val eq $value;
1014 }
1015  
1016 0 return __x( "'{value}' unknown: NOT Ok", value => $value );
1017 }
1018  
1019 4 ▶sub check_nptl_workaround_possible {
Subroutine check_nptl_workaround_possible: called CC=1 SCAR=0.0
Pod undocumented
1020 4 my $check = qx[
1021 LD_ASSUME_KERNEL=2.4.30 ls >/dev/null 2>&1 && echo NPTL_OK
1022 ];
1023 4 return $check =~ /NPTL_OK/;
1024 }
1025  
1026 1 ▶sub get_default_small_screen_value {
Subroutine get_default_small_screen_value: called CC=1 SCAR=0.0
Pod undocumented
1027 1 my $root_info = qx[xwininfo -root];
1028 1 my ($width, $height) = $root_info =~ /Width:\s+(\d+).*?Height:\s+(\d+)/si;
1029 1 return $height < 1024;
1030 }
1031  
1032 1 1;
« blib/lib/Video/DVDRip/GUI/FormFactory/SubtitlePreviews.pm ↑ Summary blib/lib/Event/ExecFlow/Job/Command.pm »