public void Upload () { // FIXME use mkstemp Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok; try { Dialog.Hide (); Gnome.Vfs.Uri source = new Gnome.Vfs.Uri (Path.Combine (gallery_path, gallery_name)); Gnome.Vfs.Uri target = dest.Clone(); target = target.AppendFileName(source.ExtractShortName ()); if (dest.IsLocal) gallery_path = Gnome.Vfs.Uri.GetLocalPathFromUri (dest.ToString ()); progress_dialog.Message = Catalog.GetString ("Building Gallery"); progress_dialog.Fraction = 0.0; FolderGallery gallery; if (static_radio.Active) { gallery = new HtmlGallery (selection, gallery_path, gallery_name); } else if (original_radio.Active) { gallery = new OriginalGallery (selection, gallery_path, gallery_name); } else { gallery = new FolderGallery (selection, gallery_path, gallery_name); } if (scale) { System.Console.WriteLine ("setting scale to {0}", size); gallery.SetScale (size); } else { System.Console.WriteLine ("Exporting full size image"); } if (rotate) { System.Console.WriteLine ("Exporting rotated image"); gallery.SetRotate(); } gallery.Description = description; gallery.GenerateLayout (); Filters.FilterSet filter_set = new Filters.FilterSet (); if (scale) filter_set.Add (new Filters.ResizeFilter ((uint) size)); else if (rotate) filter_set.Add (new Filters.OrientationFilter ()); filter_set.Add (new Filters.ChmodFilter ()); filter_set.Add (new Filters.UniqueNameFilter (gallery_path)); for (int photo_index = 0; photo_index < selection.Count; photo_index++) { try { progress_dialog.Message = System.String.Format (Catalog.GetString ("Uploading picture \"{0}\""), selection[photo_index].Name); progress_dialog.Fraction = photo_index / (double) selection.Count; gallery.ProcessImage (photo_index, filter_set); progress_dialog.ProgressText = System.String.Format (Catalog.GetString ("{0} of {1}"), photo_index, selection.Count); } catch (Exception e) { progress_dialog.Message = String.Format (Catalog.GetString ("Error uploading picture \"{0}\" to Gallery:{2}{1}"), selection[photo_index].Name, e.Message, Environment.NewLine); progress_dialog.ProgressText = Catalog.GetString ("Error"); if (progress_dialog.PerformRetrySkip ()) photo_index--; } } //create the zip tarballs for original if (gallery is OriginalGallery && (bool)Preferences.Get(Preferences.EXPORT_FOLDER_INCLUDE_TARBALLS)) (gallery as OriginalGallery).CreateZip (); // we've created the structure, now if the destination was local we are done // otherwise we xfer if (!dest.IsLocal) { Console.WriteLine(target); System.Console.WriteLine ("Xfering {0} to {1}", source.ToString (), target.ToString ()); result = Gnome.Vfs.Xfer.XferUri (source, target, Gnome.Vfs.XferOptions.Default, Gnome.Vfs.XferErrorMode.Abort, Gnome.Vfs.XferOverwriteMode.Replace, Progress); } if (result == Gnome.Vfs.Result.Ok) { progress_dialog.Message = Catalog.GetString ("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString ("Transfer Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; } else { progress_dialog.ProgressText = result.ToString (); progress_dialog.Message = Catalog.GetString ("Error While Transferring"); } if (open) { GnomeUtil.UrlShow (null, target.ToString ()); } // Save these settings for next time Preferences.Set (Preferences.EXPORT_FOLDER_SCALE, scale); Preferences.Set (Preferences.EXPORT_FOLDER_SIZE, size); Preferences.Set (Preferences.EXPORT_FOLDER_OPEN, open); Preferences.Set (Preferences.EXPORT_FOLDER_ROTATE, rotate); Preferences.Set (Preferences.EXPORT_FOLDER_METHOD, static_radio.Active ? "static" : original_radio.Active ? "original" : "folder" ); Preferences.Set (Preferences.EXPORT_FOLDER_URI, uri_chooser.Uri); } catch (System.Exception e) { // Console.WriteLine (e); progress_dialog.Message = e.ToString (); progress_dialog.ProgressText = Catalog.GetString ("Error Transferring"); } finally { // if the destination isn't local then we want to remove the temp directory we // created. if (!dest.IsLocal) System.IO.Directory.Delete (gallery_path, true); Gtk.Application.Invoke (delegate { Dialog.Destroy(); }); } }
public void Upload() { // FIXME use mkstemp Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok; try { Dialog.Hide(); Gnome.Vfs.Uri source = new Gnome.Vfs.Uri(Path.Combine(gallery_path, gallery_name)); Gnome.Vfs.Uri target = dest.Clone(); target = target.AppendFileName(source.ExtractShortName()); if (dest.IsLocal) { gallery_path = Gnome.Vfs.Uri.GetLocalPathFromUri(dest.ToString()); } progress_dialog.Message = Catalog.GetString("Building Gallery"); progress_dialog.Fraction = 0.0; FolderGallery gallery; if (static_radio.Active) { gallery = new HtmlGallery(selection, gallery_path, gallery_name); } else if (original_radio.Active) { gallery = new OriginalGallery(selection, gallery_path, gallery_name); } else { gallery = new FolderGallery(selection, gallery_path, gallery_name); } if (scale) { System.Console.WriteLine("setting scale to {0}", size); gallery.SetScale(size); } else { System.Console.WriteLine("Exporting full size image"); } if (rotate) { System.Console.WriteLine("Exporting rotated image"); gallery.SetRotate(); } gallery.Description = description; gallery.GenerateLayout(); Filters.FilterSet filter_set = new Filters.FilterSet(); if (scale) { filter_set.Add(new Filters.ResizeFilter((uint)size)); } else if (rotate) { filter_set.Add(new Filters.OrientationFilter()); } filter_set.Add(new Filters.ChmodFilter()); filter_set.Add(new Filters.UniqueNameFilter(gallery_path)); for (int photo_index = 0; photo_index < selection.Count; photo_index++) { try { progress_dialog.Message = System.String.Format(Catalog.GetString("Uploading picture \"{0}\""), selection[photo_index].Name); progress_dialog.Fraction = photo_index / (double)selection.Count; gallery.ProcessImage(photo_index, filter_set); progress_dialog.ProgressText = System.String.Format(Catalog.GetString("{0} of {1}"), photo_index, selection.Count); } catch (Exception e) { progress_dialog.Message = String.Format(Catalog.GetString("Error uploading picture \"{0}\" to Gallery:{2}{1}"), selection[photo_index].Name, e.Message, Environment.NewLine); progress_dialog.ProgressText = Catalog.GetString("Error"); if (progress_dialog.PerformRetrySkip()) { photo_index--; } } } //create the zip tarballs for original if (gallery is OriginalGallery && (bool)Preferences.Get(Preferences.EXPORT_FOLDER_INCLUDE_TARBALLS)) { (gallery as OriginalGallery).CreateZip(); } // we've created the structure, now if the destination was local we are done // otherwise we xfer if (!dest.IsLocal) { Console.WriteLine(target); System.Console.WriteLine("Xfering {0} to {1}", source.ToString(), target.ToString()); result = Gnome.Vfs.Xfer.XferUri(source, target, Gnome.Vfs.XferOptions.Default, Gnome.Vfs.XferErrorMode.Abort, Gnome.Vfs.XferOverwriteMode.Replace, Progress); } if (result == Gnome.Vfs.Result.Ok) { progress_dialog.Message = Catalog.GetString("Done Sending Photos"); progress_dialog.Fraction = 1.0; progress_dialog.ProgressText = Catalog.GetString("Transfer Complete"); progress_dialog.ButtonLabel = Gtk.Stock.Ok; } else { progress_dialog.ProgressText = result.ToString(); progress_dialog.Message = Catalog.GetString("Error While Transferring"); } if (open) { GnomeUtil.UrlShow(null, target.ToString()); } // Save these settings for next time Preferences.Set(Preferences.EXPORT_FOLDER_SCALE, scale); Preferences.Set(Preferences.EXPORT_FOLDER_SIZE, size); Preferences.Set(Preferences.EXPORT_FOLDER_OPEN, open); Preferences.Set(Preferences.EXPORT_FOLDER_ROTATE, rotate); Preferences.Set(Preferences.EXPORT_FOLDER_METHOD, static_radio.Active ? "static" : original_radio.Active ? "original" : "folder"); Preferences.Set(Preferences.EXPORT_FOLDER_URI, uri_chooser.Uri); } catch (System.Exception e) { // Console.WriteLine (e); progress_dialog.Message = e.ToString(); progress_dialog.ProgressText = Catalog.GetString("Error Transferring"); } finally { // if the destination isn't local then we want to remove the temp directory we // created. if (!dest.IsLocal) { System.IO.Directory.Delete(gallery_path, true); } Gtk.Application.Invoke(delegate { Dialog.Destroy(); }); } }