Changeset 77
- Timestamp:
- 06/02/07 16:58:42 (1 year ago)
- Files:
-
- trunk/src/main/org/lastpod/ChunkProgress.java (modified) (1 diff)
- trunk/src/main/org/lastpod/Scrobbler.java (modified) (7 diffs)
- trunk/src/main/org/lastpod/UI.java (modified) (1 diff)
- trunk/src/main/org/lastpod/action/SubmitTracks.java (modified) (2 diffs)
- trunk/src/test/org/lastpod/MockModel.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/org/lastpod/ChunkProgress.java
r66 r77 43 43 */ 44 44 void setCompletionStatus(boolean completionStatus); 45 46 /** 47 * Sets the message for the submitStatus label. 48 * @param submitStatusMessage The message for the submitStatus label. 49 */ 50 void setSubmitStatusMessage(String submitStatusMessage); 45 51 } trunk/src/main/org/lastpod/Scrobbler.java
r66 r77 136 136 } 137 137 138 logger.log(Level.INFO, "Beginning Handshake"); 138 String statusMessage = "Beginning Handshake"; 139 chunkProgress.setSubmitStatusMessage(statusMessage); 140 logger.log(Level.INFO, statusMessage); 139 141 140 142 String args = "?hs=true&p=1.1&c=apd&v=0.1&u=" + URLEncoder.encode(username, "UTF-8"); 141 143 URL url = new URL("http://post.audioscrobbler.com/" + args); 142 logger.log(Level.FINE, "Handshaking to URL: " + url.toString()); 144 145 statusMessage = "Handshaking to URL: " + url.toString(); 146 chunkProgress.setSubmitStatusMessage(statusMessage); 147 logger.log(Level.FINE, statusMessage); 143 148 144 149 HttpURLConnection c = (HttpURLConnection) url.openConnection(); … … 170 175 171 176 if ((content == null) || (content.length() == 0)) { 172 throw new RuntimeException("Invalid response received from AudioScrobbler"); 177 statusMessage = "Invalid response received from AudioScrobbler"; 178 chunkProgress.setSubmitStatusMessage(statusMessage); 179 throw new RuntimeException(statusMessage); 173 180 } 174 181 … … 176 183 177 184 if ((lines[0].length() >= 6) && lines[0].substring(0, 6).equals("FAILED")) { 178 throw new RuntimeException(lines[0].substring(7)); 185 statusMessage = lines[0].substring(7); 186 chunkProgress.setSubmitStatusMessage(statusMessage); 187 throw new RuntimeException(statusMessage); 179 188 } 180 189 181 190 if ((lines[0].length() >= 7) && lines[0].substring(0, 7).equals("BADUSER")) { 182 throw new FailedLoginException("Invalid Username"); 191 statusMessage = "Invalid Username"; 192 chunkProgress.setSubmitStatusMessage(statusMessage); 193 throw new FailedLoginException(statusMessage); 183 194 } 184 195 185 196 if ((lines[0].length() >= 6) && lines[0].substring(0, 6).equals("UPDATE")) { 186 throw new RuntimeException("Update your client:" + lines[0].substring(7)); 197 statusMessage = "Update your client:" + lines[0].substring(7); 198 chunkProgress.setSubmitStatusMessage(statusMessage); 199 throw new RuntimeException(statusMessage); 187 200 } 188 201 … … 212 225 chunkProgress.updateCurrentChunk(1); 213 226 214 logger.log(Level.INFO, "Handshake completed"); 227 statusMessage = "Handshake completed"; 228 chunkProgress.setSubmitStatusMessage(statusMessage); 229 logger.log(Level.INFO, statusMessage); 215 230 } 216 231 … … 218 233 throws UnsupportedEncodingException, NoSuchAlgorithmException, MalformedURLException, 219 234 IOException, FailedLoginException { 220 logger.log(Level.INFO, "Submitting tracks..."); 235 String statusMessage = "Submitting tracks..."; 236 chunkProgress.setSubmitStatusMessage(statusMessage); 237 logger.log(Level.INFO, statusMessage); 221 238 222 239 if (trackChunks.size() == 0) { 223 throw new RuntimeException("No tracks to submit"); 240 statusMessage = "No tracks to submit"; 241 chunkProgress.setSubmitStatusMessage(statusMessage); 242 throw new RuntimeException(statusMessage); 224 243 } 225 244 … … 298 317 } 299 318 319 chunkProgress.setSubmitStatusMessage("Done. You may now sync your iPod."); 300 320 logger.log(Level.INFO, "Tracks submitted"); 301 321 logger.log(Level.INFO, 302 "You m ustnow sync your iPod with your music management software "322 "You may now sync your iPod with your music management software " 303 323 + "or delete 'Play Counts' from the iTunes folder!"); 304 324 … … 315 335 private void pauseIfRequired() { 316 336 if (interval != 0) { 317 logger.log(Level.INFO, "The server is busy. Pausing for " + interval + " seconds.");318 319 337 try { 320 338 Thread.sleep(interval * 1000); trunk/src/main/org/lastpod/UI.java
r74 r77 342 342 ((ExitApplication) actionExit).setSubmissionSuccessful(completionStatus); 343 343 } 344 345 /** 346 * Sets the message for the submitStatus label. 347 * @param submitStatusMessage The message for the submitStatus label. 348 */ 349 public void setSubmitStatusMessage(String submitStatusMessage) { 350 submitStatus.setText(submitStatusMessage); 351 } 344 352 } trunk/src/main/org/lastpod/action/SubmitTracks.java
r73 r77 135 135 new SwingWorker() { 136 136 public Object construct() { 137 userInterface.getSubmitStatus().setText("Transferring Data...");138 137 userInterface.getStatusAnimationLabel().setIcon(busyIcons[0]); 139 138 busyIconIndex = 0; … … 144 143 145 144 public void finished() { 146 userInterface.getSubmitStatus().setText("Done");147 145 busyIconTimer.stop(); 148 146 userInterface.getStatusAnimationLabel().setIcon(idleIcon); trunk/src/test/org/lastpod/MockModel.java
r76 r77 107 107 List activeRecentPlayed = onlyActiveTrackItems(recentlyPlayed); 108 108 List inactiveRecentPlayed = onlyInactiveTrackItems(recentlyPlayed); 109 Logger logger = Logger.getLogger(LastPod.class.getPackage().getName()); 109 110 110 111 userInterface.setNumberOfChunks(activeRecentPlayed.size()); … … 121 122 userInterface.updateCurrentChunk(i + 1); 122 123 123 Logger logger = Logger.getLogger(LastPod.class.getPackage().getName()); 124 logger.info("The logger should be really noisy."); 124 String statusMessage = "The logger should be really noisy."; 125 userInterface.setSubmitStatusMessage(statusMessage); 126 logger.info(statusMessage); 125 127 } 126 128 … … 133 135 /* Refresh track list. */ 134 136 userInterface.newTrackListAvailable(recentlyPlayed); 137 138 String statusMessage = "Done."; 139 userInterface.setSubmitStatusMessage(statusMessage); 140 logger.info(statusMessage); 135 141 136 142 return "Success";
