Пример #1
0
        private void EditSelected()
        {
            if (VisList.SelectedItems.Count == 0)
                return;

            VisItem selected = (VisItem)VisList.SelectedItems[0];

            GetTextDialog getText = new GetTextDialog(StorageRes.Icon, "Sub-Levels", "Visible how many levels down from " + selected.Name + "? 0 for no one, -1 for everyone.", selected.Levels.ToString());

            if (getText.ShowDialog() == DialogResult.OK)
            {
                short levels;
                short.TryParse(getText.ResultBox.Text, out levels);

                if (levels >= -1)
                    selected.Levels = levels;

                selected.Update();
            }
        }
Пример #2
0
        private CreateUser ReadInvite(string link)
        {
            string[] mainParts = link.Replace("deops://", "").Split('/');

            if (mainParts.Length < 4)
                throw new Exception("Invalid Link");

            // Select John Marshall's Global IM Profile
            string[] nameParts = mainParts[2].Split('@');
            string name = HttpUtility.UrlDecode(nameParts[0]);
            string op = HttpUtility.UrlDecode(nameParts[1]);

            byte[] data = Utilities.HextoBytes(mainParts[3]);
            byte[] pubOpID = Utilities.ExtractBytes(data, 0, 8);
            byte[] encrypted = Utilities.ExtractBytes(data, 8, data.Length - 8);
            byte[] decrypted = null;

            // try opening invite with a currently loaded core
            Context.Cores.LockReading(delegate()
            {
                foreach (var core in Context.Cores)
                    try
                    {
                        if (Utilities.MemCompare(pubOpID, core.User.Settings.PublicOpID))
                            decrypted = core.User.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch { }
            });

            // have user select profile associated with the invite
            while (decrypted == null)
            {
                OpenFileDialog open = new OpenFileDialog();

                open.Title = "Open " + name + "'s " + op + " Profile to Verify Invitation";
                open.InitialDirectory = Application.StartupPath;
                open.Filter = "DeOps Identity (*.dop)|*.dop";

                if (open.ShowDialog() != DialogResult.OK)
                    return null; // user doesnt want to try any more

                GetTextDialog pass = new GetTextDialog("Passphrase", "Enter the passphrase for this profile", "");
                pass.ResultBox.UseSystemPasswordChar = true;

                if (pass.ShowDialog() != DialogResult.OK)
                    continue; // let user choose another profile

                try
                {
                    // open profile
                    var user = new OpUser(open.FileName, pass.ResultBox.Text, null);
                    user.Load(LoadModeType.Settings);

                    // ensure the invitation is for this op specifically
                    if (!Utilities.MemCompare(pubOpID, user.Settings.PublicOpID))
                    {
                        MessageBox.Show("This is not a " + op + " profile");
                        continue;
                    }

                    // try to decrypt the invitation
                    try
                    {
                        decrypted = user.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch
                    {
                        MessageBox.Show("Could not open the invitation with this profile");
                        continue;
                    }
                }
                catch
                {
                    MessageBox.Show("Wrong password");
                }
            }

            CreateUser created = null;

            try
            {
                InvitePackage invite = OpCore.OpenInvite(decrypted, Protocol);

                if(invite != null)
                    created = new CreateUser(App, invite);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return created;
        }
Пример #3
0
        void Folder_Create(object sender, EventArgs args)
        {
            GetTextDialog dialog = new GetTextDialog(StorageRes.Icon, "Create Folder", "Enter a name for the new folder", "New Folder");

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    if (dialog.ResultBox.Text.Length == 0)
                        throw new Exception("Folder needs to have a name");

                    if (SelectedFolder.GetFolder(dialog.ResultBox.Text) != null)
                        throw new Exception("Folder with same name already exists");

                    if (dialog.ResultBox.Text.IndexOf(Path.DirectorySeparatorChar) != -1)
                        throw new Exception("Folder name contains invalid characters");

                    Working.TrackFolder(SelectedFolder.GetPath() + Path.DirectorySeparatorChar + dialog.ResultBox.Text);

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #4
0
        private CreateUser ReadInvite(string link)
        {
            string[] mainParts = link.Replace("deops://", "").Split('/');

            if (mainParts.Length < 4)
            {
                throw new Exception("Invalid Link");
            }

            // Select John Marshall's Global IM Profile
            string[] nameParts = mainParts[2].Split('@');
            string   name      = HttpUtility.UrlDecode(nameParts[0]);
            string   op        = HttpUtility.UrlDecode(nameParts[1]);

            byte[] data      = Utilities.HextoBytes(mainParts[3]);
            byte[] pubOpID   = Utilities.ExtractBytes(data, 0, 8);
            byte[] encrypted = Utilities.ExtractBytes(data, 8, data.Length - 8);
            byte[] decrypted = null;

            // try opening invite with a currently loaded core
            Context.Cores.LockReading(delegate()
            {
                foreach (var core in Context.Cores)
                {
                    try
                    {
                        if (Utilities.MemCompare(pubOpID, core.User.Settings.PublicOpID))
                        {
                            decrypted = core.User.Settings.KeyPair.Decrypt(encrypted, false);
                        }
                    }
                    catch { }
                }
            });

            // have user select profile associated with the invite
            while (decrypted == null)
            {
                OpenFileDialog open = new OpenFileDialog();

                open.Title            = "Open " + name + "'s " + op + " Profile to Verify Invitation";
                open.InitialDirectory = Application.StartupPath;
                open.Filter           = "DeOps Identity (*.dop)|*.dop";

                if (open.ShowDialog() != DialogResult.OK)
                {
                    return(null); // user doesnt want to try any more
                }
                GetTextDialog pass = new GetTextDialog("Passphrase", "Enter the passphrase for this profile", "");
                pass.ResultBox.UseSystemPasswordChar = true;

                if (pass.ShowDialog() != DialogResult.OK)
                {
                    continue; // let user choose another profile
                }
                try
                {
                    // open profile
                    var user = new OpUser(open.FileName, pass.ResultBox.Text, null);
                    user.Load(LoadModeType.Settings);

                    // ensure the invitation is for this op specifically
                    if (!Utilities.MemCompare(pubOpID, user.Settings.PublicOpID))
                    {
                        MessageBox.Show("This is not a " + op + " profile");
                        continue;
                    }

                    // try to decrypt the invitation
                    try
                    {
                        decrypted = user.Settings.KeyPair.Decrypt(encrypted, false);
                    }
                    catch
                    {
                        MessageBox.Show("Could not open the invitation with this profile");
                        continue;
                    }
                }
                catch
                {
                    MessageBox.Show("Wrong password");
                }
            }

            CreateUser created = null;

            try
            {
                InvitePackage invite = OpCore.OpenInvite(decrypted, Protocol);

                if (invite != null)
                {
                    created = new CreateUser(App, invite);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(created);
        }
Пример #5
0
        private void RoomMenu_Join(object sender, EventArgs e)
        {
            GetTextDialog join = new GetTextDialog("Join Room", "Enter the name of the room", "");

            if (join.ShowDialog() != DialogResult.OK)
                return;

            string name = join.ResultBox.Text;

            if (name == "")
                return;

            ChatRoom room = Chat.CreateRoom(name, RoomKind.Public);

            SetCustomRoom(room);
        }
Пример #6
0
        private void StatusBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            string url = e.Url.OriginalString;

            if (GuiUtils.IsRunningOnMono() && url.StartsWith("wyciwyg"))
                return;

            if (url.StartsWith("about:blank"))
                return;

            url = url.Replace("http://", "");
            url = url.TrimEnd('/');

            string[] command = url.Split('/');

            if (CurrentMode == StatusModeType.Project)
            {
                if (url == "rename")
                {
                    GetTextDialog rename = new GetTextDialog("Rename Project", "Enter new name for project " + Core.Trust.GetProjectName(ProjectID), Core.Trust.GetProjectName(ProjectID));

                    if (rename.ShowDialog() == DialogResult.OK)
                        Core.Trust.RenameProject(ProjectID, rename.ResultBox.Text);
                }

                else if (url == "leave")
                {
                    if (MessageBox.Show("Are you sure you want to leave " + Core.Trust.GetProjectName(ProjectID) + "?", "Leave Project", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        Core.Trust.LeaveProject(ProjectID);
                }

                else if (url == "settings")
                {
                    new DeOps.Interface.Settings.Operation(Core).ShowDialog(this);
                }
            }

            else if (CurrentMode == StatusModeType.Group)
            {
                if (url == "add_buddy")
                {
                    BuddyView.AddBuddyDialog(Core, "");
                }

                else if (url == "add_group")
                {
                    // not enabled yet
                }

                else if (command[0] == "rename_group")
                {
                    string name = command[1];

                    GetTextDialog rename = new GetTextDialog("Rename Group", "Enter a new name for group " + name, name);

                    if (rename.ShowDialog() == DialogResult.OK)
                        Core.Buddies.RenameGroup(name, rename.ResultBox.Text);
                }

                else if (command[0] == "remove_group")
                {
                    string name = command[1];

                    if(MessageBox.Show("Are you sure you want to remove " + name + "?", "Remove Group", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        Core.Buddies.RemoveGroup(name);
                }
            }

            else if (CurrentMode == StatusModeType.User)
            {
                if (url == "rename_user")
                {
                    GetTextDialog rename = new GetTextDialog("Rename User", "New name for " + Core.GetName(UserID), Core.GetName(UserID));

                    if (rename.ShowDialog() == DialogResult.OK)
                        Core.RenameUser(UserID, rename.ResultBox.Text);
                }

                else if (url == "trust_accept")
                {
                    Core.Trust.AcceptTrust(UserID, ProjectID);
                }

                else if (command[0] == "change_title")
                {
                    string def = command[1];

                    GetTextDialog title = new GetTextDialog("Change Title", "Enter title for " + Core.GetName(UserID), def);

                    if (title.ShowDialog() == DialogResult.OK)
                        Core.Trust.SetTitle(UserID, ProjectID, title.ResultBox.Text);

                }

                else if (url == "edit_location")
                {
                    GetTextDialog place = new GetTextDialog("Change Location", "Where is this instance located? (home, work, mobile?)", "");

                    if (place.ShowDialog() == DialogResult.OK)
                    {
                        Core.User.Settings.Location = place.ResultBox.Text;
                        Core.Locations.UpdateLocation();

                        Core.RunInCoreAsync(() => Core.User.Save());
                    }
                }

                else if (url == "edit_status")
                {
                    // show edit status dialog available / away / invisible
                    new StatusForm(Core).ShowDialog();
                }

                else if (url == "unignore")
                {
                    if (MessageBox.Show("Stop ignoring " + Core.GetName(UserID) + "?", "Ignore", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        Core.Buddies.Ignore(UserID, false);
                }

                else if (command[0] == "project")
                {
                    uint id = uint.Parse(command[1]);

                    if (UI.GuiMain != null && UI.GuiMain.GetType() == typeof(MainForm))
                        ((MainForm)UI.GuiMain).ShowProject(id);
                }

                else if (command[0] == "use_name")
                {
                    string name = System.Web.HttpUtility.UrlDecode(command[1]);

                    if (MessageBox.Show("Change " + Core.GetName(UserID) + "'s name to " + name + "?", "Change Name", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        Core.RenameUser(UserID, name);
                }

                else if (url == "im")
                {
                    if (IM != null)
                        IM.OpenIMWindow(UserID);
                }

                else if (url == "mail")
                {
                    if (Mail != null)
                        Mail.OpenComposeWindow(UserID);
                }

                else if (url == "buddy_who")
                {
                    if(Buddy != null)
                        Buddy.ShowIdentity(UserID);
                }

                else if (url == "trust")
                {
                    Core.Trust.LinkupTo(UserID, ProjectID);
                }

                else if (url == "untrust")
                {
                    Core.Trust.UnlinkFrom(UserID, ProjectID);
                }
            }

            else if (CurrentMode == StatusModeType.Network)
            {
                if (url == "settings")
                {
                    new DeOps.Interface.Settings.Connection(Core).ShowDialog(this);
                }
            }

            e.Cancel = true;
        }
Пример #7
0
        private void ScopeLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            GetTextDialog getText = new GetTextDialog(PlanRes.Schedule, "Sub-Levels", "How many levels down is this item visible? 0 for Personal, -1 for Everyone", CurrentScope.ToString());

            if (getText.ShowDialog() == DialogResult.OK)
            {
                short levels;
                short.TryParse(getText.ResultBox.Text, out levels);

                SetScopeLink(levels);
            }
        }
Пример #8
0
        public static bool VerifyPassphrase(OpCore core, ThreatLevel threat)
        {
            //crit revise
            if (threat != ThreatLevel.High)
                return true;

            bool trying = true;

            while (trying)
            {
                GetTextDialog form = new GetTextDialog(core, core.User.GetTitle(), "Enter Passphrase", "");

                form.StartPosition = FormStartPosition.CenterScreen;
                form.ResultBox.UseSystemPasswordChar = true;

                if (form.ShowDialog() != DialogResult.OK)
                    return false;

                byte[] key = Utilities.GetPasswordKey(form.ResultBox.Text, core.User.PasswordSalt);

                if (Utilities.MemCompare(core.User.PasswordKey, key))
                    return true;

                MessageBox.Show("Wrong passphrase", "DeOps");
            }

            return false;
        }
Пример #9
0
        void Menu_AddGroup(object sender, EventArgs e)
        {
            GetTextDialog add = new GetTextDialog("Add to Group", "Enter the name of the group to add to", "");

            if (add.ShowDialog() == DialogResult.OK && add.ResultBox.Text != "" )
            {
                foreach (BuddyItem item in SelectedItems)
                    if (item.User != 0)
                        Buddies.AddtoGroup(item.User, add.ResultBox.Text);
            }
        }
Пример #10
0
        public static void AddBuddyDialog(OpCore core, string link)
        {
            GetTextDialog add = new GetTextDialog("Add Buddy", "Enter a buddy link", link);
            add.BigResultBox();

            if (add.ShowDialog() == DialogResult.OK)
                try
                {
                    core.Buddies.AddBuddy(add.ResultBox.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
        }
Пример #11
0
        private void StatusBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            string url = e.Url.OriginalString;

            if (GuiUtils.IsRunningOnMono() && url.StartsWith("wyciwyg"))
            {
                return;
            }

            if (url.StartsWith("about:blank"))
            {
                return;
            }

            url = url.Replace("http://", "");
            url = url.TrimEnd('/');

            string[] command = url.Split('/');


            if (CurrentMode == StatusModeType.Project)
            {
                if (url == "rename")
                {
                    GetTextDialog rename = new GetTextDialog("Rename Project", "Enter new name for project " + Core.Trust.GetProjectName(ProjectID), Core.Trust.GetProjectName(ProjectID));

                    if (rename.ShowDialog() == DialogResult.OK)
                    {
                        Core.Trust.RenameProject(ProjectID, rename.ResultBox.Text);
                    }
                }

                else if (url == "leave")
                {
                    if (MessageBox.Show("Are you sure you want to leave " + Core.Trust.GetProjectName(ProjectID) + "?", "Leave Project", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Core.Trust.LeaveProject(ProjectID);
                    }
                }

                else if (url == "settings")
                {
                    new DeOps.Interface.Settings.Operation(Core).ShowDialog(this);
                }
            }

            else if (CurrentMode == StatusModeType.Group)
            {
                if (url == "add_buddy")
                {
                    BuddyView.AddBuddyDialog(Core, "");
                }

                else if (url == "add_group")
                {
                    // not enabled yet
                }

                else if (command[0] == "rename_group")
                {
                    string name = command[1];

                    GetTextDialog rename = new GetTextDialog("Rename Group", "Enter a new name for group " + name, name);

                    if (rename.ShowDialog() == DialogResult.OK)
                    {
                        Core.Buddies.RenameGroup(name, rename.ResultBox.Text);
                    }
                }

                else if (command[0] == "remove_group")
                {
                    string name = command[1];

                    if (MessageBox.Show("Are you sure you want to remove " + name + "?", "Remove Group", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Core.Buddies.RemoveGroup(name);
                    }
                }
            }

            else if (CurrentMode == StatusModeType.User)
            {
                if (url == "rename_user")
                {
                    GetTextDialog rename = new GetTextDialog("Rename User", "New name for " + Core.GetName(UserID), Core.GetName(UserID));

                    if (rename.ShowDialog() == DialogResult.OK)
                    {
                        Core.RenameUser(UserID, rename.ResultBox.Text);
                    }
                }

                else if (url == "trust_accept")
                {
                    Core.Trust.AcceptTrust(UserID, ProjectID);
                }

                else if (command[0] == "change_title")
                {
                    string def = command[1];

                    GetTextDialog title = new GetTextDialog("Change Title", "Enter title for " + Core.GetName(UserID), def);

                    if (title.ShowDialog() == DialogResult.OK)
                    {
                        Core.Trust.SetTitle(UserID, ProjectID, title.ResultBox.Text);
                    }
                }

                else if (url == "edit_location")
                {
                    GetTextDialog place = new GetTextDialog("Change Location", "Where is this instance located? (home, work, mobile?)", "");

                    if (place.ShowDialog() == DialogResult.OK)
                    {
                        Core.User.Settings.Location = place.ResultBox.Text;
                        Core.Locations.UpdateLocation();

                        Core.RunInCoreAsync(() => Core.User.Save());
                    }
                }

                else if (url == "edit_status")
                {
                    // show edit status dialog available / away / invisible
                    new StatusForm(Core).ShowDialog();
                }

                else if (url == "unignore")
                {
                    if (MessageBox.Show("Stop ignoring " + Core.GetName(UserID) + "?", "Ignore", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Core.Buddies.Ignore(UserID, false);
                    }
                }

                else if (command[0] == "project")
                {
                    uint id = uint.Parse(command[1]);

                    if (UI.GuiMain != null && UI.GuiMain.GetType() == typeof(MainForm))
                    {
                        ((MainForm)UI.GuiMain).ShowProject(id);
                    }
                }

                else if (command[0] == "use_name")
                {
                    string name = System.Web.HttpUtility.UrlDecode(command[1]);

                    if (MessageBox.Show("Change " + Core.GetName(UserID) + "'s name to " + name + "?", "Change Name", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Core.RenameUser(UserID, name);
                    }
                }

                else if (url == "im")
                {
                    if (IM != null)
                    {
                        IM.OpenIMWindow(UserID);
                    }
                }

                else if (url == "mail")
                {
                    if (Mail != null)
                    {
                        Mail.OpenComposeWindow(UserID);
                    }
                }

                else if (url == "buddy_who")
                {
                    if (Buddy != null)
                    {
                        Buddy.ShowIdentity(UserID);
                    }
                }

                else if (url == "trust")
                {
                    Core.Trust.LinkupTo(UserID, ProjectID);
                }

                else if (url == "untrust")
                {
                    Core.Trust.UnlinkFrom(UserID, ProjectID);
                }
            }

            else if (CurrentMode == StatusModeType.Network)
            {
                if (url == "settings")
                {
                    new DeOps.Interface.Settings.Connection(Core).ShowDialog(this);
                }
            }

            e.Cancel = true;
        }