public SmugMugAccountDialog(Gtk.Window parent, SmugMugAccount account) { xml = new Glade.XML(null, "SmugMugExport.glade", dialog_name, "f-spot"); xml.Autoconnect(this); Dialog.Modal = false; Dialog.TransientFor = parent; 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); }
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(); }
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(); }
public void MarkChanged(bool write, SmugMugAccount changed_account) { if (write) { WriteAccounts(); } if (AccountListChanged != null) { AccountListChanged(this, changed_account); } }
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); } } }
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(); }
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); } } 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); album_button.Sensitive = false; new SmugMugAccountDialog(this.Dialog, account); } }
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); }
private void Connect(SmugMugAccount selected) { Connect(selected, null); }
public void AddAccount(SmugMugAccount account, bool write) { accounts.Add(account); MarkChanged(write, account); }
public void AddAccount(SmugMugAccount account) { AddAccount(account, true); }