// Path: AndroBOINC/src/main/java/sk/boinc/androboinc/bridge/AutoRefresh.java
// public enum RequestType {
// 	CLIENT_MODE,
// 	PROJECTS,
// 	TASKS,
// 	TRANSFERS,
// 	MESSAGES
// }
// 
// Path: BoincRpc/src/main/java/edu/berkeley/boinc/NetStats.java
// public interface NetStats {
//     public abstract void connectionOpened();
//     public abstract void bytesReceived(int numBytes);
//     public abstract void bytesTransferred(int numBytes);
//     public abstract void connectionClosed();
// }


import sk.boinc.androboinc.BuildConfig;
import sk.boinc.androboinc.bridge.AutoRefresh.RequestType;
import sk.boinc.androboinc.clientconnection.ClientReplyReceiver;
import sk.boinc.androboinc.clientconnection.ClientRequestHandler;
import sk.boinc.androboinc.clientconnection.ConnectionManagerCallback.DisconnectCause;
import sk.boinc.androboinc.clientconnection.ConnectionManagerCallback.ProgressInd;
import sk.boinc.androboinc.clientconnection.HostInfo;
import sk.boinc.androboinc.clientconnection.MessageInfo;
import sk.boinc.androboinc.clientconnection.ModeInfo;
import sk.boinc.androboinc.clientconnection.ProjectInfo;
import sk.boinc.androboinc.clientconnection.TaskInfo;
import sk.boinc.androboinc.clientconnection.TransferInfo;
import sk.boinc.androboinc.clientconnection.VersionInfo;
import edu.berkeley.boinc.NetStats;
import sk.boinc.androboinc.util.ClientId;
import android.content.Context;
import android.os.ConditionVariable;
import android.util.Log;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
				return;
			}
			// Check whether callback is still present in receivers
			if (mReceivers.contains(callback)) {
				// Yes, receiver is still present, so we can call it back with data
				boolean periodicAllowed = callback.updatedMessages(messages);
				if (periodicAllowed) {
					mAutoRefresh.scheduleAutomaticRefresh(callback, RequestType.MESSAGES);
				}
			}
		}
	}

	private final BridgeReply mBridgeReply = new BridgeReply();

	private Set<ClientReplyReceiver> mReceivers = new HashSet<ClientReplyReceiver>();
	private boolean mConnected = false;

	private ClientBridgeCallback mCallback;
	private ClientBridgeWorkerThread mWorker;

	private ClientId mRemoteClient = null;

	private final AutoRefresh mAutoRefresh;

	/**
	 * Constructs a new <code>ClientBridge</code> and starts worker thread
	 * 
	 * @throws RuntimeException if worker thread cannot start in a timely fashion
	 */
// Path: AndroBOINC/src/main/java/sk/boinc/androboinc/bridge/AutoRefresh.java
// public enum RequestType {
// 	CLIENT_MODE,
// 	PROJECTS,
// 	TASKS,
// 	TRANSFERS,
// 	MESSAGES
// }
// 
// Path: BoincRpc/src/main/java/edu/berkeley/boinc/NetStats.java
// public interface NetStats {
//     public abstract void connectionOpened();
//     public abstract void bytesReceived(int numBytes);
//     public abstract void bytesTransferred(int numBytes);
//     public abstract void connectionClosed();
// }


// Path: AndroBOINC/src/main/java/sk/boinc/androboinc/bridge/ClientBridge.java
import sk.boinc.androboinc.BuildConfig;
import sk.boinc.androboinc.bridge.AutoRefresh.RequestType;
import sk.boinc.androboinc.clientconnection.ClientReplyReceiver;
import sk.boinc.androboinc.clientconnection.ClientRequestHandler;
import sk.boinc.androboinc.clientconnection.ConnectionManagerCallback.DisconnectCause;
import sk.boinc.androboinc.clientconnection.ConnectionManagerCallback.ProgressInd;
import sk.boinc.androboinc.clientconnection.HostInfo;
import sk.boinc.androboinc.clientconnection.MessageInfo;
import sk.boinc.androboinc.clientconnection.ModeInfo;
import sk.boinc.androboinc.clientconnection.ProjectInfo;
import sk.boinc.androboinc.clientconnection.TaskInfo;
import sk.boinc.androboinc.clientconnection.TransferInfo;
import sk.boinc.androboinc.clientconnection.VersionInfo;
import edu.berkeley.boinc.NetStats;
import sk.boinc.androboinc.util.ClientId;
import android.content.Context;
import android.os.ConditionVariable;
import android.util.Log;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;

				return;
			}
			// Check whether callback is still present in receivers
			if (mReceivers.contains(callback)) {
				// Yes, receiver is still present, so we can call it back with data
				boolean periodicAllowed = callback.updatedMessages(messages);
				if (periodicAllowed) {
					mAutoRefresh.scheduleAutomaticRefresh(callback, RequestType.MESSAGES);
				}
			}
		}
	}

	private final BridgeReply mBridgeReply = new BridgeReply();

	private Set<ClientReplyReceiver> mReceivers = new HashSet<ClientReplyReceiver>();
	private boolean mConnected = false;

	private ClientBridgeCallback mCallback;
	private ClientBridgeWorkerThread mWorker;

	private ClientId mRemoteClient = null;

	private final AutoRefresh mAutoRefresh;

	/**
	 * Constructs a new <code>ClientBridge</code> and starts worker thread
	 * 
	 * @throws RuntimeException if worker thread cannot start in a timely fashion
	 */
	public ClientBridge(ClientBridgeCallback callback, Context context, NetStats netStats) throws RuntimeException {