Ignore:
Timestamp:
Jul 26, 2010, 11:21:44 AM (14 years ago)
Author:
ronosman
Message:

use tranfer error messages in progress list. various bug fixes.

Location:
extensions/pLoader/trunk/src/Uploader
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/GUI/App.pm

    r6538 r6707  
    7373
    7474my @app_properties = qw/
     75    localized_msg
    7576    version
    7677    frame
     
    140141    batch_end_event
    141142    image_progress_event
     143    image_done_event
    142144/;
    143145
     
    469471        $self->current_language
    470472    );
     473
    471474    $locale->AddCatalogLookupPathPrefix(
    472475        File::Spec->catfile($self->root_dir, $self->locale_dir)
     
    582585        ]
    583586    );
     587
     588
     589    $self->localized_msg(
     590        {
     591             map { $_ => gettext($_) } (
     592                 'cancelled',
     593                 'sending files',
     594                 'checking files',
     595                 'files checked',
     596                 'transfered',
     597                 'updating',
     598                 'updating files',
     599                 'files updated',
     600                 'updating properties',
     601                 'properties updated',
     602                 'prepared, waiting for transfer',
     603                 'preparing web size',
     604                 'web size prepared',
     605                 'preparing high',
     606                 'high prepared',
     607                 'start sending',
     608                 'sending',
     609                 
     610             )
     611        }
     612    );
     613
     614    print Dumper $self->localized_msg;
    584615
    585616}
     
    727758            batch_end_event => $resize_batch_end_event,
    728759            event_handler   => $self,
     760            localized_msg   => $self->localized_msg,
    729761        })
    730762    );
     
    817849}
    818850
     851
     852sub on_image_done {
     853    my ( $self, $image ) = @_;
     854
     855    Wx::PostEvent(
     856        $self->frame,
     857        Wx::PlThreadEvent->new(
     858            -1,
     859            $self->image_done_event,
     860            $image
     861        )
     862    );
     863}
    819864
    820865sub init_images {
     
    11081153                use_offline    => $self->use_offline,
    11091154                version        => $self->version,
     1155                localized_msg  => $self->localized_msg,
    11101156            }
    11111157        )
     
    12291275            event_handler   => $self,
    12301276            batch_end_event => $transfer_batch_end_event,
     1277            localized_msg   => $self->localized_msg,
    12311278        })
    12321279    );
    12331280
    12341281    $self->image_progress_event(
     1282        Wx::NewEventType
     1283    );
     1284
     1285    $self->image_done_event(
    12351286        Wx::NewEventType
    12361287    );
     
    12891340            my ( $handler, $event ) = @_;
    12901341            my $data = $event->GetData;
    1291             $handler->on_image_progress($data);
     1342            $handler->on_image_done($data);
    12921343        }
    12931344    );
  • extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm

    r6538 r6707  
    484484                        )
    485485                    );
    486                     wxTheApp->layout_clean(1);
    487486                },
    488487            },
     
    10621061            my $data = $event->GetData;
    10631062            $handler->upload_progressdlg->batch_end($data);
     1063            wxTheApp->images->remove_processed;
     1064            $handler->refresh_image_context;
     1065        }
     1066    );
     1067
     1068    Wx::Event::EVT_COMMAND(
     1069        $self,
     1070        -1,
     1071        wxTheApp->image_done_event,
     1072        sub {
     1073            my ( $handler, $event ) = @_;
     1074            my $data = $event->GetData;
     1075printf("image_done_event %s\n", Dumper $data);
     1076            if($data->{preferences}{remove_uploaded_from_selection}){
     1077                my $gr = $data->{global_rank};
     1078                if(defined $gr){
     1079                    wxTheApp->images->set_to_be_removed($gr) if $data->{transfer_successful};
     1080                }
     1081            }
    10641082        }
    10651083    );
     
    11241142
    11251143    $self->images->remove_selection;
    1126     $self->imageviewer->Refresh;   
    1127 
    1128     if (!$self->imageviewer->GetItemCount){
     1144    $self->refresh_image_context;
     1145}
     1146
     1147sub refresh_image_context {
     1148    my ( $self ) = @_;
     1149
     1150    $self->imageviewer->Refresh;
     1151
     1152    if ($self->imageviewer->is_empty){
    11291153        $self->image_preview_dlg->image(
    11301154            0
  • extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceFilteredPanel.pm

    r5542 r6707  
    459459    my( $self, $event ) = @_;
    460460
    461     $self->init_choices_list(
     461    $self->refresh_choices_list(
    462462        $self->choices->()
    463463    );
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageListCtrl.pm

    r6426 r6707  
    543543
    544544
    545 
     545sub is_empty {
     546    my ( $self ) = @_;
     547
     548    !$self->GetItemCount;
     549}
    5465501;
    547551
  • extensions/pLoader/trunk/src/Uploader/Images.pm

    r6538 r6707  
    3131    author
    3232    type
     33    global_rank
     34    global_rank_indx
    3335/;
    3436
     
    3739/;
    3840
     41my @tmp_properties = qw/
     42    to_be_removed_grank
     43/;
     44
     45
    3946__PACKAGE__->mk_accessors(@cbk_properties);
    4047__PACKAGE__->mk_accessors(@storable_properties);
    4148__PACKAGE__->mk_accessors(@app_properties);
    42 
    43 my $_global_rank = -1;
     49__PACKAGE__->mk_accessors(@tmp_properties);
     50
    4451
    4552sub Init {
     
    4956    $self->ordered_image_ids([]) if !defined $self->ordered_image_ids;
    5057    $self->selection([]) if !defined $self->selection;
     58    $self->global_rank(-1) if !defined $self->global_rank;
     59    $self->global_rank_indx({}) if !defined $self->global_rank_indx;
     60    $self->to_be_removed_grank([]) if !defined $self->to_be_removed_grank;
    5161}
    5262
     
    90100    $self->ordered_image_ids->[$i] = $image_id ;
    91101
     102    $self->global_rank(
     103        1+$self->global_rank
     104    );
     105
     106    $self->global_rank_indx->{
     107        $self->global_rank
     108    } = $i;
    92109
    93110    my $image = $self->_images->{
     
    104121                site_tags         => [],
    105122                site_high_file    => $file->{ANSIPathName},
    106                 global_rank       => ++$_global_rank,
     123                global_rank       => $self->global_rank,
    107124            }
    108125        );
     
    176193    my ( $self, $indx ) = @_;
    177194   
     195    return unless defined $indx;
    178196    my $id = $self->ordered_image_ids->[$indx];
    179197
     
    222240
    223241
     242sub remove_processed {
     243    my ( $self ) = @_;
     244   
     245    return if ( $self->is_empty );
     246    return if (! defined $self->to_be_removed_grank );
     247
     248    my $to_remove_indx = [];
     249    # check if the global rank correspond
     250    # the image may have changed
     251    foreach(@{$self->to_be_removed_grank}) {
     252        my $indx = $self->global_rank_indx->{$_};
     253        my $img;
     254        if(defined $indx){
     255            $img = $self->get_image($indx);
     256        }
     257        if(defined $img){
     258            push @$to_remove_indx, $indx if
     259                $img->global_rank == $_;
     260        }
     261    }
     262
     263    $self->_remove_selection($to_remove_indx);
     264    # clear image selection
     265    $self->to_be_removed_grank([]);
     266}
     267
     268
    224269sub _remove_selection {
    225270    my ( $self, $list ) = @_;
     271    printf("_remove_selection %s\n", Dumper $list);
    226272    # the list is sorted, ascendant
    227273    # we reverse it to have
     
    238284}
    239285
     286
     287# postpone actual removal.
     288sub set_to_be_removed {
     289    my ( $self, $global_rank ) = @_;
     290
     291    push @{$self->to_be_removed_grank}, $global_rank;
     292}
     293
     294
    240295sub delete_image {
    241296    my ( $self, $indx ) = @_;
     
    245300    # have to check if that id is used more than once
    246301    my $count = grep { $id eq $_} @{$self->ordered_image_ids};
     302
     303    # global rank is unique
     304    delete $self->global_rank_indx->{
     305        $self->_images->{$id}->global_rank
     306    };
    247307
    248308    delete $self->_images->{$id} unless $count > 1;
     
    517577
    518578
     579# when the progress list is cleared
    519580sub reset_add_rank {
    520581    my ( $self ) = @_;
  • extensions/pLoader/trunk/src/Uploader/Object.pm

    r6426 r6707  
    3131    version
    3232    storable_file
     33    localized_msg
    3334/);
    3435
  • extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm

    r6426 r6707  
    1919# +-----------------------------------------------------------------------+
    2020package Uploader::PWG::WebServices;
    21  
     21use threads;
     22use threads::shared;
     23
    2224use strict;
    2325use warnings;
     
    238240        );   
    239241    }
    240    
     242
    241243    return ( $result->is_success, $result->status_line );
    242244}
     
    514516    $self->log_image_progress(
    515517        $image,
    516         sprintf("sending %s", $image->{file_type_code}),
     518        sprintf(
     519            "%s : %s",
     520            $self->localized_msg->{"start sending"},
     521            $image->{file_type_code}
     522        ),
    517523        0,
    518524    );
     
    553559        $self->log_image_progress(
    554560            $image,
    555             sprintf("sending %s", $image->{file_type_code}),
     561            sprintf(
     562                "%s : %s",
     563                $self->localized_msg->{"sending"},
     564                $image->{file_type_code}
     565            ),
    556566            100*($chunk_pos/$content_length),
    557567        );
     
    604614
    605615}
     616
    606617
    607618sub add_image {
  • extensions/pLoader/trunk/src/Uploader/ResizeManager.pm

    r6522 r6707  
    1515
    1616    Uploader::ResizeWorker->new({
    17         thumb_dir    => $self->thumb_dir,
    18         wx_thumb_dir => $self->wx_thumb_dir,
    19         resized_dir  => $self->resized_dir,
    20         preferences  => $self->preferences,
    21         write_type   => 'jpg',
     17        thumb_dir     => $self->thumb_dir,
     18        wx_thumb_dir  => $self->wx_thumb_dir,
     19        resized_dir   => $self->resized_dir,
     20        preferences   => $self->preferences,
     21        write_type    => 'jpg',
     22        localized_msg => $self->localized_msg,
    2223    });
    2324}
  • extensions/pLoader/trunk/src/Uploader/ResizeWorker.pm

    r6538 r6707  
    3737    $self->log_image_progress(
    3838        $image,
    39         "cancelled",
     39        $self->localized_msg->{"cancelled"},
    4040        0,
    4141    );
     
    8080    my ( $self, $image ) = @_;
    8181
    82     $image->{status}   = "prepared, waiting for transfer";
     82    $image->{status}   = $self->localized_msg->{"prepared, waiting for transfer"};
    8383    $image->{progress} = 25;
    8484
     
    114114    );
    115115
    116     Wx::PostEvent($self->event_handler, $thread_event);
     116    eval {
     117        Wx::PostEvent($self->event_handler, $thread_event);
     118    }
     119
    117120}
    118121
     
    123126    $self->log_image_progress(
    124127        $image,
    125         "creating web size",
     128        $self->localized_msg->{"preparing web size"},
    126129        5,
    127130    );
     
    140143    $self->log_image_progress(
    141144        $image,
    142         "web size created",
     145        $self->localized_msg->{"web size prepared"},
    143146        10,
    144147    );
     
    338341    $self->log_image_progress(
    339342        $image,
    340         "preparing high",
     343        $self->localized_msg->{"preparing high"},
    341344        15,
    342345    );
     
    447450    $self->log_image_progress(
    448451        $image,
    449         "high prepared",
     452        $self->localized_msg->{"high prepared"},
    450453        25,
    451454    );
  • extensions/pLoader/trunk/src/Uploader/TransferManager.pm

    r6525 r6707  
    66use base qw/Uploader::ThreadManager/;
    77use Uploader::TransferWorker;
    8 use vars qw/$AUTOLOAD/;
    98__PACKAGE__->mk_accessors(qw/
    109    pwg
     
    1817
    1918    Uploader::TransferWorker->new({
    20         pwg => $self->pwg,
     19        pwg           => $self->pwg,
     20        localized_msg => $self->localized_msg,
    2121    });
    2222
     
    2727    my ( $self ) = @_;
    2828
    29     !scalar @{$self->destination_category};
     29    defined $self->destination_category ?
     30        !scalar @{$self->destination_category} :
     31        1;
    3032}
    3133
  • extensions/pLoader/trunk/src/Uploader/TransferWorker.pm

    r6538 r6707  
    3434    return unless $image->{image_id};
    3535
    36     $self->log_image_progress(
    37         $image,
    38         "cancelled",
    39         0,
    40     );
     36    ( $image->{status}, $image->{progress} ) = ($self->localized_msg->{"cancelled"}, 0);
     37    $self->post_image_progress_event($image);
    4138}
    4239
     
    4946    );
    5047
    51 
    5248    $self->progress_event(
    5349        $progress_event
     
    5753        $transfer_done_event
    5854    );
    59 
     55   
    6056
    6157    if(!$self->exists_image($image)){
     
    6662    }
    6763
     64    $self->post_image_done_event($image);
    6865}
    6966
     
    8178    my ( $self, $image ) = @_;
    8279
    83     $self->log_image_progress($image, "sending files", 0);
     80    ( $image->{status}, $image->{progress} ) = ($self->localized_msg->{"sending files"}, 0);
     81    $self->post_image_progress_event($image);
     82
    8483    $self->add_image_files($image);
    8584    $self->add_image($image);
    86     $self->log_image_progress($image, "transfered", 100);
    87 
    88 }
    89 
    90 
    91 sub log_image_progress {
    92     my ( $self, $image, $status, $value ) = @_;
    93 
    94     $image->{status}   = $status;
    95     $image->{progress} = $value;
     85
    9686    $self->post_image_progress_event($image);
    9787}
     
    110100
    111101
    112     $self->log_image_progress($image, "check files", 0);
     102    ( $image->{status}, $image->{progress} ) = ($self->localized_msg->{"checking files"}, 0);
     103    $self->post_image_progress_event($image);
     104
    113105    my @file_types = ('site_resized_file', 'site_thumb_file');
    114106    push @file_types, 'site_high_file' if $image->{upload_high};
     
    118110    }@file_types;
    119111
    120     $self->log_image_progress($image, "files checked", 100);
     112    ( $image->{status}, $image->{progress} ) = ($self->localized_msg->{"files checked"}, 100);
     113    $self->post_image_progress_event($image);
    121114}
    122115
     
    157150    my ( $self, $image ) = @_;
    158151
    159     $self->pwg->add_image($image);
     152    my ( $is_success, $status_line ) = $self->pwg->add_image($image);
     153   
     154    $image->{transfer_successful} = $is_success;
     155    $image->{status} = $is_success ? $self->localized_msg->{"transfered"} : $status_line ;
    160156}
    161157
     
    164160    my ( $self, $image ) = @_;
    165161
    166     $self->log_image_progress($image, "updating", 0);
     162   
     163    ( $image->{status}, $image->{progress} ) = ($self->localized_msg->{"updating"}, 0);
     164    $self->post_image_progress_event($image);
    167165
    168166    $self->update_image_files($image);
     167    $self->post_image_progress_event($image);
     168
    169169    $self->update_image_properties($image);
    170 
    171     $self->log_image_progress($image, "updated", 100);
     170    $self->post_image_progress_event($image);
    172171}
    173172
     
    177176
    178177    if($image->{preferences}{reupload_action_files}){
    179         $self->log_image_progress($image, "updating files", 0);
     178        ( $image->{status}, $image->{progress} ) = ($self->localized_msg->{"updating files"}, 0);
     179        $self->post_image_progress_event($image);
     180
    180181        $self->init_image_files_checksums($image);
    181182        $self->update_image_modified_files($image);
    182         $self->log_image_progress($image, "files updated", 100);
    183183    }
    184184}
     
    188188    my ( $self, $image ) = @_;
    189189
    190     $self->pwg->update_image_modified_files($image);
     190    my ( $is_success, $status_line ) = $self->pwg->update_image_modified_files($image);
     191    $image->{transfer_successful} = $is_success;
     192    $image->{status} = $is_success ? $self->localized_msg->{"files updated"} : $status_line ;
    191193}
    192194
     
    195197    my ( $self, $image ) = @_;
    196198
    197     $self->log_image_progress($image, "updating properties", 0);
    198     $self->pwg->update_image_properties($image);
    199     $self->log_image_progress($image, "properties updated", 100);
     199    ( $image->{status}, $image->{progress} ) = ($self->localized_msg->{"updating properties"}, 0);
     200    $self->post_image_progress_event($image);
     201
     202    my ( $is_success, $status_line ) = $self->pwg->update_image_properties($image);
     203
     204    $image->{transfer_successful} = $is_success;
     205    $image->{status} = $is_success ? $self->localized_msg->{"properties updated"} : $status_line ;
     206}
     207
     208
     209sub post_image_done_event {
     210    my ( $self, $image ) = @_;
     211
     212    $image->{progress} = 100;
     213
     214    $self->post_image_event(
     215        $self->done_event,
     216        $image
     217    );
    200218}
    201219
     
    219237        shared_clone($image)
    220238    );
    221     Wx::PostEvent($self->event_handler, $thread_event);
     239
     240    eval {
     241        Wx::PostEvent($self->event_handler, $thread_event);
     242    }
    222243}
    223244
Note: See TracChangeset for help on using the changeset viewer.