aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github/daneren2005/subphonic/service/parser
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-08-14 20:29:07 -0700
committerScott Jackson <daneren2005@gmail.com>2012-08-14 20:29:07 -0700
commit973110dedc9bd4cb68fe82a80304e5ff20192a32 (patch)
treede56a4f15972ff3b3438aeca80b7e44e43b0e626 /subsonic-android/src/github/daneren2005/subphonic/service/parser
parent4ce59daa35f0e8a04d134fa300589702823de1ba (diff)
downloaddsub-973110dedc9bd4cb68fe82a80304e5ff20192a32.tar.gz
dsub-973110dedc9bd4cb68fe82a80304e5ff20192a32.tar.bz2
dsub-973110dedc9bd4cb68fe82a80304e5ff20192a32.zip
Changed package name to subdroid to avoid getting banned by Google for being to similar to subphonic
Diffstat (limited to 'subsonic-android/src/github/daneren2005/subphonic/service/parser')
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/AbstractParser.java138
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/AlbumListParser.java62
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/ErrorParser.java49
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/IndexesParser.java104
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/JukeboxStatusParser.java62
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/LicenseParser.java62
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/LyricsParser.java65
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryEntryParser.java59
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryParser.java71
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicFoldersParser.java69
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistParser.java62
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistsParser.java67
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/RandomSongsParser.java62
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResult2Parser.java75
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResultParser.java67
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/SubsonicRESTException.java19
-rw-r--r--subsonic-android/src/github/daneren2005/subphonic/service/parser/VersionParser.java47
17 files changed, 0 insertions, 1140 deletions
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/AbstractParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/AbstractParser.java
deleted file mode 100644
index 59acb60f..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/AbstractParser.java
+++ /dev/null
@@ -1,138 +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.subphonic.service.parser;
-
-import java.io.Reader;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import android.content.Context;
-import android.util.Xml;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.Version;
-import github.daneren2005.subphonic.util.ProgressListener;
-import github.daneren2005.subphonic.util.Util;
-
-/**
- * @author Sindre Mehus
- */
-public abstract class AbstractParser {
-
- private final Context context;
- private XmlPullParser parser;
- private boolean rootElementFound;
-
- public AbstractParser(Context context) {
- this.context = context;
- }
-
- protected Context getContext() {
- return context;
- }
-
- protected void handleError() throws Exception {
- int code = getInteger("code");
- String message;
- switch (code) {
- case 20:
- message = context.getResources().getString(R.string.parser_upgrade_client);
- break;
- case 30:
- message = context.getResources().getString(R.string.parser_upgrade_server);
- break;
- case 40:
- message = context.getResources().getString(R.string.parser_not_authenticated);
- break;
- case 50:
- message = context.getResources().getString(R.string.parser_not_authorized);
- break;
- default:
- message = get("message");
- break;
- }
- throw new SubsonicRESTException(code, message);
- }
-
- protected void updateProgress(ProgressListener progressListener, int messageId) {
- if (progressListener != null) {
- progressListener.updateProgress(messageId);
- }
- }
-
- protected void updateProgress(ProgressListener progressListener, String message) {
- if (progressListener != null) {
- progressListener.updateProgress(message);
- }
- }
-
- protected String getText() {
- return parser.getText();
- }
-
- protected String get(String name) {
- return parser.getAttributeValue(null, name);
- }
-
- protected boolean getBoolean(String name) {
- return "true".equals(get(name));
- }
-
- protected Integer getInteger(String name) {
- String s = get(name);
- return s == null ? null : Integer.valueOf(s);
- }
-
- protected Long getLong(String name) {
- String s = get(name);
- return s == null ? null : Long.valueOf(s);
- }
-
- protected Float getFloat(String name) {
- String s = get(name);
- return s == null ? null : Float.valueOf(s);
- }
-
- protected void init(Reader reader) throws Exception {
- parser = Xml.newPullParser();
- parser.setInput(reader);
- rootElementFound = false;
- }
-
- protected int nextParseEvent() throws Exception {
- return parser.next();
- }
-
- protected String getElementName() {
- String name = parser.getName();
- if ("subsonic-response".equals(name)) {
- rootElementFound = true;
- String version = get("version");
- if (version != null) {
- Util.setServerRestVersion(context, new Version(version));
- }
- }
- return name;
- }
-
- protected void validate() throws Exception {
- if (!rootElementFound) {
- throw new Exception(context.getResources().getString(R.string.background_task_parse_error));
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/AlbumListParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/AlbumListParser.java
deleted file mode 100644
index f021fc68..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/AlbumListParser.java
+++ /dev/null
@@ -1,62 +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.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.MusicDirectory;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-
-/**
- * @author Sindre Mehus
- */
-public class AlbumListParser extends MusicDirectoryEntryParser {
-
- public AlbumListParser(Context context) {
- super(context);
- }
-
- public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
-
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- MusicDirectory dir = new MusicDirectory();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("album".equals(name)) {
- dir.addChild(parseEntry());
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- return dir;
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/ErrorParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/ErrorParser.java
deleted file mode 100644
index 5e2bc154..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/ErrorParser.java
+++ /dev/null
@@ -1,49 +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.subphonic.service.parser;
-
-import android.content.Context;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-
-/**
- * @author Sindre Mehus
- */
-public class ErrorParser extends AbstractParser {
-
- public ErrorParser(Context context) {
- super(context);
- }
-
- public void parse(Reader reader) throws Exception {
-
- init(reader);
-
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG && "error".equals(getElementName())) {
- handleError();
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/IndexesParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/IndexesParser.java
deleted file mode 100644
index 7a9d8385..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/IndexesParser.java
+++ /dev/null
@@ -1,104 +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.subphonic.service.parser;
-
-import java.io.Reader;
-import java.util.List;
-import java.util.ArrayList;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.Artist;
-import github.daneren2005.subphonic.domain.Indexes;
-import github.daneren2005.subphonic.util.ProgressListener;
-import android.util.Log;
-
-/**
- * @author Sindre Mehus
- */
-public class IndexesParser extends AbstractParser {
- private static final String TAG = IndexesParser.class.getSimpleName();
-
- public IndexesParser(Context context) {
- super(context);
- }
-
- public Indexes parse(Reader reader, ProgressListener progressListener) throws Exception {
-
- long t0 = System.currentTimeMillis();
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- List<Artist> artists = new ArrayList<Artist>();
- List<Artist> shortcuts = new ArrayList<Artist>();
- Long lastModified = null;
- int eventType;
- String index = "#";
- boolean changed = false;
-
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("indexes".equals(name)) {
- changed = true;
- lastModified = getLong("lastModified");
- } else if ("index".equals(name)) {
- index = get("name");
-
- } else if ("artist".equals(name)) {
- Artist artist = new Artist();
- artist.setId(get("id"));
- artist.setName(get("name"));
- artist.setIndex(index);
- artists.add(artist);
-
- if (artists.size() % 10 == 0) {
- String msg = getContext().getResources().getString(R.string.parser_artist_count, artists.size());
- updateProgress(progressListener, msg);
- }
- } else if ("shortcut".equals(name)) {
- Artist shortcut = new Artist();
- shortcut.setId(get("id"));
- shortcut.setName(get("name"));
- shortcut.setIndex("*");
- shortcuts.add(shortcut);
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
-
- if (!changed) {
- return null;
- }
-
- long t1 = System.currentTimeMillis();
- Log.d(TAG, "Got " + artists.size() + " artist(s) in " + (t1 - t0) + "ms.");
-
- String msg = getContext().getResources().getString(R.string.parser_artist_count, artists.size());
- updateProgress(progressListener, msg);
-
- return new Indexes(lastModified == null ? 0L : lastModified, shortcuts, artists);
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/JukeboxStatusParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/JukeboxStatusParser.java
deleted file mode 100644
index eed7e4a6..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/JukeboxStatusParser.java
+++ /dev/null
@@ -1,62 +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.subphonic.service.parser;
-
-import java.io.Reader;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.domain.JukeboxStatus;
-
-/**
- * @author Sindre Mehus
- */
-public class JukeboxStatusParser extends AbstractParser {
-
- public JukeboxStatusParser(Context context) {
- super(context);
- }
-
- public JukeboxStatus parse(Reader reader) throws Exception {
-
- init(reader);
-
- JukeboxStatus jukeboxStatus = new JukeboxStatus();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("jukeboxPlaylist".equals(name) || "jukeboxStatus".equals(name)) {
- jukeboxStatus.setPositionSeconds(getInteger("position"));
- jukeboxStatus.setCurrentIndex(getInteger("currentIndex"));
- jukeboxStatus.setPlaying(getBoolean("playing"));
- jukeboxStatus.setGain(getFloat("gain"));
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
-
- return jukeboxStatus;
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/LicenseParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/LicenseParser.java
deleted file mode 100644
index 22b82f24..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/LicenseParser.java
+++ /dev/null
@@ -1,62 +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.subphonic.service.parser;
-
-import android.content.Context;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-
-import github.daneren2005.subphonic.domain.ServerInfo;
-import github.daneren2005.subphonic.domain.Version;
-
-/**
- * @author Sindre Mehus
- */
-public class LicenseParser extends AbstractParser {
-
- public LicenseParser(Context context) {
- super(context);
- }
-
- public ServerInfo parse(Reader reader) throws Exception {
-
- init(reader);
-
- ServerInfo serverInfo = new ServerInfo();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("subsonic-response".equals(name)) {
- serverInfo.setRestVersion(new Version(get("version")));
- } else if ("license".equals(name)) {
- serverInfo.setLicenseValid(getBoolean("valid"));
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
-
- return serverInfo;
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/LyricsParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/LyricsParser.java
deleted file mode 100644
index be0c498a..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/LyricsParser.java
+++ /dev/null
@@ -1,65 +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 2010 (C) Sindre Mehus
- */
-package github.daneren2005.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.Lyrics;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-
-/**
- * @author Sindre Mehus
- */
-public class LyricsParser extends AbstractParser {
-
- public LyricsParser(Context context) {
- super(context);
- }
-
- public Lyrics parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- Lyrics lyrics = null;
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("lyrics".equals(name)) {
- lyrics = new Lyrics();
- lyrics.setArtist(get("artist"));
- lyrics.setTitle(get("title"));
- } else if ("error".equals(name)) {
- handleError();
- }
- } else if (eventType == XmlPullParser.TEXT) {
- if (lyrics != null && lyrics.getText() == null) {
- lyrics.setText(getText());
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- return lyrics;
- }
-}
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryEntryParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryEntryParser.java
deleted file mode 100644
index 22b8a2da..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryEntryParser.java
+++ /dev/null
@@ -1,59 +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.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.domain.MusicDirectory;
-
-/**
- * @author Sindre Mehus
- */
-public class MusicDirectoryEntryParser extends AbstractParser {
-
- public MusicDirectoryEntryParser(Context context) {
- super(context);
- }
-
- protected MusicDirectory.Entry parseEntry() {
- MusicDirectory.Entry entry = new MusicDirectory.Entry();
- entry.setId(get("id"));
- entry.setParent(get("parent"));
- entry.setTitle(get("title"));
- entry.setDirectory(getBoolean("isDir"));
- entry.setCoverArt(get("coverArt"));
- entry.setArtist(get("artist"));
-
- if (!entry.isDirectory()) {
- entry.setAlbum(get("album"));
- entry.setTrack(getInteger("track"));
- entry.setYear(getInteger("year"));
- entry.setGenre(get("genre"));
- entry.setContentType(get("contentType"));
- entry.setSuffix(get("suffix"));
- entry.setTranscodedContentType(get("transcodedContentType"));
- entry.setTranscodedSuffix(get("transcodedSuffix"));
- entry.setSize(getLong("size"));
- entry.setDuration(getInteger("duration"));
- entry.setBitRate(getInteger("bitRate"));
- entry.setPath(get("path"));
- entry.setVideo(getBoolean("isVideo"));
- }
- return entry;
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryParser.java
deleted file mode 100644
index feffce37..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicDirectoryParser.java
+++ /dev/null
@@ -1,71 +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.subphonic.service.parser;
-
-import android.content.Context;
-import android.util.Log;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.MusicDirectory;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-
-/**
- * @author Sindre Mehus
- */
-public class MusicDirectoryParser extends MusicDirectoryEntryParser {
-
- private static final String TAG = MusicDirectoryParser.class.getSimpleName();
-
- public MusicDirectoryParser(Context context) {
- super(context);
- }
-
- public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
-
- long t0 = System.currentTimeMillis();
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- MusicDirectory dir = new MusicDirectory();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("child".equals(name)) {
- dir.addChild(parseEntry());
- } else if ("directory".equals(name)) {
- dir.setName(get("name"));
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- long t1 = System.currentTimeMillis();
- Log.d(TAG, "Got music directory in " + (t1 - t0) + "ms.");
-
- return dir;
- }
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicFoldersParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicFoldersParser.java
deleted file mode 100644
index e3447ddf..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/MusicFoldersParser.java
+++ /dev/null
@@ -1,69 +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.subphonic.service.parser;
-
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.xmlpull.v1.XmlPullParser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.MusicFolder;
-import github.daneren2005.subphonic.domain.Playlist;
-import github.daneren2005.subphonic.util.ProgressListener;
-
-/**
- * @author Sindre Mehus
- */
-public class MusicFoldersParser extends AbstractParser {
-
- public MusicFoldersParser(Context context) {
- super(context);
- }
-
- public List<MusicFolder> parse(Reader reader, ProgressListener progressListener) throws Exception {
-
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- List<MusicFolder> result = new ArrayList<MusicFolder>();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String tag = getElementName();
- if ("musicFolder".equals(tag)) {
- String id = get("id");
- String name = get("name");
- result.add(new MusicFolder(id, name));
- } else if ("error".equals(tag)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- return result;
- }
-
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistParser.java
deleted file mode 100644
index 84be75ff..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistParser.java
+++ /dev/null
@@ -1,62 +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.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.MusicDirectory;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-
-/**
- * @author Sindre Mehus
- */
-public class PlaylistParser extends MusicDirectoryEntryParser {
-
- public PlaylistParser(Context context) {
- super(context);
- }
-
- public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- MusicDirectory dir = new MusicDirectory();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("entry".equals(name)) {
- dir.addChild(parseEntry());
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- return dir;
- }
-
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistsParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistsParser.java
deleted file mode 100644
index 16592ced..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/PlaylistsParser.java
+++ /dev/null
@@ -1,67 +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.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.Playlist;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Sindre Mehus
- */
-public class PlaylistsParser extends AbstractParser {
-
- public PlaylistsParser(Context context) {
- super(context);
- }
-
- public List<Playlist> parse(Reader reader, ProgressListener progressListener) throws Exception {
-
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- List<Playlist> result = new ArrayList<Playlist>();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String tag = getElementName();
- if ("playlist".equals(tag)) {
- String id = get("id");
- String name = get("name");
- result.add(new Playlist(id, name));
- } else if ("error".equals(tag)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- return result;
- }
-
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/RandomSongsParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/RandomSongsParser.java
deleted file mode 100644
index 9a318754..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/RandomSongsParser.java
+++ /dev/null
@@ -1,62 +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.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.MusicDirectory;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-
-/**
- * @author Sindre Mehus
- */
-public class RandomSongsParser extends MusicDirectoryEntryParser {
-
- public RandomSongsParser(Context context) {
- super(context);
- }
-
- public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- MusicDirectory dir = new MusicDirectory();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("song".equals(name)) {
- dir.addChild(parseEntry());
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- return dir;
- }
-
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResult2Parser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResult2Parser.java
deleted file mode 100644
index 535ea8ac..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResult2Parser.java
+++ /dev/null
@@ -1,75 +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.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.MusicDirectory;
-import github.daneren2005.subphonic.domain.SearchResult;
-import github.daneren2005.subphonic.domain.Artist;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Sindre Mehus
- */
-public class SearchResult2Parser extends MusicDirectoryEntryParser {
-
- public SearchResult2Parser(Context context) {
- super(context);
- }
-
- public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- List<Artist> artists = new ArrayList<Artist>();
- List<MusicDirectory.Entry> albums = new ArrayList<MusicDirectory.Entry>();
- List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("artist".equals(name)) {
- Artist artist = new Artist();
- artist.setId(get("id"));
- artist.setName(get("name"));
- artists.add(artist);
- } else if ("album".equals(name)) {
- albums.add(parseEntry());
- } else if ("song".equals(name)) {
- songs.add(parseEntry());
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- return new SearchResult(artists, albums, songs);
- }
-
-} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResultParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResultParser.java
deleted file mode 100644
index 57a19d16..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/SearchResultParser.java
+++ /dev/null
@@ -1,67 +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.subphonic.service.parser;
-
-import android.content.Context;
-import github.daneren2005.subphonic.R;
-import github.daneren2005.subphonic.domain.MusicDirectory;
-import github.daneren2005.subphonic.domain.SearchResult;
-import github.daneren2005.subphonic.domain.Artist;
-import github.daneren2005.subphonic.util.ProgressListener;
-import org.xmlpull.v1.XmlPullParser;
-
-import java.io.Reader;
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Sindre Mehus
- */
-public class SearchResultParser extends MusicDirectoryEntryParser {
-
- public SearchResultParser(Context context) {
- super(context);
- }
-
- public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
- init(reader);
-
- List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>();
- int eventType;
- do {
- eventType = nextParseEvent();
- if (eventType == XmlPullParser.START_TAG) {
- String name = getElementName();
- if ("match".equals(name)) {
- songs.add(parseEntry());
- } else if ("error".equals(name)) {
- handleError();
- }
- }
- } while (eventType != XmlPullParser.END_DOCUMENT);
-
- validate();
- updateProgress(progressListener, R.string.parser_reading_done);
-
- return new SearchResult(Collections.<Artist>emptyList(), Collections.<MusicDirectory.Entry>emptyList(), songs);
- }
-
-}
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/SubsonicRESTException.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/SubsonicRESTException.java
deleted file mode 100644
index 0a651ef2..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/service/parser/SubsonicRESTException.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package github.daneren2005.subphonic.service.parser;
-
-/**
- * @author Sindre Mehus
- * @version $Id$
- */
-public class SubsonicRESTException extends Exception {
-
- private final int code;
-
- public SubsonicRESTException(int code, String message) {
- super(message);
- this.code = code;
- }
-
- public int getCode() {
- return code;
- }
-}
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/parser/VersionParser.java b/subsonic-android/src/github/daneren2005/subphonic/service/parser/VersionParser.java
deleted file mode 100644
index 6d28ff7e..00000000
--- a/subsonic-android/src/github/daneren2005/subphonic/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.subphonic.service.parser;
-
-import github.daneren2005.subphonic.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