예제 #1
1
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!loadConfigFile())
            {
                MessageBox.Show("Can't read configuration file!");
                Application.Exit();
            }
            try
            {
                project_uri = new Uri(getCfgValue("projecturl"));
            }
            catch (UriFormatException)
            {
                MessageBox.Show("Malformed projecturl tag in the configuration file!");
                Application.Exit();
            }

            var value = new Uri(project_uri, getCfgValue("updates_page_url", "updates.html"));            

            webBrowser1.Navigate(value); 
            update_state = UpdateStates.Ready;

            this.Text = getCfgValue("application_title");

            runWhenFinished = (RunApplications)getCfgValueInt("runWhenFinished");

            workInBackground.DoWork += new DoWorkEventHandler(UpdateTheClient);
            workInBackground.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UpdateTheClientCompleted);
            workInBackground.ProgressChanged += new ProgressChangedEventHandler(UpdateTheClientProgressChanged);
        }
예제 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!loadConfigFile())
            {
                MessageBox.Show("Can't read configuration file!");
                Application.Exit();
            }
            try
            {
                project_uri = new Uri(getCfgValue("projecturl"));
            }
            catch (UriFormatException)
            {
                MessageBox.Show("Malformed projecturl tag in the configuration file!");
                Application.Exit();
            }

            var value = new Uri(project_uri, getCfgValue("updates_page_url", "updates.html"));

            webBrowser1.Navigate(value);
            update_state = UpdateStates.Ready;

            this.Text = getCfgValue("application_title");

            runWhenFinished = (RunApplications)getCfgValueInt("runWhenFinished");

            workInBackground.DoWork             += new DoWorkEventHandler(UpdateTheClient);
            workInBackground.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UpdateTheClientCompleted);
            workInBackground.ProgressChanged    += new ProgressChangedEventHandler(UpdateTheClientProgressChanged);
        }
예제 #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (workInBackground.IsBusy && update_state != UpdateStates.Ready)
            {
                return;
            }

            btnUpdate.Enabled = false;
            update_state      = UpdateStates.Updating;

            workInBackground.RunWorkerAsync();

            return;

            /*
             * if (update_state == UpdateStates.Ready || update_state == UpdateStates.Failed)
             * {
             *  //System.Threading.Thread.Sleep(5000);
             *  updateInBackground.RunWorkerAsync();
             * }
             */

            /*
             * if (update_state == UpdateStates.Ready || update_state == UpdateStates.Failed)
             * {
             *  update_state = UpdateStates.Updating;
             *  ((Button)sender).Text = "Checking updates..";
             *  ((Button)sender).Enabled = false;
             *
             *  lblStatus.Text = "Contacting Updates Site ..";
             *
             *  updateInBackground.DoWork += updateInBackground_DoWork;
             *
             *  var res = checkUpdates();
             *  if (res == true)
             *  {
             *      lblStatus.Text = "All done...";
             *      ((Button)sender).Text = "Play "+getCfgValue("shardname", "UO");
             *      update_state = UpdateStates.Success;
             *      if (getCfgValueInt("closeWhenFinished") == 1)
             *      {
             *          RunClientApplication();
             *          Application.Exit();
             *      }
             *  }
             *  else
             *  {
             *      update_state = UpdateStates.Failed;
             *      ((Button)sender).Text = "Check Updates ..";
             *  }
             *  ((Button)sender).Enabled = true;
             * } else
             *  if (update_state == UpdateStates.Success)
             *  {
             *      RunClientApplication();
             *      Application.Exit();
             *  }
             *
             */
        }
예제 #4
0
        public UpdateStates UpdateObject(ISerializableObject iso, DbConnection connection, ISerializerTransaction transaction)
        {
            UpdateStates    state = UpdateStates.UPDATED;
            AttributeWorker w     = AttributeWorker.GetInstance(Target);
            DbCommand       com   = connection.CreateCommand();
            Guid            g     = AttributeWorker.RowGuid(iso);
            GenericWeakReference <ISerializableObject> tmp;

            try
            {
                tmp = _persistentObjects[g];
            }
            catch (KeyNotFoundException ex)
            {
                throw new UpdateException("update failed. object is not known by the system and must be loaded first", ex);
            }
            com.CommandText = _owner.SerializeUpdate(iso, ref state, tmp);
            transaction.Guard(com);
            //Console.WriteLine(com.CommandText);
            try
            {
                if (com.ExecuteNonQuery() < 1)
                {
                    state = UpdateStates.NO_ROWS_AFFECTED;
                    return(state);
                }
                return(state);
            }
            catch (Exception ex)
            {
                throw new SerializerException("update failed", ex);
            }
        }
예제 #5
0
 void BuildDownloadListCallback(object o)
 {
     UpdateState                = UpdateStates.FetchingFiles;
     CompletedDownloads         = new List <DownloadTask>();
     FileNum                    = 1;
     PBProgress.IsIndeterminate = false;
     PBProgress.Value           = 0;
     DownloadedSize             = 0;
     FileCount                  = DownloadTasks.Count;
     FetchFiles();
 }
예제 #6
0
        private void UpdateTheClientCompleted(
            object sender, RunWorkerCompletedEventArgs e)
        {
            update_state      = UpdateStates.Ready;
            btnUpdate.Enabled = true;

            RunClientApplication();

            if (getCfgValueInt("closeWhenFinished") == 1)
            {
                Application.Exit();
            }
        }
예제 #7
0
        internal void UpdatePlain(ISerializableObject iso, ISerializerTransaction transaction)
        {
            UpdateStates state = _objectPool.UpdateObject(iso, _connection, transaction);

            if (state == UpdateStates.NO_ROWS_AFFECTED)
            {
                throw new SerializerException("entry could not be updated ...");
            }
            else if (state == UpdateStates.PRIMARYKEY_MODIFIED)
            {
                UpdateEventArgs args = new UpdateEventArgs(state);
                OnUpdateEvent(args);
            }
        }
예제 #8
0
        public static void Check(UpdateCompleteDelegate callback = null, ReleaseStream stream = ReleaseStream.Stable40, ThreadPriority priority = ThreadPriority.Normal)
        {
            lock (UpdateLock)
            {
                if (updateThread != null)
                {
                    return;
                }

                ReleaseStream    = stream;
                completeCallback = callback;

                setCallbackStatus(UpdateStates.Checking);

                updateThread = new Thread(() =>
                {
                    try
                    {
                        Log();
                        Log(@"Beginning update thread");
                        Log(@"Stream: " + ReleaseStream.ToString());
                        Log();
                        UpdateStates state = doUpdate();
                        Log();
                        Log(@"Ending update thread with result: " + state);
                        Log();
                        setCallbackStatus(state);
                    }
                    catch (ThreadAbortException)
                    {
                        setCallbackStatus(UpdateStates.NoUpdate);
                    }
                    catch (Exception e)
                    {
                        Log(@"Serious error occurred in update thread: " + e.ToString());
                        Log(@"Returning NoUpdate state to caller");
                        setCallbackStatus(UpdateStates.EmergencyFallback);
                    }

                    completeCallback = null;
                    updateThread     = null;
                });

                updateThread.IsBackground = true;
                updateThread.Priority     = priority;

                updateThread.Start();
            }
        }
예제 #9
0
 void FetchFiles()
 {
     if (DownloadTasks.Count > 0)
     {
         DownloadTask DT = DownloadTasks.Dequeue();
         TBProgress.Text = string.Format(UpdaterResources.DownloadingFile, FileNum, FileCount, DT.Name);
         WC.DownloadFileAsync(
             new Uri(DT.Source, UriKind.Absolute),
             DT.TempFile, DT);
     }
     else
     {
         UpdateState                = UpdateStates.InstallingUpdates;
         TBProgress.Text            = UpdaterResources.InstallingUpdate;
         PBProgress.IsIndeterminate = true;
         new Thread(InstallUpdate).Start();
     }
 }
예제 #10
0
        private static void setCallbackStatus(UpdateStates state)
        {
            if (State == state)
            {
                return;
            }

            Log(@"CallbackStatus updated to {0}", state.ToString());
            if (state == UpdateStates.Completed || state == UpdateStates.NoUpdate)
            {
                LogSuccess();
            }

            State = state;
            if (completeCallback != null)
            {
                completeCallback(state);
            }
        }
예제 #11
0
        internal void Save(ISerializableObject iso, ISerializerTransaction transaction)
        {
            AttributeWorker w = AttributeWorker.GetInstance(Target);

            if (!IsManaged(iso))
            {
//                Console.WriteLine("SERIALIZE");
                _objectPool.InsertObject(iso, _connection, transaction);

                ResolverData <ISerializableObject> rData = new ResolverData <ISerializableObject>();
                rData.HandledItem     = iso;
                rData.FieldsToResolve = AttributeWorker.RetrieveAllFields(iso.GetType());

                LoadHandler handler = new LoadHandler(this);
                RelationResolver <ISerializableObject> res = new RelationResolver <ISerializableObject>();
                res.Handler = handler;
                res.StartRelationResolving(rData);
            }
            else
            {
//                Console.WriteLine("UPDATE");
                UpdateStates state = _objectPool.UpdateObject(iso, _connection, transaction);

                if (state == UpdateStates.NO_ROWS_AFFECTED)
                {
                    throw new SerializerException("entry could not be updated ...");
                }
                else if (state == UpdateStates.PRIMARYKEY_MODIFIED)
                {
                    UpdateEventArgs args = new UpdateEventArgs(state);
                    OnUpdateEvent(args);
                }

                ResolverData <ISerializableObject> data = new ResolverData <ISerializableObject>();
                data.HandledItem     = iso;
                data.FieldsToResolve = AttributeWorker.RetrieveAllFields(iso.GetType());

                RelationResolver <ISerializableObject> res = new RelationResolver <ISerializableObject>();
                res.Handler = new UpdateHandler(this);
                res.StartRelationResolving(data);
            }
        }
예제 #12
0
 void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         ToErrorState();
         return;
     }
     switch (UpdateState)
     {
     case UpdateStates.Connecting:
         try
         {
             ProcessReleaseManifest(e.Result);
             TBProgress.Text = string.Format(UpdaterResources.UpdatingTo, UpdateName, DeployDate);
             UpdateState     = UpdateStates.ComparingFiles;
             Thread T = new Thread(BuildDownloadList);
             T.Start();
         }
         catch { ToErrorState(UpdaterResources.NoUpdatesFound); }
         break;
     }
 }
예제 #13
0
        private void UpdateTheClient(object sender, DoWorkEventArgs e)
        {
            Console.WriteLine("Getting updates list ...");
            ((BackgroundWorker)sender).ReportProgress(1, ("Getting update list from: "+ project_uri ));
            string updatesListRaw = DownloadUpdatesListRaw();

            if (updatesListRaw == null)
            {
                var res = MessageBox.Show("Unable to read the updates URL!",
                   "Error updating!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            foreach (var line in updatesListRaw.Split('\n'))
            {
                if (line.Trim().Length == 0)
                    continue;

                string[] fileInfoReceived = line.Trim().Split(',');
                Dictionary<string, string> remoteFileInfo =
                    new Dictionary<string, string>();

                remoteFileInfo.Add("filename", fileInfoReceived[0]);
                remoteFileInfo.Add("size", fileInfoReceived[1]);
                remoteFileInfo.Add("crc32b", fileInfoReceived[2]);
                remoteFileInfo.Add("sha256", fileInfoReceived[3]);
                remoteFileInfo.Add("local_filename", GetLocalFileName(remoteFileInfo["filename"]));                               

                ((BackgroundWorker)sender).ReportProgress(1, new string(("Checking " + Path.GetFileName(remoteFileInfo["local_filename"])).ToCharArray()));

                if (IsLocalFileNeedsUpdating(remoteFileInfo))
                {                    
                    Console.WriteLine("local file {0} needs to be updated", remoteFileInfo["filename"]);
                    update_state = UpdateStates.Downloading;
                    //
                    ((BackgroundWorker)sender).ReportProgress(1, remoteFileInfo);
                    while (update_state == UpdateStates.Downloading)
                    {
                        System.Threading.Thread.Sleep(150);
                        Console.WriteLine("Waiting for download to finish");
                    }

                    Console.WriteLine("Received {0}", remoteFileInfo["filename"]);
                    
                    if (File.Exists(remoteFileInfo["local_filename"]))
                    {
                        Console.WriteLine("Deleting the old file: {0}", remoteFileInfo["local_filename"]);
                        File.Delete(remoteFileInfo["local_filename"]);
                    }

                    var local_downloaded_filename = Path.Combine(getCfgValue("ultima_dir"), remoteFileInfo["filename"]);

                    Console.WriteLine("renaming {0} -> {1}", local_downloaded_filename + ".part", local_downloaded_filename);
                    File.Move(local_downloaded_filename + ".part", local_downloaded_filename);
                                        

                    if(isZip( remoteFileInfo["filename"] )) {
                        Console.WriteLine("Unzipping: {0}", local_downloaded_filename );
                        
                        unzipFile( local_downloaded_filename );
                        File.Delete( local_downloaded_filename );                                            
                    }            
          
                }                                             
            }                    
        }
예제 #14
0
        //Set the progress to be displayed in NovelListControl.
        public void SetUpdateProgress(int updatedItemCount = 0, int totalUpdateItemCount = 0, UpdateStates updateState = UpdateStates.Default)
        {
            int    progress = 0;
            string message  = "";

            if (totalUpdateItemCount > 0)
            {
                progress = (int)(100.0f * (float)updatedItemCount / (float)totalUpdateItemCount);
            }

            if (updateState == UpdateStates.Default)
            {
                switch (State)
                {
                case NovelState.Active:
                    updateState = UpdateStates.Waiting;
                    break;

                case NovelState.Completed:
                    updateState = UpdateStates.Completed;
                    break;

                case NovelState.Inactive:
                    updateState = UpdateStates.Inactive;
                    break;

                case NovelState.Dropped:
                    updateState = UpdateStates.Dropped;
                    break;
                }
            }

            switch (updateState)
            {
            case UpdateStates.Waiting:
                progress = 0;
                message  = "Waiting For Updates";
                break;

            case UpdateStates.Syncing:
                progress = 0;
                message  = "Syncing to origin";
                break;

            case UpdateStates.Checking:
                progress = 0;
                message  = "Checking For Updates";
                break;

            case UpdateStates.UpdateAvailable:
                progress = 0;
                if (updatedItemCount > 0)
                {
                    message = updatedItemCount + " Updates Available";
                }
                else
                {
                    message = "Novel Up To Date";
                }
                break;

            case UpdateStates.Fetching:
                message = "Fetching Updates: " + updatedItemCount + " / " + totalUpdateItemCount;
                break;

            case UpdateStates.UpToDate:
                if (State == NovelState.Active)
                {
                    message = "Novel Up To Date";
                }
                else if (State == NovelState.Completed)
                {
                    message = "Complted Novel Up To Date";
                }
                else if (State == NovelState.Inactive)
                {
                    message = "Inactive Novel Up To Date";
                }
                else if (State == NovelState.Dropped)
                {
                    message = "Dropped Novel Up To Date";
                }
                progress = 0;
                break;

            case UpdateStates.Completed:
                progress = 0;
                message  = "Novel Completed";
                break;

            case UpdateStates.Inactive:
                progress = 0;
                message  = "Novel Inactive";
                break;

            case UpdateStates.Dropped:
                progress = 0;
                message  = "Novel Dropped";
                break;

            case UpdateStates.Error:
                progress = 0;
                message  = "Network Error";
                break;
            }
            _updateState   = updateState;
            UpdateProgress = new Tuple <int, string>(progress, message);
        }
예제 #15
0
        /// <summary>
        /// State Machine
        /// Idle: Start from last known state. If none is known, ask user if they want to install, if yes goto remove scoped registry step
        /// WaitingOnExistingCheck:
        /// RemoveScopedRegistry: Remove the scoped registry entry if it exists
        /// WaitingForAdd: if the add request has been nulled or completed successfully, request a list of packages for confirmation
        /// WaitingForAddConfirmation: enumerate the packages and verify the add succeeded. If it failed, try again.
        ///                                 If it succeeded request removal of this script
        /// RemoveSelf: delete the key that we've been using to maintain state. Delete this script and the containing folder if it's empty.
        /// </summary>
        private static void Update()
        {
            switch (updateState)
            {
            case UpdateStates.Idle:
                if (EditorPrefs.HasKey(updaterKey))
                {
                    _updateState = (UpdateStates)EditorPrefs.GetInt(updaterKey);
                    packageTime.Start();
                }
                else
                {
                    RequestExisting();
                }
                break;

            case UpdateStates.WaitingOnExistingCheck:
                if (listRequest == null)
                {
                    //the list request got nulled for some reason. Request it again.
                    RequestExisting();
                }
                else if (listRequest != null && listRequest.IsCompleted)
                {
                    if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error while checking for an existing OpenVR package.", listRequest);
                    }
                    else
                    {
                        if (listRequest.Result.Any(package => package.name == valveOpenVRPackageString))
                        {
                            var existingPackage = listRequest.Result.FirstOrDefault(package => package.name == valveOpenVRPackageString);

                            string latestTarball = GetLatestTarballVersion();

                            if (latestTarball != null && latestTarball.CompareTo(existingPackage.version) == 1)
                            {
                                //we have a tarball higher than the currently installed version
                                string upgradeString = string.Format("This SteamVR Unity Plugin has a newer version of the Unity XR OpenVR package than you have installed. Would you like to upgrade?\n\nCurrent: {0}\nUpgrade: {1} (recommended)", existingPackage.version, latestTarball);
                                bool   upgrade       = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Updater", upgradeString, "Upgrade", "Cancel");
                                if (upgrade)
                                {
                                    RemoveScopedRegistry();
                                }
                                else
                                {
                                    bool delete = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Updater", "Would you like to remove this updater script so we don't ask again?", "Remove updater", "Keep");
                                    if (delete)
                                    {
                                        Stop();
                                        return;
                                    }
                                    else
                                    {
                                        GentleStop();
                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                                #if UNITY_2020_1_OR_NEWER
                            RemoveScopedRegistry();     //just install if we're on 2020 and they don't have the package
                            return;
                                #else
                            //they don't have the package yet. Ask if they want to install (only for 2019)
                            bool blankInstall = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Installer", "The SteamVR Unity Plugin can be used with the legacy Unity VR API (Unity 5.4 - 2019) or with the Unity XR API (2019+). Would you like to install OpenVR for Unity XR?", "Install", "Cancel");
                            if (blankInstall)
                            {
                                RemoveScopedRegistry();
                            }
                            else
                            {
                                bool delete = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Installer", "Would you like to remove this installer script so we don't ask again?", "Remove installer", "Keep");
                                if (delete)
                                {
                                    Stop();
                                    return;
                                }
                                else
                                {
                                    GentleStop();
                                    return;
                                }
                            }
                                #endif
                        }
                    }
                }
                break;

            case UpdateStates.WaitingForAdd:
                if (addRequest == null)
                {
                    //the add request got nulled for some reason. Request an add confirmation
                    RequestAddConfirmation();
                }
                else if (addRequest != null && addRequest.IsCompleted)
                {
                    if (addRequest.Error != null || addRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error adding new version of OpenVR package.", addRequest);
                    }
                    else
                    {
                        //verify that the package has been added (then stop)
                        RequestAddConfirmation();
                    }
                }
                else
                {
                    if (packageTime.Elapsed.TotalSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error while trying to add package.", addRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }
                break;

            case UpdateStates.WaitingForAddConfirmation:
                if (listRequest == null)
                {
                    //the list request got nulled for some reason. Request it again.
                    RequestAddConfirmation();
                }
                else if (listRequest != null && listRequest.IsCompleted)
                {
                    if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error while confirming the OpenVR package has been added.", listRequest);
                    }
                    else
                    {
                        if (listRequest.Result.Any(package => package.name == valveOpenVRPackageString))
                        {
                            updateState = UpdateStates.RemoveSelf;
                            UnityEditor.EditorUtility.DisplayDialog("OpenVR Unity XR Installer", "OpenVR Unity XR successfully installed.\n\nA restart of the Unity Editor may be necessary.", "Ok");
                        }
                        else
                        {
                            //try to add again if it's not there and we don't know why
                            RequestAdd();
                        }
                    }
                }
                else
                {
                    if (runningSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error while confirming the OpenVR package has been added.", listRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }
                break;

            case UpdateStates.RemoveSelf:
                EditorPrefs.DeleteKey(updaterKey);
                EditorUtility.ClearProgressBar();
                EditorApplication.update -= Update;

#if VALVE_SKIP_DELETE
                Debug.Log("[DEBUG] skipping script deletion. Complete.");
                return;
#endif

                var      script               = MonoScript.FromScriptableObject(OpenVRPackageInstaller.CreateInstance <OpenVRPackageInstaller>());
                var      path                 = AssetDatabase.GetAssetPath(script);
                FileInfo updaterScript        = new FileInfo(path); updaterScript.IsReadOnly = false;
                FileInfo updaterScriptMeta    = new FileInfo(path + ".meta");
                FileInfo simpleJSONScript     = new FileInfo(Path.Combine(updaterScript.Directory.FullName, "OpenVRSimpleJSON.cs"));
                FileInfo simpleJSONScriptMeta = new FileInfo(Path.Combine(updaterScript.Directory.FullName, "OpenVRSimpleJSON.cs.meta"));

                updaterScript.IsReadOnly        = false;
                updaterScriptMeta.IsReadOnly    = false;
                simpleJSONScript.IsReadOnly     = false;
                simpleJSONScriptMeta.IsReadOnly = false;

                updaterScriptMeta.Delete();
                if (updaterScriptMeta.Exists)
                {
                    DisplayErrorAndStop("Error while removing package installer script. Please delete manually.", listRequest);
                    return;
                }

                simpleJSONScript.Delete();
                simpleJSONScriptMeta.Delete();
                updaterScript.Delete();

                AssetDatabase.Refresh();
                break;
            }
        }
예제 #16
0
 public void Discard()
 {
     state          = UpdateStates.Nothing;
     updatedplugins = false;
 }
예제 #17
0
 internal void AddSimPeState(UpdateStates t)
 {
     state |= t;
 }
예제 #18
0
 void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     update_state = UpdateStates.FinishedDownloading;
     return;
 }
예제 #19
0
        internal static void SetUpdateState(UpdateStates state)
        {
            Scheduler.Add(delegate
            {
                if (state == UpdateState)
                {
                    return;
                }

                UpdateState = state;

                VoidDelegate d = UpdateStateChanged;
                if (d != null)
                {
                    d();
                }

                switch (UpdateState)
                {
                case UpdateStates.EmergencyFallback:
                    //let's hope we never need this.
                    OsuMain.Repair(true);
                    break;

                case UpdateStates.Completed:
                    ConfigManager.sUpdateFailCount.Value = 0;

                    //Update has completed and doesn't need a restart.
                    ConfigManager.sUpdatePending.Value = false;
                    ConfigManager.SaveConfig();

                    string lastVersion = ConfigManager.sLastVersion;

                    NotificationManager.ShowMessage(
                        string.Format(LocalisationManager.GetString(OsuString.Update_Complete), General.BUILD_NAME) + '\n' +
                        LocalisationManager.GetString(OsuString.GameBase_Updater_Changelog),
                        Color.Pink, 10000, delegate
                    {
                        if (string.IsNullOrEmpty(General.SUBVERSION))
                        {
                            //public releases
                            GameBase.ProcessStart(string.Format(@"https://osu.ppy.sh/p/changelog?v={0}&s={1}&l={2}",
                                                                General.BUILD_NAME, General.TargetedPublicStream.ToString().ToLower(), lastVersion));
                        }
                        else
                        {
                            //beta or cutting edge
                            GameBase.ProcessStart(@"https://osu.ppy.sh/p/changelog?v=next");
                        }
                    });
                    break;

                case UpdateStates.Error:
                    ConfigManager.sUpdatePending.Value = false;

                    if (CommonUpdater.LastError != null)
                    {
                        if (CommonUpdater.LastError is MissingFrameworkVersionException)
                        {
                            CommonUpdater.ResetError();
                            NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.GameBase_UpdateFailedFrameworkVersion), Color.Red, 300000, delegate { OsuMain.ForceUpdate(true); });
                        }
                        else
                        {
                            RunBackgroundThread(delegate
                            {
                                ErrorSubmission.Submit(new OsuError(CommonUpdater.LastError)
                                {
                                    Feedback = @"update error",
                                    ILTrace  = CommonUpdater.LastErrorExtraInformation ?? string.Empty
                                });

                                CommonUpdater.ResetError();
                            });
                        }
                    }

                    ConfigManager.ResetHashes();

                    ConfigManager.sUpdateFailCount.Value++;
                    break;

                case UpdateStates.NeedsRestart:

                    //the update could have already moved the files into their new place, so we want to make sure we have reloaded the master config file.
                    ConfigManager.ReloadHashCache();

                    ConfigManager.sUpdateFailCount.Value = 0;

                    bool isNewUpdate = !ConfigManager.sUpdatePending.Value;

                    ConfigManager.sUpdatePending.Value = true;

                    //Update completed but needs a restart. We either want to force a restart or just wait for the next user-triggered restart.
                    if (UpdateForceRestart)
                    {
                        CompleteUpdate();
                    }
                    else if (Mode != OsuModes.Menu && isNewUpdate)
                    {
                        NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.General_NewVersion), Color.Pink, 10000);
                    }

                    UpdatePendingRestart = true;
                    break;

                case UpdateStates.NoUpdate:
                    ConfigManager.sUpdateFailCount.Value = 0;
                    break;
                }
            });
        }
예제 #20
0
        /// <summary>
        /// State Machine
        /// Idle: Start from last known state. If none is known go to request a removal of the current openvr package
        /// WaitingForList: enumerate the packages to see if we have an existing package that needs to be removed. If so, request removal, if not, add scoped registry
        /// WaitingForRemove: if the remove request has been nulled or completed successfully, request a list of packages for confirmation
        /// WaitingForRemoveConfirmation: enumerate the packages and verify the removal succeeded. If it failed, try again.
        ///                                 If it succeeded, add the scoped registry.
        /// WaitingForScopedRegistry: search for available packages until the openvr package is available. Then add the package
        /// WaitingForAdd: if the add request has been nulled or completed successfully, request a list of packages for confirmation
        /// WaitingForAddConfirmation: enumerate the packages and verify the add succeeded. If it failed, try again.
        ///                                 If it succeeded request removal of this script
        /// RemoveSelf: delete the key that we've been using to maintain state. Delete this script and the containing folder if it's empty.
        /// </summary>
        private static void Update()
        {
            switch (updateState)
            {
            case UpdateStates.Idle:
                if (EditorPrefs.HasKey(updaterKey))
                {
                    _updateState = (UpdateStates)EditorPrefs.GetInt(updaterKey);
                    packageTime.Start();
                }
                else
                {
                    RequestList();
                    packageTime.Start();
                }
                break;

            case UpdateStates.WaitingForList:
                if (listRequest == null)
                {
                    //the list request got nulled for some reason. Request it again.
                    RequestList();
                }
                else if (listRequest != null && listRequest.IsCompleted)
                {
                    if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error while checking for an existing openvr package.", listRequest);
                    }
                    else
                    {
                        if (listRequest.Result.Any(package => package.name == valveOpenVRPackageString))
                        {
                            //if it's there then remove it in preparation for adding the scoped registry
                            RequestRemove(valveOpenVRPackageString);
                        }
                        else if (listRequest.Result.Any(package => package.name == valveOpenVRPackageStringOld))
                        {
                            //if it's there then remove it in preparation for adding the scoped registry
                            RequestRemove(valveOpenVRPackageStringOld);
                        }
                        else
                        {
                            AddScopedRegistry();
                        }
                    }
                }
                else
                {
                    if (runningSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error while confirming package removal.", listRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }
                break;

            case UpdateStates.WaitingForRemove:
                if (removeRequest == null)
                {
                    //if our remove request was nulled out we should check if the package has already been removed.
                    RequestRemoveConfirmation();
                }
                else if (removeRequest != null && removeRequest.IsCompleted)
                {
                    if (removeRequest.Error != null || removeRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error removing old version of OpenVR package.", removeRequest);
                    }
                    else
                    {
                        //verify that the package has been removed (then add)
                        RequestRemoveConfirmation();
                    }
                }
                else
                {
                    if (packageTime.Elapsed.TotalSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error removing old version of OpenVR package.", removeRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }
                break;

            case UpdateStates.WaitingForRemoveConfirmation:
                if (listRequest == null)
                {
                    //the list request got nulled for some reason. Request it again.
                    RequestRemoveConfirmation();
                }
                else if (listRequest != null && listRequest.IsCompleted)
                {
                    if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error while confirming package removal.", listRequest);
                    }
                    else
                    {
                        if (listRequest.Result.Any(package => package.name == valveOpenVRPackageString))
                        {
                            //try remove again if it didn't work and we don't know why.
                            RequestRemove(valveOpenVRPackageString);
                        }
                        else if (listRequest.Result.Any(package => package.name == valveOpenVRPackageStringOld))
                        {
                            //try remove again if it didn't work and we don't know why.
                            RequestRemove(valveOpenVRPackageStringOld);
                        }
                        else
                        {
                            AddScopedRegistry();
                        }
                    }
                }
                else
                {
                    if (runningSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error while confirming package removal.", listRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }
                break;

            case UpdateStates.WaitingForScopedRegistry:
                if (searchRequest == null)
                {
                    //the search request got nulled for some reason, request again
                    RequestScope();
                }
                else if (searchRequest != null && searchRequest.IsCompleted)
                {
                    if (searchRequest.Error != null || searchRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error adding Valve scoped registry to project.", searchRequest);
                    }

                    RequestAdd();
                }
                else
                {
                    if (packageTime.Elapsed.TotalSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error while trying to add scoped registry.", addRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }

                break;

            case UpdateStates.WaitingForAdd:
                if (addRequest == null)
                {
                    //the add request got nulled for some reason. Request an add confirmation
                    RequestAddConfirmation();
                }
                else if (addRequest != null && addRequest.IsCompleted)
                {
                    if (addRequest.Error != null || addRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error adding new version of OpenVR package.", addRequest);
                    }
                    else
                    {
                        //verify that the package has been added (then stop)
                        RequestAddConfirmation();
                    }
                }
                else
                {
                    if (packageTime.Elapsed.TotalSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error while trying to add package.", addRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }
                break;

            case UpdateStates.WaitingForAddConfirmation:
                if (listRequest == null)
                {
                    //the list request got nulled for some reason. Request it again.
                    RequestAddConfirmation();
                }
                else if (listRequest != null && listRequest.IsCompleted)
                {
                    if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
                    {
                        DisplayErrorAndStop("Error while confirming the OpenVR package has been added.", listRequest);
                    }
                    else
                    {
                        if (listRequest.Result.Any(package => package.name == valveOpenVRPackageString))
                        {
                            updateState = UpdateStates.RemoveSelf;
                            UnityEditor.EditorUtility.DisplayDialog("OpenVR", "OpenVR Unity XR successfully updated.", "Ok");
                        }
                        else
                        {
                            //try to add again if it's not there and we don't know why
                            RequestAdd();
                        }
                    }
                }
                else
                {
                    if (runningSeconds > estimatedTimeToInstall)
                    {
                        DisplayErrorAndStop("Error while confirming the OpenVR package has been added.", listRequest);
                    }
                    else
                    {
                        DisplayProgressBar();
                    }
                }
                break;

            case UpdateStates.RemoveSelf:
                EditorPrefs.DeleteKey(updaterKey);
                EditorUtility.ClearProgressBar();
                EditorApplication.update -= Update;

#if VALVE_SKIP_DELETE
                Debug.Log("[DEBUG] skipping script deletion. Complete.");
                return;
#endif

                var      script               = MonoScript.FromScriptableObject(OpenVRAutoUpdater.CreateInstance <OpenVRAutoUpdater>());
                var      path                 = AssetDatabase.GetAssetPath(script);
                FileInfo updaterScript        = new FileInfo(path);
                FileInfo updaterScriptMeta    = new FileInfo(path + ".meta");
                FileInfo simpleJSONScript     = new FileInfo(Path.Combine(updaterScript.Directory.FullName, "OpenVRSimpleJSON.cs"));
                FileInfo simpleJSONScriptMeta = new FileInfo(Path.Combine(updaterScript.Directory.FullName, "OpenVRSimpleJSON.cs.meta"));

                updaterScript.Delete();
                updaterScriptMeta.Delete();
                simpleJSONScript.Delete();
                simpleJSONScriptMeta.Delete();
                if (updaterScript.Directory.GetFiles().Length == 0 && updaterScript.Directory.GetDirectories().Length == 0)
                {
                    path = updaterScript.Directory.FullName + ".meta";
                    updaterScript.Directory.Delete();
                    File.Delete(path);
                }

                AssetDatabase.Refresh();
                break;
            }
        }
예제 #21
0
 internal UpdateEventArgs(UpdateStates state)
 {
     _updateState = state;
 }
예제 #22
0
        internal virtual String SerializeUpdate(ISerializableObject iso, ref UpdateStates state, GenericWeakReference <ISerializableObject> tmp)
        {
            AttributeWorker w   = AttributeWorker.GetInstance(Target);
            StringBuilder   sql = new StringBuilder();

            StringBuilder where = new StringBuilder();

            Guid      g = AttributeWorker.RowGuid(iso);
            FieldInfo f = AttributeWorker.RowGuid(iso.GetType());

            sql.Append("UPDATE ").Append(w.GetTableMapping(iso.GetType(), _praefix));
            sql.Append(" SET ");
            where.Append(" WHERE ").Append(AttributeWorker.GetInstance(Target).GetColumnMapping(f));
            where.Append("='").Append(g).Append("'");;

            FieldInfo[] fis = AttributeWorker.RetrieveAllFields(iso.GetType());



            bool start = true;

            foreach (FieldInfo fi in fis)
            {
                try
                {
                    String col = w.GetColumnMapping(fi);
                    Object val = fi.GetValue(iso);
                    Object oldVal;


                    if (w.IsAutoincID(fi))
                    {
                        continue;
                    }
                    if (AttributeWorker.IsRowGuid(fi))
                    {
                        continue;
                    }

                    if (w.IsID(fi))
                    {
                        oldVal = tmp.Properties[fi.Name];
                        if (!Object.Equals(val, oldVal))
                        {
                            state = UpdateStates.PRIMARYKEY_MODIFIED;
                        }
                        tmp.Properties[fi.Name] = val;
                    }

                    if (!start)
                    {
                        sql.Append(", ");
                    }
                    else
                    {
                        start = false;
                    }

                    sql.Append(col).Append("=").Append(SqlUtil.SqlConvert(val));
                }
                catch (SerializerException) { }
            }

            sql.Append(where);
            return(sql.ToString());
        }
예제 #23
0
        private void UpdateTheClientCompleted(
            object sender, RunWorkerCompletedEventArgs e)
        {
            update_state = UpdateStates.Ready;
            btnUpdate.Enabled = true;

            RunClientApplication();

            if(getCfgValueInt("closeWhenFinished")==1) {
                Application.Exit();
            }
        }
예제 #24
0
 void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     update_state = UpdateStates.FinishedDownloading;
     return;           
 }
예제 #25
0
 internal UpdateState(UpdateStates t)
 {
     state          = t;
     list           = new UpdateInfoList();
     updatedplugins = false;
 }
예제 #26
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {

            if (workInBackground.IsBusy && update_state != UpdateStates.Ready)
                return;          

            btnUpdate.Enabled = false;
            update_state = UpdateStates.Updating;

            workInBackground.RunWorkerAsync();

            return;

            /*
            if (update_state == UpdateStates.Ready || update_state == UpdateStates.Failed)
            {
                //System.Threading.Thread.Sleep(5000);
                updateInBackground.RunWorkerAsync();                
            }
             */

            /*
            if (update_state == UpdateStates.Ready || update_state == UpdateStates.Failed)
            {
                update_state = UpdateStates.Updating;
                ((Button)sender).Text = "Checking updates..";
                ((Button)sender).Enabled = false;

                lblStatus.Text = "Contacting Updates Site ..";

                updateInBackground.DoWork += updateInBackground_DoWork;

                var res = checkUpdates();
                if (res == true)
                {
                    lblStatus.Text = "All done...";                    
                    ((Button)sender).Text = "Play "+getCfgValue("shardname", "UO");
                    update_state = UpdateStates.Success;
                    if (getCfgValueInt("closeWhenFinished") == 1)
                    {
                        RunClientApplication();
                        Application.Exit();
                    }
                }
                else
                {
                    update_state = UpdateStates.Failed;
                    ((Button)sender).Text = "Check Updates ..";
                }
                ((Button)sender).Enabled = true;
            } else
                if (update_state == UpdateStates.Success)
                {
                    RunClientApplication();
                    Application.Exit();
                }
             * 
             */
        }
예제 #27
0
        private void UpdateTheClient(object sender, DoWorkEventArgs e)
        {
            Console.WriteLine("Getting updates list ...");
            ((BackgroundWorker)sender).ReportProgress(1, ("Getting update list from: " + project_uri));
            string updatesListRaw = DownloadUpdatesListRaw();

            if (updatesListRaw == null)
            {
                var res = MessageBox.Show("Unable to read the updates URL!",
                                          "Error updating!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            foreach (var line in updatesListRaw.Split('\n'))
            {
                if (line.Trim().Length == 0)
                {
                    continue;
                }

                string[] fileInfoReceived = line.Trim().Split(',');
                Dictionary <string, string> remoteFileInfo =
                    new Dictionary <string, string>();

                remoteFileInfo.Add("filename", fileInfoReceived[0]);
                remoteFileInfo.Add("size", fileInfoReceived[1]);
                remoteFileInfo.Add("crc32b", fileInfoReceived[2]);
                remoteFileInfo.Add("sha256", fileInfoReceived[3]);
                remoteFileInfo.Add("local_filename", GetLocalFileName(remoteFileInfo["filename"]));

                ((BackgroundWorker)sender).ReportProgress(1, new string(("Checking " + Path.GetFileName(remoteFileInfo["local_filename"])).ToCharArray()));

                if (IsLocalFileNeedsUpdating(remoteFileInfo))
                {
                    Console.WriteLine("local file {0} needs to be updated", remoteFileInfo["filename"]);
                    update_state = UpdateStates.Downloading;
                    //
                    ((BackgroundWorker)sender).ReportProgress(1, remoteFileInfo);
                    while (update_state == UpdateStates.Downloading)
                    {
                        System.Threading.Thread.Sleep(150);
                        Console.WriteLine("Waiting for download to finish");
                    }

                    Console.WriteLine("Received {0}", remoteFileInfo["filename"]);

                    if (File.Exists(remoteFileInfo["local_filename"]))
                    {
                        Console.WriteLine("Deleting the old file: {0}", remoteFileInfo["local_filename"]);
                        File.Delete(remoteFileInfo["local_filename"]);
                    }

                    var local_downloaded_filename = Path.Combine(getCfgValue("ultima_dir"), remoteFileInfo["filename"]);

                    Console.WriteLine("renaming {0} -> {1}", local_downloaded_filename + ".part", local_downloaded_filename);
                    File.Move(local_downloaded_filename + ".part", local_downloaded_filename);


                    if (isZip(remoteFileInfo["filename"]))
                    {
                        Console.WriteLine("Unzipping: {0}", local_downloaded_filename);

                        unzipFile(local_downloaded_filename);
                        File.Delete(local_downloaded_filename);
                    }
                }
            }
        }