private void Download()
        {
            lock (camera) {
                System.Collections.ArrayList saved = new System.Collections.ArrayList();

                for (int i = 0; i < index_list.Count; i++)
                {
                    try {
                        string msg = String.Format(Catalog.GetString("Copying file {0} of {1}"),
                                                   (i + 1), index_list.Count);

                        progress_dialog.ProgressText = msg;

                        SaveResult result = SaveFile((int)(index_list [i]));

                        if (!result.IsDuplicate)
                        {
                            saved.Add(result.Path);
                        }

                        progress_dialog.Fraction = (i + 1) / (double)index_list.Count;
                    }
                    catch (System.Exception e) {
                        System.Console.WriteLine(e.ToString());
                        progress_dialog.Message      = String.Format("{0}{2}{1}", e.Message, e.ToString(), Environment.NewLine);
                        progress_dialog.ProgressText = Catalog.GetString("Error transferring file");

                        if (progress_dialog.PerformRetrySkip())
                        {
                            i--;
                        }
                    }
                }

                saved_files = (string [])saved.ToArray(typeof(string));

                progress_dialog.Message      = Catalog.GetString("Done Copying Files");
                progress_dialog.Fraction     = 1.0;
                progress_dialog.ProgressText = Catalog.GetString("Download Complete");
                progress_dialog.ButtonLabel  = Gtk.Stock.Ok;
            }
        }
示例#2
0
        private void Upload()
        {
            sent_bytes  = 0;
            approx_size = 0;

            System.Uri album_uri = null;

            System.Console.WriteLine("Starting Upload to Smugmug, album {0} - {1}", album.Title, album.AlbumID);

            FilterSet filters = new FilterSet();

            filters.Add(new JpegFilter());

            if (scale)
            {
                filters.Add(new ResizeFilter((uint)size));
            }

            if (rotate)
            {
                filters.Add(new OrientationFilter());
            }

            while (photo_index < items.Length)
            {
                try {
                    IBrowsableItem item = items[photo_index];

                    FileInfo file_info;
                    Console.WriteLine("uploading {0}", photo_index);

                    progress_dialog.Message = String.Format(Catalog.GetString("Uploading picture \"{0}\" ({1} of {2})"),
                                                            item.Name, photo_index + 1, items.Length);
                    progress_dialog.ProgressText = string.Empty;
                    progress_dialog.Fraction     = ((photo_index) / (double)items.Length);
                    photo_index++;

                    FilterRequest request = new FilterRequest(item.DefaultVersionUri);

                    filters.Convert(request);

                    file_info = new FileInfo(request.Current.LocalPath);

                    if (approx_size == 0)                     //first image
                    {
                        approx_size = file_info.Length * items.Length;
                    }
                    else
                    {
                        approx_size = sent_bytes * items.Length / (photo_index - 1);
                    }

                    int image_id = account.SmugMug.Upload(request.Current.LocalPath, album.AlbumID);
                    if (Core.Database != null)
                    {
                        Core.Database.Exports.Create((item as Photo).Id,
                                                     (item as Photo).DefaultVersionId,
                                                     ExportStore.SmugMugExportType,
                                                     account.SmugMug.GetAlbumUrl(image_id).ToString());
                    }

                    sent_bytes += file_info.Length;

                    if (album_uri == null)
                    {
                        album_uri = account.SmugMug.GetAlbumUrl(image_id);
                    }
                } catch (System.Exception e) {
                    progress_dialog.Message = String.Format(Mono.Unix.Catalog.GetString("Error Uploading To Gallery: {0}"),
                                                            e.Message);
                    progress_dialog.ProgressText = Mono.Unix.Catalog.GetString("Error");
                    System.Console.WriteLine(e);

                    if (progress_dialog.PerformRetrySkip())
                    {
                        photo_index--;
                    }
                }
            }

            progress_dialog.Message      = Catalog.GetString("Done Sending Photos");
            progress_dialog.Fraction     = 1.0;
            progress_dialog.ProgressText = Mono.Unix.Catalog.GetString("Upload Complete");
            progress_dialog.ButtonLabel  = Gtk.Stock.Ok;

            if (browser && album_uri != null)
            {
                GnomeUtil.UrlShow(null, album_uri.ToString());
            }
        }
示例#3
0
        private void Upload()
        {
            album.UploadProgress += HandleUploadProgress;
            sent_bytes            = 0;
            approx_size           = 0;

            System.Console.WriteLine("Starting Upload to Picasa");

            FilterSet filters = new FilterSet();

            filters.Add(new JpegFilter());

            if (scale)
            {
                filters.Add(new ResizeFilter((uint)size));
            }

            if (rotate)
            {
                filters.Add(new OrientationFilter());
            }

            while (photo_index < items.Length)
            {
                try {
                    IBrowsableItem item = items[photo_index];

                    FileInfo file_info;
                    Console.WriteLine("uploading {0}", photo_index);

                    progress_dialog.Message = String.Format(Catalog.GetString("Uploading picture \"{0}\" ({1} of {2})"),
                                                            item.Name, photo_index + 1, items.Length);
                    photo_index++;

                    FilterRequest request = new FilterRequest(item.DefaultVersionUri);

                    filters.Convert(request);

                    file_info = new FileInfo(request.Current.LocalPath);

                    if (approx_size == 0)                     //first image
                    {
                        approx_size = file_info.Length * items.Length;
                    }
                    else
                    {
                        approx_size = sent_bytes * items.Length / (photo_index - 1);
                    }

                    PicasaPicture picture = album.UploadPicture(request.Current.LocalPath, Path.ChangeExtension(item.Name, "jpg"), item.Description);
                    if (Core.Database != null && item is Photo)
                    {
                        Core.Database.Exports.Create((item as Photo).Id,
                                                     (item as Photo).DefaultVersionId,
                                                     ExportStore.PicasaExportType,
                                                     picture.Link);
                    }

                    sent_bytes += file_info.Length;

                    request.Dispose();
                    //tagging
                    if (item.Tags != null)
                    {
                        foreach (Tag tag in item.Tags)
                        {
                            picture.AddTag(tag.Name);
                        }
                    }
                } catch (System.Exception e) {
                    progress_dialog.Message = String.Format(Catalog.GetString("Error Uploading To Gallery: {0}"),
                                                            e.Message);
                    progress_dialog.ProgressText = Catalog.GetString("Error");
                    System.Console.WriteLine(e);

                    if (progress_dialog.PerformRetrySkip())
                    {
                        photo_index--;
                    }
                }
            }

            progress_dialog.Message      = Catalog.GetString("Done Sending Photos");
            progress_dialog.Fraction     = 1.0;
            progress_dialog.ProgressText = Catalog.GetString("Upload Complete");
            progress_dialog.ButtonLabel  = Gtk.Stock.Ok;

            if (browser)
            {
                GnomeUtil.UrlShow(null, album.Link);
            }
        }
        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(); });
            }
        }
示例#5
0
        private void Upload()
        {
            account.Gallery.Progress          = new ProgressItem();
            account.Gallery.Progress.Changed += HandleProgressChanged;

            System.Console.WriteLine("Starting upload");

            FilterSet filters = new FilterSet();

            if (account.Version == GalleryVersion.Version1)
            {
                filters.Add(new WhiteListFilter(new string [] { ".jpg", ".jpeg", ".png", ".gif" }));
            }
            if (scale)
            {
                filters.Add(new ResizeFilter((uint)size));
            }
            else if (rotate)
            {
                filters.Add(new OrientationFilter());
            }


            while (photo_index < items.Length)
            {
                IBrowsableItem item = items [photo_index];

                System.Console.WriteLine("uploading {0}", photo_index);

                progress_dialog.Message  = System.String.Format(Catalog.GetString("Uploading picture \"{0}\""), item.Name);
                progress_dialog.Fraction = photo_index / (double)items.Length;
                photo_index++;

                progress_dialog.ProgressText = System.String.Format(Catalog.GetString("{0} of {1}"), photo_index, items.Length);


                Filters.FilterRequest req = new Filters.FilterRequest(item.DefaultVersionUri);

                filters.Convert(req);
                try {
                    int id = album.Add(item, req.Current.LocalPath);

                    if (item != null && item is Photo && Core.Database != null && id != 0)
                    {
                        Core.Database.Exports.Create((item as Photo).Id, (item as Photo).DefaultVersionId,
                                                     ExportStore.Gallery2ExportType,
                                                     String.Format("{0}:{1}", album.Gallery.Uri.ToString(), id.ToString()));
                    }
                } catch (System.Exception e) {
                    progress_dialog.Message      = String.Format(Catalog.GetString("Error uploading picture \"{0}\" to Gallery: {1}"), item.Name, e.Message);
                    progress_dialog.ProgressText = Catalog.GetString("Error");

                    if (progress_dialog.PerformRetrySkip())
                    {
                        photo_index--;
                    }
                }
            }

            progress_dialog.Message      = Catalog.GetString("Done Sending Photos");
            progress_dialog.Fraction     = 1.0;
            progress_dialog.ProgressText = Catalog.GetString("Upload Complete");
            progress_dialog.ButtonLabel  = Gtk.Stock.Ok;

            if (browser)
            {
                GnomeUtil.UrlShow(null, album.GetUrl());
            }
        }