Exemple #1
0
        public void AddFileFound(byte[] Hash, string name, uint size, uint avaibility, string codec, string length, uint bitrate, bool complete, uint ip, ushort port)
        {
            try
            {
                string strHash = CKernel.HashToString(Hash);

                m_sources += avaibility;
                if (ContainsKey(strHash))
                {
                    CFileFound fileFound = (CFileFound)this[strHash];
                    fileFound.UpdateFile(avaibility, name, codec, length, bitrate, complete, ip, port);
                    CKernel.SearchFileModified(fileFound, (int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
                }
                else
                {
                    CFileFound fileFound = new CFileFound(strHash, name, size, avaibility, codec, length, bitrate, complete, ip, port);
                    Add(strHash, fileFound);
                    CKernel.NewFileFound(fileFound, (int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Search error");
                Debug.WriteLine(e.ToString());
                CKernel.SearchEnded((int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
            }
        }
Exemple #2
0
        public void OnTCPSearchEnded()
        {
            if ((CKernel.Preferences.GetBool("AutoExtendSearch")) &&
                (m_sources < Protocol.MaxSearchResults) &&
                (!m_IsClientSearch) && (m_Searching))
            {
                Debug.Write("Autoextending search\n");

                m_ServerIndex = 0;
                for (uint i = 0; i < CKernel.ServersList.Count; i++)
                {
                    if ((m_sources > Protocol.MaxSearchResults) || (m_SearchCanceled))
                    {
                        break;
                    }

                    ExtendSearch();
                    Thread.Sleep(250);
                    CKernel.NewSearchProgress((int)(((float)i / (float)CKernel.ServersList.Count) * 100.0F), (int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
                }
                //m_UDPPacket.Close();
                //m_UDPPacket=null;
                if (m_ServerIndex >= CKernel.ServersList.Count)
                {
                    m_ServerIndex = 0;
                }
            }
//			else
//			{
//				if ((!m_IsClientSearch)&&(m_Searching)&&(CKernel.ServersList.ActiveServer!=null))
//					CKernel.ServersList.ActiveServer.QueryMoreResults();
//
//			}
            m_Searching = false;
            if (CKernel.Searchs.IndexOfValue(this) >= 0)
            {
                CKernel.SearchEnded((int)CKernel.Searchs.GetKey(CKernel.Searchs.IndexOfValue(this)));
            }
        }