public static bool init(BitSettings BS)
 {
     BA     = (BitAPI)CookComputing.XmlRpc.XmlRpcProxyGen.Create(typeof(BitAPI));
     BA.Url = string.Format("http://{0}:{1}/", BS.IP, BS.Port);
     BA.Headers.Add("Authorization", "Basic " + Bitmessage.B64enc(string.Format("{0}:{1}", BS.UName, BS.UPass)));
     return(true);
 }
 public static bool init(BitSettings BS)
 {
     BA = (BitAPI)CookComputing.XmlRpc.XmlRpcProxyGen.Create(typeof(BitAPI));
     BA.Url = string.Format("http://{0}:{1}/",BS.IP,BS.Port);
     BA.Headers.Add("Authorization", "Basic " + Bitmessage.B64enc(string.Format("{0}:{1}",BS.UName,BS.UPass)));
     return true;
 }
 public frmSettings(BitSettings B)
 {
     InitializeComponent();
     BS = B;
     tbKeys.Text = BS.BitConfig;
     tbIP.Text = BS.IP;
     tbPort.Text = BS.Port>=0?BS.Port.ToString():"8442";
     tbUser.Text = BS.UName.ToString();
     tbPass.Text = BS.UPass;
     cbRandom.Checked = BS.Random;
     cbStrip.Checked = BS.StripHdr;
 }
Exemple #4
0
 public frmSettings(BitSettings B)
 {
     InitializeComponent();
     BS                = B;
     tbKeys.Text       = BS.BitConfig;
     tbIP.Text         = BS.IP;
     tbPort.Text       = BS.Port >= 0?BS.Port.ToString():"8442";
     tbUser.Text       = BS.UName.ToString();
     tbPass.Text       = BS.UPass;
     cbRandom.Checked  = BS.Random;
     cbStrip.Checked   = BS.StripHdr;
     cbQuoting.Checked = BS.RemQuoting;
     tbExt.Text        = BS.Extension;
 }
Exemple #5
0
        private static bool initBS()
        {
            BS = new BitSettings();
            int i = 0;

            BS.BitConfig = INI.getSetting(CONFIG, "API", "FILE");
            if (!string.IsNullOrEmpty(BS.BitConfig) && System.IO.File.Exists(BS.BitConfig))
            {
                BS.IP = INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apiinterface").Trim();
                if (int.TryParse(INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apiport").Trim(), out i))
                {
                    BS.Port = i;
                }
                else
                {
                    return(false);
                }
                BS.UName = INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apiusername").Trim();
                BS.UPass = INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apipassword").Trim();
            }
            else
            {
                BS.IP = INI.getSetting(CONFIG, "API", "DEST");
                if (int.TryParse(INI.getSetting(CONFIG, "API", "PORT"), out i))
                {
                    BS.Port = i;
                }
                else
                {
                    return(false);
                }
                BS.UName = INI.getSetting(CONFIG, "API", "NAME");
                BS.UPass = INI.getSetting(CONFIG, "API", "PASS");
            }

            BS.Random     = toEmpty(INI.getSetting(CONFIG, "MAIL", "RANDOM")).ToUpper() == "TRUE";
            BS.StripHdr   = toEmpty(INI.getSetting(CONFIG, "MAIL", "STRIP")).ToUpper() == "TRUE";
            BS.RemQuoting = toEmpty(INI.getSetting(CONFIG, "MAIL", "RQUOT")).ToUpper() == "TRUE";
            BS.Extension  = toEmpty(INI.getSetting(CONFIG, "MAIL", "EXT"));
            if (string.IsNullOrEmpty(BS.Extension))
            {
                BS.Extension = EXTENSION;
            }

            return(!string.IsNullOrEmpty(BS.IP) &&
                   (BS.Port > 0 || BS.Port == -1) &&
                   BS.Port <= ushort.MaxValue &&
                   !string.IsNullOrEmpty(BS.UName) &&
                   !string.IsNullOrEmpty(BS.UPass));
        }
Exemple #6
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);
                }
            }
        }
Exemple #7
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);
         }
     }
 }
Exemple #8
0
        private static bool initBS()
        {
            BS = new BitSettings();
            int i = 0;
            BS.BitConfig = INI.getSetting(CONFIG, "API", "FILE");
            if (!string.IsNullOrEmpty(BS.BitConfig) && System.IO.File.Exists(BS.BitConfig))
            {
                BS.IP = INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apiinterface").Trim();
                if (int.TryParse(INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apiport").Trim(), out i))
                {
                    BS.Port = i;
                }
                else
                {
                    return false;
                }
                BS.UName = INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apiusername").Trim();
                BS.UPass = INI.getSetting(BS.BitConfig, BitAPIserver.I_SECT, "apipassword").Trim();
            }
            else
            {
                BS.IP = INI.getSetting(CONFIG, "API", "DEST");
                if (int.TryParse(INI.getSetting(CONFIG, "API", "PORT"), out i))
                {
                    BS.Port = i;
                }
                else
                {
                    return false;
                }
                BS.UName = INI.getSetting(CONFIG, "API", "NAME");
                BS.UPass = INI.getSetting(CONFIG, "API", "PASS");
            }

            BS.Random = toEmpty(INI.getSetting(CONFIG, "MAIL", "RANDOM")).ToUpper() == "TRUE";
            BS.StripHdr = toEmpty(INI.getSetting(CONFIG, "MAIL", "STRIP")).ToUpper() == "TRUE";
            BS.RemQuoting = toEmpty(INI.getSetting(CONFIG, "MAIL", "RQUOT")).ToUpper() == "TRUE";
            BS.Extension = toEmpty(INI.getSetting(CONFIG, "MAIL", "EXT"));
            if (string.IsNullOrEmpty(BS.Extension))
            {
                BS.Extension = EXTENSION;
            }

            return !string.IsNullOrEmpty(BS.IP) &&
                (BS.Port > 0 || BS.Port==-1) &&
                BS.Port <= ushort.MaxValue &&
                !string.IsNullOrEmpty(BS.UName) &&
                !string.IsNullOrEmpty(BS.UPass);
        }