public void CreateSyncContentStream(ISyncPartnership partnership, SyncStartType type, SyncStoppedReason reason, TimeSpan syncDuration) { if ((partnership != null) && this.isSqmEnabled) { SqmSyncContentStream stream = new SqmSyncContentStream(); SetSyncType(partnership, type, stream); if (partnership.Device != null) { string winMoDeviceId = partnership.Device.WinMoDeviceId; long? nullable = (long?)DeviceSettings.Get(winMoDeviceId, "SyncCount"); uint num = 0; if (nullable.HasValue) { num = (uint)nullable.Value; } stream.SyncIndex = ++num; DeviceSettings.Set(winMoDeviceId, "SyncCount", num); } ISyncRules ruleManager = partnership.RuleManager; SetGlobalRules(stream, ruleManager); CalculateMusicSyncSelections(partnership.MusicAndMovieProvider, partnership.RuleManager, stream); this.CalculatePhotoSyncSelections(partnership.PhotoAndVideoProvider, partnership.RuleManager, stream); CalculateSyncResults(partnership, stream); stream.OperationTime = (uint)syncDuration.TotalMilliseconds; SetSyncResult(reason, stream); this.sqmManager.SetStream(stream); } }
private static void SetGlobalRules(SqmSyncContentStream stream, ISyncRules rules) { stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.MusicEnabled, rules.IsMusicSyncEnabled); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.AllMusic, rules.SyncAllMusic); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PhotosEnabled, rules.IsPhotoVideoSyncEnabled); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.AllPhotos, rules.SyncAllPhotosVideos); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.IncludeVideos, rules.SyncIncludeVideos); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.VideosEnabled, rules.IsTVMoviesSyncEnabled); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.AllVideos, rules.SyncAllTvMovies); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastsEnabled, rules.IsPodcastSyncEnabled); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSyncAll, rules.SyncAllPodcasts); stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.MusicEnabled, rules.IsMusicSyncEnabled); switch (rules.PodcastSyncCount) { case 1: if (!rules.SyncUnplayedPodcastsOnly) { stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSync1MostRecent, true); return; } stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSync1Unplayed, true); return; case 3: if (!rules.SyncUnplayedPodcastsOnly) { stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSync3MostRecent, true); return; } stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSync3Unplayed, true); return; case 5: if (!rules.SyncUnplayedPodcastsOnly) { stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSync5MostRecent, true); return; } stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSync5Unplayed, true); return; } if (rules.SyncUnplayedPodcastsOnly) { stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSyncAllUnplayed, true); } else { stream.MarkGlobalSyncOption(SqmGlobalSyncOptions.PodcastSyncAll, true); } }
private void CalculatePhotoSyncSelections(IPictureSyncSource source, ISyncRules rules, SqmSyncContentStream stream) { uint num = 0; uint num2 = 0; if (rules.IsPhotoVideoSyncEnabled) { int num3; if (rules.SyncAllPhotosVideos) { num = (uint)source.PhotoVideoAlbums.Options.Count <ISyncSelectionOption>(); } else { num = (uint)this.CountTreeItemsFullySelected(source.PhotoVideoAlbums); } num2 = (uint)this.CountTreeItemsSelected(source.PhotoVideoAlbums, out num3); } stream.PhotoTreeSelectedCount = num; stream.PhotoFolderSelectedCount = num2; }
private void CalculatePhotoSyncSelections(IPictureSyncSource source, ISyncRules rules, SqmSyncContentStream stream) { uint num = 0; uint num2 = 0; if (rules.IsPhotoVideoSyncEnabled) { int num3; if (rules.SyncAllPhotosVideos) { num = (uint) source.PhotoVideoAlbums.Options.Count<ISyncSelectionOption>(); } else { num = (uint) this.CountTreeItemsFullySelected(source.PhotoVideoAlbums); } num2 = (uint) this.CountTreeItemsSelected(source.PhotoVideoAlbums, out num3); } stream.PhotoTreeSelectedCount = num; stream.PhotoFolderSelectedCount = num2; }
private static void CalculateMusicSyncSelections(IMusicSyncSource source, ISyncRules rules, SqmSyncContentStream stream) { uint num = 0; uint num2 = 0; uint num3 = 0; uint num4 = 0; uint num5 = 0; uint num6 = 0; if (rules.IsMusicSyncEnabled) { if (rules.SyncAllMusic) { num = (uint) source.Playlists.Options.Count<ISyncSelectionOption>(); num2 = (uint) source.Genres.Options.Count<ISyncSelectionOption>(); num3 = (uint) source.Artists.Options.Count<ISyncSelectionOption>(); num4 = 0; } else { num = (uint) source.Playlists.Options.Where<ISyncSelectionOption>(delegate (ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return o.IsSelectedForSync.Value; } return false; }).Count<ISyncSelectionOption>(); num2 = (uint) source.Genres.Options.Where<ISyncSelectionOption>(delegate (ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return o.IsSelectedForSync.Value; } return false; }).Count<ISyncSelectionOption>(); num3 = (uint) source.Artists.Options.Where<ISyncSelectionOption>(delegate (ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return o.IsSelectedForSync.Value; } return false; }).Count<ISyncSelectionOption>(); num4 = (uint) (from o in source.Artists.Options where !o.IsSelectedForSync.HasValue select o).Count<ISyncSelectionOption>(); } } if (rules.IsTVMoviesSyncEnabled) { if (rules.SyncAllTvMovies) { num5 = (uint) source.MoviesTVShows.Options.Count<ISyncSelectionOption>(); } else { num5 = (uint) source.MoviesTVShows.Options.Where<ISyncSelectionOption>(delegate (ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return o.IsSelectedForSync.Value; } return false; }).Count<ISyncSelectionOption>(); } } if (rules.IsPodcastSyncEnabled) { if (rules.SyncAllPodcasts) { num6 = (uint) source.Podcasts.Options.Count<ISyncSelectionOption>(); } else { num6 = (uint) source.Podcasts.Options.Where<ISyncSelectionOption>(delegate (ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return o.IsSelectedForSync.Value; } return false; }).Count<ISyncSelectionOption>(); } } stream.PlaylistFileSelectedCount = num; stream.GenreFileSelectedCount = num2; stream.ArtistFileSelectedCount = num3; stream.MusicAlbumFileSelectedCount = num4; stream.MovieFileSelectedCount = num5; stream.PodcastSeriesSelectedCount = num6; }
private static void CalculateMusicSyncSelections(IMusicSyncSource source, ISyncRules rules, SqmSyncContentStream stream) { uint num = 0; uint num2 = 0; uint num3 = 0; uint num4 = 0; uint num5 = 0; uint num6 = 0; if (rules.IsMusicSyncEnabled) { if (rules.SyncAllMusic) { num = (uint)source.Playlists.Options.Count <ISyncSelectionOption>(); num2 = (uint)source.Genres.Options.Count <ISyncSelectionOption>(); num3 = (uint)source.Artists.Options.Count <ISyncSelectionOption>(); num4 = 0; } else { num = (uint)source.Playlists.Options.Where <ISyncSelectionOption>(delegate(ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return(o.IsSelectedForSync.Value); } return(false); }).Count <ISyncSelectionOption>(); num2 = (uint)source.Genres.Options.Where <ISyncSelectionOption>(delegate(ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return(o.IsSelectedForSync.Value); } return(false); }).Count <ISyncSelectionOption>(); num3 = (uint)source.Artists.Options.Where <ISyncSelectionOption>(delegate(ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return(o.IsSelectedForSync.Value); } return(false); }).Count <ISyncSelectionOption>(); num4 = (uint)(from o in source.Artists.Options where !o.IsSelectedForSync.HasValue select o).Count <ISyncSelectionOption>(); } } if (rules.IsTVMoviesSyncEnabled) { if (rules.SyncAllTvMovies) { num5 = (uint)source.MoviesTVShows.Options.Count <ISyncSelectionOption>(); } else { num5 = (uint)source.MoviesTVShows.Options.Where <ISyncSelectionOption>(delegate(ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return(o.IsSelectedForSync.Value); } return(false); }).Count <ISyncSelectionOption>(); } } if (rules.IsPodcastSyncEnabled) { if (rules.SyncAllPodcasts) { num6 = (uint)source.Podcasts.Options.Count <ISyncSelectionOption>(); } else { num6 = (uint)source.Podcasts.Options.Where <ISyncSelectionOption>(delegate(ISyncSelectionOption o) { if (o.IsSelectedForSync.HasValue) { return(o.IsSelectedForSync.Value); } return(false); }).Count <ISyncSelectionOption>(); } } stream.PlaylistFileSelectedCount = num; stream.GenreFileSelectedCount = num2; stream.ArtistFileSelectedCount = num3; stream.MusicAlbumFileSelectedCount = num4; stream.MovieFileSelectedCount = num5; stream.PodcastSeriesSelectedCount = num6; }
private void OnPartnershipChanged() { if (this.currentPartnership != null) { this.currentPartnership.PropertyChanged -= new PropertyChangedEventHandler(this.OnPartnershipPropertyChanged); this.SyncRules.PropertyChanged -= new PropertyChangedEventHandler(this.OnSyncRulesPropertyChanged); } this.currentPartnership = this.controller.CurrentSyncPartnership; if (this.currentPartnership != null) { this.currentPartnership.PropertyChanged += new PropertyChangedEventHandler(this.OnPartnershipPropertyChanged); this.SyncRules = this.currentPartnership.RuleManager; this.SyncRules.PropertyChanged += new PropertyChangedEventHandler(this.OnSyncRulesPropertyChanged); } else { this.SyncRules = null; } this.ResetMusicAndMovieProvider(); this.ResetPhotoAndVideoProvider(); }