source: ProjectBuilder/projects/casparbuster/devel/lib/CasparBuster/Plugin.pm@ 1494

Last change on this file since 1494 was 1494, checked in by Bruno Cornec, 12 years ago
  • Add support for cbplugindirsandfiles. This param provides support for direstories and all their children, whereas cbplugindirs is restricted to the directory alone. Usefull for named support
  • Add named plugin
  • cbusterize wworks now mostly for named (access to root owned file is still aproblem to solve)
  • cb also supports the new cbplugindirsandfiles param
File size: 2.9 KB
Line 
1#
2# Manages Plugins for CasparBuster
3#
4# $Id$
5#
6#
7package CasparBuster::Plugin;
8
9use strict;
10use warnings;
11use CasparBuster::Env;
12use ProjectBuilder::Base;
13use ProjectBuilder::Conf;
14use Data::Dumper;
15
16# Global vars
17# Inherit from the "Exporter" module which handles exporting functions.
18#
19use vars qw($VERSION $REVISION @ISA @EXPORT);
20use Exporter;
21#
22# Export, by default, all the functions into the namespace of
23# any code which uses this module.
24
25our @ISA = qw(Exporter);
26our @EXPORT = qw(cb_plugin_load cb_plugin_get);
27
28=pod
29
30=head1 NAME
31
32CasparBuster::Plugin - module dealing with CasparBuster plugin management
33
34=head1 DESCRIPTION
35
36This 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
48This function loads all the plugins defined for this CasparBuster environement
49
50=cut
51
52sub cb_plugin_load {
53
54my ($pluginsdir) = pb_conf_get("cbpluginssubdir");
55my $cbconfdir = cb_env_confdir()."/$pluginsdir->{$ENV{'PBPROJ'}}";
56opendir(DIR,$cbconfdir) || die "Unable to open $cbconfdir: $!";
57foreach 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}
64closedir(DIR);
65}
66
67
68=item B<cb_plugin_get>
69
70This 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
74sub cb_plugin_get {
75
76my $plugin = shift;
77my $cbp = shift;
78
79pb_log(2,"Entering cb_plugin_get for plugin $plugin\n");
80my ($flist,$dlist,$dflist,$slist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbplugindirsandfiles","cbpluginreload");
81if ((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}
88if ((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}
95if ((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}
102if ((defined $slist) && (defined $slist->{$plugin})) {
103 $cbp->{$plugin}->{'reloadscript'} = $slist->{$plugin};
104}
105pb_log(2,"cbp: ".Dumper($cbp)."\n");
106return($cbp);
107}
108
1091;
Note: See TracBrowser for help on using the repository browser.