Ejemplo n.º 1
0
        override protected void ProcessItemUpdate(DownloadQueueItem item, ecProto.ecTag tag)
        {
            item.UpdateItem(tag);

            ecProto.ecMD5 id = ((ecProto.ecTagMD5)tag).ValueMD5();
            if (!m_enc_map.ContainsKey(id))
            {
                throw new Exception("No RLE decoder for download queue item");
            }
        }
Ejemplo n.º 2
0
        override protected SharedFileItem CreateItem(ecProto.ecTag tag)
        {
            ecProto.ecMD5  id       = ((ecProto.ecTagMD5)tag).ValueMD5();
            string         filename = ((ecProto.ecTagString)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_NAME)).StringValue();
            Int64          filesize = (Int64)((ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SIZE_FULL)).Value64();
            SharedFileItem i        = new SharedFileItem(id, filename, filesize);

            //i.UpdateItem(tag);

            return(i);
        }
Ejemplo n.º 3
0
        public void UpdateItem(ecProto.ecTag tag)
        {
            ecProto.ecTagInt itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SIZE_DONE);
            if (itag != null)
            {
                m_size_done = itag.Value64();
            }
            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SIZE_XFER);
            if (itag != null)
            {
                m_size_xfered = itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SPEED);
            if (itag != null)
            {
                m_speed = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT);
            if (itag != null)
            {
                m_src_count = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT_A4AF);
            if (itag != null)
            {
                m_a4af_src_count = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT_NOT_CURRENT);
            if (itag != null)
            {
                m_non_current_src_count = (Int32)itag.Value64();
            }

            itag = (ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SOURCE_COUNT_XFER);
            if (itag != null)
            {
                m_xfer_src_count = (Int32)itag.Value64();
            }

            ecProto.ecTagCustom gapstat  = (ecProto.ecTagCustom)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_GAP_STATUS);
            ecProto.ecTagCustom partstat = (ecProto.ecTagCustom)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_PART_STATUS);
            m_decoder.Decode(gapstat.Value(), partstat.Value());

            ecProto.ecTagCustom reqstat = (ecProto.ecTagCustom)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_REQ_STATUS);
            BinaryReader        br      = new BinaryReader(new MemoryStream(reqstat.Value()));

            m_req_parts = new GapBuffer(reqstat.Value(), reqstat.Value().Length);
            DrawLine();
        }
Ejemplo n.º 4
0
        void ProcessUpdate(ecProto.ecPacket packet, ecProto.ecPacket full_req)
        {
            m_owner.MyBeginUpdate();
            LinkedList <ecProto.ecTag> .Enumerator i = packet.GetTagIterator();
            while (i.MoveNext())
            {
                ecProto.ecTag t = i.Current;
                // sometimes reply contains additional tags
                if (t.Name() != m_item_tagname)
                {
                    continue;
                }
                ecProto.ecMD5 item_id = ((ecProto.ecTagMD5)t).ValueMD5();
                if (m_items_hash.ContainsKey(item_id))
                {
                    T item = m_items_hash[item_id];
                    ProcessItemUpdate(item, t);

                    if (m_owner != null)
                    {
                        m_owner.UpdateItem(item);
                    }
                }
                else
                {
                    if (m_inc_tags)
                    {
                        T item = CreateItem(t);
                        m_items.AddLast(item);
                        m_items_hash[item_id] = item;

                        if (m_owner != null)
                        {
                            m_owner.InsertItem(item);
                        }
                    }
                    else
                    {
                        full_req.AddSubtag(CreateItemTag(item_id));
                    }
                }
                //
                // now process item deletion
                //
                // TODO
            }
            m_owner.MyEndUpdate();
        }
Ejemplo n.º 5
0
        override protected DownloadQueueItem CreateItem(ecProto.ecTag tag)
        {
            ecProto.ecMD5 id       = ((ecProto.ecTagMD5)tag).ValueMD5();
            string        filename = ((ecProto.ecTagString)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_NAME)).StringValue();
            Int64         filesize = (Int64)((ecProto.ecTagInt)tag.SubTag(ECTagNames.EC_TAG_PARTFILE_SIZE_FULL)).Value64();

            PartFileEncoderData e = new PartFileEncoderData((int)(filesize / 9728000), 10);

            m_enc_map[id] = e;

            DownloadQueueItem i = new DownloadQueueItem(id, filename, filesize, e);

            i.AllocColorLine(m_new_item_status_length);

            i.UpdateItem(tag);

            return(i);
        }
Ejemplo n.º 6
0
        void StatsReply(ecProto.ecPacket packet)
        {
            ecProto.ecTag t = null;
            t = packet.SubTag(ECTagNames.EC_TAG_STATS_DL_SPEED);
            int dl_speed = ((ecProto.ecTagInt)t).ValueInt();

            t = packet.SubTag(ECTagNames.EC_TAG_STATS_UL_SPEED);
            int ul_speed = ((ecProto.ecTagInt)t).ValueInt();

            //string server = ((ecProto.ecTagString)t).ToString();

            ecProto.ecConnStateTag connState =
                new ecProto.ecConnStateTag((ecProto.ecTagInt)packet.SubTag(ECTagNames.EC_TAG_CONNSTATE));

            textBoxDownSpeed.Text = "Down:" + ValueToPrefix(dl_speed) + "/s";
            textBoxUpSpeed.Text   = "Up:" + ValueToPrefix(ul_speed) + "/s";
            if (connState.IsConnected())
            {
                if (connState.IsConnectedED2K())
                {
                    textLinktatus.Text = "ED2K: connected";
                    //ecProto.ecTagString server_name = (ecProto.ecTagString)server.SubTag(ECTagNames.EC_TAG_SERVER_NAME);
                    //toolStripStatusServer.Text = server_name.StringValue();
                }
                else
                {
                    //toolStripStatusServer.Text = "";
                    if (connState.IsConnectingED2K())
                    {
                        textLinktatus.Text = "ED2K: connecting ...";
                    }
                    else
                    {
                        textLinktatus.Text = "ED2K: disconnected";
                    }
                }
                if (connState.IsConnectedKademlia())
                {
                    //textLinktatus.Text = "KAD: connected";
                }
            }
        }
Ejemplo n.º 7
0
 override protected void ProcessItemUpdate(SharedFileItem item, ecProto.ecTag tag)
 {
 }
Ejemplo n.º 8
0
 abstract protected T CreateItem(ecProto.ecTag tag);
Ejemplo n.º 9
0
 //
 // derived class must provide
 //
 abstract protected void ProcessItemUpdate(T item, ecProto.ecTag tag);
Ejemplo n.º 10
0
 virtual public I ID(ecProto.ecTag tag)
 {
     return(default(I));
 }