mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
'updated' field for all INetworkLink urls has been introduced
This commit is contained in:
parent
7c679882f4
commit
dad7b7e8e4
14 changed files with 97 additions and 89 deletions
|
@ -250,7 +250,7 @@ class NetworkCatalogActions extends NetworkTreeActions {
|
|||
{
|
||||
final ICustomNetworkLink link =
|
||||
(ICustomNetworkLink)((NetworkCatalogTree)tree).Item.Link;
|
||||
final String textUrl = link.getLink(INetworkLink.URL_MAIN);
|
||||
final String textUrl = link.getUrlInfo(INetworkLink.URL_MAIN).URL;
|
||||
if (textUrl != null) {
|
||||
activity.startActivity(
|
||||
new Intent(activity, AddCustomCatalogActivity.class)
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
|||
|
||||
import org.geometerplus.fbreader.network.ICustomNetworkLink;
|
||||
import org.geometerplus.fbreader.network.NetworkDatabase;
|
||||
import org.geometerplus.fbreader.network.URLInfo;
|
||||
|
||||
import org.geometerplus.android.util.SQLiteUtil;
|
||||
|
||||
|
@ -74,7 +75,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
|||
@Override
|
||||
protected void loadCustomLinks(ICustomLinksHandler handler) {
|
||||
final Cursor cursor = myDatabase.rawQuery("SELECT link_id,title,site_name,summary,icon FROM CustomLinks", null);
|
||||
final HashMap<String,String> linksMap = new HashMap<String,String>();
|
||||
final HashMap<String,URLInfo> linksMap = new HashMap<String,URLInfo>();
|
||||
while (cursor.moveToNext()) {
|
||||
final int id = cursor.getInt(0);
|
||||
final String title = cursor.getString(1);
|
||||
|
@ -83,9 +84,15 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
|||
final String icon = cursor.getString(4);
|
||||
|
||||
linksMap.clear();
|
||||
final Cursor linksCursor = myDatabase.rawQuery("SELECT key,url FROM LinkUrls WHERE url NOT NULL AND link_id = " + id, null);
|
||||
final Cursor linksCursor = myDatabase.rawQuery("SELECT key,url,update_time FROM LinkUrls WHERE url NOT NULL AND link_id = " + id, null);
|
||||
while (linksCursor.moveToNext()) {
|
||||
linksMap.put(linksCursor.getString(0), linksCursor.getString(1));
|
||||
linksMap.put(
|
||||
linksCursor.getString(0),
|
||||
new URLInfo(
|
||||
linksCursor.getString(1),
|
||||
SQLiteUtil.getDate(linksCursor, 2)
|
||||
)
|
||||
);
|
||||
}
|
||||
linksCursor.close();
|
||||
|
||||
|
@ -127,7 +134,7 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
|||
SQLiteUtil.bindString(statement, 4, link.getIcon());
|
||||
|
||||
final long id;
|
||||
final HashMap<String,String> linksMap = new HashMap<String,String>();
|
||||
final HashMap<String,URLInfo> linksMap = new HashMap<String,URLInfo>();
|
||||
|
||||
if (statement == myInsertCustomLinkStatement) {
|
||||
id = statement.executeInsert();
|
||||
|
@ -137,35 +144,42 @@ class SQLiteNetworkDatabase extends NetworkDatabase {
|
|||
statement.bindLong(5, id);
|
||||
statement.execute();
|
||||
|
||||
final Cursor linksCursor = myDatabase.rawQuery("SELECT key,url FROM LinkUrls WHERE url NOT NULL AND link_id = " + link.getId(), null);
|
||||
final Cursor linksCursor = myDatabase.rawQuery("SELECT key,url,update_time FROM LinkUrls WHERE url NOT NULL AND link_id = " + link.getId(), null);
|
||||
while (linksCursor.moveToNext()) {
|
||||
linksMap.put(linksCursor.getString(0), linksCursor.getString(1));
|
||||
linksMap.put(
|
||||
linksCursor.getString(0),
|
||||
new URLInfo(
|
||||
linksCursor.getString(1),
|
||||
SQLiteUtil.getDate(linksCursor, 2)
|
||||
)
|
||||
);
|
||||
}
|
||||
linksCursor.close();
|
||||
}
|
||||
|
||||
for (String key: link.getLinkKeys()) {
|
||||
final String value = link.getLink(key);
|
||||
final String dbValue = linksMap.remove(key);
|
||||
for (String key : link.getUrlKeys()) {
|
||||
final URLInfo info = link.getUrlInfo(key);
|
||||
final URLInfo dbInfo = linksMap.remove(key);
|
||||
final SQLiteStatement urlStatement;
|
||||
if (dbValue == null) {
|
||||
if (dbInfo == null) {
|
||||
if (myInsertCustomLinkUrlStatement == null) {
|
||||
myInsertCustomLinkUrlStatement = myDatabase.compileStatement(
|
||||
"INSERT OR REPLACE INTO LinkUrls(url,link_id,key) VALUES (?,?,?)");
|
||||
"INSERT OR REPLACE INTO LinkUrls(url,update_time,link_id,key) VALUES (?,?,?,?)");
|
||||
}
|
||||
urlStatement = myInsertCustomLinkUrlStatement;
|
||||
} else if (!value.equals(dbValue)) {
|
||||
} else if (!info.equals(dbInfo)) {
|
||||
if (myUpdateCustomLinkUrlStatement == null) {
|
||||
myUpdateCustomLinkUrlStatement = myDatabase.compileStatement(
|
||||
"UPDATE LinkUrls SET url = ? WHERE link_id = ? AND key = ?");
|
||||
"UPDATE LinkUrls SET url = ?, update_time = ? WHERE link_id = ? AND key = ?");
|
||||
}
|
||||
urlStatement = myUpdateCustomLinkUrlStatement;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
urlStatement.bindString(1, value);
|
||||
urlStatement.bindLong(2, id);
|
||||
urlStatement.bindString(3, key);
|
||||
SQLiteUtil.bindString(urlStatement, 1, info.URL);
|
||||
SQLiteUtil.bindDate(urlStatement, 2, info.Updated);
|
||||
urlStatement.bindLong(3, id);
|
||||
urlStatement.bindString(4, key);
|
||||
urlStatement.execute();
|
||||
}
|
||||
for (String key: linksMap.keySet()) {
|
||||
|
|
|
@ -49,7 +49,7 @@ abstract class Util implements UserRegistrationConstants {
|
|||
return testService(
|
||||
activity,
|
||||
REGISTRATION_ACTION,
|
||||
link.getLink(INetworkLink.URL_SIGN_UP)
|
||||
link.getUrlInfo(INetworkLink.URL_SIGN_UP).URL
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,12 @@ abstract class Util implements UserRegistrationConstants {
|
|||
try {
|
||||
final Intent intent = new Intent(
|
||||
REGISTRATION_ACTION,
|
||||
Uri.parse(link.getLink(INetworkLink.URL_SIGN_UP))
|
||||
Uri.parse(link.getUrlInfo(INetworkLink.URL_SIGN_UP).URL)
|
||||
);
|
||||
if (PackageUtil.canBeStarted(activity, intent)) {
|
||||
activity.startActivityForResult(new Intent(
|
||||
REGISTRATION_ACTION,
|
||||
Uri.parse(link.getLink(INetworkLink.URL_SIGN_UP))
|
||||
Uri.parse(link.getUrlInfo(INetworkLink.URL_SIGN_UP).URL)
|
||||
), USER_REGISTRATION_REQUEST_CODE);
|
||||
}
|
||||
} catch (ActivityNotFoundException e) {
|
||||
|
@ -93,7 +93,7 @@ abstract class Util implements UserRegistrationConstants {
|
|||
return testService(
|
||||
activity,
|
||||
SMS_REFILLING_ACTION,
|
||||
link.getLink(INetworkLink.URL_MAIN)
|
||||
link.getUrlInfo(INetworkLink.URL_MAIN).URL
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ abstract class Util implements UserRegistrationConstants {
|
|||
try {
|
||||
final Intent intent = new Intent(
|
||||
SMS_REFILLING_ACTION,
|
||||
Uri.parse(link.getLink(INetworkLink.URL_MAIN))
|
||||
Uri.parse(link.getUrlInfo(INetworkLink.URL_MAIN).URL)
|
||||
);
|
||||
final NetworkAuthenticationManager mgr = link.authenticationManager();
|
||||
if (mgr != null) {
|
||||
|
@ -117,7 +117,7 @@ abstract class Util implements UserRegistrationConstants {
|
|||
}
|
||||
|
||||
static boolean isBrowserAccountRefillingSupported(Activity activity, INetworkLink link) {
|
||||
return link.getLink(INetworkLink.URL_REFILL_ACCOUNT) != null;
|
||||
return link.getUrlInfo(INetworkLink.URL_REFILL_ACCOUNT).URL != null;
|
||||
}
|
||||
|
||||
static void openInBrowser(Context context, String url) {
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
|
||||
package org.geometerplus.fbreader.network;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.*;
|
||||
|
||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
||||
|
||||
|
@ -31,7 +29,7 @@ public abstract class AbstractNetworkLink implements INetworkLink {
|
|||
protected String mySummary;
|
||||
protected String myIcon;
|
||||
protected final String myLanguage;
|
||||
protected final TreeMap<String, String> myLinks;
|
||||
protected final TreeMap<String,URLInfo> myInfos;
|
||||
|
||||
/**
|
||||
* Creates new NetworkLink instance.
|
||||
|
@ -41,15 +39,15 @@ public abstract class AbstractNetworkLink implements INetworkLink {
|
|||
* @param summary description of the corresponding library item. Can be <code>null</code>.
|
||||
* @param icon string contains link's icon data/url. Can be <code>null</code>.
|
||||
* @param language language of the catalog. If <code>null</code> we assume this catalog is multilanguage.
|
||||
* @param links map contains URLs with their identifiers; must always contain one URL with <code>URL_MAIN</code> identifier
|
||||
* @param infos map contains URL infos with their identifiers; must always contain one URL with <code>URL_MAIN</code> identifier
|
||||
*/
|
||||
public AbstractNetworkLink(String siteName, String title, String summary, String icon, String language, Map<String, String> links) {
|
||||
public AbstractNetworkLink(String siteName, String title, String summary, String icon, String language, Map<String,URLInfo> infos) {
|
||||
mySiteName = siteName;
|
||||
myTitle = title;
|
||||
mySummary = summary;
|
||||
myIcon = icon;
|
||||
myLanguage = language != null ? language : "multi";
|
||||
myLinks = new TreeMap<String, String>(links);
|
||||
myInfos = new TreeMap<String,URLInfo>(infos);
|
||||
}
|
||||
|
||||
public final String getSiteName() {
|
||||
|
@ -72,12 +70,13 @@ public abstract class AbstractNetworkLink implements INetworkLink {
|
|||
return myLanguage;
|
||||
}
|
||||
|
||||
public final String getLink(String urlKey) {
|
||||
return myLinks.get(urlKey);
|
||||
public final URLInfo getUrlInfo(String urlKey) {
|
||||
final URLInfo info = myInfos.get(urlKey);
|
||||
return info != null ? info : URLInfo.NULL;
|
||||
}
|
||||
|
||||
public final Set<String> getLinkKeys() {
|
||||
return myLinks.keySet();
|
||||
public final Set<String> getUrlKeys() {
|
||||
return myInfos.keySet();
|
||||
}
|
||||
|
||||
public NetworkOperationData createOperationData(NetworkOperationData.OnNewItemListener listener) {
|
||||
|
@ -96,7 +95,7 @@ public abstract class AbstractNetworkLink implements INetworkLink {
|
|||
+ "; title=" + myTitle
|
||||
+ "; summary=" + mySummary
|
||||
+ "; icon=" + icon
|
||||
+ "; links=" + myLinks
|
||||
+ "; infos=" + myInfos
|
||||
+ "}";
|
||||
}
|
||||
|
||||
|
@ -114,7 +113,7 @@ public abstract class AbstractNetworkLink implements INetworkLink {
|
|||
|| !myTitle.equals(lnk.myTitle)
|
||||
|| !ZLMiscUtil.equals(mySummary, lnk.mySummary)
|
||||
|| !ZLMiscUtil.equals(myIcon, lnk.myIcon)
|
||||
|| !ZLMiscUtil.mapsEquals(myLinks, lnk.myLinks)) {
|
||||
|| !ZLMiscUtil.mapsEquals(myInfos, lnk.myInfos)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -32,8 +32,8 @@ public interface ICustomNetworkLink extends INetworkLink {
|
|||
void setSummary(String summary);
|
||||
void setIcon(String icon);
|
||||
|
||||
void setLink(String urlKey, String url);
|
||||
void removeLink(String urlKey);
|
||||
void setUrl(String urlKey, String url);
|
||||
void removeUrl(String urlKey);
|
||||
|
||||
void reloadInfo() throws ZLNetworkException;
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationMan
|
|||
|
||||
|
||||
public interface INetworkLink {
|
||||
|
||||
String URL_MAIN = "main";
|
||||
String URL_SEARCH = "search";
|
||||
String URL_SIGN_IN = "signIn";
|
||||
|
@ -41,15 +40,15 @@ public interface INetworkLink {
|
|||
String getTitle();
|
||||
String getSummary();
|
||||
String getIcon();
|
||||
String getLink(String urlKey);
|
||||
|
||||
URLInfo getUrlInfo(String urlKey);
|
||||
Set<String> getUrlKeys();
|
||||
|
||||
/**
|
||||
* @return 2-letters language code or special token "multi"
|
||||
*/
|
||||
String getLanguage();
|
||||
|
||||
Set<String> getLinkKeys();
|
||||
|
||||
/**
|
||||
* @param listener Network operation listener
|
||||
* @return instance, which represents the state of the network operation.
|
||||
|
|
|
@ -35,7 +35,7 @@ public abstract class NetworkDatabase {
|
|||
protected abstract void executeAsATransaction(Runnable actions);
|
||||
|
||||
public interface ICustomLinksHandler {
|
||||
void handleCustomLinkData(int id, String siteName, String title, String summary, String icon, Map<String, String> links);
|
||||
void handleCustomLinkData(int id, String siteName, String title, String summary, String icon, Map<String,URLInfo> infos);
|
||||
}
|
||||
|
||||
protected abstract void loadCustomLinks(ICustomLinksHandler handler);
|
||||
|
|
|
@ -179,8 +179,8 @@ public class NetworkLibrary {
|
|||
db.loadCustomLinks(
|
||||
new NetworkDatabase.ICustomLinksHandler() {
|
||||
public void handleCustomLinkData(int id, String siteName,
|
||||
String title, String summary, String icon, Map<String, String> links) {
|
||||
final ICustomNetworkLink link = OPDSLinkReader.createCustomLink(id, siteName, title, summary, icon, links);
|
||||
String title, String summary, String icon, Map<String,URLInfo> infos) {
|
||||
final ICustomNetworkLink link = OPDSLinkReader.createCustomLink(id, siteName, title, summary, icon, infos);
|
||||
if (link != null) {
|
||||
addLinkInternal(link);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.Serializable;
|
|||
|
||||
import org.geometerplus.zlibrary.core.constants.MimeTypes;
|
||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
||||
|
||||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
||||
|
@ -50,10 +51,7 @@ public abstract class NetworkTree extends FBTree {
|
|||
return false;
|
||||
}
|
||||
final NetworkTree.Key key = (NetworkTree.Key)other;
|
||||
if (Parent == null) {
|
||||
return key.Parent == null && Id.equals(key.Id);
|
||||
}
|
||||
return Id.equals(key.Id) && Parent.equals(key.Parent);
|
||||
return Id.equals(key.Id) && ZLMiscUtil.equals(Parent, key.Parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -89,7 +89,7 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
|||
sid = mySidOption.getValue();
|
||||
}
|
||||
|
||||
String url = Link.getLink(INetworkLink.URL_SIGN_IN);
|
||||
String url = Link.getUrlInfo(INetworkLink.URL_SIGN_IN).URL;
|
||||
if (url == null) {
|
||||
throw new ZLNetworkException(NetworkException.ERROR_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
|||
|
||||
@Override
|
||||
public void authorise(String password) throws ZLNetworkException {
|
||||
String url = Link.getLink(INetworkLink.URL_SIGN_IN);
|
||||
String url = Link.getUrlInfo(INetworkLink.URL_SIGN_IN).URL;
|
||||
if (url == null) {
|
||||
throw new ZLNetworkException(NetworkException.ERROR_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
|||
if (sid.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
final String url = Link.getLink(INetworkLink.URL_REFILL_ACCOUNT);
|
||||
final String url = Link.getUrlInfo(INetworkLink.URL_REFILL_ACCOUNT).URL;
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ public class LitResAuthenticationManager extends NetworkAuthenticationManager {
|
|||
|
||||
@Override
|
||||
public void recoverPassword(String email) throws ZLNetworkException {
|
||||
String url = Link.getLink(INetworkLink.URL_RECOVER_PASSWORD);
|
||||
String url = Link.getUrlInfo(INetworkLink.URL_RECOVER_PASSWORD).URL;
|
||||
if (url == null) {
|
||||
throw new ZLNetworkException(NetworkException.ERROR_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
|
|
@ -32,14 +32,15 @@ import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
|||
import org.geometerplus.fbreader.network.ICustomNetworkLink;
|
||||
import org.geometerplus.fbreader.network.INetworkLink;
|
||||
import org.geometerplus.fbreader.network.NetworkException;
|
||||
import org.geometerplus.fbreader.network.URLInfo;
|
||||
|
||||
class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLink {
|
||||
private int myId;
|
||||
|
||||
private boolean myHasChanges;
|
||||
|
||||
OPDSCustomLink(int id, String siteName, String title, String summary, String icon, Map<String, String> links) {
|
||||
super(siteName, title, summary, icon, null, links, false);
|
||||
OPDSCustomLink(int id, String siteName, String title, String summary, String icon, Map<String,URLInfo> infos) {
|
||||
super(siteName, title, summary, icon, null, infos, false);
|
||||
myId = id;
|
||||
}
|
||||
|
||||
|
@ -80,17 +81,13 @@ class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLink {
|
|||
myTitle = title;
|
||||
}
|
||||
|
||||
public final void setLink(String urlKey, String url) {
|
||||
if (url == null) {
|
||||
removeLink(urlKey);
|
||||
} else {
|
||||
final String oldUrl = myLinks.put(urlKey, url);
|
||||
myHasChanges = myHasChanges || !url.equals(oldUrl);
|
||||
}
|
||||
public final void setUrl(String urlKey, String url) {
|
||||
myInfos.put(urlKey, new URLInfo(url, new Date()));
|
||||
myHasChanges = true;
|
||||
}
|
||||
|
||||
public final void removeLink(String urlKey) {
|
||||
final String oldUrl = myLinks.remove(urlKey);
|
||||
public final void removeUrl(String urlKey) {
|
||||
final URLInfo oldUrl = myInfos.remove(urlKey);
|
||||
myHasChanges = myHasChanges || oldUrl != null;
|
||||
}
|
||||
|
||||
|
@ -101,7 +98,7 @@ class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLink {
|
|||
|
||||
ZLNetworkException error = null;
|
||||
try {
|
||||
ZLNetworkManager.Instance().perform(new ZLNetworkRequest(getLink(INetworkLink.URL_MAIN)) {
|
||||
ZLNetworkManager.Instance().perform(new ZLNetworkRequest(getUrlInfo(INetworkLink.URL_MAIN).URL) {
|
||||
@Override
|
||||
public void handleStream(URLConnection connection, InputStream inputStream) throws IOException, ZLNetworkException {
|
||||
final CatalogInfoReader info = new CatalogInfoReader(URL, OPDSCustomLink.this, opensearchDescriptionURLs);
|
||||
|
@ -151,7 +148,7 @@ class OPDSCustomLink extends OPDSNetworkLink implements ICustomNetworkLink {
|
|||
|
||||
if (!descriptions.isEmpty()) {
|
||||
// TODO: May be do not use '%s'??? Use Description instead??? (this needs to rewrite SEARCH engine logic a little)
|
||||
setLink(URL_SEARCH, descriptions.get(0).makeQuery("%s"));
|
||||
setUrl(URL_SEARCH, descriptions.get(0).makeQuery("%s"));
|
||||
}
|
||||
if (error != null) {
|
||||
throw error;
|
||||
|
|
|
@ -39,17 +39,17 @@ import org.geometerplus.fbreader.network.atom.ATOMUpdated;
|
|||
public class OPDSLinkReader {
|
||||
static final String CATALOGS_URL = "http://data.fbreader.org/catalogs/generic-1.2.xml";
|
||||
|
||||
public static ICustomNetworkLink createCustomLink(int id, String siteName, String title, String summary, String icon, Map<String, String> links) {
|
||||
if (siteName == null || title == null || links.get(INetworkLink.URL_MAIN) == null) {
|
||||
public static ICustomNetworkLink createCustomLink(int id, String siteName, String title, String summary, String icon, Map<String,URLInfo> infos) {
|
||||
if (siteName == null || title == null || infos.get(INetworkLink.URL_MAIN) == null) {
|
||||
return null;
|
||||
}
|
||||
return new OPDSCustomLink(id, siteName, title, summary, icon, links);
|
||||
return new OPDSCustomLink(id, siteName, title, summary, icon, infos);
|
||||
}
|
||||
|
||||
public static ICustomNetworkLink createCustomLink(int id, String siteName, String title, String summary, String icon, String url) {
|
||||
final HashMap<String, String> links = new HashMap<String, String>();
|
||||
links.put(INetworkLink.URL_MAIN, url);
|
||||
return new OPDSCustomLink(id, siteName, title, summary, icon, links);
|
||||
final HashMap<String,URLInfo> infos = new HashMap<String,URLInfo>();
|
||||
infos.put(INetworkLink.URL_MAIN, new URLInfo(url));
|
||||
return new OPDSCustomLink(id, siteName, title, summary, icon, infos);
|
||||
}
|
||||
|
||||
public static ICustomNetworkLink createCustomLink(String siteName, String title, String summary, String icon, String url) {
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.geometerplus.zlibrary.core.xml.ZLStringMap;
|
|||
import org.geometerplus.fbreader.network.INetworkLink;
|
||||
import org.geometerplus.fbreader.network.NetworkLibrary;
|
||||
import org.geometerplus.fbreader.network.NetworkCatalogItem;
|
||||
import org.geometerplus.fbreader.network.URLInfo;
|
||||
import org.geometerplus.fbreader.network.atom.ATOMLink;
|
||||
import org.geometerplus.fbreader.network.atom.ATOMUpdated;
|
||||
import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;
|
||||
|
@ -99,7 +100,7 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
|
|||
final String language = entry.DCLanguage;
|
||||
|
||||
String icon = null;
|
||||
final HashMap<String,String> links = new HashMap<String,String>();
|
||||
final HashMap<String,URLInfo> infos = new HashMap<String,URLInfo>();
|
||||
final HashMap<String,NetworkCatalogItem.Accessibility> urlConditions =
|
||||
new HashMap<String,NetworkCatalogItem.Accessibility>();
|
||||
for (ATOMLink link: entry.Links) {
|
||||
|
@ -116,26 +117,26 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
|
|||
}
|
||||
} else if (rel == null) {
|
||||
if (type == MIME_APP_ATOM) {
|
||||
links.put(INetworkLink.URL_MAIN, href);
|
||||
infos.put(INetworkLink.URL_MAIN, new URLInfo(href));
|
||||
}
|
||||
} else if (rel == "search") {
|
||||
if (type == MIME_APP_ATOM) {
|
||||
final OpenSearchDescription descr = OpenSearchDescription.createDefault(href);
|
||||
if (descr.isValid()) {
|
||||
// TODO: May be do not use '%s'??? Use Description instead??? (this needs to rewrite SEARCH engine logic a little)
|
||||
links.put(INetworkLink.URL_SEARCH, descr.makeQuery("%s"));
|
||||
infos.put(INetworkLink.URL_SEARCH, new URLInfo(descr.makeQuery("%s")));
|
||||
}
|
||||
}
|
||||
} else if (rel == REL_LINK_SIGN_IN) {
|
||||
links.put(INetworkLink.URL_SIGN_IN, href);
|
||||
infos.put(INetworkLink.URL_SIGN_IN, new URLInfo(href));
|
||||
} else if (rel == REL_LINK_SIGN_OUT) {
|
||||
links.put(INetworkLink.URL_SIGN_OUT, href);
|
||||
infos.put(INetworkLink.URL_SIGN_OUT, new URLInfo(href));
|
||||
} else if (rel == REL_LINK_SIGN_UP) {
|
||||
links.put(INetworkLink.URL_SIGN_UP, href);
|
||||
infos.put(INetworkLink.URL_SIGN_UP, new URLInfo(href));
|
||||
} else if (rel == REL_LINK_REFILL_ACCOUNT) {
|
||||
links.put(INetworkLink.URL_REFILL_ACCOUNT, href);
|
||||
infos.put(INetworkLink.URL_REFILL_ACCOUNT, new URLInfo(href));
|
||||
} else if (rel == REL_LINK_RECOVER_PASSWORD) {
|
||||
links.put(INetworkLink.URL_RECOVER_PASSWORD, href);
|
||||
infos.put(INetworkLink.URL_RECOVER_PASSWORD, new URLInfo(href));
|
||||
} else if (rel == REL_CONDITION_NEVER) {
|
||||
urlConditions.put(href, NetworkCatalogItem.Accessibility.NEVER);
|
||||
} else if (rel == REL_CONDITION_SIGNED_IN) {
|
||||
|
@ -153,7 +154,7 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
|
|||
sslCertificate = null;
|
||||
}
|
||||
|
||||
INetworkLink result = link(siteName, title, summary, icon, language, links, urlConditions, sslCertificate);
|
||||
INetworkLink result = link(siteName, title, summary, icon, language, infos, urlConditions, sslCertificate);
|
||||
if (result != null) {
|
||||
myListener.onNewLink(result);
|
||||
}
|
||||
|
@ -166,11 +167,11 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
|
|||
String summary,
|
||||
String icon,
|
||||
String language,
|
||||
Map<String,String> links,
|
||||
Map<String,URLInfo> infos,
|
||||
HashMap<String,NetworkCatalogItem.Accessibility> urlConditions,
|
||||
String sslCertificate
|
||||
) {
|
||||
if (siteName == null || title == null || links.get(INetworkLink.URL_MAIN) == null) {
|
||||
if (siteName == null || title == null || infos.get(INetworkLink.URL_MAIN) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -180,7 +181,7 @@ class OPDSLinkXMLReader extends OPDSXMLReader implements OPDSConstants, MimeType
|
|||
summary,
|
||||
icon,
|
||||
language,
|
||||
links,
|
||||
infos,
|
||||
myHasStableIdentifiers
|
||||
);
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ public class OPDSNetworkLink extends AbstractNetworkLink {
|
|||
private final boolean myHasStableIdentifiers;
|
||||
|
||||
OPDSNetworkLink(String siteName, String title, String summary, String icon, String language,
|
||||
Map<String, String> links, boolean hasStableIdentifiers) {
|
||||
super(siteName, title, summary, icon, language, links);
|
||||
Map<String,URLInfo> infos, boolean hasStableIdentifiers) {
|
||||
super(siteName, title, summary, icon, language, infos);
|
||||
myHasStableIdentifiers = hasStableIdentifiers;
|
||||
myBooksInBasketOption = new ZLStringListOption(siteName, "Basket", null);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class OPDSNetworkLink extends AbstractNetworkLink {
|
|||
}
|
||||
|
||||
public ZLNetworkRequest simpleSearchRequest(String pattern, NetworkOperationData data) {
|
||||
final String url = getLink(URL_SEARCH);
|
||||
final String url = getUrlInfo(URL_SEARCH).URL;
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ public class OPDSNetworkLink extends AbstractNetworkLink {
|
|||
}
|
||||
|
||||
public NetworkCatalogItem libraryItem() {
|
||||
TreeMap<Integer, String> urlMap = new TreeMap<Integer, String>();
|
||||
urlMap.put(NetworkCatalogItem.URL_CATALOG, getLink(URL_MAIN));
|
||||
TreeMap<Integer,String> urlMap = new TreeMap<Integer,String>();
|
||||
urlMap.put(NetworkCatalogItem.URL_CATALOG, getUrlInfo(URL_MAIN).URL);
|
||||
return new OPDSCatalogItem(this, getTitle(), getSummary(), getIcon(), urlMap, myExtraData);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue