Swapper.NET Logo

Source Code Interfaces ~ IP2PStackInterfaces.cs


using System;
using System.Collections;
using System.IO;
using System.Net;
using RevolutionaryStuff.JBT;
using RevolutionaryStuff.P2P.Basics;

/*
 * Everything in here is obsolete!
 * It will be modified or replaced in the near future
 * */
namespace RevolutionaryStuff.P2P.Basics
{
	public interface IDeleteable 
	{
		void Delete();
	}

	public interface IFileServer : IFieldApplicator
	{
		/// 
		/// Name of the file server.  This is (HumanAssignedName||Hostname||Address)
		/// 
		string Name {get; set;}
		/// 
		/// The address/Port to reach the server.  The port may be 0 depending on the server type
		/// 
		System.Net.EndPoint EndPoint {get;}
		/// 
		/// An (hopefully) unique ID that was generated by the server.  Null if the server did not generate one
		/// 
		byte[] ID {get;}
		/// 
		/// A getter for the Files on the server
		/// 
		IFieldApplicatorListGetter FileSourceGetter {get;}
	}

	public interface IFileSystem : IFileServer
	{
		/// 
		/// Given an urn, find the corresponding IFileSource
		/// 
		/// The urn
		/// A filesource if the item was found, else null
		IFileSource FindByUrn(string urn);
		/// 
		/// Download a filesource OR add additional sources to an existing download
		/// 
		/// The item to be downloaded
		/// Download parameters
		/// If the returned filesource was just created or if it already existed
		/// Returns the downloadable item iff we could create/append to it, else null
		ILocalFileSource Download(IFileSource fs, DownloadAttributes downloadAttributes, out bool newlyCreated);
	}

	public interface IWebItem
	{
		/// 
		/// Gets a stream to the contents
		/// 
		/// A properly positioned stream
		Stream GetStream();
		/// 
		/// Size of the item
		/// 
		long Size { get; }
		/// 
		/// Content type of the item
		/// 
		string ContentType { get; }
		/// 
		/// List of urns
		/// 
		string[] Urns { get; }
		/// 
		/// Date this item was last modified
		/// 
		DateTime LastModified { get; }
	}

	public interface ILocalFileSource : IFileSource
	{
		/// 
		/// A unique id for this item.  Only guaranteed for the session
		/// 
		long ID { get; }
		/// 
		/// The full path of the local file
		/// 
		string FullName {get;}
		/// 
		/// Remove this from the local list
		/// 
		void Delete();
		/// 
		/// The download attributes for this item
		/// 
		DownloadAttributes DownloadAttributes { get; set; }
		/// 
		/// The state
		/// 
		FileSourceState State { get; set; }
		/// 
		/// Is this file currently shared
		/// 
		bool IsShared
		{ get; }
	}

	[Flags]
	public enum DownloadAttributes
	{
		/// 
		/// This is a normal item
		/// 
		Normal = 0,
		/// 
		/// When State==Pending, when true, don't begin a download
		/// 
		Suspended=0x1,
		/// 
		/// When true, This content should NOT be shown to a user
		/// 
		Invisible=0x2,
		/// 
		/// When true, and end user should NOT be able to delete this
		/// 
		Protected=0x4,
		/// 
		/// Append the extension given to us by the remote webserver to the filename
		/// (i.e. we get this through means like content type, content disposition, ...)
		/// 
		AppendWebserverExtension=0x8,
		/// 
		/// Only download this items if we've already started downloading it
		/// 
		OnlyDownloadIfAlreadyInProgress=0x10,
		/// 
		/// Don't look for additional sources
		/// 
		DontFindAdditionalSources=0x20,
		/// 
		/// The download must finish in this session
		/// 
		MustCompleteInThisSession=0x40
	}

}