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"); IsPutty = File.Exists("plink.exe"); Apply += OnApply; InitPages(); }
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 }
public static void Init(string[] args) { System.Threading.Thread.CurrentThread.Name = "Main"; Trace.Call(args); 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; //STFL.error_action("print"); #if LOG4NET _Logger.Info(_VersionString + " starting"); #endif _MainWindow = new MainWindow(); _FrontendConfig = new FrontendConfig(UIName); // loading and setting defaults _FrontendConfig.Load(); _FrontendConfig.Save(); if (_FrontendConfig.IsCleanConfig) { // first start assistant } 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(); } } while (true) { // wait maximum for 500ms, to force a refresh even when // not hitting a key _MainWindow.Run(500); } #if LOG4NET _Logger.Warn("_MainWindow.Run() returned!"); #endif }
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; }
public EngineAssistant(Gtk.Window parent, FrontendConfig config) : this(parent, config, null) { Trace.Call(parent, config); }
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); } }
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; _VersionNumber = asm_name.Version.ToString(); _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(); _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); } #if LOG4NET _Logger.Warn("_MainWindow.Run() returned!"); #endif }
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 #if GTK_SHARP_2_8 || GTK_SHARP_2_10 if (!GLib.Thread.Supported) { GLib.Thread.Init(); } _UIThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #else // with GTK# 2.8 we can do this better, see above // GTK# 2.7.1 for MS .NET doesn't support that though. if (Type.GetType("Mono.Runtime") == null) { // when we don't run on Mono, we need to initialize glib ourself GLib.Thread.Init(); } #endif string appDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string localeDir = Path.Combine(appDir, "locale"); if (!Directory.Exists(localeDir)) { localeDir = Path.Combine(Defines.InstallPrefix, "share"); localeDir = Path.Combine(localeDir, "locale"); } LibraryCatalog.Init("smuxi-frontend-gnome", localeDir); #if LOG4NET _Logger.Debug("Using locale data from: " + localeDir); #endif #if UI_GNOME _Program = new GNOME.Program(Name, Version.ToString(), GNOME.Modules.UI, args); #elif UI_GTK Gtk.Application.Init(Name, args); #endif #if GTK_SHARP_2_10 GLib.ExceptionManager.UnhandledException += _OnUnhandledException; #endif //_SplashScreenWindow = new SplashScreenWindow(); _FrontendConfig = new FrontendConfig(UIName); // loading and setting defaults _FrontendConfig.Load(); _FrontendConfig.Save(); Gtk.Window.DefaultIcon = new Gdk.Pixbuf(null, "icon.svg"); _MainWindow = new MainWindow(); #if GTK_SHARP_2_10 _StatusIcon = new Gtk.StatusIcon(); _StatusIcon.Visible = false; _StatusIcon.Pixbuf = new Gdk.Pixbuf(null, "icon.svg"); _StatusIcon.Activate += delegate { try { if (_StatusIcon.Blinking) { _MainWindow.Present(); return; } _MainWindow.Visible = !_MainWindow.Visible; } catch (Exception ex) { ShowException(ex); } }; _StatusIcon.PopupMenu += OnStatusIconPopupMenu; _StatusIcon.Tooltip = "Smuxi"; #endif if (String.IsNullOrEmpty((string) FrontendConfig["Engines/Default"])) { InitLocalEngine(); ConnectEngineToGUI(); } else { // there is a default engine set, means we want a remote engine //_SplashScreenWindow.Destroy(); _SplashScreenWindow = null; ShowEngineManagerDialog(); } if (_SplashScreenWindow != null) { _SplashScreenWindow.Destroy(); } #if UI_GNOME _Program.Run(); #if LOG4NET _Logger.Warn("_Program.Run() returned!"); #endif #elif UI_GTK Gtk.Application.Run(); #if LOG4NET _Logger.Warn("Gtk.Application.Run() returned!"); #endif #endif }
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 #if GTK_SHARP_2_8 || GTK_SHARP_2_10 if (!GLib.Thread.Supported) { GLib.Thread.Init(); } _UIThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #else // with GTK# 2.8 we can do this better, see above // GTK# 2.7.1 for MS .NET doesn't support that though. if (Type.GetType("Mono.Runtime") == null) { // when we don't run on Mono, we need to initialize glib ourself GLib.Thread.Init(); } #endif string appDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string localeDir = Path.Combine(appDir, "locale"); if (!Directory.Exists(localeDir)) { localeDir = Path.Combine(Defines.InstallPrefix, "share"); localeDir = Path.Combine(localeDir, "locale"); } LibraryCatalog.Init("smuxi-frontend-gnome", localeDir); #if LOG4NET _Logger.Debug("Using locale data from: " + localeDir); #endif Gtk.Application.Init(Name, ref args); #if GTK_SHARP_2_10 GLib.ExceptionManager.UnhandledException += _OnUnhandledException; #endif //_SplashScreenWindow = new SplashScreenWindow(); _FrontendConfig = new FrontendConfig(UIName); // loading and setting defaults _FrontendConfig.Load(); _FrontendConfig.Save(); Gtk.Window.DefaultIcon = new Gdk.Pixbuf(null, "icon.svg"); _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 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 throw; } }
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(); _SplashScreenWindow = new SplashScreenWindow(); _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: Kill the SplashScreen Window _SplashScreenWindow.Close(); /*TODO: Set the main message loop*/ Application.Run(_MainWindow); #if LOG4NET _Logger.Warn("Application.Run() returned!"); #endif }
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 }
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(); Gtk.Window.DefaultIcon = new Gdk.Pixbuf(null, "icon.svg"); _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 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 string engine = null; for (int i = 0; i < args.Length; i++) { var arg = args[i]; switch (arg) { case "-e": case "--engine": if (args.Length >= i + 1) { engine = args[i + 1]; } break; } } //_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(); } Gtk.Application.Run(); #if LOG4NET _Logger.Warn("Gtk.Application.Run() returned!"); #endif }
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(); }
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; } } }