Exemple #1
0
        public AdditionalResources()
        {
            InitializeComponent();

            _fileCompressor = new FileCompressor();

            groupBoxAdditionalResourceDetails.Visible = false;

            SEBSettings.additionalResourcesList  = (ListObj)SEBSettings.settingsCurrent[SEBSettings.KeyAdditionalResources];
            textBoxAdditionalResourcesTitle.Text = "";
            treeViewAdditionalResources.Nodes.Clear();
            foreach (DictObj l0Resource in SEBSettings.additionalResourcesList)
            {
                var l0Node = treeViewAdditionalResources.Nodes.Add(l0Resource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString(), GetDisplayTitle(l0Resource));
                foreach (DictObj l1Resource in (ListObj)l0Resource[SEBSettings.KeyAdditionalResources])
                {
                    var l1Node = l0Node.Nodes.Add(l1Resource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString(), GetDisplayTitle(l1Resource));
                    foreach (DictObj l2Resource in (ListObj)l1Resource[SEBSettings.KeyAdditionalResources])
                    {
                        l1Node.Nodes.Add(l2Resource[SEBSettings.KeyAdditionalResourcesIdentifier].ToString(), GetDisplayTitle(l2Resource));
                    }
                }
            }

            urlFilter = new SEBURLFilter();
        }
        private static void OnClientMessageBinary(byte[] obj)
        {
            // Check if we're running in exam mode already, if yes, then refuse to load a .seb file
            if (SEBClientInfo.examMode)
            {
                Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data is not allowed because it is already running in exam mode, sending command ReconfigureAborted to browser");
                SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted));

                SebWindowsClientMain.LoadingSebFile(false);
                SebWindowsClientForm.ShowReconfigureNotAllowed();
                return;
            }

            HasBeenReconfiguredByMessage = true;
            Logger.AddInformation("Received downloaded Config File data, " + obj.Length + " bytes. Sending command SebFileTransfer to browser");
            SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.SebFileTransfer, true));
            if (SEBClientInfo.SebWindowsClientForm.ReconfigureWithSettings(obj))
            {
                Logger.AddInformation("SEB was successfully reconfigured using the downloaded Config File data");

                // Convert new URL Filter rules to XUL seb2 rules
                // and add Start URL to allowed rules
                SEBURLFilter urlFilter = new SEBURLFilter();
                urlFilter.UpdateFilterRules();

                // Create JSON object with XULRunner parameters to pass to firefox.exe as base64 string
                var    xulRunnerSettings   = DeepClone(SEBSettings.settingsCurrent);
                string XULRunnerParameters = SEBXulRunnerSettings.XULRunnerConfigDictionarySerialize(xulRunnerSettings);

                SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.Reconfigure, new { configBase64 = XULRunnerParameters }));
            }
            else
            {
                Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data failed, sending command ReconfigureAborted to browser");
                SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted));
            }
            HasBeenReconfiguredByMessage = false;
        }