Пример #1
0
        /// <summary>
        /// Checks certain file existances, etc.
        /// </summary>
        /// <returns></returns>
        private void BootChecks()
        {
            //Check if correct thread...
            if (this.InvokeRequired)
            {
                Debug.WriteLine("InvokeRequired...");
                BootChecksCallback bcc = new BootChecksCallback(BootChecks);
                this.Invoke(bcc);
                return;
            }

            /* Check for DSi common key bin file...
            if (NUSDFileExists("dsikey.bin") == true)
            {
                WriteStatus("DSi Common Key detected.");
                dsidecrypt = true;
            }*/
            /*
            // Check for database.xml
            if (NUSDFileExists("database.xml") == false)
            {
                WriteStatus("Database.xml not found. Title database not usable!");
                DatabaseEnabled(false);
                updateDatabaseToolStripMenuItem.Enabled = true;
                updateDatabaseToolStripMenuItem.Visible = true;
                updateDatabaseToolStripMenuItem.Text = "Download Database";
            }
            else
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("Database.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                //databaseButton.Enabled = false;
                //databaseButton.Text = "DB Loading";
                databaseButton.Text = "  [    ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.fds.RunWorkerAsync();
            }

            // Check for database.xml
            if (NUSDFileExists("dsidatabase.xml") == false)
            {
                WriteStatus("DSiDatabase.xml not found. DSi database not usable!");
                DatabaseEnabled(false);
                updateDatabaseToolStripMenuItem.Enabled = true;
                updateDatabaseToolStripMenuItem.Visible = true;
                updateDatabaseToolStripMenuItem.Text = "Download Database";
            }
            else
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("Database.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                //databaseButton.Enabled = false;
                //databaseButton.Text = "DB Loading";
                databaseButton.Text = "  [    ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.fds.RunWorkerAsync();
            }*/

            if (NUSDFileExists("database.xml") == true)
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("Database.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                databaseButton.Text = "  [    ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.databaseWorker.RunWorkerAsync();
            }

            if (NUSDFileExists("dsidatabase.xml") == true)
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "dsidatabase.xml"));
                string version = db.GetDatabaseVersion();
                WriteStatus("DSiDatabase.xml detected.");
                WriteStatus(" - Version: " + version);
                updateDatabaseToolStripMenuItem.Text = "Update Database";
                databaseButton.Text = "    [  ]";
                databaseButton.Image = Properties.Resources.arrow_ticker;
                // Load it up...
                this.dsiDatabaseWorker.RunWorkerAsync();
            }

            // Load scripts (local)
            RunScriptOrganizer();

            // Check for Proxy Settings file...
            if (NUSDFileExists("proxy.txt") == true)
            {
                WriteStatus("Proxy settings detected.");
                string[] proxy_file = File.ReadAllLines(Path.Combine(CURRENT_DIR, "proxy.txt"));
                proxy_url = proxy_file[0];

                // If proxy\nuser\npassword
                if (proxy_file.Length > 2)
                {
                    proxy_usr = proxy_file[1];
                    proxy_pwd = proxy_file[2];
                }
                else if (proxy_file.Length > 1)
                {
                    proxy_usr = proxy_file[1];
                    SetAllEnabled(false);
                    ProxyVerifyBox.Visible = true;
                    ProxyVerifyBox.Enabled = true;
                    ProxyPwdBox.Enabled = true;
                    SaveProxyBtn.Enabled = true;
                    ProxyVerifyBox.Select();
                }
            }
        }
Пример #2
0
        private void FillDatabaseScripts()
        {
            SetPropertyThreadSafe(scriptsDatabaseToolStripMenuItem, false, "Visible");
            Database databaseObj = new Database();
            databaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));

            ToolStripMenuItem[] scriptItems = databaseObj.LoadScripts();
            for (int a = 0; a < scriptItems.Length; a++)
            {
                scriptItems[a].Click += new EventHandler(ScriptItem_Clicked);
                
                //AddToolStripItemToStrip(scriptsDatabaseToolStripMenuItem, scriptItems[a]);
                //SystemMenuList.DropDownItems.Add(systemItems[a]);
            }
            AddToolStripItemToStrip(scriptsDatabaseToolStripMenuItem, scriptItems);
            SetPropertyThreadSafe(scriptsDatabaseToolStripMenuItem, true, "Enabled");
            SetPropertyThreadSafe(scriptsDatabaseToolStripMenuItem, true, "Visible");
        }
Пример #3
0
        private void RetrieveNewDatabase_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            string database = e.Result.ToString();

            string databaseFilename = "";
            if (database.Contains("DSISYSTEM"))
            {
                databaseFilename = "dsidatabase.xml";
            }
            else if (database.Contains("0000000100000002"))
            {
                databaseFilename = "database.xml";
            }

            try
            {
                Database db = new Database();
                db.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, databaseFilename));
                string currentversion = db.GetDatabaseVersion();
                string onlineversion = Database.GetDatabaseVersion(database);
                WriteStatus(String.Format(" - Database successfully parsed! ({0})", databaseFilename));
                WriteStatus("   - Current Database Version: " + currentversion);
                WriteStatus("   - Online Database Version: " + onlineversion);

                if (currentversion == onlineversion)
                {
                    WriteStatus(" - You have the latest database version!");
                    return;
                }
            }
            catch (FileNotFoundException)
            {
                WriteStatus(" - Database does not yet exist.");
                WriteStatus("   - Online Database Version: " + Database.GetDatabaseVersion(database));
            }

            bool isCreation = false;
            if (File.Exists(databaseFilename))
            {
                WriteStatus(" - Overwriting your current database...");
                WriteStatus(String.Format(" - The old database will become 'old{0}' in case the new one is faulty.", databaseFilename));

                string olddatabase = File.ReadAllText(databaseFilename);
                File.WriteAllText("old" + databaseFilename, olddatabase);
                File.Delete(databaseFilename);
                File.WriteAllText(databaseFilename, database);
            }
            else
            {
                WriteStatus(String.Format(" - {0} has been created.", databaseFilename));
                File.WriteAllText(databaseFilename, database);
                isCreation = true;
            }

            // Load it up...
            this.databaseWorker.RunWorkerAsync();

            if (isCreation)
            {
                WriteStatus("Database successfully created!");
                databaseButton.Visible = true;
                //databaseButton.Enabled = false;
                updateDatabaseToolStripMenuItem.Text = "Download Database";
            }
            else
            {
                WriteStatus("Database successfully updated!");
            }
        }
Пример #4
0
        /// <summary>
        /// Loads the region codes.
        /// </summary>
        private void LoadRegionCodes()
        {
            // TODO: make this check InvokeRequired...
            if (this.InvokeRequired)
            {
                BootChecksCallback bcc = new BootChecksCallback(LoadRegionCodes);
                this.Invoke(bcc);
                return;
            }

            wiiRegionCodesMenu.DropDownItems.Clear();
            dsiRegionCodesMenu.DropDownItems.Clear();

            Database databaseObj = new Database();
            databaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));

            ToolStripMenuItem[] regionItems = databaseObj.LoadRegionCodes();

            // For each child node (region node)
            for (int z = 0; z < regionItems.Length; z++)
            {
                wiiRegionCodesMenu.DropDownItems.Add(regionItems[z].Text);
            }

            Database dsiDatabaseObj = new Database();
            dsiDatabaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "dsidatabase.xml"));

            ToolStripMenuItem[] dsiRegionItems = dsiDatabaseObj.LoadRegionCodes();

            // For each child node (region node)
            for (int z = 0; z < dsiRegionItems.Length; z++)
            {
                dsiRegionCodesMenu.DropDownItems.Add(dsiRegionItems[z].Text);
            }
        } 
Пример #5
0
        /// <summary>
        /// Fills the database strip with the local database.xml file.
        /// </summary>
        private void FillDSiDatabaseStrip(BackgroundWorker worker)
        {
            // Set fake items visible and real ones not. Only way to stop buggy enabled stuff.
            SetPropertyThreadSafe(dsiSystemToolStripMenu, false, "Visible");
            SetPropertyThreadSafe(dSiWareToolStripMenu, false, "Visible");

            SetPropertyThreadSafe(dsiFakeSystemToolStripMenu, true, "Visible");
            SetPropertyThreadSafe(dSiWareFakeToolStripMenu, true, "Visible");

            Database databaseObj = new Database();
            databaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "dsidatabase.xml"));

            ToolStripMenuItem[] systemItems = databaseObj.LoadDSiSystemTitles();
            for (int a = 0; a < systemItems.Length; a++)
            {
                systemItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                for (int b = 0; b < systemItems[a].DropDownItems.Count; b++)
                {
                    ToolStripMenuItem syslowerentry = (ToolStripMenuItem)systemItems[a].DropDownItems[b];
                    if (syslowerentry.DropDownItems.Count > 0)
                    {
                        syslowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                    }
                }
            }
            Array.Sort(systemItems, delegate(ToolStripMenuItem tsmi1, ToolStripMenuItem tsmi2)
            {
                return tsmi1.Text
                        .Substring(18, tsmi1.Text.Length - 19).CompareTo(tsmi2.Text.Substring(18, tsmi2.Text.Length - 19));
            });
            AddToolStripItemToStrip(dsiSystemToolStripMenu, systemItems);

            SetPropertyThreadSafe(dsiFakeSystemToolStripMenu, false, "Visible");
            SetPropertyThreadSafe(dsiSystemToolStripMenu, true, "Visible");

            Debug.WriteLine("Database: DSiSysTitles added");
            worker.ReportProgress(50);

            ToolStripMenuItem[] dsiWareItems = databaseObj.LoadDsiWareTitles();
            for (int a = 0; a < dsiWareItems.Length; a++)
            {
                dsiWareItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                for (int b = 0; b < dsiWareItems[a].DropDownItems.Count; b++)
                {
                    ToolStripMenuItem lowerentry = (ToolStripMenuItem)dsiWareItems[a].DropDownItems[b];
                    if (lowerentry.DropDownItems.Count > 0)
                    {
                        lowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                    }

                }
            }
            Array.Sort(dsiWareItems, delegate(ToolStripMenuItem tsmi1, ToolStripMenuItem tsmi2)
            {
                return tsmi1.Text
                        .Substring(18, tsmi1.Text.Length - 19).CompareTo(tsmi2.Text.Substring(18, tsmi2.Text.Length - 19));
            });
            AddToolStripItemToStrip(dSiWareToolStripMenu, dsiWareItems);

            SetPropertyThreadSafe(dSiWareFakeToolStripMenu, false, "Visible");
            SetPropertyThreadSafe(dSiWareToolStripMenu, true, "Visible");
            Debug.WriteLine("Database: DSiWareTitles added");
            worker.ReportProgress(100);
        }
Пример #6
0
        /// <summary>
        /// Fills the database strip with the local database.xml file.
        /// </summary>
        private void FillDatabaseStrip(BackgroundWorker worker)
        {
            // Something needs to be done to remove this i guess
            //Control.CheckForIllegalCrossThreadCalls = false;

            // Set fake items visible and real ones not. Only way to stop buggy enabled stuff.
            SetPropertyThreadSafe(SystemMenuList, false, "Visible");
            SetPropertyThreadSafe(IOSMenuList, false, "Visible");
            SetPropertyThreadSafe(VCMenuList, false, "Visible");
            SetPropertyThreadSafe(WiiWareMenuList, false, "Visible");

            SetPropertyThreadSafe(systemFakeMenuItem, true, "Visible");
            SetPropertyThreadSafe(iosFakeMenuItem, true, "Visible");
            SetPropertyThreadSafe(vcFakeMenuItem, true, "Visible");
            SetPropertyThreadSafe(wwFakeMenuItem, true, "Visible");

            Database databaseObj = new Database();
            databaseObj.LoadDatabaseToStream(Path.Combine(CURRENT_DIR, "database.xml"));

            ToolStripMenuItem[] systemItems = databaseObj.LoadSystemTitles();
            for (int a = 0; a < systemItems.Length; a++)
            {
                systemItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                for (int b = 0; b < systemItems[a].DropDownItems.Count; b++)
                {
                    ToolStripMenuItem syslowerentry = (ToolStripMenuItem)systemItems[a].DropDownItems[b];
                    if (syslowerentry.DropDownItems.Count > 0)
                    {
                        syslowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                    }
                }
                //AddToolStripItemToStrip(SystemMenuList, systemItems[a]);
                //SystemMenuList.DropDownItems.Add(systemItems[a]);
            }
            Array.Sort(systemItems, delegate(ToolStripMenuItem tsmi1, ToolStripMenuItem tsmi2)
            {
                return tsmi1.Text
                        .Substring(18, tsmi1.Text.Length - 19).CompareTo(tsmi2.Text.Substring(18, tsmi2.Text.Length - 19));
            });
            AddToolStripItemToStrip(SystemMenuList, systemItems);

            SetPropertyThreadSafe(systemFakeMenuItem, false, "Visible");
            SetPropertyThreadSafe(SystemMenuList, true, "Visible");

            Debug.WriteLine("Database: SysTitles added");
            worker.ReportProgress(25);

            ToolStripMenuItem[] iosItems = databaseObj.LoadIosTitles();
            for (int a = 0; a < iosItems.Length; a++)
            {
                iosItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                //AddToolStripItemToStrip(IOSMenuList, iosItems[a]);
                //IOSMenuList.DropDownItems.Add(iosItems[a]);
            }
            AddToolStripItemToStrip(IOSMenuList, iosItems);

            SetPropertyThreadSafe(iosFakeMenuItem, false, "Visible");
            SetPropertyThreadSafe(IOSMenuList, true, "Visible");
            Debug.WriteLine("Database: IosTitles added");
            worker.ReportProgress(50);
            
            ToolStripMenuItem[][] vcItems = databaseObj.LoadVirtualConsoleTitles();
            for (int a = 0; a < vcItems.Length; a++)
            {
                for (int b = 0; b < vcItems[a].Length; b++)
			    {
                    vcItems[a][b].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                    for (int c = 0; c < vcItems[a][b].DropDownItems.Count; c++)
                    {
                        ToolStripMenuItem lowerentry = (ToolStripMenuItem)vcItems[a][b].DropDownItems[c];
                        lowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                    }
			    }
                Array.Sort(vcItems[a], delegate(ToolStripMenuItem tsmi1, ToolStripMenuItem tsmi2)
                {
                    return tsmi1.Text
                            .Substring(18, tsmi1.Text.Length - 19).CompareTo(tsmi2.Text.Substring(18, tsmi2.Text.Length - 19));
                });
                AddToolStripItemToStrip((ToolStripMenuItem)VCMenuList.DropDownItems[a], vcItems[a]);
            }
            
            SetPropertyThreadSafe(vcFakeMenuItem, false, "Visible");
            SetPropertyThreadSafe(VCMenuList, true, "Visible");
            Debug.WriteLine("Database: VCTitles added");
            worker.ReportProgress(75);
            
            ToolStripMenuItem[] wwItems = databaseObj.LoadWiiWareTitles();
            for (int a = 0; a < wwItems.Length; a++)
            {
                wwItems[a].DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                for (int b = 0; b < wwItems[a].DropDownItems.Count; b++)
                {
                    ToolStripMenuItem lowerentry = (ToolStripMenuItem)wwItems[a].DropDownItems[b];
                    if (lowerentry.DropDownItems.Count > 0)
                    {
                        lowerentry.DropDownItemClicked += new ToolStripItemClickedEventHandler(DatabaseItem_Clicked);
                    }
                    
                }
                //AddToolStripItemToStrip(WiiWareMenuList, wwItems[a]);
                //WiiWareMenuList.DropDownItems.Add(wwItems[a]);
            }
            Array.Sort(wwItems, delegate(ToolStripMenuItem tsmi1, ToolStripMenuItem tsmi2)
            {
                return tsmi1.Text
                        .Substring(18, tsmi1.Text.Length - 19).CompareTo(tsmi2.Text.Substring(18, tsmi2.Text.Length - 19));
            });
            AddToolStripItemToStrip(WiiWareMenuList, wwItems);
            
            SetPropertyThreadSafe(wwFakeMenuItem, false, "Visible");
            SetPropertyThreadSafe(WiiWareMenuList, true, "Visible");
            Debug.WriteLine("Database: WiiWareTitles added");
            worker.ReportProgress(100);
        }