//======================================================================================== // Constructor //======================================================================================== /// <summary> /// Initialize a new instance of this scaner with the specified iTunes interface. /// </summary> /// <param name="itunes"></param> /// <param name="catalog"></param> public MaintenanceScanner( Controller controller, ICatalog catalog, MaintenanceAction action) : base(Resx.I_ScanMaintenance, controller, catalog) { base.description = Resx.ScanMaintenance; this.action = action; }
//======================================================================================== // Constructor //======================================================================================== /// <summary> /// Initialize a new instance of this scaner with the specified iTunes interface. /// </summary> /// <param name="itunes"></param> /// <param name="catalog"></param> public MaintenanceScanner( Controller controller, ICatalog catalog, MaintenanceAction action) : base(Resx.I_ScanMaintenance, controller, catalog) { base.description = Resx.ScanMaintenance; base.tooltip = action.Action.ToString(); this.action = action; }
/// <summary> /// Handle the iTunes DatabaseChangedEvent asynchronously. /// </summary> public void MaintainLibrary(MaintenanceAction action) { if (IsScannerAllowed(Resx.I_ScanMaintenance) && !disabled.Contains(Resx.I_ScanMaintenance)) { IScanner scanner = new MaintenanceScanner(controller, catalog, action); AddScanner(scanner, MaintenanceScannerPriority); } }
//======================================================================================== // Methods //======================================================================================== #region Handlers /// <summary> /// Handle iTunes database changes including adding a playlist, removing a playlist, /// adding a track to playlist, and removing a track from a playlist. /// </summary> /// <param name="deletedObjectIDs"> /// A two-dimensional safe-array specifying the object IDs of each deleted object. /// </param> /// <param name="changedObjectIDs"> /// A two-dimensional safe-array specifying the object IDs of each changed object. /// </param> /// <remarks> /// For the purposes of maintaining our in-memory catalog, we know that these /// operations result in very specific patterns that we can recognize in each /// safe-array. If we find a pattern match then we can continue processing... /// </remarks> private void DoDatabaseChanged(object deletedObjectIDs, object changedObjectIDs) { // *** This handler blocks iTunes until complete so leave as quickly as possible! // I've yet to see both deleted and changed requests at the same time so we can // assume this is always true... check for changes first since additions and edits // are most likely more probable, then check for deletions MaintenanceAction action = MaintenanceAction.Create(changedObjectIDs); if (action != null) { librarian.MaintainLibrary(action); } else { action = MaintenanceAction.Create(deletedObjectIDs); if (action != null) { librarian.MaintainLibrary(action); } } }
/// <summary> /// Handle the iTunes DatabaseChangedEvent asynchronously. /// </summary> public void MaintainLibrary(MaintenanceAction action) { if (IsScannerAllowed(Resx.I_ScanMaintenance) && !disabled.Contains(Resx.I_ScanMaintenance)) { IScanner scanner = new MaintenanceScanner(controller, catalog, action); AddScanner(scanner); } }
public void MaintainLibrary(MaintenanceAction action) { }