//======================================================================================== // 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); } } }