コード例 #1
0
ファイル: Session.cs プロジェクト: RoninBG/smuxi
        public Session(Config config, ProtocolManagerFactory protocolManagerFactory,
                       string username)
        {
            Trace.Call(config, protocolManagerFactory, username);

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

            _Config = config;
            _ProtocolManagerFactory = protocolManagerFactory;
            _Username = username;

            _FrontendManagers = new Dictionary<string, FrontendManager>();
            _ProtocolManagers = new List<IProtocolManager>();
            _UserConfig = new UserConfig(config, username);
            _Chats = new List<ChatModel>();

            _SessionChat = new SessionChatModel("smuxi", "smuxi");
            _Chats.Add(_SessionChat);
        }
コード例 #2
0
ファイル: SessionManager.cs プロジェクト: pacificIT/smuxi
        public SessionManager(Config config, ProtocolManagerFactory protocolManagerFactory)
        {
            Trace.Call(config, protocolManagerFactory);

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

            _Config = config;
            _ProtocolManagerFactory = protocolManagerFactory;

            EngineAssemblyVersion = Engine.AssemblyVersion;
            EngineProtocolVersion = Engine.ProtocolVersion;

            string[] users = (string[])Engine.Config["Engine/Users/Users"];
            if (users == null) {
                Console.WriteLine("No Engine/Users/*, aborting...\n");
                Environment.Exit(1);
            }
            foreach (string user in users) {
                // skip local session
                if (user == "local") {
                    continue;
                }
            #if LOG4NET
                _Logger.Debug("Creating Session for User "+user);
            #endif
                _Sessions.Add(user, new Session(_Config, _ProtocolManagerFactory, user));
            }
        }
コード例 #3
0
ファイル: Engine.cs プロジェクト: kvsm/smuxi
        public static void Init()
        {
            if (_IsInitialized)
            {
                return;
            }
            _IsInitialized = true;

            var asm = Assembly.GetEntryAssembly();

            if (asm == null)
            {
                asm = Assembly.GetAssembly(typeof(Engine));
            }
            var asm_name = asm.GetName(false);

            var distVersion = Defines.DistVersion;

            if (!String.IsNullOrEmpty(distVersion))
            {
                distVersion = String.Format(" ({0})", distVersion);
            }
            _VersionString = String.Format(
                "{0} {1}{2} - running on {3} {4}",
                Path.GetFileNameWithoutExtension(asm_name.Name),
                AssemblyVersion,
                distVersion,
                Platform.OperatingSystem,
                Platform.Architecture
                );

            _Config = new Config();
            _Config.Load();
            _Config.Save();

            string location = Path.GetDirectoryName(asm.Location);

            if (String.IsNullOrEmpty(location) &&
                Environment.OSVersion.Platform == PlatformID.Unix)
            {
                // we are mkbundled
                var locationBuilder = new StringBuilder(8192);
                if (Mono.Unix.Native.Syscall.readlink("/proc/self/exe", locationBuilder) >= 0)
                {
                    location = Path.GetDirectoryName(locationBuilder.ToString());
                }
            }
            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(location);
        }
コード例 #4
0
        public static void Init()
        {
            if (_IsInitialized)
            {
                return;
            }
            _IsInitialized = true;

            var asm = Assembly.GetEntryAssembly();

            if (asm == null)
            {
                asm = Assembly.GetAssembly(typeof(Engine));
            }
            var asm_name = asm.GetName(false);

            _Version       = asm_name.Version;
            _VersionNumber = asm_name.Version.ToString();

            var distVersion = Defines.DistVersion;

            if (!String.IsNullOrEmpty(distVersion))
            {
                distVersion = String.Format(" ({0})", distVersion);
            }
            _VersionString = String.Format(
                "{0} {1}{2} - running on {3} {4}",
                Path.GetFileNameWithoutExtension(asm_name.Name),
                _Version,
                distVersion,
                Platform.OperatingSystem,
                Platform.Architecture
                );

            _Config = new Config();
            _Config.Load();
            _Config.Save();

            string location = Assembly.GetExecutingAssembly().Location;

            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(Path.GetDirectoryName(location));

            _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory);
        }
コード例 #5
0
        public SessionManager(Config config, ProtocolManagerFactory protocolManagerFactory)
        {
            Trace.Call(config, protocolManagerFactory);

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

            _Config = config;
            _ProtocolManagerFactory = protocolManagerFactory;

            EngineAssemblyVersion = Engine.AssemblyVersion;
            EngineProtocolVersion = Engine.ProtocolVersion;

            string[] users = (string[])Engine.Config["Engine/Users/Users"];
            if (users == null)
            {
                Console.WriteLine("No Engine/Users/*, aborting...\n");
                Environment.Exit(1);
            }
            foreach (string user in users)
            {
                // skip local session
                if (user == "local")
                {
                    continue;
                }
#if LOG4NET
                _Logger.Debug("Creating Session for User " + user);
#endif
                var session = new Session(_Config, _ProtocolManagerFactory, user);
                session.ExecuteOnStartupCommands();
                session.ProcessAutoConnect();
                _Sessions.Add(user, session);
            }
        }
コード例 #6
0
ファイル: Engine.cs プロジェクト: licnep/smuxi
        public static void Init()
        {
            if (_IsInitialized)
            {
                return;
            }
            _IsInitialized = true;

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

            _Version       = asm_name.Version;
            _VersionNumber = asm_name.Version.ToString();

            var distVersion = Defines.DistVersion;

            if (!String.IsNullOrEmpty(distVersion))
            {
                distVersion = String.Format(" ({0})", distVersion);
            }
            _VersionString = String.Format(
                "{0} {1}{2} - running on {3} {4}",
                pr.Product,
                _Version,
                distVersion,
                Platform.OperatingSystem,
                Platform.Architecture
                );

            _Config = new Config();
            _Config.Load();
            _Config.Save();

            string location = Assembly.GetExecutingAssembly().Location;

            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(Path.GetDirectoryName(location));

            _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory);
        }
コード例 #7
0
ファイル: SessionManager.cs プロジェクト: jamesaxl/smuxi
        public SessionManager(Config config, ProtocolManagerFactory protocolManagerFactory)
        {
            Trace.Call(config, protocolManagerFactory);

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

            _Config = config;
            _ProtocolManagerFactory = protocolManagerFactory;

            // BUG: out of scope?
            _EngineVersion = Engine.Version;

            string[] users = (string[])Engine.Config["Engine/Users/Users"];
            if (users == null)
            {
                Console.WriteLine("No Engine/Users/*, aborting...\n");
                Environment.Exit(1);
            }
            foreach (string user in users)
            {
                // skip local session
                if (user == "local")
                {
                    continue;
                }
#if LOG4NET
                _Logger.Debug("Creating Session for User " + user);
#endif
                _Sessions.Add(user, new Session(_Config, _ProtocolManagerFactory, user));
            }
        }
コード例 #8
0
ファイル: Engine.cs プロジェクト: oli-obk/smuxi
        public static void Init()
        {
            if (_IsInitialized) {
                return;
            }
            _IsInitialized = true;

            var asm = Assembly.GetEntryAssembly();
            if (asm == null) {
                asm = Assembly.GetAssembly(typeof(Engine));
            }
            var asm_name = asm.GetName(false);
            _Version = asm_name.Version;
            _VersionNumber = asm_name.Version.ToString();

            var distVersion = Defines.DistVersion;
            if (!String.IsNullOrEmpty(distVersion)) {
                distVersion = String.Format(" ({0})", distVersion);
            }
            _VersionString = String.Format(
                "{0} {1}{2} - running on {3} {4}",
                Path.GetFileNameWithoutExtension(asm_name.Name),
                _Version,
                distVersion,
                Platform.OperatingSystem,
                Platform.Architecture
            );

            _Config = new Config();
            _Config.Load();
            _Config.Save();

            string location = Assembly.GetExecutingAssembly().Location;
            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(Path.GetDirectoryName(location));

            _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory);
        }
コード例 #9
0
ファイル: Engine.cs プロジェクト: tuukka/smuxi
        public static void Init()
        {
            if (_IsInitialized) {
                return;
            }
            _IsInitialized = true;

            Assembly asm = Assembly.GetAssembly(typeof(Engine));
            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 = String.Format("{0} {1} - running on {2} {3}", pr.Product, _Version, Platform.OperatingSystem, Platform.Architecture);

            _Config = new Config();
            _Config.Load();
            _Config.Save();

            string location = Assembly.GetExecutingAssembly().Location;
            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(Path.GetDirectoryName(location));

            _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory);
        }
コード例 #10
0
ファイル: Engine.cs プロジェクト: pacificIT/smuxi
        public static void Init()
        {
            if (_IsInitialized) {
                return;
            }
            _IsInitialized = true;

            var asm = Assembly.GetEntryAssembly();
            if (asm == null) {
                asm = Assembly.GetAssembly(typeof(Engine));
            }
            var asm_name = asm.GetName(false);

            var distVersion = Defines.DistVersion;
            if (!String.IsNullOrEmpty(distVersion)) {
                distVersion = String.Format(" ({0})", distVersion);
            }
            _VersionString = String.Format(
                "{0} {1}{2} - running on {3} {4}",
                Path.GetFileNameWithoutExtension(asm_name.Name),
                AssemblyVersion,
                distVersion,
                Platform.OperatingSystem,
                Platform.Architecture
            );

            _Config = new Config();
            _Config.Load();
            _Config.Save();

            string location = Path.GetDirectoryName(asm.Location);
            if (String.IsNullOrEmpty(location) &&
                Environment.OSVersion.Platform == PlatformID.Unix) {
                // we are mkbundled
                var locationBuilder = new StringBuilder(8192);
                if (Mono.Unix.Native.Syscall.readlink("/proc/self/exe", locationBuilder) >= 0) {
                    location = Path.GetDirectoryName(locationBuilder.ToString());
                }
            }
            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(location);

            _SessionManager = new SessionManager(_Config, _ProtocolManagerFactory);
        }
コード例 #11
0
ファイル: Engine.cs プロジェクト: shubhtr/smuxi
        public static void Init()
        {
            if (_IsInitialized)
            {
                return;
            }
            _IsInitialized = true;

            var asm = Assembly.GetEntryAssembly();

            if (asm == null)
            {
                asm = Assembly.GetAssembly(typeof(Engine));
            }
            var asm_name = asm.GetName(false);

            var distVersion = Defines.DistVersion;

            if (!String.IsNullOrEmpty(distVersion))
            {
                distVersion = String.Format(" ({0})", distVersion);
            }
            _VersionString = String.Format(
                "{0} {1}{2} - running on {3} {4}",
                Path.GetFileNameWithoutExtension(asm_name.Name),
                AssemblyVersion,
                distVersion,
                Platform.OperatingSystem,
                Platform.Architecture
                );

            _Config = new Config();
            _Config.Load();

            // migration config settins from 1.0 or earlier to 1.1
            if (_Config.PreviousVersion == null ||
                _Config.PreviousVersion < new Version(1, 1))
            {
                // migrate all existing IRC connections for Slack to the
                // SlackProtocolManager
                var users = (string[])_Config["Engine/Users/Users"];
                if (users != null)
                {
                    foreach (var user in users)
                    {
                        var userConfig       = new UserConfig(_Config, user);
                        var serverController = new ServerListController(userConfig);
                        var servers          = serverController.GetServerList();
                        foreach (var server in servers)
                        {
                            if (server.Protocol != "IRC")
                            {
                                continue;
                            }
                            if (!server.Hostname.EndsWith(".irc.slack.com"))
                            {
                                continue;
                            }
#if LOG4NET
                            f_Logger.InfoFormat(
                                "Migrating Slack server '{0}' of user '{1}' " +
                                "from IRC to Slack protocol manager",
                                server,
                                user
                                );
#endif
                            // this is Slack IRC bridge connection
                            var migratedServer = new ServerModel(server);
                            migratedServer.ServerID = null;
                            migratedServer.Protocol = "Slack";
                            serverController.AddServer(migratedServer);
                            // remove old Slack server with IRC as protocol
                            serverController.RemoveServer(server.Protocol,
                                                          server.ServerID);
                        }
                    }
                }
                _Config["Engine/ConfigVersion"] = _Config.CurrentVersion.ToString();
            }

            _Config.Save();

            string location = Path.GetDirectoryName(asm.Location);
            if (String.IsNullOrEmpty(location) &&
                Environment.OSVersion.Platform == PlatformID.Unix)
            {
                // we are mkbundled
                var locationBuilder = new StringBuilder(8192);
                if (Mono.Unix.Native.Syscall.readlink("/proc/self/exe", locationBuilder) >= 0)
                {
                    location = Path.GetDirectoryName(locationBuilder.ToString());
                }
            }
            _ProtocolManagerFactory = new ProtocolManagerFactory();
            _ProtocolManagerFactory.LoadAllProtocolManagers(location);
        }