public static TwitterAccount Create (object oauth) { var account = new TwitterAccount () { Username = "******", AccountId = 1, }; lock (Database.Main) Database.Main.Insert (account); accounts [account.LocalAccountId] = account; return account; }
public static TwitterAccount Create(OAuthAuthorizer oauth) { var account = new TwitterAccount () { Username = oauth.AccessScreenname, AccountId = oauth.AccessId, OAuthToken = oauth.AccessToken, OAuthTokenSecret = oauth.AccessTokenSecret }; lock (Database.Main) Database.Main.Insert (account); accounts [account.LocalAccountId] = account; return account; }
public EditAccount(IAccountContainer container, TwitterAccount account, bool pushing) { var info = new AccountInfo (); bool newAccount = account == null; if (newAccount) account = new TwitterAccount (); else { info.Login = account.Username; //info.Password = account.Password; } var bc = new BindingContext (this, info, Locale.GetText ("Edit Account")); var dvc = new DialogViewController (bc.Root, true); PushViewController (dvc, false); UIBarButtonItem done = null; done = new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate { bc.Fetch (); done.Enabled = false; CheckCredentials (info, delegate (string errorMessage) { Util.PopNetworkActive (); done.Enabled = true; if (errorMessage == null){ account.Username = info.Login; //account.Password = info.Password; lock (Database.Main){ if (newAccount) Database.Main.Insert (account); else Database.Main.Update (account); } account.SetDefaultAccount (); DismissModalViewControllerAnimated (true); container.Account = account; } else { dlg = new UIAlertView (Locale.GetText ("Login error"), errorMessage, null, Locale.GetText ("Close")); dlg.Show (); } }); }); dvc.NavigationItem.SetRightBarButtonItem (done, false); }
public static void Remove (TwitterAccount account) { var id = account.LocalAccountId; bool pickNewDefault = id == 1; if (accounts.ContainsKey (id)) accounts.Remove (id); lock (Database.Main){ Database.Main.Execute ("DELETE FROM Tweet where LocalAccountId = ?", account.LocalAccountId); Database.Main.Delete<TwitterAccount> (account); if (pickNewDefault){ var newDefault = Database.Main.Query<TwitterAccount> ("SELECT LocalAccountId FROM TwitterAccount WHERE OAuthToken != \"\"").FirstOrDefault (); if (newDefault != null) Util.Defaults.SetInt (newDefault.LocalAccountId, "DEFAULT_ACCOUNT"); } } }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Util.ReportTime ("Entering Finished"); MainAppDelegate = this; window.MakeKeyAndVisible (); //SpyTouch.SpyTouch.Run (); // Required by some HTTP calls to Twitter System.Net.ServicePointManager.Expect100Continue = false; #if true try { if (File.Exists ("/Users/miguel/xauth")){ using (var f = File.OpenText ("/Users/miguel/xauth")){ var cfg = TwitterAccount.OAuthConfig; cfg.ConsumerKey = f.ReadLine (); cfg.ConsumerSecret = f.ReadLine (); cfg.Callback = f.ReadLine (); useXauth = true; } } } catch {} #else var cfg = TwitterAccount.OAuthConfig; useXauth = true; #endif Util.ReportTime ("Before GetDefaultAccount"); var defaultAccount = TwitterAccount.GetDefaultAccount (); Util.ReportTime ("After GetDefaultAccount"); if (defaultAccount == null){ if (useXauth) NewAccountXAuth (null, null); else CreateDefaultAccountWithOAuth (); } else { Util.ReportTime ("Before UI Creation"); CreatePhoneGui (); Util.ReportTime ("After UI Creation"); Account = defaultAccount; } return true; }
public void SetDefaultAccount(OAuthAuthorizer oauth) { var newAccount = TwitterAccount.Create (oauth); TwitterAccount.SetDefault (newAccount); Account = newAccount; }
public static void SetDefault(TwitterAccount account) { Util.Defaults.SetInt (account.LocalAccountId, DEFAULT_ACCOUNT); CurrentAccount = account; }
public AccountElement(TwitterAccount account) : base(account.Username) { Account = account; }
public Uploader(TwitterAccount account) { this.account = account; }
public static TwitterAccount GetDefaultAccount () { var account = FromId (Util.Defaults.IntForKey (DEFAULT_ACCOUNT)); if (account == null || string.IsNullOrEmpty (account.OAuthToken)) return null; CurrentAccount = account; return account; }
public static void SetDefault(TwitterAccount account) { Util.Defaults.SetInt(account.LocalAccountId, DEFAULT_ACCOUNT); CurrentAccount = account; }