commit 1856bfa4e3fc787f2b649fef87b9e7534596c7b2 Author: Rogiel Date: Sun Aug 14 13:51:46 2011 -0300 First commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..edcdd6b --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..c76c53e --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + seedbox-httpchannel + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..2213c3f --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,13 @@ +#Sun Aug 14 13:47:37 BRT 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.maven.ide.eclipse.prefs b/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000..512edbb --- /dev/null +++ b/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,8 @@ +#Sun Aug 14 13:30:10 BRT 2011 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..8db6204 --- /dev/null +++ b/pom.xml @@ -0,0 +1,8 @@ + + 4.0.0 + com.rogiel.seedbox + seedbox-httpchannel + 1.0.0 + Seedbox - HTTP Channel library + Library capable of downloading and uploading files from free servers using channels. + \ No newline at end of file diff --git a/src/main/java/com/rogiel/httpchannel/DownloadChannel.java b/src/main/java/com/rogiel/httpchannel/DownloadChannel.java new file mode 100644 index 0000000..22217ef --- /dev/null +++ b/src/main/java/com/rogiel/httpchannel/DownloadChannel.java @@ -0,0 +1,26 @@ +/* + * This file is part of seedbox . + * + * seedbox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * seedbox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with seedbox. If not, see . + */ +package com.rogiel.httpchannel; + +import java.nio.channels.ReadableByteChannel; + +/** + * @author Rogiel + */ +public interface DownloadChannel extends ReadableByteChannel { + +} diff --git a/src/main/java/com/rogiel/httpchannel/UploadChannel.java b/src/main/java/com/rogiel/httpchannel/UploadChannel.java new file mode 100644 index 0000000..36097d8 --- /dev/null +++ b/src/main/java/com/rogiel/httpchannel/UploadChannel.java @@ -0,0 +1,27 @@ +/* + * This file is part of seedbox . + * + * seedbox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * seedbox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with seedbox. If not, see . + */ +package com.rogiel.httpchannel; + +import java.net.URI; +import java.nio.channels.WritableByteChannel; + +/** + * @author Rogiel + */ +public interface UploadChannel extends WritableByteChannel { + URI getLink(); +} diff --git a/src/main/java/com/rogiel/httpchannel/service/CaptchaResolver.java b/src/main/java/com/rogiel/httpchannel/service/CaptchaResolver.java new file mode 100644 index 0000000..30b56ab --- /dev/null +++ b/src/main/java/com/rogiel/httpchannel/service/CaptchaResolver.java @@ -0,0 +1,25 @@ +/* + * This file is part of seedbox . + * + * seedbox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * seedbox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with seedbox. If not, see . + */ +package com.rogiel.httpchannel.service; + +/** + * @author Rogiel + * + */ +public interface CaptchaResolver { + +} diff --git a/src/main/java/com/rogiel/httpchannel/service/DownloadService.java b/src/main/java/com/rogiel/httpchannel/service/DownloadService.java new file mode 100644 index 0000000..d6ca5a8 --- /dev/null +++ b/src/main/java/com/rogiel/httpchannel/service/DownloadService.java @@ -0,0 +1,57 @@ +/* + * This file is part of seedbox . + * + * seedbox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * seedbox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with seedbox. If not, see . + */ +package com.rogiel.httpchannel.service; + +import java.io.IOException; +import java.net.URI; +import java.nio.ByteBuffer; +import java.nio.channels.ReadableByteChannel; + +import com.rogiel.httpchannel.DownloadChannel; + +/** + * @author Rogiel + * + */ +public interface DownloadService { + DownloadChannel download(URI uri, CaptchaResolver captchaResolver); + + /** + * Simple delegating implementation for {@link DownloadChannel}. + * + * @author Rogiel + */ + public abstract class SimpleDownloadChannel implements DownloadChannel { + protected final ReadableByteChannel channel; + + public SimpleDownloadChannel(ReadableByteChannel channel) { + this.channel = channel; + } + + public int read(ByteBuffer dst) throws IOException { + return channel.read(dst); + } + + public boolean isOpen() { + return channel.isOpen(); + } + + public void close() throws IOException { + channel.close(); + } + } +} diff --git a/src/main/java/com/rogiel/httpchannel/service/Service.java b/src/main/java/com/rogiel/httpchannel/service/Service.java new file mode 100644 index 0000000..190c15a --- /dev/null +++ b/src/main/java/com/rogiel/httpchannel/service/Service.java @@ -0,0 +1,25 @@ +/* + * This file is part of seedbox . + * + * seedbox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * seedbox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with seedbox. If not, see . + */ +package com.rogiel.httpchannel.service; + +/** + * @author Rogiel + * + */ +public interface Service { + +} diff --git a/src/main/java/com/rogiel/httpchannel/service/UploadService.java b/src/main/java/com/rogiel/httpchannel/service/UploadService.java new file mode 100644 index 0000000..7a533f3 --- /dev/null +++ b/src/main/java/com/rogiel/httpchannel/service/UploadService.java @@ -0,0 +1,53 @@ +/* + * This file is part of seedbox . + * + * seedbox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * seedbox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with seedbox. If not, see . + */ +package com.rogiel.httpchannel.service; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.WritableByteChannel; + +import com.rogiel.httpchannel.UploadChannel; + +/** + * @author Rogiel + */ +public interface UploadService { + UploadChannel upload(String filename, long filesize); + + /** + * Simple delegating implementation for {@link UploadChannel}. + * + * @author Rogiel + */ + public abstract class SimpleUploadChannel implements UploadChannel { + protected final WritableByteChannel channel; + + public SimpleUploadChannel(WritableByteChannel channel) { + this.channel = channel; + } + + @Override + public int write(ByteBuffer src) throws IOException { + return channel.write(src); + } + + @Override + public boolean isOpen() { + return channel.isOpen(); + } + } +} diff --git a/src/main/java/com/rogiel/httpchannel/service/impl/MegaUploadService.java b/src/main/java/com/rogiel/httpchannel/service/impl/MegaUploadService.java new file mode 100644 index 0000000..9d7f653 --- /dev/null +++ b/src/main/java/com/rogiel/httpchannel/service/impl/MegaUploadService.java @@ -0,0 +1,51 @@ +/* + * This file is part of seedbox . + * + * seedbox is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * seedbox is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with seedbox. If not, see . + */ +package com.rogiel.httpchannel.service.impl; + +import java.io.IOException; +import java.net.URI; + +import com.rogiel.httpchannel.DownloadChannel; +import com.rogiel.httpchannel.UploadChannel; +import com.rogiel.httpchannel.service.CaptchaResolver; +import com.rogiel.httpchannel.service.DownloadService; +import com.rogiel.httpchannel.service.UploadService; + +/** + * @author Rogiel + * + */ +public class MegaUploadService implements DownloadService, UploadService { + public DownloadChannel download(URI uri, CaptchaResolver captchaResolver) { + return new SimpleDownloadChannel(null) { + }; + } + + public UploadChannel upload(String filename, long filesize) { + return new SimpleUploadChannel(null) { + @Override + public void close() throws IOException { + + } + + @Override + public URI getLink() { + return null; + } + }; + } +} diff --git a/src/main/resources/.gitignore b/src/main/resources/.gitignore new file mode 100644 index 0000000..50cf6de --- /dev/null +++ b/src/main/resources/.gitignore @@ -0,0 +1 @@ +/config