Esempio n. 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                using (new WaitCursor())
                {
                    string newBlogId = WeblogConfigurationWizardController.Add(FindForm(), false);
                    if (newBlogId != null)
                    {
                        // add the weblog
                        using (BlogSettings blogSettings = BlogSettings.ForBlogId(newBlogId))
                        {
                            ListViewItem item = listViewWeblogs.AddWeblogItem(blogSettings);

                            // select the item that was added
                            listViewWeblogs.SelectedItems.Clear();
                            item.Selected = true;

                            // set focus to the list
                            listViewWeblogs.Focus();
                        }
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                UnexpectedErrorMessage.Show(ex);
            }
        }
Esempio n. 2
0
        public ServiceUpdateSettingsDetectionContext(string blogId)
        {
            using (BlogSettings settings = BlogSettings.ForBlogId(blogId))
            {
                _blogId                  = blogId;
                _homepageUrl             = settings.HomepageUrl;
                _providerId              = settings.ProviderId;
                _manifestDownloadInfo    = settings.ManifestDownloadInfo;
                _hostBlogId              = settings.HostBlogId;
                _postApiUrl              = settings.PostApiUrl;
                _clientType              = settings.ClientType;
                _userOptionOverrides     = settings.UserOptionOverrides;
                _homepageOptionOverrides = settings.HomePageOverrides;

                _initialCategoryScheme = settings.OptionOverrides != null
                                        ? settings.OptionOverrides[BlogClientOptions.CATEGORY_SCHEME] as string
                                        : null;

                BlogCredentialsHelper.Copy(settings.Credentials, _credentials);

                using (Blog blog = new Blog(settings))
                    _blogSupportsCategories = blog.ClientOptions.SupportsCategories;

                _initialBlogSettingsContents = GetBlogSettingsContents(settings);
                _initialCategoriesContents   = GetCategoriesContents(settings.Categories);
            }
        }
 public SwitchWeblogMenuCommand(string blogId, bool latched)
 {
     _blogId = blogId;
     using (BlogSettings settings = BlogSettings.ForBlogId(_blogId))
         _caption = StringHelper.Ellipsis(settings.BlogName + "", 65);
     _latched = latched;
 }
Esempio n. 4
0
        public override void LoadItems()
        {
            items.Clear();
            selectedIndex = INVALID_INDEX;

            postInfo = (_isPost ? PostListCache.RecentPosts : PostListCache.Drafts);

            lock (_commandsLock)
            {
                for (int i = 0; i < _commands.Length && i < postInfo.Length; i++)
                {
                    PostInfo v = postInfo[i];
                    _commands[i].On                 = true;
                    _commands[i].Enabled            = true;
                    _commands[i].LabelTitle         = v.Title;
                    _commands[i].LabelDescription   = v.BlogName;
                    _commands[i].TooltipTitle       = v.Title;
                    _commands[i].TooltipDescription = v.BlogName;
                    using (BlogSettings bs = BlogSettings.ForBlogId(v.BlogId))
                    {
                        _commands[i].LargeImage = (bs.ClientType.Contains("WordPress") ? Images.WordPressPost_LargeImage
                                                       : Images.OtherBlogPost_LargeImage);
                    }
                    items.Add(new GalleryItem(v.Title, null, _commands[i]));
                }
            }

            base.LoadItems();
        }
Esempio n. 5
0
 public WeblogBlogFileUploader(string destinationContext, string postContext, string localBlogId, string remoteBlogId)
     : base(destinationContext,
            postContext,
            remoteBlogId)
 {
     _blogSettings    = BlogSettings.ForBlogId(localBlogId);
     _blogClient      = BlogClientManager.CreateClient(_blogSettings);
     _blogHomepageUrl = _blogSettings.HomepageUrl;
 }
Esempio n. 6
0
 /// <summary>
 /// Returns the file upload destination context string for the specified blog based on its upload settings.
 /// (used for persisting upload information in the ISupportingFile).
 /// </summary>
 /// <param name="blogId"></param>
 /// <returns></returns>
 public static string GetFileUploadDestinationContext(string blogId)
 {
     using (BlogSettings blogSettings = BlogSettings.ForBlogId(blogId))
     {
         IBlogFileUploadSettings uploadSettings    = blogSettings.FileUploadSettings;
         FileUploadSupport       fileUploadSupport = blogSettings.FileUploadSupport;
         return(GetFileUploadDestinationContext(blogId, fileUploadSupport, uploadSettings));
     }
 }
Esempio n. 7
0
        private void Main()
        {
            try
            {
                // delay the check for updates
                Thread.Sleep(1000);

                // only run one service-update at a time process wide
                lock (_serviceUpdateLock)
                {
                    // establish settings detection context
                    ServiceUpdateSettingsDetectionContext settingsDetectionContext = new ServiceUpdateSettingsDetectionContext(_blogId);

                    // fire-up a blog settings detector to query for changes
                    BlogSettingsDetector settingsDetector = new BlogSettingsDetector(settingsDetectionContext);
                    settingsDetector.SilentMode = true;
                    using (RegistryKey key = Registry.CurrentUser.OpenSubKey(ApplicationEnvironment.SettingsRootKeyName + @"\Weblogs\" + _blogId + @"\HomepageOptions"))
                    {
                        if (key != null)
                        {
                            settingsDetector.IncludeFavIcon            = false;
                            settingsDetector.IncludeCategories         = settingsDetectionContext.BlogSupportsCategories;
                            settingsDetector.UseManifestCache          = true;
                            settingsDetector.IncludeHomePageSettings   = false;
                            settingsDetector.IncludeCategoryScheme     = false;
                            settingsDetector.IncludeInsecureOperations = false;
                        }
                    }
                    settingsDetector.IncludeImageEndpoints = false;
                    settingsDetector.DetectSettings(SilentProgressHost.Instance);

                    // write the settings
                    using (ProcessKeepalive.Open())
                    {
                        using (BlogSettings settings = BlogSettings.ForBlogId(_blogId))
                            settings.ApplyUpdates(settingsDetectionContext);
                    }

                    // if changes were made then fire an event to notify the UI
                    if (settingsDetectionContext.HasUpdates)
                    {
                        _settingsChangedHandler(_blogId, false);
                    }
                }
            }
            catch (ManualKeepaliveOperationException)
            {
            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception during ServiceUpdateChecker.Main: " + ex.ToString());
            }
        }
        public static TemporaryBlogSettings ForBlogId(string blogId)
        {
            using (BlogSettings blogSettings = BlogSettings.ForBlogId(blogId))
            {
                TemporaryBlogSettings tempSettings = new TemporaryBlogSettings(blogId);
                tempSettings.IsNewWeblog          = false;
                tempSettings.IsSpacesBlog         = blogSettings.IsSpacesBlog;
                tempSettings.IsSharePointBlog     = blogSettings.IsSharePointBlog;
                tempSettings.IsGoogleBloggerBlog  = blogSettings.IsGoogleBloggerBlog;
                tempSettings.IsStaticSiteBlog     = blogSettings.IsStaticSiteBlog;
                tempSettings.HostBlogId           = blogSettings.HostBlogId;
                tempSettings.BlogName             = blogSettings.BlogName;
                tempSettings.HomepageUrl          = blogSettings.HomepageUrl;
                tempSettings.ForceManualConfig    = blogSettings.ForceManualConfig;
                tempSettings.ManifestDownloadInfo = blogSettings.ManifestDownloadInfo;
                tempSettings.SetProvider(blogSettings.ProviderId, blogSettings.ServiceName, blogSettings.PostApiUrl, blogSettings.ClientType);
                tempSettings.Credentials         = blogSettings.Credentials;
                tempSettings.LastPublishFailed   = blogSettings.LastPublishFailed;
                tempSettings.Categories          = blogSettings.Categories;
                tempSettings.Keywords            = blogSettings.Keywords;
                tempSettings.Authors             = blogSettings.Authors;
                tempSettings.Pages               = blogSettings.Pages;
                tempSettings.FavIcon             = blogSettings.FavIcon;
                tempSettings.Image               = blogSettings.Image;
                tempSettings.WatermarkImage      = blogSettings.WatermarkImage;
                tempSettings.OptionOverrides     = blogSettings.OptionOverrides;
                tempSettings.UserOptionOverrides = blogSettings.UserOptionOverrides;
                tempSettings.ButtonDescriptions  = blogSettings.ButtonDescriptions;
                tempSettings.HomePageOverrides   = blogSettings.HomePageOverrides;

                //set the save password flag
                tempSettings.SavePassword = blogSettings.Credentials.Password != null &&
                                            blogSettings.Credentials.Password != String.Empty;

                // file upload support
                tempSettings.FileUploadSupport = blogSettings.FileUploadSupport;

                // get ftp settings if necessary
                if (blogSettings.FileUploadSupport == FileUploadSupport.FTP)
                {
                    FtpUploaderSettings.Copy(blogSettings.FileUploadSettings, tempSettings.FileUploadSettings);
                }

                blogSettings.PublishingPluginSettings.CopyTo(tempSettings.PublishingPluginSettings);

                using (PostHtmlEditingSettings editSettings = new PostHtmlEditingSettings(blogId))
                {
                    tempSettings.TemplateFiles = editSettings.EditorTemplateHtmlFiles;
                }
                return(tempSettings);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// "It looks like the problem with the inline image is due to referrer checking.
        /// The thumbnail image being used is protected for display only on certain domains.
        /// These domains include *.blogspot.com and *.google.com.  This user is using a
        /// feature in Blogger which allows him to display his blog directly on his own
        /// domain, which will not pass the referrer checking.
        ///
        /// "The maximum size of a thumbnail image that can be displayed on non-*.blogspot.com
        /// domains is 800px. (blogs don't actually appear at *.google.com).  However, if you
        /// request a 800px thumbnail, and the image is less than 800px for the maximum
        /// dimension, then the original image will be returned without the referrer
        /// restrictions.  That sounds like it will work for you, so feel free to give it a
        /// shot and let me know if you have any further questions or problems."
        ///   -- Anonymous Google Employee
        /// </summary>
        private void PicasaRefererBlockingWorkaround(string blogId, FileUploadRole role, ref string srcUrl)
        {
            if (role == FileUploadRole.LinkedImage && Options.UsePicasaS1600h)
            {
                try
                {
                    int    lastSlash = srcUrl.LastIndexOf('/');
                    string srcUrl2   = srcUrl.Substring(0, lastSlash)
                                       + "/s1600-h"
                                       + srcUrl.Substring(lastSlash);
                    HttpWebRequest req = HttpRequestHelper.CreateHttpWebRequest(srcUrl2, true);
                    req.Method = "HEAD";
                    req.GetResponse().Close();
                    srcUrl = srcUrl2;
                    return;
                }
                catch (WebException we)
                {
                    Debug.Fail("Picasa s1600-h hack failed: " + we.ToString());
                }
            }

            try
            {
                if (!Options.UsePicasaImgMaxAlways)
                {
                    // This class doesn't have access to the homePageUrl, so this is a workaround to
                    // to get the homePageUrl while minimizing the amount of code we have to change (we're at MShip/ZBB)
                    foreach (string id in BlogSettings.GetBlogIds())
                    {
                        using (BlogSettings settings = BlogSettings.ForBlogId(id))
                        {
                            if (settings.ClientType == "BloggerAtom" && settings.HostBlogId == blogId)
                            {
                                switch (UrlHelper.GetDomain(settings.HomepageUrl).ToUpperInvariant())
                                {
                                case "BLOGSPOT.COM":
                                case "GOOGLE.COM":
                                    return;
                                }
                            }
                        }
                    }
                }
                srcUrl += ((srcUrl.IndexOf('?') >= 0) ? "&" : "?") + "imgmax=800";
            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected error while doing Picasa upload: " + ex.ToString());
            }
        }
        public static bool EditSettings(IWin32Window owner, string id, bool showAccountSettings, Type selectedPanel)
        {
            TemporaryBlogSettings temporaryBlogSettings = TemporaryBlogSettings.ForBlogId(id);

            if (EditSettings(owner, temporaryBlogSettings, showAccountSettings, selectedPanel))
            {
                using (BlogSettings blogSettings = BlogSettings.ForBlogId(id))
                    temporaryBlogSettings.Save(blogSettings);
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public static bool EditFtpImageUpload(IWin32Window owner, string id)
 {
     using (BlogSettings blogSettings = BlogSettings.ForBlogId(id))
     {
         DialogResult result = FTPSettingsForm.ShowFTPSettingsForm(owner, blogSettings);
         if (result == DialogResult.OK)
         {
             blogSettings.FileUploadSupport = FileUploadSupport.FTP;
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
        private void buttonLoadTemplate_Click(object sender, EventArgs e)
        {
            BlogSettings settings = BlogSettings.ForBlogId(_id);

            try
            {
                _templateFile = BlogTemplateDetector.DetectTemplate(this, settings);

                using (TextReader reader = new StreamReader(_templateFile, Encoding.UTF8))
                    textBoxTemplate.Text = reader.ReadToEnd();
            }
            catch (OperationCancelledException)
            {
                //user cancelled call.
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Esempio n. 13
0
        private string ShowBlogWizard(string caption, IWin32Window owner, out bool switchToWeblog)
        {
            // blog id to return
            string blogId = null;

            if (ShowDialog(owner, caption) == DialogResult.OK)
            {
                // save the blog settings
                using (BlogSettings blogSettings = BlogSettings.ForBlogId(_temporarySettings.Id))
                {
                    _temporarySettings.Save(blogSettings);
                    blogId = blogSettings.Id;
                }

                // note the last added weblog (for re-selection in subsequent invocations of the dialog)
                WeblogConfigurationWizardSettings.LastServiceName = _temporarySettings.ServiceName;
            }

            switchToWeblog = _temporarySettings.SwitchToWeblog;

            return(blogId);
        }
Esempio n. 14
0
        private void LoadData()
        {
            // take note of which profile is the default
            string defaultBlogId = BlogSettings.DefaultBlogId;

            BeginUpdate();

            Items.Clear();

            // load the profiles
            foreach (BlogDescriptor blog in BlogSettings.GetBlogs(true))
            {
                AddWeblogItem(BlogSettings.ForBlogId(blog.Id));
            }

            // select the first item in the list
            if (Items.Count > 0)
            {
                Items[0].Selected = true;
            }

            EndUpdate();
        }
 void IBlogCategorySettings.UpdateCategories(BlogPostCategory[] categories)
 {
     using (BlogSettings blogSettings = BlogSettings.ForBlogId(_targetBlog.Id))
         blogSettings.Categories = categories;
 }