Changeset 89

Show
Ignore:
Timestamp:
12/29/07 10:28:00 (11 months ago)
Author:
chris
Message:

Completes #56:
Added new parser for the iPod shuffle
Added logic to determine if the iPod being used is a shuffle

or a non-shuffle. If a shuffle is detected then the parser
is automatically switched out and the "Delete Playcounts"
action is modified to delete the proper file.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/org/lastpod/ModelImpl.java

    r85 r89  
    2020 
    2121import org.lastpod.parser.ItunesDbParser; 
     22import org.lastpod.parser.ItunesStatsParser; 
    2223import org.lastpod.parser.PlayCountsParser; 
    23  
     24import org.lastpod.parser.TrackItemParser; 
     25 
     26import org.lastpod.util.ItunesStatsFilter; 
    2427import org.lastpod.util.MiscUtilities; 
     28 
     29import java.io.File; 
    2530 
    2631import java.util.ArrayList; 
     
    95100        ItunesDbParser itunesDbParser = 
    96101            new ItunesDbParser(iTunesPath, parseVariousArtists, splitVariousArtistStrings); 
    97         PlayCountsParser playCountsParser = new PlayCountsParser(iTunesPath, parseMultiPlayTracks); 
     102 
     103        /* Defaults to the parser for non-shuffle iPods. */ 
     104        TrackItemParser playCountsParser = new PlayCountsParser(iTunesPath, parseMultiPlayTracks); 
     105 
     106        /* Checks for the "iTunesStats" file.  If it exists, switch to the iPod 
     107         * shuffle parser. */ 
     108        File file = new File(iTunesPath); 
     109        File[] itunesStatsFiles = file.listFiles(new ItunesStatsFilter()); 
     110 
     111        if ((itunesStatsFiles != null) && (itunesStatsFiles.length != 0)) { 
     112            playCountsParser = new ItunesStatsParser(iTunesPath, parseMultiPlayTracks); 
     113        } 
     114 
    98115        DbReader reader = new DbReader(itunesDbParser, playCountsParser); 
    99116 
  • trunk/src/main/org/lastpod/UI.java

    r83 r89  
    113113     */ 
    114114    public UI(Model model) { 
    115         frame = new JFrame("LastPod (v0.8)"); 
     115        frame = new JFrame("LastPod (v0.9)"); 
    116116 
    117117        submitStatus = new JLabel(); 
  • trunk/src/main/org/lastpod/action/DeletePlayCounts.java

    r71 r89  
    2121import org.lastpod.Model; 
    2222import org.lastpod.UI; 
     23 
     24import org.lastpod.util.ItunesStatsFilter; 
    2325 
    2426import java.awt.event.ActionEvent; 
     
    5456 
    5557    /** 
     58     * Stores the file location of the "Play Counts" or "iTunesStats" file. 
     59     * (For non-shuffle iPods there is a "Play Counts" file, for shuffle 
     60     * iPods the "iTunesStats" file is used.) 
     61     */ 
     62    private File playCountsFile; 
     63 
     64    /** 
    5665     * Constructs this action. 
    5766     * @param userInterface  The application's user interface. 
     
    6978        putValue(SHORT_DESCRIPTION, desc); 
    7079        putValue(MNEMONIC_KEY, new Integer(mnemonic)); 
     80 
     81        /* Setup Playcounts file; based on either iPod shuffle or non-shuffle. 
     82         */ 
     83        Preferences fPrefs = Preferences.userRoot().node("ws/afterglo/audioPod"); 
     84        String iTunesPath = fPrefs.get("iTunes Path", "default"); 
     85 
     86        if (!iTunesPath.endsWith(File.separator)) { 
     87            iTunesPath += File.separator; 
     88        } 
     89 
     90        /* Defaults the file for non-shuffle iPods. */ 
     91        playCountsFile = new File(iTunesPath + "Play Counts"); 
     92 
     93        /* Checks for the "iTunesStats" file.  If it exists, switch to the iPod 
     94         * shuffle file. */ 
     95        File file = new File(iTunesPath); 
     96        File[] itunesStatsFiles = file.listFiles(new ItunesStatsFilter()); 
     97 
     98        if ((itunesStatsFiles != null) && (itunesStatsFiles.length != 0)) { 
     99            playCountsFile = new File(iTunesPath + "iTunesStats"); 
     100            putValue(SHORT_DESCRIPTION, "Removes the iTunesStats file from the iPod shuffle."); 
     101        } 
    71102    } 
    72103 
     
    98129        } 
    99130 
    100         File playCountsFile = new File(iTunesPath + "Play Counts"); 
     131        playCountsFile = new File(iTunesPath + "Play Counts"); 
    101132 
    102133        boolean succuss = false;