return handlePostBidBuyPage(cj, loadedPage, bidForm, inEntry);
}
private int handlePostBidBuyPage(CookieJar cj, StringBuffer loadedPage, JHTML.Form bidForm, AuctionEntry inEntry) {
if(JConfig.debugging) inEntry.setLastStatus("Loading post-bid data.");
JHTML htmlDocument = new JHTML(loadedPage);
JHTML.Form continueForm = htmlDocument.getFormWithInput("firedFilterId");
if(continueForm != null) {
try {
inEntry.setLastStatus("Trying to 'continue' to the bid result page.");
String cgi = continueForm.getFormData();
// For some reason, the continue page represents the currency as
// separated from the amount with a '0xA0' character. When encoding,
// this becomes...broken somehow, and adds an extra character, which
// does not work when bidding.
cgi = cgi.replaceFirst("%[A-F][A-F0-9]%A0", "%A0");
URLConnection huc = cj.connect(continueForm.getAction(), cgi, null, true, null);
// We failed to load, entirely. Punt.
if (huc == null) return AuctionServerInterface.BID_ERROR_CONNECTION;
loadedPage = Http.net().receivePage(huc);
// We failed to load. Punt.
if (loadedPage == null) return AuctionServerInterface.BID_ERROR_CONNECTION;
htmlDocument = new JHTML(loadedPage);
} catch(Exception ignored) {
return AuctionServerInterface.BID_ERROR_CONNECTION;
}
}
String errMsg = htmlDocument.grep(mBidResultRegex);
if (errMsg != null) {
Matcher bidMatch = mFindBidResult.matcher(errMsg);
bidMatch.find();
String matched_error = bidMatch.group().toLowerCase();
Integer bidResult = getMatchedResult(matched_error);
JConfig.log().dump2File("error-" + bidResult + ".html", loadedPage);
int result = 0;
if (bidResult != null) {
result = bidResult;
if (result == ebayServer.BID_ERROR_BANNED ||
result == ebayServer.BID_ERROR_WONT_SHIP ||
result == ebayServer.BID_ERROR_REQUIREMENTS_NOT_MET) {
inEntry.setErrorPage(loadedPage);
}
} else {
String amount = htmlDocument.getNextContentAfterRegex("Enter");
if (amount != null) {
String orMore = htmlDocument.getNextContent();
if (orMore != null && orMore.indexOf("or more") != -1) {
result = ebayServer.BID_ERROR_TOO_LOW;
}
}
}