1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

new methods in API: book info for an arbitrary book

This commit is contained in:
Nikolay Pultsin 2012-01-24 23:55:52 +00:00
parent 9a3ae79474
commit 938c631afb
5 changed files with 132 additions and 13 deletions

View file

@ -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<String> getBookAuthors() throws ApiException;
List<String> 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<String> getBookAuthors(long id) throws ApiException;
List<String> 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;

View file

@ -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<String> 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);
}

View file

@ -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

View file

@ -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:

View file

@ -67,17 +67,41 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
);
return ApiObject.Void.Instance;
case GET_BOOK_LANGUAGE:
if (parameters.length == 0) {
return ApiObject.envelope(getBookLanguage());
} else {
return ApiObject.envelope(getBookLanguage(((ApiObject.Long)parameters[0]).Value));
}
case GET_BOOK_TITLE:
if (parameters.length == 0) {
return ApiObject.envelope(getBookTitle());
} else {
return ApiObject.envelope(getBookTitle(((ApiObject.Long)parameters[0]).Value));
}
case GET_BOOK_FILE_PATH:
if (parameters.length == 0) {
return ApiObject.envelope(getBookFilePath());
} else {
return ApiObject.envelope(getBookFilePath(((ApiObject.Long)parameters[0]).Value));
}
case GET_BOOK_HASH:
if (parameters.length == 0) {
return ApiObject.envelope(getBookHash());
case GET_BOOK_ID:
return ApiObject.envelope(getBookId());
} 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:
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<String> 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());