예제 #1
0
 void searchCallback(Model.Commands.SearchResultCommand c)
 {
     if (c.keyword == keyword)
     {
         try
         {
             this.Invoke(new Action(delegate
             {
                 resultsBox.BeginUpdate();
             }));
         }
         catch
         {
             return; //disposed
         }
         string username = "";
         foreach (var v in App.theCore.peerManager.allPeers)
         {
             if (v.id == c.myId)
             {
                 username = v.username;
                 break;
             }
         }
         foreach (Dimension.Model.Commands.FSListing f in c.folders)
         {
             ListViewItem i = new ListViewItem();
             i.Text = f.name;
             i.SubItems.Add(ByteFormatter.formatBytes(f.size));
             i.SubItems.Add(username);
             i.Tag = new SearchThingy()
             {
                 fsListing = f, userId = c.myId
             };
             this.Invoke(new Action(delegate
             {
                 resultsBox.Items.Add(i);
             }));
         }
         foreach (Dimension.Model.Commands.FSListing f in c.files)
         {
             ListViewItem i = new ListViewItem();
             i.Text = f.name;
             i.SubItems.Add(ByteFormatter.formatBytes(f.size));
             i.SubItems.Add(username);
             i.Tag = new SearchThingy()
             {
                 fsListing = f, userId = c.myId
             };
             this.Invoke(new Action(delegate
             {
                 resultsBox.Items.Add(i);
             }));
         }
         this.Invoke(new Action(delegate
         {
             resultsBox.EndUpdate();
         }));
     }
 }
예제 #2
0
        void update()
        {
            string s = "";

            s += "Internal IP Addresses: ";
            foreach (System.Net.IPAddress a in App.theCore.internalIPs)
            {
                s += a.ToString() + " ";
            }
            s += Environment.NewLine;
            s += "External IP Address: " + App.bootstrap.publicDataEndPoint.Address.ToString() + Environment.NewLine;

            s += "Internal TCP Port: " + App.bootstrap.internalDataPort.ToString() + Environment.NewLine;
            s += "External TCP Port: " + App.bootstrap.publicDataEndPoint.Port.ToString() + Environment.NewLine;

            s += "Internal UDP Port: " + App.bootstrap.internalControlPort.ToString() + Environment.NewLine;
            s += "External UDP Port: " + App.bootstrap.publicControlEndPoint.Port.ToString() + Environment.NewLine;

            s += "Internal Kademlia (UDP) Port: " + App.bootstrap.internalDHTPort.ToString() + Environment.NewLine;
            s += "External Kademlia (UDP) Port: " + App.bootstrap.publicDHTPort.ToString() + Environment.NewLine;


            portsTextBox.Text = s;

            s  = "";
            s += "Successful UDP command receives from other machines: " + App.theCore.udpCommandsNotFromUs.ToString() + Environment.NewLine;
            s += "Successful incoming TCP connections: " + App.theCore.incomingTcpConnections.ToString() + Environment.NewLine;
            s += "Successful incoming UDT connections: " + App.theCore.incomingUdtConnections.ToString() + Environment.NewLine;
            s += "Successful outgoing TCP connections: " + Model.ReliableOutgoingConnection.successfulConnections + Environment.NewLine;
            s += "Successful outgoing UDT connections: " + Model.UdtOutgoingConnection.successfulConnections.ToString() + Environment.NewLine;


            eventsBox.Text = s;

            s  = "*** Protocol Traffic Analysis ***" + Environment.NewLine;
            s += "(Excluding bulk data such as file transfers)" + Environment.NewLine;
            s += Environment.NewLine;
            s += "*** Incoming ***" + Environment.NewLine;
            lock (App.theCore.incomingTraffic)
                foreach (string t in App.theCore.incomingTraffic.Keys)
                {
                    s += t + ": " + ByteFormatter.formatBytes(App.theCore.incomingTraffic[t]) + Environment.NewLine;
                }

            s += Environment.NewLine;
            s += "*** Outgoing ***" + Environment.NewLine;
            lock (App.theCore.outgoingTraffic)
                foreach (string t in App.theCore.outgoingTraffic.Keys)
                {
                    s += t + ": " + ByteFormatter.formatBytes(App.theCore.outgoingTraffic[t]) + Environment.NewLine;
                }

            trafficBox.Text = s;


            systemLogBox.Text = Model.SystemLog.theLog;

            updateFont();
        }
예제 #3
0
        void load()
        {
            if (App.settings.getBool("Use UPnP", true))
            {
                UPnPButton.Checked = true;
                manuallyForwardPortsButton.Checked = false;
            }
            else
            {
                UPnPButton.Checked = false;
                manuallyForwardPortsButton.Checked = true;
            }
            udpDataPortBox.Value    = App.settings.getInt("Default Data Port", 0);
            dhtPortBox.Value        = App.settings.getInt("Default DHT Port", 0);
            udpControlPortBox.Value = App.settings.getInt("Default Control Port", Model.NetConstants.controlPort);
            usernameBox.Text        = App.settings.getString("Username", Environment.MachineName);
            descriptionBox.Text     = App.settings.getString("Description", "");

            downloadFolderInput.Text = App.settings.getString("Default Download Folder", "C:\\Downloads");
            flashNameDropBox.Checked = App.settings.getBool("Flash on Name Drop", true);
            playSoundsBox.Checked    = App.settings.getBool("Play sounds", true);

            minimizeToTrayBox.Checked = App.settings.getBool("Minimize to Tray", true);
            autoRejoinBox.Checked     = App.settings.getBool("Auto Rejoin on Startup", true);
            showAFKBox.Checked        = App.settings.getBool("Show AFK", true);

            updateWithoutPromptingBox.Checked = App.settings.getBool("Update Without Prompting", false);

            reverseDefaultBox.Checked      = App.settings.getBool("Default to Reverse Connection", false);
            alwaysRendezvousButton.Checked = App.settings.getBool("Always Rendezvous", false);

            fontSelectBox.Text = App.settings.getString("Font", "Lucida Console");
            if (App.comicSansOnly)
            {
                fontSelectBox.Items.Clear();
                fontSelectBox.Items.Add("Comic Sans MS");
                fontSelectBox.SelectedIndex = 0;
            }
            int numShares = App.fileListDatabase.getInt(App.settings.settings, "Root Share Count", 0);

            for (int i = 0; i < numShares; i++)
            {
                Model.RootShare r = App.fileListDatabase.getObject <Model.RootShare>(App.settings.settings, "Root Share " + i.ToString());

                if (r != null)
                {
                    ListViewItem li = new ListViewItem(r.name);
                    li.SubItems.Add(r.fullPath.Replace('/', System.IO.Path.DirectorySeparatorChar));
                    li.SubItems.Add(ByteFormatter.formatBytes(r.size));
                    li.Tag = r;
                    sharesListView.Items.Add(li);
                }
            }
        }
예제 #4
0
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            Model.Transfer[] z;
            lock (Model.Transfer.transfers)
                z = Model.Transfer.transfers.ToArray();

            string fingerprint = "";

            fingerprint += z.Length.ToString();
            foreach (Model.Transfer t in z)
            {
                fingerprint += t.completed.ToString() + t.download.ToString() + t.filename + t.path + t.protocol + t.rate.ToString() + t.size.ToString() + t.username;
            }
            if (lastFingerprint == fingerprint)
            {
                return;
            }
            lastFingerprint = fingerprint;

            if (!isMono)
            {
                listView.BeginUpdate();
            }

            while (listView.Items.Count < z.Length)
            {
                listView.Items.Add(new ListViewItem(""));
            }
            while (listView.Items.Count > z.Length)
            {
                listView.Items.RemoveAt(listView.Items.Count - 1);
            }


            ulong upLimit   = App.settings.getULong("Global Upload Rate Limit", 0);
            ulong downLimit = App.settings.getULong("Global Download Rate Limit", 0);

            for (int i = 0; i < z.Length; i++)
            {
                string[] w = new string[10];
                w[0] = z[i].filename;
                if (z[i].download)
                {
                    w[1] = "Downloading";
                }
                else
                {
                    w[1] = "Uploading";
                }
                w[2] = z[i].username;

                string percent = ((int)((100.0 * z[i].completed) / z[i].size)).ToString() + "%";
                string limit   = "None";
                if (z[i].download)
                {
                    if (downLimit > 0)
                    {
                        limit = UI.ByteFormatter.formatBytes(downLimit) + "/s";
                    }
                }
                else
                {
                    if (upLimit > 0)
                    {
                        limit = UI.ByteFormatter.formatBytes(upLimit) + "/s";
                    }
                }
                if (z[i].con != null)
                {
                    if (z[i].con is Model.IncomingConnection)
                    {
                        if (((Model.IncomingConnection)z[i].con).rateLimiterDisabled)
                        {
                            limit = "Bypassed";
                        }
                    }
                    else if (z[i].con is Model.OutgoingConnection)
                    {
                        if (((Model.OutgoingConnection)z[i].con).rateLimiterDisabled)
                        {
                            limit = "Bypassed";
                        }
                    }
                }

                string eta;
                var    timeElapsed           = DateTime.Now.Subtract(z[i].timeCreated);
                float  fraction              = 0;
                float  proportionateFraction = 0f;
                if (z[i].completed > 0 && z[i].size > 0)
                {
                    fraction = z[i].completed / (float)z[i].size;
                    proportionateFraction = (z[i].completed - z[i].startingByte) / (float)(z[i].size - z[i].startingByte);
                }
                double seconds;

                if (fraction == 0)
                {
                    seconds = 0;
                }
                else
                {
                    seconds = (timeElapsed.TotalSeconds * (1.0f / proportionateFraction)) - timeElapsed.TotalSeconds;
                }
                TimeSpan timeSpan = new TimeSpan(0, 0, (int)seconds);
                eta = timeSpan.ToString();


                w[3] = ByteFormatter.formatBytes(z[i].rate) + "/s";
                w[4] = limit;
                w[5] = eta;
                w[6] = ByteFormatter.formatBytes(z[i].completed);
                w[7] = percent;
                w[8] = ByteFormatter.formatBytes(z[i].size);
                w[9] = z[i].protocol;

                while (listView.Items[i].SubItems.Count < w.Length)
                {
                    listView.Items[i].SubItems.Add("");
                }
                for (int x = 0; x < 10; x++)
                {
                    if (listView.Items[i].SubItems[x].Text != w[x])
                    {
                        listView.Items[i].SubItems[x].Text = w[x];
                    }
                }
                listView.Items[i].Tag = z[i];
            }


            if (!isMono)
            {
                listView.EndUpdate();
            }
        }
예제 #5
0
        void doUpdateUserList()
        {
            var items = allPeersInCircle;

            userListView.BeginUpdate();
            while (userListView.Items.Count < items.Length)
            {
                ListViewItem i = new ListViewItem();
                i.SubItems.Add("");
                i.SubItems.Add("");
                i.SubItems.Add("");
                userListView.Items.Add(i);
            }
            while (userListView.Items.Count > items.Length)
            {
                userListView.Items.RemoveAt(0);
            }
            for (int i = 0; i < items.Length; i++)
            {
                userListView.Items[i].Tag = items[i];

                /* string s1 = items[i].username;
                 * string s2 = "";
                 *
                 * for (int i2 = 0; i2 < s1.Length; i2++)
                 *   if (char.IsLetterOrDigit(s1[i2]) || s1[i2] == ' ' || s1[i2] == '_')
                 *       s2 += s1[i2];*/

                string s2 = items[i].username;

                if (items[i].maybeDead)
                {
                    userListView.Items[i].ForeColor = SystemColors.GrayText;
                }
                else
                {
                    userListView.Items[i].ForeColor = SystemColors.WindowText;
                }
                Font b = userListView.Font;
                if (items[i].behindDoubleNAT)
                {
                    b = new Font("Comic Sans MS", b.SizeInPoints);
                }

                if (items[i].probablyDead)
                {
                    userListView.Items[i].Font = new Font(b, FontStyle.Italic);
                }
                else
                {
                    userListView.Items[i].Font = new Font(b, FontStyle.Regular);
                }


                if (items[i].afk.HasValue)
                {
                    userListView.Items[i].Text = s2 + (items[i].afk.Value ? " (AFK)" : "");
                }
                else
                {
                    userListView.Items[i].Text = s2;
                }
                userListView.Items[i].SubItems[1].Text = (items[i].buildNumber.ToString());
                userListView.Items[i].SubItems[2].Text = (ByteFormatter.formatBytes(items[i].share));
                userListView.Items[i].SubItems[3].Text = (items[i].description);
            }
            userListView.EndUpdate();
        }
예제 #6
0
        void doUpdate(Model.Commands.FileListing list)
        {
            connected      = true;
            ignoreReselect = true;
            foldersView.BeginUpdate();
            //foldersView.Nodes.Clear();
            TreeNode root = traverse(list.path);

            root.Nodes.Clear();
            foreach (Model.Commands.FSListing i in list.folders)
            {
                TreeNode t = new TreeNode(i.name);
                t.Name = i.name;
                root.Nodes.Add(t);
            }
            foldersView.EndUpdate();
            filesView.BeginUpdate();
            filesView.Items.Clear();

            if (list.path != "/")
            {
                filesView.Items.Add(new ListViewItem(".."));
            }

            foreach (Model.Commands.FSListing i in list.folders)
            {
                ListViewItem l = new ListViewItem();
                l.Text = i.name;
                l.Name = i.name;
                l.SubItems.Add(ByteFormatter.formatBytes(i.size));
                l.SubItems.Add(DateFormatter.formatDate(i.updated));
                l.Tag = i;
                filesView.Items.Add(l);

                try
                {
                    if (!iconCache.Images.ContainsKey("Folder"))
                    {
                        iconCache.Images.Add("Folder", IconReader.GetFolderIcon(IconReader.IconSize.Small, IconReader.FolderType.Closed));
                    }
                    l.ImageKey = "Folder";
                }
                catch
                {
                    //don't care
                }
            }
            foreach (Model.Commands.FSListing i in list.files)
            {
                ListViewItem l = new ListViewItem();
                l.Text = i.name;
                l.Name = i.name;
                l.SubItems.Add(ByteFormatter.formatBytes(i.size));
                l.SubItems.Add(DateFormatter.formatDate(i.updated));
                l.Tag = i;
                filesView.Items.Add(l);

                string s = i.name;
                if (i.name.Contains("."))
                {
                    s = s.Substring(s.LastIndexOf(".") + 1);
                }

                try
                {
                    if (!iconCache.Images.ContainsKey(s))
                    {
                        iconCache.Images.Add(s, IconReader.GetFileIcon("filename." + s, IconReader.IconSize.Small, false));
                    }
                    l.ImageKey = s;
                }
                catch
                {
                    //don't care
                }
            }
            filesView.EndUpdate();
            ignoreReselect = false;
            updateFilterList();
        }