예제 #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);
        }
예제 #2
0
        public CKernel()
        {
#if VERBOSE
            LogClient = new CLogClient();
#endif
            m_PortChanged = false;
            m_Version     = (Protocol.ELEPHANT_VERSION_MAJOR - 1).ToString() + "." + Protocol.ELEPHANT_VERSION.ToString("00");

            Preferences = new Config(DllDirectory, "config.xml", "0.02", "lphantKernel");
            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);
        }
예제 #3
0
        public CKernel()
        {
            #if VERBOSE
            LogClient=new CLogClient();
            #endif
            m_PortChanged=false;
            m_Version=(Protocol.ELEPHANT_VERSION_MAJOR-1).ToString()+"."+Protocol.ELEPHANT_VERSION.ToString("00");

            Preferences=new Config(DllDirectory, "config.xml", "0.02", "lphantKernel");
            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);
        }
예제 #4
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);
 }
예제 #5
0
 public CSharedFiles(MemoryStream buffer,CFilesList fileList)
 {
     BinaryWriter writer=new BinaryWriter(buffer);
     DonkeyHeader header=new DonkeyHeader((byte)Protocol.ClientCommand.AskSharedFilesAnswer,writer);
     writer.Write((uint)fileList.Count);
     lock(fileList)
     {
         foreach (CElement Elemento in fileList.Values)
         {
             writer.Write(Elemento.File.FileHash);
             writer.Write((uint)0);
             writer.Write((ushort)0);
             writer.Write(Elemento.File.FileType);
             // file name
             new ParameterWriter((byte)Protocol.FileTag.Name,Elemento.File.FileName,writer);
             // file size
             new ParameterWriter((byte)Protocol.FileTag.Size,Elemento.File.FileSize,writer);
         }
     }
     header.Packetlength = (uint)writer.BaseStream.Length-header.Packetlength+1;
     writer.Seek(0,SeekOrigin.Begin);
     header.Serialize(writer);
 }