Ejemplo n.º 1
0
        void Upload()
        {
            IPhoto [] items    = dialog.Items;
            string [] captions = dialog.Captions;
            dialog.StoreCaption();

            long sent_bytes = 0;

            FilterSet filters = new FilterSet();

            filters.Add(new JpegFilter());
            filters.Add(new ResizeFilter((uint)size));

            for (int i = 0; i < items.Length; i++)
            {
                try {
                    IPhoto item = items [i];

                    FileInfo file_info;
                    Log.DebugFormat("uploading {0}", i);

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

                    FilterRequest request = new FilterRequest(item.DefaultVersion.Uri);
                    filters.Convert(request);

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

                    album.Upload(captions [i] ?? "", request.Current.LocalPath);

                    sent_bytes += file_info.Length;
                }
                catch (Exception e) {
                    progress_dialog.Message      = string.Format(Catalog.GetString("Error Uploading To Facebook: {0}"), e.Message);
                    progress_dialog.ProgressText = Catalog.GetString("Error");
                    Log.DebugException(e);

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

            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;

            var li = new LinkButton("http://www.facebook.com/group.php?gid=158960179844&ref=mf", Catalog.GetString("Visit F-Spot group on Facebook"));

            progress_dialog.VBoxPackEnd(li);
            li.ShowAll();
        }
Ejemplo n.º 2
0
        void Upload()
        {
            progress_item                   = new ProgressItem();
            progress_item.Changed          += HandleProgressChanged;
            fr.Connection.OnUploadProgress += HandleFlickrProgress;

            var ids = new List <string> ();

            IPhoto [] photos = selection.Items.ToArray();
            Array.Sort(photos, new DateComparer());

            for (int index = 0; index < photos.Length; index++)
            {
                try {
                    IPhoto photo = photos [index];
                    progress_dialog.Message = string.Format(
                        Catalog.GetString("Uploading picture \"{0}\""), photo.Name);

                    progress_dialog.Fraction = photo_index / (double)selection.Count;
                    photo_index++;
                    progress_dialog.ProgressText = string.Format(
                        Catalog.GetString("{0} of {1}"), photo_index,
                        selection.Count);

                    info = new FileInfo(photo.DefaultVersion.Uri.LocalPath);
                    var stack = new FilterSet();
                    if (scale)
                    {
                        stack.Add(new ResizeFilter((uint)size));
                    }

                    string id = fr.Upload(photo, stack, is_public, is_family, is_friend);
                    ids.Add(id);

                    if (App.Instance.Database != null && photo is Photo)
                    {
                        App.Instance.Database.Exports.Create((photo as Photo).Id,
                                                             (photo as Photo).DefaultVersionId,
                                                             ExportStore.FlickrExportType,
                                                             token.UserId + ":" + token.Username + ":" + current_service.Name + ":" + id);
                    }
                } catch (Exception e) {
                    progress_dialog.Message = string.Format(Catalog.GetString("Error Uploading To {0}: {1}"),
                                                            current_service.Name,
                                                            e.Message);
                    progress_dialog.ProgressText = Catalog.GetString("Error");
                    Log.Exception(e);

                    if (progress_dialog.PerformRetrySkip())
                    {
                        index--;
                        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 (open && ids.Count != 0)
            {
                string view_url;
                if (current_service.Name == "Zooomr.com")
                {
                    view_url = string.Format("http://www.{0}/photos/{1}/", current_service.Name, token.Username);
                }
                else
                {
                    view_url = string.Format("http://www.{0}/tools/uploader_edit.gne?ids", current_service.Name);
                    bool first = true;

                    foreach (string id in ids)
                    {
                        view_url = view_url + (first ? "=" : ",") + id;
                        first    = false;
                    }
                }

                GtkBeans.Global.ShowUri(Dialog.Screen, view_url);
            }
        }
Ejemplo n.º 3
0
        private void Upload()
        {
            account.Gallery.Progress          = new ProgressItem();
            account.Gallery.Progress.Changed += HandleProgressChanged;

            Log.Debug("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));
            }

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

                Log.DebugFormat("uploading {0}", photo_index);

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

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


                FilterRequest req = new FilterRequest(item.DefaultVersion.Uri);

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

                    if (item != null && item is Photo && App.Instance.Database != null && id != 0)
                    {
                        App.Instance.Database.Exports.Create((item as Photo).Id, (item as Photo).DefaultVersionId,
                                                             ExportStore.Gallery2ExportType,
                                                             string.Format("{0}:{1}", album.Gallery.Uri, id.ToString()));
                    }
                } catch (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");
                    Log.Exception(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)
            {
                GtkBeans.Global.ShowUri(export_dialog.Screen, album.GetUrl());
            }
        }
Ejemplo n.º 4
0
        public void Upload()
        {
            // FIXME: use mkstemp

            try {
                ThreadAssist.ProxyToMain(Dialog.Hide);

                GLib.File source = GLib.FileFactory.NewForPath(Path.Combine(gallery_path, gallery_name));
                GLib.File target = GLib.FileFactory.NewForPath(Path.Combine(dest.Path, source.Basename));

                if (dest.IsNative)
                {
                    gallery_path = dest.Path;
                }

                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)
                {
                    Log.DebugFormat("Resize Photos to {0}.", size);
                    gallery.SetScale(size);
                }
                else
                {
                    Log.Debug("Exporting full size.");
                }

                if (exportTags)
                {
                    gallery.ExportTags = true;
                }

                if (exportTagIcons)
                {
                    gallery.ExportTagIcons = true;
                }

                gallery.Description = description;
                gallery.GenerateLayout();

                FilterSet filter_set = new FilterSet();
                if (scale)
                {
                    filter_set.Add(new ResizeFilter((uint)size));
                }
                filter_set.Add(new ChmodFilter());
                filter_set.Add(new UniqueNameFilter(new SafeUri(gallery_path)));

                for (int photo_index = 0; photo_index < selection.Count; photo_index++)
                {
                    try {
                        progress_dialog.Message  = System.String.Format(Catalog.GetString("Exporting \"{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 + 1), selection.Count);
                    }
                    catch (Exception e) {
                        Log.Error(e.ToString());
                        progress_dialog.Message = String.Format(Catalog.GetString("Error Copying \"{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 include_tarballs;
                    try {
                        include_tarballs = Preferences.Get <bool> (INCLUDE_TARBALLS_KEY);
                    } catch (NullReferenceException) {
                        include_tarballs = true;
                        Preferences.Set(INCLUDE_TARBALLS_KEY, true);
                    }
                    if (include_tarballs)
                    {
                        (gallery as OriginalGallery).CreateZip();
                    }
                }

                // we've created the structure, now if the destination was local (native) we are done
                // otherwise we xfer
                if (!dest.IsNative)
                {
                    Log.DebugFormat("Transferring \"{0}\" to \"{1}\"", source.Path, target.Path);
                    progress_dialog.Message      = String.Format(Catalog.GetString("Transferring to \"{0}\""), target.Path);
                    progress_dialog.ProgressText = Catalog.GetString("Transferring...");
                    source.CopyRecursive(target, GLib.FileCopyFlags.Overwrite, new GLib.Cancellable(), Progress);
                }

                // No need to check result here as if result is not true, an Exception will be thrown before
                progress_dialog.Message      = Catalog.GetString("Export Complete.");
                progress_dialog.Fraction     = 1.0;
                progress_dialog.ProgressText = Catalog.GetString("Exporting Photos Completed.");
                progress_dialog.ButtonLabel  = Gtk.Stock.Ok;

                if (open)
                {
                    Log.DebugFormat(String.Format("Open URI \"{0}\"", target.Uri.ToString()));
                    ThreadAssist.ProxyToMain(() => { GtkBeans.Global.ShowUri(Dialog.Screen, target.Uri.ToString()); });
                }

                // Save these settings for next time
                Preferences.Set(SCALE_KEY, scale);
                Preferences.Set(SIZE_KEY, size);
                Preferences.Set(OPEN_KEY, open);
                Preferences.Set(EXPORT_TAGS_KEY, exportTags);
                Preferences.Set(EXPORT_TAG_ICONS_KEY, exportTagIcons);
                Preferences.Set(METHOD_KEY, static_radio.Active ? "static" : original_radio.Active ? "original" : "folder");
                Preferences.Set(URI_KEY, uri_chooser.Uri);
            } catch (System.Exception e) {
                Log.Error(e.ToString());
                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.IsNative)
                {
                    System.IO.Directory.Delete(gallery_path, true);
                }

                ThreadAssist.ProxyToMain(() => { Dialog.Destroy(); });
            }
        }
Ejemplo n.º 5
0
        private void Upload()
        {
            album.UploadProgress += HandleUploadProgress;
            sent_bytes            = 0;
            approx_size           = 0;

            Log.Debug("Starting Upload to Picasa");

            FilterSet filters = new FilterSet();

            filters.Add(new JpegFilter());

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

            Array.Sort(items, new DateComparer());

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

                    FileInfo file_info;
                    Log.Debug("Picasa uploading " + photo_index);

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

                    PicasaPicture picture;
                    using (FilterRequest request = new FilterRequest(item.DefaultVersion.Uri)) {
                        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);
                        }

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

                    //tagging
                    if (item.Tags != null && export_tag)
                    {
                        foreach (Tag tag in item.Tags)
                        {
                            picture.AddTag(tag.Name);
                        }
                    }
                } catch (System.Threading.ThreadAbortException te) {
                    Log.Exception(te);
                    System.Threading.Thread.ResetAbort();
                } catch (System.Exception e) {
                    progress_dialog.Message = String.Format(Catalog.GetString("Error Uploading To Gallery: {0}"),
                                                            e.Message);
                    progress_dialog.ProgressText = Catalog.GetString("Error");
                    Log.DebugException(e);

                    if (progress_dialog.PerformRetrySkip())
                    {
                        photo_index--;
                        if (photo_index == 0)
                        {
                            approx_size = 0;
                        }
                    }
                }
            }

            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)
            {
                GtkBeans.Global.ShowUri(Dialog.Screen, album.Link);
            }
        }
Ejemplo n.º 6
0
        private void Upload()
        {
            sent_bytes  = 0;
            approx_size = 0;

            System.Uri album_uri = null;

            Log.Debug("Starting Upload to Smugmug, album " + album.Title + " - " + album.AlbumID);

            FilterSet filters = new FilterSet();

            filters.Add(new JpegFilter());

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

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

                    FileInfo file_info;
                    Log.Debug("uploading " + 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.DefaultVersion.Uri);

                    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 (App.Instance.Database != null && item is Photo && image_id >= 0)
                    {
                        App.Instance.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");
                    Log.DebugException(e);

                    if (progress_dialog.PerformRetrySkip())
                    {
                        photo_index--;
                        if (photo_index == 0)
                        {
                            approx_size = 0;
                        }
                    }
                }
            }

            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)
            {
                GtkBeans.Global.ShowUri(Dialog.Screen, album_uri.ToString());
            }
        }