public SmugMugAccountDialog(Gtk.Window parent, SmugMugAccount account) { builder = new GtkBeans.Builder(null, "smugmug_add_dialog.ui", null); builder.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) { Log.Exception(e); } MarkChanged(); }
public SmugMugAccountDialog(Gtk.Window parent, SmugMugAccount account) { builder = new GtkBeans.Builder (null, "smugmug_add_dialog.ui", null); builder.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 PopulateSmugMugOptionMenu(SmugMugAccountManager manager, SmugMugAccount changed_account) { this.account = changed_account; int pos = 0; accounts = manager.GetAccounts(); if (accounts == null || accounts.Count == 0) { gallery_optionmenu.AppendText(Mono.Unix.Catalog.GetString("(No Gallery)")); gallery_optionmenu.Sensitive = false; edit_button.Sensitive = false; } else { int i = 0; foreach (SmugMugAccount account in accounts) { if (account == changed_account) { pos = i; } gallery_optionmenu.AppendText(account.Username); i++; } gallery_optionmenu.Sensitive = true; edit_button.Sensitive = true; } gallery_optionmenu.Active = pos; }
private void Connect(SmugMugAccount selected, string text) { try { if (accounts.Count != 0 && connect) { if (selected == null) { account = (SmugMugAccount)accounts [gallery_optionmenu.Active]; } else { account = selected; } if (!account.Connected) { account.Connect(); } PopulateAlbumOptionMenu(account.SmugMug); } } catch (System.Exception) { Log.Warning("Can not connect to SmugMug. Bad username? Password? Network connection?"); if (selected != null) { account = selected; } PopulateAlbumOptionMenu(account.SmugMug); album_button.Sensitive = false; new SmugMugAccountDialog(this.Dialog, account); } }
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.Active]; 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.Active = 1; } } }
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) { Log.Exception(e); } accounts.Remove(account); MarkChanged(); }
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); }
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) { Log.Exception (e); } MarkChanged (); }
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) { Log.Exception (e); } accounts.Remove (account); MarkChanged (); }
public void MarkChanged(bool write, SmugMugAccount changed_account) { if (write) WriteAccounts (); if (AccountListChanged != null) AccountListChanged (this, changed_account); }
public void AddAccount(SmugMugAccount account) { AddAccount(account, true); }
public void AddAccount(SmugMugAccount account, bool write) { accounts.Add(account); MarkChanged(write, account); }
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 (); }