Inheritance: Object
Example #1
0
        public UserInfoDialog(Window parent, Network network, Node node)
            : base(parent, "UserInfoDialog")
        {
            this.node    = node;
            this.network = network;

            base.Window.Title = node.ToString();

            avatarImage.Pixbuf = Gui.AvatarManager.GetAvatar(node);

            nickNameLabel.Markup = String.Format("<span weight=\"bold\" size=\"x-large\">{0}</span> on <i>{1}</i>\n<span font=\"monospace\" size=\"small\">{2}</span>",
                                                 node.NickName, network.NetworkName, Common.FormatFingerprint(node.NodeID, 4));

            realNameLabel.Text = node.RealName;
            emailLabel.Text    = node.Email;

            TreeViewColumn column;

            column = addressesTreeView.AppendColumn("Protocol", new CellRendererText(), "text", 0);

            column = addressesTreeView.AppendColumn("Address Details", new CellRendererText(), "text", 1);
            column.Expand = true;

            addressesTreeView.AppendColumn("Supported", new CellRendererText(), "text", 2);
            addressesTreeView.AppendColumn("Open Externally", new CellRendererText(), "text", 3);
            addressesTreeView.AppendColumn("Connectable", new CellRendererText(), "text", 4);

            addressListStore = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));

            IDestination[] destinations = null;
            DestinationInfo[] destinationInfos;
            if (node.IsMe) {
                destinationInfos = Core.DestinationManager.DestinationInfos;
            } else {
                destinationInfos = node.GetTrustedNode().DestinationInfos.ToArray();
                destinations = node.GetTrustedNode().Destinations;
            }

            if (destinations != null) {
                foreach (IDestination destination in destinations) {
                    addressListStore.AppendValues(destination.FriendlyTypeName, destination.ToString(), "True", destination.IsOpenExternally.ToString(), destination.CanConnect.ToString());
                }
            }

            foreach (DestinationInfo info in destinationInfos) {
                if ((!info.Supported) || destinations == null) {
                    if (node.IsMe) {
                        addressListStore.AppendValues(info.FriendlyName, String.Join(", ", info.Data), info.Supported.ToString(), info.IsOpenExternally.ToString(), String.Empty);
                    } else {
                        addressListStore.AppendValues(info.FriendlyName, String.Join(", ", info.Data), "False", info.IsOpenExternally.ToString(), "False");
                    }
                }
            }

            addressesTreeView.Model = addressListStore;

            clientNameLabel.Text      = node.ClientName;
            clientVersionLabel.Text   = node.ClientVersion;
            operatingSystemLabel.Text = node.OperatingSystem;
        }
Example #2
0
        public AcceptKeyDialog(Network network, ReceivedKeyEventArgs args)
            : base(null, "AcceptKeyDialog")
        {
            var publicKey = new PublicKey(args.Key.Info, args.Key.Key);
            keyTextView.Buffer.Text = publicKey.ToArmoredString();
            string nodeID = FileFind.Common.SHA512Str(publicKey.Key);
            nodeIdLabel.Text = nodeID;

            if (args.Node != null)  {
                if (nodeID.ToUpper() != args.Node.NodeID.ToUpper()) {
                    throw new Exception ("The key recieved does not match this user!");
                }
                nicknameLabel.Text = args.Node.NickName;
            } else if (args.Connection != null) {
                var conn = args.Connection;

                connectionLabel.Text = String.Format("{0} ({1})", conn.RemoteAddress, conn.Incoming ? "Incoming" : "Outgoing");
                nicknameLabel.Text = args.Key.Info;

                connectionLabel.Show();
                connectionTitleLabel.Show();
            } else {
                nicknameLabel.Text = args.Key.Info;
            }

            denyKeyButtonLabel.Text = String.Format ("Deny Key ({0})", secondsLeft);
        }
Example #3
0
 public Memo(Network network, MemoInfo memoInfo)
 {
     this.network = network;
     this.id = memoInfo.ID;
     this.node = network.Nodes[memoInfo.FromNodeID];
     this.createdOn = memoInfo.CreatedOn;
     this.signature = memoInfo.Signature;
     this.subject = memoInfo.Subject;
     this.text = memoInfo.Text;
 }
 private TreeIter IterForNetwork(Network network)
 {
     TreeIter iter;
     if (userListStore.GetIterFirst (out iter)) {
         do {
             Network thisNetwork = (Network)userListStore.GetValue (iter, 0);
             if (thisNetwork == network) {
                 return iter;
             }
         } while (userListStore.IterNext (ref iter));
     }
     return TreeIter.Zero;
 }
        private void network_UpdateNodeInfo(Network network, string oldNick, Node node)
        {
            try {
                if (oldNick != node.NickName) {
                    if (Gui.GetPrivateMessageWindow(node) != null) {
                        Gui.GetPrivateMessageWindow (node).UserInfoChanged (oldNick);
                    }
                }

                RefreshUserList();
                Gui.MainWindow.UpdateStatusText ();
            } catch (Exception ex) {
                LoggingService.LogError(ex);
                Gui.ShowErrorDialog (ex.ToString(), Gui.MainWindow.Window);
            }
        }
        public ChatRoomInvitationDialog(Network network, Node inviteFrom, ChatRoom room, ChatInviteInfo invitation)
            : base("ChatRoomInvitationDialog")
        {
            this.room = room;
            this.invitation = invitation;

            descLabel.Markup = String.Format(descLabel.Text, GLib.Markup.EscapeText(inviteFrom.ToString()), GLib.Markup.EscapeText(room.Name));

            messageContainer.Visible = !String.IsNullOrEmpty(invitation.Message);
            messageLabel.Text = GLib.Markup.EscapeText(invitation.Message);

            passwordInfoBox.Visible = room.HasPassword;

            passwordEntry.Text = invitation.Password;
            showPasswordCheck.Visible = !String.IsNullOrEmpty(invitation.Password);

            Validate();
        }
        public PrivateChatSubpage(Network network, Node node)
            : base()
        {
            this.node = node;
            this.network = network;
            this.trustedNodeInfo = network.TrustedNodes[node.NodeID];

            if (trustedNodeInfo == null) {
                throw new Exception("Cannot have a private conversation with an untrusted node.");
            }

            base.userList.Parent.Visible = false;

            base.SendMessage += base_SendMessage;

            AddToChat(null, String.Format("Now talking with {0} ({1}).", trustedNodeInfo.Identifier, Common.FormatFingerprint(trustedNodeInfo.NodeID)));
            AddToChat(null, "This conversation is secure.");
        }
Example #8
0
        public Node(Network network, string nodeID)
        {
            if (network == null) {
                throw new ArgumentNullException("network");
            }

            if (nodeID.Length != 128) {
                throw new ArgumentException("Invalid NodeID specified.");
            }

            this.nodeID = nodeID;
            this.network = network;

            alg = new RijndaelManaged();
            diffieHellman = new DiffieHellmanManaged();

            if (nodeID != Core.MyNodeID) {
                directory = new NodeDirectory(this);
            }
        }
Example #9
0
        public ChatRoomSubpage(ChatRoom room)
            : base()
        {
            this.thisRoom = room;
            this.network = room.Network;

            userListStore = new ListStore (typeof (Node));
            userList.Model = userListStore;

            var iconCell = new CellRendererPixbuf();
            var textCell = new CellRendererText();

            var column = new TreeViewColumn();
            column.PackStart(iconCell, false);
            column.SetCellDataFunc(iconCell, new TreeCellDataFunc(UserListIconFunc));

            column.PackStart(textCell, true);
            column.SetCellDataFunc(textCell, new TreeCellDataFunc (UserListTextFunc));

            userList.AppendColumn(column);

            userList.HeadersVisible = false;
            userList.RowActivated += on_userList_RowActivated;
            userList.ButtonReleaseEvent +=  on_userList_button_release_event;

            foreach (Node n in room.Users.Values) {
                userListStore.AppendValues (n);
            }

            AddToChat (null, String.Format ("You have joined {0}.", thisRoom.Name));

            if (room.HasPassword) {
                AddToChat (null, "This chatroom is password-protected. Other users on the network who do not have the password are not able to evesdrop on the conversation.\n");
            } else {
                AddToChat (null, "This chatroom is not password-protected. Other users on the network are able to evesdrop on the conversation, regardless of if they appear to be in the room or not.\n");
            }

            base.SendMessage += base_SendMessage;
        }
 private void network_PrivateMessage(Network network, Node messageFrom, string messageText)
 {
     try {
         PrivateChatSubpage page = Gui.GetPrivateMessageWindow(messageFrom);
         if (page == null) {
             page = Gui.StartPrivateChat(network, messageFrom, false);
         }
         page.AddToChat(messageFrom, messageText);
     } catch (Exception ex) {
         LoggingService.LogError(ex);
         Gui.ShowErrorDialog (ex.ToString(), Gui.MainWindow.Window);
     }
 }
Example #11
0
 public Memo(Network network)
 {
     this.network = network;
     this.node = network.Nodes[Core.MyNodeID];
     this.createdOn = DateTime.Now;
 }
Example #12
0
        internal static Node CreateLocalNode(Network network)
        {
            if (!loaded) {
                throw new InvalidOperationException("You must call Init() first");
            }

            Node node = new Node(network, Core.MyNodeID);
            node.NickName     = Core.Settings.NickName;
            node.RealName     = Core.Settings.RealName;
            node.Email        = Core.Settings.Email;
            node.Verified     = true;

            // XXX: This is a mess. Perhaps the client should register it's name and version with Core on Init.
            object[] attrs = Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), true);
            if (attrs.Length > 0) {
                AssemblyTitleAttribute attr = (AssemblyTitleAttribute)attrs[0];
                AssemblyName asmName = Assembly.GetEntryAssembly().GetName();
                node.ClientName    = attr.Title;
                node.ClientVersion = asmName.Version.ToString();
            } else {
                node.ClientName = "Unknown";
                node.ClientVersion = "Unknown";
            }

            node.OperatingSystem = Core.OS.VersionInfo;
            return node;
        }
Example #13
0
        private static void RemoveNetwork(Network network)
        {
            network.Stop();

            networks.Remove(network);

            if (NetworkRemoved != null) {
                NetworkRemoved(network);
            }
        }
Example #14
0
        private void Connect(Network network, string address, IPAddress ip, int port)
        {
            try {
                if (!base.Dialog.Visible)
                    return;

                if (ip == null) {
                    Gui.ShowErrorDialog("Unable to resolve hostname.", Dialog);
                    return;
                }

                ITransport transport = new TcpTransport(ip, port, ConnectionType.NodeConnection);
                network.ConnectTo(transport);

                if (Gui.Settings.RecentConnections.IndexOf(address) != -1)
                    Gui.Settings.RecentConnections.Remove(address);

                Gui.Settings.RecentConnections.Insert(0, address);
                Gui.Settings.SaveSettings();

                Dialog.Respond((int)ResponseType.Ok);
            } catch (Exception ex) {
                LoggingService.LogError(ex);
                Gui.ShowErrorDialog(ex.Message, base.Dialog);
            }
        }
Example #15
0
 private void Core_NetworkRemoved(Network network)
 {
     network.UserOnline -= network_UserOnline;
 }
Example #16
0
 private void Core_NetworkAdded(Network network)
 {
     network.ReceivedSearchResult += network_ReceivedSearchResult;
 }
Example #17
0
 public ChatRoom(Network network, string id, string name)
 {
     this.network = network;
     this.id = id;
     this.name = name;
 }
Example #18
0
 private void Core_NetworkRemoved(Network network)
 {
     network.ReceivedSearchResult -= network_ReceivedSearchResult;
 }
Example #19
0
        private void Core_NetworkAdded(Network network)
        {
            Application.Invoke(delegate {
                ((ListStore)networkComboBox.Model).AppendValues(network.NetworkName, network);
            });

            network.UserOnline += network_UserOnline;
        }
Example #20
0
        private void network_LeftChat(Network network, ChatEventArgs args)
        {
            if (args.Room.InRoom == true) {
                (args.Room.Properties["Window"] as ChatRoomSubpage).RemoveUser (args.Node);
            }

            if (args.Room.Users.Count == 0) {
                chatTreeStore.RemoveItem (network, args.Room);
            } else {
                chatList.QueueDraw ();
            }

            Gui.MainWindow.RefreshCounts();
        }
Example #21
0
        private void network_JoinedChat(Network network, ChatEventArgs args)
        {
            try {
                if (chatTreeStore.ContainsItem (network, args.Room) == false) {
                    TreeIter iter = chatTreeStore.AddItem (network, args.Room);
                    if (args.Node.IsMe) {
                        chatList.Selection.SelectIter (iter);
                        chatList.GrabFocus();
                    }
                }

                if (args.Room.InRoom == true) {
                    if (args.Room.Properties.ContainsKey("Window") == false) {
                        Widget labelWidget = CreateTabLabel(args.Room.Name);

                        ChatRoomSubpage w = new ChatRoomSubpage(args.Room);
                        AppendPage(w, labelWidget);
                        args.Room.Properties.Add("Window", w);
                        w.GrabFocus();

                        tabLabelPages[labelWidget] = w;
                    } else {
                        (args.Room.Properties["Window"] as ChatRoomSubpage).AddUser (args.Node);
                    }
                }

                chatList.QueueDraw ();
                Gui.MainWindow.RefreshCounts();

            } catch (Exception ex) {
                LoggingService.LogError(ex);
            }
        }
Example #22
0
 private void Core_NetworkAdded(Network network)
 {
     network.JoinedChat += (JoinPartChatEventHandler) DispatchService.GuiDispatch (new JoinPartChatEventHandler (network_JoinedChat));
     network.LeftChat += (JoinPartChatEventHandler) DispatchService.GuiDispatch (new JoinPartChatEventHandler (network_LeftChat));
 }
 private void network_NewIncomingConnection(Network network, LocalNodeConnection c)
 {
     try {
         AddConnectionEventHandlers(c);
     } catch (Exception ex) {
         LoggingService.LogError(ex);
         Gui.ShowErrorDialog (ex.ToString(), Gui.MainWindow.Window);
     }
 }
 private void network_ReceivedNonCriticalError(Network network, Node from, MeshworkError error)
 {
     try {
         UpdateConnectionList();
     } catch (Exception ex) {
         LoggingService.LogError(ex);
         Gui.ShowErrorDialog (ex.ToString(), Gui.MainWindow.Window);
     }
 }
Example #25
0
 public MessageBuilder(Network n)
 {
     network = n;
 }
        private bool network_ReceivedKey(Network network, ReceivedKeyEventArgs args)
        {
            try {
                bool accept = false;
                AutoResetEvent receiveKeyWait = new AutoResetEvent (false);

                Application.Invoke(delegate {
                    AskAcceptKey(network, args, receiveKeyWait, ref accept);
                });

                receiveKeyWait.WaitOne ();
                return accept;

            } catch (Exception ex) {
                LoggingService.LogError(ex);
                return false;
            }
        }
Example #27
0
 internal ChatRoom(Network network, ChatRoomInfo info)
 {
     this.network = network;
     this.id = info.Id;
     this.name = info.Name;
 }
        /*
        private void network_FileOffered (Network network, FileOfferedEventArgs args)
        {
            try {
                LogManager.Current.WriteToLog (args.From.NickName + " offers to send you " + args.File.FileName);

                MessageDialog dialog = new MessageDialog (null,
                        DialogFlags.Modal,
                        Gtk.MessageType.Question,
                        ButtonsType.YesNo,
                        "{0} would like to send you the following file:\n\n{1}\n\nDo you want to accept it?",
                        args.From.ToString(),
                        args.File.FileName);

                dialog.Show ();

                if (dialog.Run() == (int)Gtk.ResponseType.Yes) {
                    //network.DownloadFile (args.From, args.File.FileFullPath, args.File.File.Size);
                }

                dialog.Destroy ();
            } catch (Exception ex) {
                LoggingService.LogError(ex);
                Gui.ShowErrorDialog (ex.ToString(), Gui.MainWindow.Window);
            }
        }
        */
        private void network_ReceivedChatInvite(Network network, Node inviteFrom, ChatRoom room, ChatInviteInfo invitation)
        {
            try {
                ChatRoomInvitationDialog dialog = new ChatRoomInvitationDialog (network, inviteFrom, room, invitation);
                dialog.Show ();
            } catch (Exception ex) {
                LoggingService.LogError(ex);
                Gui.ShowErrorDialog (ex.ToString(), Gui.MainWindow.Window);
            }
        }
Example #29
0
 private void network_ReceivedSearchResult(Network network, SearchResultInfoEventArgs args)
 {
     foreach (FileSearch thisSearch in fileSearches) {
         if (thisSearch.Id == args.Info.SearchId) {
             thisSearch.AppendResults(args.Node, args.Info);
             return;
         }
     }
     LoggingService.LogWarning("Unexpected search reply.");
 }
Example #30
0
        private void network_UserOnline(Network network, Node node)
        {
            Application.Invoke(delegate {
                string text = String.Format("{0} ({1})", node.NickName, network.NetworkName);
                Console.WriteLine("Hello ! " + text);

                ((ListStore)messageSenderToComboBox.Model).AppendValues(text, network, node);
                Console.WriteLine("Added!!");
            });
        }