private bool UpdateWeblog(bool publish)
        {
            using (new WaitCursor())
            {
                // save all pending edits
                if (!SaveToDrafts())
                    return false;

                // upload to the weblog
                using (UpdateWeblogProgressForm updateWeblogProgressForm =
                    new UpdateWeblogProgressForm(_mainFrameWindow, this, BlogPost.IsPage, BlogName, publish))
                {
                    updateWeblogProgressForm.PrePublish += PrePublishHooks;
                    updateWeblogProgressForm.Publishing += BeforePublish;
                    updateWeblogProgressForm.PostPublish += PostPublishHooks;

                    // show the progress form
                    DialogResult result = updateWeblogProgressForm.ShowDialog(_mainFrameWindow);

                    // return success or failure
                    if (result == DialogResult.OK)
                    {
                        return true;
                    }
                    else if (result == DialogResult.Abort)
                    {
                        if (updateWeblogProgressForm.CancelReason != null)
                            DisplayMessage.Show(MessageId.PublishCanceledByPlugin, _mainFrameWindow, updateWeblogProgressForm.CancelReason);
                        return false;
                    }
                    else
                    {
                        if (updateWeblogProgressForm.Exception != null)
                            Trace.Fail(updateWeblogProgressForm.Exception.ToString());

                        // if this was a failure to upload images using the Metaweblog API newMediaObject
                        // then provide a special error message form that allows the user to reconfigure
                        // their file upload settings to another destination (e.g. FTP)
                        if (updateWeblogProgressForm.Exception is BlogClientFileUploadNotSupportedException)
                        {
                            result = FileUploadFailedForm.Show(_mainFrameWindow, GetUniqueImagesInPost());
                            if (result == DialogResult.Yes)
                                _editingSite.ConfigureWeblogFtpUpload(Blog.Id);
                        }
                        else if (updateWeblogProgressForm.Exception is BlogClientOperationCancelledException)
                        {
                            // show no UI for operation cancelled
                            Debug.WriteLine("BlogClient operation cancelled");
                        }
                        else
                        {
                            _blog.DisplayException(_mainFrameWindow, updateWeblogProgressForm.Exception);
                        }

                        // return failure
                        return false;
                    }
                }
            }
        }