/// <summary> /// Change the API URL. /// </summary> private static async void ChangeApiUrl() { StopChangeApiUrlTimer(); var usingStagingServer = SettingsService.LoadSetting <bool>(SettingsResources.UseStagingServer, false) || SettingsService.LoadSetting <bool>(SettingsResources.UseStagingServerPort444, false); if (!usingStagingServer) { var result = await DialogService.ShowChangeToStagingServerDialog(); if (!result) { return; } } else { SettingsService.SaveSetting <bool>(SettingsResources.UseStagingServer, false); SettingsService.SaveSetting <bool>(SettingsResources.UseStagingServerPort444, false); MegaSdk.changeApiUrl(AppResources.AR_ApiUrl); MegaSdkFolderLinks.changeApiUrl(AppResources.AR_ApiUrl); } // If the user is logged in, do a new login with the current session if (Convert.ToBoolean(MegaSdk.isLoggedIn())) { bool fastLoginResult; try { var fastLogin = new FastLoginRequestListenerAsync(); fastLoginResult = await fastLogin.ExecuteAsync(() => MegaSdk.fastLogin(SettingsService.LoadSetting <string>(SettingsResources.UserMegaSession), fastLogin)); } // Do nothing, app is already logging out catch (BadSessionIdException) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Login failed. Bad session ID."); return; } if (fastLoginResult) { // Fetch nodes from MEGA var fetchNodes = new FetchNodesRequestListenerAsync(); var fetchNodesResult = await fetchNodes.ExecuteAsync(() => MegaSdk.fetchNodes(fetchNodes)); if (fetchNodesResult != FetchNodesResult.Success) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Fetch nodes failed."); new CustomMessageDialog(AppMessages.FetchingNodesFailed_Title, AppMessages.FetchingNodesFailed, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); } } else { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Resume session failed."); new CustomMessageDialog(UiResources.UI_ResumeSession, AppMessages.AM_ResumeSessionFailed, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); } } // Reset the "Camera Uploads" service if is enabled if (MediaService.GetAutoCameraUploadStatus()) { LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Resetting CAMERA UPLOADS service (API URL changed)"); SettingsService.SaveSetting(SettingsResources.CameraUploadsIsEnabled, MediaService.SetAutoCameraUpload(true)); } LogService.Log(MLogLevel.LOG_LEVEL_INFO, "API URL changed"); new CustomMessageDialog(null, "API URL changed", App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); OnApiUrlChanged(); }
public static void SaveAppInformation() { SettingsService.SaveSetting(SettingsResources.LastAppVersion, AppService.GetAppVersion()); }
public static void SaveMegaLoginData(string email, string session) { SettingsService.SaveSetting(SettingsResources.RememberMe, true); SettingsService.SaveSetting(SettingsResources.UserMegaEmailAddress, email); SettingsService.SaveSetting(SettingsResources.UserMegaSession, session); }