FileDocCategorySizeDatePackage
PlatformRatingMessenger.javaAPI DocAzureus 3.0.3.48269Sat Sep 08 19:48:54 BST 2007com.aelitis.azureus.core.messenger.config

PlatformRatingMessenger

public class PlatformRatingMessenger extends Object
author
TuxPaper
created
Oct 4, 2006

Fields Summary
public static final String
LISTENER_ID
public static final String
OP_GET
public static final String
OP_SET
public static final String
RATE_TYPE_CONTENT
public static final ArrayList
listeners
Constructors Summary
Methods Summary
public static voidaddListener(com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$RatingUpdateListener l)

		listeners.add(l);
	
public static voidgetGlobalRating(java.lang.String[] rateTypes, java.lang.String[] torrentHashes, long maxDelayMS, com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$GetRatingReplyListener replyListener)


		PlatformMessage message = new PlatformMessage("AZMSG", "rating",
				"get-global", new Object[] {
					"rating-type",
					rateTypes,
					"torrent-hash",
					torrentHashes,
				}, maxDelayMS);

		PlatformMessengerListener listener = new PlatformMessengerListener() {
			public void messageSent(PlatformMessage message) {
				replyListener.messageSent();
			}

			public void replyReceived(PlatformMessage message, String replyType,
					Map reply) {
				replyListener.replyReceived(replyType, new GetRatingReply(reply));
			}
		};

		PlatformMessenger.queueMessage(message, listener);
	
public static voidgetUserRating(java.lang.String[] rateTypes, java.lang.String[] torrentHashes, long maxDelayMS, com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$GetRatingReplyListener replyListener)


	      
			     

		PlatformMessage message = new PlatformMessage("AZMSG", "rating",
				"get-user", new Object[] {
					"rating-type",
					rateTypes,
					"torrent-hash",
					torrentHashes,
				}, maxDelayMS);

		PlatformMessengerListener listener = new PlatformMessengerListener() {
			public void messageSent(PlatformMessage message) {
				replyListener.messageSent();
			}

			public void replyReceived(PlatformMessage message, String replyType,
					Map reply) {

				replyListener.replyReceived(replyType, new GetRatingReply(reply));
			}
		};

		PlatformMessenger.queueMessage(message, listener);
	
private static voidinvokeUpdateListeners(com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$GetRatingReply rating)

		Object[] listArray = listeners.toArray();
		for (int i = 0; i < listArray.length; i++) {
			RatingUpdateListener l = (RatingUpdateListener) listArray[i];
			try {
				l.ratingUpdated(rating);
			} catch (Exception e) {
			}
		}
	
public static booleanratingSucceeded(java.util.Map map)

		String message = MapUtils.getMapString(map, "message", null);

		if (message != null) {
			return message.equals("Ok");
		}

		return MapUtils.getMapBoolean(map, "success", false);
	
public static voidremoveListener(com.aelitis.azureus.core.messenger.config.PlatformRatingMessenger$RatingUpdateListener l)

		listeners.remove(l);
	
public static voidsetUserRating(java.lang.String torrentHash, int rating, long maxDelayMS, com.aelitis.azureus.core.messenger.PlatformMessengerListener l)


		List array = new ArrayList();
		array.add(PlatformMessage.parseParams(new Object[] {
			"rating-type",
			"content",
			"rating-value",
			new Integer(rating)
		}));

		PlatformMessage message = new PlatformMessage("AZMSG", "rating", "set",
				new Object[] {
					"torrent-hash",
					torrentHash,
					"ratings",
					array
				}, maxDelayMS);

		PlatformMessenger.queueMessage(message, new PlatformMessengerListener() {
			// @see com.aelitis.azureus.core.messenger.PlatformMessengerListener#messageSent(com.aelitis.azureus.core.messenger.PlatformMessage)

			public void messageSent(PlatformMessage message) {
				if (l != null) {
					l.messageSent(message);
				}
			}

			// @see com.aelitis.azureus.core.messenger.PlatformMessengerListener#replyReceived(com.aelitis.azureus.core.messenger.PlatformMessage, java.lang.String, java.lang.Object)

			public void replyReceived(PlatformMessage message, String replyType,
					Map reply) {
				if (l != null) {
					l.replyReceived(message, replyType, reply);
				}
			}
		});