using skyscraper5.Docsis.MacManagement;
using skyscraper5.DsmCc.Descriptors;
using skyscraper5.Dvb.DataBroadcasting.IntModel;
using skyscraper5.Dvb.Descriptors;
using skyscraper5.Dvb.Psi.Model;
using skyscraper5.Dvb.SystemSoftwareUpdate.Model;
using skyscraper5.Dvb.TvAnytime;
using skyscraper5.Mhp.Si;
using skyscraper5.Mhp.Si.Model;
using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Mpeg2.Psi.Model;
using skyscraper5.Rds.Messages;
using skyscraper5.Scte35;
using skyscraper5.Skyscraper;
using skyscraper5.Skyscraper.Gps;
using skyscraper5.Skyscraper.Headless;
using skyscraper5.Skyscraper.IO.CrazycatStreamReader;
using skyscraper5.Skyscraper.Scraper.Storage.Utilities;
using skyscraper5.src.InteractionChannel.Model;
using skyscraper5.src.Skyscraper.FrequencyListGenerator;
using skyscraper5.src.Skyscraper.Scraper.Dns;
using skyscraper5.Teletext;
using skyscraper8.DvbI;
using skyscraper8.DvbNip;
using skyscraper8.Ses;
using System.Net;
using System.Net.NetworkInformation;
using skyscraper5.src.InteractionChannel.Model2;
using skyscraper8.InteractionChannel.Model;
using skyscraper8.InteractionChannel.Model2;

namespace skyscraper8.Skyscraper.Scraper.Storage
{
    public interface DataStorage : IDbBlindscanJobStorage, IDnsDataSource, DvbIDataStorage 
    {
        bool StoreTeletextPage(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine, DateTime timestamp);
        bool TestForNitNetwork(NitNetwork nitNetwork);
        void StoreNitNetwork(NitNetwork nitNetwork);
        bool UpdateNitNetwork(NitNetwork nitNetwork);
        bool TestForNitTransportStream(ushort networkId, NitTransportStream transportStream);
        void StoreNitTransportStream(ushort networkId, NitTransportStream transportStream);
        bool UpdateNitTransportStream(ushort networkId, NitTransportStream transportStream);
        bool StorePatEntry(int currentNetworkId, int currentTransportStreamId, int pmtPid, ushort programId);
        bool TestForPmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping result);
        bool StorePmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping mapping);
        bool TestForSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService);
        bool UpdateSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService);
        void StoreSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService);
        bool TestForBatBouquet(BatBouquet batBouquet);
        bool UpdateBatBouquet(BatBouquet batBouquet);
        void StoreBatBouquet(BatBouquet batBouquet);
        bool TestForBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child);
        bool UpdateBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child);
        void StoreBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child);
        bool UpdateTimeOffsetTable(int currentNetworkId, int currentTransportStreamId, DateTime utcTime, LocalTimeOffsetDescriptor ltod);
        bool UpdateTimeAndDate(int currentNetworkId, int currentTransportStreamId, DateTime utcTime);
        bool StoreEitEvent(EitEvent eitEvent);
        bool TestForAitApplication(ApplicationIdentifier aitApplicationApplicationIdentifier);
        void StoreAitApplication(AitApplication aitApplication);
        bool TestForCaSystem(int currentNetworkId, int currentTransportStreamId, int caDescriptorCaPid);
        void StoreCaSystem(int currentNetworkId, int currentTransportStreamId, CaDescriptor caDescriptor);
        bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber);
        void EnableRdsCollection(int currentNetworkId, int currentTransportStreamId, int programNumber);
        bool UpdateRdsProgrammeServiceName(int currentNetworkId, int currentTransportStreamId, int programNumber, string programmeService2);
        bool UpdateRdsRadioText(int currentNetworkId, int currentTransportStreamId, int programNumber, string text);
        bool UpdateRdsPty(int currentNetworkId, int currentTransportStreamId, int programNumber, PTY.ProgrammeTypeCodes pty);
        bool MarkAsRdsTrafficInformationProgramme(int currentNetworkId, int currentTransportStreamId, int programNumber);
        bool TestForScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert);
        void StoreScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert);
        bool IsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance);
        void MarkAsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance);
        bool SetStationIdentification(int currentNetworkId, int currentTransportStreamId, string stationIdentification);
        void StoreDsmCcDoItNowEvent(DateTime value, int currentNetworkId, int currentTransportStreamId, int programNumber, StreamEventDescriptor descriptorListStreamEventDescriptor, int pid);
        bool StoreRunningStatus(uint transportStreamId, uint originalNetworkId, uint serviceId, uint eventId, RunningStatus runningStatus, DateTime currentTime);
        void SetScte35TimeSignal(int currentNetworkId, int currentTransportStreamId, DateTime currentTime, ushort programNumber, TimeSignal timeSignal);
        bool TestForIpMacNotification(IpMacNotification notification);
        void StoreIpMacNotification(IpMacNotification notification);
        bool ImportFileKnown(FileInfo fi);
        void ImportMarkFileAsKnown(FileInfo fi, TimeSpan duration, int tstype);
        DateTime T2MiGetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid);
        void T2MiSetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid, DateTime resolveTime);
        bool TestForRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo);
        void SetRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo);
        bool UiTunerTestFor(TunerMetadata tuner);
        void UiTunerUpdate(TunerMetadata tuner);
        void UiTunerInsert(TunerMetadata tuner);
        void UiTunerGetConfiguration(TunerMetadata foundTuner);
        bool TestForDocsisUpstreamChannel(PhysicalAddress mmmSource, uint mmmFrequency, int currentLocation);
        void StoreDocsisUpstreamChannel(UpstreamChannelDescriptor mmm, int currentLocation);
        bool TestForDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int currentLocation);
        void StoreDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int currentLocation);
        bool SetCmtsIp(PhysicalAddress arpHeaderSenderHardwareAddress, IPAddress arpHeaderSenderProtocolAddress);
        bool IsDsmCcModuleBlacklisted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion);
        int? GetCurrentLocationId();
        void StoreDocsisParticipant(PhysicalAddress pa, int currentLocation);
        HeadlessJob GetQueuedJob();
        void SetQueuedJobComplete(HeadlessJob headlessJob);
        void WaitForCompletion();
        void UiSetVersion(int version);
        bool T2MiTestForTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier);
        void T2MiRememberTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier);
        void T2MiSetTransmitterTimeOffset(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier, ushort timeOffset);
        IEnumerable<Tuple<int, int, ProgramMapping>> SelectAllPmt();
        SdtService SelectSdtById(int networkId, int tsId, ushort programMappingProgramNumber);
        IEnumerable<Tuple<int, int, SdtService>> SelectAllSdt();
        void BeamsDisableAll();
        void BeamsEnable(int id, float satpos, string name, DateTime processTimestamp);
        void BeamFootprintStore(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, string name, string getPolygonString, string id);
        bool TestForBeamFootprint(int databasePointerId, DateTime databasePointerBeamsProcessTimestamp, string name, string id);
        void BeamsDisableSpecific(int databasePointerId, float databasePointerSatpos, string databasePointerName, DateTime databasePointerBeamsProcessTimestamp);
        IEnumerable<SatelliteBeam> BeamsSelectEnabled();
        List<SatelliteBeamFootprint> BeamsSelectFootprints(int satelliteBeamId, DateTime satelliteBeamProcessTimestamp);

        void InsertBlindscanJob(DbBlindscanJob jobInDb);
        void UpdateJobState(DbBlindscanJob jobInDb);
        void InsertSearchResult(DbBlindscanJob jobInDb, bool satellite, SearchResult searchResult, int polarityIndex, SearchResult2 searchResult2);
        void UpdateTransponderState(DbBlindscanJob jobInDb, bool satellite, SearchResult searchResult, BlindscanResultState blindscanResultState, SearchResult2 searchResult2);
        void InsertTransponderService(DbBlindscanJob jobInDb, bool resultSatellite, SearchResult resultSr1, SearchResult2 resultSr2, HumanReadableService humanReadableService);
        bool TestForIncompleteJob();
        DbBlindscanJob GetPastBlindscanJob(long offset);
		void FailDsmCcDownload(DatabaseKeyDsmCcModule key, double value);
		IReadOnlyList<string> ListImportFileByTag1(int tag1);
		bool TestForTerminalBurstTimePlan(ushort interactiveNetworkId, uint groupId, uint logonId);
		void StoreTerminalBurstTimePlan(ushort interactiveNetworkId, uint gtoupId, uint superframeCount, uint frameNumber, Tbtp.TbtpFrame.BtpEntity btp);
		bool TestForCmtEntry(ushort interactiveNetworkId, Cmt.CmtEntry entry);
		void InsertCmtEntry(ushort interactiveNetworkId, Cmt.CmtEntry entry);

        /// <summary>
        /// Supposed to figure out the Transmission Standard from a stored RMT.
        /// </summary>
        /// <param name="networkId">The RCS Network ID to figure out the Transmission Standard for</param>
        /// <returns>0 if the transmission standard is unknown or couldn't be figured out for any reason. Otherwise according to spec</returns>
		int GetRmtTransmissionStandard(ushort networkId);
		byte[] GetTmst(ushort interactiveNetworkId);
		void InsertTmst(ushort interactiveNetworkId, byte[] modes);
		void UpdateTmst(ushort interactiveNetworkId, byte[] modes);
		bool TestForSuperframeComposition(ushort interactiveNetworkId, Sct.Superframe superframe);
		void StoreSuperframeComposition(ushort interactiveNetworkId, Sct.Superframe superframe);
		bool TestForFrameComposition(ushort interactiveNetworkId, Fct.Frame frame);
		void InsertFctFrame(ushort interactiveNetworkId, Fct.Frame frame);
		bool TestForSatellitePosition(ushort interactiveNetworkId, Spt.Satellite satellite);
		void StoreSatellitePosition(ushort interactiveNetworkId, Spt.Satellite satellite);
		IEnumerable<DbBlindscanJob> GetDbBlindscanJobs();
		bool TestForSgtList(SgtList list);
		void InsertSgtList(SgtList list);
		bool TestForSgtService(SgtService child);
		void InsertSgtService(SgtService child);
		void InsertDvbiServiceListEntryPoint(long sourceHash);
		bool TestForServiceListEntryPoints(long sourceHash);
		void InsertDvbiServiceList(DvbiServiceList serviceList);
		bool TestForDvbiService(string id);
		bool TestForDvbiServiceListEntryPoints(long sourceHash);
		void UpdateDvbiServiceListLastCheckedDate(string id, DateTime currentTime);
		DateTime GetLastDvbiServiceListEntryPointUpdateDate(long sourceHash);
		DateTime GetDvbiServiceListLastUpdateDate(string id);
		void AddDvbiServiceListToServiceListEntryPoint(DvbiServiceList serviceList, long sourceHash);
		void AddDvbiServiceToServiceList(string id, string serviceListId);
		int GetDvbiServiceVersion(string id);
		void UpdateDvbiService(DvbIService service);
		void UpdateDvbiServiceListEntryPointUpdateDate(long hash, DateTime currentTime);
		void InsertDvbiService(DvbIService service);
		bool TestForDvbiServiceList(string id);

		bool DvbNipPrivateDataSpecifier(NipActualCarrierInformation currentCarrierInformation, DateTime versionUpdate, uint privateDataSpecifier, List<string> privateDataSessions);
		bool DvbNipTestForNetwork(BroadcastNetworkType network);
		void DvbNipInsertNetwork(BroadcastNetworkType network);
		bool DvbNipTestForService(BroadcastMediaStreamType broadcastMediaStreamType);
		void DvbNipInsertService(BroadcastMediaStreamType broadcastMediaStreamType);
		bool DvbNipTestForMulticastSession(MulticastSessionType multicastSession);
		void DvbNipInsertMulticastSession(MulticastSessionType multicastSession);
		bool DvbNipTestForMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastEndpointAddressType multicastEndpointAddressType);
		void DvbNipInsertMulticastGatewayConfigurationTransportSession(NipActualCarrierInformation carrier, MulticastEndpointAddressType multicastGatewayConfigurationTransportSession);

		bool DvbNipTestForCarrier(NipActualCarrierInformation currentCarrierInformation);
		void DvbNipInsertCarrier(NipActualCarrierInformation currentCarrierInformation);

		object[] GetPluginConnector();

		void Ping();
		IEnumerable<Tuple<int, SatelliteDeliverySystemDescriptor.PolarizationEnum>> GetBlindscanResultFrequencies(Guid selectedGuid);
		void InsertUiBlindscanSettingHistory(int settingsWindowBlScanTunerSelection, int settingsWindowUseDifferentTunerForSetFilter, int settingsWindowSetFilterTunerSelection, int settingsWindowDiseqc, bool settingsWindowCollectIqGraphs, bool settingsWindowCollectRfSpectrum, bool settingsWindowCaptureFile, int settingsWindowSatellite, int settingsWindowLnb, int dish, bool settingsWindowScanHorizontalLow, bool settingsWindowScanHorizontalHigh, bool settingsWindowScanVerticalLow, bool settingsWindowScanVerticalHigh);
		object[] GetLastUiBlindscanSettings();
		bool TestForTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, byte frameFrameNumber);
		void StoreTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, Tbtp2.Frame frame);
		bool TestForFrameComposition2(ushort networkId, Fct2.Frame fct2);
		void InsertFct2Frame(ushort networkId, Fct2.Frame frame);
		bool TestForBroadcastConfiguration(ushort networkId, byte txTypeTxType);
		void InsertBroadcastConfiguration(ushort networkId, Bct.BroadcastConfiguration txType);
		bool TestForRcs2Nit(RcsNit nit);
		void InsertRcs2Nit(RcsNit nit);
		bool UpdateRcs2Tdt(ushort interactiveNetworkId, DateTime tdtTimestamp);
		bool TestForTmst2(ushort interactiveNetworkId, Tmst2.TransmissionMode mode);
		void InsertTmst2(ushort interactiveNetworkId, Tmst2.TransmissionMode mode);
		bool TestForRmt(Rmt rmt);
		void InsertRmt(Rmt rmt);
		Tim GetLastTim(ushort interactiveNetworkId, PhysicalAddress physicalAddress);
		void UpsertTim(ushort interactiveNetworkId, PhysicalAddress physicalAddress, Tim currentTim);
		void StoreUpdateNotification2(UpdateNotificationGroup common, UpdateNotificationTarget target);
	}
}
