private OpLink GetTreeHigher(OpLink link) { if (link.LoopRoot != null) { return(link.LoopRoot); } return(link.GetHigher(false)); }
public void UpdateStatus() { // reset Font = ParentView.OnlineFont; ForeColor = Color.Black; string txt = ""; txt += Trust.Core.GetName(Link.UserID); if (Link.IsLoopRoot) { txt = "Trust Loop"; } OpLink parent = Link.GetHigher(false); if (parent != null) { bool confirmed = false; //bool requested = false; if (parent.Confirmed.Contains(Link.UserID)) { confirmed = true; } if (!confirmed) { ForeColor = Color.Red; } /*foreach (UplinkRequest request in parent.Requests) * if (request.KeyID == Link.UserID) * requested = true; * * * if (confirmed) * { } * else if (requested && parent.UserID == Trust.Core.UserID) * txt += " (Accept Trust?)"; * else if (requested) * txt += " (Trust Requested)"; * else if (parent.UserID == Trust.Core.UserID) * txt += " (Trust Denied)"; * else * txt += " (Trust Unconfirmed)";*/ } else if (!Link.Active) { txt += " (Left Project)"; } txt += " "; // tree bug not showing all text if (Text != txt) { Text = txt; } // bold selected if (ParentView.SelectedLink == Link.UserID && ParentView.Project == ParentView.SelectedProject) { Font = ParentView.SelectedFont; } // if not else, can override above if (Link.UserID == Trust.Core.UserID && Trust.Core.User.Settings.Invisible) { Font = ParentView.OfflineFont; ForeColor = Color.Gray; } }
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); } } }
public void RefreshCommand(ChatRoom room) // sends status updates to all members of room { if (!IsCommandRoom(room.Kind)) { Debug.Assert(false); return; } // remember connection status from before // nodes we arent connected to do try connect // if socket already active send status request OpLink localLink = Trust.LocalTrust.GetLink(room.ProjectID); if (localLink == null) { return; } OpLink uplink = localLink.GetHigher(true); // updates room's member list if (room.Kind == RoomKind.Command_High) { room.Members = new ThreadedList <ulong>(); if (uplink != null) { if (localLink.LoopRoot != null) { uplink = localLink.LoopRoot; room.Host = uplink.UserID; // use loop id cause 0 is reserved for no root room.IsLoop = true; } else { room.Host = uplink.UserID; room.IsLoop = false; room.AddMember(room.Host); } foreach (OpLink downlink in uplink.GetLowers(true)) { room.AddMember(downlink.UserID); } } } else if (room.Kind == RoomKind.Command_Low) { room.Members = new ThreadedList <ulong>(); room.Host = Core.UserID; room.AddMember(room.Host); foreach (OpLink downlink in localLink.GetLowers(true)) { room.AddMember(downlink.UserID); } } else if (room.Kind == RoomKind.Live_High) { // find highest thats online and make that the host, // if host changes, clear members // higher should send live lowers which members are conneted to it so everyone can sync up // location update should trigger a refresh of the live rooms } else if (room.Kind == RoomKind.Live_Low) { // just add self, dont remove members } // update dispaly that members has been refreshed Core.RunInGuiThread(room.MembersUpdate); }
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 }); }