public override string GetTitle(bool small) { if (small) { return("Board"); } string title = ""; if (UserID == Core.UserID) { title += "My "; } else { title += Core.GetName(UserID) + "'s "; } if (ProjectID != 0) { title += Core.Trust.GetProjectName(ProjectID) + " "; } title += "Board"; return(title); }
private void ReceiveMessage(ChatText message, RudpSession session) { if (Core.Buddies.IgnoreList.SafeContainsKey(session.UserID)) { return; } // remote's command low, is my command high // do here otherwise have to send custom roomID packets to selfs/lowers/highers if (Trust != null && session.UserID != Core.UserID) { // if check fails then it is loop node sending data, keep it unchanged if (message.Kind == RoomKind.Command_High && Trust.IsLowerDirect(session.UserID, message.ProjectID)) { message.Kind = RoomKind.Command_Low; } else if (message.Kind == RoomKind.Command_Low && Trust.IsHigher(session.UserID, message.ProjectID)) { message.Kind = RoomKind.Command_High; } else if (message.Kind == RoomKind.Live_High) { message.Kind = RoomKind.Live_Low; } else if (message.Kind == RoomKind.Live_Low) { message.Kind = RoomKind.Live_High; } } ulong id = IsCommandRoom(message.Kind) ? GetRoomID(message.ProjectID, message.Kind) : message.RoomID; ChatRoom room = null; // if not in room let remote user know if (!RoomMap.TryGetValue(id, out room) || !room.Active) { SendStatus(session); return; } // if sender not in room if (!room.Members.SafeContains(session.UserID)) { return; } if (!ChatNewsUpdate) { ChatNewsUpdate = true; Core.MakeNews(ServiceIDs.Chat, Core.GetName(session.UserID) + " is chatting", session.UserID, 0, false); } ProcessMessage(room, new ChatMessage(Core, session, message)); }
public void GetPublicList(ulong user) { if (Core.InvokeRequired) { Core.RunInCoreAsync(() => GetPublicList(user)); return; } ShareCollection collection; if (!Collections.SafeTryGetValue(user, out collection)) { collection = new ShareCollection(user); Collections.SafeAdd(user, collection); } AddTargets(collection.ToRequest, user, 0); foreach (DhtClient target in collection.ToRequest) { RudpSession session = Network.RudpControl.GetActiveSession(target); if (session == null) { Network.RudpControl.Connect(target); collection.Status = "Connecting to " + Core.GetName(target.UserID); } else { SendPublicRequest(session, collection); } } }
private void LoadVis(Dictionary <ulong, short> scope) { foreach (ulong id in scope.Keys) { VisList.Items.Add(new VisItem(Core.GetName(id), id, scope[id])); } }
public SendFileForm(CoreUI ui, ulong user) { InitializeComponent(); UI = ui; Core = ui.Core; User = user; Sharing = Core.GetService(ServiceIDs.Share) as ShareService; if (user == 0) { Text = "Send File to Room"; } else { Text = "Send File to " + Core.GetName(user); } Sharing.Local.Files.LockReading(() => { foreach (SharedFile share in Sharing.Local.Files) { if (share.Hash != null) // processed { RecentCombo.Items.Add(share); } } }); if (RecentCombo.Items.Count > 0) { RecentCombo.SelectedIndex = 0; } }
private ProfileTemplate GetTemplate(ulong id) { OpProfile profile = Profiles.GetProfile(id); if (profile == null) { return(null); } ProfileTemplate template = new ProfileTemplate(false, true); template.User = Core.GetName(id);; template.FilePath = Profiles.GetFilePath(profile); template.FileKey = profile.File.Header.FileKey; if (!profile.Loaded) { Profiles.LoadProfile(profile.UserID); } try { using (TaggedStream stream = new TaggedStream(template.FilePath, Core.GuiProtocol)) using (IVCryptoStream crypto = IVCryptoStream.Load(stream, template.FileKey)) { int buffSize = 4096; byte[] buffer = new byte[4096]; long bytesLeft = profile.EmbeddedStart; while (bytesLeft > 0) { int readSize = (bytesLeft > (long)buffSize) ? buffSize : (int)bytesLeft; int read = crypto.Read(buffer, 0, readSize); bytesLeft -= (long)read; } foreach (ProfileAttachment attach in profile.Attached) { if (attach.Name.StartsWith("template")) { byte[] html = new byte[attach.Size]; crypto.Read(html, 0, (int)attach.Size); template.Html = UTF8Encoding.UTF8.GetString(html); SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider(); template.Hash = sha1.ComputeHash(html); break; } } } } catch { return(null); } return(template); }
private void SetPerson(ulong id) { PersonID = id; if (id != 0) { PickLink.Text = Core.GetName(PersonID); } }
public override string GetTitle(bool small) { if (small) { return("Compose"); } if (CustomTitle != null) { return(CustomTitle + Core.GetName(DefaultID)); } if (DefaultID != 0) { return("Mail " + Core.GetName(DefaultID)); } return("Compose Mail"); }
public IdentityForm(OpCore core, ulong user) { InitializeComponent(); string name = core.GetName(user); HeaderLabel.Text = HeaderLabel.Text.Replace("<name>", name); HelpLabel.Text = HelpLabel.Text.Replace("<name>", name); LinkBox.Text = core.GetIdentity(user); }
public RemoveLinks(OpCore core, List <ulong> ids) : base(core) { InitializeComponent(); PersonIDs = ids; foreach (ulong id in PersonIDs) { PeopleList.Items.Add(new RemoveItem(id, core.GetName(id))); } }
private void Cache_FileAquired(OpVersionedFile file) { // get profile OpProfile prevProfile = GetProfile(file.UserID); OpProfile newProfile = new OpProfile(file); ProfileMap.SafeAdd(file.UserID, newProfile); if (file.UserID == Core.UserID) { LocalProfile = newProfile; } if ((newProfile == LocalProfile) || (prevProfile != null && prevProfile.Loaded)) { LoadProfile(newProfile.UserID); } // update subs if (Network.Established) { List <LocationData> locations = new List <LocationData>(); Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { if (newProfile.UserID == Core.UserID || Trust.IsHigher(newProfile.UserID, project)) { Trust.GetLocsBelow(Core.UserID, project, locations); } } }); Store.PublishDirect(locations, newProfile.UserID, ServiceID, 0, file.SignedHeader); } if (ProfileUpdate != null) { Core.RunInGuiThread(ProfileUpdate, newProfile); } if (Core.NewsWorthy(newProfile.UserID, 0, false)) { Core.MakeNews(ServiceIDs.Profile, "Profile updated by " + Core.GetName(newProfile.UserID), newProfile.UserID, 0, true); } }
private void UpdateName() { RemoteName = Core.GetName(UserID); if (External != null) { External.Text = "IM " + RemoteName; } }
public ComposeMail(CoreUI ui, MailService mail, ulong id) { InitializeComponent(); UI = ui; Mail = mail; Core = mail.Core; DefaultID = id; if (id != 0) { ToTextBox.Text = Core.GetName(id); ToIDs.Add(id); } }
public InviteForm(CoreUI ui, ChatService chat, ulong user, ChatRoom room) { InitializeComponent(); UI = ui; Core = ui.Core; Chat = chat; Room = room; IntroLabel.Text = IntroLabel.Text.Replace("<name>", Core.GetName(user)); NameLabel.Text = room.Title; TypeLabel.Text = room.Kind.ToString(); }
public AcceptFileForm(OpCore core, DhtClient client, SharedFile share) { InitializeComponent(); Core = core; Sharing = core.GetService(ServiceIDs.Share) as ShareService; TheFile = share; Source = client; DescriptionLabel.Text = core.GetName(client.UserID) + " wants to send you a file"; NameLabel.Text = TheFile.Name; SizeLabel.Text = Utilities.ByteSizetoDecString(TheFile.Size); }
public override string GetTitle(bool small) { if (small) { return("Post"); } string title = ""; // Edit Post: Hey Guys if (EditPost != null) { title += "Edit Post: " + EditPost.Info.Subject; } // replying to (parent thread's name) else if (Reply) { title += "Reply to " + ParentPost.Info.Subject; } // post to x's project board else { title += "Post to "; if (UserID == Core.UserID) { title += "My "; } else { title += Core.GetName(UserID) + "'s "; } if (ProjectID != 0) { title += Core.Trust.GetProjectName(ProjectID) + " "; } title += "Board"; } return(title); }
public void BlockView_Load(object sender, EventArgs e) { if (Mode == BlockViewMode.New) { Text = "New Schedule Block"; OkButton.Text = "Create"; } if (Mode == BlockViewMode.Edit) { Text = "Edit Schedule Block"; OkButton.Text = "Edit"; } if (Mode == BlockViewMode.Show) { Text = Core.GetName(View.UserID) + "'s Block"; OkButton.Hide(); } }
public override string GetTitle(bool small) { if (small) { return("Share"); } string title = ""; if (UserID == Core.UserID) { title += "My Shared Files"; } else { title += Core.GetName(UserID) + "'s Publicly Shared"; } return(title); }
public void Log(string entry) { //PeerID 10:23:250 : string prefix = Comm.PeerID.ToString() + " "; prefix += Core.TimeNow.Minute.ToString() + ":" + Core.TimeNow.Second.ToString(); if (Core.TimeNow.Millisecond == 0) { prefix += ":00"; } else { prefix += ":" + Core.TimeNow.Millisecond.ToString().Substring(0, 2); } Core.Network.UpdateLog("RUDP " + Core.GetName(UserID), prefix + ": " + entry); //byte[] data = strEnc.GetBytes(Comm.PeerID.ToString() + ": " + entry + "\r\n"); //DebugWriter.Write(data, 0, data.Length); }
public IMForm(CoreUI ui) : base(ui.Core) { InitializeComponent(); UI = ui; Core = ui.Core; GuiUtils.SetupToolstrip(TopStrip, new OpusColorTable()); GuiUtils.FixMonoDropDownOpening(OptionsButton, OptionsButton_DropDownOpening); UI.ShowView += ShowExternal; Text = "IM - " + Core.GetName(Core.UserID); BuddyList.Init(UI, Core.Buddies, SelectionInfo, true); IM = UI.GetService(ServiceIDs.IM) as IMUI; SelectionInfo.Init(UI); SelectionInfo.ShowNetwork(); if (GuiUtils.IsRunningOnMono()) { AddButton.Text = "Add"; SharedButton.Text = "Files"; } Rectangle screen = Screen.GetWorkingArea(this); Location = new Point(screen.Width - Width, screen.Height / 2 - Height / 2); ShowExternal(new Info.InfoView(Core, false, true)); }
public IgnoreItem(OpCore core, ulong id) { Name = core.GetName(id); ID = id; }
public DiffForm(InfoPanel info, ulong whoID, string what, StorageFile file, bool history) { InitializeComponent(); Core = info.ParentView.Core; Info = info; Target = file; TargetID = whoID; TargetHistory = history; Text = Target.Name + " Differences"; // set what txt // my/ben's Changes // my/ben's Integrated Changes // my/ben's History from <date> string who = (whoID == Core.UserID) ? "My" : (Core.GetName(whoID) + "'s"); WhatLabel.Text = who + " " + what; // local if (!info.CurrentFile.Temp) { if (Utilities.MemCompare(Target.InternalHash, ((StorageFile)Info.CurrentFile.Details).InternalHash)) { LocalNote.Text = "Identical"; } } else { CurrentRadio.Enabled = false; } // changes foreach (ChangeRow change in Info.SortChanges(Info.CurrentChanges)) { ChangesCombo.Items.Add(new ComboFileItem(this, change.ID, (StorageFile)change.Item)); } if (ChangesCombo.Items.Count > 0) { ChangesCombo.SelectedIndex = 0; } else { ChangesRadio.Enabled = false; } // integrated foreach (ChangeRow integrated in Info.SortChanges(Info.CurrentIntegrated)) { IntegratedCombo.Items.Add(new ComboFileItem(this, integrated.ID, (StorageFile)integrated.Item)); } if (IntegratedCombo.Items.Count > 0) { IntegratedCombo.SelectedIndex = 0; } else { IntegratedRadio.Enabled = false; } // history info.CurrentFile.Archived.LockReading(delegate() { foreach (StorageFile item in info.CurrentFile.Archived) { HistoryCombo.Items.Add(new ComboFileItem(this, 0, item)); } }); if (HistoryCombo.Items.Count > 0) { HistoryCombo.SelectedIndex = 0; } else { HistoryRadio.Enabled = false; } // using UsingCombo.Items.Add("WinMerge"); UsingCombo.Items.Add("Open Seperately"); UsingCombo.Items.Add("Another Tool..."); UsingCombo.SelectedIndex = 0; }
public void Dispose() { if (Disposing != null) { Disposing(); } HashFiles.Dispose(); CopyFiles.Dispose(); // lock down working List <LockError> errors = new List <LockError>(); foreach (WorkingStorage working in Working.Values) { working.LockAll(errors); if (working.Modified) { working.SaveWorking(); } } Working.Clear(); // delete completely folders made for other user's storages Trust.ProjectRoots.LockReading(delegate() { foreach (uint project in Trust.ProjectRoots.Keys) { string path = Core.User.RootPath + Path.DirectorySeparatorChar + Trust.GetProjectName(project) + " Storage"; string local = Core.GetName(Core.UserID); if (Directory.Exists(path)) { foreach (string dir in Directory.GetDirectories(path)) { if (Path.GetFileName(dir) != local) { try { Directory.Delete(dir, true); } catch { errors.Add(new LockError(dir, "", false, LockErrorType.Blocked)); } } } } } }); // security warning: could not secure these files if (errors.Count > 0) { string message = "Security Warning: Not able to delete these files, please do it manually\n"; foreach (LockError error in errors) { if (error.Type == LockErrorType.Blocked) { message += error.Path; } } Core.UserMessage(message); } // kill events Core.SecondTimerEvent -= Core_SecondTimer; Core.MinuteTimerEvent -= Core_MinuteTimer; Network.CoreStatusChange -= new StatusChange(Network_StatusChange); Cache.FileAquired -= new FileAquiredHandler(Cache_FileAquired); Cache.FileRemoved -= new FileRemovedHandler(Cache_FileRemoved); Cache.Dispose(); Core.Transfers.FileSearch[ServiceID, FileTypeData] -= new FileSearchHandler(Transfers_DataFileSearch); Core.Transfers.FileRequest[ServiceID, FileTypeData] -= new FileRequestHandler(Transfers_DataFileRequest); Core.Trust.LinkUpdate -= new LinkUpdateHandler(Trust_Update); }
private void ShowMessage(LocalMail message) { if (message == null) { SetHeader(""); MessageBody.Clear(); return; } string content = "<b><font size=2>" + message.Info.Subject + "</font></b> from " + Core.GetName(message.Header.SourceID) + ", sent " + Utilities.FormatTime(message.Info.Date) + @"<br> <b>To:</b> " + Mail.GetNames(message.To) + "<br>"; if (message.CC.Count > 0) { content += "<b>CC:</b> " + Mail.GetNames(message.CC) + "<br>"; } if (message.Attached.Count > 1) { string attachHtml = ""; for (int i = 0; i < message.Attached.Count; i++) { if (message.Attached[i].Name == "body") { continue; } attachHtml += "<a href='http://attach/" + i.ToString() + "'>" + message.Attached[i].Name + "</a> (" + Utilities.ByteSizetoString(message.Attached[i].Size) + "), "; } attachHtml = attachHtml.TrimEnd(new char[] { ' ', ',' }); content += "<b>Attachments: </b> " + attachHtml; } content += "<br>"; string actions = ""; if (message.Header.TargetID == Core.UserID) { actions += @"<a href='http://reply" + "'>Reply</a>"; } actions += @", <a href='http://forward'>Forward</a>"; actions += @", <a href='http://delete'>Delete</a>"; content += "<b>Actions: </b>" + actions.Trim(',', ' '); SetHeader(content); // body try { using (TaggedStream stream = new TaggedStream(Mail.GetLocalPath(message.Header), Core.GuiProtocol)) using (CryptoStream crypto = IVCryptoStream.Load(stream, message.Header.LocalKey)) { int buffSize = 4096; byte[] buffer = new byte[4096]; long bytesLeft = message.Header.FileStart; while (bytesLeft > 0) { int readSize = (bytesLeft > buffSize) ? buffSize : (int)bytesLeft; int read = crypto.Read(buffer, 0, readSize); bytesLeft -= read; } // load file foreach (MailFile file in message.Attached) { if (file.Name == "body") { byte[] msgBytes = new byte[file.Size]; crypto.Read(msgBytes, 0, (int)file.Size); UTF8Encoding utf = new UTF8Encoding(); MessageBody.Clear(); MessageBody.SelectionFont = new Font("Tahoma", 9.75f); MessageBody.SelectionColor = Color.Black; if (message.Info.Format == TextFormat.RTF) { MessageBody.Rtf = utf.GetString(msgBytes); } else { MessageBody.Text = utf.GetString(msgBytes); } MessageBody.DetectLinksDefault(); } } } } catch (Exception ex) { MessageBox.Show(this, "Error Opening Mail: " + ex.Message); } if (message.Header.Read == false) { message.Header.Read = true; Mail.SaveMailbox = true; if (MessageView.SelectedNodes.Count > 0) { ((MessageNode)MessageView.SelectedNodes[0]).UpdateRow(); } } }
private void UpdatePlanItems(GoalNode node) { PlanListItem ReselectPlanItem = null; if (PlanList.SelectedItems.Count > 0) { ReselectPlanItem = PlanList.SelectedItems[0] as PlanListItem; } PlanList.Items.Clear(); if (node == null) { Selected = null; DelegateLink.Hide(); PlanList.Columns[0].Text = "Plan"; //splitContainer2.Panel1Collapsed = true; return; } Selected = node.Goal; // set delegate task vis if (Selected.Person == Core.UserID && Trust.HasSubs(Selected.Person, View.ProjectID)) { DelegateLink.Show(); } else { DelegateLink.Hide(); } if (Selected.Person == Core.UserID) { AddItemLink.Show(); } else { AddItemLink.Hide(); } // name's Plan for <goal> PlanList.Columns[0].Text = Core.GetName(node.Goal.Person) + "'s Plan for " + node.Goal.Title; // set plan items OpPlan plan = Plans.GetPlan(Selected.Person, true); if (plan == null) // re-searched at during selection { return; } if (plan.ItemMap.ContainsKey(Head.Ident)) { foreach (PlanItem item in plan.ItemMap[Head.Ident]) { if (item.BranchUp == Selected.BranchDown) { PlanListItem row = new PlanListItem(item); if (ReselectPlanItem != null && item == ReselectPlanItem.Item) { row.Selected = true; } PlanList.Items.Add(row); FormatTime(row); } } } PlanList.Invalidate(); }
public OpBuddy AddBuddy(ulong user) { return(AddBuddy(Core.GetName(user), Core.KeyMap[user])); }
private void OkButton_Click(object sender, EventArgs e) { // get selected file / id StorageFile selected = null; ulong selectedID = 0; bool selectedHistory = false; string selectedText = ""; if (CurrentRadio.Checked) { selected = (StorageFile)Info.CurrentFile.Details; selectedID = Info.ParentView.UserID; selectedText = "Current"; } if (ChangesRadio.Checked) { ComboFileItem item = (ComboFileItem)ChangesCombo.SelectedItem; selected = item.File; selectedID = item.ID; selectedText = "Changes"; } if (IntegratedRadio.Checked) { ComboFileItem item = (ComboFileItem)IntegratedCombo.SelectedItem; selected = item.File; selectedID = item.ID; selectedText = "Integrated Changes"; } if (HistoryRadio.Checked) { ComboFileItem item = (ComboFileItem)HistoryCombo.SelectedItem; selected = item.File; selectedID = Info.ParentView.UserID; selectedHistory = HistoryCombo.SelectedIndex != 0; selectedText = "History from " + item.File.Date.ToLocalTime().ToString(); } string who = (selectedID == Core.UserID) ? "My " : (Core.GetName(selectedID) + "'s "); selectedText = who + selectedText; if (selected == null) { MessageBox.Show("No file Selected to Compare to"); return; } // unlock files List <LockError> errors = new List <LockError>(); Cursor = Cursors.WaitCursor; string fileA = Info.Storages.UnlockFile(TargetID, Info.ParentView.ProjectID, Info.CurrentFolder.GetPath(), Target, TargetHistory, errors); string fileB = Info.Storages.UnlockFile(selectedID, Info.ParentView.ProjectID, Info.CurrentFolder.GetPath(), selected, selectedHistory, errors); Cursor = Cursors.Default; if (errors.Count > 0) { LockMessage.Alert(Info.ParentView, errors); return; } if (UsingCombo.Text == "WinMerge") { // /e close with esc // /ub dont add to MRU // /wl left side read only // /wr right side read only (only NOT if local dht/not history etc..) // /dl left side desc, target info // /dr right side desc, current file info if (!File.Exists("C:\\Program files\\WinMerge\\WinMerge.exe")) { MessageBox.Show("Can't find WinMerge"); return; } string arguments = "/e /ub "; arguments += "/dl \"" + WhatLabel.Text + "\" "; arguments += "/dr \"" + selectedText + "\" "; if (TargetID != Core.UserID || TargetHistory) { arguments += "/wl "; } if (selectedID != Core.UserID || selectedHistory) { arguments += "/wr "; } arguments += "\"" + fileA + "\" "; arguments += "\"" + fileB + "\" "; Process.Start("C:\\Program files\\WinMerge\\WinMerge.exe", arguments); } if (UsingCombo.Text == "Open Seperately") { // open if (fileA != null && File.Exists(fileA)) { System.Diagnostics.Process.Start(fileA); } if (fileB != null && File.Exists(fileB)) { System.Diagnostics.Process.Start(fileB); } Info.CurrentFile.UpdateInterface(); Info.RefreshItem(); } if (UsingCombo.Text == "Another Tool...") { } // if success Close(); }
void UpdateNode(MemberNode node) { if (!Room.Members.SafeContains(node.UserID)) { if (node.IsLoopRoot) { node.Text = "Trust Loop"; } return; } // get if node is connected bool connected = (Room.Active && (node.UserID == Core.UserID || Chat.Network.RudpControl.GetActiveSessions(node.UserID).Count > 0)); // get away status bool away = false; foreach (ClientInfo info in Core.Locations.GetClients(node.UserID)) { if (info != null && info.Data.Away) { away = true; } } node.Text = Core.GetName(node.UserID); if (away) { node.Text += " [away]"; } // bold if local if (node.UserID == Core.UserID) { node.Font = new Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); } // color based on connect status Color foreColor = connected ? Color.Black : Color.Gray; if (node.ForeColor == foreColor) { MemberTree.Invalidate(); return; // no change } /*if (!node.Unset) // on first run don't show everyone as joined * { * string message = ""; * * if (connected) * message = Core.GetName(node.UserID) + " has joined the room"; * else * message = Core.GetName(node.UserID) + " has left the room"; * * * // dont log * Chat_Update(new ChatMessage(Core, message, true)); * }*/ node.Unset = false; node.ForeColor = foreColor; MemberTree.Invalidate(); }
private void TransferView_Load(object sender, EventArgs e) { RefreshView(); Text = Core.GetName(Core.UserID) + "'s Transfers"; }
private void Update(IMStatus status) { ulong key = status.UserID; // connected to jonn smith @home, @work // connecting to john smith // disconnected from john smith string places = ""; status.Connected = false; status.Connecting = false; status.Away = false; string awayMessage = ""; int activeCount = 0; foreach (RudpSession session in Network.RudpControl.SessionMap.Values.Where(s => s.UserID == key)) { if (session.Status == SessionStatus.Closed) { continue; } status.Connecting = true; if (session.Status == SessionStatus.Active) { status.Connected = true; ClientInfo info = Locations.GetLocationInfo(key, session.ClientID); awayMessage = ""; if (info != null) { if (info.Data.Away) { status.Away = true; awayMessage = " " + info.Data.AwayMessage; } } activeCount++; places += " @" + Locations.GetLocationName(key, session.ClientID) + awayMessage + ","; } } if (status.Away) { status.Text = Core.GetName(key) + " is Away "; if (activeCount > 1) { status.Text += places.TrimEnd(','); } else { status.Text += awayMessage; } } else if (status.Connected) { status.Text = "Connected to " + Core.GetName(key); if (activeCount > 1) { status.Text += places.TrimEnd(','); } } else if (status.Connecting) { status.Text = "Connecting to " + Core.GetName(key); } else { status.Text = "Disconnected from " + Core.GetName(key); } Core.RunInGuiThread(StatusUpdate, status.UserID); }