Esempio n. 1
0
        private bool PreProcessLink(string arg)
        {
            try
            {
                arg = arg.TrimEnd('/'); // copy so modifications arent permanent

                if (arg.Contains("/file/"))
                {
                    FileLink link = FileLink.Decode(arg, null);

                    var ui = FindCoreUI(link.PublicOpID);

                    if (ui != null)
                    {
                        ShareService share = ui.Core.GetService(DeOps.Services.ServiceIDs.Share) as ShareService;
                        share.DownloadLink(arg);

                        if (ui.GuiMain != null && !ui.GuiMain.ShowExistingView(typeof(SharingView)))
                        {
                            ui.ShowView(new SharingView(ui.Core, ui.Core.UserID), true);
                        }

                        return(true);
                    }
                }

                else if (arg.Contains("/ident/"))
                {
                    IdentityLink link = IdentityLink.Decode(arg);

                    var target = FindCoreUI(link.PublicOpID);

                    if (target != null)
                    {
                        BuddyView.AddBuddyDialog(target.Core, arg);
                        return(true);
                    }
                }
            }
            catch { }

            return(false);
        }
Esempio n. 2
0
 private void AddButton_Click(object sender, EventArgs e)
 {
     BuddyView.AddBuddyDialog(Core, "");
 }
Esempio n. 3
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;
        }