Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Commit

Permalink
flag/deprecate unused/misnamed code
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolateboy committed Sep 16, 2012
1 parent 450c2d9 commit 7b04941
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/main/external-resources/PMS.conf
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ alternate_thumb_folder =
# GUI Option: Browse compressed archives (toggle)
# Should the system browse compressed files looking for media? Files are
# extracted only when selected for viewing.
# Archives supported include zip, rar, cbr and possibly others.
# Supported formats: cbr, cbz, rar and zip.
# Default: false.
enable_archive_browsing =

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/pms/dlna/CueFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public File getPlaylistfile() {

public CueFolder(File f) {
playlistfile = f;
setLastmodified(playlistfile.lastModified());
setLastModified(playlistfile.lastModified());
}

@Override
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/net/pms/dlna/DLNAMediaDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ public void cleanup() {
while (rs.next()) {
String filename = rs.getString("FILENAME");
long modified = rs.getTimestamp("MODIFIED").getTime();
File entry = new File(filename);
if (!entry.exists() || entry.lastModified() != modified) {
File file = new File(filename);
if (!file.exists() || file.lastModified() != modified) {
rs.deleteRow();
}
i++;
Expand Down Expand Up @@ -611,9 +611,9 @@ public ArrayList<File> getFiles(String sql) {
while (rs.next()) {
String filename = rs.getString("FILENAME");
long modified = rs.getTimestamp("MODIFIED").getTime();
File entry = new File(filename);
if (entry.exists() && entry.lastModified() == modified) {
list.add(entry);
File file = new File(filename);
if (file.exists() && file.lastModified() == modified) {
list.add(file);
}
}
} catch (SQLException se) {
Expand Down Expand Up @@ -686,15 +686,15 @@ public void run() {
public void compact() {
logger.info("Compacting database...");
PMS.get().getFrame().setStatusLine(Messages.getString("DLNAMediaDatabase.3"));
String file = "database/backup.sql";
String filename = "database/backup.sql";
try {
Script.execute(url, "sa", "", file);
Script.execute(url, "sa", "", filename);
DeleteDbFiles.execute(dir, "medias", true); // TODO: rename "medias" -> "cache"
RunScript.execute(url, "sa", "", file, null, false);
RunScript.execute(url, "sa", "", filename, null, false);
} catch (Exception s) {
logger.error("Error in compacting database: ", s);
} finally {
File testsql = new File(file);
File testsql = new File(filename);
if (testsql.exists() && !testsql.delete()) {
testsql.deleteOnExit();
}
Expand Down
46 changes: 36 additions & 10 deletions src/main/java/net/pms/dlna/DLNAResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public abstract class DLNAResource extends HTTPResource implements Cloneable, Ru
* @deprecated Use standard getter and setter to access this field.
*/
@Deprecated
protected long lastmodified;
protected long lastmodified; // TODO make private and rename lastmodified -> lastModified

/**
* Represents the transformation to be used to the file. If null, then
Expand Down Expand Up @@ -1276,8 +1276,8 @@ public final String toString(RendererConfiguration mediaRenderer) {
closeTag(sb, "res");
}

if (getLastmodified() > 0) {
addXMLTagAndAttribute(sb, "dc:date", SDF_DATE.format(new Date(getLastmodified())));
if (getLastModified() > 0) {
addXMLTagAndAttribute(sb, "dc:date", SDF_DATE.format(new Date(getLastModified())));
}

String uclass = null;
Expand Down Expand Up @@ -1459,7 +1459,7 @@ public InputStream getInputStream(Range range, RendererConfiguration mediarender
int rewind_secs = mediarenderer.getByteToTimeseekRewindSeconds();
timeRange.rewindStart(rewind_secs);

//shagrath:
// shagrath:
timeseek_auto = true;
}
}
Expand All @@ -1484,13 +1484,13 @@ public InputStream getInputStream(Range range, RendererConfiguration mediarender
if (getFormat() != null && getFormat().isImage() && getMedia() != null && getMedia().getOrientation() > 1 && mediarenderer.isAutoRotateBasedOnExif()) {
// seems it's a jpeg file with an orientation setting to take care of
fis = ImagesUtil.getAutoRotateInputStreamImage(getInputStream(), getMedia().getOrientation());
if (fis == null) // error, let's return the original one
{
if (fis == null) { // error, let's return the original one
fis = getInputStream();
}
} else {
fis = getInputStream();
}

if (fis != null) {
if (low > 0) {
fis.skip(low);
Expand Down Expand Up @@ -1819,22 +1819,48 @@ protected void setMediaSubtitle(DLNAMediaSubtitle mediaSubtitle) {
}

/**
* @deprecated Use {@link #getLastModified()} instead.
*
* Returns the timestamp at which this resource was last modified.
*
* @return The timestamp.
*/
@Deprecated
public long getLastmodified() {
return lastmodified;
return getLastModified();
}

/**
* Returns the timestamp at which this resource was last modified.
*
* @return The timestamp.
* @since 1.71.0
*/
public long getLastModified() {
return lastmodified; // TODO rename lastmodified -> lastModified
}

/**
* @deprecated Use {@link #setLastModified()} instead.
*
* Sets the timestamp at which this resource was last modified.
*
* @param lastmodified The timestamp to set.
* @param lastModified The timestamp to set.
* @since 1.50
*/
protected void setLastmodified(long lastmodified) {
this.lastmodified = lastmodified;
@Deprecated
protected void setLastmodified(long lastModified) {
setLastModified(lastModified);
}

/**
* Sets the timestamp at which this resource was last modified.
*
* @param lastModified The timestamp to set.
* @since 1.71.0
*/
protected void setLastModified(long lastModified) {
this.lastmodified = lastModified; // TODO rename lastmodified -> lastModified
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/pms/dlna/DVDISOFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void run() {
public DVDISOFile(File f) {
super(PREFIX + (f.isFile() ? f.getName() : "VIDEO_TS"), null);
this.f = f;
setLastmodified(f.lastModified());
setLastModified(f.lastModified());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/pms/dlna/DVDISOTitle.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public long getLength() {
public DVDISOTitle(File f, int title) {
this.f = f;
this.title = title;
setLastmodified(f.lastModified());
setLastModified(f.lastModified());
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/pms/dlna/Feed.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void parse() throws Exception {
manageItem();
}
}
setLastmodified(System.currentTimeMillis());
setLastModified(System.currentTimeMillis());
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -185,6 +185,8 @@ public long length() {
return 0;
}

// XXX unused
@Deprecated
public long lastModified() {
return 0;
}
Expand All @@ -206,7 +208,7 @@ protected void manageItem() {

@Override
public boolean isRefreshNeeded() {
return (System.currentTimeMillis() - getLastmodified() > 3600000);
return (System.currentTimeMillis() - getLastModified() > 3600000);
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/pms/dlna/FeedItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public long length() {
return length;
}

// XXX unused
@Deprecated
public long lastModified() {
return 0;
}
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/net/pms/dlna/MapFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public class MapFile extends DLNAResource {

public MapFile() {
setConf(new MapFileConfiguration());
setLastmodified(0);
setLastModified(0);
}

public MapFile(MapFileConfiguration conf) {
setConf(conf);
setLastmodified(0);
setLastModified(0);
}

private boolean isFileRelevant(File f) {
Expand Down Expand Up @@ -250,13 +250,15 @@ public int compare(File f1, File f2) {

@Override
public boolean isRefreshNeeded() {
long lastModif = 0;
long modified = 0;

for (File f : this.getConf().getFiles()) {
if (f != null) {
lastModif = Math.max(lastModif, f.lastModified());
modified = Math.max(modified, f.lastModified());
}
}
return getLastRefreshTime() < lastModif;

return getLastRefreshTime() < modified;
}

@Override
Expand Down Expand Up @@ -319,7 +321,7 @@ private boolean foundInList(List<File> files, DLNAResource d) {
}

private boolean isSameLastModified(File f, DLNAResource d) {
return d.getLastmodified() == f.lastModified();
return d.getLastModified() == f.lastModified();
}

private boolean isRealFolder(DLNAResource d) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/pms/dlna/PlaylistFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public File getPlaylistfile() {

public PlaylistFolder(File f) {
playlistfile = f;
setLastmodified(playlistfile.lastModified());
setLastModified(playlistfile.lastModified());
}

@Override
Expand Down
33 changes: 22 additions & 11 deletions src/main/java/net/pms/dlna/RarredEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

import com.github.junrar.Archive;
import com.github.junrar.rarfile.FileHeader;

import net.pms.formats.Format;
import net.pms.util.FileUtil;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,23 +35,23 @@
public class RarredEntry extends DLNAResource implements IPushOutput {
private static final Logger logger = LoggerFactory.getLogger(RarredEntry.class);
private String name;
private File pere;
private String fileheadername;
private File file;
private String fileHeaderName;
private long length;

@Override
protected String getThumbnailURL() {
if (getType() == Format.IMAGE || getType() == Format.AUDIO) // no thumbnail support for now for real based disk images
{
if (getType() == Format.IMAGE || getType() == Format.AUDIO) { // no thumbnail support for now for rarred videos
return null;
}

return super.getThumbnailURL();
}

public RarredEntry(String name, File pere, String fileheadername, long length) {
this.fileheadername = fileheadername;
public RarredEntry(String name, File file, String fileHeaderName, long length) {
this.fileHeaderName = fileHeaderName;
this.name = name;
this.pere = pere;
this.file = file;
this.length = length;
}

Expand All @@ -65,26 +67,29 @@ public long length() {
if (getPlayer() != null && getPlayer().type() != Format.IMAGE) {
return DLNAMediaInfo.TRANS_SIZE;
}

return length;
}

public boolean isFolder() {
return false;
}

// XXX unused
@Deprecated
public long lastModified() {
return 0;
}

@Override
public String getSystemName() {
return FileUtil.getFileNameWithoutExtension(pere.getAbsolutePath()) + "." + FileUtil.getExtension(name);
return FileUtil.getFileNameWithoutExtension(file.getAbsolutePath()) + "." + FileUtil.getExtension(name);
}

@Override
public boolean isValid() {
checktype();
setSrtFile(FileUtil.doesSubtitlesExists(pere, null));
setSrtFile(FileUtil.doesSubtitlesExists(file, null));
return getFormat() != null;
}

Expand All @@ -100,10 +105,10 @@ public void push(final OutputStream out) throws IOException {
public void run() {
Archive rarFile = null;
try {
rarFile = new Archive(pere);
rarFile = new Archive(file);
FileHeader header = null;
for (FileHeader fh : rarFile.getFileHeaders()) {
if (fh.getFileNameString().equals(fileheadername)) {
if (fh.getFileNameString().equals(fileHeaderName)) {
header = fh;
break;
}
Expand All @@ -124,6 +129,7 @@ public void run() {
}
}
};

new Thread(r, "Rar Extractor").start();
}

Expand All @@ -132,19 +138,24 @@ public void resolve() {
if (getFormat() == null || !getFormat().isVideo()) {
return;
}

boolean found = false;

if (!found) {
if (getMedia() == null) {
setMedia(new DLNAMediaInfo());
}

found = !getMedia().isMediaparsed() && !getMedia().isParsing();

if (getFormat() != null) {
InputFile input = new InputFile();
input.setPush(this);
input.setSize(length());
getFormat().parse(getMedia(), input, getType());
}
}

super.resolve();
}

Expand Down
Loading

0 comments on commit 7b04941

Please sign in to comment.