package jp.co.corecorp.s3pdf;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

class S3Exception extends Exception
{
	private static final long serialVersionUID = 5438576280200770130L;
	S3Exception(String msg) {
		super(msg);
	}
}
class S3TypeException extends Exception
{
	private static final long serialVersionUID = 5438576480607073030L;
	S3TypeException(String msg) {
		super(msg);
	}
}
class S3SyncException extends Exception
{
	private static final long serialVersionUID = 5439472680200770130L;
	private String service;
	private String resource;
	S3SyncException(String msg, String svn) {
		super(msg);
		service 	= svn;
	}
	S3SyncException(String msg, String svn, String rsn) {
		super(msg);
		service 	= svn;
		resource	= rsn;
	}
	String getServiceName() {
		return service;
	}
	String getResourceName() {
		return resource;
	}
}

class S3Handler {
	public void onError(S3Context ctx, String msg) {}
	public void onComplete(S3Context ctx) {}
}
class S3ConnectHandler extends S3Handler {
	public void onConnect(S3Context ctx) {}
}
class S3LoginHandler extends S3Handler {
	public void onLogin(S3Context ctx) {}
}
class S3RegisterHandler extends S3Handler {
	public void onRegisterComplete(S3Context ctx, String svc) {}
}
abstract class S3SyncHandler extends S3Handler {
	public abstract void onSyncProgress(S3Context ctx, String svn, String rsn);
	public abstract void onSyncComplete(S3Context ctx, String svn);
}
class S3UpdateHandler extends S3Handler {
	public void onUpdateResource(S3Context ctx, String service, String resource) {}
}
public class S3ContextBuilder {
	public static final String version="0.1";
	private Context context;
	private String errmsg;
	
	public S3ContextBuilder(Context ctx) {
		context = ctx;
	}
	public String getErrorMessage() {
		return errmsg;
	}
	public S3Context createContext(String ver) throws S3Exception {
		if( !ver.equals(version) ) {
			throw new S3Exception(context.getString(R.string.versionError));
		}
		S3Context inst = new S3Context(context);
		return inst;
	}
}
