예제 #1
0
        static void Main()
        {
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            }

            ConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            ConfigPath = Path.Combine(ConfigPath, "batclient");
            if (!File.Exists(ConfigPath))
            {
                Directory.CreateDirectory(ConfigPath);
            }

            ClientCore clientCore = new ClientCore();

            clientCore.Run();
        }
예제 #2
0
        public ClientCore()
        {
            s_clientCore = this;

            //Ansi.SendAnsiInit();

            m_synchronizedInvoke = new SynchronizedInvoke();

            // Services
            m_baseServicesDispatcher = new BaseServicesDispatcher();

            // Init console
            m_textConsole = new TextConsole();
            ChiConsole.SetChiConsole(m_textConsole);

            // Initialize ironpython
            IronPython.Compiler.Options.GenerateModulesAsSnippets = true;
            m_pythonEngine = new PythonEngine();

            ChiPythonStream s = new ChiPythonStream();

            m_pythonEngine.SetStandardOutput(s);
            m_pythonEngine.SetStandardError(s);
            m_pythonEngine.SetStandardInput(s);
            //m_pythonEngine.AddToPath(Environment.CurrentDirectory);
            //m_pythonEngine.AddToPath(Application.StartupPath + "/lib");
#if DEBUG
            m_pythonEngine.AddToPath(@"../../../scripts/lib");
#endif
            m_pythonEngine.LoadAssembly(typeof(TriggerManager).Assembly);             // load BatClientBase
            m_pythonEngine.LoadAssembly(typeof(System.Drawing.Bitmap).Assembly);      // load System.Drawing
            m_pythonEngine.LoadAssembly(typeof(System.Windows.Forms.Keys).Assembly);  // load System.Windows.Forms



            // Network
            m_telnet = new Telnet();
            m_telnet.connectEvent    += new Telnet.ConnectDelegate(_ConnectEvent);
            m_telnet.disconnectEvent += new Telnet.DisconnectDelegate(_DisconnectEvent);
            m_telnet.receiveEvent    += new Telnet.ReceiveDelegate(_ReceiveEvent);
            m_telnet.promptEvent     += new Telnet.PromptDelegate(_PromptEvent);
            m_telnet.telnetEvent     += new Telnet.TelnetDelegate(_TelnetEvent);

            m_netPipe = UnixPipes.CreatePipes();


            m_commandManager = new CommandManager(m_baseServicesDispatcher);
            AddBuiltinCommands();

            m_triggerManager = new TriggerManager(m_baseServicesDispatcher);

            m_keyManager = new KeyManager(m_baseServicesDispatcher);

            m_hiliteManager = new HiliteManager(m_triggerManager);

            PythonInterface.Initialize(m_baseServicesDispatcher, m_triggerManager, m_commandManager, this,
                                       m_textConsole, m_pythonEngine, m_keyManager, m_hiliteManager);

            // run init script

            Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            Version baseVersion    = System.Reflection.Assembly.GetAssembly(typeof(Telnet)).GetName().Version;
            ChiConsole.WriteLine("Chiroptera version {0} (base {1})", currentVersion.ToString(2), baseVersion.ToString(2));
            ChiConsole.WriteLine("Using {0}", PythonEngine.VersionString);

            try
            {
#if DEBUG
                PythonInterface.RunScript(Path.GetFullPath("../../../scripts/std/init_std.bc"));
#else
                PythonInterface.RunScript(Path.Combine(Environment.CurrentDirectory, "std/init_std.bc"));
#endif
            }
            catch (Exception e)
            {
                ChiConsole.WriteError("Error running init_std.bc", e);
            }

/*
 *                      m_pythonEngine.Import("site");
 *
 *                      try
 *                      {
 *                              m_pythonEngine.ExecuteFile("init.py");
 *                      }
 *                      catch (Exception e)
 *                      {
 *                              ChiConsole.WriteError("Eval failed", e);
 *                      }
 */
        }