Ejemplo n.º 1
0
        private static void CheckInternal()
        {
            UpdateInfo info = new UpdateInfo();
            try
            {
                using (WebClient client = new WebClient())
                {
#if DEBUG
                    client.Credentials = new NetworkCredential("sm", "sm_pw"); //heuheu :D 
                    string versionString = client.DownloadString("ftp://127.0.0.1/version_0.txt");
#else
                    string versionString = client.DownloadString("http://updater.spedit.info/version_0.txt");
#endif
                    string[] versionLines = versionString.Split('\n');
                    string version = (versionLines[0].Trim()).Trim('\r');
                    if (version != Program.ProgramInternalVersion)
                    {
                        string destinationFileName = "updater_" + version + ".exe";
                        string destinationFile = Path.Combine(Environment.CurrentDirectory, destinationFileName);
                        info.IsAvailable = true;
                        info.Updater_File = destinationFile;
                        info.Updater_FileName = destinationFileName;
#if DEBUG
                        info.Updater_DownloadURL = "ftp://127.0.0.1/" + destinationFileName;
#else
                        info.Updater_DownloadURL = "http://updater.spedit.info/" + destinationFileName;
#endif
                        info.Update_Version = version;
                        StringBuilder updateInfoString = new StringBuilder();
                        if (versionLines.Length > 1)
                        {
                            info.Update_StringVersion = versionLines[1];
                            for (int i = 1; i < versionLines.Length; ++i)
                            {
                                updateInfoString.AppendLine((versionLines[i].Trim()).Trim('\r'));
                            }
                        }
                        info.Update_Info = updateInfoString.ToString();
                    }
                    else
                    {
                        info.IsAvailable = false;
                    }
                }
            }
            catch (Exception e)
            {
                info.IsAvailable = false;
                info.GotException = true;
                info.ExceptionMessage = e.Message;
            }
            lock (Program.UpdateStatus) //since multiple checks can occur, we'll wont override another ones...
            {
                if (Program.UpdateStatus.WriteAble)
                {
                    Program.UpdateStatus = info;
                }
            }
        }
Ejemplo n.º 2
0
 public UpdateWindow(UpdateInfo info)
 {
     updateInfo = info;
     InitializeComponent();
     DescriptionBox.Text = updateInfo.Update_Info;
     if (info.SkipDialog)
     {
         StartUpdate();
     }
 }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            bool InSafe = false;
            bool mutexReserved;
            using (Mutex appMutex = new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
            {
                if (mutexReserved)
                {
#if !DEBUG
                    try
                    {
#endif
                        SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png");
                        splashScreen.Show(false, true);
                        UpdateStatus = new UpdateInfo();
                        Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                        OptionsObject = OptionsControlIOObject.Load();
                        for (int i = 0; i < args.Length; ++i)
                        {
                            if (args[i].ToLowerInvariant() == "-rcck") //ReCreateCryptoKey
                            {
                                var opt = OptionsObject;
                                OptionsObject.ReCreateCryptoKey();
                                MessageBox.Show("All FTP passwords are now encrypted wrong!" + Environment.NewLine + "You have to replace them!",
                                    "Created new crypto key", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                            else if (args[i].ToLowerInvariant() == "-safe")
                            {
                                InSafe = true;
                            }
                        }
                        Configs = ConfigLoader.Load();
                        for (int i = 0; i < Configs.Length; ++i)
                        {
                            if (Configs[i].Name == OptionsObject.Program_SelectedConfig)
                            {
                                Program.SelectedConfig = i;
                                break;
                            }
                        }
                        if (!OptionsObject.Program_UseHardwareAcceleration)
                        {
                            RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
                        }
                        MainWindow = new MainWindow(splashScreen);
                        PipeInteropServer pipeServer = new PipeInteropServer(MainWindow);
                        pipeServer.Start();
#if !DEBUG
                    }
                    catch (Exception e)
                    {
                        File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
                        MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
                            "Error while Loading",
                            MessageBoxButton.OK,
                            MessageBoxImage.Error);
                        Environment.Exit(Environment.ExitCode);
                    }
#endif
                        Application app = new Application();
                        if (InSafe)
                        {
                            try
                            {
#if !DEBUG
                                if (OptionsObject.Program_CheckForUpdates)
                                {
                                    UpdateCheck.Check(true);
                                }
#endif
                                app.Run(MainWindow);
                                OptionsControlIOObject.Save();
                            }
                            catch (Exception e)
                            {
                                File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
                                MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
                                    "Error",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                                Environment.Exit(Environment.ExitCode);
                            }
                        }
                        else
                        {
#if !DEBUG
                            if (OptionsObject.Program_CheckForUpdates)
                            {
                                UpdateCheck.Check(true);
                            }
#endif
                            app.Run(MainWindow);
                            OptionsControlIOObject.Save();
                        }
                }
                else
                {
                    try
                    {
                        StringBuilder sBuilder = new StringBuilder();
                        bool addedFiles = false;
                        for (int i = 0; i < args.Length; ++i)
                        {
                            if (!string.IsNullOrWhiteSpace(args[i]))
                            {
                                FileInfo fInfo = new FileInfo(args[i]);
                                if (fInfo.Exists)
                                {
                                    string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' });
                                    if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
                                    {
                                        addedFiles = true;
                                        sBuilder.Append(fInfo.FullName);
                                        if ((i + 1) != args.Length)
                                        { sBuilder.Append("|"); }
                                    }
                                }
                            }
                        }
                        if (addedFiles)
                        { PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); }
                    }
                    catch (Exception) { } //dont f**k the user up with irrelevant data
                }
            }
        }