internal void UpdateVersionIfAvailable(UpdateCheckSettings updateCheckSettings) { //TODO manual mode and no network => show message if (CheckWithUpdateFrequency(updateCheckSettings.UpdateCheckFrequency) && NetworkInterface.GetIsNetworkAvailable()) { var task = HockeyClient.Current.AsInternal().GetAppVersionsAsync(); task.ContinueWith((finishedTask) => { if (finishedTask.Exception == null) { var appVersions = finishedTask.Result; var newestAvailableAppVersion = appVersions.FirstOrDefault(); var currentVersion = new Version(ManifestHelper.GetAppVersion()); if (appVersions.Any() && new Version(newestAvailableAppVersion.Version) > currentVersion && (updateCheckSettings.CustomDoShowUpdateFunc == null || updateCheckSettings.CustomDoShowUpdateFunc(newestAvailableAppVersion))) { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp) || (updateCheckSettings.EnforceUpdateIfMandatory && newestAvailableAppVersion.Mandatory)) { ShowVersionPopup(currentVersion, appVersions, updateCheckSettings); } else { ShowUpdateNotification(currentVersion, appVersions, updateCheckSettings); } } else { if (updateCheckSettings.UpdateMode.Equals(UpdateMode.InApp)) { Scheduler.Dispatcher.Schedule(() => MessageBox.Show(LocalizedStrings.LocalizedResources.NoUpdateAvailable)); } } } else { HockeyClient.Current.AsInternal().HandleInternalUnhandledException(finishedTask.Exception); } }); } }
internal void AuthenticateUser(Uri successRedirect, AuthenticationMode authMode = AuthenticationMode.Authorize, TokenValidationPolicy tokenValidationPolicy = TokenValidationPolicy.EveryLogin, AuthValidationMode authValidationMode = AuthValidationMode.Graceful, string email = null, string appSecret = null) { if (AuthenticationMode.Identify.Equals(authMode) && String.IsNullOrEmpty(appSecret)) { throw new ApplicationException(LocalizedStrings.LocalizedResources.Authentication_AppSecretMissing); } this.SuccessRedirect = successRedirect; bool needsLogin = TokenValidationPolicy.EveryLogin.Equals(tokenValidationPolicy); if (!needsLogin && TokenValidationPolicy.OnNewVersion.Equals(tokenValidationPolicy)) { string lastAuthorizedVersion = IsolatedStorageSettings.ApplicationSettings.GetValue(Constants.AuthLastAuthorizedVersionKey) as String; needsLogin = (lastAuthorizedVersion == null) || (new Version(lastAuthorizedVersion) < new Version(ManifestHelper.GetAppVersion())); } if (needsLogin) { ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(new Uri("/" + WebBrowserHelper.AssemblyNameWithoutExtension + ";component/Views/LoginPage.xaml?authmode=" + HttpUtility.UrlEncode(authMode.ToString()) + "&appsecret=" + HttpUtility.UrlEncode(appSecret) + "&email=" + HttpUtility.UrlEncode(email ?? "") + "&validationmode=" + HttpUtility.UrlEncode(authValidationMode.ToString() ?? ""), UriKind.Relative)); } else { ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(successRedirect); } }