Example #1
0
        /// <summary>
        /// Save the unique receipt id to local user settings
        /// </summary>
        /// <param name="receipt">Windows Store receipt xml</param>
        /// <returns>True if save succeeded, else False</returns>
        private static bool SaveUniqueReceiptId(string receipt)
        {
            try
            {
                LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Saving receipt ID...");

                var key        = ResourceService.SettingsResources.GetString("SR_Receipts");
                var currentIds = SettingsService.Load(key, string.Empty);
                var id         = GetUniqueReceiptId(receipt);

                if (id == null)
                {
                    return(false);
                }

                currentIds += id + ";";
                SettingsService.Save(key, currentIds);

                return(true);
            }
            catch (Exception e)
            {
                LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Failed to save receipt ID", e);
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// Change the API URL.
        /// </summary>
        private static async void ChangeApiUrl()
        {
            StopChangeApiUrlTimer();

            var useStagingServer = SettingsService.Load(ResourceService.SettingsResources.GetString("SR_UseStagingServer"), false) ||
                                   SettingsService.Load(ResourceService.SettingsResources.GetString("SR_UseStagingServerPort444"), false);

            if (!useStagingServer)
            {
                var result = await DialogService.ShowChangeToStagingServerDialog();

                if (!result)
                {
                    return;
                }
            }
            else
            {
                SettingsService.Save(ResourceService.SettingsResources.GetString("SR_UseStagingServer"), false);
                SettingsService.Save(ResourceService.SettingsResources.GetString("SR_UseStagingServerPort444"), false);
                MegaSdk.changeApiUrl(ResourceService.AppResources.GetString("AR_ApiUrl"));
                MegaSdkFolderLinks.changeApiUrl(ResourceService.AppResources.GetString("AR_ApiUrl"));
            }

            // Reset the "Camera Uploads" service if is enabled
            if (TaskService.IsBackGroundTaskActive(CameraUploadService.TaskEntryPoint, CameraUploadService.TaskName))
            {
                LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Resetting CAMERA UPLOADS service (API URL changed)");
                await TaskService.RegisterBackgroundTaskAsync(
                    CameraUploadService.TaskEntryPoint, CameraUploadService.TaskName,
                    new TimeTrigger(CameraUploadService.TaskTimeTrigger, false));
            }

            OnApiUrlChanged();
        }
Example #3
0
        /// <summary>
        /// Clear settings values we do no longer use.
        /// </summary>
        public static void ClearObsoleteSettings()
        {
            // If is the first run of the app, remove a possible session of a previous installation
            if (SettingsService.Load(ResourceService.SettingsResources.GetString("SR_AppFirstRun"), true))
            {
                SettingsService.RemoveSessionFromLocker();
                SettingsService.Save(ResourceService.SettingsResources.GetString("SR_AppFirstRun"), false);
            }

            var lastAppVersion = SettingsService.Load <string>(
                ResourceService.SettingsResources.GetString("SR_LastAppVersion"), null);

            if (lastAppVersion == null)
            {
                return;
            }
        }
Example #4
0
        /// <summary>
        /// Change the API URL.
        /// </summary>
        private static async void ChangeApiUrl()
        {
            StopChangeApiUrlTimer();

            var useStagingServer = SettingsService.Load(ResourceService.SettingsResources.GetString("SR_UseStagingServer"), false);

            if (!useStagingServer)
            {
                var result = await DialogService.ShowOkCancelAsync("Change to a testing server?",
                                                                   "Are you sure you want to change to a testing server? Your account may run irrecoverable problems.");

                if (!result)
                {
                    return;
                }
            }

            useStagingServer = !useStagingServer;

            var newApiUrl = useStagingServer ?
                            ResourceService.AppResources.GetString("AR_StagingUrl") :
                            ResourceService.AppResources.GetString("AR_ApiUrl");

            MegaSdk.changeApiUrl(newApiUrl);
            MegaSdkFolderLinks.changeApiUrl(newApiUrl);

            SettingsService.Save(ResourceService.SettingsResources.GetString("SR_UseStagingServer"), useStagingServer);

            // Reset the "Camera Uploads" service if is enabled
            if (TaskService.IsBackGroundTaskActive(CameraUploadService.TaskEntryPoint, CameraUploadService.TaskName))
            {
                LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Resetting CAMERA UPLOADS service (API URL changed)");
                await TaskService.RegisterBackgroundTaskAsync(
                    CameraUploadService.TaskEntryPoint, CameraUploadService.TaskName,
                    new TimeTrigger(CameraUploadService.TaskTimeTrigger, false));
            }

            OnApiUrlChanged();
        }
Example #5
0
 /// <summary>
 /// Save the app information for future use (like deleting settings).
 /// </summary>
 public static void SaveAppInformation()
 {
     SettingsService.Save(ResourceService.SettingsResources.GetString("SR_LastAppVersion"), GetAppVersion());
 }