Exemplo n.º 1
0
        public void SendSuccess(string extraData1, string extraData2, bool ed2IsRtf)
        {
            UpdateHelperData uh = new UpdateHelperData(Response.Succeeded, UpdateStep.CheckForUpdate, extraData1, extraData2);

            uh.ExtraDataIsRTF[1] = ed2IsRtf;

            pipeServer.SendMessage(uh.GetByteArray());
        }
Exemplo n.º 2
0
        public void SendSuccess(string extraData1, string extraData2, bool ed2IsRtf)
        {
            UpdateHelperData uh = new UpdateHelperData(Response.Succeeded, UpdateStep.CheckForUpdate, extraData1, extraData2);

            uh.ExtraDataIsRTF[1] = ed2IsRtf;

            pipeServer.SendMessage(uh.GetByteArray());
        }
Exemplo n.º 3
0
        public void SendNewWyUpdate(string pipeName, int processID)
        {
            UpdateHelperData uh = new UpdateHelperData(UpdateAction.NewWyUpdateProcess) { ProcessID = processID };

            uh.ExtraData.Add(pipeName);
            uh.ExtraDataIsRTF.Add(false);

            pipeServer.SendMessage(uh.GetByteArray());
        }
Exemplo n.º 4
0
        void ServerReceivedData(byte[] message)
        {
            UpdateHelperData data = UpdateHelperData.FromByteArray(message);

            if (data.Action == UpdateAction.GetwyUpdateProcessID)
            {
                // send ProcessID
                pipeServer.SendMessage(new UpdateHelperData(UpdateAction.GetwyUpdateProcessID)
                {
                    ProcessID = Process.GetCurrentProcess().Id
                }.GetByteArray());
                return;
            }

            UpdateStep step = data.UpdateStep;

            if (step == UpdateStep.RestartInfo)
            {
                RestartInfoSent = true;

                // load the pre-install info
                if (data.ExtraData.Count > 0)
                {
                    FileOrServiceToExecuteAfterUpdate = data.ExtraData[0];
                    IsAService = data.ExtraDataIsRTF[0];
                }

                // load the AutoUpdateID (for writing to file whether the update failed or Succeeded)
                if (data.ExtraData.Count > 1)
                {
                    AutoUpdateID = data.ExtraData[1];
                }

                if (data.ExtraData.Count > 2)
                {
                    ExecutionArguments = data.ExtraData[2];
                }
            }
            else if (step == UpdateStep.Install)
            {
                // if we're already installing, don't bother to process the message again
                if (Installing)
                {
                    return;
                }

                Installing = true;
            }

            if (RequestReceived != null)
            {
                RequestReceived(this, data.Action, step);
            }
        }
Exemplo n.º 5
0
        public static UpdateHelperData FromByteArray(byte[] data)
        {
            UpdateHelperData uhData = new UpdateHelperData();

            using (MemoryStream ms = new MemoryStream(data))
            {
                byte bType = (byte)ms.ReadByte();

                //read until the end byte is detected
                while (!ReadFiles.ReachedEndByte(ms, bType, 0xFF))
                {
                    switch (bType)
                    {
                        case 0x01:
                            uhData.Action = (UpdateAction)ReadFiles.ReadInt(ms);
                            break;
                        case 0x02: // update step we're on
                            uhData.UpdateStep = (UpdateStep)ReadFiles.ReadInt(ms);
                            break;
                        case 0x80:
                            uhData.ExtraDataIsRTF.Add(true);
                            break;
                        case 0x03: // extra data

                            uhData.ExtraData.Add(ReadFiles.ReadString(ms));

                            // keep the 'ExtraDataIsRTF' same length as ExtraData
                            if (uhData.ExtraDataIsRTF.Count != uhData.ExtraData.Count)
                                uhData.ExtraDataIsRTF.Add(false);

                            break;
                        case 0x04:
                            uhData.ProcessID = ReadFiles.ReadInt(ms);
                            break;
                        case 0x05:
                            uhData.Progress = ReadFiles.ReadInt(ms);
                            break;
                        case 0x06:
                            uhData.ResponseType = (Response)ReadFiles.ReadInt(ms);
                            break;

                        // 0x07, 0x08, and 0x09 used to be links data - obsolete

                        default:
                            ReadFiles.SkipField(ms, bType);
                            break;
                    }

                    bType = (byte)ms.ReadByte();
                }
            }

            return uhData;
        }
Exemplo n.º 6
0
        public void SendNewWyUpdate(string pipeName, int processID)
        {
            UpdateHelperData uh = new UpdateHelperData(UpdateAction.NewWyUpdateProcess)
            {
                ProcessID = processID
            };

            uh.ExtraData.Add(pipeName);
            uh.ExtraDataIsRTF.Add(false);

            pipeServer.SendMessage(uh.GetByteArray());
        }
Exemplo n.º 7
0
        public void StartPipeServer(Control OwnerHandle)
        {
            //Note: this function can only be called once. Explosions otherwise.

            owner = OwnerHandle;

            pipeServer = new PipeServer();

            pipeServer.MessageReceived    += pipeServer_MessageReceived;
            pipeServer.ClientDisconnected += pipeServer_ClientDisconnected;

            pipeServer.Start(UpdateHelperData.PipenameFromFilename(VersionTools.SelfLocation));
        }
Exemplo n.º 8
0
        public static UpdateHelperData FromByteArray(byte[] data)
        {
            UpdateHelperData uhData = new UpdateHelperData();

            using (MemoryStream ms = new MemoryStream(data))
            {
                byte bType = (byte)ms.ReadByte();

                //read until the end byte is detected
                while (!ReadFiles.ReachedEndByte(ms, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:
                        uhData.Action = (UpdateAction)ReadFiles.ReadInt(ms);
                        break;

                    case 0x02:     // update step we're on
                        uhData.UpdateStep = (UpdateStep)ReadFiles.ReadInt(ms);
                        break;

                    case 0x80:
                        uhData.ExtraDataIsRTF.Add(true);
                        break;

                    case 0x03:     // extra data

                        uhData.ExtraData.Add(ReadFiles.ReadString(ms));

                        // keep the 'ExtraDataIsRTF' same length as ExtraData
                        if (uhData.ExtraDataIsRTF.Count != uhData.ExtraData.Count)
                        {
                            uhData.ExtraDataIsRTF.Add(false);
                        }

                        break;

                    case 0x04:
                        uhData.ProcessID = ReadFiles.ReadInt(ms);
                        break;

                    case 0x05:
                        uhData.Progress = ReadFiles.ReadInt(ms);
                        break;

                    case 0x06:
                        uhData.ResponseType = (Response)ReadFiles.ReadInt(ms);
                        break;

                    // 0x07, 0x08, and 0x09 used to be links data - obsolete

                    default:
                        ReadFiles.SkipField(ms, bType);
                        break;
                    }

                    bType = (byte)ms.ReadByte();
                }
            }

            return(uhData);
        }