예제 #1
0
        public AlbumStore(Album[] albums)
            : base(typeof (string))
        {
            _albums = albums;

            foreach (Album album in Albums) {
                AppendValues (album.Name);
            }
        }
예제 #2
0
        public Album[] GetAlbums()
        {
            AlbumsResponse rsp = util.GetResponse<AlbumsResponse> ("facebook.photos.getAlbums",
                FacebookParam.Create ("uid", session_info.UId),
                FacebookParam.Create ("session_key", session_info.SessionKey),
                FacebookParam.Create ("call_id", DateTime.Now.Ticks));

            // Fetch "Profile pictures" album ID, and remove it from list. We cannot upload there. Bgo#595952
            AlbumsResponse rsp_profile = util.GetResponse<AlbumsResponse> ("facebook.photos.getAlbums",
                FacebookParam.Create ("uid", session_info.UId),
                FacebookParam.Create ("session_key", session_info.SessionKey),
                FacebookParam.Create ("aid", "-3"),
                FacebookParam.Create ("call_id", DateTime.Now.Ticks));

            Album [] rsp_albums = new Album [rsp.Albums.Length - 1];
            uint id = 0;
            foreach (Album album in rsp.Albums)
                if (album.AId != rsp_profile.Albums [0].AId) {
                    album.Session = this;
                    rsp_albums [id ++] = album;
                }

            return rsp_albums;
        }
        public void Run(IBrowsableCollection selection)
        {
            dialog = new FacebookExportDialog (selection);

            if (selection.Items.Length > max_photos_per_album) {
                HigMessageDialog mbox = new HigMessageDialog (dialog,
                        Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.MessageType.Error,
                        Gtk.ButtonsType.Ok, Catalog.GetString ("Too many images to export"),
                        String.Format (Catalog.GetString ("Facebook only permits {0} photographs per album.  Please refine your selection and try again."), max_photos_per_album));
                mbox.Run ();
                mbox.Destroy ();
                return;
            }

            if (dialog.Run () != (int)ResponseType.Ok) {
                dialog.Destroy ();
                return;
            }

            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;
            }

            if (dialog.Account != null) {
                dialog.Hide ();

                command_thread = new System.Threading.Thread (new System.Threading.ThreadStart (Upload));
                command_thread.Name = Mono.Unix.Catalog.GetString ("Uploading Pictures");

                progress_dialog = new ThreadProgressDialog (command_thread, selection.Items.Length);
                progress_dialog.Start ();
            }

            dialog.Destroy ();
        }