aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-04-26 21:25:42 -0700
committerScott Jackson <daneren2005@gmail.com>2016-04-26 21:25:42 -0700
commitca5d525b3efb7fcdc8ee00b4324a534dc443a034 (patch)
tree4d43b065014f4ad6771f1b6d072a23975c39ad54
parentfa30b8dd4caff884cee6b8f787434efeabbdc1c2 (diff)
downloaddsub-ca5d525b3efb7fcdc8ee00b4324a534dc443a034.tar.gz
dsub-ca5d525b3efb7fcdc8ee00b4324a534dc443a034.tar.bz2
dsub-ca5d525b3efb7fcdc8ee00b4324a534dc443a034.zip
Add Ampache to list of server checks
-rw-r--r--app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java8
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java14
2 files changed, 19 insertions, 3 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
index 73037c4a..e4c9b17d 100644
--- a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
+++ b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java
@@ -35,6 +35,7 @@ import github.daneren2005.dsub.util.Util;
public class ServerInfo implements Serializable {
public static final int TYPE_SUBSONIC = 1;
public static final int TYPE_MADSONIC = 2;
+ public static final int TYPE_AMPACHE = 3;
private static final Map<Integer, ServerInfo> SERVERS = new ConcurrentHashMap<Integer, ServerInfo>();
private boolean isLicenseValid;
@@ -189,6 +190,13 @@ public class ServerInfo implements Serializable {
public static boolean isMadsonic6(Context context, int instance) {
return getServerType(context, instance) == TYPE_MADSONIC && checkServerVersion(context, "2.0", instance);
}
+
+ public static boolean isAmpache(Context context) {
+ return isAmpache(context, Util.getActiveServer(context));
+ }
+ public static boolean isAmpache(Context context, int instance) {
+ return getServerType(context, instance) == TYPE_AMPACHE;
+ }
private static String getCacheName(Context context, int instance) {
return "server-" + Util.getRestUrl(context, null, instance, false).hashCode() + ".ser";
diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java
index 664adcfb..4ee37dad 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/parser/AbstractParser.java
@@ -36,6 +36,12 @@ import github.daneren2005.dsub.util.Util;
*/
public abstract class AbstractParser {
private static final String TAG = AbstractParser.class.getSimpleName();
+ private static final String SUBSONIC_RESPONSE = "subsonic-response";
+ private static final String MADSONIC_RESPONSE = "madsonic-response";
+ private static final String SUBSONIC = "subsonic";
+ private static final String MADSONIC = "madsonic";
+ private static final String AMPACHE = "ampache";
+
protected final Context context;
protected final int instance;
private XmlPullParser parser;
@@ -132,16 +138,18 @@ public abstract class AbstractParser {
protected String getElementName() {
String name = parser.getName();
- if ("subsonic-response".equals(name) || "madsonic-response".equals(name)) {
+ if (SUBSONIC_RESPONSE.equals(name) || MADSONIC_RESPONSE.equals(name)) {
rootElementFound = true;
String version = get("version");
if (version != null) {
ServerInfo server = new ServerInfo();
server.setRestVersion(new Version(version));
- if("madsonic".equals(get("type")) || "madsonic-response".equals(name)) {
+ if(MADSONIC.equals(get("type")) || MADSONIC_RESPONSE.equals(name)) {
server.setRestType(ServerInfo.TYPE_MADSONIC);
- } else if("subsonic".equals(get("type")) && server.checkServerVersion(context, "1.13")) {
+ } if(AMPACHE.equals(get("type"))) {
+ server.setRestType(ServerInfo.TYPE_AMPACHE);
+ } else if(SUBSONIC.equals(get("type")) && server.checkServerVersion(context, "1.13")) {
// Oh am I going to regret this
server.setRestType(ServerInfo.TYPE_MADSONIC);
server.setRestVersion(new Version("2.0.0"));