1 | #
|
---|
2 | # Manages Plugins for CasparBuster
|
---|
3 | #
|
---|
4 | # $Id$
|
---|
5 | #
|
---|
6 | #
|
---|
7 | package CasparBuster::Plugin;
|
---|
8 |
|
---|
9 | use strict;
|
---|
10 | use warnings;
|
---|
11 | use CasparBuster::Env;
|
---|
12 | use ProjectBuilder::Base;
|
---|
13 | use ProjectBuilder::Conf;
|
---|
14 | use Data::Dumper;
|
---|
15 |
|
---|
16 | # Global vars
|
---|
17 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
18 | #
|
---|
19 | use vars qw($VERSION $REVISION @ISA @EXPORT);
|
---|
20 | use Exporter;
|
---|
21 | #
|
---|
22 | # Export, by default, all the functions into the namespace of
|
---|
23 | # any code which uses this module.
|
---|
24 |
|
---|
25 | our @ISA = qw(Exporter);
|
---|
26 | our @EXPORT = qw(cb_plugin_load cb_plugin_get);
|
---|
27 |
|
---|
28 | =pod
|
---|
29 |
|
---|
30 | =head1 NAME
|
---|
31 |
|
---|
32 | CasparBuster::Plugin - module dealing with CasparBuster plugin management
|
---|
33 |
|
---|
34 | =head1 DESCRIPTION
|
---|
35 |
|
---|
36 | This modules provides functions to allow the management of CasparBuster plugins
|
---|
37 |
|
---|
38 | =head1 SYNOPSIS
|
---|
39 |
|
---|
40 | use CasparBuster::Plugin;
|
---|
41 |
|
---|
42 | =head1 USAGE
|
---|
43 |
|
---|
44 | =over 4
|
---|
45 |
|
---|
46 | =item B<cb_plugin_load>
|
---|
47 |
|
---|
48 | This function loads all the plugins defined for this CasparBuster environement
|
---|
49 |
|
---|
50 | =cut
|
---|
51 |
|
---|
52 | sub cb_plugin_load {
|
---|
53 |
|
---|
54 | my ($pluginsdir) = pb_conf_get("cbpluginssubdir");
|
---|
55 | my $cbconfdir = cb_env_confdir()."/$pluginsdir->{$ENV{'PBPROJ'}}";
|
---|
56 | opendir(DIR,$cbconfdir) || die "Unable to open $cbconfdir: $!";
|
---|
57 | foreach my $f (readdir(DIR)) {
|
---|
58 | next if ($f =~ /^\./);
|
---|
59 | # Add on plugins files
|
---|
60 | if ($f =~ /\.conf$/) {
|
---|
61 | pb_conf_add("$cbconfdir/$f") if (-f "$cbconfdir/$f");
|
---|
62 | }
|
---|
63 | }
|
---|
64 | closedir(DIR);
|
---|
65 | }
|
---|
66 |
|
---|
67 |
|
---|
68 | =item B<cb_plugin_get>
|
---|
69 |
|
---|
70 | This function adds into the plugin hash, passed as second parameter, the new plugin content based on its name, passed as first parameter.
|
---|
71 |
|
---|
72 | =cut
|
---|
73 |
|
---|
74 | sub cb_plugin_get {
|
---|
75 |
|
---|
76 | my $plugin = shift;
|
---|
77 | my $cbp = shift;
|
---|
78 |
|
---|
79 | pb_log(2,"Entering cb_plugin_get for plugin $plugin\n");
|
---|
80 | my ($flist,$dlist,$dflist,$slist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbplugindirsandfiles","cbpluginreload");
|
---|
81 | if ((defined $flist) && (defined $flist->{$plugin}) && ($flist->{$plugin} !~ /^\s*$/)) {
|
---|
82 | foreach my $block (split(/;/,$flist->{$plugin})) {
|
---|
83 | pb_log(3,"block : $block\n");
|
---|
84 | my ($name,$tmp) = split(/\|/,$block);
|
---|
85 | ($cbp->{$plugin}->{'files'}->{$name}->{'uid'},$cbp->{$plugin}->{'files'}->{$name}->{'gid'},$cbp->{$plugin}->{'files'}->{$name}->{'mode'}) = split(/\,/,$tmp);
|
---|
86 | }
|
---|
87 | }
|
---|
88 | if ((defined $dlist) && (defined $dlist->{$plugin}) && ($dlist->{$plugin} !~ /^\s*$/)) {
|
---|
89 | foreach my $block (split(/;/,$dlist->{$plugin})) {
|
---|
90 | pb_log(3,"block : $block\n");
|
---|
91 | my ($name,$tmp) = split(/\|/,$block);
|
---|
92 | ($cbp->{$plugin}->{'dirs'}->{$name}->{'uid'},$cbp->{$plugin}->{'dirs'}->{$name}->{'gid'},$cbp->{$plugin}->{'dirs'}->{$name}->{'mode'}) = split(/\,/,$tmp);
|
---|
93 | }
|
---|
94 | }
|
---|
95 | if ((defined $dflist) && (defined $dflist->{$plugin}) && ($dflist->{$plugin} !~ /^\s*$/)) {
|
---|
96 | foreach my $block (split(/;/,$dflist->{$plugin})) {
|
---|
97 | pb_log(3,"block : $block\n");
|
---|
98 | my ($name,$tmp) = split(/\|/,$block);
|
---|
99 | ($cbp->{$plugin}->{'dirsandfiles'}->{$name}->{'uid'},$cbp->{$plugin}->{'dirsandfiles'}->{$name}->{'gid'},$cbp->{$plugin}->{'dirsandfiles'}->{$name}->{'mode'}) = split(/\,/,$tmp);
|
---|
100 | }
|
---|
101 | }
|
---|
102 | if ((defined $slist) && (defined $slist->{$plugin})) {
|
---|
103 | $cbp->{$plugin}->{'reloadscript'} = $slist->{$plugin};
|
---|
104 | }
|
---|
105 | pb_log(2,"cbp: ".Dumper($cbp)."\n");
|
---|
106 | return($cbp);
|
---|
107 | }
|
---|
108 |
|
---|
109 | 1;
|
---|