Esempio n. 1
0
 private static void UnderscoresLoaded(BackgroundRequest req)
 {
     lock (DelayedRequests)
     {
         DelayedRequests.Remove(req);
         UnderscoredTitles.Clear();
         foreach (Article a in (List <Article>)req.Result)
         {
             UnderscoredTitles.Add(a.Name);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Default constructor, typos being loaded on separate thread is optional
        /// </summary>
        /// <param name="loadThreaded">Whether to load typos on a new thread</param>
        /// <param name="provider">Typos provider to use</param>
        public RegExTypoFix(bool loadThreaded, ITyposProvider provider)
        {
            Source = provider;
            if (!loadThreaded)
            {
                MakeRegexes();
                return;
            }

            TypoThread = new BackgroundRequest(Complete);
            TypoThread.Execute(MakeRegexes);
        }
Esempio n. 3
0
        internal static void LoadUnderscores(params string[] cats)
        {
            BackgroundRequest r = new BackgroundRequest(UnderscoresLoaded)
            {
                HasUI = false
            };

            lock (DelayedRequests)
            {
                DelayedRequests.Add(r);
            }
            r.GetList(new CategoryListProvider(), cats);
        }
        private static void UploadFinishedArticlesToServerErrored(BackgroundRequest req)
        {
            AWB.StopProgressBar();
            AWB.StatusLabelText = "TypoScan reporting failed";
            isUploading         = false;

            if (req.ErrorException is System.IO.IOException)
            {
                Tools.WriteDebug("TypoScanAWBPlugin", req.ErrorException.Message);
            }
            else if (req.ErrorException is System.Net.WebException)
            {
                Tools.WriteDebug("TypoScanAWBPlugin", req.ErrorException.Message);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Starts the asyn getRoot call
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public IAsyncResult BeginGetRootRequest(AsyncCallback callback)
        {
            // build the request data structure
            BackgroundRequest request = new BackgroundRequest();

            request.callback           = callback;
            request.result             = new AsyncResultEx(request);
            request.OperationParameter = null;

            // add to threadpool
            ThreadPool.QueueUserWorkItem(GetRootRequestCallback, request);

            // return the result
            return(request.result);
        }
Esempio n. 6
0
        /// <summary>
        /// Starts the asyn get childs call
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public IAsyncResult BeginGetChildsRequest(AsyncCallback callback, ICloudDirectoryEntry parent)
        {
            // build the request data structure
            var request = new BackgroundRequest();

            request.callback           = callback;
            request.result             = new AsyncResultEx(request);
            request.OperationParameter = parent;

            // add to threadpool
            ThreadPool.QueueUserWorkItem(GetChildsRequestCallback, request);

            // return the result
            return(request.result);
        }
Esempio n. 7
0
        private void GetFileUriCallback(object state)
        {
            BackgroundRequest req = state as BackgroundRequest;

            try
            {
                req.OperationResult = m_dropBox.GetFileSystemObjectUrl(req.fileEntry.Name, req.fileEntry.Parent);
            }
            catch (Exception e)
            {
                var openRequest = req.result.AsyncState as BackgroundRequest;
                openRequest.OperationResult = null;
                openRequest.errorReason     = e;
            }

            req.callback(req.result);
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                timer.Enabled = false;
                RefreshCats();
                txtBacklog.Text = txtBacklog.Text.Replace("_", " ");

                ToDo.Clear();
                foreach (DataGridViewRow r in Grid.Rows)
                {
                    if (!r.IsNewRow && !string.IsNullOrEmpty((string)r.Cells[0].Value) &&
                        !ToDo.ContainsKey((string)r.Cells[0].Value))
                    {
                        ToDo.Add((string)r.Cells[0].Value, (string)r.Cells[1].Value);
                    }
                }

                BackgroundRequest req = new BackgroundRequest();
                if (ToDo.Count > 0)
                {
                    string[] cats = new string[ToDo.Count];
                    ToDo.Keys.CopyTo(cats, 0);
                    Enabled = false;

                    GetLists.QuietMode = true;
                    req.GetList(GetLists.From.Category, cats);

                    req.Wait();
                    GetLists.QuietMode = false;
                    Enabled            = true;

                    if (req.Result != null && req.Result is List <Article> )
                    {
                        CfdAWBPlugin.AWB.ListMaker.Add((List <Article>)req.Result);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Handle(ex);
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 9
0
        /// <summary>
        /// This method implements a asyncallback for the getroot
        /// request, which is describe in BeginGetRootRequest
        /// </summary>
        /// <param name="state"></param>
        private void GetRootRequestCallback(object state)
        {
            // cast the request
            BackgroundRequest req = state as BackgroundRequest;

            try
            {
                req.OperationResult = GetRoot();
            }
            catch (Exception e)
            {
                // failure to login
                var openRequest = req.result.AsyncState as BackgroundRequest;
                openRequest.OperationResult = null;
                openRequest.errorReason     = e;
            }

            // call the async callback
            req.callback(req.result);
        }
        /// <summary>
        /// Starts the asyn getRoot call
        /// </summary>
        /// <param name="callback"></param>        
        /// <returns></returns>
        public IAsyncResult BeginGetRootRequest(AsyncCallback callback)
        {
            // build the request data structure
            BackgroundRequest request = new BackgroundRequest();
            request.callback = callback;
            request.result = new AsyncResultEx(request);
            request.OperationParameter = null;

            // add to threadpool
            ThreadPool.QueueUserWorkItem(GetRootRequestCallback, request);

            // return the result
            return request.result;
        }
        /// <summary>
        /// Starts the asyn get childs call
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public IAsyncResult BeginGetChildsRequest(AsyncCallback callback, ICloudDirectoryEntry parent)
        {
            // build the request data structure
            BackgroundRequest request = new BackgroundRequest();
            request.callback = callback;
            request.result = new AsyncResultEx(request);
            request.OperationParameter = parent;

            // add to threadpool
            ThreadPool.QueueUserWorkItem(GetChildsRequestCallback, request);

            // return the result
            return request.result;            
        }
Esempio n. 12
0
 /// <summary>
 /// Checks to see if AWBUpdater.exe.new exists, if it does, replace it.
 /// If not, see if the version of AWB Updater is older than the version on the checkpage, and run AWBUpdater if so
 /// </summary>
 public static void Update()
 {
     Request = new BackgroundRequest();
     Request.Execute(UpdateFunc);
 }
Esempio n. 13
0
 /// <summary>
 /// Checks to see if AWBUpdater.exe.new exists, if it does, replace it.
 /// If not, see if the version of AWB Updater is older than the version on the checkpage, and run AWBUpdater if so
 /// </summary>
 public static void Update()
 {
     request = new BackgroundRequest();
     request.Execute(new ExecuteFunctionDelegate(UpdateFunc));
 }
Esempio n. 14
0
        public Uri EndGetFileUri(IAsyncResult result)
        {
            BackgroundRequest req = result.AsyncState as BackgroundRequest;

            return(req.OperationResult as Uri);
        }
Esempio n. 15
0
        /// <summary>
        /// Finishes the async getRoot call
        /// </summary>
        /// <param name="asyncResult"></param>
        /// <returns></returns>
        public ICloudDirectoryEntry EndGetRootRequest(IAsyncResult asyncResult)
        {
            BackgroundRequest req = asyncResult.AsyncState as BackgroundRequest;

            return(req.OperationResult as ICloudDirectoryEntry);
        }
Esempio n. 16
0
        /// <summary>
        /// Finishes the async get childs call
        /// </summary>
        /// <param name="asyncResult"></param>
        /// <returns></returns>
        public List <ICloudFileSystemEntry> EndGetChildsRequest(IAsyncResult asyncResult)
        {
            BackgroundRequest req = asyncResult.AsyncState as BackgroundRequest;

            return(req.OperationResult as List <ICloudFileSystemEntry>);
        }
 private static void UploadFinishedArticlesToServerFinished(BackgroundRequest req)
 {
     UploadResult(req.Result.ToString());
 }
Esempio n. 18
0
        /// <summary>
        /// Checks log in status, registered and version.
        /// </summary>
        public WikiStatusResult UpdateWikiStatus()
        {
            try
            {
                string strText = String.Empty;
                string strVersionPage;

                //this object loads a local checkpage on Wikia
                //it cannot be used to approve users, but it could be used to set some settings
                //such as underscores and pages to ignore
                WebControl webBrowserWikia = null;
                string     typoPostfix     = "";
                string     userGroups;

                Groups.Clear();

                if (Variables.IsWikia)
                {
                    webBrowserWikia = new WebControl();
                    webBrowserWikia.Navigate(Variables.URLLong +
                                             "index.php?title=Project:AutoWikiBrowser/CheckPage&action=edit");
                }

                //load version check page
                BackgroundRequest br = new BackgroundRequest();
                br.GetHTML(
                    "http://en.wikipedia.org/w/index.php?title=Wikipedia:AutoWikiBrowser/CheckPage/Version&action=raw");

                //load check page
                if (Variables.IsWikia)
                {
                    webBrowserLogin.Navigate(
                        "http://www.wikia.com/wiki/index.php?title=Wikia:AutoWikiBrowser/CheckPage&action=edit");
                }
                else if ((Variables.Project == ProjectEnum.wikipedia) && (Variables.LangCode == LangCodeEnum.ar))
                {
                    webBrowserLogin.Navigate(
                        "http://ar.wikipedia.org/w/index.php?title=%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D9%82%D8%A7%D8%A6%D9%85%D8%A9_%D8%A7%D9%84%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D9%88%D9%86_%D8%A7%D9%84%D9%85%D8%B3%D9%85%D9%88%D8%AD_%D9%84%D9%87%D9%85_%D8%A8%D8%A7%D8%B3%D8%AA%D8%AE%D8%AF%D8%A7%D9%85_%D8%A7%D9%84%D8%A3%D9%88%D8%AA%D9%88_%D9%88%D9%8A%D9%83%D9%8A_%D8%A8%D8%B1%D8%A7%D9%88%D8%B2%D8%B1&action=edit");
                }
                else
                {
                    webBrowserLogin.Navigate(Variables.URLLong +
                                             "index.php?title=Project:AutoWikiBrowser/CheckPage&action=edit");
                }

                //wait for both pages to load
                webBrowserLogin.Wait();
                strText = webBrowserLogin.GetArticleText();
                br.Wait();

                Variables.RTL = HeadRTL.IsMatch(webBrowserLogin.ToString());

                if (Variables.IsWikia)
                {
                    webBrowserWikia.Wait();
                    try
                    {
                        Variables.LangCode =
                            Variables.ParseLanguage(webBrowserWikia.GetScriptingVar("wgContentLanguage"));
                    }
                    catch
                    {
                        // use English if language not recognized
                        Variables.LangCode = LangCodeEnum.en;
                    }
                    typoPostfix = "-" + Variables.ParseLanguage(webBrowserWikia.GetScriptingVar("wgContentLanguage"));
                    string s = webBrowserWikia.GetArticleText();

                    // selectively add content of the local checkpage to the global one
                    strText += Message.Match(s).Value
                               /*+ Underscores.Match(s).Value*/
                               + WikiRegexes.NoGeneralFixes.Match(s);

                    userGroups = webBrowserWikia.GetScriptingVar("wgUserGroups");
                }
                else
                {
                    userGroups = webBrowserLogin.GetScriptingVar("wgUserGroups");
                }

                bLoaded = true;

                if (Variables.IsCustomProject)
                {
                    try
                    {
                        Variables.LangCode =
                            Variables.ParseLanguage(webBrowserLogin.GetScriptingVar("wgContentLanguage"));
                    }
                    catch
                    {
                        // use English if language not recognized
                        Variables.LangCode = LangCodeEnum.en;
                    }
                }

                strVersionPage = (string)br.Result;

                //see if this version is enabled
                if (!strVersionPage.Contains(AWBVersion + " enabled"))
                {
                    IsBot = IsAdmin = WikiStatus = false;
                    return(WikiStatusResult.OldVersion);
                }

                // else
                if (!WeAskedAboutUpdate && strVersionPage.Contains(AWBVersion + " enabled (old)"))
                {
                    WeAskedAboutUpdate = true;
                    if (
                        MessageBox.Show(
                            "This version has been superceeded by a new version.  You may continue to use this version or update to the newest version.\r\n\r\nWould you like to automatically upgrade to the newest version?",
                            "Upgrade?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Match m_version = Regex.Match(strVersionPage, @"<!-- Current version: (.*?) -->");
                        if (m_version.Success && m_version.Groups[1].Value.Length == 4)
                        {
                            System.Diagnostics.Process.Start(Path.GetDirectoryName(Application.ExecutablePath) +
                                                             "\\AWBUpdater.exe");
                        }
                        else if (
                            MessageBox.Show("Error automatically updating AWB.  Load the download page instead?",
                                            "Load download page?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            Tools.OpenURLInBrowser("http://sourceforge.net/project/showfiles.php?group_id=158332");
                        }
                    }
                }

                CheckPageText = strText;

                //AWB does not support any skin other than Monobook
                string skin = webBrowserLogin.GetScriptingVar("skin");
                if (skin == "cologneblue")
                {
                    MessageBox.Show("This software does not support the Cologne Blue skin." +
                                    "\r\nPlease choose another skin in your preferences and relogin.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return(WikiStatusResult.Null);
                }

                //see if we are logged in
                this.Name = webBrowserLogin.UserName;
                if (string.IsNullOrEmpty(Name))
                {
                    // don't run GetInLogInStatus if we don't have the username, we sometimes get 2 error message boxes otherwise
                    LoggedIn = false;
                }
                else
                {
                    LoggedIn = webBrowserLogin.GetLogInStatus();
                }

                if (!LoggedIn)
                {
                    IsBot = IsAdmin = WikiStatus = false;
                    return(WikiStatusResult.NotLoggedIn);
                }

                // check if username is globally blacklisted
                foreach (
                    Match m3 in Regex.Matches(strVersionPage, @"badname:\s*(.*)\s*(:?|#.*)$", RegexOptions.IgnoreCase))
                {
                    if (!string.IsNullOrEmpty(m3.Groups[1].Value.Trim()) &&
                        Regex.IsMatch(Name, m3.Groups[1].Value.Trim(),
                                      RegexOptions.IgnoreCase | RegexOptions.Multiline))
                    {
                        return(WikiStatusResult.NotRegistered);
                    }
                }

                //see if there is a message
                Match m = Message.Match(strText);
                if (m.Success && m.Groups[1].Value.Trim().Length > 0)
                {
                    MessageBox.Show(m.Groups[1].Value, "Automated message", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                //see if there is a version-specific message
                m = VersionMessage.Match(strText);
                if (m.Success && m.Groups[1].Value.Trim().Length > 0 && m.Groups[1].Value == AWBVersion)
                {
                    MessageBox.Show(m.Groups[2].Value, "Automated message", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                m = Regex.Match(strText, "<!--[Tt]ypos" + typoPostfix + ":(.*?)-->");
                if (m.Success && m.Groups[1].Value.Trim().Length > 0)
                {
                    Variables.RETFPath = m.Groups[1].Value.Trim();
                }

                //List<string> us = new List<string>();
                //foreach (Match m1 in Underscores.Matches(strText))
                //{
                //    if (m1.Success && m1.Groups[1].Value.Trim().Length > 0)
                //        us.Add(m1.Groups[1].Value.Trim());
                //}
                //if (us.Count > 0) Variables.LoadUnderscores(us.ToArray());

                Regex r = new Regex("\"([a-z]*)\"[,\\]]");

                foreach (Match m1 in r.Matches(userGroups))
                {
                    Groups.Add(m1.Groups[1].Value);
                }

                //don't require approval if checkpage does not exist.
                if (strText.Length < 1)
                {
                    WikiStatus = true;
                    IsBot      = true;
                    return(WikiStatusResult.Registered);
                }

                if (strText.Contains("<!--All users enabled-->"))
                {
//see if all users enabled
                    WikiStatus = true;
                    IsBot      = true;
                    IsAdmin    = Groups.Contains("sysop");
                    return(WikiStatusResult.Registered);
                }

                //see if we are allowed to use this softare
                strText = Tools.StringBetween(strText, "<!--enabledusersbegins-->", "<!--enabledusersends-->");

                string strBotUsers = Tools.StringBetween(strText, "<!--enabledbots-->", "<!--enabledbotsends-->");
                string strAdmins   = Tools.StringBetween(strText, "<!--adminsbegins-->", "<!--adminsends-->");
                Regex  username    = new Regex(@"^\*\s*" + Tools.CaseInsensitive(Variables.User.Name)
                                               + @"\s*$", RegexOptions.Multiline);

                if (Groups.Contains("sysop") || Groups.Contains("staff"))
                {
                    WikiStatus = IsAdmin = true;
                    IsBot      = username.IsMatch(strBotUsers);
                    return(WikiStatusResult.Registered);
                }

                if (Name.Length > 0 && username.IsMatch(strText))
                {
                    //enable botmode
                    IsBot = username.IsMatch(strBotUsers);

                    //enable admin features
                    IsAdmin = username.IsMatch(strAdmins);

                    WikiStatus = true;

                    return(WikiStatusResult.Registered);
                }

                IsBot = IsAdmin = WikiStatus = false;
                return(WikiStatusResult.NotRegistered);
            }
            catch (Exception ex)
            {
                Tools.WriteDebug(ToString(), ex.Message);
                Tools.WriteDebug(ToString(), ex.StackTrace);
                IsBot = IsAdmin = WikiStatus = false;
                return(WikiStatusResult.Error);
            }
        }
Esempio n. 19
0
        private object DoWork(BackgroundRequest request, BackgroundWorker worker, DoWorkEventArgs e)
        {
            object result = null;

            if (worker.CancellationPending)
            {
                e.Cancel = true;
            }
            else
            {
                switch (request.Name)
                {
                case CommandName.Connect:
                    var computerName = txtComputerName.Text;
                    var port         = int.Parse(txtPort.Text);
                    var username     = txtUsername.Text;
                    var password     = txtPassword.Text;
                    if (rdbAuthBasic.Checked)
                    {
                        _machineManager = new MachineManager(computerName, port, username, password.ToSecureString(), AuthenticationMechanism.Basic);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
                        {
                            _machineManager = new MachineManager(computerName, port);
                        }
                        else
                        {
                            _machineManager = new MachineManager(computerName, port, username, password.ToSecureString(), AuthenticationMechanism.Default);
                        }
                    }
                    _machineManager.EnterSession();
                    result = new BackgroundResult
                    {
                        Name = CommandName.Connect
                    };
                    break;

                case CommandName.Disconnect:
                    _machineManager?.ExitSession();
                    result = new BackgroundResult
                    {
                        Name = CommandName.Disconnect
                    };
                    break;

                case CommandName.Upload:
                    _machineManager.CopyFileToSession(request.Request[0].ToString(), request.Request[1].ToString());
                    result = new BackgroundResult
                    {
                        Name = CommandName.Upload
                    };
                    break;

                case CommandName.Download:
                    _machineManager.CopyFileFromSession(request.Request[0].ToString(), request.Request[1].ToString());
                    result = new BackgroundResult
                    {
                        Name = CommandName.Download
                    };
                    break;

                case CommandName.Delete:
                    _machineManager.RemoveFileFromSession(request.Request[0].ToString());
                    result = new BackgroundResult
                    {
                        Name   = CommandName.Delete,
                        Result = request.Request[0]
                    };
                    break;

                case CommandName.Rename:
                    _machineManager.RenameFileFromSession(request.Request[0].ToString(), request.Request[1].ToString());
                    result = new BackgroundResult
                    {
                        Name   = CommandName.Rename,
                        Result = request.Request[0]
                    };
                    break;

                case CommandName.Extract:
                    _machineManager.ExtractFileFromSession(request.Request[0].ToString(), request.Request[1].ToString());
                    result = new BackgroundResult
                    {
                        Name   = CommandName.Extract,
                        Result = request.Request[0]
                    };
                    break;

                case CommandName.RefreshFiles:
                    result = new BackgroundResult
                    {
                        Name   = CommandName.RefreshFiles,
                        Result = _machineManager.LoadFilesCommand(request.Request[0].ToString())
                    };
                    break;

                case CommandName.RefreshDirectories:
                    result = new BackgroundResult
                    {
                        Name   = CommandName.RefreshDirectories,
                        Result = _machineManager.LoadDirectoriesCommand(request.Request[0].ToString())
                    };
                    break;

                case CommandName.RefreshDrives:
                    result = new BackgroundResult
                    {
                        Name   = CommandName.RefreshDrives,
                        Result = _machineManager.LoadDrives()
                    };
                    break;

                case CommandName.ProgressChanged:
                    result = new BackgroundResult
                    {
                        Name   = CommandName.ProgressChanged,
                        Result = request.Request[0]
                    };
                    break;
                }
            }

            return(result);
        }
Esempio n. 20
0
        /// <summary>
        /// Checks log in status, registered and version.
        /// </summary>
        private WikiStatusResult UpdateWikiStatus()
        {
            try
            {
                string typoPostfix = "";

                IsBot = false;

                //TODO: login?
                Site = new SiteInfo(Editor);

                //load version check page
                BackgroundRequest versionRequest = new BackgroundRequest();
                versionRequest.GetHTML(
                    "http://en.wikipedia.org/w/index.php?title=Wikipedia:AutoWikiBrowser/CheckPage/Version&action=raw");

                //load check page
                string url;
                if (Variables.IsWikia)
                {
                    url = "http://www.wikia.com/wiki/index.php?title=Wikia:AutoWikiBrowser/CheckPage&action=edit";
                }
                else if ((Variables.Project == ProjectEnum.wikipedia) && (Variables.LangCode == LangCodeEnum.ar))
                {
                    url = "http://ar.wikipedia.org/w/index.php?title=%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D8%A7%D9%84%D8%A3%D9%88%D8%AA%D9%88%D9%88%D9%8A%D9%83%D9%8A_%D8%A8%D8%B1%D8%A7%D9%88%D8%B2%D8%B1/%D9%85%D8%B3%D9%85%D9%88%D8%AD&action=edit";
                }
                else
                {
                    url = Variables.URLIndex + "?title=Project:AutoWikiBrowser/CheckPage&action=edit";
                }

                string strText = Editor.SynchronousEditor.HttpGet(url);

                Variables.RTL = Site.IsRightToLeft;

                if (Variables.IsCustomProject || Variables.IsWikia)
                {
                    try
                    {
                        Variables.LangCode =
                            Variables.ParseLanguage(Site.Language);
                    }
                    catch
                    {
                        // use English if language not recognized
                        Variables.LangCode = LangCodeEnum.en;
                    }
                }

                if (Variables.IsWikia)
                {
                    //this object loads a local checkpage on Wikia
                    //it cannot be used to approve users, but it could be used to set some settings
                    //such as underscores and pages to ignore
                    AsyncApiEdit editWikia = (AsyncApiEdit)Editor.Clone();
                    SiteInfo     wikiaInfo = new SiteInfo();
                    string       s         = editWikia.SynchronousEditor.Open("Project:AutoWikiBrowser/CheckPage");

                    typoPostfix = "-" + Variables.LangCode;

                    // selectively add content of the local checkpage to the global one
                    strText += Message.Match(s).Value
                               /*+ Underscores.Match(s).Value*/
                               + WikiRegexes.NoGeneralFixes.Match(s);
                }

                versionRequest.Wait();
                string strVersionPage = (string)versionRequest.Result;

                //see if this version is enabled
                if (!strVersionPage.Contains(AWBVersion + " enabled"))
                {
                    return(WikiStatusResult.OldVersion);
                }

                //TODO:
                // else
                //if (!WeAskedAboutUpdate && strVersionPage.Contains(AWBVersion + " enabled (old)"))
                //{
                //    WeAskedAboutUpdate = true;
                //    if (
                //        MessageBox.Show(
                //            "This version has been superceeded by a new version.  You may continue to use this version or update to the newest version.\r\n\r\nWould you like to automatically upgrade to the newest version?",
                //            "Upgrade?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                //    {
                //        Match version = Regex.Match(strVersionPage, @"<!-- Current version: (.*?) -->");
                //        if (version.Success && version.Groups[1].Value.Length == 4)
                //        {
                //            System.Diagnostics.Process.Start(Path.GetDirectoryName(Application.ExecutablePath) +
                //                                             "\\AWBUpdater.exe");
                //        }
                //        else if (
                //            MessageBox.Show("Error automatically updating AWB. Load the download page instead?",
                //                            "Load download page?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                //        {
                //            Tools.OpenURLInBrowser("http://sourceforge.net/project/showfiles.php?group_id=158332");
                //        }
                //    }
                //}

                CheckPageText = strText;

                // don't run GetInLogInStatus if we don't have the username, we sometimes get 2 error message boxes otherwise
                bool loggedIn = Editor.User.IsRegistered;

                if (!loggedIn)
                {
                    return(WikiStatusResult.NotLoggedIn);
                }

                // check if username is globally blacklisted
                foreach (
                    Match m3 in Regex.Matches(strVersionPage, @"badname:\s*(.*)\s*(:?|#.*)$", RegexOptions.IgnoreCase))
                {
                    if (!string.IsNullOrEmpty(m3.Groups[1].Value.Trim()) &&
                        !string.IsNullOrEmpty(Editor.User.Name) &&
                        Regex.IsMatch(Editor.User.Name, m3.Groups[1].Value.Trim(),
                                      RegexOptions.IgnoreCase | RegexOptions.Multiline))
                    {
                        return(WikiStatusResult.NotRegistered);
                    }
                }

                //see if there is a message
                Match m = Message.Match(strText);
                if (m.Success && m.Groups[1].Value.Trim().Length > 0)
                {
                    MessageBox.Show(m.Groups[1].Value, "Automated message", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                //see if there is a version-specific message
                m = VersionMessage.Match(strText);
                if (m.Success && m.Groups[1].Value.Trim().Length > 0 && m.Groups[1].Value == AWBVersion)
                {
                    MessageBox.Show(m.Groups[2].Value, "Automated message", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                m = Regex.Match(strText, "<!--[Tt]ypos" + typoPostfix + ":(.*?)-->");
                if (m.Success && m.Groups[1].Value.Trim().Length > 0)
                {
                    Variables.RetfPath = m.Groups[1].Value.Trim();
                }

                List <string> us = new List <string>();
                foreach (Match m1 in Underscores.Matches(strText))
                {
                    if (m1.Success && m1.Groups[1].Value.Trim().Length > 0)
                    {
                        us.Add(m1.Groups[1].Value.Trim());
                    }
                }
                if (us.Count > 0)
                {
                    Variables.LoadUnderscores(us.ToArray());
                }

                //don't require approval if checkpage does not exist.
                if (strText.Length < 1)
                {
                    IsBot = true;
                    return(WikiStatusResult.Registered);
                }

                if (strText.Contains("<!--All users enabled-->"))
                {
                    //see if all users enabled
                    IsBot = true;
                    return(WikiStatusResult.Registered);
                }

                //see if we are allowed to use this softare
                strText = Tools.StringBetween(strText, "<!--enabledusersbegins-->", "<!--enabledusersends-->");

                string strBotUsers = Tools.StringBetween(strText, "<!--enabledbots-->", "<!--enabledbotsends-->");
                Regex  username    = new Regex(@"^\*\s*" + Tools.CaseInsensitive(Editor.User.Name)
                                               + @"\s*$", RegexOptions.Multiline);

                if (IsSysop)
                {
                    IsBot = username.IsMatch(strBotUsers);
                    return(WikiStatusResult.Registered);
                }

                if (!string.IsNullOrEmpty(Editor.User.Name) && username.IsMatch(strText))
                {
                    //enable bot mode
                    IsBot = username.IsMatch(strBotUsers);

                    return(WikiStatusResult.Registered);
                }

                return(WikiStatusResult.NotRegistered);
            }
            catch (Exception ex)
            {
                Tools.WriteDebug(ToString(), ex.Message);
                Tools.WriteDebug(ToString(), ex.StackTrace);
                IsBot = false;
                return(WikiStatusResult.Error);
            }
        }