public void ShowProject(uint project) { CurrentMode = StatusModeType.Project; ProjectID = project; UpdateHeader("FireBrick", Core.Trust.GetProjectName(project)); string content = "<div style='padding-left: 10; line-height: 14pt;'>"; content += AddContentLink("rename", "Rename"); if (project != 0) { content += AddContentLink("leave", "Leave"); } if (project == 0 && Core.Trust.LocalTrust.Links[0].Uplink == null) { content += AddContentLink("settings", "Settings"); } content += "</div>"; UpdateContent(content); }
public void ShowNetwork() { if (GuiUtils.IsRunningOnMono()) { if (CurrentMode == StatusModeType.Network && PrevOp == Core.Network.Responsive && PrevFirewall == Core.Firewall && (Core.Context.Lookup == null || PrevLookup == Core.Context.Lookup.Network.Responsive)) { return; } } CurrentMode = StatusModeType.Network; UserID = 0; UpdateHeader("Green", "Network Status"); string content = ""; content += "<div style='padding-left: 10; line-height: 14pt;'>"; if (Core.Context.Lookup != null) { string lookup = Core.Context.Lookup.Network.Responsive ? "Connected" : "Connecting"; content += "<b>Lookup: </b>" + lookup + "<br>"; PrevLookup = Core.Context.Lookup.Network.Responsive; } string operation = Core.Network.Responsive ? "Connected" : "Connecting"; content += "<b>Network: </b>" + operation + "<br>"; PrevOp = Core.Network.Responsive; content += "<b>Firewall: </b>" + Core.Firewall.ToString() + "<br>"; PrevFirewall = Core.Firewall; content += "<b><a href='http://settings'>Settings</a></b><br>"; content += "</div>"; UpdateContent(content); }
public void ShowGroup(string name) { CurrentMode = StatusModeType.Group; BuddyGroup = name; UpdateHeader("FireBrick", BuddyGroup == null ? "Buddies" : BuddyGroup); string content = "<div style='padding-left: 10;'>"; content += AddContentLink("add_buddy", "Add Buddy"); if (BuddyGroup != null) { content += AddContentLink("remove_group/" + name, "Remove Group"); content += AddContentLink("rename_group/" + name, "Rename Group"); } //else // content += AddContentLink("add_group", "Add Group"); content += "</div>"; UpdateContent(content); }
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 }); }
public void ShowProject(uint project) { CurrentMode = StatusModeType.Project; ProjectID = project; UpdateHeader("FireBrick", Core.Trust.GetProjectName(project)); string content = "<div style='padding-left: 10; line-height: 14pt;'>"; content += AddContentLink("rename", "Rename"); if (project != 0) content += AddContentLink("leave", "Leave"); if (project == 0 && Core.Trust.LocalTrust.Links[0].Uplink == null) content += AddContentLink("settings", "Settings"); content += "</div>"; UpdateContent(content); }
public void ShowNetwork() { if (GuiUtils.IsRunningOnMono()) if(CurrentMode == StatusModeType.Network && PrevOp == Core.Network.Responsive && PrevFirewall == Core.Firewall && (Core.Context.Lookup == null || PrevLookup == Core.Context.Lookup.Network.Responsive)) return; CurrentMode = StatusModeType.Network; UserID = 0; UpdateHeader("Green", "Network Status"); string content = ""; content += "<div style='padding-left: 10; line-height: 14pt;'>"; if (Core.Context.Lookup != null) { string lookup = Core.Context.Lookup.Network.Responsive ? "Connected" : "Connecting"; content += "<b>Lookup: </b>" + lookup + "<br>"; PrevLookup = Core.Context.Lookup.Network.Responsive; } string operation = Core.Network.Responsive ? "Connected" : "Connecting"; content += "<b>Network: </b>" + operation + "<br>"; PrevOp = Core.Network.Responsive; content += "<b>Firewall: </b>" + Core.Firewall.ToString() + "<br>"; PrevFirewall = Core.Firewall; content += "<b><a href='http://settings'>Settings</a></b><br>"; content += "</div>"; UpdateContent(content); }
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 }); }