aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/org/connectbot/data
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-09-11 13:09:13 -0700
committerKenny Root <kenny@the-b.org>2015-09-11 13:09:15 -0700
commit0310e8e9f19338f470031a737bfdaa6f848edcae (patch)
tree2ada3f5b5d5bb4efd914cbdffd66c3e9d8e84b41 /app/src/main/java/org/connectbot/data
parentb90e0af0e1a7aa4c1653390d43326604346fe90d (diff)
downloadconnectbot-0310e8e9f19338f470031a737bfdaa6f848edcae.tar.gz
connectbot-0310e8e9f19338f470031a737bfdaa6f848edcae.tar.bz2
connectbot-0310e8e9f19338f470031a737bfdaa6f848edcae.zip
Add interfaces for HostStorage and ColorStorage
An attempt to help with testing.
Diffstat (limited to 'app/src/main/java/org/connectbot/data')
-rw-r--r--app/src/main/java/org/connectbot/data/ColorStorage.java31
-rw-r--r--app/src/main/java/org/connectbot/data/HostStorage.java89
2 files changed, 120 insertions, 0 deletions
diff --git a/app/src/main/java/org/connectbot/data/ColorStorage.java b/app/src/main/java/org/connectbot/data/ColorStorage.java
new file mode 100644
index 0000000..eb3d2d2
--- /dev/null
+++ b/app/src/main/java/org/connectbot/data/ColorStorage.java
@@ -0,0 +1,31 @@
+/*
+ * ConnectBot: simple, powerful, open-source SSH client for Android
+ * Copyright 2015 Kenny Root, Jeffrey Sharkey
+ *
+ * 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 org.connectbot.data;
+
+/**
+ * Created by kroot on 9/11/15.
+ */
+public interface ColorStorage {
+ public int[] getColorsForScheme(int colorScheme);
+
+ public void setGlobalColor(int mCurrentColor, int value);
+
+ public int[] getDefaultColorsForScheme(int colorScheme);
+
+ public void setDefaultColorsForScheme(int mColorScheme, int mDefaultColor, int mDefaultColor1);
+}
diff --git a/app/src/main/java/org/connectbot/data/HostStorage.java b/app/src/main/java/org/connectbot/data/HostStorage.java
new file mode 100644
index 0000000..9d4fc7d
--- /dev/null
+++ b/app/src/main/java/org/connectbot/data/HostStorage.java
@@ -0,0 +1,89 @@
+/*
+ * ConnectBot: simple, powerful, open-source SSH client for Android
+ * Copyright 2015 Kenny Root, Jeffrey Sharkey
+ *
+ * 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 org.connectbot.data;
+
+import java.util.List;
+import java.util.Map;
+
+import org.connectbot.bean.HostBean;
+import org.connectbot.bean.PortForwardBean;
+
+import com.trilead.ssh2.KnownHosts;
+
+import android.support.annotation.VisibleForTesting;
+
+/**
+ * Interface that defines the operation used to interact with the storage layer.
+ */
+public interface HostStorage {
+ /**
+ * Resets the database during testing.
+ */
+ @VisibleForTesting
+ void resetDatabase();
+
+ /**
+ * Finds the host that is represented by the given selection.
+ * @param selection all fields to be considered
+ * @return the matching host
+ */
+ HostBean findHost(Map<String, String> selection);
+
+ /**
+ * Deletes the given {@code host} from the storage layer.
+ */
+ void deleteHost(HostBean host);
+
+ /**
+ * Saves the given {@code host} to the storage layer.
+ */
+ HostBean saveHost(HostBean host);
+
+ /**
+ * Returns a list of all the hosts as a list of {@link HostBean}.
+ * @param sortedByColor if hosts should be grouped by color.
+ */
+ List<HostBean> getHosts(boolean sortedByColor);
+
+ /**
+ * Updates the last connected time for {@code host}.
+ */
+ void touchHost(HostBean host);
+
+ /**
+ * Finds a {@link HostBean} based on the given {@code hostId}.
+ */
+ HostBean findHostById(long hostId);
+
+ /**
+ * Returns the list of known hosts.
+ *
+ * @see #saveKnownHost(String, int, String, byte[])
+ */
+ KnownHosts getKnownHosts();
+
+ /**
+ * Adds a known host to the database for later retrieval using {@link #getKnownHosts()}.
+ */
+ void saveKnownHost(String hostname, int port, String serverHostKeyAlgorithm, byte[] serverHostKey);
+
+ /**
+ * Return all port forwards for the given {@code host}.
+ */
+ PortForwardBean[] getPortForwardsForHost(HostBean host);
+}