-
Notifications
You must be signed in to change notification settings - Fork 13
Remember openkeychain key #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
5a734b4
d985951
69a1cfa
d632e7c
80376e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,15 +12,19 @@ public class Server { | |
| String _name; | ||
| String _url; | ||
| String _apgKey; | ||
| String _openpgpgKey; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pgpg? Looks like a nice combination of PGP and GPG, but please only use one ^^
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you reuse apgKey? (did we have that question before :O ) |
||
| boolean _saveKey; | ||
|
|
||
| public Server(String name, String url) { | ||
| this(name, url, ""); | ||
| this(name, url, "", "", false); | ||
| } | ||
|
|
||
| public Server(String name, String url, String apgKey) { | ||
| public Server(String name, String url, String apgKey, String openpgpgKey, boolean saveKey) { | ||
| _name = name; | ||
| _url = url; | ||
| _apgKey = apgKey; | ||
| _openpgpgKey = openpgpgKey; | ||
| _saveKey = saveKey; | ||
| } | ||
|
|
||
| public String name() { | ||
|
|
@@ -35,6 +39,14 @@ public String apgKey() { | |
| return _apgKey; | ||
| } | ||
|
|
||
| public String openpgpgKey() { | ||
| return _openpgpgKey; | ||
| } | ||
|
|
||
| public boolean saveKey() { | ||
| return _saveKey; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| _name = name; | ||
| } | ||
|
|
@@ -47,6 +59,18 @@ public void setApgKey(String apgKey) { | |
| _apgKey = apgKey; | ||
| } | ||
|
|
||
| public void setOpenpgpgKey(String openpgpgKey) { | ||
| _openpgpgKey = openpgpgKey; | ||
| } | ||
|
|
||
| public void keepKey() { | ||
| _saveKey = true; | ||
| } | ||
|
|
||
| public void forgetKey() { | ||
| _saveKey = false; | ||
| } | ||
|
|
||
| public boolean isEmpty() { | ||
| return _name == "" && _url == ""; | ||
| } | ||
|
|
@@ -59,8 +83,8 @@ public static Server deserialize(String serialized) { | |
| return new Server(parts[0], parts[1]); | ||
| } | ||
|
|
||
| if (parts.length == 3) { | ||
| return new Server(parts[0], parts[1], parts[2]); | ||
| if (parts.length == 5) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do not change things in this function. It is only here to support config loading for configs generated by older versions of the app |
||
| return new Server(parts[0], parts[1], parts[2], parts[3], Boolean.parseBoolean(parts[4])); | ||
| } | ||
|
|
||
| return null; | ||
|
|
@@ -73,6 +97,10 @@ public JSONObject serializeJSON() { | |
| ret.put("name", _name); | ||
| ret.put("url", _url); | ||
| ret.put("apgKey", _apgKey); | ||
| if (saveKey()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use private variables where possible, as function calls are slower in most languages. |
||
| ret.put("openpgpgKey", _openpgpgKey); | ||
| } | ||
| ret.put("saveKey", _saveKey); | ||
| } catch (JSONException e) { | ||
| // should not happen as we just serialize a bunch of strings | ||
| return null; | ||
|
|
@@ -86,8 +114,12 @@ public static Server deserializeJSON(JSONObject obj) throws JSONException { | |
| String name = obj.getString("name"); | ||
| String url = obj.getString("url"); | ||
| String apgKey = obj.getString("apgKey"); | ||
|
|
||
| return new Server(name, url, apgKey); | ||
| boolean saveTheKey = obj.getBoolean("saveKey"); | ||
| String openpgpgKey = ""; | ||
| if (saveTheKey) { | ||
| openpgpgKey = obj.getString("openpgpgKey"); | ||
| } | ||
| return new Server(name, url, apgKey, openpgpgKey, saveTheKey); | ||
| } catch (JSONException e) { | ||
| // should not happen as we just serialize a bunch of strings | ||
| throw e; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename to
openPGPKeyIDeverywhereThis way its is clearer what that variable is ^^