Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/android/configurators/ProxyConfigurator.java

Issue 4705284891082752: Proxy configurators (Closed)
Patch Set: Created Aug. 11, 2014, 12:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/org/adblockplus/android/configurators/ProxyConfigurator.java
diff --git a/src/org/adblockplus/android/configurators/ProxyConfigurator.java b/src/org/adblockplus/android/configurators/ProxyConfigurator.java
new file mode 100644
index 0000000000000000000000000000000000000000..a045e059b1213857ecd337c8f31aac98aef9e9b6
--- /dev/null
+++ b/src/org/adblockplus/android/configurators/ProxyConfigurator.java
@@ -0,0 +1,78 @@
+/*
+ * This file is part of Adblock Plus <http://adblockplus.org/>,
+ * Copyright (C) 2006-2014 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus 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 Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.adblockplus.android.configurators;
+
+import java.net.InetAddress;
+
+/**
+ * Interface for different proxy registration types. Constructor must always succeed, do any work that may fail in
+ * {@link ProxyConfigurator#initialize()}.
+ *
+ * @author rjeschke
+ */
+public interface ProxyConfigurator
+{
+ /**
+ * Initializes this {@code ProxyConfigurator}. This function will normally get called only once.
+ *
+ * @return {@code true} if initialization succeeded
+ */
+ public boolean initialize();
+
+ /**
+ * Registers the proxy. May get called multiple times (e.g. for enable/disable).
+ *
+ * @param address
+ * The address ...
+ * @param port
+ * ... and port to bind to
+ * @return {@code true} if registration succeeded
+ */
+ public boolean registerProxy(InetAddress address, int port);
+
+ /**
+ * Unregisters the proxy. May get called multiple times (e.g. for enable/disable).
+ */
+ public void unregisterProxy();
+
+ /**
+ * Shuts down this configurator, normally called on application exit to perform any clean up.
+ *
+ * @param context
+ * Service/Application context
+ */
+ public void shutdown();
+
+ /**
+ * @return {@code true} if we actually registered the proxy
+ */
+ public boolean isRegistered();
+
+ /**
+ * Returning {@code true} here will allow the configurator to succeed on {@link #initialize()} and fail on {@link #registerProxy(InetAddress, int)}.
+ * This situation could arise for the CyanogenMod and iptables case.
+ *
+ * @return {@code true} to disable auto-advancing in configurator list
+ */
+ public boolean isSticky();
+
+ /**
+ * @return the registration type of this configurator.
+ */
+ public ProxyRegistrationType getType();
+}

Powered by Google App Engine
This is Rietveld