VSNDK.DebugEngine.AD7PortSupplier.verifyAndAddPorts C# (CSharp) Method

verifyAndAddPorts() private method

private verifyAndAddPorts ( ) : int
return int
        private int verifyAndAddPorts()
        {
            if (GDBParser.s_running == true) // Returning because VS can debug only one app at a time.
                return 0;

            RegistryKey rkHKCU = Registry.CurrentUser;
            RegistryKey rkPluginRegKey = null;
            string DeviceIP = "";
            string DevicePassword = "";
            string SimulatorIP = "";
            string SimulatorPassword = "";

            try
            {
                rkPluginRegKey = rkHKCU.OpenSubKey("Software\\BlackBerry\\BlackBerryVSPlugin");
                m_toolsPath = rkPluginRegKey.GetValue("NDKHostPath").ToString();

                if ((m_toolsPath == null) || (m_toolsPath == ""))
                    return -1;

                m_toolsPath += "/usr/bin";

                DeviceIP = rkPluginRegKey.GetValue("device_IP").ToString();
                if ((DeviceIP != "") && (DeviceIP != null))
                {
                    DevicePassword = rkPluginRegKey.GetValue("device_password").ToString();
                    if ((DevicePassword != "") && (DevicePassword != null))
                    {
                        try
                        {
                            DevicePassword = Decrypt(DevicePassword);
                        }
                        catch
                        {
                            DevicePassword = "";
                        }
                    }
                    if (DevicePassword == "")
                    {
                        MessageBox.Show("Missing Device password", "Missing Device Password", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    DeviceIP = "";
                }
                SimulatorIP = rkPluginRegKey.GetValue("simulator_IP").ToString();
                SimulatorPassword = rkPluginRegKey.GetValue("simulator_password").ToString();
                if ((SimulatorPassword != "") && (SimulatorPassword != null))
                {
                    try
                    {
                        SimulatorPassword = Decrypt(SimulatorPassword);
                    }
                    catch
                    {
                        SimulatorPassword = "";
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Microsoft Visual Studio", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }

            rkPluginRegKey.Close();
            rkHKCU.Close();

            if ((DeviceIP != "") && (DevicePassword != ""))
            {
                IDebugPort2 p;
                AddPort(new AD7PortRequest("Device: " + DeviceIP + "-" + DevicePassword), out p);
            }

            if (SimulatorIP != "")
            {
                IDebugPort2 p;
                AddPort(new AD7PortRequest("Simulator: " + SimulatorIP + "-" + SimulatorPassword), out p);
            }
            return 1;
        }