Package org.our2unes.itunes.client.request

Examples of org.our2unes.itunes.client.request.SongRequest


              }
          }
         
          this.one2.hostQueueModel.updateStatus(songData.server, HostTableModel.DOWNLOADING);
         
          SongRequest sr = null;
          while (songData != null && sr == null && tries < 2) {
              One2OhMyGod.songQueue.updateCurrentStatus(SongBuffer.DOWNLOADING, songData);
              try {
                  sr =
                      new SongRequest(
                              songData.server,
                              songData.port,
                              songData.dbId,
                              songData.songId,
                              songData.songFmt,
                              sessionId,
                              // songData.status
                              _status);
              } catch (NoServerPermissionException e) {
                  //e.printStackTrace();
                  One2OhMyGod.debugPrint(
                  "that request didn't work ... try again");
                  /*if (!songData.server.equals(connectedHost))*/
                  tryLogin(songData);
                  tries++;
              }
          }
         
          if(songData == null){ 
              this.one2.doStatusUpdate("");
                One2OhMyGod.songQueue.updateCurrentStatus(SongBuffer.FAILED, songData);
             
              continue;
          }
          else {
              One2OhMyGod.songQueue.updateCurrentStatus(SongBuffer.DOWNLOADING, songData);
          }
         
          final String filename = songData.fileName;
          One2OhMyGod.debugPrint("Popped to queue: " + filename);          
         
          int newSize = iCurSize -1;
          if(iCurSize == 0) {newSize = 0;}
           String downloadString =
                      new String(
                              "Downloading "
                              + "("
                              + Integer.toString(newSize)
                              + " remaining): "
                              + filename
                      );

        this.one2.doStatusUpdate(downloadString);
         
          if(sr != null){
              try {
                  String filesep = System.getProperty("file.separator");
                  int index = filename.lastIndexOf(filesep);
                  if(index > 0){
                      String path = filename.substring(0, index);
                      One2OhMyGod.debugPrint("PATHS: " + path);
                      (new File(songData.dir, path)).mkdirs();
                  }
                 
                  BufferedOutputStream out =
                      new BufferedOutputStream(
                              new FileOutputStream(songData.dir + filename));
                  byte[] buffer = new byte[512];
                  int byte_total= 0;
                  while (true) {
                      int read = (sr.getStream()).read(buffer);
                      if (read == -1)
                          break;                   
                      out.write(buffer,0,read);
                      byte_total += read;
                     
View Full Code Here

TOP

Related Classes of org.our2unes.itunes.client.request.SongRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.