parent
40c210c751
commit
7f52271ee5
@ -0,0 +1,62 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.common.ftp; |
||||
|
||||
import com.arialyy.aria.core.FtpUrlEntity; |
||||
import com.arialyy.aria.core.inf.ITaskDelegate; |
||||
import java.net.Proxy; |
||||
|
||||
/** |
||||
* fTP任务设置的信息,如:用户名、密码、端口等信息 |
||||
*/ |
||||
public class FtpTaskDelegate implements ITaskDelegate { |
||||
|
||||
/** |
||||
* 账号和密码 |
||||
*/ |
||||
private FtpUrlEntity urlEntity; |
||||
|
||||
private Proxy proxy; |
||||
|
||||
/** |
||||
* 字符编码,默认为"utf-8" |
||||
*/ |
||||
private String charSet = "utf-8"; |
||||
|
||||
public FtpUrlEntity getUrlEntity() { |
||||
return urlEntity; |
||||
} |
||||
|
||||
public void setUrlEntity(FtpUrlEntity urlEntity) { |
||||
this.urlEntity = urlEntity; |
||||
} |
||||
|
||||
public void setProxy(Proxy proxy) { |
||||
this.proxy = proxy; |
||||
} |
||||
|
||||
public Proxy getProxy() { |
||||
return proxy; |
||||
} |
||||
|
||||
public String getCharSet() { |
||||
return charSet; |
||||
} |
||||
|
||||
public void setCharSet(String charSet) { |
||||
this.charSet = charSet; |
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.common.http; |
||||
|
||||
import android.text.TextUtils; |
||||
import com.arialyy.aria.core.download.DGTaskWrapper; |
||||
import com.arialyy.aria.core.download.DTaskWrapper; |
||||
import com.arialyy.aria.core.download.DownloadGroupTarget; |
||||
import com.arialyy.aria.core.inf.AbsTarget; |
||||
import com.arialyy.aria.core.inf.ITarget; |
||||
import com.arialyy.aria.util.ALog; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
class BaseTarget<TARGET extends AbsTarget> implements ITarget { |
||||
private static final String TAG = "PostDelegate"; |
||||
TARGET mTarget; |
||||
|
||||
public BaseTarget(TARGET target){ |
||||
mTarget = target; |
||||
} |
||||
|
||||
public TARGET setParams(Map<String, String> params) { |
||||
mTarget.getTaskWrapper().asHttp().setParams(params); |
||||
if (mTarget instanceof DownloadGroupTarget) { |
||||
for (DTaskWrapper subTask : ((DGTaskWrapper) mTarget.getTaskWrapper()).getSubTaskWrapper()) { |
||||
subTask.asHttp().setParams(params); |
||||
} |
||||
} |
||||
return mTarget; |
||||
} |
||||
|
||||
public TARGET setParam(String key, String value) { |
||||
if (TextUtils.isEmpty(key) || TextUtils.isEmpty(value)) { |
||||
ALog.d(TAG, "key 或value 为空"); |
||||
return mTarget; |
||||
} |
||||
Map<String, String> params = mTarget.getTaskWrapper().asHttp().getParams(); |
||||
if (params == null) { |
||||
params = new HashMap<>(); |
||||
mTarget.getTaskWrapper().asHttp().setParams(params); |
||||
} |
||||
params.put(key, value); |
||||
if (mTarget instanceof DownloadGroupTarget) { |
||||
for (DTaskWrapper subTask : ((DGTaskWrapper) mTarget.getTaskWrapper()).getSubTaskWrapper()) { |
||||
subTask.asHttp().setParams(params); |
||||
} |
||||
} |
||||
return mTarget; |
||||
} |
||||
|
||||
@Override public void start() { |
||||
|
||||
} |
||||
|
||||
@Override public void stop() { |
||||
|
||||
} |
||||
|
||||
@Override public void resume() { |
||||
|
||||
} |
||||
|
||||
@Override public void cancel() { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,187 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package com.arialyy.aria.core.common.http; |
||||
|
||||
import com.arialyy.aria.core.common.RequestEnum; |
||||
import com.arialyy.aria.core.inf.ITaskDelegate; |
||||
import java.net.CookieManager; |
||||
import java.net.Proxy; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Http任务设置的信息,如:cookie、请求参数 |
||||
*/ |
||||
public class HttpTaskDelegate implements ITaskDelegate { |
||||
|
||||
private CookieManager cookieManager; |
||||
|
||||
/** |
||||
* 请求参数 |
||||
*/ |
||||
private Map<String, String> params; |
||||
|
||||
/** |
||||
* http 请求头 |
||||
*/ |
||||
private Map<String, String> headers = new HashMap<>(); |
||||
|
||||
/** |
||||
* 字符编码,默认为"utf-8" |
||||
*/ |
||||
private String charSet = "utf-8"; |
||||
|
||||
/** |
||||
* 网络请求类型 |
||||
*/ |
||||
private RequestEnum requestEnum = RequestEnum.GET; |
||||
|
||||
/** |
||||
* 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment; filename="filename.jpg"} {@code true} |
||||
* 使用 |
||||
*/ |
||||
private boolean useServerFileName = false; |
||||
|
||||
/** |
||||
* 重定向链接 |
||||
*/ |
||||
private String redirectUrl = ""; |
||||
|
||||
/** |
||||
* 是否是chunk模式 |
||||
*/ |
||||
private boolean isChunked = false; |
||||
/** |
||||
* 文件上传需要的key |
||||
*/ |
||||
private String attachment; |
||||
/** |
||||
* 上传的文件类型 |
||||
*/ |
||||
private String contentType = "multipart/form-data"; |
||||
private String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)"; |
||||
|
||||
private Proxy proxy; |
||||
/** |
||||
* 文件上传表单 |
||||
*/ |
||||
private Map<String, String> formFields = new HashMap<>(); |
||||
|
||||
public Map<String, String> getFormFields() { |
||||
return formFields; |
||||
} |
||||
|
||||
public void setFormFields(Map<String, String> formFields) { |
||||
this.formFields = formFields; |
||||
} |
||||
|
||||
public String getAttachment() { |
||||
return attachment; |
||||
} |
||||
|
||||
public void setAttachment(String attachment) { |
||||
this.attachment = attachment; |
||||
} |
||||
|
||||
public String getContentType() { |
||||
return contentType; |
||||
} |
||||
|
||||
public void setContentType(String contentType) { |
||||
this.contentType = contentType; |
||||
} |
||||
|
||||
public String getUserAgent() { |
||||
return userAgent; |
||||
} |
||||
|
||||
public void setUserAgent(String userAgent) { |
||||
this.userAgent = userAgent; |
||||
} |
||||
|
||||
public boolean isChunked() { |
||||
return isChunked; |
||||
} |
||||
|
||||
public void setChunked(boolean chunked) { |
||||
isChunked = chunked; |
||||
} |
||||
|
||||
public CookieManager getCookieManager() { |
||||
return cookieManager; |
||||
} |
||||
|
||||
public void setCookieManager(CookieManager cookieManager) { |
||||
this.cookieManager = cookieManager; |
||||
} |
||||
|
||||
public Proxy getProxy() { |
||||
return proxy; |
||||
} |
||||
|
||||
public void setProxy(Proxy proxy) { |
||||
this.proxy = proxy; |
||||
} |
||||
|
||||
public Map<String, String> getHeaders() { |
||||
return headers; |
||||
} |
||||
|
||||
public void setHeaders(Map<String, String> headers) { |
||||
this.headers = headers; |
||||
} |
||||
|
||||
public String getCharSet() { |
||||
return charSet; |
||||
} |
||||
|
||||
public void setCharSet(String charSet) { |
||||
this.charSet = charSet; |
||||
} |
||||
|
||||
public RequestEnum getRequestEnum() { |
||||
return requestEnum; |
||||
} |
||||
|
||||
public void setRequestEnum(RequestEnum requestEnum) { |
||||
this.requestEnum = requestEnum; |
||||
} |
||||
|
||||
public boolean isUseServerFileName() { |
||||
return useServerFileName; |
||||
} |
||||
|
||||
public void setUseServerFileName(boolean useServerFileName) { |
||||
this.useServerFileName = useServerFileName; |
||||
} |
||||
|
||||
public String getRedirectUrl() { |
||||
return redirectUrl; |
||||
} |
||||
|
||||
public void setRedirectUrl(String redirectUrl) { |
||||
this.redirectUrl = redirectUrl; |
||||
} |
||||
|
||||
public Map<String, String> getParams() { |
||||
return params; |
||||
} |
||||
|
||||
public void setParams(Map<String, String> params) { |
||||
this.params = params; |
||||
} |
||||
} |
@ -1,26 +0,0 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package com.arialyy.aria.core.inf; |
||||
|
||||
/** |
||||
* Created by lyy on 2017/9/5. |
||||
*/ |
||||
public abstract class AbsGroupTaskEntity<ENTITY extends AbsGroupEntity> extends AbsTaskEntity<ENTITY>{ |
||||
@Override public ENTITY getEntity() { |
||||
return null; |
||||
} |
||||
} |
@ -1,286 +0,0 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.inf; |
||||
|
||||
import com.arialyy.aria.core.FtpUrlEntity; |
||||
import com.arialyy.aria.core.common.RequestEnum; |
||||
import com.arialyy.aria.orm.DbEntity; |
||||
import com.arialyy.aria.orm.annotation.Ignore; |
||||
import java.net.CookieManager; |
||||
import java.net.HttpCookie; |
||||
import java.net.Proxy; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by lyy on 2017/2/23. |
||||
* 所有任务实体的父类 |
||||
*/ |
||||
public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity { |
||||
/** |
||||
* HTTP单任务载 |
||||
*/ |
||||
public static final int D_HTTP = 0x11; |
||||
/** |
||||
* HTTP任务组下载 |
||||
*/ |
||||
public static final int DG_HTTP = 0x12; |
||||
|
||||
/** |
||||
* FTP单文件下载 |
||||
*/ |
||||
public static final int D_FTP = 0x13; |
||||
/** |
||||
* FTP文件夹下载,为避免登录过多,子任务由单线程进行处理 |
||||
*/ |
||||
public static final int D_FTP_DIR = 0x14; |
||||
|
||||
/** |
||||
* HTTP单文件上传 |
||||
*/ |
||||
public static final int U_HTTP = 0xA1; |
||||
/** |
||||
* FTP单文件上传 |
||||
*/ |
||||
public static final int U_FTP = 0xA2; |
||||
|
||||
@Ignore private CookieManager cookieManager; |
||||
|
||||
/** |
||||
* 账号和密码 |
||||
*/ |
||||
@Ignore private FtpUrlEntity urlEntity; |
||||
|
||||
/** |
||||
* 刷新信息 {@code true} 重新刷新下载信息 |
||||
*/ |
||||
@Ignore private boolean refreshInfo = false; |
||||
|
||||
/** |
||||
* 是否是新任务,{@code true} 新任务 |
||||
*/ |
||||
@Ignore private boolean isNewTask = false; |
||||
|
||||
/** |
||||
* 请求参数 |
||||
*/ |
||||
@Ignore private Map<String, String> params; |
||||
|
||||
/** |
||||
* 任务状态,和Entity的state同步 |
||||
*/ |
||||
private int state = IEntity.STATE_WAIT; |
||||
|
||||
/** |
||||
* 请求类型 |
||||
* {@link AbsTaskEntity#D_HTTP}、{@link AbsTaskEntity#D_FTP}、{@link AbsTaskEntity#D_FTP_DIR}。。。 |
||||
*/ |
||||
private int requestType = D_HTTP; |
||||
|
||||
/** |
||||
* http 请求头 |
||||
*/ |
||||
private Map<String, String> headers = new HashMap<>(); |
||||
|
||||
/** |
||||
* 字符编码,默认为"utf-8" |
||||
*/ |
||||
private String charSet = "utf-8"; |
||||
|
||||
/** |
||||
* 网络请求类型 |
||||
*/ |
||||
private RequestEnum requestEnum = RequestEnum.GET; |
||||
|
||||
/** |
||||
* 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment; filename="filename.jpg"} |
||||
* {@code true} 使用 |
||||
*/ |
||||
private boolean useServerFileName = false; |
||||
|
||||
/** |
||||
* 重定向链接 |
||||
*/ |
||||
private String redirectUrl = ""; |
||||
|
||||
/** |
||||
* 删除任务时,是否删除已下载完成的文件 |
||||
* 未完成的任务,不管true还是false,都会删除文件 |
||||
* {@code true} 删除任务数据库记录,并且删除已经下载完成的文件 |
||||
* {@code false} 如果任务已经完成,只删除任务数据库记录 |
||||
*/ |
||||
@Ignore private boolean removeFile = false; |
||||
|
||||
/** |
||||
* 是否支持断点, {@code true} 为支持断点 |
||||
*/ |
||||
private boolean isSupportBP = true; |
||||
|
||||
/** |
||||
* 状态码 |
||||
*/ |
||||
private int code; |
||||
|
||||
@Ignore private Proxy proxy; |
||||
|
||||
public abstract ENTITY getEntity(); |
||||
|
||||
public CookieManager getCookieManager() { |
||||
return cookieManager; |
||||
} |
||||
|
||||
public void setCookieManager(CookieManager cookieManager) { |
||||
this.cookieManager = cookieManager; |
||||
} |
||||
|
||||
/** |
||||
* 获取任务下载状态 |
||||
* |
||||
* @return {@link IEntity} |
||||
*/ |
||||
public int getState() { |
||||
return getEntity().getState(); |
||||
} |
||||
|
||||
public Proxy getProxy() { |
||||
return proxy; |
||||
} |
||||
|
||||
public void setProxy(Proxy proxy) { |
||||
this.proxy = proxy; |
||||
} |
||||
|
||||
public abstract String getKey(); |
||||
|
||||
public abstract void setKey(String key); |
||||
|
||||
@Override public void update() { |
||||
if (getEntity() != null) { |
||||
getEntity().update(); |
||||
} |
||||
super.update(); |
||||
} |
||||
|
||||
public FtpUrlEntity getUrlEntity() { |
||||
return urlEntity; |
||||
} |
||||
|
||||
public void setUrlEntity(FtpUrlEntity urlEntity) { |
||||
this.urlEntity = urlEntity; |
||||
} |
||||
|
||||
public boolean isRefreshInfo() { |
||||
return refreshInfo; |
||||
} |
||||
|
||||
public void setRefreshInfo(boolean refreshInfo) { |
||||
this.refreshInfo = refreshInfo; |
||||
} |
||||
|
||||
public boolean isNewTask() { |
||||
return isNewTask; |
||||
} |
||||
|
||||
public void setNewTask(boolean newTask) { |
||||
isNewTask = newTask; |
||||
} |
||||
|
||||
public void setState(int state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
public int getRequestType() { |
||||
return requestType; |
||||
} |
||||
|
||||
public void setRequestType(int requestType) { |
||||
this.requestType = requestType; |
||||
} |
||||
|
||||
public Map<String, String> getHeaders() { |
||||
return headers; |
||||
} |
||||
|
||||
public void setHeaders(Map<String, String> headers) { |
||||
this.headers = headers; |
||||
} |
||||
|
||||
public String getCharSet() { |
||||
return charSet; |
||||
} |
||||
|
||||
public void setCharSet(String charSet) { |
||||
this.charSet = charSet; |
||||
} |
||||
|
||||
public RequestEnum getRequestEnum() { |
||||
return requestEnum; |
||||
} |
||||
|
||||
public void setRequestEnum(RequestEnum requestEnum) { |
||||
this.requestEnum = requestEnum; |
||||
} |
||||
|
||||
public boolean isUseServerFileName() { |
||||
return useServerFileName; |
||||
} |
||||
|
||||
public void setUseServerFileName(boolean useServerFileName) { |
||||
this.useServerFileName = useServerFileName; |
||||
} |
||||
|
||||
public String getRedirectUrl() { |
||||
return redirectUrl; |
||||
} |
||||
|
||||
public void setRedirectUrl(String redirectUrl) { |
||||
this.redirectUrl = redirectUrl; |
||||
} |
||||
|
||||
public boolean isRemoveFile() { |
||||
return removeFile; |
||||
} |
||||
|
||||
public void setRemoveFile(boolean removeFile) { |
||||
this.removeFile = removeFile; |
||||
} |
||||
|
||||
public boolean isSupportBP() { |
||||
return isSupportBP; |
||||
} |
||||
|
||||
public void setSupportBP(boolean supportBP) { |
||||
isSupportBP = supportBP; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(int code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public Map<String, String> getParams() { |
||||
return params; |
||||
} |
||||
|
||||
public void setParams(Map<String, String> params) { |
||||
this.params = params; |
||||
} |
||||
} |
@ -0,0 +1,151 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.inf; |
||||
|
||||
import com.arialyy.aria.core.common.ftp.FtpTaskDelegate; |
||||
import com.arialyy.aria.core.common.http.HttpTaskDelegate; |
||||
|
||||
/** |
||||
* Created by lyy on 2017/2/23. 所有任务实体的父类 |
||||
*/ |
||||
public abstract class AbsTaskWrapper<ENTITY extends AbsEntity> |
||||
implements ITaskWrapper<ENTITY> { |
||||
|
||||
private HttpTaskDelegate httpTaskDelegate; |
||||
private FtpTaskDelegate ftpTaskDelegate; |
||||
|
||||
/** |
||||
* 刷新信息 {@code true} 重新刷新下载信息 |
||||
*/ |
||||
private boolean refreshInfo = false; |
||||
|
||||
/** |
||||
* 任务状态,和Entity的state同步 |
||||
*/ |
||||
private int state = IEntity.STATE_WAIT; |
||||
|
||||
/** |
||||
* 是否是新任务,{@code true} 新任务 |
||||
*/ |
||||
private boolean isNewTask = false; |
||||
|
||||
/** |
||||
* 请求类型 {@link AbsTaskWrapper#D_HTTP}、{@link AbsTaskWrapper#D_FTP}、{@link |
||||
* AbsTaskWrapper#D_FTP_DIR}。。。 |
||||
*/ |
||||
private int requestType = D_HTTP; |
||||
|
||||
/** |
||||
* 删除任务时,是否删除已下载完成的文件 未完成的任务,不管true还是false,都会删除文件 {@code true} 删除任务数据库记录,并且删除已经下载完成的文件 {@code |
||||
* false} 如果任务已经完成,只删除任务数据库记录 |
||||
*/ |
||||
private boolean removeFile = false; |
||||
|
||||
/** |
||||
* 是否支持断点, {@code true} 为支持断点 |
||||
*/ |
||||
private boolean isSupportBP = true; |
||||
|
||||
/** |
||||
* 状态码 |
||||
*/ |
||||
private int code; |
||||
|
||||
public abstract String getKey(); |
||||
|
||||
public abstract void setKey(String key); |
||||
|
||||
/** |
||||
* 设置或获取HTTP任务相关参数 |
||||
*/ |
||||
public HttpTaskDelegate asHttp() { |
||||
if (httpTaskDelegate == null) { |
||||
httpTaskDelegate = new HttpTaskDelegate(); |
||||
} |
||||
return httpTaskDelegate; |
||||
} |
||||
|
||||
/** |
||||
* 设置或获取FTP任务相关参数 |
||||
*/ |
||||
public FtpTaskDelegate asFtp() { |
||||
if (ftpTaskDelegate == null) { |
||||
ftpTaskDelegate = new FtpTaskDelegate(); |
||||
} |
||||
return ftpTaskDelegate; |
||||
} |
||||
|
||||
/** |
||||
* 获取任务下载状态 |
||||
* |
||||
* @return {@link IEntity} |
||||
*/ |
||||
public int getState() { |
||||
return getEntity().getState(); |
||||
} |
||||
|
||||
public boolean isRefreshInfo() { |
||||
return refreshInfo; |
||||
} |
||||
|
||||
public void setRefreshInfo(boolean refreshInfo) { |
||||
this.refreshInfo = refreshInfo; |
||||
} |
||||
|
||||
public boolean isNewTask() { |
||||
return isNewTask; |
||||
} |
||||
|
||||
public void setNewTask(boolean newTask) { |
||||
isNewTask = newTask; |
||||
} |
||||
|
||||
public void setState(int state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
public int getRequestType() { |
||||
return requestType; |
||||
} |
||||
|
||||
public void setRequestType(int requestType) { |
||||
this.requestType = requestType; |
||||
} |
||||
|
||||
public boolean isRemoveFile() { |
||||
return removeFile; |
||||
} |
||||
|
||||
public void setRemoveFile(boolean removeFile) { |
||||
this.removeFile = removeFile; |
||||
} |
||||
|
||||
public boolean isSupportBP() { |
||||
return isSupportBP; |
||||
} |
||||
|
||||
public void setSupportBP(boolean supportBP) { |
||||
isSupportBP = supportBP; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(int code) { |
||||
this.code = code; |
||||
} |
||||
} |
@ -0,0 +1,53 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.inf; |
||||
|
||||
import com.arialyy.aria.core.download.DownloadGroupEntity; |
||||
|
||||
/** |
||||
* 组合任务实体包裹器,用于加载和任务相关的参数,如:组合任务实体{@link DownloadGroupEntity}、header头部 |
||||
*/ |
||||
public interface ITaskWrapper<ENTITY extends AbsEntity> { |
||||
|
||||
/** |
||||
* HTTP单任务载 |
||||
*/ |
||||
int D_HTTP = 0x11; |
||||
/** |
||||
* HTTP任务组下载 |
||||
*/ |
||||
int DG_HTTP = 0x12; |
||||
|
||||
/** |
||||
* FTP单文件下载 |
||||
*/ |
||||
int D_FTP = 0x13; |
||||
/** |
||||
* FTP文件夹下载,为避免登录过多,子任务由单线程进行处理 |
||||
*/ |
||||
int D_FTP_DIR = 0x14; |
||||
|
||||
/** |
||||
* HTTP单文件上传 |
||||
*/ |
||||
int U_HTTP = 0xA1; |
||||
/** |
||||
* FTP单文件上传 |
||||
*/ |
||||
int U_FTP = 0xA2; |
||||
|
||||
ENTITY getEntity(); |
||||
} |
@ -0,0 +1,57 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.upload; |
||||
|
||||
import com.arialyy.aria.core.inf.AbsTaskWrapper; |
||||
|
||||
/** |
||||
* Created by lyy on 2017/2/9. 上传任务实体 |
||||
*/ |
||||
public class UTaskWrapper extends AbsTaskWrapper<UploadEntity> { |
||||
|
||||
private UploadEntity entity; |
||||
|
||||
private String filePath; |
||||
|
||||
private String key; |
||||
|
||||
public UTaskWrapper() { |
||||
} |
||||
|
||||
@Override public UploadEntity getEntity() { |
||||
return entity; |
||||
} |
||||
|
||||
@Override public String getKey() { |
||||
return key; |
||||
} |
||||
|
||||
public void setEntity(UploadEntity entity) { |
||||
this.entity = entity; |
||||
} |
||||
|
||||
public String getFilePath() { |
||||
return filePath; |
||||
} |
||||
|
||||
public void setFilePath(String filePath) { |
||||
this.filePath = filePath; |
||||
} |
||||
|
||||
public void setKey(String key) { |
||||
this.key = key; |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue