Exemplo n.º 1
0
        /**
         * the function close server after call to the close
         */
        public void closeServer(object sender, DirectoryCloseEventArgs e)
        {
            IDirectoryHandler h = (IDirectoryHandler)sender;

            CommandRecieved -= h.OnCommandRecieved;
            m_logging.Log("close service: " + e.Message, MessageTypeEnum.INFO);
        }
Exemplo n.º 2
0
        /// <summary>
        /// close specific handler
        /// </summary>
        /// <param name="sender"> the object calling to this function </param>
        /// <param name="eventArgs"> the event args of closing a handler </param>
        private void CloseHandler(object sender, DirectoryCloseEventArgs eventArgs)
        {
            IDirectoryHandler dirHandler = (IDirectoryHandler)sender;

            CommandRecieved           -= dirHandler.OnCommandRecieved;
            dirHandler.DirectoryClose -= CloseHandler;
        }
Exemplo n.º 3
0
 public DirectoryWebSocketService(IWebSocketHandler webSocketHandler, IDirectoryHandler directoryHandler, IDebugHandler debugHandler)
 {
     debugHandler.TraceMessage("Constructor Called.", DebugSource.CONSTRUCTOR, DebugType.ENTRY_EXIT);
     DebugHandler     = debugHandler;
     WebSocketHandler = webSocketHandler;
     DirectoryHandler = directoryHandler;
 }
        /************************************************************************
         * The Input: sender and an event.
         * The Output: -
         * The Function operation: The function is called when the handler is closed.
         *************************************************************************/
        public void OnHandlerClose(object sender, DirectoryCloseEventArgs e)
        {
            IDirectoryHandler dirHandler = (IDirectoryHandler)sender;

            CommandReceived -= dirHandler.OnCommandRecieved;
            m_logging.Log("Stop handle directory " + e.Message, Logging.Modal.MessageTypeEnum.INFO);
        }
Exemplo n.º 5
0
        public event EventHandler <CommandRecievedEventArgs> CommandRecieved; // The event that notifies about a new Command being recieved
        #endregion


        /*********************************************************************/

        public void onCloseServer(object sender, ...)
        {
            IDirectoryHandler h = sender;

            CommandRecieved -= h.OnCommandRecieved(sender, CommandRecieved);
            CommandRecieved -= h.OnCloseServer;
        }
        public DownloadWebSocketService(
            IWebSocketHandler webSocketHandler,
            IDirectoryHandler directoryHandler,
            IDownloadHandler downloadHandler,
            IFileHandler fileHandler,
            IFileHistoryHandler fileHistoryHandler,
            ISettingsHandler settingsHandler,
            IDebugHandler debugHandler)
        {
            debugHandler.TraceMessage("Constructor called.", DebugSource.CONSTRUCTOR, DebugType.ENTRY_EXIT);

            DebugHandler       = debugHandler;
            WebSocketHandler   = webSocketHandler;
            DirectoryHandler   = directoryHandler;
            DownloadHandler    = downloadHandler;
            FileHandler        = fileHandler;
            FileHistoryHandler = fileHistoryHandler;
            SettingsHandler    = settingsHandler;
            LastDownloadedInfo = new JsonDownloadInfo();

            LittleWeebSettings = SettingsHandler.GetLittleWeebSettings();
            IrcSettings        = SettingsHandler.GetIrcSettings();


            downloadHandler.OnDownloadUpdateEvent += OnDownloadUpdateEvent;
        }
Exemplo n.º 7
0
        /// <summary>
        /// removing a handler from the list of the handlers
        /// </summary>
        /// <param name="path">the path of the directory that need to stop handling</param>
        /// <returns>the result of action (success or failure)</returns>
        public string RemoveHandler(string path)
        {
            bool              sucsses         = false;
            string            newHandlersList = "";
            IDirectoryHandler chosenHandler   = null;

            foreach (IDirectoryHandler handler in this.listOfHandlers)
            {
                if (handler.GetPath() == path)
                {
                    chosenHandler = handler;
                    sucsses       = true;
                }
                else
                {
                    newHandlersList += (handler.GetPath() + ";");
                }
            }
            if (chosenHandler != null)
            {
                chosenHandler.CloseHandler(path);
                ConfigurationManager.AppSettings.Set("Handler", newHandlersList);
                this.m_logging.Log("The handler of " + path + " removed", MessageTypeEnum.INFO);
                Thread.Sleep(100);
            }
            if (sucsses)
            {
                return("sucsses");
            }
            return("failure");
        }
Exemplo n.º 8
0
        public GameController(IGameSettings gameSettings, int rX, int rY, GraphicsMode graphicsMode,
                              string title, int major, int minor, IDirectoryHandler directoryHandler)
            : base(rX, rY, graphicsMode, title, GameWindowFlags.Default, DisplayDevice.Default,
                   major, minor, GraphicsContextFlags.Default)
        {
            // Add OpenGL/GPU information tags to sentry
            var glVersion   = GL.GetString(StringName.Version);
            var glslVersion = GL.GetString(StringName.ShadingLanguageVersion);
            var gpuVendor   = GL.GetString(StringName.Vendor);
            var renderer    = GL.GetString(StringName.Renderer);

            ServiceLocator.ErrorReporting.AddTags(new Dictionary <string, string>
            {
                { "opengl", glVersion },
                { "glsl", glslVersion },
                { "vendor", gpuVendor },
                { "gpu", renderer }
            });

            // Add backend information tags to sentry
            var sdl = Configuration.RunningOnSdl2;

            Console.WriteLine("Running on SDL2: {0}", sdl);
            ServiceLocator.ErrorReporting.AddTags(new Dictionary <string, string>
            {
                { "sdl", sdl.ToString() }
            });

            KeyDown          += Keyboard_KeyDown;
            this.VSync        = (bool)gameSettings["VSync"] ? VSyncMode.On : VSyncMode.Off;
            this.WindowState  = (WindowState)Enum.Parse(typeof(WindowState), (string)gameSettings["WindowState"]);
            DebugMode.Value   = (bool)gameSettings["Debug"];
            _gameSettings     = gameSettings;
            _directoryHandler = directoryHandler;
        }
Exemplo n.º 9
0
        public void OnCloseServer(object sender, DirectoryCloseEventArgs args)
        {
            IDirectoryHandler handler = (IDirectoryHandler)sender;

            onCommand              -= handler.OnCommandRecieved;
            informHandlerClose     -= handler.CloseHandler;
            handler.DirectoryClose -= OnCloseServer;
        }
Exemplo n.º 10
0
        /// <summary>
        /// removeHandler.
        /// remove handler from CommandRecieved event.
        /// </summary>
        /// <param name="source">source</param>
        /// <param name="args">arguments</param>
        public void removeHandler(object source, DirectoryCloseEventArgs args)
        {
            IDirectoryHandler toRemove = (IDirectoryHandler)source;

            this.CommandRecieved -= toRemove.OnCommandRecieved;
            this.m_logging.Log(args.Message, MessageTypeEnum.INFO);
            this.m_logging.Log("Handler closed", MessageTypeEnum.INFO);
        }
Exemplo n.º 11
0
        /// <summary>
        /// remove the directory handle from the CommanedRecived event
        /// </summary>
        /// <param name="sender"> sender class</param>
        /// <param name="e"> arguments of Directory close</param>
        public void CloseDirectory(object sender, DirectoryCloseEventArgs e)
        {
            IDirectoryHandler d = (DirectoyHandler)sender;

            CommandRecieved  -= d.OnCommandRecieved;
            d.DirectoryClose -= CloseDirectory;
            m_logging.Log(e.Message, MessageTypeEnum.INFO);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Closes the handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="d">The <see cref="DirectoryCloseEventArgs"/> instance containing the close command.</param>
        public void CloseHandler(object sender, DirectoryCloseEventArgs d)
        {
            IDirectoryHandler idh = (IDirectoryHandler)sender;

            CommandReceived    -= idh.OnCommandReceived;
            idh.DirectoryClose -= CloseHandler;
            handlersDict.Remove(d.DirectoryPath);
        }
Exemplo n.º 13
0
        /// <summary>
        /// close specific handler
        /// </summary>
        /// <param name="sender"> the object calling to this function </param>
        /// <param name="eventArgs"> the event args of closing a handler </param>
        private void CloseHandler(object sender, DirectoryCloseEventArgs eventArgs)
        {
            IDirectoryHandler dirHandler = (IDirectoryHandler)sender;

            CommandRecieved           -= dirHandler.OnCommandRecieved;
            dirHandler.DirectoryClose -= CloseHandler;
            AppConfig.Instance.Folders.Remove(eventArgs.DirectoryPath);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Deletes the handler.
        /// </summary>
        /// <param name="sender"> Sender. </param>
        /// <param name="e"> Event. </param>
        public void DeleteHandler(object sender, DirectoryCloseEventArgs e)
        {
            IDirectoryHandler handler = (IDirectoryHandler)sender;

            CommandRecieved        -= handler.OnCommandRecieved;
            handler.DirectoryClose -= DeleteHandler;
            m_logging.Log(e.Message + "directory is closed", Logging.Modal.MessageTypeEnum.INFO);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Closes the server and logs the result.
        /// Param: Object sender, DirectoryCloseEventArgs args.
        /// </summary>
        public void OnCloseServer(Object sender, DirectoryCloseEventArgs args)
        {
            IDirectoryHandler h = (IDirectoryHandler)sender;

            CommandRecieved  -= h.OnCommandRecieved;
            h.DirectoryClose -= OnCloseServer;
            m_logging.Log(args.DirectoryPath + args.Message, Logging.Modal.MessageTypeEnum.INFO);
        }
Exemplo n.º 16
0
        /// <summary>
        /// The function inform the server that a handler is done handle the dir.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void closeServer(object sender, DirectoryCloseEventArgs args)
        {
            _mLogging.Log(args.Message, MessageTypeEnum.INFO);
            IDirectoryHandler handler = (IDirectoryHandler)sender;

            CommandRecieved        -= handler.OnCommandRecieved;
            handler.DirectoryClose -= closeServer;
        }
Exemplo n.º 17
0
        //informs the server that the handler has been closed
        public void OnCloseServer(object sender, DirectoryCloseEventArgs e)
        {
            IDirectoryHandler closeHandler = (IDirectoryHandler)sender;

            this.CommandRecieved -= closeHandler.OnCommandRecieved; //removes the delegate of the current closed handler
            //informs the current handler has been closed
            this.m_logging.Log("The handler that handles the directory " + e.DirectoryPath + " has been closed", Logging.Modal.MessageTypeEnum.INFO);
        }
Exemplo n.º 18
0
        /// <summary>
        /// this method remove handler.
        /// </summary>
        /// <param name="source">object that send the event</param>
        /// <param name="e">args for the event</param>
        public void RemoveHandler(object source, DirectoryCloseEventArgs e)
        {
            IDirectoryHandler handler = (IDirectoryHandler)source;

            CommandRecieved        -= handler.OnCommandRecieved;
            handler.DirectoryClose -= RemoveHandler;
            m_logging.Log(e.Message, MessageTypeEnum.INFO);
        }
Exemplo n.º 19
0
        /// <summary>
        /// the method get an handler and responsible to close the handler
        /// </summary>
        /// <param name="path">a string that represent the handler</param>
        public void closeHandler(string path)
        {
            IDirectoryHandler directory = this.handlers[path];

            directory.onCloseService(this, null);
            CloseService -= directory.onCloseService;
            handlers.Remove(path);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Subscribe events to the input directory handler.
        /// </summary>
        /// <param name="dirHandler">An IDirectoryHandler instance</param>
        private void SubscribeHandlerEvents(IDirectoryHandler dirHandler)
        {
            // Subscribing a command received function to the command event.
            CommandRecieved += dirHandler.OnCommandRecieved;

            // Subscribing a close handler function to the closing event.
            dirHandler.DirectoryClose += StopHandler;
        }
Exemplo n.º 21
0
 /// <summary>
 /// CloseSpecipicHandler function.
 /// closes specipic handler.
 /// </summary>
 /// <param name="toBeDeletedHandler">path of to be deleted handler</param>
 internal void CloseSpecipicHandler(string toBeDeletedHandler)
 {
     if (Handlers.ContainsKey(toBeDeletedHandler))
     {
         IDirectoryHandler handler = Handlers[toBeDeletedHandler];
         this.CloseServer -= handler.OnCloseHandler;
         handler.OnCloseHandler(this, null);
     }
 }
Exemplo n.º 22
0
        private FileConfigurationManager GetFileConfigurationManager(string name, IDirectoryHandler directory)
        {
            string configurationFilename = name + ".json";
            if (!directory.IsFilePresent(configurationFilename))
                return null;

            ITextHandler configurationFileHandler = directory.OpenFile(configurationFilename).CastFileHandler<ITextHandler>();
            return new FileConfigurationManager(configurationFileHandler);
        }
Exemplo n.º 23
0
        private void OnDirectoryClose(object sender, Modal.DirectoryCloseEventArgs e)
        {
            IDirectoryHandler handler = sender as IDirectoryHandler;            // Casting the Handler

            CommandRecieved -= handler.OnCommandRecieved;                       // Unsubscribing the Command

            // Notify To The Logger
            m_logging.Log(e.Message, Logging.Modal.MessageTypeEnum.INFO);              // Notifying about the Logger the reason for closing the directory
        }
Exemplo n.º 24
0
 /// <summary>
 /// Create a handler object to every directory.
 /// </summary>
 /// <param name="serverParameters">IImageServerParameters object</param>
 /// <param name="modalParameters">IModalParameters modalParameters</param>
 private void CreateHandlers(IImageServerParameters serverParameters, IModalParameters modalParameters)
 {
     HandlersList = new List <IDirectoryHandler>();
     foreach (string dir in serverParameters.Handlers)
     {
         IDirectoryHandler handler = CreateHandlerByDirectory(dir, modalParameters);
         HandlersList.Add(handler);
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// Delegate to run when the handler is being closed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnHandlerClose(object sender, DirectoryCloseEventArgs e)
        {
            IDirectoryHandler dirHandler = (IDirectoryHandler)sender;

            CommandRecieved -= dirHandler.OnCommandRecieved;
            this.handlers.Remove(dirHandler);
            m_logging.Log("Stop handle directory " + e.Message, Logging.Model.MessageTypeEnum.INFO);
            this.server.SendClose(sender, e);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Closes the specified handler.
 /// </summary>
 /// <param name="handlerToDelete">The handler to delete.</param>
 public void CloseSpecifiedHandler(string handlerToDelete)
 {
     if (handlers.ContainsKey(handlerToDelete))
     {
         IDirectoryHandler handler = handlers[handlerToDelete];
         this.CloseServer -= handler.OnCloseHandler;
         handler.OnCloseHandler(this, null);
     }
 }
Exemplo n.º 27
0
 public PaymentFileExportJob(
     IEmployeeSalaryService employeeSalaryService,
     IConfigurationProvider configurationProvider,
     IDirectoryHandler directoryHandler)
 {
     _employeeSalaryService = employeeSalaryService;
     _directoryHandler      = directoryHandler;
     _configurationProvider = configurationProvider;
 }
Exemplo n.º 28
0
 /// <summary>
 /// This method is called when a directory is closing.
 /// </summary>
 /// <param name="sender">The command sender.</param>
 /// <param name="args">The directory close event arguments.</param>
 private void OnDirectoryClose(object sender, DirectoryCloseEventArgs args)
 {
     if (sender is IDirectoryHandler)
     {
         IDirectoryHandler directoryHandler = (IDirectoryHandler)sender;
         CommandRecieved -= directoryHandler.OnCommandRecieved;
         m_logging.Log(args.Message, MessageTypeEnum.INFO);
     }
 }
Exemplo n.º 29
0
        public LocalFileSystem(IDirectoryHandler directoryHandler)
        {
            _fileFilter       = CSCore.Codecs.CodecFactory.Instance.GetSupportedFileExtensions();
            _directoryHandler = directoryHandler;

            _drives = new List <FileBrowserEntry>();
            _localFileSystemEntries = new List <FileBrowserEntry>();
            _userFolders            = new List <FileBrowserEntry>();
        }
Exemplo n.º 30
0
        /// <summary>
        /// When a handler is closed, he will raise a event and this function will remove it from the CommandRecieved
        /// </summary>
        /// <param name="sender"> who was sent the event </param>
        /// <param name="d"> details about the handler </param>
        private void OnCloseHandler(object sender, DirectoryCloseEventArgs d)
        {
            IDirectoryHandler handler = (IDirectoryHandler)sender;

            CommandRecieved -= handler.OnCommandRecieved;
            m_appParsing.RemoveDir(handler.DirPath);
            RemoveHandlerFromClients(handler.DirPath);
            m_logging.Log(d.DirectoryPath + " " + d.Message, MessageTypeEnum.INFO);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Closes the directory handler when required..
 /// </summary>
 /// <param name="source"></param>
 /// <param name="args"></param>
 public void CloseHandler(object source, DirectoryCloseEventArgs args)
 {
     if (source is IDirectoryHandler)
     {
         IDirectoryHandler handler = (IDirectoryHandler)source;
         // future
         //HandlerDispatchCommand -= handler.OnCommandRecieved;
     }
 }
        public override void Syncronize(IDirectoryHandler rootDirectoryHandler)
        {
            base.Syncronize(rootDirectoryHandler);

            IDirectoryHandler statsDirectory;

            if (!rootDirectoryHandler.IsFilePresent("Stats"))
            {
                statsDirectory = rootDirectoryHandler.CreateFile(
                    "Stats",
                    "directory",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id).FileContainer.CastFileHandler<IDirectoryHandler>();

                rootDirectoryHandler.SetPermission(
                    null,
                    "Stats",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.AnonymousUser.Id },
                    FilePermissionEnum.Read,
                    false,
                    false);
            }
            else
                statsDirectory = rootDirectoryHandler.OpenFile("Stats").CastFileHandler<IDirectoryHandler>();

            if (!statsDirectory.IsFilePresent("CallHomeTracker"))
            {
                statsDirectory.CreateFile(
                    "CallHomeTracker",
                    "callhome",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                statsDirectory.SetPermission(
                    null,
                    "CallHomeTracker",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.AnonymousUser.Id },
                    FilePermissionEnum.Read,
                    false,
                    false);
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// The default Constructor.
        /// </summary>
        public SceneManager(GameWindow gameWindow, Camera camera, FontLibrary fontLibrary, string fontPath, IDirectoryHandler directoryHandler, IGameSettings gameSettings, ValueWrapper<bool> debug)
        {
            GameWindow = gameWindow;
            SceneList = new List<Scene>();
            _scenesToAdd = new List<Scene>();
            _scenesToRemove = new List<Scene>();

            Directories = directoryHandler;

            FontPath = fontPath;
            GameFontLibrary = fontLibrary;
            DefaultFont = GameFontLibrary.GetFirstOrDefault(GameFontType.Default);
            FontDrawing = new QFontDrawing();
            FontDrawing.ProjectionMatrix = camera.ScreenProjectionMatrix;

            ScreenCamera = camera;
            ScreenCamera.Center = Vector2.Zero;
            ScreenCamera.MaximumScale = new Vector2(10000, 10000);

            GameSettings = gameSettings;

            Debug = debug;
        }
 public void RestoreFile(IFileId fileId, string pathToRestoreFrom, ID<IUserOrGroup, Guid> userId, IDirectoryHandler parentDirectory)
 {
     throw new NotImplementedException("File type isn't supported");
 }
Exemplo n.º 35
0
        private void DoUpgrades(IDirectoryHandler rootDirectoryHandler)
        {
            IDirectoryHandler systemDirectory = rootDirectoryHandler.OpenFile("System").CastFileHandler<IDirectoryHandler>();

            if (!systemDirectory.IsFilePresent("BrowserInfo"))
            {
                systemDirectory.CreateFile(
                    "BrowserInfo",
                    "browserinfo",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                systemDirectory.SetPermission(
                    null,
                    "BrowserInfo",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }

            if (!systemDirectory.IsFilePresent("Comet"))
            {
                IDirectoryHandler cometDirectory = (IDirectoryHandler)systemDirectory.CreateFile(
                    "Comet",
                    "directory",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                systemDirectory.SetPermission(
                    null,
                    "Comet",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);

                cometDirectory.CreateFile(
                    "Loopback",
                    "cometloopback",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                cometDirectory.SetPermission(
                    null,
                    "Loopback",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);

                cometDirectory.CreateFile(
                    "Echo",
                    "cometecho",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                cometDirectory.SetPermission(
                    null,
                    "Echo",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);

                cometDirectory.CreateFile(
                    "Multiplexer",
                    "cometmultiplex",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                cometDirectory.SetPermission(
                    null,
                    "Multiplexer",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);

                cometDirectory.CreateFile(
                    "LoopbackQuality",
                    "cometloopbackqueuingreliable",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                cometDirectory.SetPermission(
                    null,
                    "LoopbackQuality",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }

            if (!systemDirectory.IsFilePresent("TemplateEngine"))
            {
                systemDirectory.CreateFile(
                    "TemplateEngine",
                    "templateengine",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                systemDirectory.SetPermission(
                    null,
                    "TemplateEngine",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }

            if (!systemDirectory.IsFilePresent("JavascriptInterpreter"))
            {
                systemDirectory.CreateFile(
                    "JavascriptInterpreter",
                    "javascriptinterpreter",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                systemDirectory.SetPermission(
                    null,
                    "JavascriptInterpreter",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }

            IDirectoryHandler usersDirectory = FileHandlerFactoryLocator.FileSystemResolver.ResolveFile("Users").CastFileHandler<IDirectoryHandler>();

            if (!systemDirectory.IsFilePresent("Documentation"))
            {
                systemDirectory.CreateFile(
                    "Documentation",
                    "documentation",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                systemDirectory.SetPermission(
                    null,
                    "Documentation",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }

            if (!rootDirectoryHandler.IsFilePresent("Actions"))
            {
                // Create actions directory
                rootDirectoryHandler.RestoreFile(
                    "Actions",
                    "directory",
                    "." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Actions",
                    FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                rootDirectoryHandler.SetPermission(
                    null,
                    "Actions",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }

            // Let the root user see information about the anonymous user
            IFileContainer anonymousUserFileContainer = usersDirectory.OpenFile("anonymous.user");
            usersDirectory.Chown(null, anonymousUserFileContainer.FileId, FileHandlerFactoryLocator.UserFactory.RootUser.Id);
            usersDirectory.RemovePermission("anonymous.user", new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.AnonymousUser.Id });

            if (!usersDirectory.IsFilePresent("ParticleAvatars"))
            {
                usersDirectory.CreateFile("ParticleAvatars", "directory", null);
                usersDirectory.SetPermission(
                    null,
                    "ParticleAvatars",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.LocalUsers.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }

            // Make sure every user has a friends group
            // TODO: At some point this needs to go away
            foreach (ID<IUserOrGroup, Guid> userId in FileHandlerFactoryLocator.UserManagerHandler.GetAllLocalUserIds())
            {
                IUser user = FileHandlerFactoryLocator.UserManagerHandler.GetUser(userId);

                if (!user.BuiltIn)
                    if (FileHandlerFactoryLocator.LocalIdentityProvider == user.IdentityProvider)
                    {
                        bool hasFriendsGroup = false;

                        foreach (IGroupAndAlias group in FileHandlerFactoryLocator.UserManagerHandler.GetGroupsThatUserOwns(userId))
                        {
                            if (group.Alias == "friends")
                                hasFriendsGroup = true;
                        }

                        if (!hasFriendsGroup)
                            try
                            {
                                FileHandlerFactoryLocator.UserManagerHandler.CreateGroup("friends", user.DisplayName + "'s friends", user.Id, GroupType.Personal);
                            }
                            catch (Exception e)
                            {
                                log.Warn("Exception creating friends group for user " + user.Name, e);
                            }
                    }
            }

            /*if (!rootDirectoryHandler.IsFilePresent("Config"))
            {
                IDirectoryHandler configDirectory = (IDirectoryHandler)rootDirectoryHandler.CreateFile(
                    "Config", "directory", FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                CreateConfigDirectory(configDirectory, "ByExtension");
                CreateConfigDirectory(configDirectory, "ByType");
            }*/
        }
Exemplo n.º 36
0
        public virtual void Syncronize(IDirectoryHandler rootDirectoryHandler)
        {
            IFileHandler dir;

            if (rootDirectoryHandler.IsFilePresent("Actions"))
            {
                dir = rootDirectoryHandler.OpenFile("Actions").FileHandler;
                dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Actions", false, DateTime.MinValue);
            }

            dir = rootDirectoryHandler.OpenFile("Shell").FileHandler;
            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Shell", false, DateTime.MinValue);

            dir = rootDirectoryHandler.OpenFile("API").FileHandler;
            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "API", false, DateTime.MinValue);

            dir = rootDirectoryHandler.OpenFile("Templates").FileHandler;
            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Templates", false, DateTime.MinValue);

            dir = rootDirectoryHandler.OpenFile("Tests").FileHandler;
            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Tests", false, DateTime.MinValue);

            dir = rootDirectoryHandler.OpenFile("Pages").FileHandler;
            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Pages", false, DateTime.MinValue);

            dir = rootDirectoryHandler.OpenFile("Docs").FileHandler;
            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Docs", false, DateTime.MinValue);

            dir = rootDirectoryHandler.OpenFile("Classes").FileHandler;
            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Classes", false, DateTime.MinValue);

            if (!rootDirectoryHandler.IsFilePresent("Config"))
            {
                dir = (IDirectoryHandler)rootDirectoryHandler.CreateFile(
                    "Config", "directory", FileHandlerFactoryLocator.UserFactory.RootUser.Id);

                rootDirectoryHandler.SetPermission(
                    null,
                    "Config",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    ObjectCloud.Interfaces.Security.FilePermissionEnum.Read,
                    false,
                    false);

                rootDirectoryHandler.SetPermission(
                    null,
                    "Config",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Administrators.Id },
                    ObjectCloud.Interfaces.Security.FilePermissionEnum.Administer,
                    false,
                    false);
            }
            else
                dir = rootDirectoryHandler.OpenFile("Config").FileHandler;

            dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "Config", false, DateTime.MinValue);

            if (!rootDirectoryHandler.IsFilePresent("DefaultTemplate"))
            {
                dir = rootDirectoryHandler.CreateFile(
                    "DefaultTemplate",
                    "directory",
                    null);

                rootDirectoryHandler.SetPermission(
                    null,
                    "DefaultTemplate",
                    new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id },
                    FilePermissionEnum.Read,
                    true,
                    false);
            }
            else
                dir = rootDirectoryHandler.OpenFile("DefaultTemplate").FileHandler;

            /*// Only sync if the DefaultTemplate is empty
            List<IFileContainer> defaultTemplateFiles = new List<IFileContainer>(
                dir.FileContainer.CastFileHandler<IDirectoryHandler>().Files);

            if (defaultTemplateFiles.Count == 0)
                // Because most installations will modify the DefaultTemplate folder, syncing only happens if the folder is
                // missing.  This will prevent minor system upgrades from overwriting custom look and feel.
                dir.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "DefaultTemplate", false);*/

            dir.FileContainer.CastFileHandler<IDirectoryHandler>().SyncFromLocalDisk(
                "." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "DefaultTemplate",
                false,
                true);

            // Do not syncronize the index file; this is for the user to update.  It's just a web component anyway
            //IFileHandler indexFile = rootDirectoryHandler.OpenFile("index.oc").FileHandler;
            //indexFile.SyncFromLocalDisk("." + Path.DirectorySeparatorChar + "DefaultFiles" + Path.DirectorySeparatorChar + "index.oc");

            DoUpgrades(rootDirectoryHandler);
        }
Exemplo n.º 37
0
 public IFileContainer ConstructFileContainer(IFileHandler fileHandler, IFileId fileId, string typeId, IDirectoryHandler parentDirectoryHandler, FileHandlerFactoryLocator fileHandlerFactoryLocator, DateTime created)
 {
     return new FileContainer(fileHandler, fileId, typeId, parentDirectoryHandler, fileHandlerFactoryLocator, created);
 }
Exemplo n.º 38
0
        private IEnumerable<IFileContainer> GetObjectsAndTraverseDirectories(IDirectoryHandler directory)
        {
            foreach (IFileContainer toYield in directory.Files)
            {
                yield return toYield;

                if (toYield.FileHandler is IDirectoryHandler)
                    foreach (IFileContainer subToYield in GetObjectsAndTraverseDirectories((IDirectoryHandler)toYield.FileHandler))
                        yield return subToYield;
            }
        }
 public void CopyFile(IFileHandler sourceFileHandler, IFileId fileId, ID<IUserOrGroup, Guid>? ownerID, IDirectoryHandler parentDirectory)
 {
     throw new NotImplementedException("File type isn't supported");
 }