Beispiel #1
0
        //constructor to publish a list of files
        public CServerPublishFiles(MemoryStream buffer, CFilesList FilesList, uint startIndex)
        {
            DonkeyHeader header;

            LastFilePublished = startIndex;
            BinaryWriter writer = new BinaryWriter(buffer);

            header = new DonkeyHeader((byte)Protocol.ServerCommand.OfferFiles, writer);
            writer.Write((uint)FilesList.Count);
            uint nfiles    = 0;
            int  fileIndex = 0;

            foreach (CElement element in FilesList.Values)
            {
                fileIndex++;
                if (fileIndex < startIndex)
                {
                    continue;
                }
                if (m_AddFileToPacket(writer, element))
                {
                    nfiles++;
                }
                LastFilePublished++;
                if (nfiles >= 200)
                {
                    break;                              //TODO: check server soft limits
                }
            }
            header.Packetlength = (uint)writer.BaseStream.Length - header.Packetlength + 1;
            writer.Seek(0, SeekOrigin.Begin);
            header.Serialize(writer);
            writer.Write(nfiles);
            CLog.Log(Types.Constants.Log.Info, "FIL_PUBLISHED", nfiles);
        }
Beispiel #2
0
        public CKernel()
        {
#if VERBOSE
            LogClient = new CLogClient();
#endif
            m_PortChanged = false;
            m_Version     = (Protocol.eAnt_VERSION_MAJOR).ToString() + "." + Protocol.eAnt_VERSION.ToString("00");

            Preferences = new Config(DllDirectory, "config.xml", "0.02", "AntKernel");

            Preferences.PropertyChanged  += new Config.PropertyEventHandler(OnPropertyChanged);
            Preferences.PropertyDefaults += new Config.PropertyDefaultHandler(OnGetDefaultProperty);
            Preferences.PropertyLoaded   += new Config.PropertyLoadedHandler(OnPropertyLoaded);
            Preferences.LoadProperties();

            Globalization = new Classes.Globalization(LangDirectory, "kernel_", "xml", Preferences.GetString("Language"));



            SourcesOld      = new CSourcesOld();
            Listener        = new CListener();
            ConnectionsList = new CConnectionsList();
            ServersList     = new CServersList();

            FilesList               = new CFilesList();
            ClientsList             = new CClientsList();
            InterfaceGateway[0]     = new CInterfaceGateway();
            InterfaceGateway[0].apw = true;
            //InterfaceGateway[0].CheckPw(Preferences.GetString("RemotePassword"));
            //FilesList.LoadSharedFiles(); // > StartKernel()
            FriendsList = new CFriendsList();

            GlobalStatistics = new CStatistics();
            if (Preferences.GetBool("RemoteControlEnabled"))
            {
                Sremoto = new CRemoting();
            }
            Searchs     = new SortedList();
            Queue       = new CQueue();
            UDPListener = new CUDPListener();           // UDPListener.Start(); > StartKernel()

            CategoriesList = new CCategoriesList();

            httpDownload             = new ChttpDownload();
            httpDownload.Downloaded += new DownloadedEventHandler(OnFileDownloaded);
        }