Esempio n. 1
0
        static async Task SilentMain()
        {
            var detector = new ApplicationEnumerator();

            var apps = (await detector.GetInstalledApplications()).ToList();

            if (!apps.Any())
            {
                Trace.TraceWarning("No BitTorrent applications found. Nothing to do, so exiting.");
                return;
            }

            var cancellationSource = new CancellationTokenSource();

            // Download the filter
            var downloader = new FilterDownloader();
            var progress = new Progress<ProgressModel>(delegate(ProgressModel model)
            {
                Trace.TraceInformation("{0}", model.Caption);
            });

            using (var filter = await downloader.DownloadFilter(null, cancellationSource.Token, progress))
            {
                if (filter.Exception != null) throw filter.Exception;

                foreach (var application in apps)
                {
                    Trace.TraceInformation("Updating app {0} {1}", application.Description, application.Version);

                    await application.Application.UpdateFilterAsync(filter, cancellationSource.Token, progress);
                }
            }

            Trace.TraceInformation("Done.");
        }
Esempio n. 2
0
        static async Task SilentMain()
        {
            var detector = new ApplicationEnumerator();

            var apps = (await detector.GetInstalledApplications()).ToList();

            var cancellationSource = new CancellationTokenSource();

            // Download the filter
            var downloader    = new FilterDownloader();
            var progressValue = 0;
            var progress      = new Progress <ProgressModel>(delegate(ProgressModel model)
            {
                progressValue = model.Value;
                Trace.TraceInformation("{0}", model.Caption);
            });

            using (var filter = await downloader.DownloadFilter(null, cancellationSource.Token, progress))
            {
                if (filter.Exception != null)
                {
                    throw filter.Exception;
                }

                Trace.TraceInformation("Parsing filter (" + filter.Length + " bytes)");
                filter.Stream.Seek(0, SeekOrigin.Begin);
                using (var reader = new StreamReader(filter.Stream, Encoding.Default, false, 65535, true))
                {
                    var line = await reader.ReadLineAsync();

                    while (line != null)
                    {
                        var entry = DatParser.ParseEntry(line);
                        if (entry != null)
                        {
                            filter.Entries.Add(entry);
                        }
                        var percent = (int)Math.Floor((double)filter.Stream.Position / filter.Stream.Length * 100);
                        await Task.Yield();

                        //if( percent > progressValue) progress.Report(UpdateState.Decompressing, "Parsed " + filter.Entries.Count + " entries",  percent);
                        line = await reader.ReadLineAsync();
                    }

                    Trace.TraceInformation("Parsed " + filter.Entries.Count + " entries");
                }

                foreach (var application in apps)
                {
                    Trace.TraceInformation("Updating app {0} {1}", application.Description, application.Version);

                    await application.Application.UpdateFilterAsync(filter, cancellationSource.Token, progress);
                }
            }

            Trace.TraceInformation("Done.");
        }
Esempio n. 3
0
        public MainWindowViewModel()
        {
            Trace.Listeners.Add(new DelegateTraceListener(null,LogLineAction ));
            Trace.TraceInformation("Initializing...");

            dispatcher = Dispatcher.CurrentDispatcher;

            StatusText = "Ready";
            State = UpdateState.Ready;
            ProgressMax = 100;
            
            Options = new OptionsViewModel();
            Update = new UpdateModel();
            MirrorProviders = new List<IMirrorProvider> {new EmuleSecurity(), new BlocklistMirrorProvider()};
            LaunchHelpCommand = new DelegateCommand(LaunchHelp);
            StartCommand = new DelegateCommand(Start, IsStartEnabled);
            applicationEnumerator = new ApplicationEnumerator();
            downloader = new FilterDownloader();
            
            progress = new Progress<ProgressModel>(ProgressHandler);
            cancellationToken = new CancellationTokenSource();
        }
Esempio n. 4
0
        static async Task SilentMain()
        {
            var detector = new ApplicationEnumerator();

            var apps = (await detector.GetInstalledApplications()).ToList();

            if (!apps.Any())
            {
                Trace.TraceWarning("No BitTorrent applications found. Nothing to do, so exiting.");
                return;
            }

            var cancellationSource = new CancellationTokenSource();

            // Download the filter
            var downloader = new FilterDownloader();
            var progress   = new Progress <ProgressModel>(delegate(ProgressModel model)
            {
                Trace.TraceInformation("{0}", model.Caption);
            });

            using (var filter = await downloader.DownloadFilter(null, cancellationSource.Token, progress))
            {
                if (filter.Exception != null)
                {
                    throw filter.Exception;
                }

                foreach (var application in apps)
                {
                    Trace.TraceInformation("Updating app {0} {1}", application.Description, application.Version);

                    await application.Application.UpdateFilterAsync(filter, cancellationSource.Token, progress);
                }
            }

            Trace.TraceInformation("Done.");
        }
Esempio n. 5
0
        public MainWindowViewModel()
        {
            //Trace.TraceInformation("Initializing...");
            //Trace.Listeners.Add(new DelegateTraceListener(null,LogLineAction ));

            dispatcher = Dispatcher.CurrentDispatcher;

            StatusText  = "Ready";
            State       = UpdateState.Ready;
            ProgressMax = 100;

            Options               = new OptionsViewModel();
            Update                = new UpdateModel();
            MirrorProviders       = MirrorProvidersFactory.Get();
            LaunchHelpCommand     = new DelegateCommand(LaunchHelp);
            ShowOptionsCommand    = new DelegateCommand(ShowOptions);
            ShowLogCommand        = new DelegateCommand(ShowLog);
            StartCommand          = new DelegateCommand(Start, IsStartEnabled);
            applicationEnumerator = new ApplicationEnumerator();
            downloader            = new FilterDownloader();

            cancellationToken = new CancellationTokenSource();
        }
Esempio n. 6
0
        public MainWindowViewModel()
        {
            Trace.Listeners.Add(new DelegateTraceListener(null, LogLineAction));
            Trace.TraceInformation("Initializing...");

            dispatcher = Dispatcher.CurrentDispatcher;

            StatusText  = "Ready";
            State       = UpdateState.Ready;
            ProgressMax = 100;

            Options         = new OptionsViewModel();
            Update          = new UpdateModel();
            MirrorProviders = new List <IMirrorProvider> {
                new EmuleSecurity(), new BlocklistMirrorProvider()
            };
            LaunchHelpCommand     = new DelegateCommand(LaunchHelp);
            StartCommand          = new DelegateCommand(Start, IsStartEnabled);
            applicationEnumerator = new ApplicationEnumerator();
            downloader            = new FilterDownloader();

            progress          = new Progress <ProgressModel>(ProgressHandler);
            cancellationToken = new CancellationTokenSource();
        }