Beispiel #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //Only if user has chosen to generate log
            var debugMode = Environment.GetEnvironmentVariable("XDM_DEBUG_MODE");

            if (!string.IsNullOrEmpty(debugMode) && debugMode == "1")
            {
                var logFile = Path.Combine(Config.DataDir, "log.txt");
                Log.InitFileBasedTrace(Path.Combine(Config.DataDir, "log.txt"));
            }
            Log.Debug($"Application_Startup::args->: {string.Join(" ", Environment.GetCommandLineArgs())}");

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            core = new ApplicationCore();
            win  = new MainWindow();
            app  = new XDMApp();

            ApplicationContext.Configurer()
            .RegisterApplicationWindow(win)
            .RegisterApplication(app)
            .RegisterApplicationCore(core)
            .RegisterCapturedVideoTracker(new VideoTracker())
            .RegisterClipboardMonitor(new ClipboardMonitor())
            .RegisterLinkRefresher(new LinkRefresher())
            .RegisterPlatformUIService(new WpfPlatformUIService())
            .Configure();

            var args           = Environment.GetCommandLineArgs();
            var commandOptions = ArgsProcessor.ParseArgs(args, 1);

            AppTrayIcon.AttachToSystemTray();
            AppTrayIcon.TrayClick += (_, _) =>
            {
                win.Show();
                if (win.WindowState == WindowState.Minimized)
                {
                    win.WindowState = WindowState.Normal;
                }
                win.Activate();
            };

            if (!commandOptions.ContainsKey("-m"))
            {
                win.Show();
                if (commandOptions.ContainsKey("-i"))
                {
                    Config.Instance.RunOnLogon = true;
                    Config.SaveConfig();
                    ApplicationContext.PlatformUIService.ShowBrowserMonitoringDialog();
                }
            }
        }
Beispiel #2
0
        internal static void Handle(RawBrowserMessageEnvelop envelop)
        {
            //Log.Debug("Type: " + envelop.MessageType);
            if (envelop.MessageType == "videoIds")
            {
                foreach (var item in envelop.VideoIds)
                {
                    ApplicationContext.VideoTracker.AddVideoDownload(item);
                }
                return;
            }

            if (envelop.MessageType == "clear")
            {
                ApplicationContext.VideoTracker.ClearVideoList();
                return;
            }

            if (envelop.MessageType == "sync")
            {
                return;
            }

            if (envelop.MessageType == "custom")
            {
                var args = ArgsProcessor.ParseArgs(envelop.CustomData.Split('\r'));
                ArgsProcessor.Process(args);
                return;
            }

            var rawMessage = envelop.Message;

            if (rawMessage == null && envelop.Messages == null)
            {
                Log.Debug("Raw message/messages is null");
                return;
            }
            ;

            switch (envelop.MessageType)
            {
            case "download":
            {
                var message = Parse(rawMessage);
                if (!(Helpers.IsBlockedHost(message.Url) || Helpers.IsCompressedJSorCSS(message.Url)))
                {
                    ApplicationContext.CoreService.AddDownload(message);
                }
                break;
            }

            case "links":
            {
                var messages = new List <Message>(envelop.Messages.Length);
                foreach (var msg in envelop.Messages)
                {
                    var message = Parse(msg);
                    messages.Add(message);
                }
                ApplicationContext.CoreService.AddBatchLinks(messages);
                break;
            }

            case "video":
            {
                var message     = Parse(rawMessage);
                var contentType = message.GetResponseHeaderFirstValue("Content-Type");

                if (VideoUrlHelper.IsYtFormat(contentType))
                {
                    VideoUrlHelper.ProcessPostYtFormats(message);
                }

                //if (VideoUrlHelper.IsFBFormat(contentType, message.Url))
                //{
                //    VideoUrlHelper.ProcessPostFBFormats(message, ApplicationContext.Core);
                //}

                if (VideoUrlHelper.IsHLS(contentType))
                {
                    VideoUrlHelper.ProcessHLSVideo(message);
                }

                if (VideoUrlHelper.IsDASH(contentType))
                {
                    VideoUrlHelper.ProcessDashVideo(message);
                }

                if (!VideoUrlHelper.ProcessYtDashSegment(message))
                {
                    if (VideoUrlHelper.IsNormalVideo(contentType, message.Url, message.GetContentLength()))
                    {
                        VideoUrlHelper.ProcessNormalVideo(message);
                    }
                }
                break;
            }
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Gtk.Application.Init();
            GLib.ExceptionManager.UnhandledException += ExceptionManager_UnhandledException;
            var globalStyleSheet = @"
                                    .large-font{ font-size: 16px; }
                                    .medium-font{ font-size: 14px; }
                                    ";

            var screen   = Gdk.Screen.Default;
            var provider = new CssProvider();

            provider.LoadFromData(globalStyleSheet);
            Gtk.StyleContext.AddProviderForScreen(screen, provider, 800);
            //var screen = Gdk.Screen.Default;
            //var provider = new CssProvider();
            //provider.LoadFromData(@".dark
            //                                    {
            //                                        color: gray;
            //                                        background: rgb(36,41,46);
            //                                    }

            //                                    treeview.view :selected
            //                                    {
            //                                        background-color: rgb(10,106,182);
            //                                        color: white;
            //                                    }
            //.listt
            //{
            //font-family: Segoe UI;
            //}
            //                                    .dark2
            //                                    {
            //                                        color: gray;
            //                                        background: rgb(35,35,35);
            //                                        /*background: rgb(36,41,46);*/
            //                                    }
            //                                    .toolbar-border-dark
            //                                    {
            //                                        border-bottom: 1px solid rgb(20,20,20);
            //                                    }
            //                                    .toolbar-border-light
            //                                    {
            //                                        border-bottom: 2px solid rgb(240,240,240);
            //                                    }
            //                                  ");
            //Gtk.StyleContext.AddProviderForScreen(screen, provider, 800);

            ServicePointManager.ServerCertificateValidationCallback += (a, b, c, d) => true;
            ServicePointManager.DefaultConnectionLimit = 100;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault;

            AppContext.SetSwitch(DisableCachingName, true);
            AppContext.SetSwitch(DontEnableSchUseStrongCryptoName, true);

            TextResource.Load(Config.Instance.Language);

            var debugMode = Environment.GetEnvironmentVariable("XDM_DEBUG_MODE");

            if (!string.IsNullOrEmpty(debugMode) && debugMode == "1")
            {
                var logFile = System.IO.Path.Combine(Config.DataDir, "log.txt");
                Log.InitFileBasedTrace(System.IO.Path.Combine(Config.DataDir, "log.txt"));
            }
            Log.Debug("Application_Startup");

            if (Config.Instance.AllowSystemDarkTheme)
            {
                Gtk.Settings.Default.ThemeName = "Adwaita";
                Gtk.Settings.Default.ApplicationPreferDarkTheme = true;
            }

            var core = new ApplicationCore();
            var app  = new XDMApp();
            var win  = new MainWindow();

            ApplicationContext.Configurer()
            .RegisterApplicationWindow(win)
            .RegisterApplication(app)
            .RegisterApplicationCore(core)
            .RegisterCapturedVideoTracker(new VideoTracker())
            .RegisterClipboardMonitor(new ClipboardMonitor())
            .RegisterLinkRefresher(new LinkRefresher())
            .RegisterPlatformUIService(new GtkPlatformUIService())
            .Configure();

            var commandOptions = ArgsProcessor.ParseArgs(args, 0);

            if (!commandOptions.ContainsKey("-m"))
            {
                win.Show();
                if (commandOptions.ContainsKey("-i"))
                {
                    Config.Instance.RunOnLogon = true;
                    Config.SaveConfig();
                    ApplicationContext.PlatformUIService.ShowBrowserMonitoringDialog();
                }
            }

            //var t = new System.Threading.Thread(() =>
            //  {
            //      while (true)
            //      {
            //          System.Threading.Thread.Sleep(5000);
            //          Console.WriteLine("Trigger GC");
            //          GC.Collect();
            //      }
            //  });
            //t.Start();

            Gtk.Application.Run();

            //var app = new XDM.Core.XDM.Core();
            //var appWin = new AppWinPeer(app);
            //appWin.ShowAll();
            //Application.Run();


            //            Environment.SetEnvironmentVariable("PANGOCAIRO_BACKEND", "fc", EnvironmentVariableTarget.User);
            //            //Console.WriteLine(Environment.GetEnvironmentVariable("PANGOCAIRO_BACKEND"));
            //            //var arr = new string[] {  "PANGOCAIRO_BACKEND=fc" };
            //            Application.Init();// "app", ref arr);
            //            Gtk.Settings.Default.ThemeName = "Adwaita";
            //            Gtk.Settings.Default.ApplicationPreferDarkTheme = true;

            //            App app = new App();



            //            var appWin = new AppWin();
            //            Console.WriteLine("Starting show all");
            //            appWin.Show();
            //            Console.WriteLine("Finished show all");
            //            Application.Run();
        }