mirror of https://github.com/kurisufriend/Clover
parent
aa4f96cacf
commit
f8c182bba5
@ -0,0 +1,28 @@ |
|||||||
|
/* |
||||||
|
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||||
|
* Copyright (C) 2014 Floens |
||||||
|
* |
||||||
|
* This program 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. |
||||||
|
* |
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.floens.chan.core.model; |
||||||
|
|
||||||
|
|
||||||
|
public interface BoardReference { |
||||||
|
/** |
||||||
|
* Get the Board object that this model references. |
||||||
|
* |
||||||
|
* @return a {@link Board} |
||||||
|
*/ |
||||||
|
Board getBoard(); |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
/* |
||||||
|
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||||
|
* Copyright (C) 2014 Floens |
||||||
|
* |
||||||
|
* This program 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. |
||||||
|
* |
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.floens.chan.core.site.http; |
||||||
|
|
||||||
|
|
||||||
|
import org.floens.chan.core.model.Post; |
||||||
|
import org.floens.chan.core.model.SavedReply; |
||||||
|
import org.floens.chan.core.site.Site; |
||||||
|
|
||||||
|
public class DeleteRequest { |
||||||
|
public final Site site; |
||||||
|
public final Post post; |
||||||
|
public final SavedReply savedReply; |
||||||
|
public final boolean imageOnly; |
||||||
|
|
||||||
|
public DeleteRequest(Site site, Post post, SavedReply savedReply, boolean imageOnly) { |
||||||
|
this.site = site; |
||||||
|
this.post = post; |
||||||
|
this.savedReply = savedReply; |
||||||
|
this.imageOnly = imageOnly; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
/* |
||||||
|
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||||
|
* Copyright (C) 2014 Floens |
||||||
|
* |
||||||
|
* This program 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. |
||||||
|
* |
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.floens.chan.core.site.http; |
||||||
|
|
||||||
|
|
||||||
|
public class DeleteResponse { |
||||||
|
public boolean deleted; |
||||||
|
public String errorMessage; |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
/* |
||||||
|
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||||
|
* Copyright (C) 2014 Floens |
||||||
|
* |
||||||
|
* This program 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. |
||||||
|
* |
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.floens.chan.core.site.http; |
||||||
|
|
||||||
|
|
||||||
|
import org.floens.chan.core.di.UserAgentProvider; |
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
import javax.inject.Inject; |
||||||
|
import javax.inject.Singleton; |
||||||
|
|
||||||
|
import okhttp3.OkHttpClient; |
||||||
|
import okhttp3.Request; |
||||||
|
|
||||||
|
/** |
||||||
|
* Manages the {@link HttpCall} executions. |
||||||
|
*/ |
||||||
|
@Singleton |
||||||
|
public class HttpCallManager { |
||||||
|
private static final int TIMEOUT = 30000; |
||||||
|
|
||||||
|
private UserAgentProvider userAgentProvider; |
||||||
|
private OkHttpClient client; |
||||||
|
|
||||||
|
@Inject |
||||||
|
public HttpCallManager(UserAgentProvider userAgentProvider) { |
||||||
|
this.userAgentProvider = userAgentProvider; |
||||||
|
client = new OkHttpClient.Builder() |
||||||
|
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS) |
||||||
|
.readTimeout(TIMEOUT, TimeUnit.MILLISECONDS) |
||||||
|
.writeTimeout(TIMEOUT, TimeUnit.MILLISECONDS) |
||||||
|
.build(); |
||||||
|
} |
||||||
|
|
||||||
|
public void makeHttpCall(HttpCall httpCall, HttpCall.HttpCallback<? extends HttpCall> callback) { |
||||||
|
httpCall.setCallback(callback); |
||||||
|
|
||||||
|
Request.Builder requestBuilder = new Request.Builder(); |
||||||
|
|
||||||
|
httpCall.setup(requestBuilder); |
||||||
|
|
||||||
|
requestBuilder.header("User-Agent", userAgentProvider.getUserAgent()); |
||||||
|
Request request = requestBuilder.build(); |
||||||
|
|
||||||
|
client.newCall(request).enqueue(httpCall); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
/* |
||||||
|
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||||
|
* Copyright (C) 2014 Floens |
||||||
|
* |
||||||
|
* This program 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. |
||||||
|
* |
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.floens.chan.core.site.http; |
||||||
|
|
||||||
|
|
||||||
|
import org.floens.chan.core.site.Site; |
||||||
|
|
||||||
|
public class LoginRequest { |
||||||
|
public final Site site; |
||||||
|
public final String user; |
||||||
|
public final String pass; |
||||||
|
|
||||||
|
public LoginRequest(Site site, String user, String pass) { |
||||||
|
this.site = site; |
||||||
|
this.user = user; |
||||||
|
this.pass = pass; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
/* |
||||||
|
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||||
|
* Copyright (C) 2014 Floens |
||||||
|
* |
||||||
|
* This program 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. |
||||||
|
* |
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.floens.chan.core.site.http; |
||||||
|
|
||||||
|
|
||||||
|
public class LoginResponse { |
||||||
|
public boolean success; |
||||||
|
public String message; |
||||||
|
|
||||||
|
// TODO(multi-site) make this a cookie abstraction
|
||||||
|
public String token; |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
/* |
||||||
|
* Clover - 4chan browser https://github.com/Floens/Clover/
|
||||||
|
* Copyright (C) 2014 Floens |
||||||
|
* |
||||||
|
* This program 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. |
||||||
|
* |
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/ |
||||||
|
package org.floens.chan.core.site.http; |
||||||
|
|
||||||
|
import org.floens.chan.core.site.Site; |
||||||
|
|
||||||
|
/** |
||||||
|
* Generic response for {@link Site#post(Reply, Site.PostListener)} that the reply layout uses. |
||||||
|
*/ |
||||||
|
public class ReplyResponse { |
||||||
|
/** |
||||||
|
* {@code true} if the post when through, {@code false} otherwise. |
||||||
|
*/ |
||||||
|
public boolean posted; |
||||||
|
|
||||||
|
/** |
||||||
|
* Error message used to show to the user if {@link #posted} is {@code false}. |
||||||
|
* <p>Optional |
||||||
|
*/ |
||||||
|
public String errorMessage; |
||||||
|
|
||||||
|
// TODO(multi-site)
|
||||||
|
public int threadNo; |
||||||
|
public int postNo; |
||||||
|
public String password; |
||||||
|
public boolean probablyBanned; |
||||||
|
} |
Loading…
Reference in new issue