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

Last change on this file since 1487 was 1487, checked in by bruno, 7 years ago
  • Fix Plugin.pm for caspar structure management (don't use tables but hashes)
  • more code in cb still not ready.
File size: 2.5 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
79my ($flist,$dlist,$slist) = pb_conf_get_if("cbpluginfiles","cbplugindirs","cbpluginreload");
80if ((defined $flist) && (defined $flist->{$plugin}) && ($flist->{$plugin} !~ /^\s*$/)) {
81    foreach my $block (split(/;/,$flist->{$plugin})) {
82        pb_log(3,"block : $block\n");
83        my ($name,$tmp) = split(/\|/,$block);
84        ($cbp->{$plugin}->{'files'}->{$name}->{'uid'},$cbp->{$plugin}->{'files'}->{$name}->{'gid'},$cbp->{$plugin}->{'files'}->{$name}->{'mode'}) = split(/\,/,$tmp);
85    }
86}
87if ((defined $dlist) && (defined $dlist->{$plugin}) && ($dlist->{$plugin} !~ /^\s*$/)) {
88    foreach my $block (split(/;/,$dlist->{$plugin})) {
89        pb_log(3,"block : $block\n");
90        ($name,$tmp) = split(/\|/,$block);
91        ($cbp->{$plugin}->{'dirs'}->{$name}->{'uid'},$cbp->{$plugin}->{'dirs'}->{$name}->{'gid'},$cbp->{$plugin}->{'dirs'}->{$name}->{'mode'}) = split(/\,/,$tmp);
92    }
93}
94if ((defined $slist) && (defined $slist->{$plugin})) {
95    $cbp->{$plugin}->{'reloadscript'} = $slist->{$plugin};
96}
97pb_log(2,"cbp: ".Dumper($cbp)."\n");
98return($cbp);
99}
100
1011;
Note: See TracBrowser for help on using the repository browser.