private void CreateAndStartProfile() { if (_createProfileWindowShown) { return; } _createProfileWindowShown = true; using (frmCreateProfile frm = new frmCreateProfile()) { frm.Activate(); if (frm.ShowDialog(this) == DialogResult.OK) { int localServicePort; if (frm.NodeType == MeshNodeType.P2P) { localServicePort = (new Random()).Next(10000, 65000); //fixed random port for p2p } else { localServicePort = 0; //new random port at startup for Tor node } MeshNode node = new MeshNode(frm.NodeType, frm.PrivateKey, SecureChannelCipherSuite.DHE2048_RSA2048_WITH_AES256_CBC_HMAC_SHA256, Convert.ToUInt16(localServicePort), frm.ProfileDisplayName, _profileFolder, GetDownloadFolder(), _torController); if (frm.NodeType == MeshNodeType.P2P) { //create default local network group for LAN user discovery node.CreateGroupChat("Local Network", "", true); } string profileFilePath = Path.Combine(_profileFolder, frm.ProfileDisplayName + ".profile"); using (FileStream fS = new FileStream(profileFilePath, FileMode.Create, FileAccess.ReadWrite)) { node.ChangePassword(frm.ProfilePassword); node.SaveTo(fS); } LoadProfileMainForm(frm.ProfileDisplayName, node, profileFilePath); } else { if (cmbProfiles.Items.Count > 0) { this.Show(); this.Activate(); } } } _createProfileWindowShown = false; }
private void mnuAddGroupChat_Click(object sender, EventArgs e) { using (frmAddGroupChat frm = new frmAddGroupChat()) { if (frm.ShowDialog(this) == DialogResult.OK) { try { MeshNetwork network = _node.CreateGroupChat(frm.NetworkName, frm.SharedSecret, frm.LocalNetworkOnly); lstChats.SelectItem(AddChatView(network)); ShowSelectedChatView(); SaveProfile(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } }