Changeset 4279
- Timestamp:
- Nov 16, 2009, 12:28:47 PM (14 years ago)
- Location:
- extensions/pLoader/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/locale/fr_FR/pLoader.po
r4126 r4279 254 254 msgstr "Durée" 255 255 256 msgid "seconds" 257 msgstr "secondes" 258 256 259 msgid "Categories" 257 260 msgstr "Catégories" … … 470 473 msgstr "Non sélectionnés" 471 474 475 msgid "Uploading" 476 msgstr "Transfère" 477 478 msgid "Uploading resized" 479 msgstr "Transfère la photo réduite" 480 481 msgid "Uploading thumbnail" 482 msgstr "Transfère la miniature" 483 484 msgid "Uploading high definition" 485 msgstr "Transfère la photo HD" 486 487 msgid "Checksum for" 488 msgstr "Checksum de" 489 490 msgid "Communication error with" 491 msgstr "Erreur de communication avec" 492 493 msgid "Uploaded" 494 msgstr "Transféré" 495 496 msgid "Preparing resized image for" 497 msgstr "Prépare la photo réduite de" 498 499 msgid "Close" 500 msgstr "Fermer" 501 502 msgid "on" 503 msgstr "sur" 504 505 msgid "photos added to the selection" 506 msgstr "photos ajoutées à la sélection" 507 508 msgid "errors" 509 msgstr "erreurs" -
extensions/pLoader/trunk/res/progress_wdr.pl
r2597 r4279 1 #-----------------------------------------------------------------------------2 # Perl source generated by wxDesigner from file: progress.wdr3 # Do not modify this file, all changes will be lost!4 #-----------------------------------------------------------------------------5 6 1 use Wx; 7 2 use strict; … … 23 18 use vars qw($ID_LINE); $ID_LINE = 10003; 24 19 use vars qw($ID_PROGRESS_OK); $ID_PROGRESS_OK = 10004; 20 use vars qw($ID_PROGRESS_TXT2); $ID_PROGRESS_TXT2 = 10005; 25 21 26 22 sub ProcessingProgress { … … 29 25 my( $item1 ) = Wx::BoxSizer->new( wxVERTICAL ); 30 26 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 ); 32 28 $item1->AddWindow( $item2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); 33 29 … … 38 34 39 35 $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 ); 40 39 41 40 my( $item4 ) = Wx::Gauge->new( $_[0], $main::ID_PROGRESS_GAUGE, 100, wxDefaultPosition, [400,12], 0 ); … … 67 66 } 68 67 69 # Menu bar functions70 71 72 # Toolbar functions73 74 75 # End of generated file -
extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm
r4152 r4279 214 214 ); 215 215 216 $self->imagelist->progress_msg_details_refresh( 217 sub { $self->UploadProgressMessageDetailsRefresh(@_) } 218 ); 216 219 217 220 $self->imagelist->progressbar_refresh( … … 1401 1404 title => gettext("Image processing progress information"), 1402 1405 bt_label => gettext("Cancel image processing"), 1406 bt_close_label => gettext("Close"), 1403 1407 } 1404 1408 ) … … 1706 1710 my ( $self, $msg ) = @_; 1707 1711 1712 Wx::Yield(); 1713 1708 1714 $self->upload_progressdlg->processing( 1709 1715 $msg 1710 1716 ); 1717 $self->upload_progressdlg->LogProgress(); 1711 1718 1712 1719 Wx::Yield(); 1713 1720 } 1721 1722 sub 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 1714 1735 1715 1736 sub UploadProgressThumbnailRefresh { … … 1731 1752 1732 1753 sub UploadProgressBarRefresh { 1733 my ( $self, $ratio ) = @_; 1734 1735 $ratio = $self->imagelist->count > 1 ? 1 : $ratio; 1754 my ( $self, $value ) = @_; 1755 1736 1756 eval { 1737 1757 $self->upload_progressdlg->progress( 1738 $ ratio*$self->imagelist->count * ( 100/scalar @{$self->imagelist->image_selection} )1758 $value 1739 1759 ); 1740 1760 $self->upload_progressdlg->LogProgress(); 1741 1761 }; 1742 croak gettext("Upload cancelled") if $@;1762 #croak gettext("Upload cancelled") if $@; 1743 1763 1744 1764 Wx::Yield(); … … 1818 1838 { 1819 1839 title => gettext("Image upload progress information"), 1820 bt_label => gettext("Cancel upload"), 1840 bt_label => gettext("Cancel upload"), 1841 bt_close_label => gettext("Close"), 1821 1842 } 1822 1843 ) … … 1913 1934 wxTheApp->StoreLayoutProperties; 1914 1935 1936 $self->manager->UnInit; 1915 1937 $self->Destroy; 1916 1938 } … … 2024 2046 my( $self ) = @_; 2025 2047 2026 $self->manager->UnInit;2027 2048 } 2028 2049 -
extensions/pLoader/trunk/src/Uploader/GUI/wxImageProcessingProgressDlg.pm
r2728 r4279 40 40 processing 41 41 txtprocessing 42 processing_details 43 txtprocessing_details 42 44 image 43 45 cancelled 46 bt_close_label 44 47 / 45 48 ); … … 62 65 $self->gauge( $self->FindWindow($main::ID_PROGRESS_GAUGE) ); 63 66 $self->txtprocessing( $self->FindWindow($main::ID_PROGRESS_TXT) ); 67 $self->txtprocessing_details( $self->FindWindow($main::ID_PROGRESS_TXT2) ); 64 68 $self->image( $self->FindWindow($main::ID_STATICBITMAP) ); 65 69 $self->gauge->SetForegroundColour(wxGREEN); … … 68 72 $self->btok->SetLabel( 69 73 $params->{bt_label}||'Cancel' 74 ); 75 $self->bt_close_label( 76 $params->{bt_close_label}||'Close' 70 77 ); 71 78 … … 94 101 $self->processing 95 102 ); 103 $self->txtprocessing_details->SetLabel( 104 $self->processing_details 105 ); 96 106 $self->gauge->SetValue( 97 $self->progress 107 $self->progress 98 108 ); 99 109 } … … 107 117 $self->image->Show(0); 108 118 $self->gauge->Show(0); 109 119 # for i18n 110 120 $self->btok->SetLabel( 111 'Close'121 $self->bt_close_label 112 122 ); 113 123 124 $self->txtprocessing_details->SetLabel(""); 114 125 } 115 126 -
extensions/pLoader/trunk/src/Uploader/ImageList.pm
r4152 r4279 72 72 UploadImagesViewerCallback 73 73 progress_thumbnail_refresh 74 progress_msg_details_refresh 74 75 progress_msg_refresh 75 76 progressbar_refresh … … 102 103 gravity 103 104 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 104 116 / 105 117 ); … … 263 275 $self->SetNewFilesDisplayEndInfoCallback->( 264 276 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"), 266 279 $self->count, 267 $errors 280 gettext("errors"), 281 $errors, 268 282 269 283 ) … … 867 881 my $viewer_callback = $self->UploadImagesViewerCallback ; 868 882 869 883 $self->image_selection([]) if !defined $self->image_selection; 870 884 $self->upload_rejects( 871 885 [] 872 886 ); 873 887 874 my $count = 1;875 my $msg;876 888 $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}) { 884 897 # current image object 885 898 $self->current_image( 886 899 $self->GetImage($_) 887 900 ); 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); 1060 908 $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 } 1073 912 1074 913 if($self->remove_uploaded_from_selection){ … … 1076 915 $viewer_callback->(); 1077 916 } 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 921 sub _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 960 sub _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 977 sub _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 995 sub _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 1039 sub _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 1058 sub _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 1083 sub _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 1114 sub _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 1140 sub _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; 1089 1159 } 1090 1160 … … 1206 1276 $file_out 1207 1277 ); 1208 printf("gravity %s, color %s, pointsize %s, x %s, y %s\n", $gravity, $fill, $text_size, $x, $y); 1278 1209 1279 my $ratio = $image->Get('height')/($self->resize_h||$image->Get('height')); 1210 1280 $ratio||=1; 1211 1281 $text ||="Your watermark"; 1212 1282 $image->Annotate( 1213 # font => 'Vera.ttf',1214 1283 pointsize => $text_size*$ratio, 1215 1284 fill => $fill, -
extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm
r4268 r4279 28 28 use Digest::MD5::File qw/file_md5_hex md5_hex/; 29 29 use File::Slurp; 30 use File::Spec; 30 31 use POSIX qw(ceil floor); 31 32 use base qw/ … … 236 237 237 238 sub UploadImage { 238 my ( $self, $ yield_callback) = @_;239 my ( $self, $progress ) = @_; 239 240 240 241 my $file_sum; 241 242 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 ); 242 252 eval { 243 253 $file_sum = file_md5_hex( … … 245 255 ); 246 256 }; 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 ); 249 266 my $thumbnail_sum = file_md5_hex( 250 267 $self->site_thumb_file, 251 268 ); 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 253 279 my $original_sum = file_md5_hex( 254 280 $self->site_high_file … … 260 286 }; 261 287 288 $yield->(); 262 289 my $result = $self->uagent->post( 263 290 $self->urlbase.'/ws.php?format=json', 264 291 $form 265 292 ); 293 $yield->(); 266 294 267 295 my $hresult = {}; … … 285 313 type => 'file', 286 314 original_sum => $original_sum, 287 yield_callback => $yield_callback,288 315 }; 289 316 317 $progress->{current_msg} = $progress->{resized_msg}; 318 $yield->(); 290 319 $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 295 325 $status_line = $resized_params->{message}; 296 326 last if !$resized_params->{ok}; … … 300 330 type => 'thumb', 301 331 original_sum => $original_sum, 302 yield_callback => $yield_callback,303 332 }; 304 333 334 $progress->{current_msg} = $progress->{thumbnail_msg}; 335 $yield->(); 305 336 $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->(); 310 341 $status_line = $thumb_params->{message}; 311 342 last if !$thumb_params->{ok}; … … 330 361 type => 'high', 331 362 original_sum => $original_sum, 332 yield_callback => $yield_callback,333 363 }; 334 364 335 365 if($self->upload_high){ 336 366 $form->{high_sum} = $original_sum; 337 367 $progress->{current_msg} = $progress->{highdef_msg}; 368 $yield->(); 338 369 $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->(); 343 374 $status_line = $high_params->{message}; 344 375 last if !$high_params->{ok}; 345 346 376 } 347 377 } … … 358 388 tag_ids => $self->site_tags, 359 389 }; 360 $yield _callback->() if 'CODE' eq ref($yield_callback);390 $yield->(); 361 391 } 362 392 … … 364 394 delete $form->{tag_ids} if '' eq $self->site_tags; 365 395 396 $yield->(); 366 397 $result = $self->uagent->post( 367 398 $self->urlbase.'/ws.php?format=json', 368 399 $form 369 400 ); 370 371 401 eval { 372 402 $content = from_json( … … 441 471 442 472 sub 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->(); 445 491 my $content = read_file( 446 492 $params->{filepath}, 447 493 binmode => ':raw', 448 494 ); 495 $yield->(); 449 496 450 497 my $content_length = length($content); … … 453 500 my $chunk_pos = 0; 454 501 my $chunk_id = 1; 502 503 455 504 while ($chunk_pos < $content_length) { 505 456 506 my $chunk = substr( 457 507 $content, … … 460 510 ); 461 511 $chunk_pos += $self->chunk_size; 462 463 512 my $response = $self->uagent->post( 464 513 $self->urlbase.'/ws.php?format=json', … … 471 520 } 472 521 ); 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 ); 474 531 $params->{ok} = 1; 475 532 if ($response->code != 200) { -
extensions/pLoader/trunk/src/ploader.pl
r4095 r4279 26 26 use Wx::Locale qw/:default/; 27 27 28 #$SIG{__DIE__} = \&OnDieHandler; 28 29 29 30 … … 35 36 $app->MainLoop(); 36 37 }; 38 39 sub OnDieHandler { 40 my ( $exception ) = @_; 41 42 # if triggered in eval 43 # return if $^S; 44 print $exception; 45 } 37 46 1; 38 47
Note: See TracChangeset
for help on using the changeset viewer.