Esempio n. 1
0
 public void Exited(IApplicationInstance sender, int returnValue)
 {
     callback.Exited(this, returnValue);
     isRunning     = false;
     exitResult    = returnValue;
     exitException = null;
 }
Esempio n. 2
0
 public void Exited(IApplicationInstance sender, Exception exception)
 {
     callback.Exited(this, exception);
     isRunning     = false;
     exitException = exception;
     exitResult    = ~0;
 }
Esempio n. 3
0
        void SendExecuteMessage(IEnumerable <GuidData> applicationInstances, string command)
        {
            List <Exception> exceptions = null;

            foreach (GuidData applicationInstanceId in applicationInstances)
            {
                try {
                    using (ChannelFactory <IApplicationInstance> pipeFactory = new ChannelFactory <IApplicationInstance>(new NetNamedPipeBinding(), new EndpointAddress(string.Format("{0}/{1}", GetServiceUri(applicationInstanceId), EndPointName)))) {
                        IApplicationInstance pipeProxy = pipeFactory.CreateChannel();
                        pipeProxy.Execute(command);
                    }
                } catch (CommunicationException) {
                } catch (Exception e) {
                    if (exceptions == null)
                    {
                        exceptions = new List <Exception>();
                    }
                    exceptions.Add(e);
                }
            }
            if (exceptions != null)
            {
                throw new InvalidOperationException("", new AggregateException(exceptions.ToArray()));
            }
        }
Esempio n. 4
0
        public ActionCenterApplicationButton(IApplicationInfo info, IApplicationInstance instance = null)
        {
            this.info     = info;
            this.instance = instance;

            InitializeComponent();
            InitializeApplicationInstanceButton();
        }
 static ApplicationInstance ()
 {
     if (Application.IsMSDotNet || ApplicationContext.CommandLine.Contains ("disable-dbus")) {
         instance = new IpcRemotingApplicationInstance ();
     } else {
         instance = new DBusApplicationInstance ();
     }
 }
        public TaskbarApplicationInstanceButton(IApplicationInstance instance, IApplicationInfo info)
        {
            this.info     = info;
            this.instance = instance;

            InitializeComponent();
            InitializeApplicationInstanceButton();
        }
Esempio n. 7
0
        public void Exited(IApplicationInstance sender, int returnValue)
        {
            this.isRunning     = false;
            this.exitResult    = returnValue;
            this.exitException = null;

            this.callback.Exited(this, returnValue);
            Cleanup();
        }
        public void Exited(IApplicationInstance sender, Exception exception)
        {
            applicationInstances.RemoveAll(delegate(IApplicationInstance instance)
            {
                return(instance.InstanceId == sender.InstanceId);
            });

            //Console.Out.WriteLine("Kernel: {0} has exited with exception\n{1}", sender.ApplicationInfo.Name, exception);
        }
        public void Exited(IApplicationInstance sender, int returnValue)
        {
            applicationInstances.RemoveAll(delegate(IApplicationInstance instance)
            {
                return(instance.InstanceId == sender.InstanceId);
            });

            //Console.Out.WriteLine("Kernel: {0} has exited with code {1}", sender.ApplicationInfo.Name, returnValue);
        }
Esempio n. 10
0
        public void Exited(IApplicationInstance sender, Exception exception)
        {
            this.isRunning     = false;
            this.exitException = exception;
            this.exitResult    = ~0;

            this.callback.Exited(this, exception);
            Cleanup();
        }
Esempio n. 11
0
        public bool Start()
        {
            if (instance == null || !instance.IsRunning)
            {
                instance = appInstances.Run(ApplicationPath, string.Empty, new string[0]);
            }

            return(Started);
        }
Esempio n. 12
0
        public bool Stop()
        {
            if (instance != null && instance.IsRunning)
            {
                appInstances.Kill(instance);
                instance = null;
            }

            return(!Started);
        }
 public void Kill(IApplicationInstance app)
 {
     if (app is IOSApplication)
     {
         (app as IOSApplication).Kill();
     }
     else
     {
         throw new Exception("Invalid application instance");
     }
 }
        private void RemoveInstance(TaskbarApplicationInstanceButton button)
        {
            Dispatcher.InvokeAsync(() =>
            {
                InstanceStackPanel.Children.Remove(button);

                if (InstanceStackPanel.Children.Count == 0)
                {
                    single = default(IApplicationInstance);
                }
            });
        }
        public void RegisterInstance(IApplicationInstance instance)
        {
            Dispatcher.Invoke(() =>
            {
                var instanceButton = new TaskbarApplicationInstanceButton(instance, info);

                instanceButton.Clicked += (id) => Clicked?.Invoke(id);
                instance.Terminated    += (id) => Instance_OnTerminated(id, instanceButton);

                instances.Add(instance);
                InstanceStackPanel.Children.Add(instanceButton);
            });
        }
Esempio n. 16
0
        public void RegisterInstance(IApplicationInstance instance)
        {
            Dispatcher.Invoke(() =>
            {
                var button = new ActionCenterApplicationButton(info, instance);

                button.Clicked      += (id) => Clicked?.Invoke(id);
                instance.Terminated += (id) => Instance_OnTerminated(id, button);
                InstancePanel.Children.Add(button);

                ApplicationName.Visibility   = Visibility.Visible;
                ApplicationButton.Visibility = Visibility.Collapsed;
            });
        }
        private void Application_InstanceStarted(IApplicationInstance instance)
        {
            Dispatcher.InvokeAsync(() =>
            {
                var button = new ActionCenterApplicationButton(application.Info, instance);

                button.Clicked      += (o, args) => instance.Activate();
                instance.Terminated += (_) => RemoveInstance(button);
                InstancePanel.Children.Add(button);

                ApplicationName.Visibility   = Visibility.Visible;
                ApplicationButton.Visibility = Visibility.Collapsed;
            });
        }
        private void Application_InstanceStarted(IApplicationInstance instance)
        {
            Dispatcher.Invoke(() =>
            {
                var button = new TaskbarApplicationInstanceButton(instance, application.Info);

                instance.Terminated += (_) => RemoveInstance(button);
                InstanceStackPanel.Children.Add(button);

                if (single == default(IApplicationInstance))
                {
                    single = instance;
                }
            });
        }
        private void ConfigureBackBehaviour(
            IApplicationInstance applicationInstance,
            IApplicationManager appManager)
        {
            applicationInstance.GoHome = () => appManager.GoHome();

            applicationInstance.GoBack = () =>
            {
                if (applicationInstance.ScreenManager.CurrentLayer > 0)
                {
                    applicationInstance.ScreenManager.GoBack();
                }
                else
                {
                    appManager.GoHome();
                }
            };
        }
Esempio n. 20
0
        public void SetActiveApplication(IApplicationInstance application)
        {
            if (ActiveApplication != null)
            {
                // Suspend all screen activity - event listeners
                ActiveApplication.Suspend();
            }

            // Probably need to think of a nicer way to do this, but for now passing in null brings us back to our home screen
            ActiveApplication = application;

            // Ensure that the application has been initialized
            if (!ActiveApplication.IsInitialized)
            {
                ActiveApplication.Initialize();
            }
            else
            {
                // Every time an application becomes active, we call start, regardless of initialization status.
                ActiveApplication.Start();
            }
        }
Esempio n. 21
0
        public override int Start(string verb, string[] args)
        {
            Console.WriteLine(String.Join(",", args));

            Console.WriteLine(">> INIT, v.0.0.1 Booting SharpMedia ComponentOS (c) 2005-2008");
            Console.WriteLine("Init: Starting Services...");
            (componentDirectory.GetInstance <IServiceRegistry>() as IServiceControl).Start();

            Console.Out.WriteLine("Double Vectors Per Second on a WU Thread: " +
                                  (threadControl.WorkUnits.FreeMost(typeof(ICPUWorkUnit)) as ICPUWorkUnit).FPU.DoubleVectorCrosses4D);

            IApplicationInstance proc =
                applicationInstances.Run(
                    args.Length > 0 ? args[0] : "/System/Applications/Components/TextShell", string.Empty, args);

            while (proc.IsRunning)
            {
                Thread.Sleep(100);
            }

            Console.WriteLine("Init: Shutting Down...");
            (componentDirectory.GetInstance <IServiceRegistry>() as IServiceControl).Stop();
            return(1);
        }
 internal void ApplicationExited(IApplicationInstance osApp, Exception exc)
 {
     applicationInstances.Remove(osApp);
 }
Esempio n. 23
0
 static IoC()
 {
     Container = new WindsorContainer();
     Container.Register(Component.For <IApplicationInstance>().ImplementedBy <ApplicationInstance>());
     Application = Container.Resolve <IApplicationInstance>();
 }
 internal void ApplicationExited(IApplicationInstance osApp, int rval)
 {
     applicationInstances.Remove(osApp);
 }
Esempio n. 25
0
        public static void Execute(DatabaseManager dbMgr, string[] args)
        {
            //---- Hook up the assembly loading ----
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            AppDomain.CurrentDomain.TypeResolve     += new ResolveEventHandler(CurrentDomain_TypeResolve);

            assemblyLoader = new KernelAssemblyLoader();
            assemblyLoader.DatabaseManager = dbMgr;

            kernelEnvironment.Register(
                new Instance(assemblyLoader, "AssemblyLoader"));

            kernelEnvironment.Register(
                new ConfiguredComponent(
                    typeof(DocumentManagement), "DocumentManagement"));

            kernelEnvironment.Register(
                new ConfiguredComponent(
                    typeof(KernelApplicationsDirectory), "ApplicationManagement"));

            kernelEnvironment.Register(
                new ConfiguredComponent(
                    typeof(Installation.AuthoringInstallationService), "InstallationService"));

            kernelEnvironment.Register(
                new Instance(dbMgr, "DatabaseManagerDriver"));

            kernelEnvironment.Register(
                new AlwaysNewConfiguredComponent(typeof(DatabaseManager), "DatabaseManager"));

            kernelEnvironment.Register(
                new ConfiguredComponent(typeof(StandardConsole), "Console"));

            kernelEnvironment.Register(
                new ConfiguredComponent(typeof(ServiceManager), "Services"));
            kernelEnvironment.GetInstance<IServiceRegistry>();

            kernelEnvironment.Register(
                new ConfiguredComponent(typeof(ThreadControl), "ThreadControl"));

            //---- INIT ----
            InstallationService installService = kernelEnvironment.GetInstance<InstallationService>();

            if (!installService.IsPackageInstalled(baseSystemId))
            {
                IPackage pkg = 
                    installService.OpenPackageForInstallation("/Volumes/Host/Installation/BaseSystem.ipkg");

                pkg.Selected = true;
                installService.Install(pkg);
     
                pkg =
                    installService.OpenPackageForInstallation("/Volumes/Host/Installation/Graphics.ipkg");
                
                pkg.Selected = true;
                installService.Install(pkg);

                
                pkg =
                    installService.OpenPackageForInstallation("/Volumes/Host/Installation/Direct3D10Driver.ipkg");

                pkg.Selected = true;
                installService.Install(pkg);
                 
                /*
                pkg = 
                    installService.OpenPackageForInstallation("/Volumes/Host/Installation/Tools.ipkg");
                pkg.Selected = true;
                installService.Install(pkg);*/
            }

            IApplicationInstances appInstances = kernelEnvironment.GetInstance<IApplicationInstances>();
            IApplicationInstance init = appInstances.Run("/System/Applications/Components/Init", string.Empty, args);

            while (init.IsRunning) Thread.Sleep(100);
        }
Esempio n. 26
0
        public int Exec(ExecutionContext context, out object[] inlineOutputDump)
        {
            // We set at beginning to invalid.
            inlineOutputDump = CommonShellCommands.EmptyParameters;

            // 1) We first resolve the method's name.
            object[] outDummy;
            if (methodName.Exec(context.ShellApp.CreateSubContext(context, methodName), out outDummy) < 0)
            {
                return(-1);
            }

            if (outDummy.Length != 1)
            {
                context.Error.WriteLine("The method name constist of too many inline returns.");
                return(-1);
            }

            // We have the method's name.
            string resolvedMethodName = outDummy[0].ToString();

            // 2) We resolve all parameters.
            List <object> resolvedParameters = new List <object>();

            for (int i = 0; i < parameters.Length; i++)
            {
                // We execute each.
                if (parameters[i].Exec(context.ShellApp.CreateSubContext(context, parameters[i]), out outDummy) < 0)
                {
                    return(-1);
                }

                resolvedParameters.AddRange(outDummy);
            }

            // 3a) handle aliases.
            string methodNameAlias;

            if (context.ShellApp.Aliases.TryGetValue(resolvedMethodName, out methodNameAlias))
            {
                resolvedMethodName = methodNameAlias;
            }


            // 3b) We now execute the method. We search in internal commands.
            for (int i = 0; i < context.ShellApp.ShellCommandTypes.Length; i++)
            {
                Type commands = context.ShellApp.ShellCommandTypes[i];

                foreach (MethodInfo info in commands.GetMethods(BindingFlags.Static | BindingFlags.Public))
                {
                    object[] attrs = info.GetCustomAttributes(typeof(ShellCommandAttribute), false);
                    if (attrs.Length == 0)
                    {
                        continue;
                    }

                    // We now match attributes.
                    ShellCommandAttribute attr = attrs[0] as ShellCommandAttribute;

                    if (string.Compare(resolvedMethodName, info.Name, !attr.CaseSensitive) != 0)
                    {
                        continue;
                    }

                    if (context.IsParallel && !attr.CanParallel)
                    {
                        context.Error.WriteLine("Command {0} failed: cannot be used parallel.", resolvedMethodName);
                        return(-1);
                    }

                    // We have a method, we call it.
                    try
                    {
                        object[] inputParams = new object[] { context, resolvedParameters.ToArray(), null };
                        int      returnVal   = (int)info.Invoke(null, inputParams);

                        // We link to out parameter.
                        inlineOutputDump = (object[])inputParams[2];

                        return(returnVal);
                    }
                    catch (Exception ex)
                    {
                        context.Error.WriteLine("Command {0} failed:\n {1}", resolvedMethodName,
                                                context.ShellApp.ReportLevel == ReportLevel.NoTrace ? ex.Message : ex.ToString());
                    }
                    return(1);
                }
            }

            // 3c) We search applications.
            try
            {
                string[] args = Array.ConvertAll(resolvedParameters.ToArray(),
                                                 new Converter <object, string>(delegate(object someObj) { return(someObj.ToString()); }));

                // We find application.
                Node <object> appNode = context.ShellApp.WorkingDirectory.Find(resolvedMethodName);
                if (appNode == null)
                {
                    // We try common paths.
                    for (int i = 0; i < context.ShellApp.ExecutableSearchPaths.Length; i++)
                    {
                        appNode = context.ShellApp.Database.Find(
                            context.ShellApp.ExecutableSearchPaths[i] + resolvedMethodName);
                        if (appNode != null)
                        {
                            break;
                        }
                    }

                    if (appNode == null)
                    {
                        context.Error.WriteLine("Command '{0}' not understood", resolvedMethodName);
                        return(-1);
                    }
                }

                // We run instance and wait for result.
                IApplicationInstance instance = context.ShellApp.ApplicationInstances.Run(appNode.Path, string.Empty, args);

                // FIXME: use 'lock for'
                if (!context.IsParallel)
                {
                    while (instance.IsRunning)
                    {
                        Thread.Sleep(100);
                    }
                    if (instance.ExitException != null)
                    {
                        context.Error.WriteLine("Executing '{0}' failed, exeption thrown:\n {1}", resolvedMethodName,
                                                context.ShellApp.ReportLevel == ReportLevel.NoTrace ? instance.ExitException.Message : instance.ExitException.ToString());
                    }

                    return(instance.ExitResult);
                }
                else
                {
                    context.ShellApp.RegisterParallel(instance);
                }
            }
            catch (Exception e)
            {
                context.Error.WriteLine("Executing '{0}' failed, exeption thrown:\n {1}", resolvedMethodName,
                                        context.ShellApp.ReportLevel == ReportLevel.NoTrace ? e.Message : e.ToString());
            }

            return(1);
        }
Esempio n. 27
0
 internal void RegisterParallel(IApplicationInstance instance)
 {
     // For now ignore it, in future we may allow managment, switch to it or something like that.
 }
Esempio n. 28
0
        /// <summary>
        /// Sets up the bridge in the new appdomain
        /// </summary>
        /// <param name="parentDirectory">Parent component directory</param>
        /// <param name="app">Application descriptor</param>
        /// <param name="guid">Application instance GUID</param>
        /// <param name="appInstance">Self application instance to link into the directory</param>
        internal void Setup(IComponentDirectory parentDirectory, ApplicationDesc app, Guid guid, IApplicationInstance appInstance, IAssemblyLoader xassemblyLoader)
        {
            assemblyLoader = xassemblyLoader;

            string iname = app.Name + " " + guid;

            // Console.Out.WriteLine("Creating process: {0}", iname);
            AppDomain.CurrentDomain.TypeResolve     += new ResolveEventHandler(CurrentDomain_TypeResolve);
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            this.directory = new ComponentDirectory(parentDirectory, iname);
            this.directory.Register(
                new Instance(
                    this.directory.GetInstance <DatabaseManager>().Find("/")));

            IComponentProvider appProvider = null;

            /** register self as process **/
            this.directory.Register(
                new Instance(appInstance, "Self"));

            /*******************************************************************************************
            * TODO: SECURITY: this is where we would re-register views of already registered (kernel)
            * providers to shadow the originals
            *******************************************************************************************/

            foreach (IComponentProvider provider in app.Components)
            {
                this.directory.Register(provider);

                if (provider.MatchedName == app.ApplicationComponent)
                {
                    appProvider = provider;
                }
            }

            if (appProvider == null)
            {
                throw new Exception(
                          String.Format(
                              "The application {0} cannot be set up because the application component was not found",
                              app.Name));
            }

            this.appInstance = this.directory.GetInstance(appProvider.MatchedName) as IApplicationBase;

            if (app == null)
            {
                throw new Exception(
                          String.Format(
                              "The application {0} cannot be set up because the application component cannot be instantiated",
                              app.Name));
            }

            /* a-ok */
        }
 public ApplicationInstanceVisual(IApplicationInstance applicationinstance, Vector2f position)
 {
     this.ApplicationInstance = applicationinstance;
     Image.Position           = position;
 }
Esempio n. 30
0
        public void SetHomeApplication(IApplicationInstance homeApplication)
        {
            this.HomeApplication = homeApplication;

            SetActiveApplication(homeApplication);
        }
Esempio n. 31
0
 public void GoHome()
 {
     ActiveApplication = HomeApplication;
 }