예제 #1
0
        private async void btnDeleteCurrent_Click(object sender, EventArgs e)
        {
            string currentLockscreen = Config.CurrentLockscreen;

            List <Uri> images = await new BaseStorageHelper().GetImageList();

            List <Uri> otherimages = images.FindAll(i => String.Compare(Path.GetFileName(i.AbsoluteUri), currentLockscreen, StringComparison.OrdinalIgnoreCase) != 0);

            await ScheduledAgent.LockScreenChange(otherimages);

            if (!String.IsNullOrWhiteSpace(currentLockscreen))
            {
                try
                {
                    IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();

                    string folder = "Shared\\ShellContent";

                    string fileToDelete = String.Format("{0}\\{1}", folder, currentLockscreen);

                    isf.DeleteFile(fileToDelete);
                }
                catch { }
            }
        }
예제 #2
0
        public void onTransferFinish(MegaSDK api, MTransfer transfer, MError e)
        {
            if (_timer != null)
            {
                _timer.Dispose();
            }

            if (e.getErrorCode() == MErrorType.API_EGOINGOVERQUOTA || e.getErrorCode() == MErrorType.API_EOVERQUOTA)
            {
                //Stop the Camera Upload Service
                LogService.Log(MLogLevel.LOG_LEVEL_INFO,
                               "Storage quota exceeded ({0}) - Disabling CAMERA UPLOADS service", e.getErrorCode().ToString());
                OnStorageQuotaExceeded(EventArgs.Empty);
                return;
            }

            try
            {
                if (e.getErrorCode() == MErrorType.API_OK)
                {
                    ulong    mtime       = api.getNodeByHandle(transfer.getNodeHandle()).getModificationTime();
                    DateTime pictureDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(mtime));
                    SettingsService.SaveSettingToFile <DateTime>("LastUploadDate", pictureDate);

                    // If file upload succeeded. Clear the error information for a clean sheet.
                    ErrorProcessingService.Clear();
                }
                else
                {
                    // An error occured. Log and process it.
                    switch (e.getErrorCode())
                    {
                    case MErrorType.API_EFAILED:
                    case MErrorType.API_EEXIST:
                    case MErrorType.API_EARGS:
                    case MErrorType.API_EREAD:
                    case MErrorType.API_EWRITE:
                    {
                        LogService.Log(MLogLevel.LOG_LEVEL_ERROR, e.getErrorString());
                        ErrorProcessingService.ProcessFileError(transfer.getFileName());
                        break;
                    }
                    }
                }
            }
            catch (Exception)
            {
                // Setting could not be saved. Just continue the run
            }
            finally
            {
                // Start a new upload action
                ScheduledAgent.Upload();
            }
        }
예제 #3
0
 public void onNodesUpdate(MegaSDK api, MNodeList nodes)
 {
     // If the SDK has resumed the possible pending transfers
     if (nodes == null)
     {
         // If no pending transfers to resume start a new upload
         // Else it will start when finish the current transfer
         if (api.getTransferData().getNumUploads() == 0)
         {
             ScheduledAgent.Upload();
         }
     }
 }
예제 #4
0
        /// <summary>
        /// Create a MegaSDK instance
        /// </summary>
        /// <returns>The new MegaSDK instance</returns>
        private static MegaSDK CreateSdk()
        {
            String folderCameraUploadService = Path.Combine(ApplicationData.Current.LocalFolder.Path, "CameraUploadService");

            if (!Directory.Exists(folderCameraUploadService))
            {
                Directory.CreateDirectory(folderCameraUploadService);
            }

            return(new MegaSDK(
                       "Z5dGhQhL",
                       String.Format("{0}/{1}/{2}",
                                     ScheduledAgent.GetBackgroundAgentUserAgent(),
                                     DeviceStatus.DeviceManufacturer,
                                     DeviceStatus.DeviceName),
                       folderCameraUploadService,
                       new MegaRandomNumberProvider()));
        }
예제 #5
0
        void RefreshBusTime()
        {
            prgbarWaiting.Visibility = Visibility.Visible;
            foreach (var btn in this.ApplicationBar.Buttons)
            {
                (btn as ApplicationBarIconButton).IsEnabled = false;
            }
            this.ApplicationBar.IsMenuEnabled = false;

            var busTags = DataService.BusTags;

            ScheduledAgent.RefreshBusTime(DataService.BusTags);
            foreach (var btn in this.ApplicationBar.Buttons)
            {
                (btn as ApplicationBarIconButton).IsEnabled = true;
            }
            this.ApplicationBar.IsMenuEnabled = true;
            prgbarWaiting.Visibility          = Visibility.Collapsed;
        }
예제 #6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            agentMessage.Text = ((App)Application.Current).AgentStatus;

            ScheduledAgent.UpdateDefaultTile();

            List <ScheduledAction> items = new List <ScheduledAction>();

            var notifications = ScheduledActionService
                                .GetActions <ScheduledNotification>()
                                .OrderBy((item) => item.BeginTime);

            foreach (ScheduledNotification notification in notifications)
            {
                ScheduledAction item = ScheduledActionService.Find(notification.Name);
                items.Add(item);
            }
            notificationList.ItemsSource = items;
        }
        async void miLockscreen_Click(object sender, RoutedEventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi != null)
            {
                ContextMenu cm = mi.Parent as ContextMenu;

                FilmInfo fi = (FilmInfo)cm.Tag;

                if (Config.AnimateLockscreen && !LockScreenManager.IsProvidedByCurrentApplication)
                {
                    // If you're not the provider, this call will prompt the user for permission.
                    // Calling RequestAccessAsync from a background agent is not allowed.
                    await LockScreenManager.RequestAccessAsync();
                }

                Config.AnimateLockscreen = LockScreenManager.IsProvidedByCurrentApplication;

                await ScheduledAgent.SetPoster(fi.MediumPosterUrl);
            }
        }
예제 #8
0
        /// <summary>
        /// Create a MegaSDK instance
        /// </summary>
        /// <returns>The new MegaSDK instance</returns>
        private static MegaSDK CreateSdk()
        {
            String folderCameraUploadService = Path.Combine(ApplicationData.Current.LocalFolder.Path, "CameraUploadService");

            if (!Directory.Exists(folderCameraUploadService))
            {
                Directory.CreateDirectory(folderCameraUploadService);
            }

            // Initialize a MegaSDK instance
            var newMegaSDK = new MegaSDK(
                "Z5dGhQhL",
                String.Format("{0}/{1}/{2}",
                              ScheduledAgent.GetBackgroundAgentUserAgent(),
                              DeviceStatus.DeviceManufacturer,
                              DeviceStatus.DeviceName),
                folderCameraUploadService,
                new MegaRandomNumberProvider());

            // Use custom DNS servers in the new SDK instance
            SetDnsServers(newMegaSDK, false);

            return(newMegaSDK);
        }