Fix a few TODO's and some general cleanup.
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/AuctionEntry.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/AuctionInfo.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/MultiSnipe.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/my/MyJBidwatcher.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/ui/AuctionsManager.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/ui/UserActions.java view
| 917 | 955 | |
|---|---|---|
| 252 | 252 | if (mLoaded) { |
| 253 | 253 | if(mAuction.getServer() != null) setServer((AuctionServerInterface)mAuction.getServer()); |
| 254 | 254 | setDefaultCurrency(mAuction.getCurBid()); |
| 255 | checkHighBidder(true); | |
| 255 | updateHighBid(); | |
| 256 | checkHighBidder(); | |
| 256 | 257 | checkSeller(); |
| 257 | 258 | checkEnded(); |
| 258 | 259 | } |
| --- | --- | |
| 660 | 661 | /////////////////////////// |
| 661 | 662 | // Actual logic functions |
| 662 | 663 | |
| 663 | // TODO -- Check this for the need of a saveDB() occasionally... | |
| 664 | public void updateHighBid() { | |
| 665 | int numBidders = getNumBidders(); | |
| 666 | ||
| 667 | if (numBidders > 0 && isOutbid()) { | |
| 668 | getServer().updateHighBid(this); | |
| 669 | } | |
| 670 | } | |
| 671 | ||
| 664 | 672 | /** |
| 665 | 673 | * @brief On update, we check if we're the high bidder. |
| 666 | 674 | * |
| 667 | 675 | * When you change user ID's, you should force a complete update, so |
| 668 | 676 | * this is synchronized correctly. |
| 669 | * | |
| 670 | * @param doNetworkCheck - Should we actually check over the network for new bid information, if the user is outbid? | |
| 671 | 677 | */ |
| 672 | private void checkHighBidder(boolean doNetworkCheck) { | |
| 678 | private void checkHighBidder() { | |
| 673 | 679 | int numBidders = getNumBidders(); |
| 674 | 680 | |
| 675 | 681 | if(numBidders > 0) { |
| 676 | // TODO -- This is silly. Why should the AuctionEntry know about doing a network check? | |
| 677 | if(isOutbid() && doNetworkCheck) { | |
| 678 | getServer().updateHighBid(this); | |
| 679 | } | |
| 680 | 682 | if(isBidOn() && isPrivate()) { |
| 681 | 683 | Currency curBid = getCurBid(); |
| 682 | 684 | try { |
| --- | --- | |
| 695 | 697 | // eBay knows the 'true' answer, but how to extract it from them... |
| 696 | 698 | } |
| 697 | 699 | } else { |
| 698 | if(!isDutch()) { | |
| 699 | setWinning(getServer().isCurrentUser(getHighBidder())); | |
| 700 | } | |
| 700 | setWinning(getServer().isCurrentUser(getHighBidder())); | |
| 701 | 701 | } |
| 702 | 702 | } |
| 703 | 703 | } |
| --- | --- | |
| 1037 | 1037 | if(mEntryEvents == null) { |
| 1038 | 1038 | getEvents(); |
| 1039 | 1039 | } |
| 1040 | checkHighBidder(false); | |
| 1040 | checkHighBidder(); | |
| 1041 | 1041 | checkSeller(); |
| 1042 | 1042 | saveDB(); |
| 1043 | 1043 | } |
| --- | --- | |
| 1139 | 1139 | mLastUpdatedAt = System.currentTimeMillis(); |
| 1140 | 1140 | mAddedRecently = 0; |
| 1141 | 1141 | try { |
| 1142 | checkHighBidder(true); | |
| 1142 | updateHighBid(); | |
| 1143 | checkHighBidder(); | |
| 1143 | 1144 | if(isDutch()) checkDutchHighBidder(); |
| 1144 | 1145 | } catch(Exception e) { |
| 1145 | 1146 | JConfig.log().handleException("Unexpected exception during high bidder check.", e); |
| --- | --- | |
| 1261 | 1262 | Currency bin = getBuyNow(); |
| 1262 | 1263 | if(bin != null && !bin.isNull()) { |
| 1263 | 1264 | setBid(getBuyNow()); |
| 1264 | setBidQuantity(quant); // TODO -- Is it possible to Buy more than 1 item? Yes...how? | |
| 1265 | setBidQuantity(quant); | |
| 1265 | 1266 | mBidAt = System.currentTimeMillis(); |
| 1266 | 1267 | JConfig.log().logDebug("Buying " + quant + " item[s] of (" + getIdentifier() + ")-" + getTitle()); |
| 1267 | 1268 | rval = getServer().buy(this, quant); |
| --- | --- | |
| 1586 | 1587 | } |
| 1587 | 1588 | } |
| 1588 | 1589 | |
| 1589 | checkHighBidder(false); | |
| 1590 | checkHighBidder(); | |
| 1590 | 1591 | checkSeller(); |
| 1591 | 1592 | checkEnded(); |
| 1592 | 1593 | saveDB(); |
| 917 | 955 | |
|---|---|---|
| 32 | 32 | private static Map<String, String> mKeys; |
| 33 | 33 | private String mThumbnailPath; |
| 34 | 34 | private Object mServer = null; // TODO -- This is a hack! |
| 35 | // It's so that the AuctionServer that creates this can record | |
| 36 | // 'who it is', so the AuctionEntry will pick it up. | |
| 35 | 37 | |
| 36 | 38 | private static void setupKeys() { |
| 37 | 39 | mKeys = new HashMap<String, String>(); |
| 819 | 955 | |
|---|---|---|
| 143 | 143 | mAuctionEntriesInThisGroup = new LinkedList<Snipeable>(); |
| 144 | 144 | |
| 145 | 145 | for (Snipeable aeFromList : oldEntries) { |
| 146 | // TODO -- Fix this up; this calls back into here, for the remove() function. This needs to be seperated somehow. | |
| 147 | 146 | aeFromList.cancelSnipe(false); |
| 148 | 147 | } |
| 149 | 148 | oldEntries.clear(); |
| 949 | 955 | |
|---|---|---|
| 137 | 137 | return sInstance; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | private void getSQSURL() { | |
| 141 | StringBuffer sb = http().get(url("my.jbidwatcher.com/services/syncq")); | |
| 142 | mSyncQueueURL = (sb == null) ? null : sb.toString(); | |
| 143 | sb = http().get(url("my.jbidwatcher.com/services/reportq")); | |
| 144 | mReportQueueURL = (sb == null) ? null : sb.toString(); | |
| 145 | } | |
| 146 | ||
| 147 | 140 | public void postXML(String queue, XMLSerialize ae) { |
| 148 | 141 | XMLElement xmlWrapper = new XMLElement("message"); |
| 149 | 142 | XMLElement user = new XMLElement("user"); |
| 816 | 955 | |
|---|---|---|
| 218 | 218 | AuctionServerManager.getInstance().loadAuctionsFromDB(newServer); |
| 219 | 219 | AuctionStats as = AuctionServerManager.getInstance().getStats(); |
| 220 | 220 | |
| 221 | // TODO -- Do something more valuable than just notify, when the auction counts are off. | |
| 222 | 221 | int savedCount = Integer.parseInt(JConfig.queryConfiguration("last.auctioncount", "-1")); |
| 223 | 222 | if (as != null) { |
| 224 | 223 | if (as.getCount() != activeCount || (savedCount != -1 && as.getCount() != savedCount)) { |
| --- | --- | |
| 259 | 258 | |
| 260 | 259 | AuctionStats as = AuctionServerManager.getInstance().getStats(); |
| 261 | 260 | |
| 262 | // TODO -- Do something more valuable than just notify, when the auction counts are off. | |
| 263 | 261 | int savedCount = Integer.parseInt(JConfig.queryConfiguration("last.auctioncount", "-1")); |
| 264 | 262 | if(as != null) { |
| 265 | 263 | if(as.getCount() != auctionTotal || (savedCount != -1 && as.getCount() != savedCount)) { |
| 937 | 955 | |
|---|---|---|
| 912 | 912 | |
| 913 | 913 | return false; |
| 914 | 914 | } |
| 915 | ||
| 915 | // TODO -- Add the ability to pick a quantity to buy, defaulting to 1. | |
| 916 | 916 | private void DoBuy(Component src, AuctionEntry ae) { |
| 917 | 917 | if(anyBiddingErrors(src, ae)) return; |
| 918 | 918 | |
| --- | --- | |
| 978 | 978 | AuctionEntry ae = inAuction; |
| 979 | 979 | int[] rowList = mTabs.getPossibleRows(); |
| 980 | 980 | |
| 981 | // TODO -- It would be nice to be able to show multiple items. | |
| 981 | 982 | if(rowList.length != 0) { |
| 982 | // Vector<String> multiAuctionIds = new Vector<String>(); | |
| 983 | // int i; | |
| 984 | // | |
| 985 | // for(i=0; i<rowList.length; i++) { | |
| 986 | // AuctionEntry tempEntry = (AuctionEntry) mTabs.getIndexedEntry(rowList[i]); | |
| 987 | // | |
| 988 | // multiAuctionIds.add(tempEntry.getIdentifier()); | |
| 989 | // } | |
| 990 | // TODO -- Find another way to do this... | |
| 991 | // JBidProxy.setItems(multiAuctionIds); | |
| 992 | ||
| 993 | 983 | ae = (AuctionEntry) mTabs.getIndexedEntry(rowList[0]); |
| 994 | 984 | } else { |
| 995 | 985 | if(ae == null) { |
