From ad482780beb5b8a47154707ba11390f75c4b9008 Mon Sep 17 00:00:00 2001 From: Will Duff Date: Sat, 12 Dec 2015 02:38:43 -0800 Subject: [PATCH] Add Google Blogger configuration wizard panel Adds a new radio button to specify a Google Blogger blog and a follow up panel to prompt users to open the Google Blogger OAuth flow. --- .../OpenLiveWriter.BlogClient/BlogSettings.cs | 7 + .../Clients/BloggerAtomClient.cs | 4 + .../DisplayMessages.xml | 7 +- .../OpenLiveWriter.Localization/MessageId.cs | 1 + .../Properties.resx | 6 + .../PropertiesNonLoc.resx | 3 + .../OpenLiveWriter.Localization/StringId.cs | 14 +- .../OpenLiveWriter.Localization/Strings.csv | 5 +- .../OpenLiveWriter.Localization/Strings.resx | 11 +- .../Configuration/TemporaryBlogSettings.cs | 16 ++ .../WeblogConfigurationWizardController.cs | 28 ++ .../Wizard/WeblogConfigurationWizardPanel.cs | 1 + .../WeblogConfigurationWizardPanelBlogType.cs | 40 ++- ...nWizardPanelGoogleBloggerAuthentication.cs | 243 ++++++++++++++++++ ...izardPanelGoogleBloggerAuthentication.resx | 238 +++++++++++++++++ .../OpenLiveWriter.PostEditor.csproj | 75 ++++++ .../OpenLiveWriter.PostEditor/packages.config | 11 + 17 files changed, 701 insertions(+), 9 deletions(-) create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.cs create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.resx diff --git a/src/managed/OpenLiveWriter.BlogClient/BlogSettings.cs b/src/managed/OpenLiveWriter.BlogClient/BlogSettings.cs index 983f6ef2..6f3d186d 100644 --- a/src/managed/OpenLiveWriter.BlogClient/BlogSettings.cs +++ b/src/managed/OpenLiveWriter.BlogClient/BlogSettings.cs @@ -168,6 +168,13 @@ namespace OpenLiveWriter.BlogClient } private const string IS_SHAREPOINT_BLOG = "IsSharePointBlog"; + public bool IsGoogleBloggerBlog + { + get { return Settings.GetBoolean(IS_GOOGLE_BLOGGER_BLOG, false); } + set { Settings.SetBoolean(IS_GOOGLE_BLOGGER_BLOG, value); } + } + private const string IS_GOOGLE_BLOGGER_BLOG = "IsGoogleBloggerBlog"; + /// /// Id of the weblog on the host service /// diff --git a/src/managed/OpenLiveWriter.BlogClient/Clients/BloggerAtomClient.cs b/src/managed/OpenLiveWriter.BlogClient/Clients/BloggerAtomClient.cs index 14586d73..7c12dfaf 100644 --- a/src/managed/OpenLiveWriter.BlogClient/Clients/BloggerAtomClient.cs +++ b/src/managed/OpenLiveWriter.BlogClient/Clients/BloggerAtomClient.cs @@ -20,12 +20,16 @@ using OpenLiveWriter.BlogClient.Providers; using OpenLiveWriter.HtmlParser.Parser; using OpenLiveWriter.HtmlParser.Parser.FormAgent; using OpenLiveWriter.Localization; +using Google.Apis.Blogger.v3; namespace OpenLiveWriter.BlogClient.Clients { [BlogClient("BloggerAtom", "Atom")] public class BloggerAtomClient : AtomClient { + public static string PicasaServiceScope = "https://picasaweb.google.com/data"; + public static string BloggerServiceScope = BloggerService.Scope.Blogger; + public BloggerAtomClient(Uri postApiUrl, IBlogCredentialsAccessor credentials) : base(AtomProtocolVersion.V10DraftBlogger, postApiUrl, credentials) { diff --git a/src/managed/OpenLiveWriter.Localization/DisplayMessages.xml b/src/managed/OpenLiveWriter.Localization/DisplayMessages.xml index 68c56f80..a0695314 100644 --- a/src/managed/OpenLiveWriter.Localization/DisplayMessages.xml +++ b/src/managed/OpenLiveWriter.Localization/DisplayMessages.xml @@ -457,6 +457,11 @@ Identifier="BloggerError" Text="Blogger returned the following error: {0}" comment:Text="{0} - an error message" /> + + Text="Sign in and select a video to continue." /> The server did not respond with the expected authorization token. + + Sign in to Google Blogger to continue. + + + Open Live Writer + Using Open Live Writer from the guest account is not supported. diff --git a/src/managed/OpenLiveWriter.Localization/PropertiesNonLoc.resx b/src/managed/OpenLiveWriter.Localization/PropertiesNonLoc.resx index 4eccd7a3..8df27350 100644 --- a/src/managed/OpenLiveWriter.Localization/PropertiesNonLoc.resx +++ b/src/managed/OpenLiveWriter.Localization/PropertiesNonLoc.resx @@ -360,6 +360,9 @@ Asterisk + + Warning + YesNo diff --git a/src/managed/OpenLiveWriter.Localization/StringId.cs b/src/managed/OpenLiveWriter.Localization/StringId.cs index cf26dc15..11db9df3 100644 --- a/src/managed/OpenLiveWriter.Localization/StringId.cs +++ b/src/managed/OpenLiveWriter.Localization/StringId.cs @@ -395,7 +395,7 @@ namespace OpenLiveWriter.Localization /// BlogPluginsDescription, /// - /// Blogger, TypePad, and more + /// TypePad and more /// BlogServiceNames, /// @@ -1103,6 +1103,14 @@ namespace OpenLiveWriter.Localization /// CWSharePointUseSystemLogin, /// + /// Provide Google Blogger Login + /// + CWGoogleBloggerTitle, + /// + /// To configure Google Blogger please sign in. + /// + CWGoogleBloggerDescription, + /// /// &Microsoft Account: /// CWSpacesUsername, @@ -5203,6 +5211,10 @@ namespace OpenLiveWriter.Localization /// WizardBlogTypeConfigureTo, /// + /// &Google Blogger + /// + WizardBlogTypeGoogleBlogger, + /// /// &Other services /// WizardBlogTypeOther, diff --git a/src/managed/OpenLiveWriter.Localization/Strings.csv b/src/managed/OpenLiveWriter.Localization/Strings.csv index e5746f89..80024955 100644 --- a/src/managed/OpenLiveWriter.Localization/Strings.csv +++ b/src/managed/OpenLiveWriter.Localization/Strings.csv @@ -59,6 +59,7 @@ WizardBlogTypeWelcome,"Many popular blog services work with {0}.","{0} - Long pr WizardBlogTypeWhatBlogType,What blog service do you use?, WizardBlogTypeConfigureTo,Configure {0} to publish to:,"{0} - Long product name, i.e. ""Open Live Writer""; followed by a choice of two options: ""SharePoint blog"" or ""Another blog service""" WizardBlogTypeSharePoint,&SharePoint, +WizardBlogTypeGoogleBlogger,&Google Blogger, WizardBlogTypeOther,&Other services, Options,Options, AllowAutoUpdate,"Automatically &update account information (categories, links, capabilities, and provider extensions)", @@ -365,6 +366,8 @@ CWSharePointTitle,Configure {0} for a SharePoint blog,{0} - Writer CWSharePointTitle2,Provide SharePoint Blog Login, CWSharePointText2,Enter the login required to publish to your SharePoint blog., CWSharePointUseSystemLogin,Use my &Windows user name and password, +CWGoogleBloggerTitle,Provide Google Blogger Login, +CWGoogleBloggerDescription,To configure Google Blogger please sign in., CWTitle,Add Blog Wizard,Caption of the Add Blog Wizard window. CWProgressHeader,Setting up your blog account, ProgressDownloadingEditingTemplate,Downloading editing template..., @@ -1329,7 +1332,7 @@ PostPageFilter,Filter {0}, {0} - Posts or Pages LiveIDPrivacy,Privacy policy, ForgotMyPassword,Forgot my password, BrowseForFile,Browse for file,Tooltip over the button in the insert video from file dialog that opens an Open File Dialog when clicked, -BlogServiceNames,"Blogger, TypePad, and more", +BlogServiceNames,"TypePad and more", FindCategory,Find category, Alignment,Alignment,Tooltip for image alignment dropdown, CropPane,Image crop pane, diff --git a/src/managed/OpenLiveWriter.Localization/Strings.resx b/src/managed/OpenLiveWriter.Localization/Strings.resx index 75268200..7d27c826 100644 --- a/src/managed/OpenLiveWriter.Localization/Strings.resx +++ b/src/managed/OpenLiveWriter.Localization/Strings.resx @@ -460,7 +460,7 @@ From the Weblog | Edit Weblog Settings | Plugins preferences panel - Blogger, TypePad, and more + TypePad and more Contrast @@ -1066,6 +1066,12 @@ Use my &Windows user name and password + + Provide Google Blogger Login + + + To configure Google Blogger please sign in. + &Microsoft Account ID: @@ -4497,6 +4503,9 @@ This might take a while. Configure {0} to publish to: {0} - Long product name, i.e. "Open Live Writer"; followed by a choice of two options: "SharePoint blog" or "Another blog service" + + &Google Blogger + &Other services diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/TemporaryBlogSettings.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/TemporaryBlogSettings.cs index 81199f81..16025dab 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/TemporaryBlogSettings.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/TemporaryBlogSettings.cs @@ -35,6 +35,7 @@ namespace OpenLiveWriter.PostEditor.Configuration tempSettings.IsNewWeblog = false; tempSettings.IsSpacesBlog = blogSettings.IsSpacesBlog; tempSettings.IsSharePointBlog = blogSettings.IsSharePointBlog; + tempSettings.IsGoogleBloggerBlog = blogSettings.IsGoogleBloggerBlog; tempSettings.HostBlogId = blogSettings.HostBlogId; tempSettings.BlogName = blogSettings.BlogName; tempSettings.HomepageUrl = blogSettings.HomepageUrl; @@ -83,6 +84,7 @@ namespace OpenLiveWriter.PostEditor.Configuration settings.HostBlogId = this.HostBlogId; settings.IsSpacesBlog = this.IsSpacesBlog; settings.IsSharePointBlog = this.IsSharePointBlog; + settings.IsGoogleBloggerBlog = this.IsGoogleBloggerBlog; settings.BlogName = this.BlogName; settings.HomepageUrl = this.HomepageUrl; settings.ForceManualConfig = this.ForceManualConfig; @@ -254,6 +256,18 @@ namespace OpenLiveWriter.PostEditor.Configuration } } + public bool IsGoogleBloggerBlog + { + get + { + return _isGoogleBloggerBlog; + } + set + { + _isGoogleBloggerBlog = value; + } + } + public string HostBlogId { get @@ -605,6 +619,7 @@ namespace OpenLiveWriter.PostEditor.Configuration private bool? _savePassword; private bool _isSpacesBlog = false; private bool _isSharePointBlog = false; + private bool _isGoogleBloggerBlog = false; private string _hostBlogId = String.Empty; private string _blogName = String.Empty; private string _homePageUrl = String.Empty; @@ -665,6 +680,7 @@ namespace OpenLiveWriter.PostEditor.Configuration _savePassword = sourceSettings._savePassword; _isSpacesBlog = sourceSettings._isSpacesBlog; _isSharePointBlog = sourceSettings._isSharePointBlog; + _isGoogleBloggerBlog = sourceSettings._isGoogleBloggerBlog; _hostBlogId = sourceSettings._hostBlogId; _blogName = sourceSettings._blogName; _homePageUrl = sourceSettings._homePageUrl; diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs index acb9f70d..d26aa70e 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs @@ -227,6 +227,18 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard _authenticationRequired = showAuthenticationStep; } + private void AddGoogleBloggerOAuthSubStep() + { + addWizardSubStep( + new WizardSubStep(new WeblogConfigurationWizardPanelGoogleBloggerAuthentication(), + null, + new DisplayCallback(OnBasicInfoDisplayed), + new VerifyStepCallback(OnValidatePanel), + new NextCallback(OnGoogleBloggerOAuthCompleted), + null, + new BackCallback(OnGoogleBloggerOAuthBack))); + } + private void AddConfirmationStep() { addWizardStep( @@ -324,6 +336,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard // set the user's choice _temporarySettings.IsSharePointBlog = panelBlogType.IsSharePointBlog; + _temporarySettings.IsGoogleBloggerBlog = panelBlogType.IsGoogleBloggerBlog; // did this bootstrap a custom account wizard? _providerAccountWizard = panelBlogType.ProviderAccountWizard; @@ -333,6 +346,10 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard { AddSharePointBasicInfoSubStep(false); } + else if (_temporarySettings.IsGoogleBloggerBlog) + { + AddGoogleBloggerOAuthSubStep(); + } else { AddBasicInfoSubStep(); @@ -514,6 +531,17 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard _authenticationStepAdded = false; } + private void OnGoogleBloggerOAuthCompleted(Object stepControl) + { + OnBasicInfoAndAuthenticationCompleted((IAccountBasicInfoProvider)stepControl, new PerformBlogAutoDetection(PerformWeblogAndSettingsAutoDetectionSubStep)); + } + + private void OnGoogleBloggerOAuthBack(Object stepControl) + { + var panel = (WeblogConfigurationWizardPanelGoogleBloggerAuthentication)stepControl; + panel.CancelAuthorization(); + } + private void OnWeblogAndSettingsAutoDetectionCompleted(Object stepControl) { // if we weren't able to identify a specific weblog diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanel.cs index 83bff689..2141c734 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanel.cs @@ -30,6 +30,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard OtherBasicInfo = 33, SelectProvider = 40, SharePointAuth = 41, + GoogleBloggerAuth = 42, SelectBlog = 50, SelectImageEndPoint = 60, Confirm = 80, diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelBlogType.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelBlogType.cs index 22eb0fed..a9bb2cef 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelBlogType.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelBlogType.cs @@ -25,6 +25,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard private System.Windows.Forms.Label labelWelcomeText; private System.Windows.Forms.Panel panelRadioButtons; private System.Windows.Forms.RadioButton radioButtonSharePoint; + private System.Windows.Forms.RadioButton radioButtonBlogger; private System.Windows.Forms.RadioButton radioButtonOther; private System.Windows.Forms.Label labelOtherDesc; private System.Windows.Forms.RadioButton radioButtonWordpress; @@ -47,6 +48,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard labelHeader.Text = Res.Get(StringId.WizardBlogTypeWhatBlogType); labelWelcomeText.Text = Res.Get(StringId.WizardBlogTypeWelcome); radioButtonSharePoint.Text = Res.Get(StringId.WizardBlogTypeSharePoint); + radioButtonBlogger.Text = Res.Get(StringId.WizardBlogTypeGoogleBlogger); radioButtonOther.Text = Res.Get(StringId.WizardBlogTypeOther); radioButtonWordpress.Text = Res.Get(StringId.CWWelcomeWP); @@ -78,6 +80,8 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard comboBoxSelectWeblogType.Items.Add(new WeblogType(serviceName)); } + comboBoxSelectWeblogType.Items.Add(new WeblogType(radioButtonBlogger)); + // add "another weblog type" entry comboBoxSelectWeblogType.Items.Add(new WeblogType(radioButtonOther)); @@ -99,8 +103,8 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard comboBoxSelectWeblogType.SelectedIndexChanged += new EventHandler(UserChangedSelectionHandler); radioButtonWordpress.CheckedChanged += new EventHandler(UserChangedSelectionHandler); radioButtonSharePoint.CheckedChanged += new EventHandler(UserChangedSelectionHandler); + radioButtonBlogger.CheckedChanged += new EventHandler(UserChangedSelectionHandler); radioButtonOther.CheckedChanged += new EventHandler(UserChangedSelectionHandler); - } public override void NaturalizeLayout() @@ -117,12 +121,13 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard MaximizeWidth(radioButtonWordpress); MaximizeWidth(radioButtonSharePoint); + MaximizeWidth(radioButtonBlogger); MaximizeWidth(radioButtonOther); MaximizeWidth(labelOtherDesc); using (new AutoGrow(panelRadioButtons, AnchorStyles.Bottom, true)) { - LayoutHelper.NaturalizeHeightAndDistribute(3, radioButtonWordpress, radioButtonSharePoint, radioButtonOther); + LayoutHelper.NaturalizeHeightAndDistribute(3, radioButtonWordpress, radioButtonSharePoint, radioButtonBlogger, radioButtonOther); labelOtherDesc.Top = radioButtonOther.Bottom; } } @@ -162,6 +167,21 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard } } + public bool IsGoogleBloggerBlog + { + get + { + if (panelRadioButtons.Visible) + { + return radioButtonBlogger.Checked; + } + else + { + return SelectedWeblog.RadioButton == radioButtonBlogger; + } + } + } + public IBlogProviderAccountWizardDescription ProviderAccountWizard { get @@ -293,6 +313,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard this.panelRadioButtons = new System.Windows.Forms.Panel(); this.radioButtonWordpress = new System.Windows.Forms.RadioButton(); this.radioButtonSharePoint = new System.Windows.Forms.RadioButton(); + this.radioButtonBlogger = new System.Windows.Forms.RadioButton(); this.radioButtonOther = new System.Windows.Forms.RadioButton(); this.labelOtherDesc = new System.Windows.Forms.Label(); this.panelComboBox = new System.Windows.Forms.Panel(); @@ -326,6 +347,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard | System.Windows.Forms.AnchorStyles.Right))); this.panelRadioButtons.Controls.Add(this.radioButtonWordpress); this.panelRadioButtons.Controls.Add(this.radioButtonSharePoint); + this.panelRadioButtons.Controls.Add(this.radioButtonBlogger); this.panelRadioButtons.Controls.Add(this.radioButtonOther); this.panelRadioButtons.Controls.Add(this.labelOtherDesc); this.panelRadioButtons.Location = new System.Drawing.Point(20, 88); @@ -349,7 +371,15 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard this.radioButtonSharePoint.Size = new System.Drawing.Size(104, 24); this.radioButtonSharePoint.TabIndex = 2; this.radioButtonSharePoint.Text = "Share&Point weblog"; - // + // + // radioButtonBlogger + // + this.radioButtonBlogger.Location = new System.Drawing.Point(0, 72); + this.radioButtonBlogger.Name = "radioButtonBlogger"; + this.radioButtonBlogger.Size = new System.Drawing.Size(104, 24); + this.radioButtonBlogger.TabIndex = 3; + this.radioButtonBlogger.Text = "&Google Blogger"; + // // radioButtonOther // this.radioButtonOther.Location = new System.Drawing.Point(0, 48); @@ -366,8 +396,8 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard this.labelOtherDesc.Name = "labelOtherDesc"; this.labelOtherDesc.Size = new System.Drawing.Size(332, 40); this.labelOtherDesc.TabIndex = 5; - this.labelOtherDesc.Text = "Blogger, WordPress, TypePad, all others"; - // + this.labelOtherDesc.Text = "TypePad and others"; + // // panelComboBox // this.panelComboBox.Controls.Add(this.comboBoxSelectWeblogType); diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.cs new file mode 100644 index 00000000..fc3d1ea6 --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.cs @@ -0,0 +1,243 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for details. + +using System; +using System.Windows.Forms; +using System.Collections.Generic; +using System.Threading.Tasks; +using OpenLiveWriter.BlogClient; +using OpenLiveWriter.BlogClient.Clients; +using OpenLiveWriter.CoreServices; +using OpenLiveWriter.CoreServices.Layout; +using OpenLiveWriter.Extensibility.BlogClient; +using OpenLiveWriter.Localization; +using Google.Apis.Auth.OAuth2; +using Google.Apis.Blogger.v3; +using Google.Apis.Blogger.v3.Data; +using Google.Apis.Services; +using System.Threading; +using OpenLiveWriter.BlogClient.Detection; + +namespace OpenLiveWriter.PostEditor.Configuration.Wizard +{ + /// + /// Summary description for WeblogConfigurationWizardPanelAuthentication. + /// + internal class WeblogConfigurationWizardPanelGoogleBloggerAuthentication : WeblogConfigurationWizardPanel, IAccountBasicInfoProvider + { + private System.Windows.Forms.Label labelDescription; + private System.Windows.Forms.Button buttonLogin; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + private UserCredential _userCredentials; + private BlogList _blogList; + private CancellationTokenSource _cancellationTokenSource; + + public WeblogConfigurationWizardPanelGoogleBloggerAuthentication() + { + // This call is required by the Windows.Forms Form Designer. + InitializeComponent(); + + labelHeader.Text = Res.Get(StringId.CWGoogleBloggerTitle); + labelDescription.Text = Res.Get(StringId.CWGoogleBloggerDescription); + buttonLogin.Text = Res.Get(StringId.Login); + } + + private async void buttonLogin_Click(object sender, EventArgs e) + { + buttonLogin.Enabled = false; + + try + { + _cancellationTokenSource = new CancellationTokenSource(); + _userCredentials = await GoogleWebAuthorizationBroker.AuthorizeAsync( + new ClientSecrets() + { + ClientId = "clientId", + ClientSecret = "clientSecret" + }, + new List() { BloggerAtomClient.BloggerServiceScope, BloggerAtomClient.PicasaServiceScope }, + "user", + _cancellationTokenSource.Token); + _cancellationTokenSource = null; + } + finally + { + buttonLogin.Enabled = true; + } + } + + private async Task ListUserBlogs() + { + BloggerService service = new BloggerService(new BaseClientService.Initializer() + { + HttpClientInitializer = _userCredentials + }); + + _blogList = await service.Blogs.ListByUser("self").ExecuteAsync(); + } + + public void CancelAuthorization() + { + if (_cancellationTokenSource != null) + { + _cancellationTokenSource.Cancel(); + } + } + + public override void NaturalizeLayout() + { + if (!DesignMode) + { + MaximizeWidth(labelDescription); + + LayoutHelper.NaturalizeHeight(labelDescription); + LayoutHelper.DistributeVertically(10, false, labelDescription, buttonLogin); + } + } + + public override ConfigPanelId? PanelId + { + get { return ConfigPanelId.GoogleBloggerAuth; } + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Component Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.buttonLogin = new System.Windows.Forms.Button(); + this.labelDescription = new System.Windows.Forms.Label(); + this.panelMain.SuspendLayout(); + this.SuspendLayout(); + // + // panelMain + // + this.panelMain.Controls.Add(this.buttonLogin); + this.panelMain.Controls.Add(this.labelDescription); + // + // buttonLogin + // + this.buttonLogin.AutoSize = true; + this.buttonLogin.Location = new System.Drawing.Point(20, 0); + this.buttonLogin.FlatStyle = FlatStyle.System; + this.buttonLogin.Name = "buttonLogin"; + this.buttonLogin.Size = new System.Drawing.Size(168, 13); + this.buttonLogin.TabIndex = 0; + this.buttonLogin.Text = "Sign in"; + this.buttonLogin.Click += buttonLogin_Click; + // + // labelDescription + // + this.labelDescription.FlatStyle = FlatStyle.System; + this.labelDescription.Location = new System.Drawing.Point(20, 0); + this.labelDescription.Name = "labelDescription"; + this.labelDescription.Size = new System.Drawing.Size(360, 24); + this.labelDescription.TabIndex = 1; + this.labelDescription.Text = "To configure Google Blogger please sign in."; + // + // WeblogConfigurationWizardPanelGoogleBloggerAuthentication + // + this.Name = "WeblogConfigurationWizardPanelGoogleBloggerAuthentication"; + this.panelMain.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + public override bool ValidatePanel() + { + if (_userCredentials == null || _userCredentials.Token == null) + { + ShowValidationError(buttonLogin, MessageId.GoogleBloggerLoginRequired); + return false; + } + + return true; + } + + public bool IsDirty(TemporaryBlogSettings settings) + { + return false; + + // TODO:OLW + // return Credentials.OAuthCredentials != settings.Credentials.OAuthCredentials; + } + + public IBlogProviderAccountWizardDescription ProviderAccountWizard + { + set { } + } + + public string AccountId + { + set { } + } + + public string HomepageUrl + { + get { return string.Empty; } + set { } + } + + public bool SavePassword + { + get { return true; } + set { } + } + + public bool ForceManualConfiguration + { + get { return false; } + set { } + } + + public IBlogCredentials Credentials + { + get + { + TemporaryBlogCredentials credentials = new TemporaryBlogCredentials(); + credentials.Username = "user"; + if (_userCredentials != null) + { + // TODO:OLW + //credentials.GoogleBloggerToken = _userCredentials; + credentials.Password = _userCredentials.Token.AccessToken; + credentials.SetCustomValue("RefreshToken", _userCredentials.Token.RefreshToken); + credentials.SetCustomValue("Scope", _userCredentials.Token.Scope); + credentials.SetCustomValue("Issued", _userCredentials.Token.Issued.ToBinary().ToString()); + } + return credentials; + } + set + { + // TODO:OLW + } + } + + public BlogInfo BlogAccount + { + get { return null; } + } + } +} diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.resx b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.resx new file mode 100644 index 00000000..ce95e20a --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelGoogleBloggerAuthentication.resx @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + True + + + True + + + Private + + + Family + + + 8, 8 + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + True + + + Private + + + 8, 8 + + + True + + + Private + + + False + + + Private + + + Private + + + False + + + False + + + True + + + True + + + 80 + + + (Default) + + + False + + + Private + + + WeblogConfigurationWizardPanelSharePointAuthentication + + + 8, 8 + + \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj b/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj index ecf91290..feca8301 100644 --- a/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj +++ b/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj @@ -7,6 +7,8 @@ OpenLiveWriter.PostEditor {D6C9A393-E0B8-4548-B84B-F8B6FE2A5645} true + + @@ -22,10 +24,50 @@ ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll True + + ..\packages\Google.Apis.1.9.2\lib\net40\Google.Apis.dll + True + + + ..\packages\Google.Apis.Auth.1.9.2\lib\net40\Google.Apis.Auth.dll + True + + + ..\packages\Google.Apis.Auth.1.9.2\lib\net40\Google.Apis.Auth.PlatformServices.dll + True + + + ..\packages\Google.Apis.Blogger.v3.1.9.2.480\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Blogger.v3.dll + True + + + ..\packages\Google.Apis.Core.1.9.2\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll + True + + + ..\packages\Google.Apis.1.9.2\lib\net40\Google.Apis.PlatformServices.dll + True + ..\packages\squirrel.windows.1.2.1\lib\Net45\ICSharpCode.SharpZipLib.dll True + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + True + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + True + ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll True @@ -42,6 +84,10 @@ ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll True + + ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll + True + ..\packages\squirrel.windows.1.2.1\lib\Net45\NuGet.Squirrel.dll True @@ -58,6 +104,17 @@ + + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll + True + + + ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll + True + + @@ -141,6 +198,10 @@ {699FB638-CE02-48D7-8078-30A7939C5BCB} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + ..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + True + @@ -270,6 +331,9 @@ UserControl + + UserControl + UserControl @@ -989,6 +1053,10 @@ WeblogConfigurationWizardPanelSelectProvider.cs Designer + + WeblogConfigurationWizardPanelGoogleBloggerAuthentication.cs + Designer + WeblogConfigurationWizardPanelSharePointAuthentication.cs Designer @@ -1612,4 +1680,11 @@ + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/packages.config b/src/managed/OpenLiveWriter.PostEditor/packages.config index a31960ee..fab1fa0e 100644 --- a/src/managed/OpenLiveWriter.PostEditor/packages.config +++ b/src/managed/OpenLiveWriter.PostEditor/packages.config @@ -1,7 +1,18 @@  + + + + + + + + + + + \ No newline at end of file