private void CreatePipeServer()
        {
            pipeServer = new NamedPipeServerStream("www.pmuniverse.net-installer", PipeDirection.InOut, 1, (PipeTransmissionMode)0, PipeOptions.Asynchronous);

            pipeServer.WaitForConnection();
            //pipeServer.BeginWaitForConnection(new AsyncCallback(PipeConnected), pipeServer);

            Pipes.StreamString streamString = new Pipes.StreamString(pipeServer);

            while (pipeServer.IsConnected) {
                string line = streamString.ReadString();

                if (!string.IsNullOrEmpty(line)) {

                    if (line.StartsWith("[Status]")) {
                        installPage.UpdateStatus(line.Substring("[Status]".Length));
                    } else if (line.StartsWith("[Progress]")) {
                        installPage.UpdateProgress(line.Substring("[Progress]".Length).ToInt());
                    } else if (line.StartsWith("[Component]")) {
                        installPage.UpdateCurrentComponent(line.Substring("[Component]".Length));
                    } else if (line == "[Error]") {
                        throw new Exception(line.Substring("[Error]".Length));
                    } else if (line == "[InstallComplete]") {
                        installPage.InstallComplete();
                        break;
                    }

                }
            }

            pipeServer.Close();
        }
Example #2
0
        public void Install(Pipes.StreamString pipeStream)
        {
            Thread installThread = new Thread(new ParameterizedThreadStart(InstallCallback));

            installThread.Name         = "Installation Thread";
            installThread.IsBackground = true;
            installThread.Priority     = ThreadPriority.Normal;
            installThread.Start(pipeStream);
        }
Example #3
0
        public static void RunProperMode(Command command)
        {
            if (command.ContainsCommandArg("/Uninstall"))   // Are we in uninstall-mode?
            {
                UninstallHelper uninstallHelper = new UninstallHelper();
                uninstallHelper.RunUninstall();
            }
            else if (command.ContainsCommandArg("-silentinstall"))
            {
                Globals.InPortableMode  = command["-portable"].ToBool();
                Globals.IsSilentInstall = true;
                NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "www.pmuniverse.net-installer", PipeDirection.InOut, PipeOptions.None, System.Security.Principal.TokenImpersonationLevel.Impersonation);
                pipeClient.Connect();
                Pipes.StreamString clientStream = new Pipes.StreamString(pipeClient);
                Globals.SilentInstallCommunicationPipeStream = clientStream;
                Globals.SilentInstallCommunicationPipe       = pipeClient;
                installWaitEvent = new ManualResetEvent(false);
                Installer installer = new Installer(command);
                installer.InstallComplete += new EventHandler(installer_InstallComplete);
                installer.Install(clientStream);

                installWaitEvent.WaitOne();

                clientStream.WriteString("[InstallComplete]");

                pipeClient.WaitForPipeDrain();
                pipeClient.Close();

                System.Environment.Exit(0);
            }
            else
            {
                // There are no special command line arguments, run the installer in install mode
                // Let's check if we elevated ourselves
                if (!Globals.CommandLine.ContainsCommandArg("/skipwelcome") || !VistaSecurity.IsAdmin())
                {
                    // Show the welcome page
                    PageManager.ActivePage = new Pages.pgeWelcome();
                }
                else
                {
                    // Show the license page
                    PageManager.ActivePage = new Pages.pgeLicense();
                }
            }
        }
Example #4
0
        private void CreatePipeServer()
        {
            pipeServer = new NamedPipeServerStream("www.pmuniverse.net-installer", PipeDirection.InOut, 1, (PipeTransmissionMode)0, PipeOptions.Asynchronous);

            pipeServer.WaitForConnection();
            //pipeServer.BeginWaitForConnection(new AsyncCallback(PipeConnected), pipeServer);

            Pipes.StreamString streamString = new Pipes.StreamString(pipeServer);

            while (pipeServer.IsConnected)
            {
                string line = streamString.ReadString();

                if (!string.IsNullOrEmpty(line))
                {
                    if (line.StartsWith("[Status]"))
                    {
                        installPage.UpdateStatus(line.Substring("[Status]".Length));
                    }
                    else if (line.StartsWith("[Progress]"))
                    {
                        installPage.UpdateProgress(line.Substring("[Progress]".Length).ToInt());
                    }
                    else if (line.StartsWith("[Component]"))
                    {
                        installPage.UpdateCurrentComponent(line.Substring("[Component]".Length));
                    }
                    else if (line == "[Error]")
                    {
                        throw new Exception(line.Substring("[Error]".Length));
                    }
                    else if (line == "[InstallComplete]")
                    {
                        installPage.InstallComplete();
                        break;
                    }
                }
            }

            pipeServer.Close();
        }
Example #5
0
        private void InstallComponent(int index, Pipes.StreamString pipeStream)
        {
            pipeStream.WriteString("[Component]" + components[index].Name);
            // Subscribe to the ProgressUpdate event, and update the installer pages' progress bar
            components[index].ProgressUpdate += delegate(object sender, ProgressUpdateEventArgs e)
            {
                pipeStream.WriteString("[Progress]" + e.Percent);
            };
            components[index].StatusUpdate += delegate(object sender, StatusUpdateEventArgs e)
            {
                pipeStream.WriteString("[Status]" + e.Status);
            };
            components[index].InstallComplete += delegate(object sender, EventArgs e)
            {
                if (index + 1 < components.Count)
                {
                    InstallComponent(index + 1, pipeStream);
                }
                else
                {
                    if (InstallComplete != null)
                    {
                        InstallComplete(this, EventArgs.Empty);
                    }
                }
            };
            switch (Mode)
            {
            case InstallMode.Install: {
                components[index].Install();
            }
            break;

            case InstallMode.Repair: {
                components[index].Repair(destinationDirectory);
            }
            break;
            }
        }
        public static void RunProperMode(Command command)
        {
            if (command.ContainsCommandArg("/Uninstall")) { // Are we in uninstall-mode?
                UninstallHelper uninstallHelper = new UninstallHelper();
                uninstallHelper.RunUninstall();
            } else if (command.ContainsCommandArg("-silentinstall")) {
                Globals.InPortableMode = command["-portable"].ToBool();
                Globals.IsSilentInstall = true;
                NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "www.pmuniverse.net-installer", PipeDirection.InOut, PipeOptions.None, System.Security.Principal.TokenImpersonationLevel.Impersonation);
                pipeClient.Connect();
                Pipes.StreamString clientStream = new Pipes.StreamString(pipeClient);
                Globals.SilentInstallCommunicationPipeStream = clientStream;
                Globals.SilentInstallCommunicationPipe = pipeClient;
                installWaitEvent = new ManualResetEvent(false);
                Installer installer = new Installer(command);
                installer.InstallComplete += new EventHandler(installer_InstallComplete);
                installer.Install(clientStream);

                installWaitEvent.WaitOne();

                clientStream.WriteString("[InstallComplete]");

                pipeClient.WaitForPipeDrain();
                pipeClient.Close();

                System.Environment.Exit(0);
            } else {
                // There are no special command line arguments, run the installer in install mode
                // Let's check if we elevated ourselves
                if (!Globals.CommandLine.ContainsCommandArg("/skipwelcome") || !VistaSecurity.IsAdmin()) {
                    // Show the welcome page
                    PageManager.ActivePage = new Pages.pgeWelcome();
                } else {
                    // Show the license page
                    PageManager.ActivePage = new Pages.pgeLicense();
                }
            }
        }
Example #7
0
        private void PipeConnected(IAsyncResult asyncResult)
        {
            NamedPipeServerStream pipeServer = asyncResult.AsyncState as NamedPipeServerStream;

            pipeServer.EndWaitForConnection(asyncResult);

            Pipes.StreamString streamString = new Pipes.StreamString(pipeServer);

            while (pipeServer.IsConnected)
            {
                string line = streamString.ReadString();

                if (!string.IsNullOrEmpty(line))
                {
                    if (line.StartsWith("[Status]"))
                    {
                        installPage.UpdateStatus(line.Substring("[Status]".Length));
                    }
                    else if (line.StartsWith("[Progress]"))
                    {
                        installPage.UpdateProgress(line.Substring("[Progress]".Length).ToInt());
                    }
                    else if (line.StartsWith("[Component]"))
                    {
                        installPage.UpdateCurrentComponent(line.Substring("[Component]".Length));
                    }
                    else if (line == "[InstallComplete]")
                    {
                        installPage.InstallComplete();
                        break;
                    }
                }
            }

            pipeServer.Close();
        }
        private void PipeConnected(IAsyncResult asyncResult)
        {
            NamedPipeServerStream pipeServer = asyncResult.AsyncState as NamedPipeServerStream;
            pipeServer.EndWaitForConnection(asyncResult);

            Pipes.StreamString streamString = new Pipes.StreamString(pipeServer);

            while (pipeServer.IsConnected) {
                string line = streamString.ReadString();

                if (!string.IsNullOrEmpty(line)) {

                    if (line.StartsWith("[Status]")) {
                        installPage.UpdateStatus(line.Substring("[Status]".Length));
                    } else if (line.StartsWith("[Progress]")) {
                        installPage.UpdateProgress(line.Substring("[Progress]".Length).ToInt());
                    } else if (line.StartsWith("[Component]")) {
                        installPage.UpdateCurrentComponent(line.Substring("[Component]".Length));
                    } else if (line == "[InstallComplete]") {
                        installPage.InstallComplete();
                        break;
                    }

                }
            }

            pipeServer.Close();
        }