aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-07-22 18:14:40 -0700
committerScott Jackson <daneren2005@gmail.com>2014-07-22 18:14:40 -0700
commit0f1a69656d19f3da8a907164e5e1de23dcfb6ac6 (patch)
treec4f9f1f5e68cc0f69e62f2859fc9a6ab956ce19b
parent3fdb0677104aba0bce46a6a3aa3250b10a33b52f (diff)
downloaddsub-0f1a69656d19f3da8a907164e5e1de23dcfb6ac6.tar.gz
dsub-0f1a69656d19f3da8a907164e5e1de23dcfb6ac6.tar.bz2
dsub-0f1a69656d19f3da8a907164e5e1de23dcfb6ac6.zip
Fix background sync overwriting current server's version
-rw-r--r--src/github/daneren2005/dsub/domain/ServerInfo.java5
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java112
-rw-r--r--src/github/daneren2005/dsub/service/parser/AbstractParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/AlbumListParser.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/BookmarkParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/ChatMessageParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/ErrorParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/GenreParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/IndexesParser.java7
-rw-r--r--src/github/daneren2005/dsub/service/parser/JukeboxStatusParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/LicenseParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/LyricsParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java8
-rw-r--r--src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/PlaylistParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/PlaylistsParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/RandomSongsParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/ScanStatusParser.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/SearchResultParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/ShareParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/StarredListParser.java6
-rw-r--r--src/github/daneren2005/dsub/service/parser/UserParser.java4
26 files changed, 126 insertions, 128 deletions
diff --git a/src/github/daneren2005/dsub/domain/ServerInfo.java b/src/github/daneren2005/dsub/domain/ServerInfo.java
index 0cce774e..4dcc8074 100644
--- a/src/github/daneren2005/dsub/domain/ServerInfo.java
+++ b/src/github/daneren2005/dsub/domain/ServerInfo.java
@@ -95,8 +95,9 @@ public class ServerInfo implements Serializable {
}
}
- public void saveServerInfo(Context context) {
- saveServerInfo(context, Util.getActiveServer(context));
+ // Stub to make sure this is never used, too easy to screw up
+ private void saveServerInfo(Context context) {
+
}
public void saveServerInfo(Context context, int instance) {
ServerInfo current = SERVERS.get(instance);
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index 1a246867..295711e2 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -165,7 +165,7 @@ public class RESTMusicService implements MusicService {
public void ping(Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "ping", null);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -176,7 +176,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getLicense", null);
try {
- ServerInfo serverInfo = new LicenseParser(context).parse(reader);
+ ServerInfo serverInfo = new LicenseParser(context, getInstance(context)).parse(reader);
return serverInfo.isLicenseValid();
} finally {
Util.close(reader);
@@ -186,7 +186,7 @@ public class RESTMusicService implements MusicService {
public List<MusicFolder> getMusicFolders(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getMusicFolders", null);
try {
- return new MusicFoldersParser(context).parse(reader, progressListener);
+ return new MusicFoldersParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -196,7 +196,7 @@ public class RESTMusicService implements MusicService {
public void startRescan(Context context, ProgressListener listener) throws Exception {
Reader reader = getReader(context, listener, "startRescan", null);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -206,7 +206,7 @@ public class RESTMusicService implements MusicService {
while(!done) {
reader = getReader(context, null, "scanstatus", null);
try {
- boolean running = new ScanStatusParser(context).parse(reader, listener);
+ boolean running = new ScanStatusParser(context, getInstance(context)).parse(reader, listener);
if(running) {
// Don't run system ragged trying to query too much
Thread.sleep(100L);
@@ -245,7 +245,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getArtists" : "getIndexes", null, parameterNames, parameterValues);
try {
- Indexes indexes = new IndexesParser(context).parse(reader, progressListener);
+ Indexes indexes = new IndexesParser(context, getInstance(context)).parse(reader, progressListener);
if (indexes != null) {
writeCachedIndexes(context, indexes, musicFolderId);
return indexes;
@@ -292,7 +292,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getMusicDirectory", null, "id", id);
try {
- return new MusicDirectoryParser(context).parse(name, reader, progressListener);
+ return new MusicDirectoryParser(context, getInstance(context)).parse(name, reader, progressListener);
} finally {
Util.close(reader);
}
@@ -302,7 +302,7 @@ public class RESTMusicService implements MusicService {
public MusicDirectory getArtist(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getArtist", null, "id", id);
try {
- return new MusicDirectoryParser(context).parse(name, reader, progressListener);
+ return new MusicDirectoryParser(context, getInstance(context)).parse(name, reader, progressListener);
} finally {
Util.close(reader);
}
@@ -312,7 +312,7 @@ public class RESTMusicService implements MusicService {
public MusicDirectory getAlbum(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getAlbum", null, "id", id);
try {
- return new MusicDirectoryParser(context).parse(name, reader, progressListener);
+ return new MusicDirectoryParser(context, getInstance(context)).parse(name, reader, progressListener);
} finally {
Util.close(reader);
}
@@ -336,7 +336,7 @@ public class RESTMusicService implements MusicService {
List<Object> parameterValues = Arrays.<Object>asList(critera.getQuery(), critera.getSongCount());
Reader reader = getReader(context, progressListener, "search", null, parameterNames, parameterValues);
try {
- return new SearchResultParser(context).parse(reader, progressListener);
+ return new SearchResultParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -353,7 +353,7 @@ public class RESTMusicService implements MusicService {
critera.getAlbumCount(), critera.getSongCount());
Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "search3" : "search2", null, parameterNames, parameterValues);
try {
- return new SearchResult2Parser(context).parse(reader, progressListener);
+ return new SearchResult2Parser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -366,7 +366,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getPlaylist", params, "id", id);
try {
- return new PlaylistParser(context).parse(reader, progressListener);
+ return new PlaylistParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -376,7 +376,7 @@ public class RESTMusicService implements MusicService {
public List<Playlist> getPlaylists(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getPlaylists", null);
try {
- return new PlaylistsParser(context).parse(reader, progressListener);
+ return new PlaylistsParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -402,7 +402,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "createPlaylist", null, parameterNames, parameterValues);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -412,7 +412,7 @@ public class RESTMusicService implements MusicService {
public void deletePlaylist(String id, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "deletePlaylist", null, "id", id);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -431,7 +431,7 @@ public class RESTMusicService implements MusicService {
}
Reader reader = getReader(context, progressListener, "updatePlaylist", null, names, values);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -450,7 +450,7 @@ public class RESTMusicService implements MusicService {
}
Reader reader = getReader(context, progressListener, "updatePlaylist", null, names, values);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -475,7 +475,7 @@ public class RESTMusicService implements MusicService {
}
Reader reader = getReader(context, progressListener, "updatePlaylist", null, names, values);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -486,7 +486,7 @@ public class RESTMusicService implements MusicService {
checkServerVersion(context, "1.8", "Updating playlists is not supported.");
Reader reader = getReader(context, progressListener, "updatePlaylist", null, Arrays.asList("playlistId", "name", "comment", "public"), Arrays.<Object>asList(id, name, comment, pub));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -496,7 +496,7 @@ public class RESTMusicService implements MusicService {
public Lyrics getLyrics(String artist, String title, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getLyrics", null, Arrays.asList("artist", "title"), Arrays.<Object>asList(artist, title));
try {
- return new LyricsParser(context).parse(reader, progressListener);
+ return new LyricsParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -518,7 +518,7 @@ public class RESTMusicService implements MusicService {
else
reader = getReader(context, progressListener, "scrobble", null, Arrays.asList("id", "submission"), Arrays.<Object>asList(id, submission));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -529,7 +529,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getAlbumList2" : "getAlbumList",
null, Arrays.asList("type", "size", "offset"), Arrays.<Object>asList(type, size, offset));
try {
- return new AlbumListParser(context).parse(reader, progressListener);
+ return new AlbumListParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -568,7 +568,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getAlbumList2" : "getAlbumList", null, names, values);
try {
- return new AlbumListParser(context).parse(reader, progressListener);
+ return new AlbumListParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -578,7 +578,7 @@ public class RESTMusicService implements MusicService {
public MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getStarred2" : "getStarred", null);
try {
- return new StarredListParser(context).parse(reader, progressListener);
+ return new StarredListParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -614,7 +614,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getRandomSongs", params, names, values);
try {
- return new RandomSongsParser(context).parse(reader, progressListener);
+ return new RandomSongsParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -661,7 +661,7 @@ public class RESTMusicService implements MusicService {
// If content type is XML, an error occured. Get it.
String contentType = Util.getContentType(entity);
if (contentType != null && contentType.startsWith("text/xml")) {
- new ErrorParser(context).parse(new InputStreamReader(in, Constants.UTF_8));
+ new ErrorParser(context, getInstance(context)).parse(new InputStreamReader(in, Constants.UTF_8));
return null; // Never reached.
}
@@ -712,7 +712,7 @@ public class RESTMusicService implements MusicService {
if (contentType != null && contentType.startsWith("text/xml")) {
InputStream in = response.getEntity().getContent();
try {
- new ErrorParser(context).parse(new InputStreamReader(in, Constants.UTF_8));
+ new ErrorParser(context, getInstance(context)).parse(new InputStreamReader(in, Constants.UTF_8));
} finally {
Util.close(in);
}
@@ -823,7 +823,7 @@ public class RESTMusicService implements MusicService {
checkServerVersion(context, "1.7", "Jukebox not supported.");
Reader reader = getReader(context, progressListener, "jukeboxControl", null, parameterNames, parameterValues);
try {
- return new JukeboxStatusParser(context).parse(reader);
+ return new JukeboxStatusParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -862,7 +862,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, starred ? "star" : "unstar", null, names, values);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -874,7 +874,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getShares", null);
try {
- return new ShareParser(context).parse(reader, progressListener);
+ return new ShareParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -902,7 +902,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "createShare", null, parameterNames, parameterValues);
try {
- return new ShareParser(context).parse(reader, progressListener);
+ return new ShareParser(context, getInstance(context)).parse(reader, progressListener);
}
finally {
Util.close(reader);
@@ -925,7 +925,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "deleteShare", params, parameterNames, parameterValues);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
}
finally {
Util.close(reader);
@@ -955,7 +955,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "updateShare", params, parameterNames, parameterValues);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
}
finally {
Util.close(reader);
@@ -978,7 +978,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getChatMessages", params, parameterNames, parameterValues);
try {
- return new ChatMessageParser(context).parse(reader, progressListener);
+ return new ChatMessageParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -1000,7 +1000,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "addChatMessage", params, parameterNames, parameterValues);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1012,7 +1012,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getGenres", null);
try {
- return new GenreParser(context).parse(reader, progressListener);
+ return new GenreParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -1038,7 +1038,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getSongsByGenre", params, parameterNames, parameterValues);
try {
- return new RandomSongsParser(context).parse(reader, progressListener);
+ return new RandomSongsParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -1050,7 +1050,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getPodcasts", null, Arrays.asList("includeEpisodes"), Arrays.<Object>asList("false"));
try {
- List<PodcastChannel> channels = new PodcastChannelParser(context).parse(reader, progressListener);
+ List<PodcastChannel> channels = new PodcastChannelParser(context, getInstance(context)).parse(reader, progressListener);
String content = "";
for(PodcastChannel channel: channels) {
@@ -1072,7 +1072,7 @@ public class RESTMusicService implements MusicService {
public MusicDirectory getPodcastEpisodes(boolean refresh, String id, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getPodcasts", null, Arrays.asList("id"), Arrays.<Object>asList(id));
try {
- return new PodcastEntryParser(context).parse(id, reader, progressListener);
+ return new PodcastEntryParser(context, getInstance(context)).parse(id, reader, progressListener);
} finally {
Util.close(reader);
}
@@ -1084,7 +1084,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "refreshPodcasts", null);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1096,7 +1096,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "createPodcastChannel", null, "url", url);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1108,7 +1108,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "deletePodcastChannel", null, "id", id);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1120,7 +1120,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "downloadPodcastEpisode", null, "id", id);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1132,7 +1132,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "deletePodcastEpisode", null, "id", id);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1144,7 +1144,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "setRating", null, Arrays.asList("id", "rating"), Arrays.<Object>asList(id, rating));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1156,7 +1156,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getBookmarks", null);
try {
- return new BookmarkParser(context).parse(reader, progressListener);
+ return new BookmarkParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -1168,7 +1168,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "createBookmark", null, Arrays.asList("id", "position", "comment"), Arrays.<Object>asList(id, position, comment));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1180,7 +1180,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "deleteBookmark", null, Arrays.asList("id"), Arrays.<Object>asList(id));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1190,7 +1190,7 @@ public class RESTMusicService implements MusicService {
public User getUser(boolean refresh, String username, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getUser", null, Arrays.asList("username"), Arrays.<Object>asList(username));
try {
- List<User> users = new UserParser(context).parse(reader, progressListener);
+ List<User> users = new UserParser(context, getInstance(context)).parse(reader, progressListener);
if(users.size() > 0) {
// Should only have returned one anyways
return users.get(0);
@@ -1208,7 +1208,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "getUsers", null);
try {
- return new UserParser(context).parse(reader, progressListener);
+ return new UserParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -1233,7 +1233,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "createUser", null, names, values);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1258,7 +1258,7 @@ public class RESTMusicService implements MusicService {
Reader reader = getReader(context, progressListener, "updateUser", null, names, values);
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1268,7 +1268,7 @@ public class RESTMusicService implements MusicService {
public void deleteUser(String username, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "deleteUser", null, Arrays.asList("username"), Arrays.<Object>asList(username));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1278,7 +1278,7 @@ public class RESTMusicService implements MusicService {
public void changeEmail(String username, String email, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "updateUser", null, Arrays.asList("username", "email"), Arrays.<Object>asList(username, email));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1288,7 +1288,7 @@ public class RESTMusicService implements MusicService {
public void changePassword(String username, String password, Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "changePassword", null, Arrays.asList("username", "password"), Arrays.<Object>asList(username, password));
try {
- new ErrorParser(context).parse(reader);
+ new ErrorParser(context, getInstance(context)).parse(reader);
} finally {
Util.close(reader);
}
@@ -1327,7 +1327,7 @@ public class RESTMusicService implements MusicService {
String contentType = Util.getContentType(entity);
if (contentType != null && contentType.startsWith("text/xml"))
{
- new ErrorParser(context).parse(new InputStreamReader(in, Constants.UTF_8));
+ new ErrorParser(context, getInstance(context)).parse(new InputStreamReader(in, Constants.UTF_8));
return null; // Never reached.
}
diff --git a/src/github/daneren2005/dsub/service/parser/AbstractParser.java b/src/github/daneren2005/dsub/service/parser/AbstractParser.java
index 56382bf4..bc5d2199 100644
--- a/src/github/daneren2005/dsub/service/parser/AbstractParser.java
+++ b/src/github/daneren2005/dsub/service/parser/AbstractParser.java
@@ -36,11 +36,13 @@ import github.daneren2005.dsub.util.Util;
public abstract class AbstractParser {
protected final Context context;
+ protected final int instance;
private XmlPullParser parser;
private boolean rootElementFound;
- public AbstractParser(Context context) {
+ public AbstractParser(Context context, int instance) {
this.context = context;
+ this.instance = instance;
}
protected Context getContext() {
@@ -134,7 +136,7 @@ public abstract class AbstractParser {
if("madsonic".equals(get("type"))) {
server.setRestType(ServerInfo.TYPE_MADSONIC);
}
- server.saveServerInfo(context);
+ server.saveServerInfo(context, instance);
}
}
return name;
diff --git a/src/github/daneren2005/dsub/service/parser/AlbumListParser.java b/src/github/daneren2005/dsub/service/parser/AlbumListParser.java
index 880a9a22..773c241b 100644
--- a/src/github/daneren2005/dsub/service/parser/AlbumListParser.java
+++ b/src/github/daneren2005/dsub/service/parser/AlbumListParser.java
@@ -31,8 +31,8 @@ import java.io.Reader;
*/
public class AlbumListParser extends MusicDirectoryEntryParser {
- public AlbumListParser(Context context) {
- super(context);
+ public AlbumListParser(Context context, int instance) {
+ super(context, instance);
}
public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
diff --git a/src/github/daneren2005/dsub/service/parser/BookmarkParser.java b/src/github/daneren2005/dsub/service/parser/BookmarkParser.java
index 23db3a07..68dc3898 100644
--- a/src/github/daneren2005/dsub/service/parser/BookmarkParser.java
+++ b/src/github/daneren2005/dsub/service/parser/BookmarkParser.java
@@ -32,9 +32,9 @@ import java.util.List;
* @author Scott Jackson
*/
public class BookmarkParser extends MusicDirectoryEntryParser {
- public BookmarkParser(Context context) {
- super(context);
- }
+ public BookmarkParser(Context context, int instance) {
+ super(context, instance);
+ }
public List<Bookmark> parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java b/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java
index 8e37de40..2692d42b 100644
--- a/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java
+++ b/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java
@@ -33,9 +33,9 @@ import java.util.List;
*/
public class ChatMessageParser extends AbstractParser {
- public ChatMessageParser(Context context) {
- super(context);
- }
+ public ChatMessageParser(Context context, int instance) {
+ super(context, instance);
+ }
public List<ChatMessage> parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/ErrorParser.java b/src/github/daneren2005/dsub/service/parser/ErrorParser.java
index 3463687d..afb05928 100644
--- a/src/github/daneren2005/dsub/service/parser/ErrorParser.java
+++ b/src/github/daneren2005/dsub/service/parser/ErrorParser.java
@@ -28,9 +28,9 @@ import java.io.Reader;
*/
public class ErrorParser extends AbstractParser {
- public ErrorParser(Context context) {
- super(context);
- }
+ public ErrorParser(Context context, int instance) {
+ super(context, instance);
+ }
public void parse(Reader reader) throws Exception {
diff --git a/src/github/daneren2005/dsub/service/parser/GenreParser.java b/src/github/daneren2005/dsub/service/parser/GenreParser.java
index e963442c..a9860f84 100644
--- a/src/github/daneren2005/dsub/service/parser/GenreParser.java
+++ b/src/github/daneren2005/dsub/service/parser/GenreParser.java
@@ -40,9 +40,9 @@ import java.util.List;
public class GenreParser extends AbstractParser {
private static final String TAG = GenreParser.class.getSimpleName();
- public GenreParser(Context context) {
- super(context);
- }
+ public GenreParser(Context context, int instance) {
+ super(context, instance);
+ }
public List<Genre> parse(Reader reader, ProgressListener progressListener) throws Exception {
List<Genre> result = new ArrayList<Genre>();
diff --git a/src/github/daneren2005/dsub/service/parser/IndexesParser.java b/src/github/daneren2005/dsub/service/parser/IndexesParser.java
index 3af76e1d..d718a387 100644
--- a/src/github/daneren2005/dsub/service/parser/IndexesParser.java
+++ b/src/github/daneren2005/dsub/service/parser/IndexesParser.java
@@ -40,12 +40,9 @@ import github.daneren2005.dsub.util.Util;
*/
public class IndexesParser extends MusicDirectoryEntryParser {
private static final String TAG = IndexesParser.class.getSimpleName();
-
- private Context context;
- public IndexesParser(Context context) {
- super(context);
- this.context = context;
+ public IndexesParser(Context context, int instance) {
+ super(context, instance);
}
public Indexes parse(Reader reader, ProgressListener progressListener) throws Exception {
diff --git a/src/github/daneren2005/dsub/service/parser/JukeboxStatusParser.java b/src/github/daneren2005/dsub/service/parser/JukeboxStatusParser.java
index b7fc2f3f..95529635 100644
--- a/src/github/daneren2005/dsub/service/parser/JukeboxStatusParser.java
+++ b/src/github/daneren2005/dsub/service/parser/JukeboxStatusParser.java
@@ -30,9 +30,9 @@ import github.daneren2005.dsub.domain.RemoteStatus;
*/
public class JukeboxStatusParser extends AbstractParser {
- public JukeboxStatusParser(Context context) {
- super(context);
- }
+ public JukeboxStatusParser(Context context, int instance) {
+ super(context, instance);
+ }
public RemoteStatus parse(Reader reader) throws Exception {
diff --git a/src/github/daneren2005/dsub/service/parser/LicenseParser.java b/src/github/daneren2005/dsub/service/parser/LicenseParser.java
index e7b200fd..78790062 100644
--- a/src/github/daneren2005/dsub/service/parser/LicenseParser.java
+++ b/src/github/daneren2005/dsub/service/parser/LicenseParser.java
@@ -31,9 +31,9 @@ import github.daneren2005.dsub.domain.Version;
*/
public class LicenseParser extends AbstractParser {
- public LicenseParser(Context context) {
- super(context);
- }
+ public LicenseParser(Context context, int instance) {
+ super(context, instance);
+ }
public ServerInfo parse(Reader reader) throws Exception {
diff --git a/src/github/daneren2005/dsub/service/parser/LyricsParser.java b/src/github/daneren2005/dsub/service/parser/LyricsParser.java
index b621d518..e7ce7a4b 100644
--- a/src/github/daneren2005/dsub/service/parser/LyricsParser.java
+++ b/src/github/daneren2005/dsub/service/parser/LyricsParser.java
@@ -31,9 +31,9 @@ import java.io.Reader;
*/
public class LyricsParser extends AbstractParser {
- public LyricsParser(Context context) {
- super(context);
- }
+ public LyricsParser(Context context, int instance) {
+ super(context, instance);
+ }
public Lyrics parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java b/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java
index 2957712e..a9bafd12 100644
--- a/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java
+++ b/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java
@@ -25,8 +25,8 @@ import github.daneren2005.dsub.domain.MusicDirectory;
* @author Sindre Mehus
*/
public class MusicDirectoryEntryParser extends AbstractParser {
- public MusicDirectoryEntryParser(Context context) {
- super(context);
+ public MusicDirectoryEntryParser(Context context, int instance) {
+ super(context, instance);
}
protected MusicDirectory.Entry parseEntry(String artist) {
diff --git a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java
index 7a953593..05e8b274 100644
--- a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java
+++ b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java
@@ -40,11 +40,9 @@ import static github.daneren2005.dsub.domain.MusicDirectory.*;
public class MusicDirectoryParser extends MusicDirectoryEntryParser {
private static final String TAG = MusicDirectoryParser.class.getSimpleName();
- private Context context;
- public MusicDirectoryParser(Context context) {
- super(context);
- this.context = context;
+ public MusicDirectoryParser(Context context, int instance) {
+ super(context, instance);
}
public MusicDirectory parse(String artist, Reader reader, ProgressListener progressListener) throws Exception {
@@ -98,7 +96,7 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser {
validate();
// Only apply sorting on server version 4.7 and greater, where disc is supported
- if(ServerInfo.checkServerVersion(context, "1.8.0")) {
+ if(ServerInfo.checkServerVersion(context, "1.8.0", instance)) {
dir.sortChildren(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_CUSTOM_SORT_ENABLED, true));
}
diff --git a/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java b/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java
index 246c3415..a525084e 100644
--- a/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java
+++ b/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java
@@ -34,9 +34,9 @@ import github.daneren2005.dsub.util.ProgressListener;
*/
public class MusicFoldersParser extends AbstractParser {
- public MusicFoldersParser(Context context) {
- super(context);
- }
+ public MusicFoldersParser(Context context, int instance) {
+ super(context, instance);
+ }
public List<MusicFolder> parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/PlaylistParser.java b/src/github/daneren2005/dsub/service/parser/PlaylistParser.java
index 1eda1806..5bb07dfd 100644
--- a/src/github/daneren2005/dsub/service/parser/PlaylistParser.java
+++ b/src/github/daneren2005/dsub/service/parser/PlaylistParser.java
@@ -31,9 +31,9 @@ import java.io.Reader;
*/
public class PlaylistParser extends MusicDirectoryEntryParser {
- public PlaylistParser(Context context) {
- super(context);
- }
+ public PlaylistParser(Context context, int instance) {
+ super(context, instance);
+ }
public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java b/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java
index c3b47f47..ee978167 100644
--- a/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java
+++ b/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java
@@ -34,9 +34,9 @@ import java.util.List;
*/
public class PlaylistsParser extends AbstractParser {
- public PlaylistsParser(Context context) {
- super(context);
- }
+ public PlaylistsParser(Context context, int instance) {
+ super(context, instance);
+ }
public List<Playlist> parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java b/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java
index 6c83fad6..8c77e2bc 100644
--- a/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java
+++ b/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java
@@ -32,8 +32,8 @@ import org.xmlpull.v1.XmlPullParser;
* @author Scott
*/
public class PodcastChannelParser extends AbstractParser {
- public PodcastChannelParser(Context context) {
- super(context);
+ public PodcastChannelParser(Context context, int instance) {
+ super(context, instance);
}
public List<PodcastChannel> parse(Reader reader, ProgressListener progressListener) throws Exception {
diff --git a/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java b/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java
index c331f7e1..35d478d8 100644
--- a/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java
+++ b/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java
@@ -34,9 +34,9 @@ import org.xmlpull.v1.XmlPullParser;
public class PodcastEntryParser extends AbstractParser {
private static int bogusId = -1;
- public PodcastEntryParser(Context context) {
- super(context);
- }
+ public PodcastEntryParser(Context context, int instance) {
+ super(context, instance);
+ }
public MusicDirectory parse(String channel, Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java b/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java
index 88be3662..37057723 100644
--- a/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java
+++ b/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java
@@ -31,9 +31,9 @@ import java.io.Reader;
*/
public class RandomSongsParser extends MusicDirectoryEntryParser {
- public RandomSongsParser(Context context) {
- super(context);
- }
+ public RandomSongsParser(Context context, int instance) {
+ super(context, instance);
+ }
public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/ScanStatusParser.java b/src/github/daneren2005/dsub/service/parser/ScanStatusParser.java
index e26b0562..395dbcb6 100644
--- a/src/github/daneren2005/dsub/service/parser/ScanStatusParser.java
+++ b/src/github/daneren2005/dsub/service/parser/ScanStatusParser.java
@@ -25,8 +25,8 @@ import github.daneren2005.dsub.util.ProgressListener;
public class ScanStatusParser extends AbstractParser {
- public ScanStatusParser(Context context) {
- super(context);
+ public ScanStatusParser(Context context, int instance) {
+ super(context, instance);
}
public boolean parse(Reader reader, ProgressListener progressListener) throws Exception {
diff --git a/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java b/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java
index ce4a71c8..8cc0c50d 100644
--- a/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java
+++ b/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java
@@ -35,9 +35,9 @@ import java.util.ArrayList;
*/
public class SearchResult2Parser extends MusicDirectoryEntryParser {
- public SearchResult2Parser(Context context) {
- super(context);
- }
+ public SearchResult2Parser(Context context, int instance) {
+ super(context, instance);
+ }
public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/SearchResultParser.java b/src/github/daneren2005/dsub/service/parser/SearchResultParser.java
index 952b95bc..252a7b20 100644
--- a/src/github/daneren2005/dsub/service/parser/SearchResultParser.java
+++ b/src/github/daneren2005/dsub/service/parser/SearchResultParser.java
@@ -36,9 +36,9 @@ import java.util.ArrayList;
*/
public class SearchResultParser extends MusicDirectoryEntryParser {
- public SearchResultParser(Context context) {
- super(context);
- }
+ public SearchResultParser(Context context, int instance) {
+ super(context, instance);
+ }
public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/ShareParser.java b/src/github/daneren2005/dsub/service/parser/ShareParser.java
index 25feb5af..e18e1414 100644
--- a/src/github/daneren2005/dsub/service/parser/ShareParser.java
+++ b/src/github/daneren2005/dsub/service/parser/ShareParser.java
@@ -38,9 +38,9 @@ import java.util.List;
public class ShareParser extends MusicDirectoryEntryParser {
private static final String TAG = ShareParser.class.getSimpleName();
- public ShareParser(Context context) {
- super(context);
- }
+ public ShareParser(Context context, int instance) {
+ super(context, instance);
+ }
public List<Share> parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/StarredListParser.java b/src/github/daneren2005/dsub/service/parser/StarredListParser.java
index 89addecd..6328d1b0 100644
--- a/src/github/daneren2005/dsub/service/parser/StarredListParser.java
+++ b/src/github/daneren2005/dsub/service/parser/StarredListParser.java
@@ -31,9 +31,9 @@ import java.io.Reader;
*/
public class StarredListParser extends MusicDirectoryEntryParser {
- public StarredListParser(Context context) {
- super(context);
- }
+ public StarredListParser(Context context, int instance) {
+ super(context, instance);
+ }
public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
init(reader);
diff --git a/src/github/daneren2005/dsub/service/parser/UserParser.java b/src/github/daneren2005/dsub/service/parser/UserParser.java
index 4c0c8db7..558a7bab 100644
--- a/src/github/daneren2005/dsub/service/parser/UserParser.java
+++ b/src/github/daneren2005/dsub/service/parser/UserParser.java
@@ -28,8 +28,8 @@ import github.daneren2005.dsub.util.ProgressListener;
public class UserParser extends AbstractParser {
- public UserParser(Context context) {
- super(context);
+ public UserParser(Context context, int instance) {
+ super(context, instance);
}
public List<User> parse(Reader reader, ProgressListener progressListener) throws Exception {