示例#1
0
        public SmugMugAccountDialog(Gtk.Window parent, SmugMugAccount account) :  base("smugmug_add_dialog")
        {
            this.Dialog.Modal           = false;
            this.Dialog.TransientFor    = parent;
            this.Dialog.DefaultResponse = Gtk.ResponseType.Ok;

            this.account = account;

            password_entry.ActivatesDefault = true;
            username_entry.ActivatesDefault = true;

            if (account != null)
            {
                password_entry.Text = account.Password;
                username_entry.Text = account.Username;
                add_button.Label    = Gtk.Stock.Ok;
                Dialog.Response    += HandleEditResponse;
            }

            if (remove_button != null)
            {
                remove_button.Visible = account != null;
            }

            this.Dialog.Show();

            password_entry.Changed += HandleChanged;
            username_entry.Changed += HandleChanged;
            HandleChanged(null, null);
        }
示例#2
0
        private void ReadAccounts()
        {
            Hashtable request_attributes = new Hashtable();

            request_attributes["name"] = keyring_item_name;
            try {
                foreach (ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes))
                {
                    if (!result.Attributes.ContainsKey("name") || !result.Attributes.ContainsKey("username") ||
                        (result.Attributes["name"] as string) != keyring_item_name)
                    {
                        continue;
                    }

                    string username = (string)result.Attributes["username"];
                    string password = result.Secret;

                    if (username == null || username == String.Empty || password == null || password == String.Empty)
                    {
                        throw new ApplicationException("Invalid username/password in keyring");
                    }

                    SmugMugAccount account = new SmugMugAccount(username, password);
                    if (account != null)
                    {
                        AddAccount(account, false);
                    }
                }
            } catch (Exception e) {
                Console.Error.WriteLine(e);
            }

            MarkChanged();
        }
示例#3
0
 protected void HandleAddResponse(object sender, Gtk.ResponseArgs args)
 {
     if (args.ResponseId == Gtk.ResponseType.Ok)
     {
         SmugMugAccount account = new SmugMugAccount(username, password);
         SmugMugAccountManager.GetInstance().AddAccount(account);
     }
     Dialog.Destroy();
 }
示例#4
0
        public void MarkChanged(bool write, SmugMugAccount changed_account)
        {
            if (write)
            {
                WriteAccounts();
            }

            if (AccountListChanged != null)
            {
                AccountListChanged(this, changed_account);
            }
        }
示例#5
0
        public void HandleAlbumAdded(string title)
        {
            SmugMugAccount account = (SmugMugAccount)accounts [gallery_optionmenu.History];

            PopulateAlbumOptionMenu(account.SmugMug);

            // make the newly created album selected
            Album[] albums = account.SmugMug.GetAlbums();
            for (int i = 0; i < albums.Length; i++)
            {
                if (((Album)albums[i]).Title == title)
                {
                    album_optionmenu.SetHistory((uint)i);
                }
            }
        }
示例#6
0
        public void RemoveAccount(SmugMugAccount account)
        {
            string    keyring            = Ring.GetDefaultKeyring();
            Hashtable request_attributes = new Hashtable();

            request_attributes["name"]     = keyring_item_name;
            request_attributes["username"] = account.Username;
            try {
                foreach (ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes))
                {
                    Ring.DeleteItem(keyring, result.ItemID);
                }
            } catch (Exception e) {
                Console.WriteLine(e);
            }
            accounts.Remove(account);
            MarkChanged();
        }
示例#7
0
        private void Connect(SmugMugAccount selected, string text)
        {
            try {
                if (accounts.Count != 0 && connect)
                {
                    if (selected == null)
                    {
                        account = (SmugMugAccount)accounts [gallery_optionmenu.History];
                    }
                    else
                    {
                        account = selected;
                    }

                    if (!account.Connected)
                    {
                        account.Connect();
                    }

                    PopulateAlbumOptionMenu(account.SmugMug);
                    album_button.Sensitive = true;
                }
            } catch (System.Exception) {
                System.Console.WriteLine("Can not connect to SmugMug. Bad username ? password ? network connection ?");
                //System.Console.WriteLine ("{0}",ex);
                if (selected != null)
                {
                    account = selected;
                }

                PopulateAlbumOptionMenu(account.SmugMug);

                status_label.Text      = "";
                album_button.Sensitive = false;

                new SmugMugAccountDialog(this.Dialog, account);
            }
        }
示例#8
0
        private void PopulateSmugMugOptionMenu(SmugMugAccountManager manager, SmugMugAccount changed_account)
        {
            Gtk.Menu menu = new Gtk.Menu();
            this.account = changed_account;
            int pos = -1;

            accounts = manager.GetAccounts();
            if (accounts == null || accounts.Count == 0)
            {
                Gtk.MenuItem item = new Gtk.MenuItem(Mono.Unix.Catalog.GetString("(No Gallery)"));
                menu.Append(item);
                gallery_optionmenu.Sensitive = false;
                edit_button.Sensitive        = false;
            }
            else
            {
                int i = 0;
                foreach (SmugMugAccount account in accounts)
                {
                    if (account == changed_account)
                    {
                        pos = i;
                    }

                    Gtk.MenuItem item = new Gtk.MenuItem(account.Username);
                    menu.Append(item);
                    i++;
                }
                gallery_optionmenu.Sensitive = true;
                edit_button.Sensitive        = true;
            }

            menu.ShowAll();
            gallery_optionmenu.Menu = menu;
            gallery_optionmenu.SetHistory((uint)pos);
        }
示例#9
0
        public SmugMugAccountDialog(Gtk.Window parent, SmugMugAccount account)
            : base("smugmug_add_dialog")
        {
            this.Dialog.Modal = false;
                        this.Dialog.TransientFor = parent;
                        this.Dialog.DefaultResponse = Gtk.ResponseType.Ok;

                        this.account = account;

                        password_entry.ActivatesDefault = true;
                        username_entry.ActivatesDefault = true;

                        if (account != null) {
                                password_entry.Text = account.Password;
                                username_entry.Text = account.Username;
                                add_button.Label = Gtk.Stock.Ok;
                                Dialog.Response += HandleEditResponse;
                        }

                        if (remove_button != null)
                                remove_button.Visible = account != null;

                        this.Dialog.Show ();

                        password_entry.Changed += HandleChanged;
                        username_entry.Changed += HandleChanged;
                        HandleChanged (null, null);
        }
示例#10
0
 private void Connect(SmugMugAccount selected)
 {
     Connect(selected, null);
 }
示例#11
0
 public void AddAccount(SmugMugAccount account)
 {
     AddAccount (account, true);
 }
示例#12
0
 public void AddAccount(SmugMugAccount account, bool write)
 {
     accounts.Add (account);
                 MarkChanged (write, account);
 }
示例#13
0
        public void MarkChanged(bool write, SmugMugAccount changed_account)
        {
            if (write)
                                WriteAccounts ();

                        if (AccountListChanged != null)
                                AccountListChanged (this, changed_account);
        }
示例#14
0
 public void AddAccount(SmugMugAccount account, bool write)
 {
     accounts.Add(account);
     MarkChanged(write, account);
 }
示例#15
0
 protected void HandleAddResponse(object sender, Gtk.ResponseArgs args)
 {
     if (args.ResponseId == Gtk.ResponseType.Ok) {
                         SmugMugAccount account = new SmugMugAccount (username, password);
                         SmugMugAccountManager.GetInstance ().AddAccount (account);
                 }
                 Dialog.Destroy ();
 }
示例#16
0
 public void AddAccount(SmugMugAccount account)
 {
     AddAccount(account, true);
 }
示例#17
0
        private void PopulateSmugMugOptionMenu(SmugMugAccountManager manager, SmugMugAccount changed_account)
        {
            Gtk.Menu menu = new Gtk.Menu ();
                        this.account = changed_account;
                        int pos = -1;

                        accounts = manager.GetAccounts ();
                        if (accounts == null || accounts.Count == 0) {
                                Gtk.MenuItem item = new Gtk.MenuItem (Mono.Unix.Catalog.GetString ("(No Gallery)"));
                                menu.Append (item);
                                gallery_optionmenu.Sensitive = false;
                                edit_button.Sensitive = false;
                        } else {
                                int i = 0;
                                foreach (SmugMugAccount account in accounts) {
                                        if (account == changed_account)
                                                pos = i;

                                        Gtk.MenuItem item = new Gtk.MenuItem (account.Username);
                                        menu.Append (item);
                                        i++;
                                }
                                gallery_optionmenu.Sensitive = true;
                                edit_button.Sensitive = true;
                        }

                        menu.ShowAll ();
                        gallery_optionmenu.Menu = menu;
                        gallery_optionmenu.SetHistory ((uint)pos);
        }
示例#18
0
        private void Connect(SmugMugAccount selected, string text)
        {
            try {
                                if (accounts.Count != 0 && connect) {
                                        if (selected == null)
                                                account = (SmugMugAccount) accounts [gallery_optionmenu.History];
                                        else
                                                account = selected;

                                        if (!account.Connected)
                                                account.Connect ();

                                        PopulateAlbumOptionMenu (account.SmugMug);
                                        album_button.Sensitive = true;
                                }
                        } catch (System.Exception) {
                                System.Console.WriteLine ("Can not connect to SmugMug. Bad username ? password ? network connection ?");
                                //System.Console.WriteLine ("{0}",ex);
                                if (selected != null)
                                        account = selected;

                                PopulateAlbumOptionMenu (account.SmugMug);

                                status_label.Text = "";
                                album_button.Sensitive = false;

                                new SmugMugAccountDialog (this.Dialog, account);
                        }
        }
示例#19
0
 private void Connect(SmugMugAccount selected)
 {
     Connect (selected, null);
 }
示例#20
0
        private void ReadAccounts()
        {
            Hashtable request_attributes = new Hashtable();
                        request_attributes["name"] = keyring_item_name;
                        try {
                                foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) {
                                        if(!result.Attributes.ContainsKey("name") || !result.Attributes.ContainsKey("username") ||
                                                (result.Attributes["name"] as string) != keyring_item_name)
                                                continue;

                                        string username = (string)result.Attributes["username"];
                                        string password = result.Secret;

                                        if (username == null || username == String.Empty || password == null || password == String.Empty)
                                                throw new ApplicationException ("Invalid username/password in keyring");

                                        SmugMugAccount account = new SmugMugAccount(username, password);
                                        if (account != null)
                                                AddAccount (account, false);

                                }
                        } catch (Exception e) {
                                Console.Error.WriteLine(e);
                        }

                        MarkChanged ();
        }
示例#21
0
 public void RemoveAccount(SmugMugAccount account)
 {
     string keyring = Ring.GetDefaultKeyring();
                 Hashtable request_attributes = new Hashtable();
                 request_attributes["name"] = keyring_item_name;
                 request_attributes["username"] = account.Username;
                 try {
                         foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) {
                                 Ring.DeleteItem(keyring, result.ItemID);
                         }
                 } catch (Exception e) {
                         Console.WriteLine(e);
                 }
                 accounts.Remove (account);
                 MarkChanged ();
 }