Esempio n. 1
0
        private void frmRegisterNow_Click(object sender, EventArgs e)
        {
            this.Hide();

            using (frmRegister frm = new frmRegister(_isPortableApp, _profileFolder))
            {
                DialogResult result = frm.ShowDialog(this);

                switch (result)
                {
                case System.Windows.Forms.DialogResult.OK:
                    _profile         = frm.Profile;
                    _profileFilePath = frm.ProfileFilePath;

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                    break;

                case System.Windows.Forms.DialogResult.Ignore:
                    this.Show();
                    break;

                default:
                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    this.Close();
                    break;
                }
            }
        }
Esempio n. 2
0
        private void btnReIssueProfile_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Reissuing a profile certificate will allow you register again with the same email address and change your information in the profile certificate while keeping all your profile settings intact.\r\n\r\nAre you sure you want to reissue the selected profile?\r\n\r\nWARNING! This will revoke the previously issued profile certificate however, your settings will remain intact.", "Reissue Profile Certificate?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            {
                this.Hide();

                _profileFilePath = Path.Combine(_localAppData, (lstProfiles.SelectedItem as string) + ".profile");

                using (frmPassword frm = new frmPassword(_profileFilePath))
                {
                    if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        _profile = frm.Profile;

                        using (frmRegister frmReg = new frmRegister(_localAppData, _profile, _profileFilePath, true))
                        {
                            if (frmReg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                            {
                                _profile         = frmReg.Profile;
                                _profileFilePath = frmReg.ProfileFilePath;

                                string profileName = Path.GetFileNameWithoutExtension(_profileFilePath);
                                lstProfiles.SelectedItem = profileName;
                            }
                        }
                    }
                }

                this.Show();
            }
        }
Esempio n. 3
0
        private void btnNewProfile_Click(object sender, EventArgs e)
        {
            this.Hide();

            using (frmRegister frm = new frmRegister(_localAppData))
            {
                if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    _profile         = frm.Profile;
                    _profileFilePath = frm.ProfileFilePath;

                    string profileName = Path.GetFileNameWithoutExtension(_profileFilePath);

                    lstProfiles.Items.Add(profileName);
                    lstProfiles.SelectedItem = profileName;
                }
            }

            this.Show();
        }
Esempio n. 4
0
        private void frmRegisterNow_Click(object sender, EventArgs e)
        {
            this.Hide();

            using (frmRegister frm = new frmRegister(_localAppData))
            {
                DialogResult result = frm.ShowDialog(this);

                switch (result)
                {
                    case System.Windows.Forms.DialogResult.OK:
                        _profile = frm.Profile;
                        _profileFilePath = frm.ProfileFilePath;

                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                        break;

                    case System.Windows.Forms.DialogResult.Ignore:
                        this.Show();
                        break;

                    default:
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                        this.Close();
                        break;
                }
            }
        }
        public static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                #region check windows firewall entry

                string appPath             = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "").Replace("/", "\\");
                bool   firewallEntryExists = WindowsFirewallEntryExists(appPath);

                if (!firewallEntryExists)
                {
                    bool isAdmin = (new WindowsPrincipal(WindowsIdentity.GetCurrent())).IsInRole(WindowsBuiltInRole.Administrator);

                    if (isAdmin)
                    {
                        AddWindowsFirewallEntry(appPath);
                    }
                    else
                    {
                        ProcessStartInfo processInfo = new ProcessStartInfo(appPath, string.Join(" ", args));

                        processInfo.UseShellExecute = true;
                        processInfo.Verb            = "runas";

                        try
                        {
                            Process.Start(processInfo);
                            return;
                        }
                        catch
                        { }
                    }
                }

                #endregion

                #region check for multiple instances

                bool createdNewMutex;

                _app = new Mutex(true, MUTEX_NAME, out createdNewMutex);

                if (!createdNewMutex)
                {
                    MessageBox.Show("Bit Chat is already running. Please click on the Bit Chat system tray icon to open the chat window.", "Bit Chat Already Running!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                #endregion

                #region profile manager

                while (true)
                {
                    frmProfileManager mgr = new frmProfileManager();

                    if (mgr.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            if (mgr.Profile != null)
                            {
                                bool loadMainForm = false;

                                if ((mgr.Profile.LocalCertificateStore.Certificate.Type == CertificateType.User) && (mgr.Profile.LocalCertificateStore.Certificate.Capability == CertificateCapability.UserAuthentication))
                                {
                                    loadMainForm = true;
                                }
                                else
                                {
                                    using (frmRegister frm = new frmRegister(mgr.Profile, mgr.ProfileFilePath, mgr.IsPortableApp, mgr.ProfileFolder, false))
                                    {
                                        loadMainForm = (frm.ShowDialog() == DialogResult.OK);
                                    }
                                }

                                if (loadMainForm)
                                {
                                    using (frmMain frm = new frmMain(mgr.Profile, mgr.ProfileFilePath, string.Join(" ", args)))
                                    {
                                        Application.Run(frm);

                                        if (frm.DialogResult != DialogResult.Ignore)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error! " + ex.Message, "Error - Bit Chat Profile Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex.Message + "\r\n\r\nClick OK to quit the application.", "Error - Bit Chat", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
        public static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                #region check for multiple instances

                bool createdNewMutex;

                _app = new Mutex(true, MUTEX_NAME, out createdNewMutex);

                if (!createdNewMutex)
                {
                    AppLink.SendCommand(string.Join(" ", args), APP_LINK_PORT);
                    return;
                }

                #endregion

                string appPath = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "").Replace("/", "\\");

                #region check for admin priviledge

                if (!(new WindowsPrincipal(WindowsIdentity.GetCurrent())).IsInRole(WindowsBuiltInRole.Administrator))
                {
                    ProcessStartInfo processInfo = new ProcessStartInfo(appPath, string.Join(" ", args));

                    processInfo.UseShellExecute = true;
                    processInfo.Verb            = "runas";

                    try
                    {
                        Process.Start(processInfo);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Technitium Bit Chat requires administrative privileges to run. You will need to contact your system administrator to run this application.", "Cannot Start Bit Chat", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    return;
                }

                #endregion

                #region load trusted certificates

                TRUSTED_CERTIFICATES = new Certificate[1];

                using (MemoryStream mS = new MemoryStream(Convert.FromBase64String(_rootCert)))
                {
                    TRUSTED_CERTIFICATES[0] = new Certificate(mS);
                }

                #endregion

                #region profile manager

                bool loaded = false;

                //read local app data folder
                string localAppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Technitium", "BitChat");

                if (!Directory.Exists(localAppData))
                {
                    Directory.CreateDirectory(localAppData);
                }

                while (true)
                {
                    frmProfileManager mgr = new frmProfileManager(localAppData, loaded);

                    if (mgr.ShowDialog() == DialogResult.OK)
                    {
                        loaded = true;

                        try
                        {
                            if (mgr.Profile != null)
                            {
                                bool loadMainForm = false;

                                if ((mgr.Profile.LocalCertificateStore.Certificate.Type == CertificateType.Normal) && (mgr.Profile.LocalCertificateStore.Certificate.Capability == CertificateCapability.KeyExchange))
                                {
                                    loadMainForm = true;
                                }
                                else
                                {
                                    using (frmRegister frm = new frmRegister(localAppData, mgr.Profile, mgr.ProfileFilePath, false))
                                    {
                                        loadMainForm = (frm.ShowDialog() == DialogResult.OK);
                                    }
                                }

                                if (loadMainForm)
                                {
                                    using (frmMain frm = new frmMain(mgr.Profile, mgr.ProfileFilePath, string.Join(" ", args)))
                                    {
                                        Application.Run(frm);

                                        if (frm.DialogResult != DialogResult.Ignore)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error! " + ex.Message, "Error - Bit Chat Profile Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex.Message + "\r\n\r\nClick OK to quit the application.", "Error - Bit Chat", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                #region check for multiple instances

                bool createdNewMutex;

                _app = new Mutex(true, MUTEX_NAME, out createdNewMutex);

                if (!createdNewMutex)
                {
                    MessageBox.Show("Bit Chat is already running. Please click on the Bit Chat icon to open the chat window.", "Bit Chat Already Running!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                #endregion

                #region profile manager

                while (true)
                {
                    frmProfileManager mgr = new frmProfileManager();

                    if (mgr.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            if (mgr.Profile != null)
                            {
                                bool loadMainForm = false;

                                if ((mgr.Profile.LocalCertificateStore.Certificate.Type == CertificateType.User) && (mgr.Profile.LocalCertificateStore.Certificate.Capability == CertificateCapability.UserAuthentication))
                                {
                                    loadMainForm = true;
                                }
                                else
                                {
                                    using (frmRegister frm = new frmRegister(mgr.Profile, mgr.ProfileFilePath, mgr.IsPortableApp, mgr.ProfileFolder, false))
                                    {
                                        loadMainForm = (frm.ShowDialog() == DialogResult.OK);
                                    }
                                }

                                if (loadMainForm)
                                {
                                    using (frmMain frm = new frmMain(mgr.Profile, mgr.ProfileFilePath, string.Join(" ", args)))
                                    {
                                        Application.Run(frm);

                                        if (frm.DialogResult != DialogResult.Ignore)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error! " + ex.Message, "Error - Bit Chat Profile Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex.Message + "\r\n\r\nClick OK to quit the application.", "Error - Bit Chat", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnReIssueProfile_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Reissuing a profile certificate will allow you register again with the same email address and change your information in the profile certificate while keeping all your profile settings intact.\r\n\r\nAre you sure you want to reissue the selected profile?\r\n\r\nWARNING! This will revoke the previously issued profile certificate however, your settings will remain intact.", "Reissue Profile Certificate?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            {
                this.Hide();

                _profileFilePath = Path.Combine(_localAppData, (lstProfiles.SelectedItem as string) + ".profile");

                using (frmPassword frm = new frmPassword(_profileFilePath))
                {
                    if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                    {
                        _profile = frm.Profile;

                        using (frmRegister frmReg = new frmRegister(_localAppData, _profile, _profileFilePath, true))
                        {
                            if (frmReg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                            {
                                _profile = frmReg.Profile;
                                _profileFilePath = frmReg.ProfileFilePath;

                                string profileName = Path.GetFileNameWithoutExtension(_profileFilePath);
                                lstProfiles.SelectedItem = profileName;
                            }
                        }
                    }
                }

                this.Show();
            }
        }
        private void btnNewProfile_Click(object sender, EventArgs e)
        {
            this.Hide();

            using (frmRegister frm = new frmRegister(_localAppData))
            {
                if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    _profile = frm.Profile;
                    _profileFilePath = frm.ProfileFilePath;

                    string profileName = Path.GetFileNameWithoutExtension(_profileFilePath);

                    lstProfiles.Items.Add(profileName);
                    lstProfiles.SelectedItem = profileName;
                }
            }

            this.Show();
        }