source: A2P/a2p/AFPDS/MODCA/PTX.pm @ 3

Last change on this file since 3 was 3, checked in by guillaume, 17 years ago
  • AUTHORS: Ajout des différents contributeurs
  • COPYING: Ajout de la licence GPL v3
  • a2p: Préparation des sources pour leur publication sous GPL
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1#
2# Copyright (c) 2004-2007 - Consultas, PKG.fr
3#
4# This file is part of A2P.
5#
6# A2P is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# A2P is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with A2P; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19#
20# $Id: PTX.pm 3 2007-10-18 16:20:19Z guillaume $
21#
22# Class to export Presentation Text Data (PTCA flux) members
23#
24# cf ref #2, p. 309
25#
26
27package AFPDS::MODCA::PTX ;
28
29use strict ;
30use A2P::Globals ;
31use A2P::Syslog ;
32use AFPDS::PTCA ;
33use AFPDS::MODCA::Common ;
34
35BEGIN {
36    our $VERSION = sprintf "%s", q$Rev: 1007 $ =~ /([0-9.]+)\s+/ ;
37}
38our $VERSION ;
39our @ISA = ("AFPDS::MODCA");
40our $IDENTS ;
41
42sub _ID { 0xD3EE9B }
43
44sub new {
45    my $class = shift ;
46    &Debug("new " . __PACKAGE__ . " v$VERSION object");
47
48    my $self = {
49        FLUX     => 0,        # Associated flux
50        IDENT    => _ID,      # MO:DCA identity
51        FLAG     => 0,        # MO:DCA flags
52        RESERVED => 0,        # MO:DCA reserved
53        LONG     => 0,        # MO:DCA buffer length
54        BUFFER   => ''        # MO:DCA content buffer
55    };
56
57    return bless $self , $class ;
58}
59
60sub validate {
61    my $self = shift ;
62
63    &UPSTAT('GETPTCA');
64
65    my $ptx = new AFPDS::PTCA( $self->{BUFFER} );
66
67    return ( 251, "Can't convert invalid PTCA flux" )
68        unless ( $ptx->isValid );
69
70    # Check FLUX is a Flux object
71    return ( 251, "IPS needs to be used with Flux object" )
72        unless ( ref($self->{FLUX}) =~ /^AFPDS::Flux$/ );
73
74    # Store PTX only if used
75    $self->{PTX} = $ptx->isValid > 0 ? $ptx : 0 ;
76
77    return () ;
78}
79
80sub create {
81    my $self = shift ;
82
83    # Still return if not used
84    my $ptx  = $self->{PTX} or return () ;
85
86    my $flux = $self->{FLUX} ;
87
88    if ( $flux->getlineindex > 0 ) {
89        # Directly insert if any line exists
90        $flux->addline( $ptx->getTex() ) ;
91
92    } else {
93        # Otherwise this means page is not initialized, so we can add
94        # it to logo def. This case arises when adding line with logos
95        $flux->newlogo( $ptx->getTex() ) ;
96    }
97
98    if ( my $font = $ptx->getFont() ){
99        # PTCA has selected a font, we should handle it
100        $flux->updateFlux( { DefaultTRC => $font } );
101    }
102
103    return () ;
104}
105
106&Debug("Module " . __PACKAGE__ . " v$VERSION loaded");
107
108( $IDENTS->{&_ID} ) = __PACKAGE__ =~ /(\w+)$/ ;
109
1101 ;
Note: See TracBrowser for help on using the repository browser.