コード例 #1
0
        void Trust_Update(OpTrust trust)
        {
            // update working projects (add)
            if (trust.UserID == Core.UserID)
            {
                OpStorage local = GetStorage(Core.UserID);

                foreach (uint project in Trust.LocalTrust.Links.Keys)
                {
                    if (!Working.ContainsKey(project))
                    {
                        if (local != null)
                        {
                            LoadHeaderFile(GetWorkingPath(project), local, false, true);
                        }

                        Working[project] = new WorkingStorage(this, project);
                    }
                }
            }

            // remove all higher changes, reload with new highers (cause link changed
            foreach (WorkingStorage working in Working.Values)
            {
                if (Core.UserID == trust.UserID || Trust.IsHigher(trust.UserID, working.ProjectID))
                {
                    working.RemoveAllHigherChanges();

                    foreach (ulong uplink in Trust.GetAutoInheritIDs(Core.UserID, working.ProjectID))
                    {
                        working.RefreshHigherChanges(uplink);
                    }
                }
            }
        }
コード例 #2
0
ファイル: IMService.cs プロジェクト: nandub/DeOps
        public void Trust_Update(OpTrust trust)
        {
            if (!ActiveUsers.Contains(trust.UserID))
            {
                return;
            }

            IMStatus status = null;

            if (IMMap.SafeTryGetValue(trust.UserID, out status))
            {
                Update(status);
            }
        }
コード例 #3
0
        public void Link_Update(OpTrust trust)
        {
            // update command/live rooms
            Trust.ProjectRoots.LockReading(delegate()
            {
                foreach (uint project in Trust.ProjectRoots.Keys)
                {
                    OpLink localLink  = Trust.LocalTrust.GetLink(project);
                    OpLink remoteLink = trust.GetLink(project);

                    if (localLink == null || remoteLink == null)
                    {
                        continue;
                    }

                    OpLink uplink           = localLink.GetHigher(true);
                    List <OpLink> downlinks = localLink.GetLowers(true);

                    // if local link updating
                    if (trust == Trust.LocalTrust)
                    {
                        // if we are in the project
                        if (localLink.Active)
                        {
                            JoinCommand(project, RoomKind.Command_High);
                            JoinCommand(project, RoomKind.Command_Low);
                            JoinCommand(project, RoomKind.Live_High);
                            JoinCommand(project, RoomKind.Live_Low);
                        }

                        // else leave any command/live rooms for this project
                        else
                        {
                            LeaveRooms(project);
                        }
                    }

                    // else if remote user updating
                    else
                    {
                        if (uplink != null)
                        {
                            if (uplink.Trust == trust || uplink.GetLowers(true).Contains(remoteLink))
                            {
                                RefreshCommand(project, RoomKind.Command_High);
                                RefreshCommand(project, RoomKind.Live_High);
                            }
                        }

                        if (downlinks.Contains(remoteLink))
                        {
                            RefreshCommand(project, RoomKind.Command_Low);
                            RefreshCommand(project, RoomKind.Live_Low);
                        }
                    }

                    Core.RunInGuiThread(Refresh);
                }
            });

            // refresh member list of any commmand/live room this person is apart of
            // link would already be added above, this ensures user is removed
            foreach (ChatRoom room in FindRoom(trust.UserID))
            {
                if (IsCommandRoom(room.Kind))
                {
                    RefreshCommand(room);
                }
                else if (room.Members.SafeContains(trust.UserID))
                {
                    Core.RunInGuiThread(room.MembersUpdate);
                }
            }
        }
コード例 #4
0
ファイル: StatusPanel.cs プロジェクト: nandub/DeOps
        public void ShowUser(ulong user, uint project)
        {
            CurrentMode = StatusModeType.User;

            UserID    = user;
            ProjectID = project;

            string header  = "";
            string content = "";


            // get trust info
            OpLink link = null, parent = null;

            if (Core.Trust != null)
            {
                link = Core.Trust.GetLink(user, project);

                if (link != null)
                {
                    parent = link.GetHigher(false);
                }
            }

            // if loop root
            if (link != null && link.IsLoopRoot)
            {
                content = "<b>Order</b><br>";

                content += "<div style='padding-left: 10;'>";

                if (link.Downlinks.Count > 0)
                {
                    foreach (OpLink downlink in link.Downlinks)
                    {
                        string entry = "";

                        if (downlink.UserID == Core.UserID)
                        {
                            entry += "<b>" + Core.GetName(downlink.UserID) + "</b> <i>trusts</i>";
                        }
                        else
                        {
                            entry += Core.GetName(downlink.UserID) + " <i>trusts</i>";
                        }

                        if (downlink.GetHigher(true) == null)
                        {
                            entry = "<font style='color: red;'>" + entry + "</font>";
                        }

                        content += entry + "<br>";
                    }

                    content += Core.GetName(link.Downlinks[0].UserID) + "<br>";
                }

                content += "</div>";

                UpdateHeader("MediumSlateBlue", "Trust Loop");
                StatusBrowser.SafeInvokeScript("SetElement", new String[] { "content", content });
                return;
            }

            // add icons on right
            content += "<div style='float: right;'>";

            Func <string, string, string> getImgLine = (url, path) => "<a href='http://" + url + "'><img style='margin:2px;' src='" + path + "' border=0></a><br>";

            if (UserID != Core.UserID && Core.GetService(ServiceIDs.IM) != null && Core.Locations.ActiveClientCount(UserID) > 0)
            {
                content += getImgLine("im", IMImg);
            }

            if (UserID != Core.UserID && Core.GetService(ServiceIDs.Mail) != null)
            {
                content += getImgLine("mail", MailImg);
            }

            content += getImgLine("buddy_who", BuddyWhoImg);

            if (UserID != Core.UserID && link != null)
            {
                OpLink local = Core.Trust.GetLink(Core.UserID, ProjectID);

                if (local != null && local.Uplink == link)
                {
                    content += getImgLine("untrust", UntrustImg);
                }
                else
                {
                    content += getImgLine("trust", TrustImg);
                }
            }

            content += "</div>";


            // name
            string username = Core.GetName(user);

            header = "<a class='header' href='http://rename_user'>" + username + "</a>";


            if (link != null)
            {
                // trust unconfirmed?
                if (parent != null && !parent.Confirmed.Contains(link.UserID))
                {
                    bool requested = parent.Requests.Any(r => r.KeyID == link.UserID);

                    string msg = requested ? "Trust Requested" : "Trust Denied";

                    if (parent.UserID == Core.UserID)
                    {
                        msg = "<b><a class='untrusted' href='http://trust_accept'>" + msg + "</a></b>";
                    }

                    msg = "<span class='untrusted'>" + msg + "</span>";

                    content += msg + "<br>";
                }

                // title
                if (parent != null)
                {
                    string title = parent.Titles.ContainsKey(UserID) ? parent.Titles[UserID] : "None";

                    if (parent.UserID == Core.UserID)
                    {
                        title = "<a href='http://change_title/" + title + "'>" + title + "</a>";
                    }

                    content += "<b>Title: </b>" + title + "<br>";
                }
                // projects
                string projects = "";
                foreach (uint id in link.Trust.Links.Keys)
                {
                    if (id != 0)
                    {
                        projects += "<a href='http://project/" + id.ToString() + "'>" + Core.Trust.GetProjectName(id) + "</a>, ";
                    }
                }
                projects = projects.TrimEnd(new char[] { ' ', ',' });

                if (projects != "")
                {
                    content += "<b>Projects: </b>" + projects + "<br>";
                }
            }


            if (Core.Buddies.IgnoreList.SafeContainsKey(user))
            {
                content += "<span class='untrusted'><b><a class='untrusted' href='http://unignore'>Ignored</a></b></span><br>";
            }


            //Locations:
            //    Home: Online
            //    Office: Away - At Home
            //    Mobile: Online, Local Time 2:30pm
            //    Server: Last Seen 10/2/2007

            string aliases   = "";
            string locations = "";

            foreach (ClientInfo info in Core.Locations.GetClients(user))
            {
                string name  = Core.Locations.GetLocationName(user, info.ClientID);
                bool   local = Core.Network.Local.Equals(info);

                if (info.Data.Name != username)
                {
                    aliases += AddAlias(info.Data.Name);
                }

                if (local)
                {
                    name = "<a href='http://edit_location'>" + name + "</a>";
                }

                locations += "<b>" + name + ": </b>";


                string status = "Online";

                if (local && Core.User.Settings.Invisible)
                {
                    status = "Invisible";
                }

                else if (info.Data.Away)
                {
                    status = "Away - " + info.Data.AwayMessage;
                }


                if (local)
                {
                    locations += "<a href='http://edit_status'>" + status + "</a>";
                }
                else
                {
                    locations += status;
                }


                if (info.Data.GmtOffset != System.TimeZone.CurrentTimeZone.GetUtcOffset(Core.TimeNow).TotalMinutes)
                {
                    locations += ", Local Time " + Core.TimeNow.ToUniversalTime().AddMinutes(info.Data.GmtOffset).ToString("t");
                }

                locations += "<br>";
            }

            if (locations == "")
            {
                content += "<b>Offline</b><br>";
            }
            else
            {
                content += "<b>Locations</b><br>";
                content += "<div style='padding-left: 10; line-height: normal'>";
                content += locations;
                content += "</div>";
            }

            // add aliases
            if (Core.Trust != null)
            {
                OpTrust trust = Core.Trust.GetTrust(user);

                if (trust != null && trust.Name != username)
                {
                    aliases += AddAlias(trust.Name);
                }
            }

            OpBuddy buddy;

            if (Core.Buddies.BuddyList.SafeTryGetValue(user, out buddy))
            {
                if (buddy.Name != username) // should be equal unless we synced our buddy list with ourselves somewhere else
                {
                    aliases += AddAlias(buddy.Name);
                }
            }

            if (aliases != "")
            {
                content += "<b>Aliases: </b>" + aliases.Trim(',', ' ') + "<br>";
            }


            UpdateHeader("MediumSlateBlue", header);
            StatusBrowser.SafeInvokeScript("SetElement", new String[] { "content", content });
        }