Esempio n. 1
0
 private static void ManageUser(bool addUser, bool delUser, bool modUser,
                                bool listUsers,
                                string username, string password)
 {
     Config config = new Config();
     UserListController controller = new UserListController(config);
     if (addUser) {
         config.Load();
         controller.AddUser(username, password);
         config.Save();
         Console.WriteLine(
              _("User \"{0}\" successfully added to server."),
              username
         );
         Environment.Exit(0);
     } else if (modUser) {
         config.Load();
         controller.ModifyUser(username, password);
         config.Save();
         Console.WriteLine(
              _("User \"{0}\" successfully modified."),
              username
         );
         Environment.Exit(0);
     } else if (delUser) {
         config.Load();
         controller.DeleteUser(username);
         config.Save();
         Console.WriteLine(
             _("User \"{0}\" successfully deleted from server."),
             username
         );
         Environment.Exit(0);
     } else if (listUsers) {
         config.Load();
         var users = controller.GetUsers();
         Console.WriteLine(_("Users:"));
         foreach (var user in users) {
             if (user == "local") {
                 // is not a real user and could cause confusion
                 continue;
             }
             Console.WriteLine("\t{0}", user);
         }
         Environment.Exit(0);
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
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);
        }
Esempio n. 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);

            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);
        }