Changeset 5962

Show
Ignore:
Timestamp:
05/17/08 17:37:46 (8 months ago)
Author:
coolengineer
Message:
  • #960, stat callback 추가
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/components/Needlworks.Mail.Pop3.php

    r5953 r5962  
    1111        $this->uidl_filter = null; 
    1212        $this->size_filter = null; 
     13        $this->stat_callback = null; 
    1314        $this->retr_callback = null; 
    1415        $this->mails = array(); 
     
    3132        $this->ctx = fsockopen( $bSSL ? "ssl://$server" : $server, $port);  
    3233        if( !$this->ctx ) { 
    33             $this->log( "Connect failed: $server:$port" ); 
    3434            return false; 
    3535        } 
     
    126126    } 
    127127 
     128    function setStatCallback( $func ) 
     129    { 
     130        $this->stat_callback =& $func; 
     131    } 
     132 
    128133    function setRetrCallback( $func ) 
    129134    { 
     
    152157            list( $number, $uid ) = split( " ", $line ); 
    153158            if( !empty($this->filterred[$number]) ) { 
    154                 $this->log( "Msg $number: Already filterred" ); 
    155159                continue; 
    156160            } 
    157             if( $this->uidl_filter && call_user_func($this->uidl_filter, $uid) ) { 
    158                 $this->log( "Msg $number: Filterred by uid: $uid" ); 
     161            if( $this->uidl_filter && call_user_func($this->uidl_filter, $uid, $number) ) { 
    159162                $this->filterred[$number] = true; 
    160163                continue; 
     
    177180        } 
    178181        list( $total, $totalsize ) = split( " ", $this->status ); 
     182        if( $this->stat_callback ) { 
     183            if( !call_user_func( $this->stat_callback, $total, $totalsize ) ) { 
     184                return false; 
     185            } 
     186        } 
     187 
     188        if( $total == 0 ) { 
     189            return false; 
     190        } 
    179191 
    180192        $this->log( "Send: LIST" ); 
     
    188200            list( $number, $size ) = split( " ", $line ); 
    189201            if( !empty($this->filterred[$number]) ) { 
    190                 $this->log( "Msg $number: Already filterred" ); 
    191202                continue; 
    192203            } 
    193204            if( $this->size_filter && call_user_func($this->size_filter, $size, $number, $total) ) { 
    194                 $this->log( "Msg $number: Filterred by size: $size" ); 
    195205                if( isset( $this->uids[$number] ) ) { 
    196206                    unset( $this->mails[$this->uids[$number]] ); 
     
    221231        $count = 1000000; /* Maximum 1000000 lines! it's enough to handle 6MB bytes */ 
    222232        $line = fgets($this->ctx, 1024);  
    223         $this->log( "Recv: $line" ); 
     233        $this->log( "Recv: ".trim($line) ); 
    224234        if( !$line ) { 
    225235            return false;