init() 공개 정적인 메소드

public static init ( BitSettings BS ) : bool
BS BitSettings
리턴 bool
예제 #1
0
        internal static void storeBS(BitSettings B)
        {
            INI.setSetting(CONFIG, "API", "FILE", B.BitConfig);
            INI.setSetting(CONFIG, "API", "DEST", B.IP);
            INI.setSetting(CONFIG, "API", "PORT", B.Port.ToString());
            INI.setSetting(CONFIG, "API", "NAME", B.UName);
            INI.setSetting(CONFIG, "API", "PASS", B.UPass);
            INI.setSetting(CONFIG, "MAIL", "RANDOM", B.Random?"TRUE":"FALSE");
            INI.setSetting(CONFIG, "MAIL", "STRIP", B.StripHdr ? "TRUE" : "FALSE");
            INI.setSetting(CONFIG, "MAIL", "RQUOT", B.RemQuoting? "TRUE" : "FALSE");
            INI.setSetting(CONFIG, "MAIL", "EXT", B.Extension);
            initBS();
            BitAPIserver.init(BS);
            bool passIO = true;

            try
            {
                if (BitAPIserver.BA.helloWorld("A", "B") != "A-B")
                {
                    passIO = false;
                    throw new Exception("Wrong Password");
                }
            }
            catch
            {
                string MSG = "Cannot reach the Bitmessage API.";
                if (!passIO)
                {
                    MSG = "Username and Password seem incorrect.";
                }
                if (MessageBox.Show(MSG + "\r\nPlease double check your Settings.\r\nDo so now?",
                                    "BitAPI not reached", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                {
                    Settings_Click(null, null);
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            if (initBS())
            {
                //Check First Run (-1)
                if (BS.Port != -1 && !BitAPIserver.init(BS))
                {
                    MessageBox.Show(@"Error reading API values.
Check if keys.dat is present and API values are set.
Also verify the API File Path in BitServer.ini is valid.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    AuxMessages = new List <POP3message>();
                    AckMessage  = new List <string>();

                    tDSN = new Thread(new ThreadStart(checkMSG));
                    tDSN.IsBackground = true;
                    tDSN.Start();

                    if (BS.Port == -1)
                    {
                        Settings_Click(null, null);
                        Application.Run(GUI = new frmLoop());
                    }
                    else
                    {
                        Application.Run(GUI = new frmLoop());
                    }
                }
            }
            else
            {
                var Parts = new INI.INIPart[] { new INI.INIPart(), new INI.INIPart() };
                var NVC   = new System.Collections.Specialized.NameValueCollection();

                Parts[0].Section = "API";
                NVC.Add("FILE", "keys.dat");
                NVC.Add("NAME", "AyrA");
                NVC.Add("PASS", "BitMailServer");
                NVC.Add("DEST", "127.0.0.1");
                NVC.Add("PORT", "-1");
                Parts[0].Settings = NVC;

                Parts[1].Section = "MAIL";
                NVC = new System.Collections.Specialized.NameValueCollection();
                NVC.Add("RANDOM", "TRUE");
                NVC.Add("STRIP", "TRUE");
                Parts[1].Settings = NVC;

                INI.RewriteINI(CONFIG, Parts);

                MessageBox.Show("Error reading BitServer.ini Values.\r\nA File with Default Settings was created.\r\nPlease change its settings in the folowing Window.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Restart();
            }

            cont = false;

            Console.WriteLine("Exiting...");
            if (NFI != null)
            {
                NFI.Visible = false;
                NFI.Dispose();
                CMS.Dispose();
            }
            tDSN.Join();
        }