diff options
Diffstat (limited to 'src/github/daneren2005')
40 files changed, 440 insertions, 322 deletions
diff --git a/src/github/daneren2005/dsub/domain/ServerInfo.java b/src/github/daneren2005/dsub/domain/ServerInfo.java index 43c7319a..4dcc8074 100644 --- a/src/github/daneren2005/dsub/domain/ServerInfo.java +++ b/src/github/daneren2005/dsub/domain/ServerInfo.java @@ -18,29 +18,173 @@ */ package github.daneren2005.dsub.domain; +import android.content.Context; + +import java.io.Serializable; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import github.daneren2005.dsub.util.FileUtil; +import github.daneren2005.dsub.util.Util; + /** * Information about the Subsonic server. * * @author Sindre Mehus */ -public class ServerInfo { +public class ServerInfo implements Serializable { + public static final int TYPE_SUBSONIC = 1; + public static final int TYPE_MADSONIC = 2; + private static final Map<Integer, ServerInfo> SERVERS = new ConcurrentHashMap<Integer, ServerInfo>(); + + private boolean isLicenseValid; + private Version restVersion; + private int type; + + public ServerInfo() { + type = TYPE_SUBSONIC; + } + + public boolean isLicenseValid() { + return isLicenseValid; + } + + public void setLicenseValid(boolean licenseValid) { + isLicenseValid = licenseValid; + } + + public Version getRestVersion() { + return restVersion; + } + + public void setRestVersion(Version restVersion) { + this.restVersion = restVersion; + } + + public int getRestType() { + return type; + } + public void setRestType(int type) { + this.type = type; + } + + public boolean isStockSubsonic() { + return type == TYPE_SUBSONIC; + } + public boolean isMadsonic() { + return type == TYPE_MADSONIC; + } + + @Override + public boolean equals(Object o) { + if(this == o) { + return true; + } else if(o == null || getClass() != o.getClass()) { + return false; + } + + final ServerInfo info = (ServerInfo) o; + + if(this.type != info.type) { + return false; + } else if(this.restVersion == null || info.restVersion == null) { + // Should never be null unless just starting up + return false; + } else { + return this.restVersion.equals(info.restVersion); + } + } + + // 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); + if(!this.equals(current)) { + SERVERS.put(instance, this); + FileUtil.serialize(context, this, getCacheName(context, instance)); + } + } + + public static ServerInfo getServerInfo(Context context) { + return getServerInfo(context, Util.getActiveServer(context)); + } + public static ServerInfo getServerInfo(Context context, int instance) { + ServerInfo current = SERVERS.get(instance); + if(current != null) { + return current; + } + + current = FileUtil.deserialize(context, getCacheName(context, instance), ServerInfo.class); + if(current != null) { + SERVERS.put(instance, current); + } + + return current; + } + + public static Version getServerVersion(Context context) { + return getServerVersion(context, Util.getActiveServer(context)); + } + public static Version getServerVersion(Context context, int instance) { + ServerInfo server = getServerInfo(context, instance); + if(server == null) { + return null; + } + + return server.getRestVersion(); + } + + public static boolean checkServerVersion(Context context, String requiredVersion) { + return checkServerVersion(context, requiredVersion, Util.getActiveServer(context)); + } + public static boolean checkServerVersion(Context context, String requiredVersion, int instance) { + ServerInfo server = getServerInfo(context, instance); + if(server == null) { + return false; + } + + Version version = server.getRestVersion(); + if(version == null) { + return false; + } + + Version required = new Version(requiredVersion); + return version.compareTo(required) >= 0; + } - private boolean isLicenseValid; - private Version restVersion; + public static int getServerType(Context context) { + return getServerType(context, Util.getActiveServer(context)); + } + public static int getServerType(Context context, int instance) { + if(Util.isOffline(context)) { + return 0; + } - public boolean isLicenseValid() { - return isLicenseValid; - } + ServerInfo server = getServerInfo(context, instance); + if(server == null) { + return 0; + } - public void setLicenseValid(boolean licenseValid) { - isLicenseValid = licenseValid; - } + return server.getRestType(); + } - public Version getRestVersion() { - return restVersion; - } + public static boolean isStockSubsonic(Context context) { + return isStockSubsonic(context, Util.getActiveServer(context)); + } + public static boolean isStockSubsonic(Context context, int instance) { + return getServerType(context, instance) == TYPE_SUBSONIC; + } - public void setRestVersion(Version restVersion) { - this.restVersion = restVersion; - } + public static boolean isMadsonic(Context context) { + return isMadsonic(context, Util.getActiveServer(context)); + } + public static boolean isMadsonic(Context context, int instance) { + return getServerType(context, instance) == TYPE_MADSONIC; + } + + private static String getCacheName(Context context, int instance) { + return "server-" + Util.getRestUrl(context, null, instance, false).hashCode() + ".ser"; + } } diff --git a/src/github/daneren2005/dsub/domain/User.java b/src/github/daneren2005/dsub/domain/User.java index f04b3d94..f61f98df 100644 --- a/src/github/daneren2005/dsub/domain/User.java +++ b/src/github/daneren2005/dsub/domain/User.java @@ -31,6 +31,7 @@ public class User implements Serializable { public static final String STREAM = "streamRole";
public static final String JUKEBOX = "jukeboxRole";
public static final String SHARE = "shareRole";
+ public static final String LASTFM = "lastFMRole";
public static final List<String> ROLES = new ArrayList<String>();
static {
diff --git a/src/github/daneren2005/dsub/domain/Version.java b/src/github/daneren2005/dsub/domain/Version.java index 8cf338f1..75221cd5 100644 --- a/src/github/daneren2005/dsub/domain/Version.java +++ b/src/github/daneren2005/dsub/domain/Version.java @@ -18,13 +18,15 @@ */ package github.daneren2005.dsub.domain; +import java.io.Serializable; + /** * Represents the version number of the Subsonic Android app. * * @author Sindre Mehus * @version $Revision: 1.3 $ $Date: 2006/01/20 21:25:16 $ */ -public class Version implements Comparable<Version> { +public class Version implements Comparable<Version>, Serializable { private int major; private int minor; private int beta; diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java index 561e32c4..da0711ef 100644 --- a/src/github/daneren2005/dsub/fragments/MainFragment.java +++ b/src/github/daneren2005/dsub/fragments/MainFragment.java @@ -21,6 +21,7 @@ import android.widget.CheckBox; import android.widget.ListView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
@@ -73,6 +74,10 @@ public class MainFragment extends SubsonicFragment { @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
menuInflater.inflate(R.menu.main, menu);
+
+ if(!ServerInfo.isMadsonic(context) || !UserUtil.isCurrentAdmin()) {
+ menu.setGroupVisible(R.id.madsonic, false);
+ }
}
@Override
@@ -95,6 +100,9 @@ public class MainFragment extends SubsonicFragment { case R.id.menu_faq:
showFAQDialog();
return true;
+ case R.id.menu_rescan:
+ rescanServer();
+ return true;
}
return false;
@@ -366,6 +374,22 @@ public class MainFragment extends SubsonicFragment { Util.showHTMLDialog(context, R.string.main_faq_title, R.string.main_faq_text);
}
+ private void rescanServer() {
+ new LoadingTask<Void>(context, false) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.startRescan(context, this);
+ return null;
+ }
+
+ @Override
+ protected void done(Void value) {
+ Util.toast(context, R.string.main_scan_complete);
+ }
+ }.execute();
+ }
+
private void getLogs() {
try {
final String version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index f0497703..14b83317 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -23,6 +23,7 @@ import android.widget.ListView; import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.domain.Share;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.view.AlbumGridAdapter;
@@ -584,7 +585,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter MusicDirectory result;
if ("starred".equals(albumListType)) {
result = service.getStarredList(context, this);
- } else if(("genres".equals(albumListType) && Util.checkServerVersion(context, "1.10.0")) || "years".equals(albumListType)) {
+ } else if(("genres".equals(albumListType) && ServerInfo.checkServerVersion(context, "1.10.0")) || "years".equals(albumListType)) {
result = service.getAlbumList(albumListType, albumListExtra, size, 0, context, this);
if(result.getChildrenSize() == 0 && "genres".equals(albumListType)) {
SelectDirectoryFragment.this.albumListType = "genres-songs";
diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index 7f6de2d8..694c6d19 100644 --- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -16,6 +16,7 @@ import android.widget.EditText; import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.Playlist;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
@@ -54,7 +55,7 @@ public class SelectPlaylistFragment extends SelectListFragment<Playlist> { menu.removeItem(R.id.playlist_menu_stop_sync);
}
- if(!Util.checkServerVersion(context, "1.8")) {
+ if(!ServerInfo.checkServerVersion(context, "1.8")) {
menu.removeItem(R.id.playlist_update_info);
} else if(playlist.getPublic() != null && playlist.getPublic() == true && playlist.getId().indexOf(".m3u") == -1 && !UserUtil.getCurrentUsername(context).equals(playlist.getOwner())) {
menu.removeItem(R.id.playlist_update_info);
@@ -155,7 +156,7 @@ public class SelectPlaylistFragment extends SelectListFragment<Playlist> { Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
- if(Util.checkServerVersion(context, "1.8") && playlist.getOwner() != null && playlist.getOwner().equals(UserUtil.getCurrentUsername(context))) {
+ if(ServerInfo.checkServerVersion(context, "1.8") && playlist.getOwner() != null && playlist.getOwner().equals(UserUtil.getCurrentUsername(context))) {
args.putBoolean(Constants.INTENT_EXTRA_NAME_PLAYLIST_OWNER, true);
}
fragment.setArguments(args);
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index b935f065..d3e152c3 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -52,6 +52,7 @@ import github.daneren2005.dsub.domain.Genre; import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.Playlist;
import github.daneren2005.dsub.domain.PodcastEpisode;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.domain.Share;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
@@ -211,11 +212,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
protected void hideMenuItems(ContextMenu menu) {
- if(!Util.checkServerVersion(context, "1.8")) {
+ if(!ServerInfo.checkServerVersion(context, "1.8")) {
menu.setGroupVisible(R.id.server_1_8, false);
menu.setGroupVisible(R.id.hide_star, false);
}
- if(!Util.checkServerVersion(context, "1.10.1")) {
+ if(!ServerInfo.checkServerVersion(context, "1.10.1")) {
menu.setGroupVisible(R.id.server_1_10, false);
}
@@ -543,7 +544,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR final String oldGenre = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, "");
boolean _useCombo = false;
- if(Util.checkServerVersion(context, "1.9.0")) {
+ if(ServerInfo.checkServerVersion(context, "1.9.0")) {
genreBox.setVisibility(View.GONE);
genreCombo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -931,7 +932,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if (playlistName != null) {
playlistNameView.setText(playlistName);
try {
- if(Util.checkServerVersion(context, "1.8.0") && Integer.parseInt(getDownloadService().getSuggestedPlaylistId()) != -1) {
+ if(ServerInfo.checkServerVersion(context, "1.8.0") && Integer.parseInt(getDownloadService().getSuggestedPlaylistId()) != -1) {
overwriteCheckBox.setChecked(true);
overwriteCheckBox.setVisibility(View.VISIBLE);
}
diff --git a/src/github/daneren2005/dsub/fragments/UserFragment.java b/src/github/daneren2005/dsub/fragments/UserFragment.java index 9bf26baf..2391762e 100644 --- a/src/github/daneren2005/dsub/fragments/UserFragment.java +++ b/src/github/daneren2005/dsub/fragments/UserFragment.java @@ -32,6 +32,7 @@ import android.widget.TextView; import github.daneren2005.dsub.R;
import github.daneren2005.dsub.activity.SubsonicActivity;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.domain.User;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
@@ -60,7 +61,7 @@ public class UserFragment extends SubsonicFragment{ listView = (ListView)rootView.findViewById(R.id.fragment_list);
createHeader();
- listView.setAdapter(new SettingsAdapter(context, user.getSettings(), UserUtil.isCurrentAdmin() && Util.checkServerVersion(context, "1.10")));
+ listView.setAdapter(new SettingsAdapter(context, user.getSettings(), UserUtil.isCurrentAdmin() && ServerInfo.checkServerVersion(context, "1.10")));
setTitle(user.getUsername());
@@ -80,7 +81,7 @@ public class UserFragment extends SubsonicFragment{ return;
}
- if(UserUtil.isCurrentAdmin() && Util.checkServerVersion(context, "1.10")) {
+ if(UserUtil.isCurrentAdmin() && ServerInfo.checkServerVersion(context, "1.10")) {
menuInflater.inflate(R.menu.user, menu);
} else if(UserUtil.isCurrentRole(User.SETTINGS)) {
menuInflater.inflate(R.menu.user_user, menu);
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index 31280b19..4f722d5c 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -42,7 +42,6 @@ import github.daneren2005.dsub.domain.SearchCritera; import github.daneren2005.dsub.domain.SearchResult; import github.daneren2005.dsub.domain.Share; import github.daneren2005.dsub.domain.User; -import github.daneren2005.dsub.domain.Version; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.TimeLimitedCache; @@ -118,7 +117,12 @@ public class CachedMusicService implements MusicService { return result; } - @Override + @Override + public void startRescan(Context context, ProgressListener listener) throws Exception { + musicService.startRescan(context, listener); + } + + @Override public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) throws Exception { checkSettingsChanged(context); if (refresh) { @@ -311,16 +315,6 @@ public class CachedMusicService implements MusicService { } @Override - public Version getLocalVersion(Context context) throws Exception { - return musicService.getLocalVersion(context); - } - - @Override - public Version getLatestVersion(Context context, ProgressListener progressListener) throws Exception { - return musicService.getLatestVersion(context, progressListener); - } - - @Override public String getVideoUrl(int maxBitrate, Context context, String id) { return musicService.getVideoUrl(maxBitrate, context, id); } diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java index cefd0c23..9f87065c 100644 --- a/src/github/daneren2005/dsub/service/MusicService.java +++ b/src/github/daneren2005/dsub/service/MusicService.java @@ -54,6 +54,8 @@ public interface MusicService { List<MusicFolder> getMusicFolders(boolean refresh, Context context, ProgressListener progressListener) throws Exception; + void startRescan(Context context, ProgressListener listener) throws Exception; + Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) throws Exception; MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception; @@ -100,11 +102,7 @@ public interface MusicService { String getMusicUrl(Context context, MusicDirectory.Entry song, int maxBitrate) throws Exception; - Version getLocalVersion(Context context) throws Exception; - - Version getLatestVersion(Context context, ProgressListener progressListener) throws Exception; - - String getVideoUrl(int maxBitrate, Context context, String id); + String getVideoUrl(int maxBitrate, Context context, String id); String getVideoStreamUrl(String format, int Bitrate, Context context, String id) throws Exception; diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java index 05d17444..3dacaee7 100644 --- a/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -52,7 +52,6 @@ import github.daneren2005.dsub.domain.SearchCritera; import github.daneren2005.dsub.domain.SearchResult; import github.daneren2005.dsub.domain.Share; import github.daneren2005.dsub.domain.User; -import github.daneren2005.dsub.domain.Version; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.ProgressListener; @@ -258,21 +257,16 @@ public class OfflineMusicService implements MusicService { } @Override - public Version getLocalVersion(Context context) throws Exception { + public List<MusicFolder> getMusicFolders(boolean refresh, Context context, ProgressListener progressListener) throws Exception { throw new OfflineException(ERRORMSG); - } + } @Override - public Version getLatestVersion(Context context, ProgressListener progressListener) throws Exception { + public void startRescan(Context context, ProgressListener listener) throws Exception { throw new OfflineException(ERRORMSG); } @Override - public List<MusicFolder> getMusicFolders(boolean refresh, Context context, ProgressListener progressListener) throws Exception { - throw new OfflineException(ERRORMSG); - } - - @Override public SearchResult search(SearchCritera criteria, Context context, ProgressListener progressListener) throws Exception { List<Artist> artists = new ArrayList<Artist>(); List<MusicDirectory.Entry> albums = new ArrayList<MusicDirectory.Entry>(); diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 43d443d2..295711e2 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -61,7 +61,6 @@ import org.apache.http.protocol.HttpContext; import android.content.Context; import android.content.SharedPreferences; -import android.content.pm.PackageInfo; import android.graphics.Bitmap; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -84,12 +83,12 @@ import github.daneren2005.dsub.service.parser.PlaylistsParser; import github.daneren2005.dsub.service.parser.PodcastChannelParser; import github.daneren2005.dsub.service.parser.PodcastEntryParser; import github.daneren2005.dsub.service.parser.RandomSongsParser; +import github.daneren2005.dsub.service.parser.ScanStatusParser; import github.daneren2005.dsub.service.parser.SearchResult2Parser; import github.daneren2005.dsub.service.parser.SearchResultParser; import github.daneren2005.dsub.service.parser.ShareParser; import github.daneren2005.dsub.service.parser.StarredListParser; import github.daneren2005.dsub.service.parser.UserParser; -import github.daneren2005.dsub.service.parser.VersionParser; import github.daneren2005.dsub.service.ssl.SSLSocketFactory; import github.daneren2005.dsub.service.ssl.TrustSelfSignedStrategy; import github.daneren2005.dsub.util.BackgroundTask; @@ -117,11 +116,6 @@ public class RESTMusicService implements MusicService { // Allow 20 seconds extra timeout per MB offset. private static final double TIMEOUT_MILLIS_PER_OFFSET_BYTE = 20000.0 / 1000000.0; - /** - * URL from which to fetch latest versions. - */ - private static final String VERSION_URL = "http://subsonic.org/backend/version.view"; - private static final int HTTP_REQUEST_MAX_ATTEMPTS = 5; private static final long REDIRECTION_CHECK_INTERVAL_MILLIS = 60L * 60L * 1000L; @@ -171,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); } @@ -182,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); @@ -192,11 +186,40 @@ 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); } } + + @Override + public void startRescan(Context context, ProgressListener listener) throws Exception { + Reader reader = getReader(context, listener, "startRescan", null); + try { + new ErrorParser(context, getInstance(context)).parse(reader); + } finally { + Util.close(reader); + } + + // Now check if still running + boolean done = false; + while(!done) { + reader = getReader(context, null, "scanstatus", null); + try { + 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); + } else { + done = true; + } + } catch(Exception e) { + done = true; + } finally { + Util.close(reader); + } + } + } @Override public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) throws Exception { @@ -205,18 +228,6 @@ public class RESTMusicService implements MusicService { return cachedIndexes; } - // If manual refresh, try to start server scan for madsonic servers - /*if(refresh) { - Reader reader = getReader(context, progressListener, "startRescan", null); - try { - new ErrorParser(context).parse(reader); - } catch(Exception e) { - // Probably not madsonic, don't care - } finally { - Util.close(reader); - } - }*/ - long lastModified = (cachedIndexes == null || refresh) ? 0L : cachedIndexes.getLastModified(); List<String> parameterNames = new ArrayList<String>(); @@ -234,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; @@ -281,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); } @@ -291,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); } @@ -301,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); } @@ -325,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); } @@ -342,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); } @@ -355,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); } @@ -365,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); } @@ -391,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); } @@ -401,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); } @@ -420,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); } @@ -439,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); } @@ -464,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); } @@ -475,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); } @@ -485,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); } @@ -507,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); } @@ -518,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); } @@ -557,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); } @@ -567,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); } @@ -603,30 +614,14 @@ public class RESTMusicService implements MusicService { Reader reader = getReader(context, progressListener, "getRandomSongs", params, names, values); try { - return new RandomSongsParser(context).parse(reader, progressListener); - } finally { - Util.close(reader); - } - } - - @Override - public Version getLocalVersion(Context context) throws Exception { - PackageInfo packageInfo = context.getPackageManager().getPackageInfo("github.daneren2005.dsub", 0); - return new Version(packageInfo.versionName); - } - - @Override - public Version getLatestVersion(Context context, ProgressListener progressListener) throws Exception { - Reader reader = getReaderForURL(context, VERSION_URL, null, null, null, progressListener); - try { - return new VersionParser().parse(reader); + return new RandomSongsParser(context, getInstance(context)).parse(reader, progressListener); } finally { Util.close(reader); } } - private void checkServerVersion(Context context, String version, String text) throws ServerTooOldException { - Version serverVersion = Util.getServerRestVersion(context); + private void checkServerVersion(Context context, String version, String text) throws ServerTooOldException { + Version serverVersion = ServerInfo.getServerVersion(context); Version requiredVersion = new Version(version); boolean ok = serverVersion == null || serverVersion.compareTo(requiredVersion) >= 0; @@ -666,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. } @@ -717,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); } @@ -828,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); } @@ -867,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); } @@ -879,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); } @@ -907,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); @@ -930,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); @@ -960,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); @@ -983,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); } @@ -1005,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); } @@ -1017,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); } @@ -1043,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); } @@ -1055,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) { @@ -1077,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); } @@ -1089,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); } @@ -1101,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); } @@ -1113,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); } @@ -1125,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); } @@ -1137,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); } @@ -1149,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); } @@ -1161,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); } @@ -1173,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); } @@ -1185,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); } @@ -1195,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); @@ -1213,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); } @@ -1238,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); } @@ -1263,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); } @@ -1273,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); } @@ -1283,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); } @@ -1293,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); } @@ -1302,7 +1297,7 @@ public class RESTMusicService implements MusicService { @Override public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener) throws Exception { // Return silently if server is too old - if (!Util.checkServerVersion(context, "1.8")) { + if (!ServerInfo.checkServerVersion(context, "1.8")) { return null; } @@ -1332,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. } @@ -1519,7 +1514,9 @@ public class RESTMusicService implements MusicService { List<String> parameterNames, List<Object> parameterValues, List<Header> headers, ProgressListener progressListener, SilentBackgroundTask task) throws Exception { // Strip out sensitive information from log - Log.i(TAG, stripUrlInfo(url)); + if(url.indexOf("scanstatus") == -1) { + Log.i(TAG, stripUrlInfo(url)); + } SharedPreferences prefs = Util.getPreferences(context); int networkTimeout = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT, "15000")); diff --git a/src/github/daneren2005/dsub/service/parser/AbstractParser.java b/src/github/daneren2005/dsub/service/parser/AbstractParser.java index 9db40dad..bc5d2199 100644 --- a/src/github/daneren2005/dsub/service/parser/AbstractParser.java +++ b/src/github/daneren2005/dsub/service/parser/AbstractParser.java @@ -25,6 +25,7 @@ import org.xmlpull.v1.XmlPullParser; import android.content.Context; import android.util.Xml; import github.daneren2005.dsub.R; +import github.daneren2005.dsub.domain.ServerInfo; import github.daneren2005.dsub.domain.Version; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.Util; @@ -35,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() { @@ -127,7 +130,13 @@ public abstract class AbstractParser { rootElementFound = true; String version = get("version"); if (version != null) { - Util.setServerRestVersion(context, new Version(version)); + ServerInfo server = new ServerInfo(); + server.setRestVersion(new Version(version)); + + if("madsonic".equals(get("type"))) { + server.setRestType(ServerInfo.TYPE_MADSONIC); + } + server.saveServerInfo(context, instance); } } return name; @@ -138,4 +147,4 @@ public abstract class AbstractParser { throw new Exception(context.getResources().getString(R.string.background_task_parse_error)); } } -}
\ No newline at end of file +} 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 95ee1744..05e8b274 100644 --- a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java +++ b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java @@ -22,6 +22,7 @@ import android.content.Context; import android.util.Log; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.domain.ServerInfo; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.Util; @@ -39,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 { @@ -97,7 +96,7 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser { validate(); // Only apply sorting on server version 4.7 and greater, where disc is supported - if(Util.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 new file mode 100644 index 00000000..395dbcb6 --- /dev/null +++ b/src/github/daneren2005/dsub/service/parser/ScanStatusParser.java @@ -0,0 +1,56 @@ +/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2014 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.service.parser;
+
+import android.content.Context;
+import org.xmlpull.v1.XmlPullParser;
+
+import java.io.Reader;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.util.ProgressListener;
+
+public class ScanStatusParser extends AbstractParser {
+
+ public ScanStatusParser(Context context, int instance) {
+ super(context, instance);
+ }
+
+ public boolean parse(Reader reader, ProgressListener progressListener) throws Exception {
+ init(reader);
+
+ Boolean started = null;
+ int eventType;
+ do {
+ eventType = nextParseEvent();
+ if (eventType == XmlPullParser.START_TAG) {
+ String name = getElementName();
+ if("status".equals(name)) {
+ started = getBoolean("started");
+
+ String msg = context.getResources().getString(R.string.parser_scan_count, getInteger("count"));
+ progressListener.updateProgress(msg);
+ } else if ("error".equals(name)) {
+ handleError();
+ }
+ }
+ } while (eventType != XmlPullParser.END_DOCUMENT);
+
+ validate();
+
+ return started != null && started;
+ }
+}
\ No newline at end of file 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..931bc4a5 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 {
@@ -50,6 +50,7 @@ public class UserParser extends AbstractParser { for(String role: User.ROLES) {
parseSetting(user, role);
}
+ parseSetting(user, User.LASTFM);
result.add(user);
} else if ("error".equals(name)) {
diff --git a/src/github/daneren2005/dsub/service/parser/VersionParser.java b/src/github/daneren2005/dsub/service/parser/VersionParser.java deleted file mode 100644 index 1b646206..00000000 --- a/src/github/daneren2005/dsub/service/parser/VersionParser.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of Subsonic. - - Subsonic is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Subsonic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Subsonic. If not, see <http://www.gnu.org/licenses/>. - - Copyright 2009 (C) Sindre Mehus - */ -package github.daneren2005.dsub.service.parser; - -import github.daneren2005.dsub.domain.Version; - -import java.io.BufferedReader; -import java.io.Reader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author Sindre Mehus - */ -public class VersionParser { - - public Version parse(Reader reader) throws Exception { - - BufferedReader bufferedReader = new BufferedReader(reader); - Pattern pattern = Pattern.compile("SUBSONIC_ANDROID_VERSION_BEGIN(.*)SUBSONIC_ANDROID_VERSION_END"); - String line = bufferedReader.readLine(); - while (line != null) { - Matcher finalMatcher = pattern.matcher(line); - if (finalMatcher.find()) { - return new Version(finalMatcher.group(1)); - } - line = bufferedReader.readLine(); - } - return null; - } -}
\ No newline at end of file diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index f8e4cf95..a4ed527e 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -62,6 +62,7 @@ import github.daneren2005.dsub.activity.SubsonicFragmentActivity; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PlayerState; import github.daneren2005.dsub.domain.RepeatMode; +import github.daneren2005.dsub.domain.ServerInfo; import github.daneren2005.dsub.domain.User; import github.daneren2005.dsub.domain.Version; import github.daneren2005.dsub.provider.DSubWidgetProvider; @@ -116,8 +117,6 @@ public final class Util { private static boolean pauseFocus = false; private static boolean lowerFocus = false; - private static final Map<Integer, Version> SERVER_REST_VERSIONS = new ConcurrentHashMap<Integer, Version>(); - // Used by hexEncode() private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; @@ -172,12 +171,6 @@ public final class Util { return prefs.getBoolean(Constants.PREFERENCES_KEY_OFFLINE, false) ? 0 : prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); } - public static boolean checkServerVersion(Context context, String requiredVersion) { - Version version = Util.getServerRestVersion(context); - Version required = new Version(requiredVersion); - return version != null && version.compareTo(required) >= 0; - } - public static int getServerCount(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getInt(Constants.PREFERENCES_KEY_SERVER_COUNT, 1); @@ -229,31 +222,6 @@ public final class Util { return prefs.getString(Constants.PREFERENCES_KEY_SERVER_NAME + instance, null); } - public static void setServerRestVersion(Context context, Version version) { - int instance = getActiveServer(context); - Version current = SERVER_REST_VERSIONS.get(instance); - if(current != version) { - SERVER_REST_VERSIONS.put(instance, version); - SharedPreferences.Editor editor = getPreferences(context).edit(); - editor.putString(Constants.PREFERENCES_KEY_SERVER_VERSION + instance, version.getVersion()); - editor.commit(); - } - } - - public static Version getServerRestVersion(Context context) { - int instance = getActiveServer(context); - Version version = SERVER_REST_VERSIONS.get(instance); - if(version == null) { - SharedPreferences prefs = getPreferences(context); - String versionString = prefs.getString(Constants.PREFERENCES_KEY_SERVER_VERSION + instance, null); - if(versionString != null && versionString != "") { - version = new Version(versionString); - SERVER_REST_VERSIONS.put(instance, version); - } - } - return version; - } - public static void setSelectedMusicFolderId(Context context, String musicFolderId) { int instance = getActiveServer(context); SharedPreferences prefs = getPreferences(context); @@ -564,35 +532,9 @@ public final class Util { return count; } - public static void atomicCopy(File from, File to) throws IOException { - FileInputStream in = null; - FileOutputStream out = null; - File tmp = null; - try { - tmp = new File(to.getPath() + ".tmp"); - in = new FileInputStream(from); - out = new FileOutputStream(tmp); - in.getChannel().transferTo(0, from.length(), out.getChannel()); - out.close(); - if (!tmp.renameTo(to)) { - throw new IOException("Failed to rename " + tmp + " to " + to); - } - Log.i(TAG, "Copied " + from + " to " + to); - } catch (IOException x) { - close(out); - delete(to); - throw x; - } finally { - close(in); - close(out); - delete(tmp); - } - } public static void renameFile(File from, File to) throws IOException { - if(from.renameTo(to)) { - Log.i(TAG, "Renamed " + from + " to " + to); - } else { - atomicCopy(from, to); + if(!from.renameTo(to)) { + Log.i(TAG, "Failed to rename " + from + " to " + to); } } diff --git a/src/github/daneren2005/dsub/view/AlbumListAdapter.java b/src/github/daneren2005/dsub/view/AlbumListAdapter.java index 308eb7d7..6c3b2f73 100644 --- a/src/github/daneren2005/dsub/view/AlbumListAdapter.java +++ b/src/github/daneren2005/dsub/view/AlbumListAdapter.java @@ -26,6 +26,7 @@ import android.widget.ArrayAdapter; import com.commonsware.cwac.endless.EndlessAdapter;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.domain.ServerInfo;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.Util;
@@ -55,7 +56,7 @@ public class AlbumListAdapter extends EndlessAdapter { protected boolean cacheInBackground() throws Exception {
MusicService service = MusicServiceFactory.getMusicService(context);
MusicDirectory result;
- if(("genres".equals(type) && Util.checkServerVersion(context, "1.10.0")) || "years".equals(type)) {
+ if(("genres".equals(type) && ServerInfo.checkServerVersion(context, "1.10.0")) || "years".equals(type)) {
result = service.getAlbumList(type, extra, size, offset, context, null);
} else if("genres".equals(type) || "genres-songs".equals(type)) {
result = service.getSongsByGenre(extra, size, offset, context, null);
diff --git a/src/github/daneren2005/dsub/view/SettingView.java b/src/github/daneren2005/dsub/view/SettingView.java index 70fb4715..ea89fb01 100644 --- a/src/github/daneren2005/dsub/view/SettingView.java +++ b/src/github/daneren2005/dsub/view/SettingView.java @@ -70,6 +70,8 @@ public class SettingView extends UpdateView { res = R.string.admin_role_jukebox;
} else if(User.SHARE.equals(name)) {
res = R.string.admin_role_share;
+ } else if(User.LASTFM.equals(name)) {
+ res = R.string.admin_role_lastfm;
} else {
// Last resort to display the raw value
view.setText(name);
|