Index: extensions/pLoader/trunk/locale/fr_FR/pLoader.po
===================================================================
--- extensions/pLoader/trunk/locale/fr_FR/pLoader.po	(revision 4475)
+++ extensions/pLoader/trunk/locale/fr_FR/pLoader.po	(revision 4476)
@@ -577,2 +577,23 @@
 msgid "Photo update management"
 msgstr "Gestion de la mise à jour des photos"
+
+msgid "Who can see the photo? :"
+msgstr "Qui peut voir la photo ? :"
+
+msgid "everybody"
+msgstr "tout le monde"
+
+msgid "contacts"
+msgstr "contacts"
+
+msgid "friends"
+msgstr "amis"
+
+msgid "family"
+msgstr "famille"
+
+msgid "admins"
+msgstr "administrateurs"
+
+msgid "What shall we do with privacy level?"
+msgstr "Que faire pour le niveau de confidentialité ?"
Index: extensions/pLoader/trunk/res/photo_properties_wdr.pl
===================================================================
--- extensions/pLoader/trunk/res/photo_properties_wdr.pl	(revision 4475)
+++ extensions/pLoader/trunk/res/photo_properties_wdr.pl	(revision 4476)
@@ -27,84 +27,76 @@
 use vars qw($CAPTION); $CAPTION = 10000;
 use vars qw($PHOTO_PROPERTIES_CAPTION); $PHOTO_PROPERTIES_CAPTION = 10001;
-use vars qw($COMMENT); $COMMENT = 10002;
-use vars qw($PHOTO_PROPERTIES_COMMENT); $PHOTO_PROPERTIES_COMMENT = 10003;
-use vars qw($AUTHOR); $AUTHOR = 10004;
-use vars qw($PHOTO_PROPERTIES_AUTHOR); $PHOTO_PROPERTIES_AUTHOR = 10005;
+use vars qw($AUTHOR); $AUTHOR = 10002;
+use vars qw($PHOTO_PROPERTIES_AUTHOR); $PHOTO_PROPERTIES_AUTHOR = 10003;
+use vars qw($COMMENT); $COMMENT = 10004;
+use vars qw($PHOTO_PROPERTIES_COMMENT); $PHOTO_PROPERTIES_COMMENT = 10005;
 use vars qw($CREATE_DATE); $CREATE_DATE = 10006;
 use vars qw($PHOTO_PROPERTIES_CREATE_DATE); $PHOTO_PROPERTIES_CREATE_DATE = 10007;
 use vars qw($TAGS); $TAGS = 10008;
 use vars qw($PHOTO_PROPERTIES_TAG); $PHOTO_PROPERTIES_TAG = 10009;
+use vars qw($PRIVACY_LEVEL); $PRIVACY_LEVEL = 10010;
+use vars qw($PHOTO_PROPERTIES_PRIVACY_LEVEL); $PHOTO_PROPERTIES_PRIVACY_LEVEL = 10011;
 
 sub PhotoProperties {
     my( $parent ) = $_[0];
-    my( $item0 ) = Wx::BoxSizer->new( wxHORIZONTAL );
+    my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
     
-    my( $item1 ) = Wx::BoxSizer->new( wxVERTICAL );
+    my( $item1 ) = Wx::BoxSizer->new( wxHORIZONTAL );
     
     my( $item2 ) = Wx::BoxSizer->new( wxVERTICAL );
     
-    my( $item3 ) = Wx::BoxSizer->new( wxVERTICAL );
-    
-    my( $item4 ) = Wx::StaticText->new( $parent, $main::CAPTION, "text", wxDefaultPosition, wxDefaultSize, 0 );
-    $item3->AddWindow( $item4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
+    my( $item3 ) = Wx::StaticText->new( $parent, $main::CAPTION, "text", wxDefaultPosition, wxDefaultSize, 0 );
+    $item2->AddWindow( $item3, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
 
-    my( $item5 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_CAPTION, "", wxDefaultPosition, [200,-1], 0 );
-    $item3->AddWindow( $item5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5 );
+    my( $item4 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_CAPTION, "", wxDefaultPosition, [200,-1], 0 );
+    $item2->AddWindow( $item4, 0, wxALIGN_CENTER_VERTICAL, 5 );
 
-    $item2->Add( $item3, 0, wxALIGN_CENTER|wxALL, 5 );
+    my( $item5 ) = Wx::StaticText->new( $parent, $main::AUTHOR, "text", wxDefaultPosition, wxDefaultSize, 0 );
+    $item2->AddWindow( $item5, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
 
-    my( $item6 ) = Wx::BoxSizer->new( wxVERTICAL );
-    
+    my( $item6 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_AUTHOR, "", wxDefaultPosition, [200,-1], 0 );
+    $item2->AddWindow( $item6, 0, wxALIGN_CENTER, 5 );
+
     my( $item7 ) = Wx::StaticText->new( $parent, $main::COMMENT, "text", wxDefaultPosition, wxDefaultSize, 0 );
-    $item6->AddWindow( $item7, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
+    $item2->AddWindow( $item7, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
 
     my( $item8 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_COMMENT, "", wxDefaultPosition, [200,100], wxTE_MULTILINE );
-    $item6->AddWindow( $item8, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5 );
+    $item2->AddWindow( $item8, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
 
-    $item2->Add( $item6, 0, wxALIGN_CENTER_VERTICAL, 5 );
+    my( $item9 ) = Wx::StaticText->new( $parent, $main::CREATE_DATE, "text", wxDefaultPosition, wxDefaultSize, 0 );
+    $item2->AddWindow( $item9, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
 
-    my( $item9 ) = Wx::BoxSizer->new( wxVERTICAL );
+    my( $item10 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_CREATE_DATE, "", wxDefaultPosition, [200,-1], 0 );
+    $item2->AddWindow( $item10, 0, wxALIGN_CENTER_VERTICAL, 5 );
+
+    $item1->Add( $item2, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
+
+    my( $item11 ) = Wx::BoxSizer->new( wxVERTICAL );
     
-    my( $item10 ) = Wx::StaticText->new( $parent, $main::AUTHOR, "text", wxDefaultPosition, wxDefaultSize, 0 );
-    $item9->AddWindow( $item10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
-
-    my( $item11 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_AUTHOR, "", wxDefaultPosition, [200,-1], 0 );
-    $item9->AddWindow( $item11, 0, wxALIGN_CENTER|wxRIGHT|wxTOP, 5 );
-
-    $item2->Add( $item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
-
-    my( $item12 ) = Wx::BoxSizer->new( wxVERTICAL );
-    
-    my( $item13 ) = Wx::StaticText->new( $parent, $main::CREATE_DATE, "text", wxDefaultPosition, wxDefaultSize, 0 );
-    $item12->AddWindow( $item13, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
-
-    my( $item14 ) = Wx::TextCtrl->new( $parent, $main::PHOTO_PROPERTIES_CREATE_DATE, "", wxDefaultPosition, [200,-1], 0 );
-    $item12->AddWindow( $item14, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5 );
-
-    $item2->Add( $item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
-
-    $item1->Add( $item2, 0, wxALIGN_CENTER|wxALL, 5 );
-
-    my( $item15 ) = Wx::BoxSizer->new( wxVERTICAL );
-    
-    $item1->Add( $item15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
-
-    my( $item16 ) = Wx::BoxSizer->new( wxVERTICAL );
-    
-    $item1->Add( $item16, 0, wxALIGN_CENTER|wxALL, 5 );
-
-    $item0->Add( $item1, 0, wxALL, 5 );
-
-    my( $item17 ) = Wx::BoxSizer->new( wxVERTICAL );
-    
-    my( $item18 ) = Wx::StaticText->new( $parent, $main::TAGS, "text", wxDefaultPosition, wxDefaultSize, 0 );
-    $item17->AddWindow( $item18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+    my( $item12 ) = Wx::StaticText->new( $parent, $main::TAGS, "text", wxDefaultPosition, wxDefaultSize, 0 );
+    $item11->AddWindow( $item12, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
 
     my $tags = $_[1];
 $tags->{parentwnd}=$parent;
-my( $item19 ) = Uploader::GUI::wxChoiceFilteredPanel->new($tags);
-    $item17->AddWindow( $item19, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+my( $item13 ) = Uploader::GUI::wxChoiceFilteredPanel->new($tags);
+    $item11->AddWindow( $item13, 0, wxALIGN_CENTER_VERTICAL, 5 );
 
-    $item0->Add( $item17, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
+    $item1->Add( $item11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0 );
+
+    $item0->Add( $item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+    my( $item14 ) = Wx::BoxSizer->new( wxHORIZONTAL );
+    
+    my( $item15 ) = Wx::BoxSizer->new( wxVERTICAL );
+    
+    my( $item16 ) = Wx::StaticText->new( $parent, $main::PRIVACY_LEVEL, "text", wxDefaultPosition, wxDefaultSize, 0 );
+    $item15->AddWindow( $item16, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
+
+    my( $item17 ) = Wx::Choice->new( $parent, $main::PHOTO_PROPERTIES_PRIVACY_LEVEL, wxDefaultPosition, [520,-1], [], 0 );
+    $item15->AddWindow( $item17, 0, wxALIGN_CENTER_VERTICAL, 5 );
+
+    $item14->Add( $item15, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
+
+    $item0->Add( $item14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
 
     my( $set_size ) = @_ >= 3 ? $_[2] : 1;
Index: extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm	(revision 4475)
+++ extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm	(revision 4476)
@@ -18,4 +18,5 @@
 	my $ctrl_handlers = {
 	    'Wx::TextCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnTextCtrl(@_) } ); },
+	    'Wx::Choice' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_CHOICE( $ctrl, $ctrl, sub { $self->OnChoice(@_) } ); },
 	};
 	
@@ -35,5 +36,4 @@
     my ( $self, $ctrl, $event ) = @_;
 	
-	printf("OnTextCtrl %s, %s\n", $ctrl->GetId, $event->GetString);
     my $id = $ctrl->GetId;
     # change the property value
@@ -47,4 +47,20 @@
 	
 }
+
+sub OnChoice {
+    my ( $self, $ctrl, $event ) = @_;
+	
+    my $id = $ctrl->GetId;
+    # change the property value
+	$self->properties->{$id}->{selection}->(
+        $event->GetSelection
+    ) if exists $self->properties->{$id}->{selection};
+
+    # exec the callback
+    $self->properties->{$id}->{frame_callback}->() if exists
+        $self->properties->{$id}->{frame_callback};	
+	
+}
+
 
 my $change_value = {
@@ -98,4 +114,23 @@
 }
 
+sub InitChoices {
+    my ( $self ) = @_;
+
+		map {
+        my $ctrl =$self->FindWindow($_);
+        #printf("ctrl %s : %s\n", $_, $ctrl);		
+        if(defined $ctrl){
+            # choice
+            my $choices =$self->properties->{$_}->{choices};
+		    $choices||=[];
+		    map{
+		        $ctrl->Append($_);
+		    }@$choices;
+		}
+    }
+	keys %{$self->properties};
+
+}
+
 sub GetProperties {
     my ( $self ) = @_;
@@ -115,4 +150,6 @@
 		) if exists $self->properties->{$_}->{selection};
 		
+		printf("selection %s\n", $ctrl->GetSelection())if exists $self->properties->{$_}->{selection};
+		
 		}
     }
Index: extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm	(revision 4475)
+++ extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm	(revision 4476)
@@ -111,4 +111,5 @@
 		  upload_hd
 		  eng_upload_hd
+		  privacy_level
       / 
 );
@@ -303,4 +304,38 @@
         }
     );
+	
+	# hard coded because the piwigo api to read custom privacy level is not yet available
+	$self->privacy_level(
+	    [
+		    'everybody',
+			'contacts',
+			'friends',
+			'family',
+			'admins'
+		]
+	);
+
+	
+}
+
+# display privacy level list in a pyramid way :
+# ['everybody', 'contacts', friends, family, admins] -> [everybody, 'contacts, friends, family, admins', 'friends, family, admins', 'family, admins', 'admins only' ]
+sub privacy_level_choices{
+    my ( $self ) = @_;
+
+    my $pl = $self->privacy_level;	
+    my $n = scalar @$pl - 1;
+    my $list = [ gettext($pl->[0]) ];
+    my $i=0;
+    while(++$i<$n){    
+        push @$list, join(
+		    ', ', 
+			map{ gettext($_) }
+			@$pl[$i..$n] 
+		);
+    }
+    push @$list, gettext($pl->[$n]);
+	
+	$list;
 }
 
@@ -429,5 +464,5 @@
             Wx::LogMessage(
                 gettext("An error has occured. Can not read %s\n%s"),
-                $self->storable_file,
+                $self->storable_file, 
                 $@
             );
Index: extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm	(revision 4475)
+++ extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm	(revision 4476)
@@ -348,5 +348,9 @@
 			                                       value => sub { $self->imagelist->current_image->create_date(@_) },
 			                                   },
-		    $main::PRIVACY_LEVEL => { label=>gettext("Privacy level :")},
+		    $main::PRIVACY_LEVEL => { label=>gettext("Who can see the photo? :")},
+			$main::PHOTO_PROPERTIES_PRIVACY_LEVEL => {
+                                                         selection => sub { $self->imagelist->current_image->privacy_level(@_)},
+                                                         choices => wxTheApp->privacy_level_choices,														           ,														 
+			                                         },
 		}
     );	
Index: extensions/pLoader/trunk/src/Uploader/GUI/wxPhotoProperties.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/GUI/wxPhotoProperties.pm	(revision 4475)
+++ extensions/pLoader/trunk/src/Uploader/GUI/wxPhotoProperties.pm	(revision 4476)
@@ -55,4 +55,5 @@
         #$self->_init_values;		
         $self->InitLabels();
+		$self->InitChoices();
         $self->SetProperties();
 		$self->InitHandler();
Index: extensions/pLoader/trunk/src/Uploader/Image.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/Image.pm	(revision 4475)
+++ extensions/pLoader/trunk/src/Uploader/Image.pm	(revision 4476)
@@ -39,4 +39,5 @@
 		width
 		height
+		privacy_level
     /
 );
Index: extensions/pLoader/trunk/src/Uploader/ImageList.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 4475)
+++ extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 4476)
@@ -1263,4 +1263,5 @@
     my ( $self ) = @_;
 
+	
 	$self->pwg->reupload_action_files(
 	    $self->reupload_action_files||1
@@ -1306,4 +1307,8 @@
     );
 
+	$self->pwg->privacy_level(
+	    $self->current_image->privacy_level
+	);
+	
     $self->current_image->site_categories(
         $self->categories
Index: extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm	(revision 4475)
+++ extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm	(revision 4476)
@@ -69,4 +69,5 @@
 		   single_value_mode
 		   multiple_value_mode
+		   privacy_level
       / 
 );
@@ -170,5 +171,4 @@
         # when server response has warnings, the content response is not a valid json string
 		# find the json response
-		#printf("%s\n", $self->uagent_response->content);
         $self->uagent_response->content =~ /(\{.+\})/;
 		#printf("json response %s\n", $1);
@@ -181,5 +181,5 @@
     }
     else{
-	$hresult = {
+    	$hresult = {
             'message' => $self->uagent_response->message,
             'stat'    => 'fail',
@@ -306,9 +306,8 @@
 		   
            $progress->{yield}->();
-           ( $status, $status_line ) = $self->_execute_post($form); 
+           ( $status, $status_line ) = $self->_execute_post($form);
 		}
         # re-upload
         else{
-		    #printf("reupload, files %s, properties %s\n", $self->reupload_action_files, $self->reupload_action_properties);
             # need to check if files have changed
             # and update image info
@@ -327,10 +326,11 @@
             # update metadata info
             if($self->reupload_action_properties){  	
-			    #printf("reupload_action_properties %s\n", $self->reupload_action_properties);
-                $form->{name} = $self->site_image_name;
+    			#printf("reupload_action_properties %s\n", $self->reupload_action_properties);
+                $form->{name}          = $self->site_image_name;
                 $form->{author}        = $self->site_author;
                 $form->{comment}       = $self->site_comment;
                 $form->{date_creation} = $self->site_img_date_creation;
 				$form->{single_value_mode}  = $self->single_value_mode->{$self->reupload_action_properties};
+                $form->{level} = $self->privacy_level ? 2**($self->privacy_level - 1) : 0;
 		    }
             if($self->reupload_action_properties_m){  	
@@ -342,5 +342,6 @@
             $progress->{yield}->();
             ( $status, $status_line ) = $self->_execute_post($form); 
-	    }
+
+		}
 
         delete $form->{tag_ids} unless defined $self->site_tags;
@@ -348,9 +349,14 @@
 
         $progress->{yield}->();
-	    #print "form ", Dumper $form;
-		#print "status ", $status, "\n";
-		#print "status_line ", $status_line, "\n";
-	    # basic check, should perform a checkfile
-        $content->{stat} = !$self->_exists($progress->{original_sum}) ? 'fail' : 'ok'; 
+        # for first upload
+        if($doubleCheck){
+		    $self->image_id(
+			    $self->_exists($progress->{original_sum})
+			);
+            $content->{stat} = !defined $self->image_id  ? 'fail' : 'ok'; 
+            if(defined $self->image_id and defined $self->privacy_level){
+	    	    ( $status, $status_line, $content ) = $self->_set_privacy_level;
+	        }
+        }
 
 		last UPLOAD;
@@ -358,4 +364,19 @@
     
     return ( $status,  $status_line, $content);
+}
+
+sub _set_privacy_level {
+    my ( $self ) = @_;
+		
+    my $form = {
+        method        => 'pwg.images.setPrivacyLevel',
+        image_id      => $self->image_id,
+        level         => $self->privacy_level ? 2**($self->privacy_level - 1) : 0,
+    };
+	print Dumper $form;
+	my ( $status, $status_line ) = $self->_execute_post($form); 
+    my $hresult = $self->_json_response_content;
+
+    ($status, $status_line, $hresult );
 }
 
@@ -443,5 +464,5 @@
     $self->_execute_post($form);    
     my $hresult = $self->_json_response_content;
-print Dumper $hresult;
+
     my $rval = 'ok' eq $hresult->{stat} ? $hresult->{result} : undef;
     
