aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github/daneren2005')
-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"));