/* public constructors */ public EditMemoDialog(Window parentWindow, Memo editMemo) : base(parentWindow, "EditMemoDialog") { SharedConstructor (); theMemo = editMemo; subjectEntry.Text = editMemo.Subject; memoTextView.Buffer.Text = editMemo.Text; Dialog.Title = "Edit Memo"; TreeIter iter; if (networksListStore.GetIterFirst (out iter)) { do { Network thisNetwork = networksListStore.GetValue(iter, 0) as Network; if (thisNetwork == editMemo.Network) { networksComboBox.SetActiveIter (iter); networksComboBox.Sensitive = false; break; } } while (networksListStore.IterNext (ref iter)); } //foreach (FileLink f in theMemo.FileLinks) { //Dim newItem As ListViewItem = lstvFiles.Items.Add(f.FileName) //newItem.SubItems.Add(SetBytes(f.FileSize)) //newItem.Tag = f //} }
public Message CreateAddMemoMessage(Memo memo) { MemoInfo memoInfo = new MemoInfo (memo); Message message = new Message (network, MessageType.AddMemo); message.Content = memoInfo; return message; }
internal void ProcessAddMemoMessage(Node messageFrom, MemoInfo memoInfo) { Memo memo = new Memo (network, memoInfo); if (!Core.IsLocalNode(memo.Node)) { if (network.TrustedNodes.ContainsKey(memo.Node.NodeID) && memo.Verify() == false) { LoggingService.LogWarning("Ignored a memo with an invalid signature!"); return; } network.AddOrUpdateMemo(memo); } }
internal void ProcessAddMemoMessage(Node messageFrom, MemoInfo memoInfo) { Memo memo = new Memo(network, memoInfo); if (!memo.Node.IsLocal) { if (network.TrustedNodes.ContainsKey(memo.Node.NodeID) && memo.Verify() == false) { Core.LoggingService.LogWarning("Ignored a memo with an invalid signature!"); return; } network.AddOrUpdateMemo(memo); } }
internal void ProcessDeleteMemoMessage(Node messageFrom, string memoId) { if (network.HasMemo(memoId)) { Memo theMemo = network.GetMemo(memoId); if (messageFrom == theMemo.Node) { network.RemoveMemo(theMemo); } else { Core.LoggingService.LogWarning("Someone tired to delete someone else's memo!"); } } }
public MemoWindow(Memo memo) : base("MemoWindow") { lblSubject.Markup = String.Format("<b>{0}</b>", GLib.Markup.EscapeText(memo.Subject)); lblPostedBy.Text = memo.Node.ToString(); lblDate.Text = memo.CreatedOn.ToString(); txtMemo.Buffer.Text = memo.Text; base.Window.Title = memo.Subject; networkLabel.Text = memo.Network.NetworkName; this.memo = memo; eventbox2.ModifyBg(StateType.Normal, new Gdk.Color(0xff,0xff,0xff)); if (!memo.Network.TrustedNodes.ContainsKey(memo.Node.NodeID)) { if (Core.IsLocalNode(memo.Node)) { alignmentSignatureInfo.Visible = false; } else { lblSignatureStatus.Markup = "<b>Unable to verify digital signature (Node not trusted)</b>"; signedByButton.Sensitive = false; signatureImage.IconName = "dialog-warning"; } } else { lblSignatureStatus.Markup = "<b>This memo has a valid digital signature.</b>"; } lblSignatureInfo.Text = String.Format("{0} ({1})", memo.Node.NickName, memo.Node.NodeID); fileListStore = new ListStore(typeof(string),typeof(string)); fileList.Model = fileListStore; fileList.AppendColumn("FileName", new CellRendererText(), "text",0); fileList.HeadersVisible = false; /* if (memo.FileLinks.Count > 0) { foreach (FileLink thisFile in memo.FileLinks) { fileListStore.AppendValues ( new object[] { thisFile.FileName + " (" + FileFind.Common.FormatBytes(thisFile.FileSize) + ")", thisFile.FilePath }); } hboxFilesList.Visible = true; } */ }
internal void AddMemo(Memo memo) { if (memo.ID == null) { throw new Exception("Cannot add a memo with no ID"); } lock (memos) { memos.Add(memo.ID, memo); } OnMemoAdded(memo); }
public Message CreateDelMemoMessage(Memo theMemo) { Message theMessage = new Message(network, MessageType.DeleteMemo); theMessage.Content = theMemo.ID; return theMessage; }
private void network_MemoDeleted(Network network, Memo memo) { memoTreeStore.RemoveItem (network, memo); Gui.MainWindow.RefreshCounts(); memoCount -= 1; }
/* private methods */ private void on_postButton_clicked(object sender, EventArgs e) { Network network = GetSelectedNetwork(); if (network == null) { Gui.ShowMessageDialog ("You must select a network.", Dialog); return; } /*theMemo.FileLinks.Clear(); foreach (object[] row in fileListStore) { theMemo.FileLinks.Add(row[0].ToString()); }*/ bool isNew = false; if (theMemo == null) { foreach (Memo m in network.Memos) { if (m.Subject == subjectEntry.Text & Core.IsLocalNode(m.Node)) { Gui.ShowMessageDialog ("You have already posted a memo with the specified subject, please select another.",Dialog); return; } } theMemo = new Memo(network); isNew = true; } theMemo.Subject = subjectEntry.Text; theMemo.Text = memoTextView.Buffer.Text; theMemo.Sign (); network.PostMemo (theMemo); if (isNew) Gui.ShowMessageDialog("Your memo has been posted.", base.Dialog); else Gui.ShowMessageDialog("Your memo has been updated.", base.Dialog); Dialog.Respond(ResponseType.Ok); Dialog.Hide(); }
internal void AddOrUpdateMemo(Memo memo) { lock (memos) { if (memos.ContainsKey(memo.ID)) { Memo existingMemo = memos[memo.ID]; //existingMemo.FileLinks = memo.FileLinks; existingMemo.Subject = memo.Subject; existingMemo.Text = memo.Text; OnMemoUpdated(memo); } else { AddMemo(memo); } } }
internal void AppendNetworkState(NetworkState stateObject) { if (stateObject.KnownConnections != null) { foreach (ConnectionInfo connection in stateObject.KnownConnections) { this.ProcessNewConnection (connection); } } if (stateObject.KnownChatRooms != null) { foreach (ChatRoomInfo roomInfo in stateObject.KnownChatRooms) { lock (chatRooms) { if (!chatRooms.ContainsKey(roomInfo.Id)) { ChatRoom newRoom = new ChatRoom(this, roomInfo); AddChatRoom(newRoom); } } ChatRoom realRoom = chatRooms[roomInfo.Id]; foreach (string nodeId in roomInfo.Users) { Node currentNode = GetNode(nodeId); if (currentNode != null) { if (!realRoom.Users.ContainsKey(currentNode.NodeID)) { if (currentNode.NodeID == Core.MyNodeID) { // err.. but.. i'm not in here!! LoggingService.LogWarning("Someone thought I was in {0} but I'm not!!", realRoom.Name); this.LeaveChat(realRoom); } else { realRoom.AddUser(currentNode); OnJoinedChat (new ChatEventArgs (currentNode, realRoom)); } } } else { LoggingService.LogWarning("TRIED TO ADD NON-EXISTANT NODE {0} TO CHATROOM {1}", nodeId, roomInfo.Name); } } } } if (stateObject.KnownMemos != null) { foreach (MemoInfo memoInfo in stateObject.KnownMemos) { lock (memos) { if (memos.ContainsKey(memoInfo.ID)) { Memo existingMemo = memos[memoInfo.ID]; existingMemo.Subject = memoInfo.Subject; existingMemo.Text = memoInfo.Text; OnMemoUpdated (existingMemo); } else { Memo memo = new Memo (this, memoInfo); AddMemo(memo); } } } } }
public void PostMemo(Memo memo) { lock (memos) { if (!memos.ContainsKey(memo.ID)) { AddMemo(memo); } else { OnMemoUpdated(memo); } } SendBroadcast(MessageBuilder.CreateAddMemoMessage(memo), LocalNode); Core.Settings.SyncNetworkInfoAndSave(); }
private void network_MemoAdded(Network network, Memo memo) { TreeIter iter = memoTreeStore.AddItem (network, memo); if (Core.IsLocalNode(memo.Node)) { memoList.Selection.SelectIter (iter); memoList.GrabFocus(); } UpdateMemoList (); memoCount += 1; }
public void DeleteMemo(Memo m) { if (Core.IsLocalNode(m.Node)) { RemoveMemo(m); SendBroadcast(MessageBuilder.CreateDelMemoMessage(m), LocalNode); } else { throw new InvalidOperationException(); } Core.Settings.SyncNetworkInfoAndSave(); }
protected virtual void OnMemoUpdated(Memo memo) { LoggingService.LogInfo("Memo updated: {0} by {1}.", memo.Subject, memo.Node); if (MemoUpdated != null) { MemoUpdated (this, memo); } }
protected virtual void OnMemoDeleted(Memo memo) { LoggingService.LogInfo("Memo deleted: " + memo.Subject); if (MemoDeleted != null) { MemoDeleted (this, memo); } }
internal void RemoveMemo(Memo memo) { lock (memos) { memos.Remove(memo.ID); } OnMemoDeleted(memo); }
private void network_MemoUpdated(Network network, Memo memo) { UpdateMemoList (); }