Ejemplo n.º 1
0
        public EngineAssistant(Gtk.Window parent, FrontendConfig config,
                               string engineName)
        {
            Trace.Call(parent, config, engineName);

            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            f_Config     = config;
            f_EngineName = engineName;

            TransientFor = parent;
            SetDefaultSize(640, 480);
            SetPosition(Gtk.WindowPosition.CenterAlways);
            Title = _("Engine Assistant - Smuxi");

            Apply += OnApply;

            InitPages();
        }
Ejemplo n.º 2
0
 public static Config CreateDefaultConfig()
 {
     return(new Config()
     {
         fileVersion = FileVersion, frontend = FrontendConfig.CreateDefaultConfig(), contentPatch = "latest", contentCdn = "https://ddragon.leagueoflegends.com/cdn"
     });
 }
Ejemplo n.º 3
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            Assembly                 asm      = Assembly.GetAssembly(typeof(Frontend));
            AssemblyName             asm_name = asm.GetName(false);
            AssemblyProductAttribute pr       = (AssemblyProductAttribute)asm.
                                                GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];

            _Version       = asm_name.Version;
            _VersionNumber = asm_name.Version.ToString();
            _VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;

#if LOG4NET
            _Logger.Info(_VersionString + " starting");
#endif

            // We don't want to put any XP/Vista users by using the dull ugly
            // unthemed interface.  Application.EnableVisualStyles() should be
            // called before any form is displayed.
            Application.EnableVisualStyles();

            _MainWindow = new MainWindow();
            // HACK: force creation of window handle, else the engine will have problems adding stuff
            IntPtr handle = _MainWindow.Handle;

            _FrontendConfig = new FrontendConfig(UIName);
            // loading and setting defaults
            _FrontendConfig.Load();
            _FrontendConfig.Save();

            if (_FrontendConfig.IsCleanConfig)
            {
                /*TODO: Create and show first run wizard*/
            }
            else
            {
                if (((string)FrontendConfig["Engines/Default"]).Length == 0)
                {
                    InitLocalEngine();
                }
                else
                {
                    // there is a default engine set, means we want a remote engine
                    /*TODO: Create and show Engine Manager Dialog*/

                    // HACK: for now always use local engine
                    InitLocalEngine();
                }
            }
            /*TODO: Set the main message loop*/
            Application.Run(_MainWindow);
#if LOG4NET
            _Logger.Warn("Application.Run() returned!");
#endif
        }
        private void PatchChanged(object sender, TextChangedEventArgs e)
        {
            TextBox        textBox = sender as TextBox;
            FrontendConfig config  = BroadcastHubController.ClientConfig.frontend;

            if (textBox.Text != config.patch)
            {
                config.patch = textBox.Text;
                BroadcastHubController.UpdateConfig();
            }
        }
Ejemplo n.º 5
0
        public static void Init(string engine)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";
            Trace.Call(engine);

            Assembly                 asm      = Assembly.GetAssembly(typeof(Frontend));
            AssemblyName             asm_name = asm.GetName(false);
            AssemblyProductAttribute pr       = (AssemblyProductAttribute)asm.
                                                GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];

            _Version       = asm_name.Version;
            _VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;

            // this always calls abort() :(((
            //StflApi.stfl_error_action("print");

#if LOG4NET
            _Logger.Info(_VersionString + " starting");
#endif
            _MainWindow = new MainWindow();

            _FrontendConfig = new FrontendConfig(UIName);
            // loading and setting defaults
            _FrontendConfig.Load();
            if (_FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] == null)
            {
                _FrontendConfig[Frontend.UIName + "/Interface/TerminalBackgroundColor"] = "#000000";
            }
            _FrontendConfig.Save();

            if (_FrontendConfig.IsCleanConfig)
            {
                // first start assistant
            }
            else
            {
                if (String.IsNullOrEmpty(engine) || engine == "local")
                {
                    InitLocalEngine();
                }
                else
                {
                    InitRemoteEngine(engine);
                }
            }

            while (true)
            {
                // wait maximum for 500ms, to force a refresh even when
                // not hitting a key
                _MainWindow.Run(500);
            }
        }
Ejemplo n.º 6
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            Assembly                 asm      = Assembly.GetAssembly(typeof(Frontend));
            AssemblyName             asm_name = asm.GetName(false);
            AssemblyProductAttribute pr       = (AssemblyProductAttribute)asm.
                                                GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];

            _Version       = asm_name.Version;
            _VersionNumber = asm_name.Version.ToString();
            _VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;

#if LOG4NET
            _Logger.Info(_VersionString + " starting");
#endif
            Application.Init(false);

            _MainWindow = new MainWindow();

            _FrontendConfig = new FrontendConfig(UIName);
            // loading and setting defaults
            _FrontendConfig.Load();
            _FrontendConfig.Save();

            if (_FrontendConfig.IsCleanConfig)
            {
            }
            else
            {
                if (((string)FrontendConfig["Engines/Default"]).Length == 0)
                {
                    InitLocalEngine();
                }
                else
                {
                    // there is a default engine set, means we want a remote engine
                    //new EngineManagerDialog();
                    InitLocalEngine();
                }
            }

            Application.Timeout    = 100;
            Application.Iteration += delegate {
                Application.Refresh();
            };

            Application.Run(_MainWindow);
#if LOG4NET
            _Logger.Warn("Application.Run() returned!");
#endif
        }
Ejemplo n.º 7
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            Assembly                 asm      = Assembly.GetAssembly(typeof(Frontend));
            AssemblyName             asm_name = asm.GetName(false);
            AssemblyProductAttribute pr       = (AssemblyProductAttribute)asm.
                                                GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];

            _Version       = asm_name.Version;
            _VersionNumber = asm_name.Version.ToString();
            _VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;

#if LOG4NET
            _Logger.Info(_VersionString + " starting");
#endif

            InitGtk(args);

            //_SplashScreenWindow = new SplashScreenWindow();

            _FrontendConfig = new FrontendConfig(UIName);
            // loading and setting defaults
            _FrontendConfig.Load();
            _FrontendConfig.Save();

            _MainWindow = new MainWindow();

            if (((string[])FrontendConfig["Engines/Engines"]).Length == 0)
            {
                InitLocalEngine();
                ConnectEngineToGUI();
            }
            else
            {
                // there are remote engines defined, means we have to ask
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                ShowEngineManagerDialog();
            }

            if (_SplashScreenWindow != null)
            {
                _SplashScreenWindow.Destroy();
            }

            Gtk.Application.Run();
#if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
#endif
        }
 public HomeController(
     ILogger <HomeController> logger,
     IOptions <FrontendConfig> resourcesSettings,
     IResourcesRepo resourcesRepo,
     IStorageRepo storageRepo,
     GrpcGreeter.GreeterService.GreeterServiceClient grpcGreeterClient,
     ResourcesService.ResourcesServiceClient grpcResourcesBackend)
 {
     _logger               = logger;
     _frontendSettings     = resourcesSettings.Value;
     _resourcesRepo        = resourcesRepo;
     _storageRepo          = storageRepo;
     _grpcGreeterClient    = grpcGreeterClient;
     _grpcResourcesBackend = grpcResourcesBackend;
 }
Ejemplo n.º 9
0
        public EngineManager(FrontendConfig frontendConfig, IFrontendUI frontendUI)
        {
            Trace.Call(frontendConfig, frontendUI);

            if (frontendConfig == null)
            {
                throw new ArgumentNullException("frontendConfig");
            }
            if (frontendUI == null)
            {
                throw new ArgumentNullException("frontendUI");
            }

            f_FrontendConfig = frontendConfig;
            f_FrontendUI     = frontendUI;
        }
Ejemplo n.º 10
0
        private void StartApplication(object sender, StartupEventArgs e)
        {
#if LOG4NET
            log4net.Config.BasicConfigurator.Configure();
#endif


            // Splash screen should be shown as soon as the application begins

            Window ss = StartSplashScreen();



            // Now we can continue to initialize the application as needed

            System.Threading.Thread.CurrentThread.Name = "Main";



            {
                Assembly asm = Assembly.GetAssembly(typeof(Frontend));

                AssemblyName asm_name = asm.GetName(false);

                AssemblyProductAttribute pr = (AssemblyProductAttribute)asm.

                                              GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];

                Version = asm_name.Version;

                VersionString = String.Format("{0} - {1} frontend {2}", pr.Product, UIName, Version);
            }

#if LOG4NET
            _Logger.Info(VersionString + " starting");
#endif



            FrontendConfig = new FrontendConfig(UIName);

            // loading and setting defaults

            FrontendConfig.Load();

            FrontendConfig.Save();



            if (FrontendConfig.IsCleanConfig)
            {
                ss.Close();

                RunInitWizard();
            }
            else
            {
                if (((string)FrontendConfig["Engines/Default"]).Length == 0)
                {
                    //InitLocalEngine();
                }
                else
                {
                    // there is a default engine set, means we want a remote engine

                    ss.Close();

                    RunEngineManagerDialog();
                }
            }

            // Now that everything is setup, we can destroy the splash screen

            // and start the application

            ss.Close();
        }
Ejemplo n.º 11
0
 public HeartbeatEvent(StateData stateData)
 {
     this.eventType = "GameHeartbeat";
     this.stateData = stateData;
     this.config    = BroadcastHubController.ClientConfig.frontend;
 }
 public ErrorController(ILogger <ErrorController> logger, IOptions <FrontendConfig> resourcesSettings)
 {
     _logger           = logger;
     _frontendSettings = resourcesSettings.Value;
 }
Ejemplo n.º 13
0
Archivo: Main.cs Proyecto: licnep/smuxi
        public static void Main(string[] args)
        {
#if LOG4NET
            // initialize log level
            log4net.Repository.ILoggerRepository repo = log4net.LogManager.GetRepository();
            repo.Threshold = log4net.Core.Level.Error;
#endif

            bool   debug       = false;
            bool   listEngines = false;
            string engine      = "local";

            InitLocale();

            OptionSet parser = new OptionSet();

            parser.Add(
                "d|debug",
                _("Enable debug output"),
                delegate(string value) {
                debug = true;
            }
                );

            parser.Add(
                "e|engine=",
                _("Engine to connect to"),
                delegate(string value) {
                engine = value;
            }
                );

            parser.Add(
                "l|list-engines",
                _("List available engines"),
                delegate(string value) {
                listEngines = true;
            }
                );

            parser.Add(
                "h|help",
                _("Show this help"),
                delegate(string value) {
                Console.WriteLine(_("Usage: smuxi-frontend-stfl [options]"));
                Console.WriteLine();
                Console.WriteLine(_("Options:"));
                parser.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
                );

            parser.Add(
                "<>",
                delegate(string value) {
                throw new OptionException(
                    String.Format(
                        _("Unknown option: '{0}'"),
                        value
                        ),
                    value
                    );
            }
                );

            try {
                parser.Parse(args);
#if LOG4NET
                if (debug)
                {
                    repo.Threshold = log4net.Core.Level.Debug;
                }
#endif
            } catch (OptionException ex) {
                Console.Error.WriteLine(_("Command line error: {0}"), ex.Message);
                Environment.Exit(1);
            }

            if (listEngines)
            {
                Console.WriteLine(_("Available Engines:"));
                var config = new FrontendConfig(Frontend.UIName);
                config.Load();
                foreach (var entry in  (string[])config["Engines/Engines"])
                {
                    Console.WriteLine("\t{0}", entry);
                }
                return;
            }

            try {
                Frontend.Init(engine);
            } catch (Exception e) {
#if LOG4NET
                _Logger.Fatal(e);
#endif
                if (SysDiag.Debugger.IsAttached)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
#if LOG4NET
            // initialize log level
            log4net.Repository.ILoggerRepository repo = log4net.LogManager.GetRepository();
            repo.Threshold = log4net.Core.Level.Error;
#endif

            bool   debug       = false;
            bool   listEngines = false;
            string engine      = "local";

            InitLocale();

            OptionSet parser = new OptionSet();

            parser.Add(
                "d|debug",
                _("Enable debug output"),
                delegate(string value) {
                debug = true;
            }
                );

            parser.Add(
                "e|engine=",
                _("Engine to connect to"),
                delegate(string value) {
                engine = value;
            }
                );

            parser.Add(
                "l|list-engines",
                _("List available engines"),
                delegate(string value) {
                listEngines = true;
            }
                );

            parser.Add(
                "h|help",
                _("Show this help"),
                delegate(string value) {
                Console.WriteLine(_("Usage: smuxi-frontend-stfl [options]"));
                Console.WriteLine();
                Console.WriteLine(_("Options:"));
                parser.WriteOptionDescriptions(Console.Out);
                Environment.Exit(0);
            }
                );

            parser.Add(
                "<>",
                delegate(string value) {
                throw new OptionException(
                    String.Format(
                        _("Unknown option: '{0}'"),
                        value
                        ),
                    value
                    );
            }
                );

            try {
                parser.Parse(args);
#if LOG4NET
                if (debug)
                {
                    repo.Threshold = log4net.Core.Level.Debug;
                }
#endif
            } catch (OptionException ex) {
                Console.Error.WriteLine(_("Command line error: {0}"), ex.Message);
                Environment.Exit(1);
            }

            if (listEngines)
            {
                Console.WriteLine(_("Available Engines:"));
                var config = new FrontendConfig(Frontend.UIName);
                config.Load();
                foreach (var entry in  (string[])config["Engines/Engines"])
                {
                    Console.WriteLine("\t{0}", entry);
                }
                return;
            }

            if ((Environment.OSVersion.Platform == PlatformID.Unix) ||
                (Environment.OSVersion.Platform == PlatformID.MacOSX))
            {
                // Register shutdown handlers
#if LOG4NET
                _Logger.Info("Registering signal handlers");
#endif
                UnixSignal[] shutdown_signals =
                {
                    new UnixSignal(Signum.SIGINT),
                    new UnixSignal(Signum.SIGTERM),
                };
                Thread signal_thread = new Thread(() => {
                    var index = UnixSignal.WaitAny(shutdown_signals);
#if LOG4NET
                    _Logger.Info("Caught signal " + shutdown_signals[index].Signum.ToString() + ", shutting down");
#endif
                    Frontend.Quit();
                });
                signal_thread.Start();
            }

            try {
                Frontend.Init(engine);
            } catch (Exception e) {
#if LOG4NET
                _Logger.Fatal(e);
#endif
                if (SysDiag.Debugger.IsAttached)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 15
0
        public static void Init(string[] args, string engine)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            Assembly                 asm      = Assembly.GetAssembly(typeof(Frontend));
            AssemblyName             asm_name = asm.GetName(false);
            AssemblyProductAttribute pr       = (AssemblyProductAttribute)asm.
                                                GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0];

            _Version       = asm_name.Version;
            _VersionString = pr.Product + " - " + _UIName + " frontend " + _Version;

#if LOG4NET
            _Logger.Info(_VersionString + " starting");
#endif

            InitSignalHandlers();
            InitGtk(args);

            //_SplashScreenWindow = new SplashScreenWindow();

            _FrontendConfig = new FrontendConfig(UIName);
            // loading and setting defaults
            _FrontendConfig.Load();
            _FrontendConfig.Save();

            _MainWindow = new MainWindow();

            if (((string[])FrontendConfig["Engines/Engines"]).Length == 0)
            {
                InitLocalEngine();
                ConnectEngineToGUI();
            }
            else
            {
                // there are remote engines defined, means we have to ask
                //_SplashScreenWindow.Destroy();
                _SplashScreenWindow = null;
                try {
                    ShowEngineManagerDialog(engine);
                } catch (ArgumentException ex) {
                    if (ex.ParamName == "value")
                    {
                        Console.WriteLine(ex.Message);
                        System.Environment.Exit(1);
                    }
                    throw;
                }
            }

            if (_SplashScreenWindow != null)
            {
                _SplashScreenWindow.Destroy();
            }

            if (IsMacOSX)
            {
                ApplicationEvents.Quit += delegate(object sender, ApplicationQuitEventArgs e) {
                    Quit();
                    e.Handled = true;
                };

                ApplicationEvents.Reopen += delegate(object sender, ApplicationEventArgs e) {
                    MainWindow.Deiconify();
                    MainWindow.Visible = true;
                    e.Handled          = true;
                };

                ApplicationEvents.OpenUrls += delegate(object sender, ApplicationUrlEventArgs e) {
                    e.Handled = true;
                    if (e.Urls == null || e.Urls.Count == 0)
                    {
                        return;
                    }
                    foreach (var url in e.Urls)
                    {
                        try {
                            OpenChatLink(new Uri(url));
                        } catch (Exception ex) {
#if LOG4NET
                            _Logger.Error("ApplicationEvents.OpenUrls() Exception", ex);
#endif
                        }
                    }
                };
            }

            InGtkApplicationRun = true;
            Gtk.Application.Run();
            InGtkApplicationRun = false;
#if LOG4NET
            _Logger.Warn("Gtk.Application.Run() returned!");
#endif
        }
Ejemplo n.º 16
0
        public static void Init(string[] args)
        {
            System.Threading.Thread.CurrentThread.Name = "Main";

            if (!(args.Length >= 1))
            {
                Console.Error.WriteLine("Usage: smuxi-test.exe profile");
                Environment.Exit(1);
            }

#if LOG4NET
            _Logger.Info("smuxi-test starting");
#endif

            _FrontendConfig = new FrontendConfig("Test");
            _FrontendConfig.Load();

            string profile = args[0];
            if (String.IsNullOrEmpty(profile))
            {
                Console.Error.WriteLine("profile parameter must not be empty!");
                Environment.Exit(1);
            }

            IFrontendUI ui = new TestUI();

            Session session = null;
            if (profile == "local")
            {
                Engine.Engine.Init();
                session = new Engine.Session(Engine.Engine.Config,
                                             Engine.Engine.ProtocolManagerFactory,
                                             "local");
                session.RegisterFrontendUI(ui);
            }
            else
            {
                // remote engine
                EngineManager engineManager = new EngineManager(_FrontendConfig, ui);
                engineManager.Connect(profile);
                session = engineManager.Session;
            }

            if (session == null)
            {
                Console.Error.WriteLine("Session is null, something went wrong setting up or connecting to the engine!");
                Environment.Exit(1);
            }

            _Session         = session;
            _UserConfig      = session.UserConfig;
            _FrontendManager = session.GetFrontendManager(ui);
            _FrontendManager.Sync();

            if (_UserConfig.IsCaching)
            {
                // when our UserConfig is cached, we need to invalidate the cache
                _FrontendManager.ConfigChangedDelegate = new SimpleDelegate(_UserConfig.ClearCache);
            }

            while (true)
            {
                string line = Console.ReadLine();
                // TODO: remove the entered line from output
                //Console.WriteLine(Escape+"M");

                _ExecuteCommand(line);
            }
        }
Ejemplo n.º 17
0
 public EngineAssistant(Gtk.Window parent, FrontendConfig config) :
     this(parent, config, null)
 {
     Trace.Call(parent, config);
 }