示例#1
0
文件: Frontend.cs 项目: knocte/smuxi
        public static void ConnectEngineToGUI()
        {
            if (IsLocalEngine) {
                // HACK: SessionManager.Register() is not used for local engines
                _LocalSession.RegisterFrontendUI(_MainWindow.UI);
            }

            SyncConfig();

            _FrontendManager = _Session.GetFrontendManager(_MainWindow.UI);
            _FrontendManager.Sync();

            // MS .NET doesn't like this with Remoting?
            if (Type.GetType("Mono.Runtime") != null) {
                // when are running on Mono, all should be good
                if (_UserConfig.IsCaching) {
                    // when our UserConfig is cached, we need to invalidate the cache
                    // DISABLED: see FrontendManager._OnConfigChanged
                    //_FrontendManager.ConfigChangedDelegate = SyncConfig;
                }
            }

            _MainWindow.ShowAll();
            // make sure entry got attention :-P
            _MainWindow.Entry.HasFocus = true;

            // local sessions can't have network issues :)
            if (_Session != _LocalSession) {
                _FrontendManagerCheckerQueue = new TaskQueue("FrontendManagerCheckerQueue");
                _FrontendManagerCheckerQueue.AbortedEvent += delegate {
            #if LOG4NET
                    _Logger.Debug("_FrontendManagerCheckerQueue.AbortedEvent(): task queue aborted!");
            #endif
                };

                _FrontendManagerCheckerQueue.ExceptionEvent +=
                delegate(object sender, TaskQueueExceptionEventArgs e) {
            #if LOG4NET
                    _Logger.Error("Exception in TaskQueue: ", e.Exception);
                    _Logger.Error("Inner-Exception: ", e.Exception.InnerException);
            #endif
                    Frontend.ShowException(e.Exception);
                };

                _FrontendManagerCheckerQueue.Queue(delegate {
                    // keep looping as long as the checker returns true
                    while (CheckFrontendManagerStatus()) {
                        // FIXME: bail out somehow when we lost the connection
                        // without an exception in the meantime

                        // only check once per minute
                        Thread.Sleep(60 * 1000);
                    }
            #if LOG4NET
                    _Logger.Debug("_FrontendManagerCheckerQueue(): " +
                                  "CheckFrontendManagerStatus() returned false, "+
                                  "time to say good bye!");
            #endif
                });
            }
            MainWindow.ChatViewManager.IsSensitive = true;
        }
示例#2
0
文件: Frontend.cs 项目: tuukka/smuxi
        public static void ConnectEngineToGUI()
        {
            _FrontendManager = _Session.GetFrontendManager(_MainWindow.UI);
            _FrontendManager.Sync();

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

            // make sure entry got attention :-P
            // BUG: MonoCurses
            //_MainWindow.Entry.HasFocus = true;
        }
示例#3
0
文件: Frontend.cs 项目: RoninBG/smuxi
        public static void ConnectEngineToGUI()
        {
            _Session.RegisterFrontendUI(_MainWindow.UI);
            _FrontendManager = _Session.GetFrontendManager(_MainWindow.UI);
            _FrontendManager.Sync();

            // MS .NET doesn't like this with Remoting?
            if (Type.GetType("Mono.Runtime") != null) {
                // when are running on Mono, all should be good
                if (_UserConfig.IsCaching) {
                    // when our UserConfig is cached, we need to invalidate the cache
                    _FrontendManager.ConfigChangedDelegate = new SimpleDelegate(_UserConfig.ClearCache);
                }
            }

            ApplyConfig(_UserConfig);

            _MainWindow.ShowAll();
            // make sure entry got attention :-P
            _MainWindow.Entry.HasFocus = true;

            // check once per minute the status of the frontend manager
            GLib.Timeout.Add(60 * 1000, _CheckFrontendManagerStatus);
        }
示例#4
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);
            }
        }
示例#5
0
文件: Frontend.cs 项目: RoninBG/smuxi
        public static void ConnectEngineToGUI()
        {
            _FrontendManager = _Session.GetFrontendManager(_MainWindow.UI);
            _FrontendManager.Sync();

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

            _MainWindow.Show();
            _MainWindow.ApplyConfig(_UserConfig);
            // make sure entry got attention :-P
            _MainWindow.Entry.Select();
        }