Changeset 6236

Show
Ignore:
Timestamp:
07/31/08 12:39:26 (2 months ago)
Author:
p_lindheimer
Message:

closes #2413 and closes #2974 adding an optional low-res image and DID information

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/core/bin/fax-process.pl

    r5848 r6236  
    1212my $to = "xrobau\@gmail.com"; 
    1313my $from = "fax\@"; 
     14my $dest = undef; 
    1415my $subject = "Fax received"; 
    1516my $ct = "application/x-pdf"; 
     
    2627 
    2728# Usage: 
    28 my $usage="Usage: --file filename [--attachment filename] [--to email_address] [--from email_address] [--type content/type] [--subject \"Subject Of Email\"]";  
     29my $usage="Usage: --file filename [--attachment filename] [--to email_address] [--from email_address] [--type content/type] [--subject \"Subject Of Email\"] [--dest DID]";  
    2930 
    3031# Parse command line.. 
     
    5455        } 
    5556  # Convert %2x to proper characters, leave anything else alone. 
    56   $subject =~ s/\%20/ /g; 
     57    $subject =~ s/\%20/ /g; 
    5758    $subject =~ s/\%21/\!/g; 
    5859    $subject =~ s/\%22/\"/g; 
     
    8889        my $tmp = shift @ARGV; 
    8990        $attachment = $tmp if (defined $tmp); 
     91  } elsif ($cmd eq "--dest") { 
     92       my $tmp = shift @ARGV; 
     93       if ($tmp =~ /\^(\")|^(\')/) { 
     94               # It's a quoted string 
     95               my $delim = $+;   # $+ is 'last match', which is ' or " 
     96               $tmp =~ s/\Q$delim\E//; # Strip out ' or " 
     97               $dest = $tmp; 
     98               while ($tmp = shift @ARGV) { 
     99                       if ($tmp =~ /\Q$delim\E/) { 
     100                               $tmp =~ s/\Q$delim\E//; 
     101                               last; 
     102                       } 
     103               $dest .= $tmp; 
     104               } 
     105       } else { 
     106               # It's a single word 
     107               $dest = $tmp; 
     108       } 
    90109  } else { 
    91110        die "$cmd not understood\n$usage\n"; 
     
    103122 
    104123my $encoded=""; 
     124my $enc_gif=""; 
    105125my $buf=""; 
     126my $convert_status=0; 
     127 
    106128# First, lets find out if it's a TIFF file 
    107129read(FILE, $buf, 4); 
     
    116138        } 
    117139        close PDF; 
     140 
     141        open GIF, "convert -resize '50%' -monochrome -delay 300 ${file}[0,1] gif:- |"; 
     142        if (!eof(GIF)) { 
     143                $convert_status=1; 
     144                $buf = ""; 
     145                while (read(GIF, $buf, 60*57))  { 
     146                        $enc_gif .= encode_base64($buf); 
     147                } 
     148        } 
     149        close GIF; 
    118150} else { 
    119151        # It's a PDF already 
     
    139171 
    140172my $len = length $encoded; 
     173my $len_gif = length $enc_gif; 
    141174# message body.. 
    142175my $msg ="Content-Class: urn:content-classes:message 
     
    157190Content-Transfer-Encoding: quoted-printable 
    158191 
    159 A Fax has been recieved by the fax gateway, and is attached to this message. 
    160  
    161  
    162 --$boundary 
     192A Fax has been received by the fax gateway and is attached to this message. 
     193 
     194The destination number for this fax is ".$dest." 
     195 
     196 
     197"; 
     198if ($convert_status eq 1) { 
     199$msg=$msg."--$boundary 
     200Content-Type: image/gif; name=\"thumb-".substr($attachment,0,-4).".gif\" 
     201Content-Transfer-Encoding: base64 
     202 
     203$enc_gif  
     204"; 
     205
     206 
     207$msg=$msg."--$boundary 
    163208Content-Type: $ct; name=\"$attachment\" 
    164209Content-Transfer-Encoding: base64 
  • modules/branches/2.5/core/etc/extensions.conf

    r6218 r6236  
    10991099exten => out_fax,1,txfax(${TXFAX_NAME},caller) 
    11001100exten => out_fax,2,Hangup 
    1101 exten => h,1,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${FAXFILE}); 
     1101exten => h,1,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} --dest "${FROM_DID}" --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${FAXFILE}); 
    11021102exten => h,2,Hangup() 
    11031103 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads