diff --git a/src/org/geometerplus/android/fbreader/api/Api.java b/src/org/geometerplus/android/fbreader/api/Api.java index 52263ee0d..328900836 100644 --- a/src/org/geometerplus/android/fbreader/api/Api.java +++ b/src/org/geometerplus/android/fbreader/api/Api.java @@ -17,16 +17,26 @@ public interface Api { String getOptionValue(String group, String name) throws ApiException; void setOptionValue(String group, String name, String value) throws ApiException; - // book information + // book information for current book String getBookLanguage() throws ApiException; String getBookTitle() throws ApiException; //List getBookAuthors() throws ApiException; List getBookTags() throws ApiException; String getBookFilePath() throws ApiException; String getBookHash() throws ApiException; - String getBookId() throws ApiException; + String getBookUniqueId() throws ApiException; Date getBookLastTurningTime() throws ApiException; + // book information for book defined by id + String getBookLanguage(long id) throws ApiException; + String getBookTitle(long id) throws ApiException; + //List getBookAuthors(long id) throws ApiException; + List getBookTags(long id) throws ApiException; + String getBookFilePath(long id) throws ApiException; + String getBookHash(long id) throws ApiException; + String getBookUniqueId(long id) throws ApiException; + Date getBookLastTurningTime(long id) throws ApiException; + // text information int getParagraphsNumber() throws ApiException; int getElementsNumber(int paragraphIndex) throws ApiException; diff --git a/src/org/geometerplus/android/fbreader/api/ApiClientImplementation.java b/src/org/geometerplus/android/fbreader/api/ApiClientImplementation.java index d426cb0f4..de5277dba 100644 --- a/src/org/geometerplus/android/fbreader/api/ApiClientImplementation.java +++ b/src/org/geometerplus/android/fbreader/api/ApiClientImplementation.java @@ -229,14 +229,42 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho return requestString(GET_BOOK_HASH, EMPTY_PARAMETERS); } - public String getBookId() throws ApiException { - return requestString(GET_BOOK_ID, EMPTY_PARAMETERS); + public String getBookUniqueId() throws ApiException { + return requestString(GET_BOOK_UNIQUE_ID, EMPTY_PARAMETERS); } public Date getBookLastTurningTime() throws ApiException { return requestDate(GET_BOOK_LAST_TURNING_TIME, EMPTY_PARAMETERS); } + public String getBookLanguage(long id) throws ApiException { + return requestString(GET_BOOK_LANGUAGE, EMPTY_PARAMETERS); + } + + public String getBookTitle(long id) throws ApiException { + return requestString(GET_BOOK_TITLE, EMPTY_PARAMETERS); + } + + public List getBookTags(long id) throws ApiException { + return requestStringList(GET_BOOK_TAGS, EMPTY_PARAMETERS); + } + + public String getBookFilePath(long id) throws ApiException { + return requestString(GET_BOOK_FILE_PATH, EMPTY_PARAMETERS); + } + + public String getBookHash(long id) throws ApiException { + return requestString(GET_BOOK_HASH, EMPTY_PARAMETERS); + } + + public String getBookUniqueId(long id) throws ApiException { + return requestString(GET_BOOK_UNIQUE_ID, EMPTY_PARAMETERS); + } + + public Date getBookLastTurningTime(long id) throws ApiException { + return requestDate(GET_BOOK_LAST_TURNING_TIME, EMPTY_PARAMETERS); + } + public TextPosition getPageStart() throws ApiException { return requestTextPosition(GET_PAGE_START, EMPTY_PARAMETERS); } diff --git a/src/org/geometerplus/android/fbreader/api/ApiMethods.java b/src/org/geometerplus/android/fbreader/api/ApiMethods.java index 4341bc910..08941341f 100644 --- a/src/org/geometerplus/android/fbreader/api/ApiMethods.java +++ b/src/org/geometerplus/android/fbreader/api/ApiMethods.java @@ -27,7 +27,7 @@ interface ApiMethods { int GET_BOOK_TAGS = 504; int GET_BOOK_FILE_PATH = 505; int GET_BOOK_HASH = 506; - int GET_BOOK_ID = 507; + int GET_BOOK_UNIQUE_ID = 507; int GET_BOOK_LAST_TURNING_TIME = 508; // text information diff --git a/src/org/geometerplus/android/fbreader/api/ApiObject.java b/src/org/geometerplus/android/fbreader/api/ApiObject.java index 7472864a3..8d6623f65 100644 --- a/src/org/geometerplus/android/fbreader/api/ApiObject.java +++ b/src/org/geometerplus/android/fbreader/api/ApiObject.java @@ -18,6 +18,7 @@ public abstract class ApiObject implements Parcelable { int STRING = 2; int BOOLEAN = 3; int DATE = 4; + int LONG = 5; int TEXT_POSITION = 10; } @@ -52,6 +53,25 @@ public abstract class ApiObject implements Parcelable { } } + static class Long extends ApiObject { + final long Value; + + Long(long value) { + Value = value; + } + + @Override + protected int type() { + return Type.LONG; + } + + @Override + public void writeToParcel(Parcel parcel, int flags) { + super.writeToParcel(parcel, flags); + parcel.writeLong(Value); + } + } + static class Boolean extends ApiObject { final boolean Value; @@ -175,6 +195,8 @@ public abstract class ApiObject implements Parcelable { return Void.Instance; case Type.INT: return new Integer(parcel.readInt()); + case Type.LONG: + return new Long(parcel.readLong()); case Type.BOOLEAN: return new Boolean(parcel.readByte() == 1); case Type.DATE: diff --git a/src/org/geometerplus/android/fbreader/api/ApiServerImplementation.java b/src/org/geometerplus/android/fbreader/api/ApiServerImplementation.java index 7a81a5ae4..a229fec5c 100644 --- a/src/org/geometerplus/android/fbreader/api/ApiServerImplementation.java +++ b/src/org/geometerplus/android/fbreader/api/ApiServerImplementation.java @@ -67,17 +67,41 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A ); return ApiObject.Void.Instance; case GET_BOOK_LANGUAGE: - return ApiObject.envelope(getBookLanguage()); + if (parameters.length == 0) { + return ApiObject.envelope(getBookLanguage()); + } else { + return ApiObject.envelope(getBookLanguage(((ApiObject.Long)parameters[0]).Value)); + } case GET_BOOK_TITLE: - return ApiObject.envelope(getBookTitle()); + if (parameters.length == 0) { + return ApiObject.envelope(getBookTitle()); + } else { + return ApiObject.envelope(getBookTitle(((ApiObject.Long)parameters[0]).Value)); + } case GET_BOOK_FILE_PATH: - return ApiObject.envelope(getBookFilePath()); + if (parameters.length == 0) { + return ApiObject.envelope(getBookFilePath()); + } else { + return ApiObject.envelope(getBookFilePath(((ApiObject.Long)parameters[0]).Value)); + } case GET_BOOK_HASH: - return ApiObject.envelope(getBookHash()); - case GET_BOOK_ID: - return ApiObject.envelope(getBookId()); + if (parameters.length == 0) { + return ApiObject.envelope(getBookHash()); + } else { + return ApiObject.envelope(getBookHash(((ApiObject.Long)parameters[0]).Value)); + } + case GET_BOOK_UNIQUE_ID: + if (parameters.length == 0) { + return ApiObject.envelope(getBookUniqueId()); + } else { + return ApiObject.envelope(getBookUniqueId(((ApiObject.Long)parameters[0]).Value)); + } case GET_BOOK_LAST_TURNING_TIME: - return ApiObject.envelope(getBookLastTurningTime()); + if (parameters.length == 0) { + return ApiObject.envelope(getBookLastTurningTime()); + } else { + return ApiObject.envelope(getBookLastTurningTime(((ApiObject.Long)parameters[0]).Value)); + } case GET_PARAGRAPHS_NUMBER: return ApiObject.envelope(getParagraphsNumber()); case GET_ELEMENTS_NUMBER: @@ -192,7 +216,7 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A return myReader.Model.Book.getContentHashCode(); } - public String getBookId() { + public String getBookUniqueId() { // TODO: implement return null; } @@ -202,6 +226,41 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A return null; } + public String getBookLanguage(long id) { + // TODO: implement + return null; + } + + public String getBookTitle(long id) { + // TODO: implement + return null; + } + + public List getBookTags(long id) { + // TODO: implement + return Collections.emptyList(); + } + + public String getBookFilePath(long id) { + // TODO: implement + return null; + } + + public String getBookHash(long id) { + // TODO: implement + return null; + } + + public String getBookUniqueId(long id) { + // TODO: implement + return null; + } + + public Date getBookLastTurningTime(long id) { + // TODO: implement + return null; + } + // page information public TextPosition getPageStart() { return getTextPosition(myReader.getTextView().getStartCursor());