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 ();
        }
Example #2
0
        void Upload()
        {
            Album album = null;

            IBrowsableItem [] items = dialog.Items;
            string [] captions = dialog.Captions;
            dialog.StoreCaption ();

            if (dialog.CreateAlbum) {
                string name = dialog.AlbumName;
                if (String.IsNullOrEmpty (name)) {
                    HigMessageDialog mbox = new HigMessageDialog (dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal,
                            Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Album must have a name"),
                            Catalog.GetString ("Please name your album or choose an existing album."));
                    mbox.Run ();
                    mbox.Destroy ();
                    return;
                }

                string description = dialog.AlbumDescription;
                string location = dialog.AlbumLocation;

                try {
                    album = dialog.Account.Facebook.CreateAlbum (name, description, location);
                }
                catch (FacebookException fe) {
                    HigMessageDialog mbox = new HigMessageDialog (dialog, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal,
                            Gtk.MessageType.Error, Gtk.ButtonsType.Ok, Catalog.GetString ("Creating a new album failed"),
                            String.Format (Catalog.GetString ("An error occurred creating a new album.\n\n{0}"), fe.Message));
                    mbox.Run ();
                    mbox.Destroy ();
                    return;
                }
            } else {
                album = dialog.ActiveAlbum;
            }

            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 {
                    IBrowsableItem item = items [i];

                    FileInfo file_info;
                    Console.WriteLine ("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.DefaultVersionUri);
                    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");
                    Console.WriteLine (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 ();
        }