public override void ViewDidLoad() { try { TitleLabel.Font = Theme.HugeFont; TitleLabel.Text = "USER SETTINGS"; var info = Repo.Foreground.Table <GoogleReaderConfig> ().FirstOrDefault(); if (info == null) { info = new GoogleReaderConfig(); Repo.Foreground.Insert(info); } _settings = new UserSettings.Settings(); _settings.GoogleAccount = info.Account; _settings.GooglePassword = info.Password; var y = TitleLabel.Frame.Bottom + App.Inst.LabelGap; _form = new Form(_settings, new RectangleF(TitleLabel.Frame.Left, y, View.Frame.Width, View.Frame.Height - y)); _form.ConfirmButtonText = "SAVE"; _form.OnCancel += delegate { try { App.Inst.PopDialog(); } catch (Exception error) { Log.Error(error); } }; _form.OnOK += delegate { try { info.Account = _settings.GoogleAccount; info.Password = _settings.GooglePassword; Repo.Foreground.Update(info); GoogleReaderUpdater.SetReaderChanged(); App.Inst.PopDialog(); } catch (Exception error) { Log.Error(error); } }; View.AddSubview(_form); } catch (Exception error) { Log.Error(error); } }
public override void ViewDidLoad() { try { TitleLabel.Font = Theme.HugeFont; TitleLabel.Text = "USER SETTINGS"; var info = Repo.Foreground.Table<GoogleReaderConfig> ().FirstOrDefault (); if (info == null) { info = new GoogleReaderConfig (); Repo.Foreground.Insert (info); } _settings = new UserSettings.Settings (); _settings.GoogleAccount = info.Account; _settings.GooglePassword = info.Password; var y = TitleLabel.Frame.Bottom + App.Inst.LabelGap; _form = new Form (_settings, new RectangleF (TitleLabel.Frame.Left, y, View.Frame.Width, View.Frame.Height - y)); _form.ConfirmButtonText = "SAVE"; _form.OnCancel += delegate { try { App.Inst.PopDialog (); } catch (Exception error) { Log.Error (error); } }; _form.OnOK += delegate { try { info.Account = _settings.GoogleAccount; info.Password = _settings.GooglePassword; Repo.Foreground.Update (info); GoogleReaderUpdater.SetReaderChanged (); App.Inst.PopDialog (); } catch (Exception error) { Log.Error (error); } }; View.AddSubview (_form); } catch (Exception error) { Log.Error (error); } }
void LogIn(GoogleReaderConfig conf) { var url = "https://www.google.com/accounts/ServiceLogin?hl=en&nui=5&service=reader<mpl=mobile&btmpl=mobile&continue=http%3A%2F%2Fwww.google.com%2Freader%2Fm%2Fsubscriptions"; var req = Http.NewRequest(url); req.CookieContainer = _cookies; var rawResp = Http.ReadResponse(req); var resp = Html.Parse(rawResp); //Console.WriteLine (rawResp); var form = resp.SelectSingleNode("//form[@id='gaia_loginform']"); var action = form.Attributes["action"].Value; var inputs = new Dictionary <string, string>(); foreach (HtmlAgilityPack.HtmlNode i in form.SelectNodes("//input")) { var ka = i.Attributes["name"]; if (ka == null) { continue; } var key = i.Attributes["name"].Value; var val = ""; var va = i.Attributes["value"]; if (va != null) { val = va.Value; } inputs[key] = val; } inputs["Email"] = conf.Account; inputs["Passwd"] = conf.Password; Http.Post(action, inputs, _cookies); }
TimeSpan Update() { GoogleReaderConfig info = null; var now = DateTime.UtcNow; var updateInterval = TimeSpan.FromHours(8); using (var repo = new Repo()) { info = repo.Table <GoogleReaderConfig>().FirstOrDefault(); } if (info == null || !info.IsValid) { return(TimeSpan.FromHours(10)); } if ((now - info.LastUpdateTime) < updateInterval) { return(updateInterval - (now - info.LastUpdateTime)); } Console.WriteLine("GU: Gathering subscriptions"); LogIn(info); var subs = GetSubscriptions(); Subscribe(subs); MarkRead(); using (var repo = new Repo()) { info.LastUpdateTime = now; repo.Update(info); } return(TimeSpan.FromHours(8)); }
void LogIn(GoogleReaderConfig conf) { var url = "https://www.google.com/accounts/ServiceLogin?hl=en&nui=5&service=reader<mpl=mobile&btmpl=mobile&continue=http%3A%2F%2Fwww.google.com%2Freader%2Fm%2Fsubscriptions"; var req = Http.NewRequest(url); req.CookieContainer = _cookies; var rawResp = Http.ReadResponse(req); var resp = Html.Parse(rawResp); //Console.WriteLine (rawResp); var form = resp.SelectSingleNode("//form[@id='gaia_loginform']"); var action = form.Attributes["action"].Value; var inputs = new Dictionary<string, string>(); foreach (HtmlAgilityPack.HtmlNode i in form.SelectNodes("//input")) { var ka = i.Attributes["name"]; if (ka == null) continue; var key = i.Attributes["name"].Value; var val = ""; var va = i.Attributes["value"]; if (va != null) { val = va.Value; } inputs[key] = val; } inputs["Email"] = conf.Account; inputs["Passwd"] = conf.Password; Http.Post(action, inputs, _cookies); }