Changeset 1323


Ignore:
Timestamp:
12/13/08 16:58:36 (3 years ago)
Author:
CrawfordCurrie
Message:

Item456: work in progress

Location:
trunk/MailInContrib
Files:
8 edited
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/MailInContrib/data/System/MailInContrib.txt

    r878 r1323  
    1 ---+!! <nop>MailInContrib for TWiki 
     1---+!! <nop>Mail In to Foswiki 
    22%SHORTDESCRIPTION% 
    33<a href="http://wikiring.com"><img src="%ATTACHURL%/logo.gif" style="float:right" /></a> 
    4 This Contrib supports the submission of content to TWiki topics via e-mail. 
     4This Contrib supports the submission of content to Foswiki topics via e-mail. 
    55 
    66<!-- 
     
    1111   you make will simply be overwritten the next time a release is generated. 
    1212 
    13    Instead, you could check your fix in, raise a bug in the Bugs web, or mail the author. 
     13   Instead, you could check your fix in, raise a bug in the Tasks web, or mail the author. 
    1414--> 
    1515 
    16 <div class="twikiBroadcastMessage" style="background-color:#ffc;">WARNING: TWiki-4 only. If you want to use this extension with an earlier version of TWiki, please use [[http://twiki.org/cgi-bin/attach/Plugins/%TOPIC%?filename=%TOPIC%.zip&revInfo=1][revision 7 of the zip]].</div> 
     16Mails can be pulled out of mail folders using [[CPAN:Email::Folder::POP3][POP3]], [[CPAN:Email::Folder::IMAP][IMAP]], or anything else supported by CPAN:Email::Folder. 
    1717 
    18 Mails for twiki can be pulled out of mail folders using [[CPAN:Email::Folder::POP3][POP3]], [[CPAN:Email::Folder::IMAP][IMAP]], or anything else supported by CPAN:Email::Folder. 
    19  
    20 The implementation is very simple; a script called =mailincron= is run every so often (usually by =cron= or an equivalent offline job scheduler). The script trawls the mail folders you specify and grabs messages that it recognises as being for the TWiki. 
     18The implementation is very simple; a script called =mailincron= is run every so often (usually by =cron= or an equivalent offline job scheduler). The script trawls the mail folders you specify and grabs messages that it recognises as being for the wiki. 
    2119 
    2220For example, your wayward child might send a mail like this from an internet cafe in Thailand: 
     
    2826*Phuket*: I've run out of money! 
    2927</verbatim> 
    30 The message lands in your email folder at your ISP. Once an hour, a cron job runs the =mailincron= script, which scans the folder. If it finds any messages that have nothing but a correctly formatted TWiki Web.Topic<nop>Name in the subject line, that topic is appended to (created) with the plain text of the email.  The Web must exist, though the topic will be created if necessary. Both web and topic _must_ be specified. 
     28The message lands in your email folder at your ISP. Once an hour, a cron job runs the =mailincron= script, which scans the folder. If it finds any messages that have nothing but a correctly formatted Web.Topic<nop>Name in the subject line, that topic is appended to (created) with the plain text of the email.  The Web must exist, though the topic will be created if necessary. Both web and topic _must_ be specified. 
    3129 
    3230In our example, the web exists, and so does the topic, so the following text gets appended to Travels.Daily<nop>Diary: 
     
    3836 
    3937</div> 
    40 Attachments to the mail get treated as attachments by TWiki, and attached to the target topic. 
     38Attachments to the mail get treated as attachments by Foswiki, and attached to the target topic. 
    4139 
    4240Note that =mailincron= will only process messages that have arrived since the last time it ran. So if there was an error adding a mail, it won't attempt to add it again even if it is still in the inbox. 
     
    5149The module can use special HTML comments in the topic to decide where to insert new emails within the text. 
    5250 
    53 If it sees the comment =&lt;!--MAIL--&gt;= it will insert the incoming mail immediately *below* the comment. =MAIL= is rather ike a TWikiVariable; you can give it parameters. For example, =&lt;!--MAIL{where="below"}--&gt;=. The following options are available: 
     51If it sees the comment =&lt;!--MAIL--&gt;= it will insert the incoming mail immediately *below* the comment. =MAIL= is rather ike a [[%SYSTEMWEB%.Macro][Foswiki macro]]; you can give it parameters. For example, =&lt;!--MAIL{where="below"}--&gt;=. The following options are available: 
    5452   * =where= - can be =above=, =below= (relative to the comment) =top=, =bottom= (of the topic) 
    5553   * =template= set to the name of one of the templates in %SYSTEMWEB%.MailInContribTemplate to change the formatting of comments. The default format is "below" format. 
     
    5755If there is no such comment in the topic, then it just appends it to the end. If there is more than one, only the first is recognised. 
    5856 
    59 Any attachments in the mail get added to the target topic as TWiki attachments. Attachments are also listed immediately below the mail body in the topic. 
     57Any attachments in the mail get added to the target topic as attachments. Attachments are also listed immediately below the mail body in the topic. 
    6058 
    6159---+ How the contributor is identified 
    62 The user identity is used for access control checks on the target topic, so you can use TWiki access controls to protect target topics. 
     60The user identity is used for access control checks on the target topic, so you can use Foswiki access controls to protect target topics. 
    6361 
    6462You can configure the module to look at the =From:= entry in the email, and if a registered user has set that email (see ChangeEmailAddress), then they are identified as the contributor. Note that there is a security risk here, as the =From:= address in e-mail can easily be spoofed. 
     
    6765 
    6866<!-- 
    69       * Set SHORTDESCRIPTION = Supports submissions to TWiki via e-mail 
     67      * Set SHORTDESCRIPTION = Supports submissions to Foswiki via e-mail 
    7068--> 
    7169 
     
    7472 
    7573__Note__: The CPAN =Email= modules uses *many* pluggable modules to support different folder types. It's impossible to cover all the options here; all we can suggest is that you try running the script from the command-line and resolve missing modules as you find them. 
    76    * Set up cron (or equivalent) jobs to run =mailincron=. You must =cd= to the TWiki bin directory, and invoke the sript from there (this is so =mailincron= can read =setlib.cfg=) 
     74   * Set up cron (or equivalent) jobs to run =mailincron=. You must =cd= to the =bin= directory, and invoke the sript from there (this is so =mailincron= can read =setlib.cfg=) 
    7775 
    7876Because of the security issues involved (passwords for the mailboxes etc.) configuration uses variables set in your =LocalSite.cfg=. The easiest way to set them is using =configure=. 
    7977 
    80 The =mailincron= script takes one optional parameter, <tt>debug</tt>, which takes a boolean value e.g. <tt>debug=1</tt>. If you pass anything other than 0 or the empty string in =debug=, the script will scan the mail folders, describe what it would have done, and exit, without modifying any folders, the TWiki, or sending any mails. 
     78The =mailincron= script takes one optional parameter, <tt>debug</tt>, which takes a boolean value e.g. <tt>debug=1</tt>. If you pass anything other than 0 or the empty string in =debug=, the script will scan the mail folders, describe what it would have done, and exit, without modifying any folders, the wiki, or sending any mails. 
    8179 
    82 To run the script you need to set up a cron job. For example, to transfer mail into the TWiki once every hour you might write: 
     80To run the script you need to set up a cron job. For example, to transfer mail into the wiki once every hour you might write: 
    8381<verbatim> 
    84 0 * * * * cd /home/twiki/bin && ../tools/mailincron 2&>1 >> /home/twiki/logs/mailincron.log 
     820 * * * * cd /home/twiki/bin && ../tools/mailincron 2>&1 >> /home/twiki/logs/mailincron.log 
    8583</verbatim> 
    8684You _must_ run the script from the bin directory. 
    87 Make sure that the cron is run by a user with the permissions needed to read and write the TWiki data directory. 
    88  
    89 This is a brand-new development, not related in any to the original Foswiki:Extensions/MailInAddon. Due acknowledgement is made to those early pioneers for the idea. ;-) 
     85Make sure that the cron is run by a user with the permissions needed to read and write the =data= directory. 
    9086 
    9187---++ Contrib Info 
    9288 
    93 Another great TWiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience! 
     89Another great Foswiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience! 
    9490 
    9591Many thanks to the following sponsors for supporting this work: 
    9692   * [[http://www.evolvedmedianetwork.com][Evolved Media Network]] 
    9793 
    98 |  Author: | TWiki:Main/CrawfordCurrie (http://c-dot.co.uk) | 
    99 |  Copyright &copy;: | 2005, TWiki Contributors | 
     94|  Author: | Foswiki:Main.CrawfordCurrie (http://c-dot.co.uk) | 
     95|  Copyright &copy;: | 2005, TWiki Contributors; 2008 Foswiki Contributors | 
    10096|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | 
    10197|  Dependencies: | %$DEPENDENCIES% | 
     
    119115|  10 Mar 2005 | 1.000 Initial version | 
    120116|  Home: | Foswiki:Extensions/%TOPIC% | 
    121 |  Feedback: | Foswiki:Extensions/%TOPIC%Dev | 
    122 |  Appraisal: | http://foswiki.org/Extensions/%TOPIC%Appraisal | 
    123117 
    124118__Related Topics:__ %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences 
  • trunk/MailInContrib/lib/Foswiki/Contrib/MailInContrib.pm

    r1050 r1323  
    33# 
    44# Copyright (C) 2005 TWiki Contributors. All Rights Reserved. 
    5 # TWiki Contributors are listed in the AUTHORS file in the root 
     5# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved. 
     6# Foswiki Contributors are listed in the AUTHORS file in the root 
    67# of this distribution. 
    78# NOTE: Please extend that file, not this notice. 
     
    1819# 
    1920# As per the GPL, removal of this notice is prohibited. 
    20 package TWiki::Contrib::MailInContrib; 
     21package Foswiki::Contrib::MailInContrib; 
    2122 
    2223use strict; 
    23 use TWiki; 
     24use Foswiki; 
    2425 
    2526use Email::Folder; 
     
    3233use Carp; 
    3334 
    34 # This should always be $Rev: 10183$ so that TWiki can determine the checked-in 
     35# This should always be $Rev: 10183$ so that Foswiki can determine the checked-in 
    3536# status of the plugin. It is used by the build automation tools, so 
    3637# you should leave it alone. 
     
    6263 
    6364---++ ClassMethod new( $session ) 
    64    * =$session= - ref to a TWiki object 
     65   * =$session= - ref to a Foswiki object 
    6566Construct a new inbox processor. 
    6667 
     
    7475 
    7576    # Find out when we last processed mail 
    76     my $workdir = TWiki::Func::getWorkArea('MailInContrib'); 
     77    my $workdir = Foswiki::Func::getWorkArea('MailInContrib'); 
    7778    if (-e "$workdir/timestamp") { 
    7879        open(F, "<$workdir/timestamp") || die $!; 
     
    100101 
    101102    # re-stamp 
    102     my $workdir = TWiki::Func::getWorkArea('MailInContrib'); 
     103    my $workdir = Foswiki::Func::getWorkArea('MailInContrib'); 
    103104    open(F, ">$workdir/timestamp") || die $!; 
    104105    print F time(),"\n"; 
     
    109110    my $u = shift; 
    110111 
    111     if ($TWiki::Plugins::SESSION->{users}->can('getCanonicalUserID')) { 
    112         return $TWiki::Plugins::SESSION->{users}->getCanonicalUserID($u); 
     112    if ($Foswiki::Plugins::SESSION->{users}->can('getCanonicalUserID')) { 
     113        return $Foswiki::Plugins::SESSION->{users}->getCanonicalUserID($u); 
    113114    } else { 
    114         return $TWiki::Plugins::SESSION->{users}->findUser( $u ); 
     115        return $Foswiki::Plugins::SESSION->{users}->findUser( $u ); 
    115116    } 
    116117} 
     
    121122   * =$box= - hash describing the box 
    122123Scan messages in the box that have been received since the last run, 
    123 and process them for inclusion in TWiki topics. 
     124and process them for inclusion in Foswiki topics. 
    124125 
    125126=cut 
     
    128129    my( $this, $box ) = @_; 
    129130 
    130     $TWiki::Plugins::SESSION = $this->{session}; 
     131    $Foswiki::Plugins::SESSION = $this->{session}; 
    131132 
    132133    die "No folder specification" unless $box->{folder}; 
     
    148149 
    149150    # Load the file of mail templates 
    150     my $templates = TWiki::Func::loadTemplate( 'MailInContrib' ); 
     151    my $templates = Foswiki::Func::loadTemplate( 'MailInContrib' ); 
    151152 
    152153    print STDERR "Scanning $box->{folder}\n" if $this->{debug}; 
     
    172173        #    1. examining the "To" address to see if it is a valid web.wikiname (if 
    173174        #       enabled in config) 
    174         #    2. if the subject line starts with a valid TWiki Web.WikiName (if optionally 
     175        #    2. if the subject line starts with a valid Foswiki Web.WikiName (if optionally 
    175176        #       followed by a colon, the rest of the subject line will be ignored) 
    176177        #    3. Routing the comment to the spambox if it is enabled 
     
    206207 
    207208        if( $box->{topicPath} =~ /\bto\b/ && 
    208               $to =~ /^(?:($TWiki::regex{webNameRegex})\.)($TWiki::regex{wikiWordRegex})@/i) { 
     209              $to =~ /^(?:($Foswiki::regex{webNameRegex})\.)($Foswiki::regex{wikiWordRegex})@/i) { 
    209210            ( $web, $topic ) = ( $1, $2 ); 
    210211        } 
    211212        if( !$topic && $box->{topicPath} =~ /\bsubject\b/ && 
    212213              $subject =~ 
    213                 s/^\s*(?:($TWiki::regex{webNameRegex})\.)?($TWiki::regex{wikiWordRegex})(:\s*|\s*$)// ) { 
     214                s/^\s*(?:($Foswiki::regex{webNameRegex})\.)?($Foswiki::regex{wikiWordRegex})(:\s*|\s*$)// ) { 
    214215            ( $web, $topic ) = ( $1, $2 ); 
    215216        } 
     
    219220        print STDERR "Topic $web.",$topic||'',"\n" if $this->{debug}; 
    220221 
    221         unless( TWiki::Func::webExists( $web )) { 
     222        unless( Foswiki::Func::webExists( $web )) { 
    222223            $topic = ''; 
    223224        } 
     
    243244        if( $received > $this->{lastMailIn} ) { 
    244245            my $err = ''; 
    245             unless( $this->{session}->{store}->webExists( $web )) { 
     246            unless( Foswiki::Func::webExists( $web )) { 
    246247                $err = "Web $web does not exist"; 
    247248            } else { 
     
    261262                $this->_onError( 
    262263                    $box, $mail, 
    263                     "TWiki encountered an error while adding your mail to $web.$topic: $err", \%kill, $num ); 
     264                    "Foswiki encountered an error while adding your mail to $web.$topic: $err", \%kill, $num ); 
    264265            } else { 
    265266                if( $box->{onSuccess} =~ /\breply\b/ ) { 
     
    279280    eval 'use Email::Delete'; 
    280281    if( $@ ) { 
    281         TWiki::writeWarning( "Cannot delete from inbox: $@\n" ); 
     282        Foswiki::writeWarning( "Cannot delete from inbox: $@\n" ); 
    282283    } else { 
    283284        Email::Delete::delete_message 
     
    304305 
    305306    if( $box->{onError} =~ /\blog\b/ ) { 
    306         TWiki::Func::writeWarning( $mess ); 
     307        Foswiki::Func::writeWarning( $mess ); 
    307308    } 
    308309    if( $box->{onError} =~ /\breply\b/ ) { 
    309310        $this->_reply( $box, $mail, 
    310                        "TWiki found an error in your e-mail submission\n\n$mess\n\n". 
     311                       "Foswiki found an error in your e-mail submission\n\n$mess\n\n". 
    311312                         $mail->as_string()); 
    312313    } 
     
    341342    my $err = ''; 
    342343 
     344    my $curUser = $Foswiki::Plugins::SESSION->{user}; 
     345    $Foswiki::Plugins::SESSION->{user} = $user; 
     346 
    343347    try { 
    344         my( $meta, $text ) = $this->{session}->{store}->readTopic( 
    345             $user, $web, $topic ); 
     348        my( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); 
    346349 
    347350        my $opts; 
    348351        if( $text =~ /<!--MAIL(?:{(.*?)})?-->/ ) { 
    349             $opts = new TWiki::Attrs( $1 ); 
     352            $opts = new Foswiki::Attrs( $1 ); 
    350353        } else { 
    351             $opts = new TWiki::Attrs( '' ); 
     354            $opts = new Foswiki::Attrs( '' ); 
    352355        } 
    353356        $opts->{template} ||= 'normal'; 
     
    358361        # MailInContribTemplate as MailInContribUserTemplate and edit to 
    359362        # taste. - VickiBrown - 07 Sep 2007 
    360         my $insert = TWiki::Func::expandTemplate( 'MAILIN:'.$opts->{template} ); 
     363        my $insert = Foswiki::Func::expandTemplate( 'MAILIN:'.$opts->{template} ); 
    361364        $insert ||= "   * *%SUBJECT%*: %TEXT% _%WIKIUSERNAME% @ %SERVERTIME%_\n"; 
    362365        $insert =~ s/%SUBJECT%/$subject/g; 
     
    367370        foreach my $att ( @$attachments ) { 
    368371            $attached = 1; 
    369             $err .= $this->_saveAttachment( $user, $web, $topic, $att ); 
    370             my $tmpl = TWiki::Func::expandTemplate( 
     372            $err .= $this->_saveAttachment( $web, $topic, $att ); 
     373            my $tmpl = Foswiki::Func::expandTemplate( 
    371374                'MAILIN:'.$opts->{template}.':ATTACHMENT' ); 
    372375            if( $tmpl ) { 
     
    380383 
    381384        $insert =~ s/%TEXT%/$body/g; 
    382         my $curUser = $TWiki::Plugins::SESSION->{user}; 
    383         $TWiki::Plugins::SESSION->{user} = $user; 
    384         $insert = TWiki::Func::expandVariablesOnTopicCreation($insert); 
    385         $TWiki::Plugins::SESSION->{user} = $curUser; 
     385        $insert = Foswiki::Func::expandVariablesOnTopicCreation($insert); 
    386386 
    387387        # Reload the topic if we added attachments. 
    388388        if( $attached ) { 
    389             ( $meta, $text ) = $this->{session}->{store}->readTopic( 
    390                 $user, $web, $topic ); 
     389            ( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); 
    391390        } 
    392391 
     
    403402        print STDERR "Save topic $web.$topic:\n$text\n" if( $this->{debug} ); 
    404403 
    405         $this->{session}->{store}->saveTopic( 
    406             $user, $web, $topic, $text, $meta, 
    407             { comment => "Submitted by e-mail" } ); 
    408  
    409     } catch TWiki::AccessControlException with { 
     404        Foswiki::Func::saveTopic( 
     405            $web, $topic, $text, $meta, 
     406            { comment => "Submitted by e-mail", 
     407              forcenewrevision => 1} ); 
     408 
     409    } catch Foswiki::AccessControlException with { 
    410410        my $e = shift; 
    411411        $err .= $e->stringify(); 
     
    413413        my $e = shift; 
    414414        $err .= $e->stringify(); 
     415    } finally { 
     416        $Foswiki::Plugins::SESSION->{user} = $curUser; 
    415417    }; 
    416418    return $err; 
     
    418420 
    419421sub _saveAttachment { 
    420     my( $this, $user, $web, $topic, $attachment ) = @_; 
     422    my( $this, $web, $topic, $attachment ) = @_; 
    421423    my $filename = $attachment->{filename}; 
    422424    my $payload = $attachment->{payload}; 
     
    425427 
    426428    my $tmpfile = $web.'_'.$topic.'_'.$filename; 
    427     $tmpfile = $TWiki::cfg{PubDir}.'/'.$tmpfile; 
     429    $tmpfile = $Foswiki::cfg{PubDir}.'/'.$tmpfile; 
    428430 
    429431    $tmpfile .= 'X' while -e $tmpfile; 
     
    434436    my $err = ''; 
    435437    # SMELL: no central way to process attachment filenames, so we 
    436     # have to copy-paste the TWiki core code. 
     438    # have to copy-paste the Foswiki core code. 
    437439    $filename =~ s/ /_/go; 
    438     $filename =~ s/$TWiki::cfg{NameFilter}//goi; 
    439     $filename =~ s/$TWiki::cfg{UploadFilter}/$1\.txt/goi; 
    440     $this->{session}->{store}->saveAttachment( 
    441         $web, $topic, $filename, $user, 
     440    $filename =~ s/$Foswiki::cfg{NameFilter}//goi; 
     441    $filename =~ s/$Foswiki::cfg{UploadFilter}/$1\.txt/goi; 
     442    Foswiki::Func::saveAttachment( 
     443        $web, $topic, $filename, 
    442444        { comment => "Submitted by e-mail", file => $tmpfile }); 
    443445    unlink( $tmpfile ); 
     
    455457      "To: $addressee" . 
    456458        "\nFrom: ".$mail->header('To'). 
    457           "\nSubject: RE: your TWiki submission to ".$mail->header('Subject'). 
     459          "\nSubject: RE: your Foswiki submission to ".$mail->header('Subject'). 
    458460            "\n\n$body\n"; 
    459     eval { 
    460         $TWiki::Plugins::SESSION->{net}->sendEmail( $message, 5 ); 
    461     }; 
    462     if ($@) { 
    463         print "Failed trying to send mail: $@\n"; 
     461    my $errors = Foswiki::Func::sendEmail( $message, 5 ); 
     462    if ($errors) { 
     463        print "Failed trying to send mail: $errors\n"; 
    464464    } 
    465465} 
  • trunk/MailInContrib/lib/Foswiki/Contrib/MailInContrib/Config.spec

    r205 r1323  
    1 # ---+ MailInContrib 
     1#---+ Mail and Proxies 
     2#---++ Mail In 
    23# **PERL** 
    34# The configuration is in the form of an (perl) array of mailbox 
  • trunk/MailInContrib/lib/Foswiki/Contrib/MailInContrib/DEPENDENCIES

    r205 r1323  
    1 TWiki::Plugins,>=1.1,,This module requires TWiki-4 
    21Time::ParseDate,>=2003.0211,cpan,Required. Available from the CPAN:Time::ParseDate archive. 
    3 Error,>=0.15,cpan,Required. Available from the CPAN:Error archive. 
    42Email::Folder,>=0.84,cpan,Required. Available from the CPAN:Email::Folder archive. 
    53Email::FolderType::Net,>=1.02,cpan,Required. Available from the CPAN:Email::FolderType::Net archive. 
  • trunk/MailInContrib/lib/Foswiki/Contrib/MailInContrib/MANIFEST

    r205 r1323  
    11tools/mailincron 0555 command-line perl script 
    2 data/TWiki/MailInContrib.txt 0444 this topic 
    3 data/TWiki/MailInContribTemplate.txt 0444 file of templates 
    4 lib/TWiki/Contrib/MailInContrib.pm 0444 perl module 
    5 lib/TWiki/Contrib/MailInContrib/Config.spec 0444 configure spec 
     2data/System/MailInContrib.txt 0444 this topic 
     3data/System/MailInContribTemplate.txt 0444 file of templates 
     4lib/Foswiki/Contrib/MailInContrib.pm 0444 perl module 
     5lib/Foswiki/Contrib/MailInContrib/Config.spec 0444 configure spec 
    66lib/CPAN/lib/Email/Delete/IMAP.pm 0444 Extension to incomplete CPAN module 
    77lib/CPAN/lib/Email/Delete/POP3.pm 0444 Extension to incomplete CPAN module 
    8 pub/TWiki/MailInContrib/wikiringlogo20x20.png 0660 
     8pub/System/MailInContrib/wikiringlogo20x20.png 0660 
  • trunk/MailInContrib/lib/Foswiki/Contrib/MailInContrib/build.pl

    r1065 r1323  
    11#!/usr/bin/perl -w 
    2 # 
    3 # Example build class. Copy this file to the equivalent place in your 
    4 # plugin or contrib and edit. 
    5 # 
    6 # Requires the environment variable FOSWIKI_LIBS (a colon-separated path 
    7 # list) to be set to point at the build system and any required dependencies. 
    8 # Usage: ./build.pl [-n] [-v] [target] 
    9 # where [target] is the optional build target (build, test, 
    10 # install, release, uninstall), test is the default. 
    11 # Two command-line options are supported: 
    12 # -n Don't actually do anything, just print commands 
    13 # -v Be verbose 
    14 # 
    15  
    16 # Standard preamble 
    172BEGIN { 
    183  foreach my $pc (split(/:/, $ENV{FOSWIKI_LIBS})) { 
     
    216} 
    227 
    23 use TWiki::Contrib::Build; 
    24  
    25 # Declare our build package 
    26 { package MailInBuild; 
    27  
    28   @MailInBuild::ISA = ( "TWiki::Contrib::Build" ); 
    29  
    30   sub new { 
    31     my $class = shift; 
    32     return bless( $class->SUPER::new( "MailInContrib" ), $class ); 
    33   } 
    34  
    35   # Example: Override the build target 
    36   sub target_build { 
    37     my $this = shift; 
    38  
    39     $this->SUPER::target_build(); 
    40  
    41     # Do other build stuff here 
    42   } 
    43 } 
     8use Foswiki::Contrib::Build; 
    449 
    4510# Create the build object 
    46 $build = new MailInBuild(); 
     11$build = new Foswiki::Contrib::Build("MailInContrib"); 
    4712 
    4813# Build the target on the command line, or the default target 
  • trunk/MailInContrib/test/unit/MailInContrib/MailInContribSuite.pm

    r1064 r1323  
    22 
    33package MailInContribSuite; 
    4  
    5 use base qw( FoswikiFnTestCase! ); 
    6  
    7 use TWiki; 
     4use base 'FoswikiFnTestCase'; 
     5 
     6use Foswiki; 
    87use Error qw( :try ); 
    98use File::Path; 
    109use Error qw( :try ); 
    11 use TWiki::Contrib::MailInContrib; 
     10use Foswiki::Contrib::MailInContrib; 
    1211 
    1312my $box; 
     
    2322    $this->{twiki}->{store}->createWeb( 
    2423        $this->{twiki}->{user}, $this->{system_web}, 
    25         $TWiki::cfg{SystemWebName} ); 
     24        $Foswiki::cfg{SystemWebName} ); 
     25    my $adm = Foswiki::Func::getCanonicalUserID( 
     26        $Foswiki::cfg{AdminUserWikiName}); 
    2627    $this->{twiki}->{store}->saveTopic( 
    27         $TWiki::cfg{AdminUserWikiName}, $this->{system_web}, 
     28        $adm, $this->{system_web}, 
    2829        'WebPreferences', ""); 
    2930 
    30     $TWiki::cfg{SystemWebName} = $this->{system_web}; 
     31    $Foswiki::cfg{SystemWebName} = $this->{system_web}; 
    3132 
    3233    $this->{twiki}->finish(); 
    33     $this->{twiki} = new TWiki(); 
    34  
    35     my $workdir = TWiki::Func::getWorkArea('MailInContrib'); 
     34    $this->{twiki} = new Foswiki(); 
     35 
     36    my $workdir = Foswiki::Func::getWorkArea('MailInContrib'); 
    3637    open(F, ">$workdir/timestamp") || die $!; 
    3738    print F "0\n"; 
     
    5051 
    5152    $this->{twiki}->finish(); 
    52     $this->{twiki} = new TWiki(); 
     53    $this->{twiki} = new Foswiki(); 
    5354    $this->{twiki}->net->setMailHandler(\&sentMail); 
    5455 
    5556    $box = {}; 
    56  
    5757    # Make a maildir 
    5858    my $tmp = "/tmp/mail$$"; 
     
    6262    $box->{folder} = "$tmp/"; 
    6363 
    64     $TWiki::cfg{MailInContrib} = [ $box ]; 
     64    $Foswiki::cfg{MailInContrib} = [ $box ]; 
    6565    @mails = (); 
    6666} 
     
    9494sub cron { 
    9595    my $this = shift; 
    96     my $min = new TWiki::Contrib::MailInContrib( $this->{twiki}, 0 ); 
     96    my $min = new Foswiki::Contrib::MailInContrib( $this->{twiki}, 0 ); 
    9797    $min->processInbox( $box ); 
    9898    $min->wrapUp(); 
     
    119119and there is no valid default username', $c->{error}); 
    120120 
    121     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
     121    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
    122122 
    123123    $this->assert($t !~ /\S/, $t); 
     
    154154    $this->assert_null($c->{error}); 
    155155 
    156     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
     156    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
    157157 
    158158    $this->assert($t =~ s/^ *\* \*$this->{test_web}\.NotHere\*: Message 1 text here\s*-- $this->{users_web}\.MoleInnaHole -\s+\d+\s+\w+\s+\d+\s+-\s+\d+:\d+\n//m, $t); 
     
    190190    $this->assert_null($c->{error}); 
    191191 
    192     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
     192    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},$this->{test_topic}); 
    193193 
    194194    $this->assert($t =~ s/^\s*\* \*\*: Message 1 text here\s* -- $this->{users_web}\.MoleInnaHole -\s+\d+\s+\w+\s+\d+\s+-\s+\d+:\d+$//m, $t); 
     
    223223    $this->assert_null($c->{error}); 
    224224 
    225     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},'DangleBerries'); 
     225    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},'DangleBerries'); 
    226226 
    227227    $t =~ s/\* \*no valid topic\*: Message 1 text here\s*-- $this->{users_web}.AllyGator -\s+\d+\s+\w+\s+\d+\s+-\s+\d+:\d+//s; 
     
    367367    my $c = $this->cron(); 
    368368 
     369print STDERR "VBLO\n"; 
    369370    $this->assert_equals(1, scalar(@mails)); 
    370371    $this->assert_matches(qr/Thank you for your successful/, $mails[0]); 
    371372 
    372     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},'AnotherTopic'); 
     373    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},'AnotherTopic'); 
    373374    my @a = $m->get('FILEATTACHMENT'); 
    374375    $this->assert_equals(1, scalar(@a)); 
    375376    $this->assert_str_equals("data.asc", $a[0]->{attachment}); 
    376377 
    377     $this->assert(-e "$TWiki::cfg{PubDir}/$this->{test_web}/AnotherTopic/data.asc"); 
     378    $this->assert(-e "$Foswiki::cfg{PubDir}/$this->{test_web}/AnotherTopic/data.asc"); 
    378379} 
    379380 
     
    395396    $box->{onSuccess} = 'reply delete'; 
    396397    $this->{twiki}->{store}->saveTopic( 
    397         $this->{twiki}->{user}, $TWiki::cfg{SystemWebName}, 
     398        $this->{twiki}->{user}, $Foswiki::cfg{SystemWebName}, 
    398399        'MailInContribUserTemplate', <<'HERE'); 
    399400%TMPL:DEF{MAILIN:wierd}% 
     
    414415    $this->assert_matches(qr/Thank you for your successful/, $mails[0]); 
    415416 
    416     my( $m, $t ) = TWiki::Func::readTopic($this->{test_web},'TargetTopic'); 
     417    my( $m, $t ) = Foswiki::Func::readTopic($this->{test_web},'TargetTopic'); 
    417418 
    418419    $this->assert_matches(qr/BEGIN\s*Subject: Object\s*Body: Message 1 text here\s*<!--MAIL{/s, $t); 
  • trunk/MailInContrib/tools/mailincron

    r1050 r1323  
    44# 
    55# Copyright (C) 2005 TWiki Contributors. All Rights Reserved. 
    6 # TWiki Contributors are listed in the AUTHORS file in the root 
     6# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved. 
     7# Foswiki Contributors are listed in the AUTHORS file in the root 
    78# of this distribution. 
    89# NOTE: Please extend that file, not this notice. 
     
    2627} 
    2728 
    28 use TWiki::Contrib::MailInContrib; 
     29use Foswiki::Contrib::MailInContrib; 
    2930 
    3031my $debug; 
     
    4344} 
    4445 
    45 my $twiki; 
    46 my $folders; 
    47 if( eval 'defined($TWiki::wikiversion)' ) { 
    48     TWiki::initialize(); 
    49     $twiki = undef; 
    50     eval "use LocalSite.cfg"; 
    51 } else { 
    52     $twiki = new TWiki(); 
    53     $TWiki::Plugins::SESSION = $twiki; 
    54 } 
    55 $folders = $TWiki::cfg{MailInContrib}; 
    56 my $processor = new TWiki::Contrib::MailInContrib($twiki, $debug); 
     46my $session = new Foswiki(); 
     47my $folders = $Foswiki::cfg{MailInContrib}; 
     48my $processor = new Foswiki::Contrib::MailInContrib($session, $debug); 
    5749foreach my $folder ( @$folders ) { 
    5850    $processor->processInbox( $folder ); 
Note: See TracChangeset for help on using the changeset viewer.