public static void doUserAndPassword()
        {
            string droneshareusername = MainV2.getConfig("droneshareusername");

            InputBox.Show("Username", "Username", ref droneshareusername);

            MainV2.config["droneshareusername"] = droneshareusername;

            string dronesharepassword = MainV2.getConfig("dronesharepassword");

            if (dronesharepassword != "")
            {
                try
                {
                    // fail on bad entry
                    var crypto = new Crypto();
                    dronesharepassword = crypto.DecryptString(dronesharepassword);
                }
                catch
                {
                }
            }

            InputBox.Show("Password", "Password", ref dronesharepassword, true);

            var crypto2 = new Crypto();

            string encryptedpw = crypto2.EncryptString(dronesharepassword);

            MainV2.config["dronesharepassword"] = encryptedpw;
        }
        public static void doUpload(string file)
        {
            if (!validcred)
            {
                doUserAndPassword();
            }

            string droneshareusername = MainV2.getConfig("droneshareusername");

            string dronesharepassword = MainV2.getConfig("dronesharepassword");

            if (dronesharepassword != "")
            {
                try
                {
                    // fail on bad entry
                    var crypto = new Crypto();
                    dronesharepassword = crypto.DecryptString(dronesharepassword);
                }
                catch { }
            }

            MAVLinkInterface mav = new MAVLinkInterface();
            mav.BaseStream = new Comms.CommsFile();
            mav.BaseStream.PortName = file;
            mav.BaseStream.Open();
            if (mav.getHeartBeat().Length == 0)
            {
                CustomMessageBox.Show("Invalid log");
                return;
            }
            mav.Close();

            string viewurl = Utilities.DroneApi.droneshare.doUpload(file, droneshareusername, dronesharepassword, mav.MAV.Guid , Utilities.DroneApi.APIConstants.apiKey);

            if (viewurl != "")
            {
                try
                {
                    validcred = true;
                    System.Diagnostics.Process.Start(viewurl);
                }
                catch (Exception ex) { log.Error(ex); CustomMessageBox.Show("Failed to open url " + viewurl); }
            }
        }
        public static void doUpload(string file)
        {
            if (file == null)
                return;

            if (!validcred)
            {
                doUserAndPassword();
            }

            string droneshareusername = MainV2.getConfig("droneshareusername");

            string dronesharepassword = MainV2.getConfig("dronesharepassword");

            if (dronesharepassword != "")
            {
                try
                {
                    // fail on bad entry
                    var crypto = new Crypto();
                    dronesharepassword = crypto.DecryptString(dronesharepassword);
                }
                catch
                {
                }
            }


            String tempguid = null;

            if (!doLogin(droneshareusername, dronesharepassword))
            {
                CustomMessageBox.Show("Bad Credentials", Strings.ERROR);
                return;
            }

            validcred = true;

            if (uuidcached == "")
            {
                UI.VehicleSelection veh = new VehicleSelection(accountuuids);
                veh.ShowDialog();

                tempguid = veh.uuid;
                uuidcached = veh.uuid;
            }
            else
            {
                tempguid = uuidcached;
            }

            string viewurl = Utilities.DroneApi.droneshare.doUpload(file, droneshareusername, dronesharepassword,
                tempguid);

            if (viewurl != "")
            {
                try
                {
                    
                    System.Diagnostics.Process.Start(viewurl);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                    CustomMessageBox.Show("Failed to open url " + viewurl);
                }
            }
        }
        public static void doUserAndPassword()
        {
            string droneshareusername = Settings.Instance["droneshareusername"];

            InputBox.Show("Username", "Username", ref droneshareusername);

            Settings.Instance["droneshareusername"] = droneshareusername;

            string dronesharepassword = Settings.Instance["dronesharepassword"];

            if (dronesharepassword != "")
            {
                try
                {
                    // fail on bad entry
                    var crypto = new Crypto();
                    dronesharepassword = crypto.DecryptString(dronesharepassword);
                }
                catch
                {
                }
            }

            InputBox.Show("Password", "Password", ref dronesharepassword, true);

            var crypto2 = new Crypto();

            string encryptedpw = crypto2.EncryptString(dronesharepassword);

            Settings.Instance["dronesharepassword"] = encryptedpw;
        }