Changeset 4279


Ignore:
Timestamp:
Nov 16, 2009, 12:28:47 PM (14 years ago)
Author:
ronosman
Message:

Feature 1064 added : improve upload progress dialog box to display current operation and the rank of the photo being uploaded.

Location:
extensions/pLoader/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/locale/fr_FR/pLoader.po

    r4126 r4279  
    254254msgstr "Durée"
    255255
     256msgid "seconds"
     257msgstr "secondes"
     258
    256259msgid "Categories"
    257260msgstr "Catégories"
     
    470473msgstr "Non sélectionnés"
    471474
     475msgid "Uploading"
     476msgstr "Transfère"
     477
     478msgid "Uploading resized"
     479msgstr "Transfère la photo réduite"
     480
     481msgid "Uploading thumbnail"
     482msgstr "Transfère la miniature"
     483
     484msgid "Uploading high definition"
     485msgstr "Transfère la photo HD"
     486
     487msgid "Checksum for"
     488msgstr "Checksum de"
     489
     490msgid "Communication error with"
     491msgstr "Erreur de communication avec"
     492
     493msgid "Uploaded"
     494msgstr "Transféré"
     495
     496msgid "Preparing resized image for"
     497msgstr "Prépare la photo réduite de"
     498
     499msgid "Close"
     500msgstr "Fermer"
     501
     502msgid "on"
     503msgstr "sur"
     504
     505msgid "photos added to the selection"
     506msgstr "photos ajoutées à la sélection"
     507
     508msgid "errors"
     509msgstr "erreurs"
  • extensions/pLoader/trunk/res/progress_wdr.pl

    r2597 r4279  
    1 #-----------------------------------------------------------------------------
    2 # Perl source generated by wxDesigner from file: progress.wdr
    3 # Do not modify this file, all changes will be lost!
    4 #-----------------------------------------------------------------------------
    5 
    61use Wx;
    72use strict;
     
    2318use vars qw($ID_LINE); $ID_LINE = 10003;
    2419use vars qw($ID_PROGRESS_OK); $ID_PROGRESS_OK = 10004;
     20use vars qw($ID_PROGRESS_TXT2); $ID_PROGRESS_TXT2 = 10005;
    2521
    2622sub ProcessingProgress {
     
    2925    my( $item1 ) = Wx::BoxSizer->new( wxVERTICAL );
    3026   
    31     my( $item2 ) = Wx::StaticText->new( $_[0], $main::ID_PROGRESS_TXT, "Processing", wxDefaultPosition, wxDefaultSize, 0 );
     27    my( $item2 ) = Wx::StaticText->new( $_[0], $main::ID_PROGRESS_TXT, "", wxDefaultPosition, wxDefaultSize, 0 );
    3228    $item1->AddWindow( $item2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    3329
     
    3834
    3935    $item1->AddSpace( 20, 30, 0, wxALIGN_CENTER|wxALL, 5 );
     36
     37    my( $item30 ) = Wx::StaticText->new( $_[0], $main::ID_PROGRESS_TXT2, "", wxDefaultPosition, wxDefaultSize, 0 );
     38    $item1->AddWindow( $item30, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
    4039
    4140    my( $item4 ) = Wx::Gauge->new( $_[0], $main::ID_PROGRESS_GAUGE, 100, wxDefaultPosition, [400,12], 0 );
     
    6766}
    6867
    69 # Menu bar functions
    70 
    71 
    72 # Toolbar functions
    73 
    74 
    75 # End of generated file
  • extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm

    r4152 r4279  
    214214    );
    215215
     216    $self->imagelist->progress_msg_details_refresh(
     217        sub { $self->UploadProgressMessageDetailsRefresh(@_) }
     218    );
    216219
    217220    $self->imagelist->progressbar_refresh(
     
    14011404                title => gettext("Image processing progress information"),
    14021405                bt_label => gettext("Cancel image processing"),
     1406                bt_close_label => gettext("Close"),
    14031407             }
    14041408        )       
     
    17061710    my ( $self, $msg ) = @_;   
    17071711
     1712    Wx::Yield();
     1713
    17081714    $self->upload_progressdlg->processing(
    17091715        $msg   
    17101716    ); 
     1717    $self->upload_progressdlg->LogProgress();
    17111718
    17121719    Wx::Yield();
    17131720}
     1721
     1722sub UploadProgressMessageDetailsRefresh {
     1723    my ( $self, $msg ) = @_;   
     1724
     1725    Wx::Yield();
     1726
     1727    $self->upload_progressdlg->processing_details(
     1728        $msg   
     1729    ); 
     1730    $self->upload_progressdlg->LogProgress();
     1731
     1732    Wx::Yield();
     1733}
     1734
    17141735
    17151736sub UploadProgressThumbnailRefresh {
     
    17311752
    17321753sub UploadProgressBarRefresh {
    1733     my ( $self, $ratio ) = @_; 
    1734 
    1735     $ratio = $self->imagelist->count > 1 ? 1 : $ratio;
     1754    my ( $self, $value ) = @_; 
     1755
    17361756    eval {
    17371757        $self->upload_progressdlg->progress(
    1738             $ratio*$self->imagelist->count * ( 100/scalar @{$self->imagelist->image_selection} )
     1758            $value
    17391759        );
    17401760        $self->upload_progressdlg->LogProgress();
    17411761    };
    1742     croak gettext("Upload cancelled") if $@;
     1762    #croak gettext("Upload cancelled") if $@;
    17431763
    17441764    Wx::Yield();
     
    18181838                {
    18191839                    title    => gettext("Image upload progress information"),
    1820                     bt_label => gettext("Cancel upload"),
     1840                    bt_label => gettext("Cancel upload"),
     1841                    bt_close_label => gettext("Close"),
    18211842                 }
    18221843            )       
     
    19131934    wxTheApp->StoreLayoutProperties;
    19141935
     1936    $self->manager->UnInit;
    19151937    $self->Destroy;
    19161938}
     
    20242046    my( $self ) = @_;
    20252047
    2026     $self->manager->UnInit;
    20272048}
    20282049
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageProcessingProgressDlg.pm

    r2728 r4279  
    4040           processing
    4141           txtprocessing
     42           processing_details
     43           txtprocessing_details
    4244           image
    4345           cancelled
     46           bt_close_label
    4447      /
    4548);
     
    6265    $self->gauge( $self->FindWindow($main::ID_PROGRESS_GAUGE) );
    6366    $self->txtprocessing( $self->FindWindow($main::ID_PROGRESS_TXT) );
     67    $self->txtprocessing_details( $self->FindWindow($main::ID_PROGRESS_TXT2) );
    6468    $self->image( $self->FindWindow($main::ID_STATICBITMAP) );
    6569    $self->gauge->SetForegroundColour(wxGREEN);
     
    6872    $self->btok->SetLabel(
    6973        $params->{bt_label}||'Cancel'
     74    );
     75    $self->bt_close_label(
     76        $params->{bt_close_label}||'Close'
    7077    );
    7178
     
    94101        $self->processing
    95102    );
     103    $self->txtprocessing_details->SetLabel(
     104        $self->processing_details
     105    );
    96106    $self->gauge->SetValue(
    97         $self->progress
     107        $self->progress 
    98108    );
    99109}
     
    107117    $self->image->Show(0);
    108118    $self->gauge->Show(0);
    109 
     119    # for i18n
    110120    $self->btok->SetLabel(
    111         'Close'
     121        $self->bt_close_label
    112122    );
    113123       
     124    $self->txtprocessing_details->SetLabel("");
    114125}
    115126
  • extensions/pLoader/trunk/src/Uploader/ImageList.pm

    r4152 r4279  
    7272                UploadImagesViewerCallback
    7373                progress_thumbnail_refresh
     74                progress_msg_details_refresh
    7475                progress_msg_refresh
    7576                progressbar_refresh
     
    102103                gravity
    103104                rgbcolor
     105                upload_msg
     106                upload_selection_count
     107                upload_uploaded_count
     108                upload_rejected_count
     109                upload_last_error
     110                upload_error_content
     111                upload_begin_time
     112                upload_end_time
     113                upload_duration
     114                upload_file
     115                upload_name
    104116     /
    105117);
     
    263275    $self->SetNewFilesDisplayEndInfoCallback->(
    264276        sprintf(
    265             "%s images added to the selection\n\n%s errors",
     277            "%s : %s\n\n%s : %s",
     278            gettext("photos added to the selection"),
    266279            $self->count,
    267             $errors
     280            gettext("errors"),
     281            $errors,
    268282           
    269283        )
     
    867881    my $viewer_callback = $self->UploadImagesViewerCallback ;
    868882
    869 
     883    $self->image_selection([]) if !defined $self->image_selection;
    870884    $self->upload_rejects(
    871885        []
    872886    );
    873887
    874     my $count = 1;
    875     my $msg;
    876888    $self->count(
    877         $count
    878     );
    879     my $uploaded = 0;
    880     my $rejected = 0;
    881     my $time_begin = time;
    882     my $last_error;
    883     map {
     889        1
     890    );
     891
     892    $self->upload_uploaded_count(0);
     893    $self->upload_rejected_count(0);
     894    $self->upload_begin_time(time);
     895    $self->upload_selection_count(scalar @{$self->image_selection});
     896    foreach(@{$self->image_selection}) {
    884897        # current image object         
    885898        $self->current_image(
    886899            $self->GetImage($_)
    887900        );
    888 
    889         my ( $vol, $dir, $file ) = File::Spec->splitpath(
    890             $self->current_image->file
    891         );
    892        
    893         my $site_name = $self->current_image->site_name;
    894    
    895         my $filename = $self->current_image->file_sum ;
    896 
    897         # lately defined to make sure we have the last global properties ( resize_w, resize_h )
    898         $self->current_image->site_resized_file(
    899             File::Spec->catfile(
    900                 $self->site_resized_dir,
    901                 sprintf(
    902                     "%s_%sx%s.%s",
    903                     $filename,
    904                     $self->resize_w,
    905                     $self->resize_h,
    906                     $self->type,
    907                 )
    908             )
    909         );
    910        
    911         $msg = sprintf(
    912             "Preparing resized image for %s - %s",
    913             $site_name,
    914             $file,
    915         );
    916 
    917         eval {
    918             # set current image thumbnail
    919             $self->progress_thumbnail_refresh->();
    920 
    921             $self->progress_msg_refresh->($msg);
    922    
    923             # update upload progress dialog
    924             $self->progressbar_refresh->(0.05);
    925         };
    926         # user cancelled : dialog box is destroyed
    927         croak "Upload cancelled. ", $@ if $@ ;
    928 
    929         if( $self->create_resized ){
    930             eval {
    931                 if(!$self->CreateResized()){
    932                     printf("CreateResized failed %s. Use ResizeCallback\n", $@);
    933                     # use method provided by the caller
    934                     # source, target, type, ratio, width, $height
    935                     $self->ResizeCallback->(
    936                         $self->current_image->file,
    937                         $self->current_image->site_resized_file,
    938                         $self->type,
    939                         undef,
    940                         $self->resize_w,
    941                         $self->resize_h,
    942                         $self->quality,
    943                     );
    944                
    945                     $self->RotateImage(
    946                         $self->current_image->site_resized_file,
    947                     ) if $self->auto_rotate;
    948                 }
    949             };
    950             $self->_set_exif_tag(
    951                 $self->current_image->site_resized_file,
    952                 'Orientation',
    953                 'Horizontal (normal)',
    954             ) if $self->auto_rotate;
    955 
    956             $self->CreateWatermark(
    957                $self->watermark_text,
    958                $self->watermark_text_size,
    959                $self->watermark_position,
    960                $self->watermark_x,
    961                $self->watermark_y,
    962                $self->watermark_color,
    963                $self->current_image->site_resized_file
    964            ) if $self->watermark_activate;
    965         }
    966         # the original is at the right size, no need to create a resize
    967         else {
    968             $self->current_image->site_resized_file(
    969                 $self->current_image->file,
    970             );
    971         }
    972 
    973 
    974 
    975         # if upload high, rotate a copy of original file
    976         if($self->upload_high){
    977             $self->CreateHigh();
    978         }
    979 
    980         # Resized and original are ready
    981         $self->progressbar_refresh->(0.10);
    982 
    983 
    984         $msg = sprintf(
    985             "Preparing thumbnail for %s - %s",
    986             $site_name,
    987             $file,
    988         );
    989 
    990         eval {
    991             $self->progress_msg_refresh->($msg);
    992         };
    993         croak "Upload cancelled. ", $@ if $@ ;
    994 
    995         eval {
    996             $self->CreateThumbnail();
    997         };
    998 
    999         if($@){
    1000             $msg = sprintf(
    1001                 "An error has occured %s - %s\n$@",
    1002                 $site_name,
    1003                 $file
    1004             );
    1005         }
    1006         else{
    1007             $msg = sprintf(
    1008                 "Uploading %s - %s",
    1009                 $site_name,
    1010                 $file
    1011             );
    1012         }
    1013         eval {
    1014             $self->progress_msg_refresh->($msg);
    1015             # Thumbnail is ready
    1016             $self->progressbar_refresh->(0.20);
    1017         };
    1018         croak "Upload cancelled. ", $@ if $@ ;
    1019 
    1020         # photo metadata
    1021         $self->_prepare_upload_properties();           
    1022         my ( $status, $status_msg, $content ) = $self->pwg->UploadImage( $self->YieldCallback, $self->progressbar_refresh );
    1023         my $ok = 0;
    1024         # HTTP REQUEST OK
    1025         if ( $status ){
    1026             # PIWIGO RESULT ( HTTP may be ok while Piwigo is not )
    1027             $ok = 'fail' eq $content->{stat} ? 0 : 1;
    1028         }
    1029         else{
    1030             Wx::LogMessage(
    1031                 "%s %s : %s",
    1032                 gettext("Communication error with"),
    1033                 $self->pwg->site_url,
    1034                 $status_msg,
    1035             );
    1036         }
    1037 
    1038         if($ok){
    1039             $msg = sprintf(
    1040                 "%s : %s - %s.",
    1041                 $site_name,
    1042                 $file,
    1043                 gettext("upload succcessful"),
    1044             );
    1045            
    1046             push @{$self->uploaded_images}, $_;
    1047             $uploaded++;
    1048         } else {
    1049             $msg = sprintf(
    1050                 "An error has occured.\n%s : %s upload is cancelled.\n%s",
    1051                 $site_name,
    1052                 $file,
    1053                 Dumper($content),
    1054             );
    1055             $rejected++;
    1056             $last_error = $status_msg;
    1057         }       
    1058        
    1059         $count++;
     901        # prepare resized, high, thumbnail
     902        $self->_upload_selection_prepare();
     903
     904        # transfert resized, high, thumbnail to site
     905        my $status = $self->_upload_selection_transfert();
     906        # log operations
     907        $self->_upload_selection_log($status);
    1060908        $self->count(
    1061             $count
    1062         );
    1063         # update upload progress dialog
    1064         eval {
    1065             $self->progress_msg_refresh->($msg);
    1066             $self->progressbar_refresh->(1);
    1067         };
    1068         croak "Upload cancelled. ", $@ if $@ ;
    1069        
    1070     }
    1071     @{$self->image_selection} if defined
    1072         $self->image_selection;
     909            1+$self->count
     910        );
     911    }
    1073912
    1074913    if($self->remove_uploaded_from_selection){
     
    1076915        $viewer_callback->();
    1077916    }
    1078     my $time_end = time;
    1079     my $duration = $time_end - $time_begin;
    1080     $msg = sprintf(
    1081         "%s images processed\n\n%s images uploaded\n\n%s images in errors and not uploaded - \n%s\n\nDuration : %s seconds",
    1082         $self->count - 1,
    1083         $uploaded,
    1084         $rejected,
    1085         $last_error,
    1086         $duration,
    1087     );
    1088     $self->progress_endinfo_refresh->($msg);
     917
     918    $self->_upload_selection_final_log();
     919}
     920
     921sub _upload_selection_prepare {
     922    my ( $self ) = @_;
     923
     924    $self->progress_thumbnail_refresh->();
     925    # PREPARE
     926    $self->_set_site_resized_file();
     927    $self->_set_upload_msg(gettext("Preparing resized image for"));
     928    $self->_upload_progress();
     929
     930    if( $self->create_resized ){
     931        $self->_create_site_resized_file();
     932        $self->_set_upload_msg(gettext("Resized image done for"));
     933        $self->_upload_progress();
     934    }
     935    # the original is at the right size, no need to create a resize
     936    else {
     937        $self->current_image->site_resized_file(
     938            $self->current_image->file,
     939        );
     940    }
     941
     942    # if upload high, rotate a copy of original file
     943    if($self->upload_high){
     944        $self->CreateHigh();
     945        $self->_set_upload_msg(gettext("HD image done for"));
     946        $self->_upload_progress();
     947    }
     948
     949    eval {
     950        $self->CreateThumbnail();
     951    };
     952    $self->_set_upload_msg(gettext("Thumbnail image done for"));
     953    $self->_upload_progress();
     954
     955    # photo metadata
     956    $self->_prepare_upload_properties();       
     957
     958}
     959
     960sub _upload_progress {
     961    my ( $self, $value ) = @_;
     962
     963    eval {
     964        $self->progress_msg_refresh->(
     965            $self->upload_msg
     966        );
     967        # set current image thumbnail
     968        # update upload progress dialog
     969        #$self->progressbar_refresh->($value);
     970    };
     971    # user cancelled : dialog box is destroyed
     972    croak gettext("Upload cancelled"), " .", $@ if $@ ;
     973
     974
     975}
     976
     977sub _set_upload_msg {
     978    my ( $self, $msg, $errmsg ) = @_;
     979
     980    $self->upload_msg(
     981        sprintf(
     982            "%s : %s - %s\n\n%s %s %s %s\n%s",
     983            $msg,
     984            $self->upload_file,
     985            $self->upload_name,
     986            gettext("Photo"),
     987            $self->count,
     988            gettext("on"),
     989            $self->upload_selection_count,
     990            $errmsg
     991        )
     992    );
     993}
     994
     995sub _upload_selection_transfert {
     996    my ( $self ) = @_;
     997
     998    $self->_set_upload_msg(gettext("Uploading"));
     999    $self->_upload_progress(0);
     1000
     1001    # UPLOAD
     1002    my ( $status, $status_msg, $content ) = $self->pwg->UploadImage(
     1003        {
     1004            yield=>$self->YieldCallback,
     1005            bar=>$self->progressbar_refresh,
     1006            msg=>$self->progress_msg_refresh,
     1007            msg_details=>$self->progress_msg_details_refresh,
     1008            resized_msg=>gettext("Uploading resized"),
     1009            thumbnail_msg=>gettext("Uploading thumbnail"),
     1010            highdef_msg=>gettext("Uploading high definition"),
     1011            checksum_msg=>gettext("Checksum for"),
     1012        }
     1013    );
     1014    my $ok = 0;
     1015    # HTTP REQUEST OK
     1016    if ( $status ){
     1017        # PIWIGO RESULT ( HTTP may be ok while Piwigo is not )
     1018        $ok = 'fail' eq $content->{stat} ? 0 : 1;
     1019    }
     1020    else{
     1021        Wx::LogMessage(
     1022            "%s %s : %s",
     1023            gettext("Communication error with"),
     1024            $self->pwg->site_url,
     1025            $status_msg,
     1026        );
     1027    }
     1028    $self->upload_last_error(
     1029        $status_msg
     1030    );
     1031
     1032    $self->upload_error_content(
     1033        $content
     1034    );
     1035
     1036    $ok;
     1037}
     1038
     1039sub _upload_selection_log {
     1040    my ( $self, $ok ) = @_;
     1041
     1042    if($ok){
     1043        $self->_set_upload_msg(gettext("Uploaded"));
     1044        $self->_upload_progress(0);
     1045        push @{$self->uploaded_images}, $_;
     1046        $self->upload_uploaded_count(
     1047            1+$self->upload_uploaded_count       
     1048        );
     1049    } else {
     1050        $self->_set_upload_msg(gettext("An error has occured"), Dumper($self->upload_error_content));
     1051        $self->upload_rejected_count(
     1052            1+$self->upload_rejected_count
     1053        );
     1054    }   
     1055       
     1056}
     1057
     1058sub _upload_selection_final_log {
     1059    my ( $self ) = @_;
     1060
     1061    $self->upload_end_time(time);
     1062    $self->upload_duration(
     1063        $self->upload_end_time - $self->upload_begin_time
     1064    );
     1065
     1066    $self->progress_endinfo_refresh->(
     1067        sprintf(
     1068            "%s : %s\n\n%s : %s\n\n%s : %s\n\n\n%s : %s %s",
     1069            gettext("images processed"),
     1070            $self->count - 1,
     1071            gettext("images uploaded"),
     1072            $self->upload_uploaded_count,
     1073            gettext("images in errors and not uploaded"),
     1074            $self->upload_rejected_count,
     1075            gettext("Duration"),
     1076            $self->upload_duration,
     1077            gettext("seconds"),
     1078        )
     1079    );
     1080    $self->progress_msg_details_refresh(" ");
     1081}
     1082
     1083sub _set_site_resized_file {
     1084    my ( $self ) = @_;
     1085
     1086    my ( $vol, $dir, $file ) = File::Spec->splitpath(
     1087        $self->current_image->file
     1088    );
     1089
     1090    $self->upload_file(
     1091        $file
     1092    );
     1093       
     1094    $self->upload_name(
     1095        $self->current_image->site_name
     1096    );
     1097    my $filename = $self->current_image->file_sum ;
     1098
     1099    # lately defined to make sure we have the last global properties ( resize_w, resize_h )
     1100    $self->current_image->site_resized_file(
     1101        File::Spec->catfile(
     1102            $self->site_resized_dir,
     1103            sprintf(
     1104                "%s_%sx%s.%s",
     1105                $filename,
     1106                $self->resize_w,
     1107                $self->resize_h,
     1108                $self->type,
     1109            )
     1110        )
     1111    );
     1112}
     1113
     1114sub _create_site_resized_file {
     1115    my ( $self ) = @_;
     1116
     1117    eval {
     1118        if(!$self->CreateResized()){
     1119            $self->__create_resized_fallback();
     1120        };
     1121
     1122        $self->_set_exif_tag(
     1123            $self->current_image->site_resized_file,
     1124            'Orientation',
     1125            'Horizontal (normal)',
     1126        ) if $self->auto_rotate;
     1127
     1128        $self->CreateWatermark(
     1129            $self->watermark_text,
     1130            $self->watermark_text_size,
     1131            $self->watermark_position,
     1132            $self->watermark_x,
     1133            $self->watermark_y,
     1134            $self->watermark_color,
     1135            $self->current_image->site_resized_file
     1136        ) if $self->watermark_activate;
     1137    }
     1138}
     1139
     1140sub _create_resized_fallback {
     1141    my ( $self ) = @_;
     1142    # use wx builtin rescale if IM fails
     1143    printf("CreateResized failed %s. Use ResizeCallback\n", $@);
     1144    # use method provided by the caller
     1145    # source, target, type, ratio, width, $height
     1146    $self->ResizeCallback->(
     1147        $self->current_image->file,
     1148        $self->current_image->site_resized_file,
     1149        $self->type,
     1150        undef,
     1151        $self->resize_w,
     1152        $self->resize_h,
     1153        $self->quality,
     1154    );
     1155               
     1156    $self->RotateImage(
     1157        $self->current_image->site_resized_file,
     1158    ) if $self->auto_rotate;
    10891159}
    10901160
     
    12061276        $file_out
    12071277    );     
    1208 printf("gravity %s, color %s, pointsize %s, x %s, y %s\n", $gravity, $fill, $text_size, $x, $y);   
     1278
    12091279    my $ratio = $image->Get('height')/($self->resize_h||$image->Get('height'));
    12101280    $ratio||=1;
    12111281    $text ||="Your watermark";
    12121282    $image->Annotate(
    1213 #        font => 'Vera.ttf',
    12141283        pointsize => $text_size*$ratio,
    12151284        fill => $fill,
  • extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm

    r4268 r4279  
    2828use Digest::MD5::File qw/file_md5_hex md5_hex/;
    2929use File::Slurp;
     30use File::Spec;
    3031use POSIX qw(ceil floor);
    3132use base qw/
     
    236237
    237238sub UploadImage {
    238     my ( $self, $yield_callback ) = @_;
     239    my ( $self, $progress ) = @_;
    239240
    240241    my $file_sum;
    241242
     243    my $yield = $progress->{yield};
     244    $yield->();
     245    $progress->{msg_details}->(
     246            sprintf(
     247                "%s : %s",
     248                $progress->{checksum_msg},
     249                $self->site_resized_file
     250            )
     251        );
    242252    eval {
    243253        $file_sum = file_md5_hex(
     
    245255        );
    246256    };
    247  
    248 
     257    $yield->();
     258 
     259    $progress->{msg_details}->(
     260            sprintf(
     261                "%s : %s",
     262                $progress->{checksum_msg},
     263                $self->site_thumb_file
     264            )
     265        );
    249266    my $thumbnail_sum = file_md5_hex(
    250267        $self->site_thumb_file,
    251268    );
    252 
     269   $yield->();
     270 
     271    $progress->{msg_details}->(
     272            sprintf(
     273                "%s : %s",
     274                $progress->{checksum_msg},
     275                $self->site_high_file
     276            )
     277        );
     278 
    253279    my $original_sum = file_md5_hex(
    254280        $self->site_high_file
     
    260286    };
    261287
     288    $yield->();
    262289    my $result = $self->uagent->post(
    263290        $self->urlbase.'/ws.php?format=json',
    264291        $form
    265292    );
     293    $yield->();
    266294
    267295    my $hresult = {};
     
    285313                type           => 'file',
    286314                original_sum   => $original_sum,
    287                 yield_callback => $yield_callback,
    288315            };
    289    
     316
     317            $progress->{current_msg} = $progress->{resized_msg};
     318            $yield->();
    290319            $self->send_chunks(
    291                 $resized_params
    292             );
    293 
    294             $yield_callback->() if 'CODE' eq ref($yield_callback);
     320                $resized_params,
     321                $progress,
     322            );
     323            $yield->();
     324
    295325            $status_line = $resized_params->{message};
    296326            last if !$resized_params->{ok};
     
    300330                type           => 'thumb',
    301331                original_sum   => $original_sum,               
    302                 yield_callback => $yield_callback,
    303332            };
    304333   
     334            $progress->{current_msg} = $progress->{thumbnail_msg};
     335            $yield->();
    305336            $self->send_chunks(
    306                 $thumb_params
    307             );
    308 
    309             $yield_callback->() if 'CODE' eq ref($yield_callback);
     337                $thumb_params,
     338                $progress,
     339            );
     340            $yield->();
    310341            $status_line = $thumb_params->{message};
    311342            last if !$thumb_params->{ok};
     
    330361                type           => 'high',
    331362                original_sum   => $original_sum,
    332                 yield_callback => $yield_callback,
    333363            };
    334364   
    335365            if($self->upload_high){
    336366                $form->{high_sum} = $original_sum;
    337    
     367                $progress->{current_msg} = $progress->{highdef_msg};
     368                $yield->();
    338369                $self->send_chunks(
    339                     $high_params
    340                 );
    341                 $yield_callback->() if 'CODE' eq ref($yield_callback);
    342 
     370                    $high_params,
     371                    $progress
     372                );
     373                $yield->();
    343374                $status_line = $high_params->{message};
    344375                last if !$high_params->{ok};
    345    
    346376            }
    347377        }
     
    358388                tag_ids           => $self->site_tags,
    359389            };
    360             $yield_callback->() if 'CODE' eq ref($yield_callback);
     390            $yield->();
    361391        }
    362392
     
    364394        delete $form->{tag_ids} if '' eq $self->site_tags;
    365395
     396        $yield->();
    366397        $result = $self->uagent->post(
    367398            $self->urlbase.'/ws.php?format=json',
    368399            $form
    369400        );
    370 
    371401        eval {
    372402            $content = from_json(
     
    441471
    442472sub send_chunks {
    443     my ( $self, $params ) = @_;
    444 
     473    my ( $self, $params, $progress ) = @_;
     474
     475    my $yield = $progress->{yield};
     476    my ( $vol, $dir, $filename ) = File::Spec->splitpath($params->{filepath});
     477
     478    $yield->();
     479    $progress->{bar}->(0);
     480    $yield->();
     481    $progress->{msg_details}->(
     482        sprintf(
     483            "%s : %s",
     484            $progress->{current_msg},
     485            $filename
     486        )
     487    );
     488
     489
     490    $yield->();
    445491    my $content = read_file(
    446492        $params->{filepath},
    447493        binmode => ':raw',
    448494    );
     495    $yield->();
    449496
    450497    my $content_length = length($content);
     
    453500    my $chunk_pos = 0;
    454501    my $chunk_id = 1;
     502
     503
    455504    while ($chunk_pos < $content_length) {
     505
    456506        my $chunk = substr(
    457507            $content,
     
    460510        );
    461511        $chunk_pos += $self->chunk_size;
    462 
    463512        my $response = $self->uagent->post(
    464513            $self->urlbase.'/ws.php?format=json',
     
    471520            }
    472521        );
    473         $params->{yield_callback}->() if 'CODE' eq ref($params->{yield_callback});
     522        $yield->();
     523        $progress->{bar}->(100*($chunk_pos/$content_length));
     524        $progress->{msg_details}->(
     525            sprintf(
     526                "%s : %s",
     527                $progress->{current_msg},
     528                $filename
     529            )
     530        );
    474531        $params->{ok} = 1;
    475532        if ($response->code != 200) {
  • extensions/pLoader/trunk/src/ploader.pl

    r4095 r4279  
    2626use Wx::Locale qw/:default/;
    2727
     28#$SIG{__DIE__} = \&OnDieHandler;
    2829
    2930
     
    3536    $app->MainLoop();
    3637};
     38
     39sub OnDieHandler {
     40    my ( $exception ) = @_;
     41   
     42    # if triggered in eval
     43    # return if $^S;
     44    print $exception;
     45}
    37461;
    3847
Note: See TracChangeset for help on using the changeset viewer.